reload for mangoaccount
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
This commit is contained in:
parent
3c469d7194
commit
b56fd46721
|
@ -1,5 +1,6 @@
|
|||
import { utf8 } from '@project-serum/anchor/dist/cjs/utils/bytes';
|
||||
import { PublicKey } from '@solana/web3.js';
|
||||
import { MangoClient } from '../client';
|
||||
import { Bank } from './bank';
|
||||
import { I80F48, I80F48Dto } from './I80F48';
|
||||
export class MangoAccount {
|
||||
|
@ -61,6 +62,10 @@ export class MangoAccount {
|
|||
this.serum3 = serum3.values.map((dto) => Serum3Account.from(dto));
|
||||
}
|
||||
|
||||
async reload(client: MangoClient) {
|
||||
Object.assign(this, await client.getMangoAccount(this));
|
||||
}
|
||||
|
||||
findToken(tokenIndex: number): TokenAccount | undefined {
|
||||
return this.tokens.find((ta) => ta.tokenIndex == tokenIndex);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { PublicKey } from '@solana/web3.js';
|
||||
|
||||
export const DEVNET_GROUP = '4Fv4jWsd9kYZjCMvkpcXnS63x9cHHHTqCDHTTTB5MbQt';
|
||||
export const DEVNET_GROUP = 'NDLmPdjzm7Tm3gnsZw8EoBbBTR7wfAcyDY8LCqFSGtX';
|
||||
|
||||
export const DEVNET_MINTS = new Map([
|
||||
['USDC', '8FRFC6MoGGkMFQwngccyu69VnYbzykGeez7ignHVAFSN'],
|
||||
|
|
|
@ -47,11 +47,17 @@ async function main() {
|
|||
console.log(`MangoAccount ${mangoAccount.publicKey}`);
|
||||
|
||||
// deposit and withdraw
|
||||
console.log(`Depositing...5000000`);
|
||||
console.log(`Depositing...5000000 USDC`);
|
||||
await client.deposit(group, mangoAccount, 'USDC', 50_000000);
|
||||
await mangoAccount.reload(client);
|
||||
|
||||
console.log(`Depositing...5000000 BTC`);
|
||||
await client.deposit(group, mangoAccount, 'BTC', 5000000);
|
||||
await mangoAccount.reload(client);
|
||||
|
||||
console.log(`Withdrawing...1000000`);
|
||||
await client.withdraw(group, mangoAccount, 'USDC', 1_000000, false);
|
||||
await mangoAccount.reload(client);
|
||||
|
||||
// serum3
|
||||
console.log(
|
||||
|
@ -70,6 +76,8 @@ async function main() {
|
|||
Date.now(),
|
||||
10,
|
||||
);
|
||||
await mangoAccount.reload(client);
|
||||
|
||||
console.log(`Placing serum3 bid way above midprice`);
|
||||
await client.serum3PlaceOrder(
|
||||
group,
|
||||
|
@ -84,6 +92,8 @@ async function main() {
|
|||
Date.now(),
|
||||
10,
|
||||
);
|
||||
await mangoAccount.reload(client);
|
||||
|
||||
console.log(`Placing serum3 ask way below midprice`);
|
||||
await client.serum3PlaceOrder(
|
||||
group,
|
||||
|
|
Loading…
Reference in New Issue