Skip to content

Commit

Permalink
testing script
Browse files Browse the repository at this point in the history
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
  • Loading branch information
microwavedcola1 committed May 16, 2024
1 parent e6b85c9 commit db6c79d
Showing 1 changed file with 52 additions and 45 deletions.
97 changes: 52 additions & 45 deletions ts/client/scripts/archive/devnet-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ import { Connection, Keypair, PublicKey } from '@solana/web3.js';
import { expect } from 'chai';
import fs from 'fs';
import { Group } from '../../src/accounts/group';
import { MangoAccount } from '../../src/accounts/mangoAccount';
import { HealthType, MangoAccount } from '../../src/accounts/mangoAccount';
import {
OpenbookV2OrderType,
OpenbookV2SelfTradeBehavior,
OpenbookV2Side,
} from '../../src/accounts/openbookV2';
import { MangoClient } from '../../src/client';
import { MANGO_V4_ID } from '../../src/constants';
import { toUiDecimalsForQuote } from '../../src/utils';
Expand Down Expand Up @@ -328,36 +333,37 @@ async function main(): Promise<void> {

// eslint-disable-next-line no-constant-condition
if (true) {
await mangoAccount.reload(client);
console.log(
'...mangoAccount.getEquity() ' +
toUiDecimalsForQuote(mangoAccount.getEquity(group)!.toNumber()),
);
console.log(
'...mangoAccount.getCollateralValue() ' +
toUiDecimalsForQuote(
mangoAccount.getCollateralValue(group)!.toNumber(),
),
);
console.log(
'...mangoAccount.getAssetsVal() ' +
toUiDecimalsForQuote(mangoAccount.getAssetsValue(group)!.toNumber()),
);
console.log(
'...mangoAccount.getLiabsVal() ' +
toUiDecimalsForQuote(mangoAccount.getLiabsValue(group)!.toNumber()),
);
console.log(
'...mangoAccount.getMaxWithdrawWithBorrowForToken(group, "SOL") ' +
toUiDecimalsForQuote(
mangoAccount
.getMaxWithdrawWithBorrowForToken(
group,
new PublicKey(DEVNET_MINTS.get('SOL')!),
)!
.toNumber(),
),
);
console.log(mangoAccount.getHealth(group, HealthType.maint));
// await mangoAccount.reload(client);
// console.log(
// '...mangoAccount.getEquity() ' +
// toUiDecimalsForQuote(mangoAccount.getEquity(group)!.toNumber()),
// );
// console.log(
// '...mangoAccount.getCollateralValue() ' +
// toUiDecimalsForQuote(
// mangoAccount.getCollateralValue(group)!.toNumber(),
// ),
// );
// console.log(
// '...mangoAccount.getAssetsVal() ' +
// toUiDecimalsForQuote(mangoAccount.getAssetsValue(group)!.toNumber()),
// );
// console.log(
// '...mangoAccount.getLiabsVal() ' +
// toUiDecimalsForQuote(mangoAccount.getLiabsValue(group)!.toNumber()),
// );
// console.log(
// '...mangoAccount.getMaxWithdrawWithBorrowForToken(group, "SOL") ' +
// toUiDecimalsForQuote(
// mangoAccount
// .getMaxWithdrawWithBorrowForToken(
// group,
// new PublicKey(DEVNET_MINTS.get('SOL')!),
// )!
// .toNumber(),
// ),
// );
}

// // eslint-disable-next-line no-constant-condition
Expand Down Expand Up @@ -749,7 +755,7 @@ async function main(): Promise<void> {
group.openbookV2MarketsMapByMarketIndex.values(),
)[0];

console.log(mangoAccount.openbookV2);
// console.log(mangoAccount.openbookV2);

// const sig = await client.openbookV2CreateOpenOrders(
// group,
Expand All @@ -765,20 +771,21 @@ async function main(): Promise<void> {
// );
// console.log(sig1.signature);

// const sig2 = await client.openbookV2PlaceOrder(
// group,
// mangoAccount,
// market.openbookMarketExternal,
// OpenbookV2Side.bid,
// 10,
// 1,
// OpenbookV2SelfTradeBehavior.decrementTake,
// OrderType.Limit,
// 0,
// 10,
// );
// console.log(sig2.signature);
const sig2 = await client.openbookV2PlaceOrder(
group,
mangoAccount,
market.openbookMarketExternal,
OpenbookV2Side.bid,
10,
1,
OpenbookV2SelfTradeBehavior.decrementTake,
OpenbookV2OrderType.limit,
0,
10,
);
console.log(sig2.signature);

await mangoAccount.reload(client);
console.log(mangoAccount.getOpenbookV2OoAccount(market.marketIndex));
}

Expand Down

0 comments on commit db6c79d

Please sign in to comment.