simply debug user

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
This commit is contained in:
microwavedcola1 2023-01-18 20:15:04 +01:00
parent 7d74c5a6a6
commit fbbce98ec3
2 changed files with 38 additions and 23 deletions

View File

@ -981,7 +981,18 @@ export class MangoAccount {
res =
this.perpActive().length > 0
? res + '\n perps:' + JSON.stringify(this.perpActive(), null, 4)
? res +
'\n perps:' +
JSON.stringify(
this.perpActive().map((p) =>
p.toString(
group,
group?.getPerpMarketByMarketIndex(p.marketIndex),
),
),
null,
4,
)
: res + '';
res =
@ -1470,6 +1481,30 @@ export class PerpPosition {
perpMarket,
);
}
toString(group?: Group, perpMarket?: PerpMarket): string {
return perpMarket && group
? 'market - ' +
perpMarket.name +
', basePositionLots - ' +
perpMarket.baseLotsToUi(this.basePositionLots) +
', quotePositiveNative - ' +
toUiDecimals(
this.quotePositionNative.toNumber(),
group.getMintDecimalsByTokenIndex(perpMarket.settleTokenIndex),
) +
', bidsBaseLots - ' +
perpMarket.baseLotsToUi(this.bidsBaseLots) +
', asksBaseLots - ' +
perpMarket.baseLotsToUi(this.asksBaseLots) +
', takerBaseLots - ' +
perpMarket.baseLotsToUi(this.takerBaseLots) +
', takerQuoteLots - ' +
perpMarket.quoteLotsToUi(this.takerQuoteLots) +
', unsettled pnl - ' +
this.getUnsettledPnlUi(group!, perpMarket!).toString()
: '';
}
}
export class PerpPositionDto {

View File

@ -26,11 +26,7 @@ async function debugUser(
group: Group,
mangoAccount: MangoAccount,
): Promise<void> {
// Log only tokens
console.log(mangoAccount.toString(group, true));
// Turn on, to see serum and perp stuff
// console.log(mangoAccount.toString(group));
console.log(mangoAccount.toString(group));
await mangoAccount.reload(client);
@ -237,23 +233,7 @@ async function main(): Promise<void> {
const userWallet = new Wallet(user);
console.log(`User ${userWallet.publicKey.toBase58()}`);
// 1. mango account for owner
const mangoAccounts = await client.getMangoAccountsForOwner(
group,
user.publicKey,
);
// 2. mango account by pubkey
// const mangoAccounts = await Promise.all([
// await client.getMangoAccount({
// publicKey: new PublicKey(
// '6mqHfpJqnXcu6RgDYZSVW9CQXQPFyRYhgvdzvWXN9mPW',
// ),
// } as any),
// ]);
// 3. all mango accounts
// const mangoAccounts = await client.getAllMangoAccounts(group);
const mangoAccounts = await client.getAllMangoAccounts(group);
for (const mangoAccount of mangoAccounts) {
if (