Skip to content
This repository was archived by the owner on Nov 15, 2024. It is now read-only.

Commit 2fa203c

Browse files
committed
update create pool to openbook program
1 parent 031424f commit 2fa203c

File tree

1 file changed

+41
-31
lines changed

1 file changed

+41
-31
lines changed

src/utils/market.ts

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,5 @@
11
import BigNumber from 'bignumber.js'
2-
// @ts-ignore
3-
import { struct, u8, nu64 } from 'buffer-layout'
4-
5-
// import { AMM_INFO_LAYOUT_V4 } from '@/utils/liquidity'
6-
import { Market as MarketSerum } from '@project-serum/serum'
7-
import { Orderbook } from '@project-serum/serum/lib/market.js'
8-
import { closeAccount, initializeAccount } from '@project-serum/serum/lib/token-instructions'
9-
import { ASSOCIATED_TOKEN_PROGRAM_ID, Token } from '@solana/spl-token'
10-
import {
11-
Account,
12-
Connection,
13-
PublicKey,
14-
SystemProgram,
15-
SYSVAR_RENT_PUBKEY,
16-
Transaction,
17-
TransactionInstruction
18-
} from '@solana/web3.js'
192

20-
import {
21-
commitment,
22-
createAmmAuthority,
23-
createAssociatedId,
24-
findAssociatedTokenAddress,
25-
getFilteredTokenAccountsByOwner,
26-
getMintDecimals,
27-
getMultipleAccounts,
28-
sendTransaction
29-
} from '@/utils/web3'
30-
import { TOKENS } from '@/utils/tokens'
313
import {
324
AMM_ASSOCIATED_SEED,
335
COIN_VAULT_ASSOCIATED_SEED,
@@ -42,11 +14,49 @@ import {
4214
TOKEN_PROGRAM_ID,
4315
WITHDRAW_ASSOCIATED_SEED
4416
} from '@/utils/ids'
17+
import { TOKENS } from '@/utils/tokens'
18+
import {
19+
commitment,
20+
createAmmAuthority,
21+
createAssociatedId,
22+
findAssociatedTokenAddress,
23+
getFilteredTokenAccountsByOwner,
24+
getMintDecimals,
25+
getMultipleAccounts,
26+
sendTransaction
27+
} from '@/utils/web3'
28+
// import { AMM_INFO_LAYOUT_V4 } from '@/utils/liquidity'
29+
import { Market as MarketSerum } from '@project-serum/serum'
30+
import { Orderbook } from '@project-serum/serum/lib/market.js'
31+
import {
32+
closeAccount,
33+
initializeAccount
34+
} from '@project-serum/serum/lib/token-instructions'
35+
import {
36+
ASSOCIATED_TOKEN_PROGRAM_ID,
37+
Token
38+
} from '@solana/spl-token'
39+
import {
40+
Account,
41+
Connection,
42+
PublicKey,
43+
SystemProgram,
44+
SYSVAR_RENT_PUBKEY,
45+
Transaction,
46+
TransactionInstruction
47+
} from '@solana/web3.js'
48+
4549
import { throwIfNull } from './errors'
46-
import { ACCOUNT_LAYOUT, getBigNumber, MINT_LAYOUT } from './layouts'
50+
import {
51+
ACCOUNT_LAYOUT,
52+
getBigNumber,
53+
MINT_LAYOUT
54+
} from './layouts'
4755
import { LIQUIDITY_POOLS } from './pools'
4856
import { transfer } from './swap'
4957

58+
const { nu64, struct, u8 } = require('buffer-layout')
59+
5060
export async function getMarket(conn: any, marketAddress: string): Promise<any | any> {
5161
try {
5262
const expectAmmId = (
@@ -61,7 +71,7 @@ export async function getMarket(conn: any, marketAddress: string): Promise<any |
6171
throw new Error(`There is already a pool for this Serum Market, ammid -> ${knownAmm.ammId}`)
6272
}
6373
const marketAddressPubKey = new PublicKey(marketAddress)
64-
const market = await Market.load(conn, marketAddressPubKey, undefined, new PublicKey(SERUM_PROGRAM_ID_V3))
74+
const market = await Market.load(conn, marketAddressPubKey, undefined, new PublicKey('srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX'))
6575
const {
6676
asksAddress,
6777
bidsAddress,
@@ -548,7 +558,7 @@ export function preInitialize(
548558
poolTempLpTokenAccount: PublicKey,
549559
market: PublicKey,
550560
owner: PublicKey,
551-
nonce: u8
561+
nonce: number
552562
): TransactionInstruction {
553563
const dataLayout = struct([u8('instruction'), u8('nonce')])
554564

0 commit comments

Comments
 (0)