From 68de248c5bc50bb7f53cf8ff957de88b92837bf9 Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Wed, 10 Aug 2022 09:31:58 +0200 Subject: [PATCH] fix Signed-off-by: microwavedcola1 --- ...ample1-ids-json.ts => mb-example1-user.ts} | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) rename ts/client/src/scripts/{mb-example1-ids-json.ts => mb-example1-user.ts} (83%) diff --git a/ts/client/src/scripts/mb-example1-ids-json.ts b/ts/client/src/scripts/mb-example1-user.ts similarity index 83% rename from ts/client/src/scripts/mb-example1-ids-json.ts rename to ts/client/src/scripts/mb-example1-user.ts index 6f816bad3..6a945fb75 100644 --- a/ts/client/src/scripts/mb-example1-ids-json.ts +++ b/ts/client/src/scripts/mb-example1-user.ts @@ -2,13 +2,9 @@ import { AnchorProvider, Wallet } from '@project-serum/anchor'; import { Connection, Keypair } from '@solana/web3.js'; import fs from 'fs'; import { HealthType } from '../accounts/mangoAccount'; -import { MangoClient } from '../index'; +import { MangoClient, MANGO_V4_ID } from '../index'; import { toUiDecimals } from '../utils'; -// -// example script shows usage of ids json (saves havint to do gpa) -// - async function main() { const options = AnchorProvider.defaultOptions(); const connection = new Connection(process.env.MB_CLUSTER_URL!, options); @@ -20,9 +16,10 @@ async function main() { ); const userWallet = new Wallet(user); const userProvider = new AnchorProvider(connection, userWallet, options); - const client = await MangoClient.connectForGroupName( + const client = await MangoClient.connect( userProvider, - 'mainnet-beta.microwavedcola' /* Use ids json instead of getProgramAccounts */, + 'mainnet-beta', + MANGO_V4_ID['mainnet-beta'], ); console.log(`User ${userWallet.publicKey.toBase58()}`); @@ -45,7 +42,7 @@ async function main() { console.log(`...created/found mangoAccount ${mangoAccount.publicKey}`); console.log(mangoAccount.toString(group)); - if (false) { + if (true) { console.log(`...depositing 10 USDC`); await client.tokenDeposit(group, mangoAccount, 'USDC', 10); await mangoAccount.reload(client, group); @@ -89,14 +86,6 @@ async function main() { ).toNumber(), ), ); - // let withdraw = mangoAccount - // .getNative(group.banksMap.get('SOL')!) - // .add(mangoAccount.getMaxWithdrawWithBorrowForToken(group, 'SOL')) - // .toNumber(); - // console.log(` Withdrawing ${toUiDecimals(withdraw)} SOL`); - // await client.tokenWithdraw2(group, mangoAccount, 'SOL', withdraw, true); - // console.log(` Depositing ${toUiDecimals(withdraw)} SOL`); - // await client.tokenDeposit(group, mangoAccount, 'SOL', withdraw); console.log( "mangoAccount.getMaxSourceForTokenSwap(group, 'USDC', 'BTC') " +