simply debug user
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
This commit is contained in:
parent
7d74c5a6a6
commit
fbbce98ec3
|
@ -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 {
|
||||
|
|
|
@ -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 (
|
||||
|
|
Loading…
Reference in New Issue