Skip to content

Commit

Permalink
ts sb crank: Fix types
Browse files Browse the repository at this point in the history
Signed-off-by: microwavedcola1 <[email protected]>
  • Loading branch information
microwavedcola1 committed Aug 30, 2024
1 parent 5e3e364 commit 1b6aef5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 8 additions & 2 deletions ts/client/scripts/sb-on-demand-crank-utils.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { PublicKey } from '@solana/web3.js';
import { TokenIndex } from '../src/accounts/bank';
import { Group } from '../src/accounts/group';
import { PerpMarketIndex } from '../src/accounts/perp';
import { ZERO_I80F48 } from '../src/numbers/I80F48';

export interface OraclesFromMangoGroupInterface {
oraclePk: PublicKey;
name: string;
fallbackForOracle: PublicKey | undefined;
tokenIndex: number | undefined; // todo remove
perpMarketIndex: number | undefined;
tokenIndex: TokenIndex | undefined; // todo remove
perpMarketIndex: PerpMarketIndex | undefined;
isOracleStaleOrUnconfident: boolean;
// todo: add tier when program mango-v4 24.3 is released
}

Expand Down Expand Up @@ -37,6 +40,7 @@ export function getOraclesForMangoGroup(
fallbackForOracle: undefined,
tokenIndex: b[0].tokenIndex,
perpMarketIndex: undefined,
isOracleStaleOrUnconfident: false,
};
});

Expand All @@ -50,6 +54,7 @@ export function getOraclesForMangoGroup(
fallbackForOracle: undefined,
tokenIndex: undefined,
perpMarketIndex: pM.perpMarketIndex,
isOracleStaleOrUnconfident: false,
};
});

Expand All @@ -72,6 +77,7 @@ export function getOraclesForMangoGroup(
fallbackForOracle: b[0].oracle,
tokenIndex: b[0].tokenIndex,
perpMarketIndex: undefined,
isOracleStaleOrUnconfident: false,
};
})
.filter((item) => !item.oraclePk.equals(PublicKey.default));
Expand Down
8 changes: 5 additions & 3 deletions ts/client/scripts/sb-on-demand-crank.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import {
} from '@solana/web3.js';
import {
CrossbarClient,
ON_DEMAND_MAINNET_PID,
PullFeed,
Queue,
RecentSlotHashes,
SB_ON_DEMAND_PID,
} from '@switchboard-xyz/on-demand';
import fs from 'fs';
import chunk from 'lodash/chunk';
Expand Down Expand Up @@ -472,7 +472,7 @@ async function prepareCandidateOracles(
.map((o, i) => {
return { oracle: o, ai: ais[i] };
})
.filter((item) => item.ai?.owner.equals(SB_ON_DEMAND_PID));
.filter((item) => item.ai?.owner.equals(ON_DEMAND_MAINNET_PID));

// parse account info data
const parsedOracles = sbodOracles.map((item) => {
Expand Down Expand Up @@ -526,6 +526,7 @@ function extendOraclesManually(
fallbackForOracle: undefined,
tokenIndex: undefined,
perpMarketIndex: undefined,
isOracleStaleOrUnconfident: false,
},
];
}
Expand All @@ -545,6 +546,7 @@ function extendOraclesManually(
fallbackForOracle: undefined,
tokenIndex: undefined,
perpMarketIndex: undefined,
isOracleStaleOrUnconfident: false,
};
});
}
Expand Down Expand Up @@ -589,7 +591,7 @@ async function setupSwitchboard(client: MangoClient): Promise<{
queue: PublicKey;
}> {
const idl = await Anchor30Program.fetchIdl(
SB_ON_DEMAND_PID,
ON_DEMAND_MAINNET_PID,
client.program.provider,
);
const sbOnDemandProgram = new Anchor30Program(idl!, client.program.provider);
Expand Down

0 comments on commit 1b6aef5

Please sign in to comment.