From 3f39ceefedc158bb9e7a00af36d8cc3afeb4e1fd Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Fri, 8 Apr 2022 17:17:26 +0200 Subject: [PATCH] remove deprecated Signed-off-by: microwavedcola1 --- ts/accounts/types/bank.ts | 85 +------ ts/accounts/types/group.ts | 49 ---- ts/accounts/types/mangoAccount.ts | 197 ---------------- ts/accounts/types/oracle.ts | 69 ------ ts/accounts/types/serum3.ts | 100 +------- ts/client.ts | 2 +- ts/example0.ts | 374 ------------------------------ ts/example1-admin.ts | 8 +- ts/index.ts | 38 +-- 9 files changed, 11 insertions(+), 911 deletions(-) delete mode 100644 ts/example0.ts diff --git a/ts/accounts/types/bank.ts b/ts/accounts/types/bank.ts index d67f6b14a..0887b3089 100644 --- a/ts/accounts/types/bank.ts +++ b/ts/accounts/types/bank.ts @@ -1,10 +1,4 @@ -import { - PublicKey, - SYSVAR_RENT_PUBKEY, - Transaction, - TransactionInstruction, - TransactionSignature, -} from '@solana/web3.js'; +import { PublicKey } from '@solana/web3.js'; import bs58 from 'bs58'; import { MangoClient } from '../../client'; import { I80F48, I80F48Dto } from './I80F48'; @@ -82,83 +76,6 @@ export class Bank { } } -/** - * @deprecated - */ -export async function registerToken( - client: MangoClient, - groupPk: PublicKey, - adminPk: PublicKey, - mintPk: PublicKey, - oraclePk: PublicKey, - tokenIndex: number, -): Promise { - const tx = new Transaction(); - const ix = await registerTokenIx( - client, - groupPk, - adminPk, - mintPk, - oraclePk, - tokenIndex, - ); - tx.add(ix); - return await client.program.provider.send(tx); -} - -/** - * @deprecated - */ -export async function registerTokenIx( - client: MangoClient, - groupPk: PublicKey, - adminPk: PublicKey, - mintPk: PublicKey, - oraclePk: PublicKey, - tokenIndex: number, -): Promise { - return await client.program.methods - .registerToken(tokenIndex, 0.8, 0.6, 1.2, 1.4, 0.02) - .accounts({ - group: groupPk, - admin: adminPk, - mint: mintPk, - oracle: oraclePk, - payer: adminPk, - rent: SYSVAR_RENT_PUBKEY, - }) - .instruction(); -} - -/** - * @deprecated - */ -export async function getBank( - client: MangoClient, - address: PublicKey, -): Promise { - return Bank.from(address, await client.program.account.bank.fetch(address)); -} - -/** - * @deprecated - */ -export async function getBanksForGroup( - client: MangoClient, - groupPk: PublicKey, -): Promise { - return ( - await client.program.account.bank.all([ - { - memcmp: { - bytes: groupPk.toBase58(), - offset: 8, - }, - }, - ]) - ).map((tuple) => Bank.from(tuple.publicKey, tuple.account)); -} - export async function getBankForGroupAndMint( client: MangoClient, groupPk: PublicKey, diff --git a/ts/accounts/types/group.ts b/ts/accounts/types/group.ts index c86dca60b..36bc2f1f8 100644 --- a/ts/accounts/types/group.ts +++ b/ts/accounts/types/group.ts @@ -54,52 +54,3 @@ export class Group { ); } } - -/** - * @deprecated - */ -export async function createGroup( - client: MangoClient, - adminPk: PublicKey, -): Promise { - const tx = new Transaction(); - const ix = await createGroupIx(client, adminPk); - tx.add(ix); - return await client.program.provider.send(tx); -} - -/** - * @deprecated - */ -export async function createGroupIx( - client: MangoClient, - adminPk: PublicKey, -): Promise { - return await client.program.methods - .createGroup() - .accounts({ - admin: adminPk, - payer: adminPk, - }) - .instruction(); -} - -/** - * @deprecated - */ -export async function getGroupForAdmin( - client: MangoClient, - adminPk: PublicKey, -): Promise { - const groups = ( - await client.program.account.group.all([ - { - memcmp: { - bytes: adminPk.toBase58(), - offset: 8, - }, - }, - ]) - ).map((tuple) => Group.from(tuple.publicKey, tuple.account)); - return groups[0]; -} diff --git a/ts/accounts/types/mangoAccount.ts b/ts/accounts/types/mangoAccount.ts index baa249b53..f0854a360 100644 --- a/ts/accounts/types/mangoAccount.ts +++ b/ts/accounts/types/mangoAccount.ts @@ -1,6 +1,4 @@ -import { BN } from '@project-serum/anchor'; import { - AccountMeta, PublicKey, Transaction, TransactionInstruction, @@ -137,44 +135,6 @@ export class Serum3AccountDto { ) {} } -export async function createMangoAccount( - client: MangoClient, - groupPk: PublicKey, - ownerPk: PublicKey, - accountNumber: number, -): Promise { - const tx = new Transaction(); - const ix = await createMangoAccountIx( - client, - groupPk, - ownerPk, - accountNumber, - ); - tx.add(ix); - return await client.program.provider.send(tx); -} - -/** - * - * @deprecated - */ -export async function createMangoAccountIx( - client: MangoClient, - groupPk: PublicKey, - ownerPk: PublicKey, - accountNumber: number, -): Promise { - return await client.program.methods - .createAccount(accountNumber) - .accounts({ - group: groupPk, - owner: ownerPk, - payer: ownerPk, - }) - .signers() - .instruction(); -} - export async function closeMangoAccount( client: MangoClient, accountPk: PublicKey, @@ -226,160 +186,3 @@ export async function getMangoAccountsForGroup( ]) ).map((pa) => MangoAccount.from(pa.publicKey, pa.account)); } - -/** - * @deprecated - */ -export async function getMangoAccountsForGroupAndOwner( - client: MangoClient, - groupPk: PublicKey, - ownerPk: PublicKey, -): Promise { - return ( - await client.program.account.mangoAccount.all([ - { - memcmp: { - bytes: groupPk.toBase58(), - offset: 8, - }, - }, - { - memcmp: { - bytes: ownerPk.toBase58(), - offset: 40, - }, - }, - ]) - ).map((pa) => { - return MangoAccount.from(pa.publicKey, pa.account); - }); -} - -/** - * @deprecated - */ -export async function deposit( - client: MangoClient, - groupPk: PublicKey, - mangoAccountPk: PublicKey, - bankPk: PublicKey, - vaultPk: PublicKey, - tokenAccountPk: PublicKey, - ownerPk: PublicKey, - healthRemainingAccounts: PublicKey[], - amount: number, -): Promise { - const tx = new Transaction(); - const ix = await depositIx( - client, - groupPk, - mangoAccountPk, - bankPk, - vaultPk, - tokenAccountPk, - ownerPk, - healthRemainingAccounts, - amount, - ); - tx.add(ix); - return await client.program.provider.send(tx); -} - -/** - * @deprecated - */ -export async function depositIx( - client: MangoClient, - groupPk: PublicKey, - mangoAccountPk: PublicKey, - bankPk: PublicKey, - vaultPk: PublicKey, - tokenAccountPk: PublicKey, - ownerPk: PublicKey, - healthRemainingAccounts: PublicKey[], - amount: number, -): Promise { - return await client.program.methods - .deposit(new BN(amount)) - .accounts({ - group: groupPk, - account: mangoAccountPk, - bank: bankPk, - vault: vaultPk, - tokenAccount: tokenAccountPk, - tokenAuthority: ownerPk, - }) - .remainingAccounts( - healthRemainingAccounts.map( - (pk) => - ({ pubkey: pk, isWritable: false, isSigner: false } as AccountMeta), - ), - ) - .instruction(); -} - -/** - * @deprecated - */ -export async function withdraw( - client: MangoClient, - groupPk: PublicKey, - mangoAccountPk: PublicKey, - bankPk: PublicKey, - vaultPk: PublicKey, - tokenAccountPk: PublicKey, - ownerPk: PublicKey, - healthRemainingAccounts: PublicKey[], - amount: number, - allowBorrow: boolean, -): Promise { - const tx = new Transaction(); - const ix = await withdrawIx( - client, - groupPk, - mangoAccountPk, - bankPk, - vaultPk, - tokenAccountPk, - ownerPk, - healthRemainingAccounts, - amount, - allowBorrow, - ); - tx.add(ix); - return await client.program.provider.send(tx); -} - -/** - * @deprecated - */ -export async function withdrawIx( - client: MangoClient, - groupPk: PublicKey, - mangoAccountPk: PublicKey, - bankPk: PublicKey, - vaultPk: PublicKey, - tokenAccountPk: PublicKey, - ownerPk: PublicKey, - healthRemainingAccounts: PublicKey[], - amount: number, - allowBorrow: boolean, -): Promise { - return await client.program.methods - .withdraw(new BN(amount), allowBorrow) - .accounts({ - group: groupPk, - account: mangoAccountPk, - bank: bankPk, - vault: vaultPk, - tokenAccount: tokenAccountPk, - tokenAuthority: ownerPk, - }) - .remainingAccounts( - healthRemainingAccounts.map( - (pk) => - ({ pubkey: pk, isWritable: false, isSigner: false } as AccountMeta), - ), - ) - .instruction(); -} diff --git a/ts/accounts/types/oracle.ts b/ts/accounts/types/oracle.ts index dafa43472..7f0cc3a92 100644 --- a/ts/accounts/types/oracle.ts +++ b/ts/accounts/types/oracle.ts @@ -37,72 +37,3 @@ export class StubOracle { this.lastUpdated = lastUpdated.toNumber(); } } - -/** - * @deprecated - */ -export async function createStubOracle( - client: MangoClient, - groupPk: PublicKey, - adminPk: PublicKey, - tokenMintPk: PublicKey, - staticPrice: number, -): Promise { - return await client.program.methods - .createStubOracle({ val: I80F48.fromNumber(staticPrice).getData() }) - .accounts({ - group: groupPk, - admin: adminPk, - tokenMint: tokenMintPk, - payer: adminPk, - }) - .rpc(); -} - -/** - * @deprecated - */ -export async function setStubOracle( - client: MangoClient, - groupPk: PublicKey, - adminPk: PublicKey, - tokenMintPk: PublicKey, - staticPrice: number, -): Promise { - return await client.program.methods - .setStubOracle({ val: new BN(staticPrice) }) - .accounts({ - group: groupPk, - admin: adminPk, - tokenMint: tokenMintPk, - payer: adminPk, - }) - .rpc(); -} - -/** - * @deprecated - */ -export async function getStubOracleForGroupAndMint( - client: MangoClient, - groupPk: PublicKey, - mintPk: PublicKey, -): Promise { - const stubOracles = ( - await client.program.account.stubOracle.all([ - { - memcmp: { - bytes: groupPk.toBase58(), - offset: 8, - }, - }, - { - memcmp: { - bytes: mintPk.toBase58(), - offset: 40, - }, - }, - ]) - ).map((pa) => StubOracle.from(pa.publicKey, pa.account)); - return stubOracles[0]; -} diff --git a/ts/accounts/types/serum3.ts b/ts/accounts/types/serum3.ts index 84a2d8029..c317ee07f 100644 --- a/ts/accounts/types/serum3.ts +++ b/ts/accounts/types/serum3.ts @@ -1,12 +1,5 @@ -import { - AccountMeta, - PublicKey, - Transaction, - TransactionInstruction, - TransactionSignature, -} from '@solana/web3.js'; +import { AccountMeta, PublicKey } from '@solana/web3.js'; import BN from 'bn.js'; -import * as bs58 from 'bs58'; import { MangoClient } from '../../client'; export class Serum3Market { @@ -45,97 +38,6 @@ export class Serum3Market { ) {} } -/** @deprecated */ -export async function serum3RegisterMarket( - client: MangoClient, - groupPk: PublicKey, - adminPk: PublicKey, - serumProgramPk: PublicKey, - serumMarketExternalPk: PublicKey, - quoteBankPk: PublicKey, - baseBankPk: PublicKey, - marketIndex: number, -): Promise { - const tx = new Transaction(); - const ix = await serum3RegisterMarketIx( - client, - groupPk, - adminPk, - serumProgramPk, - serumMarketExternalPk, - quoteBankPk, - baseBankPk, - marketIndex, - ); - tx.add(ix); - return await client.program.provider.send(tx); -} - -/** @deprecated */ -export async function serum3RegisterMarketIx( - client: MangoClient, - groupPk: PublicKey, - adminPk: PublicKey, - serumProgramPk: PublicKey, - serumMarketExternalPk: PublicKey, - quoteBankPk: PublicKey, - baseBankPk: PublicKey, - marketIndex: number, -): Promise { - return await client.program.methods - .serum3RegisterMarket(marketIndex) - .accounts({ - group: groupPk, - admin: adminPk, - serumProgram: serumProgramPk, - serumMarketExternal: serumMarketExternalPk, - quoteBank: quoteBankPk, - baseBank: baseBankPk, - payer: adminPk, - }) - .instruction(); -} - -/** @deprecated */ -export async function getSerum3MarketForBaseAndQuote( - client: MangoClient, - groupPk: PublicKey, - baseTokenIndex: number, - quoteTokenIndex: number, -): Promise { - const bbuf = Buffer.alloc(2); - bbuf.writeUInt16LE(baseTokenIndex); - - const qbuf = Buffer.alloc(2); - qbuf.writeUInt16LE(quoteTokenIndex); - - const bumpfbuf = Buffer.alloc(1); - bumpfbuf.writeUInt8(255); - - return ( - await client.program.account.serum3Market.all([ - { - memcmp: { - bytes: groupPk.toBase58(), - offset: 8, - }, - }, - { - memcmp: { - bytes: bs58.encode(bbuf), - offset: 106, - }, - }, - { - memcmp: { - bytes: bs58.encode(qbuf), - offset: 108, - }, - }, - ]) - ).map((tuple) => Serum3Market.from(tuple.publicKey, tuple.account)); -} - export async function serum3CreateOpenOrders( client: MangoClient, groupPk: PublicKey, diff --git a/ts/client.ts b/ts/client.ts index e323e5627..627c1e43c 100644 --- a/ts/client.ts +++ b/ts/client.ts @@ -347,7 +347,7 @@ export class MangoClient { filters.push({ memcmp: { bytes: bs58.encode(qbuf), - offset: 106, + offset: 108, }, }); } diff --git a/ts/example0.ts b/ts/example0.ts deleted file mode 100644 index 577d851d2..000000000 --- a/ts/example0.ts +++ /dev/null @@ -1,374 +0,0 @@ -import { Provider, Wallet, web3 } from '@project-serum/anchor'; -import { Market } from '@project-serum/serum'; -import * as spl from '@solana/spl-token'; -import { Connection, Keypair, PublicKey } from '@solana/web3.js'; -import fs from 'fs'; -import { - Bank, - getBank, - getBankForGroupAndMint, - getMintInfoForTokenIndex, - registerToken, -} from './accounts/types/bank'; -import { createGroup, getGroupForAdmin, Group } from './accounts/types/group'; -import { - createMangoAccount, - deposit, - getMangoAccount, - getMangoAccountsForGroupAndOwner, - MangoAccount, - withdraw, -} from './accounts/types/mangoAccount'; -import { - createStubOracle, - getStubOracleForGroupAndMint, - StubOracle, -} from './accounts/types/oracle'; -import { - getSerum3MarketForBaseAndQuote, - serum3CreateOpenOrders, - Serum3Market, - Serum3OrderType, - serum3PlaceOrder, - serum3RegisterMarket, - Serum3SelfTradeBehavior, - Serum3Side, -} from './accounts/types/serum3'; -import { MangoClient } from './client'; -import { - DEVNET_MINTS, - DEVNET_ORACLES, - DEVNET_SERUM3_PROGRAM_ID, -} from './constants'; -import { findOrCreate } from './utils'; - -// -// Deprecated, see other examples -// - -// -// An example which uses low level global methods -// - -async function main() { - // - // Setup - // - const options = Provider.defaultOptions(); - const connection = new Connection( - 'https://mango.devnet.rpcpool.com', - options, - ); - - const admin = Keypair.fromSecretKey( - Buffer.from( - JSON.parse(fs.readFileSync(process.env.ADMIN_KEYPAIR!, 'utf-8')), - ), - ); - const adminWallet = new Wallet(admin); - console.log(`Admin ${adminWallet.publicKey.toBase58()}`); - const adminProvider = new Provider(connection, adminWallet, options); - const adminClient = await MangoClient.connect(adminProvider, true); - - // const payer = Keypair.fromSecretKey( - // Buffer.from( - // JSON.parse(fs.readFileSync(process.env.PAYER_KEYPAIR!, 'utf-8')), - // ), - // ); - // console.log(`Payer ${payer.publicKey.toBase58()}`); - // - // Find existing or create a new group - // - const group: Group = await findOrCreate( - 'group', - getGroupForAdmin, - [adminClient, admin.publicKey], - createGroup, - [adminClient, admin.publicKey], - ); - console.log(`Group ${group.publicKey}`); - - // - // Find existing or register new oracles - // - const usdcDevnetMint = new PublicKey(DEVNET_MINTS['USDC']); - const usdcDevnetStubOracle = await findOrCreate( - 'stubOracle', - getStubOracleForGroupAndMint, - [adminClient, group.publicKey, usdcDevnetMint], - createStubOracle, - [adminClient, group.publicKey, admin.publicKey, usdcDevnetMint, 1], - ); - console.log( - `usdcDevnetStubOracle ${usdcDevnetStubOracle.publicKey.toBase58()}`, - ); - const btcDevnetMint = new PublicKey(DEVNET_MINTS['BTC']); - const btcDevnetOracle = new PublicKey(DEVNET_ORACLES['BTC']); - - // - // Find existing or register new tokens - // - // TODO: replace with 4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU, - // see https://developers.circle.com/docs/usdc-on-testnet#usdc-on-solana-testnet - const btcBank = await findOrCreate( - 'bank', - getBankForGroupAndMint, - [adminClient, group.publicKey, btcDevnetMint], - registerToken, - [ - adminClient, - group.publicKey, - admin.publicKey, - btcDevnetMint, - btcDevnetOracle, - - 0, - ], - ); - console.log(`BtcBank ${btcBank.publicKey}`); - const usdcBank = await findOrCreate( - 'bank', - getBankForGroupAndMint, - [adminClient, group.publicKey, usdcDevnetMint], - registerToken, - [ - adminClient, - group.publicKey, - admin.publicKey, - usdcDevnetMint, - usdcDevnetStubOracle.publicKey, - - 1, - ], - ); - console.log(`UsdcBank ${usdcBank.publicKey}`); - - // - // User operations - // - - const user = Keypair.fromSecretKey( - Buffer.from( - JSON.parse(fs.readFileSync(process.env.USER_KEYPAIR!, 'utf-8')), - ), - ); - const userWallet = new Wallet(user); - const userProvider = new Provider(connection, userWallet, options); - const userClient = await MangoClient.connect(userProvider, true); - console.log(`User ${userWallet.publicKey.toBase58()}`); - - // - // Create mango account - // - const mangoAccount = await findOrCreate( - 'mangoAccount', - getMangoAccountsForGroupAndOwner, - [userClient, group.publicKey, user.publicKey], - createMangoAccount, - [userClient, group.publicKey, user.publicKey, 0], - ); - console.log(`MangoAccount ${mangoAccount.publicKey}`); - - // close mango account, note: close doesnt settle/withdraw for user atm, - // only use when you want to free up a mango account address for testing on not-mainnet - // await closeMangoAccount(userClient, account.publicKey, user.publicKey); - // accounts = await getMangoAccountsForGroupAndOwner( - // userClient, - // group.publicKey, - // user.publicKey, - // ); - // if (accounts.length === 0) { - // console.log(`Closed account ${account.publicKey}`); - // } - - // - // Find existing or register a new serum3 market - // - - const serumMarketExternalPk = new web3.PublicKey( - 'DW83EpHFywBxCHmyARxwj3nzxJd7MUdSeznmrdzZKNZB', - ); - const serum3Market = await findOrCreate( - 'serum3Market', - getSerum3MarketForBaseAndQuote, - [adminClient, group.publicKey, btcBank.tokenIndex, usdcBank.tokenIndex], - serum3RegisterMarket, - [ - adminClient, - group.publicKey, - admin.publicKey, - DEVNET_SERUM3_PROGRAM_ID, - serumMarketExternalPk, - usdcBank.publicKey, - btcBank.publicKey, - 0, - ], - ); - console.log(`Serum3Market ${serum3Market.publicKey}`); - - // - // Serum3 OO - // - if (mangoAccount.serum3[0].marketIndex == 65535) { - console.log('Creating serum3 open orders account...'); - await serum3CreateOpenOrders( - userClient, - group.publicKey, - mangoAccount.publicKey, - serum3Market.publicKey, - DEVNET_SERUM3_PROGRAM_ID, - serumMarketExternalPk, - user.publicKey, - ); - } - - // - // Deposit & withdraw - // - console.log(`Depositing...1000`); - const btcTokenAccount = await spl.getAssociatedTokenAddress( - btcDevnetMint, - user.publicKey, - ); - - // Aggregate all PKs of users active assets, banks, oracles and serum OOs - const healthRemainingAccounts: PublicKey[] = []; - { - const mintInfos = await Promise.all( - mangoAccount.tokens - .filter((token) => token.tokenIndex !== 65535) - .map(async (token) => - getMintInfoForTokenIndex( - userClient, - group.publicKey, - token.tokenIndex, - ), - ), - ); - // banks - healthRemainingAccounts.push( - ...mintInfos.flatMap((mintinfos) => { - return mintinfos.flatMap((mintinfo) => { - return mintinfo.bank; - }); - }), - ); - // oracles - healthRemainingAccounts.push( - ...mintInfos.flatMap((mintinfos) => { - return mintinfos.flatMap((mintinfo) => { - return mintinfo.oracle; - }); - }), - ); - // serum OOs - healthRemainingAccounts.push( - ...mangoAccount.serum3 - .filter((serum3Account) => serum3Account.marketIndex !== 65535) - .map((serum3Account) => serum3Account.openOrders), - ); - } - - await deposit( - userClient, - group.publicKey, - mangoAccount.publicKey, - btcBank.publicKey, - btcBank.vault, - btcTokenAccount, - user.publicKey, - healthRemainingAccounts, - 1000, - ); - - console.log(`Withdrawing...500`); - await withdraw( - userClient, - group.publicKey, - mangoAccount.publicKey, - btcBank.publicKey, - btcBank.vault, - btcTokenAccount, - user.publicKey, - healthRemainingAccounts, - 500, - false, - ); - - // log - const freshBank = await getBank(userClient, btcBank.publicKey); - console.log(freshBank.toString()); - - let freshAccount = await getMangoAccount(userClient, mangoAccount.publicKey); - console.log( - `- Mango account ${freshAccount.getNativeDeposit( - freshBank, - )} Deposits for bank ${freshBank.tokenIndex}`, - ); - - // - // Place serum3 order - // - console.log('Placing serum3 order...'); - const serum3MarketExternal = await Market.load( - userClient.program.provider.connection, - serumMarketExternalPk, - { commitment: userClient.program.provider.connection.commitment }, - DEVNET_SERUM3_PROGRAM_ID, - ); - const serum3MarketExternalVaultSigner = await PublicKey.createProgramAddress( - [ - serumMarketExternalPk.toBuffer(), - serum3MarketExternal.decoded.vaultSignerNonce.toArrayLike( - Buffer, - 'le', - 8, - ), - ], - DEVNET_SERUM3_PROGRAM_ID, - ); - const clientOrderId = Date.now(); - await serum3PlaceOrder( - userClient, - group.publicKey, - mangoAccount.publicKey, - user.publicKey, - mangoAccount.serum3[0].openOrders, - serum3Market.publicKey, - DEVNET_SERUM3_PROGRAM_ID, - serumMarketExternalPk, - serum3MarketExternal.bidsAddress, - serum3MarketExternal.asksAddress, - serum3MarketExternal.decoded.eventQueue, - serum3MarketExternal.decoded.requestQueue, - serum3MarketExternal.decoded.baseVault, - serum3MarketExternal.decoded.quoteVault, - serum3MarketExternalVaultSigner, - usdcBank.publicKey, - usdcBank.vault, - btcBank.publicKey, - btcBank.vault, - healthRemainingAccounts, - Serum3Side.bid, - 40000, - 1, - 1000000, - Serum3SelfTradeBehavior.decrementTake, - Serum3OrderType.limit, - clientOrderId, - 10, - ); - - const ordersForOwner = await serum3MarketExternal.loadOrdersForOwner( - userClient.program.provider.connection, - group.publicKey, - ); - const orderJustPlaced = ordersForOwner.filter( - (order) => order.clientId?.toNumber() === clientOrderId, - )[0]; - console.log(`- Serum3 order orderId ${orderJustPlaced.orderId}`); - - process.exit(0); -} - -main(); diff --git a/ts/example1-admin.ts b/ts/example1-admin.ts index 2205c489f..a0f3676c6 100644 --- a/ts/example1-admin.ts +++ b/ts/example1-admin.ts @@ -37,14 +37,14 @@ async function main() { console.log(`Group ${group.publicKey}`); // register token 0 - const btcDevnetMint = new PublicKey(DEVNET_MINTS['BTC']); - const btcDevnetOracle = new PublicKey(DEVNET_ORACLES['BTC']); + const btcDevnetMint = new PublicKey(DEVNET_MINTS.get('BTC')!); + const btcDevnetOracle = new PublicKey(DEVNET_ORACLES.get('BTC')!); try { await client.registerToken(group, btcDevnetMint, btcDevnetOracle, 0); } catch (error) {} // stub oracle + register token 1 - const usdcDevnetMint = new PublicKey(DEVNET_MINTS['USDC']); + const usdcDevnetMint = new PublicKey(DEVNET_MINTS.get('BTC')!); try { await client.createStubOracle(group, usdcDevnetMint, 1.0); } catch (error) {} @@ -68,7 +68,7 @@ async function main() { // register serum market const serumMarketExternalPk = new PublicKey( - DEVNET_SERUM3_MARKETS['BTC/USDC'], + DEVNET_SERUM3_MARKETS.get('BTC/USDC')!, ); try { } catch (error) { diff --git a/ts/index.ts b/ts/index.ts index 4b8ee8a92..d4b2d8b53 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -1,44 +1,14 @@ -export { - Bank, - getBank, - getBankForGroupAndMint, - getBanksForGroup, - registerToken, - registerTokenIx, -} from './accounts/types/bank'; -export { - createGroup, - createGroupIx, - getGroupForAdmin, - Group, -} from './accounts/types/group'; +export { Bank, getBankForGroupAndMint } from './accounts/types/bank'; +export { Group } from './accounts/types/group'; export * from './accounts/types/I80F48'; export { closeMangoAccount, - closeMangoAccountIx, - createMangoAccount, - createMangoAccountIx, - deposit, - depositIx, getMangoAccount, getMangoAccountsForGroup, - getMangoAccountsForGroupAndOwner, MangoAccount, TokenAccount, TokenAccountDto, - withdraw, - withdrawIx, } from './accounts/types/mangoAccount'; -export { - createStubOracle, - getStubOracleForGroupAndMint, - setStubOracle, - StubOracle, -} from './accounts/types/oracle'; -export { - getSerum3MarketForBaseAndQuote, - Serum3Market, - serum3RegisterMarket, - serum3RegisterMarketIx, -} from './accounts/types/serum3'; +export { StubOracle } from './accounts/types/oracle'; +export { Serum3Market } from './accounts/types/serum3'; export * from './client';