Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Lou-Kamades committed Dec 6, 2023
1 parent 27a81e2 commit 59daa80
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
3 changes: 2 additions & 1 deletion lib/client/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,8 @@ impl MangoGroupContext {
.is_err()
|| state
.check_staleness(bank.name(), &bank.oracle_config, now_slot)
.is_err()) && bank.fallback_oracle != Pubkey::default()
.is_err())
&& bank.fallback_oracle != Pubkey::default()
{
fallbacks.push(bank.fallback_oracle);
}
Expand Down
2 changes: 1 addition & 1 deletion ts/client/src/accounts/bank.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export class Bank implements BankForHealth {
obj.maintWeightShiftAssetTarget,
obj.maintWeightShiftLiabTarget,
obj.depositLimit,
obj.fallbackOracle
obj.fallbackOracle,
);
}

Expand Down
38 changes: 26 additions & 12 deletions ts/client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ export enum FallbackOracleMode {
}

export type FallbackOracleOptions = {
mode: FallbackOracleMode,
fixedOracles: PublicKey[]
}
mode: FallbackOracleMode;
fixedOracles: PublicKey[];
};

export type IdsSource = 'api' | 'static' | 'get-program-accounts';

Expand All @@ -137,8 +137,8 @@ export class MangoClient {
private openbookFeesToDao: boolean;
private prependedGlobalAdditionalInstructions: TransactionInstruction[] = [];
private fallbackOracleOptions: FallbackOracleOptions = {
mode: FallbackOracleMode.None,
fixedOracles: []
mode: FallbackOracleMode.None,
fixedOracles: [],
};

constructor(
Expand Down Expand Up @@ -4686,10 +4686,20 @@ export class MangoClient {
case FallbackOracleMode.None:
break;
case FallbackOracleMode.Fixed:
healthRemainingAccounts.push(...this.fallbackOracleOptions.fixedOracles)
healthRemainingAccounts.push(
...this.fallbackOracleOptions.fixedOracles,
);
break;
case FallbackOracleMode.AllAvailable:
healthRemainingAccounts.push(
...mintInfos.filter((mintInfo) => mintInfo.fallbackOracle.toBase58() != PublicKey.default.toBase58()).map(m => m.fallbackOracle))
...mintInfos
.filter(
(mintInfo) =>
mintInfo.fallbackOracle.toBase58() !=
PublicKey.default.toBase58(),
)
.map((m) => m.fallbackOracle),
);
}

return healthRemainingAccounts;
Expand Down Expand Up @@ -4833,14 +4843,18 @@ export class MangoClient {
* Checks all oracles and returns the PublicKeys of any configured fallback oracles if the primary oracle is stale or outside the confidence interval.
* This function assumes that the group has Banks.
*
*/
public async fetchFallbacksForStaleOracles(group: Group): Promise<PublicKey[]> {
await group.reloadBankOraclePrices(this)
*/
public async fetchFallbacksForStaleOracles(
group: Group,
): Promise<PublicKey[]> {
await group.reloadBankOraclePrices(this);
const banks: Bank[][] = Array.from(
group.banksMapByMint,
([, value]) => value,
);
const staleBanks = banks.filter((b) => b[0].isOracleStaleOrUnconfident).map((s) => s[0].fallbackOracle);
return staleBanks
const staleBanks = banks
.filter((b) => b[0].isOracleStaleOrUnconfident)
.map((s) => s[0].fallbackOracle);
return staleBanks;
}
}

0 comments on commit 59daa80

Please sign in to comment.