Skip to content

Commit

Permalink
force withdraw token script: improved logging
Browse files Browse the repository at this point in the history
Signed-off-by: microwavedcola1 <[email protected]>
  • Loading branch information
microwavedcola1 committed Sep 2, 2024
1 parent b16d611 commit 4fe8cac
Showing 1 changed file with 8 additions and 25 deletions.
33 changes: 8 additions & 25 deletions ts/client/scripts/force-withdraw-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,43 +65,26 @@ async function forceWithdrawTokens(): Promise<void> {

for (const mangoAccount of mangoAccounts) {
console.log(
`${mangoAccount.getTokenBalanceUi(forceWithdrawBank)} for ${
mangoAccount.publicKey
}`,
`${mangoAccount.publicKey} ${forceWithdrawBank.name} balance ${mangoAccount.getTokenBalanceUi(forceWithdrawBank)}`,
);

try {
const sig = await client.serum3LiqForceCancelOrders(
group,
mangoAccount,
serum3Market.serumMarketExternal,
);
console.log(
` serum3LiqForceCancelOrders for ${mangoAccount.publicKey}, owner ${
mangoAccount.owner
}, sig https://explorer.solana.com/tx/${sig.signature}?cluster=${
CLUSTER == 'devnet' ? 'devnet' : ''
}`,
);
} catch (error) {
console.log(error);
}

await client
.tokenForceWithdraw(group, mangoAccount, TOKEN_INDEX)
.then((sig) => {
console.log(
` tokenForceWithdraw for ${mangoAccount.publicKey}, owner ${
mangoAccount.owner
}, sig https://explorer.solana.com/tx/${sig.signature}?cluster=${
` - tokenForceWithdraw https://explorer.solana.com/tx/${sig.signature}?cluster=${
CLUSTER == 'devnet' ? 'devnet' : ''
}`,
);
});
}

await group.reloadAll(client);
console.log(forceWithdrawBank.uiDeposits());
const groupFresh = await client.getGroup(new PublicKey(GROUP_PK));
const forceWithdrawBankFresh =
groupFresh.getFirstBankByTokenIndex(TOKEN_INDEX);
console.log(
`Final ${forceWithdrawBankFresh.name} deposits ${forceWithdrawBankFresh.uiDeposits()}`,
);
}

forceWithdrawTokens();

0 comments on commit 4fe8cac

Please sign in to comment.