Skip to content

Commit

Permalink
Fixes from review
Browse files Browse the repository at this point in the history
Signed-off-by: microwavedcola1 <[email protected]>
  • Loading branch information
microwavedcola1 committed Aug 22, 2024
1 parent e223e4b commit 1eb06af
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 28 deletions.
7 changes: 3 additions & 4 deletions ts/client/scripts/sb-on-demand-crank.ts
Original file line number Diff line number Diff line change
Expand Up @@ -636,8 +636,9 @@ async function updateFilteredOraclesAis(
fo.decodedPullFeed = decodedPullFeed;
});

// ais for oracles whose fallbacks are sbod oracles
// make a note iff a sbod oracle, is a fallback for another oracle, where the main oracle is stale or unconfident
{
// filter where sbod oracle is a fallback for another oracle
const publicKeysWithIndices = filteredOracles
.map((item, idx) => {
return { publicKey: item.oracle.fallbackForOracle, idx: idx };
Expand All @@ -661,8 +662,8 @@ async function updateFilteredOraclesAis(
zipWith(publicKeysWithIndices, ais, function (publicKeyWithIndex, ai) {
return { publicKeyWithIndex, ai };
}).map(async (item) => {
// fetch main oracle, and check if it is stale or unconfident
const filteredOracle = filteredOracles[item.publicKeyWithIndex.idx];

let mintDecimals, maxStalenessSlots, confFilter;
if (filteredOracle.oracle.tokenIndex !== undefined) {
const bank = group.getFirstBankByTokenIndex(
Expand All @@ -681,7 +682,6 @@ async function updateFilteredOraclesAis(
} else {
return;
}

const result = await Group.decodePriceFromOracleAi(
group,
coder,
Expand All @@ -690,7 +690,6 @@ async function updateFilteredOraclesAis(
mintDecimals,
client,
);

filteredOracle.oracle.isOracleStaleOrUnconfident =
isOracleStaleOrUnconfident(
nowSlot,
Expand Down
45 changes: 21 additions & 24 deletions ts/client/scripts/update-risk-params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,28 +289,26 @@ async function updateTokenParams(): Promise<void> {
// }

// eslint-disable-next-line no-constant-condition
if (true) {
if (bank.reduceOnly == 1) {
builder.disableAssetLiquidation(true);
builder.oracleConfig({
confFilter: 1000,
maxStalenessSlots: null,
});
builder.forceClose(true);
builder.forceWithdraw(true);
if (bank.name == 'NEON') {
builder.initLiabWeight(1.96);
}
change = true;
console.log(
` - ${bank.name}, ${(
bank.uiDeposits() * bank.uiPrice
).toLocaleString()} ${bank.uiBorrows() * bank.uiPrice} `,
);
}
// // eslint-disable-next-line no-constant-condition
// if (1 == 1) return;
}
// if (true) {
// if (
// bank.uiBorrows() == 0 &&
// bank.reduceOnly == 2 &&
// bank.initAssetWeight.toNumber() == 0 &&
// bank.maintAssetWeight.toNumber() == 0
// ) {
// builder.disableAssetLiquidation(true);
// builder.oracleConfig({
// confFilter: 1000,
// maxStalenessSlots: -1,
// });
// change = true;
// console.log(
// ` - ${bank.name}, ${(
// bank.uiDeposits() * bank.uiPrice
// ).toLocaleString()} disabled asset liquidation`,
// );
// }
// }

// // eslint-disable-next-line no-constant-condition
// if (true) {
Expand Down Expand Up @@ -536,7 +534,6 @@ async function updateTokenParams(): Promise<void> {
const simulated = await client.connection.simulateTransaction(tx);

if (simulated.value.err) {
console.log('error', bank.name);
console.log('error', simulated.value.logs);
throw simulated.value.logs;
}
Expand Down Expand Up @@ -576,7 +573,7 @@ async function updateTokenParams(): Promise<void> {
tokenOwnerRecord,
PROPOSAL_TITLE
? PROPOSAL_TITLE
: 'Cleanup delisted token fields in mango-v4',
: 'Reset sb on demand oracles as fallback oracles in mango-v4',
PROPOSAL_LINK ?? '',
Object.values(proposals).length,
instructions,
Expand Down

0 comments on commit 1eb06af

Please sign in to comment.