@triadxyz/triad-protocol 1.9.8-beta → 2.0.0-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,10 @@
1
1
  import { PublicKey } from '@solana/web3.js';
2
- export declare const STAKE_VAULT_NAME = "Triad Share 1";
3
2
  export declare const TRD_DECIMALS = 6;
4
3
  export declare const VERIFIER: PublicKey;
5
4
  export declare const TRD_MINT: PublicKey;
6
5
  export declare const TRIAD_ADMIN: PublicKey;
7
6
  export declare const SOL_MINT: PublicKey;
8
7
  export declare const TICKET_CORE_COLLECTION: PublicKey;
9
- export declare const VALENT_SPIN_NAME = "valent";
10
- export declare const WHEEL_MINT: PublicKey;
11
8
  export declare const POSEIDON_COLLECTION_SYMBOL = "$PSN";
12
9
  export declare const POSEIDON_CORE_COLLECTION: PublicKey;
13
10
  export declare const TICKET_COLLECTION_SYMBOL = "PTCKT";
@@ -1,16 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TICKET_COLLECTION_SYMBOL = exports.POSEIDON_CORE_COLLECTION = exports.POSEIDON_COLLECTION_SYMBOL = exports.WHEEL_MINT = exports.VALENT_SPIN_NAME = exports.TICKET_CORE_COLLECTION = exports.SOL_MINT = exports.TRIAD_ADMIN = exports.TRD_MINT = exports.VERIFIER = exports.TRD_DECIMALS = exports.STAKE_VAULT_NAME = void 0;
3
+ exports.TICKET_COLLECTION_SYMBOL = exports.POSEIDON_CORE_COLLECTION = exports.POSEIDON_COLLECTION_SYMBOL = exports.TICKET_CORE_COLLECTION = exports.SOL_MINT = exports.TRIAD_ADMIN = exports.TRD_MINT = exports.VERIFIER = exports.TRD_DECIMALS = void 0;
4
4
  const web3_js_1 = require("@solana/web3.js");
5
- exports.STAKE_VAULT_NAME = 'Triad Share 1';
6
5
  exports.TRD_DECIMALS = 6;
7
6
  exports.VERIFIER = new web3_js_1.PublicKey('42n6BHufivUKrb5Bi6tXbMZvM8NHovrDLX1Rt5w2a919');
8
7
  exports.TRD_MINT = new web3_js_1.PublicKey('t3DohmswhKk94PPbPYwA6ZKACyY3y5kbcqeQerAJjmV');
9
8
  exports.TRIAD_ADMIN = new web3_js_1.PublicKey('82ppCojm3yrEKgdpH8B5AmBJTU1r1uAWXFWhxvPs9UCR');
10
9
  exports.SOL_MINT = new web3_js_1.PublicKey('So11111111111111111111111111111111111111112');
11
10
  exports.TICKET_CORE_COLLECTION = new web3_js_1.PublicKey('BaqopH1VXYUCT6VsojbTibVcd3k5jpGGT6296HFb6fVa');
12
- exports.VALENT_SPIN_NAME = 'valent';
13
- exports.WHEEL_MINT = new web3_js_1.PublicKey('tCMraBSGHeMcQS76hNnBhnfbMzrtnnT3nbt3vAnSCE2');
14
11
  exports.POSEIDON_COLLECTION_SYMBOL = '$PSN';
15
12
  exports.POSEIDON_CORE_COLLECTION = new web3_js_1.PublicKey('69CLccefLRmvDSAJP7Er632dvn878qkpdcnvq5ZUspSm');
16
13
  exports.TICKET_COLLECTION_SYMBOL = 'PTCKT';
@@ -1,13 +1,15 @@
1
1
  import { Stake, StakeVault } from './../types/stake';
2
2
  import { Market, Order, OrderDirection, OrderSide, OrderStatus, OrderType, UserTrade } from '../types/trade';
3
3
  import { PublicKey } from '@solana/web3.js';
4
+ import { IdlAccounts } from '@coral-xyz/anchor';
5
+ import { TriadProtocol } from '../types/triad_protocol';
4
6
  export declare const encodeString: (value: string, alloc?: number) => number[];
5
7
  export declare const decodeString: (bytes: number[]) => string;
6
- export declare const formatStakeVault: (stakeVault: any) => StakeVault;
7
- export declare const formatStake: (stake: any) => Stake;
8
- export declare const formatMarket: (account: any, address: PublicKey) => Market;
9
- export declare const formatOrder: (order: any, authority?: string) => Order;
10
- export declare const formatUserTrade: (account: any, publicKey: PublicKey) => UserTrade;
8
+ export declare const formatStakeVault: (stakeVault: IdlAccounts<TriadProtocol>['stakeVault']) => StakeVault;
9
+ export declare const formatStake: (stake: IdlAccounts<TriadProtocol>['stakeV2']) => Stake;
10
+ export declare const formatMarket: (account: IdlAccounts<TriadProtocol>['marketV2'], address: PublicKey) => Market;
11
+ export declare const formatUserTrade: (account: IdlAccounts<TriadProtocol>['userTrade'], publicKey: PublicKey) => UserTrade;
12
+ export declare const formatOrder: (order: IdlAccounts<TriadProtocol>['userTrade']['orders'][number], authority?: string) => Order;
11
13
  export declare const calculateStakeRewards: (stake: Stake) => number;
12
14
  export declare const getTokenProgram: (mint: PublicKey) => PublicKey;
13
15
  export declare const getOrderDirection: (direction: {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getOrderStatus = exports.getOrderSide = exports.getOrderType = exports.getOrderDirection = exports.getTokenProgram = exports.calculateStakeRewards = exports.formatUserTrade = exports.formatOrder = exports.formatMarket = exports.formatStake = exports.formatStakeVault = exports.decodeString = exports.encodeString = void 0;
3
+ exports.getOrderStatus = exports.getOrderSide = exports.getOrderType = exports.getOrderDirection = exports.getTokenProgram = exports.calculateStakeRewards = exports.formatOrder = exports.formatUserTrade = exports.formatMarket = exports.formatStake = exports.formatStakeVault = exports.decodeString = exports.encodeString = void 0;
4
4
  const trade_1 = require("../types/trade");
5
5
  const constants_1 = require("./constants");
6
6
  const spl_token_1 = require("@solana/spl-token");
@@ -79,14 +79,26 @@ const formatMarket = (account, address) => {
79
79
  marketFeeAvailable: account.marketFeeAvailable.toString(),
80
80
  marketFeeClaimed: account.marketFeeClaimed.toString(),
81
81
  winningDirection: trade_1.WinningDirection[Object.keys(account.winningDirection)[0].toUpperCase()],
82
- marketLiquidityAtStart: account.marketLiquidityAtStart.toString() > 0
82
+ marketLiquidityAtStart: account.marketLiquidityAtStart.toNumber() > 0
83
83
  ? account.marketLiquidityAtStart.toString()
84
84
  : '0',
85
85
  payoutFee: account.payoutFee,
86
- customer: account.customer ? account.customer.toString() : 'Triad'
86
+ customer: account.customerId === 0 ? 'Triad' : account.customerId.toString()
87
87
  };
88
88
  };
89
89
  exports.formatMarket = formatMarket;
90
+ const formatUserTrade = (account, publicKey) => {
91
+ return {
92
+ user: publicKey.toString(),
93
+ totalDeposits: account.totalDeposits.toString(),
94
+ totalWithdraws: account.totalWithdraws.toString(),
95
+ orders: account.orders.map((order) => (0, exports.formatOrder)(order, account.authority.toString())),
96
+ nonce: account.nonce.toString(),
97
+ poseidon: account.poseidon ? account.poseidon.toString() : '',
98
+ isSubUser: account.isSubUser
99
+ };
100
+ };
101
+ exports.formatUserTrade = formatUserTrade;
90
102
  const formatOrder = (order, authority) => {
91
103
  return {
92
104
  ts: order.ts.toString(),
@@ -110,18 +122,6 @@ const formatOrder = (order, authority) => {
110
122
  };
111
123
  };
112
124
  exports.formatOrder = formatOrder;
113
- const formatUserTrade = (account, publicKey) => {
114
- return {
115
- user: publicKey.toString(),
116
- totalDeposits: account.totalDeposits.toString(),
117
- totalWithdraws: account.totalWithdraws.toString(),
118
- orders: account.orders.map((order) => (0, exports.formatOrder)(order, account.authority.toString())),
119
- nonce: account.nonce.toString(),
120
- poseidon: account.poseidon ? account.poseidon.toString() : '',
121
- isSubUser: account.isSubUser
122
- };
123
- };
124
- exports.formatUserTrade = formatUserTrade;
125
125
  const calculateStakeRewards = (stake) => {
126
126
  if (stake.withdrawTs !== 0)
127
127
  return 0;
@@ -1,7 +1,6 @@
1
1
  import { PublicKey } from '@solana/web3.js';
2
- export declare const getUserPositionPDA: (programId: PublicKey, wallet: PublicKey, ticker: PublicKey) => PublicKey;
3
2
  export declare const getTokenATA: (address: PublicKey, Mint: PublicKey, program?: PublicKey) => PublicKey;
4
- export declare const getWheelPDA: (programId: PublicKey, name: string) => PublicKey;
5
- export declare const getCollectionPDA: (programId: PublicKey, collectionSymbol: string) => PublicKey;
6
- export declare const getNftPDA: (programId: PublicKey, number: number) => PublicKey;
7
- export declare const getPoseidonPDA: (programId: PublicKey, number: number) => PublicKey;
3
+ export declare const getMarketPDA: (programId: PublicKey, marketId: number) => PublicKey;
4
+ export declare const getCustomerPDA: (programId: PublicKey, customerId: number) => PublicKey;
5
+ export declare const getUserTradePDA: (programId: PublicKey, wallet: PublicKey) => PublicKey;
6
+ export declare const getSubUserTradePDA: (programId: PublicKey, wallet: PublicKey, nonce: number) => PublicKey;
@@ -3,31 +3,31 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getPoseidonPDA = exports.getNftPDA = exports.getCollectionPDA = exports.getWheelPDA = exports.getTokenATA = exports.getUserPositionPDA = void 0;
6
+ exports.getSubUserTradePDA = exports.getUserTradePDA = exports.getCustomerPDA = exports.getMarketPDA = exports.getTokenATA = void 0;
7
7
  const web3_js_1 = require("@solana/web3.js");
8
8
  const bn_js_1 = __importDefault(require("bn.js"));
9
9
  const spl_token_1 = require("@solana/spl-token");
10
- const getUserPositionPDA = (programId, wallet, ticker) => {
11
- return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('user_position'), wallet.toBuffer(), ticker.toBuffer()], programId)[0];
12
- };
13
- exports.getUserPositionPDA = getUserPositionPDA;
14
10
  const getTokenATA = (address, Mint, program = spl_token_1.TOKEN_2022_PROGRAM_ID) => {
15
11
  return web3_js_1.PublicKey.findProgramAddressSync([address.toBytes(), program.toBytes(), Mint.toBytes()], new web3_js_1.PublicKey(spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID))[0];
16
12
  };
17
13
  exports.getTokenATA = getTokenATA;
18
- const getWheelPDA = (programId, name) => {
19
- return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('whell'), Buffer.from(name)], programId)[0];
14
+ const getMarketPDA = (programId, marketId) => {
15
+ return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('market'), new bn_js_1.default(marketId).toArrayLike(Buffer, 'le', 8)], programId)[0];
20
16
  };
21
- exports.getWheelPDA = getWheelPDA;
22
- const getCollectionPDA = (programId, collectionSymbol) => {
23
- return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('collection'), Buffer.from(collectionSymbol)], programId)[0];
17
+ exports.getMarketPDA = getMarketPDA;
18
+ const getCustomerPDA = (programId, customerId) => {
19
+ return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('customer'), new bn_js_1.default(customerId).toArrayLike(Buffer, 'le', 8)], programId)[0];
24
20
  };
25
- exports.getCollectionPDA = getCollectionPDA;
26
- const getNftPDA = (programId, number) => {
27
- return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('nft'), new bn_js_1.default(number).toArrayLike(Buffer, 'le', 8)], programId)[0];
21
+ exports.getCustomerPDA = getCustomerPDA;
22
+ const getUserTradePDA = (programId, wallet) => {
23
+ return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('user_trade'), wallet.toBuffer()], programId)[0];
28
24
  };
29
- exports.getNftPDA = getNftPDA;
30
- const getPoseidonPDA = (programId, number) => {
31
- return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('poseidon'), new bn_js_1.default(number).toArrayLike(Buffer, 'le', 8)], programId)[0];
25
+ exports.getUserTradePDA = getUserTradePDA;
26
+ const getSubUserTradePDA = (programId, wallet, nonce) => {
27
+ return web3_js_1.PublicKey.findProgramAddressSync([
28
+ Buffer.from('sub_user_trade'),
29
+ wallet.toBuffer(),
30
+ new bn_js_1.default(nonce).toArrayLike(Buffer, 'le', 8)
31
+ ], programId)[0];
32
32
  };
33
- exports.getPoseidonPDA = getPoseidonPDA;
33
+ exports.getSubUserTradePDA = getSubUserTradePDA;
@@ -0,0 +1,4 @@
1
+ import { PublicKey } from '@solana/web3.js';
2
+ export declare const getCollectionPDA: (programId: PublicKey, collectionSymbol: string) => PublicKey;
3
+ export declare const getNftPDA: (programId: PublicKey, number: number) => PublicKey;
4
+ export declare const getPoseidonPDA: (programId: PublicKey, number: number) => PublicKey;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getPoseidonPDA = exports.getNftPDA = exports.getCollectionPDA = void 0;
7
+ const web3_js_1 = require("@solana/web3.js");
8
+ const bn_js_1 = __importDefault(require("bn.js"));
9
+ const getCollectionPDA = (programId, collectionSymbol) => {
10
+ return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('collection'), Buffer.from(collectionSymbol)], programId)[0];
11
+ };
12
+ exports.getCollectionPDA = getCollectionPDA;
13
+ const getNftPDA = (programId, number) => {
14
+ return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('nft'), new bn_js_1.default(number).toArrayLike(Buffer, 'le', 8)], programId)[0];
15
+ };
16
+ exports.getNftPDA = getNftPDA;
17
+ const getPoseidonPDA = (programId, number) => {
18
+ return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('poseidon'), new bn_js_1.default(number).toArrayLike(Buffer, 'le', 8)], programId)[0];
19
+ };
20
+ exports.getPoseidonPDA = getPoseidonPDA;
@@ -1,3 +1,2 @@
1
1
  import { PublicKey } from '@solana/web3.js';
2
- export declare const getStakeVaultPDA: (programId: PublicKey, vaultName: string) => PublicKey;
3
2
  export declare const getStakePDA: (programId: PublicKey, wallet: PublicKey, name: string) => PublicKey;
@@ -1,11 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getStakePDA = exports.getStakeVaultPDA = void 0;
3
+ exports.getStakePDA = void 0;
4
4
  const web3_js_1 = require("@solana/web3.js");
5
- const getStakeVaultPDA = (programId, vaultName) => {
6
- return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('stake_vault'), Buffer.from(vaultName)], programId)[0];
7
- };
8
- exports.getStakeVaultPDA = getStakeVaultPDA;
9
5
  const getStakePDA = (programId, wallet, name) => {
10
6
  return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('stake'), wallet.toBuffer(), Buffer.from(name)], programId)[0];
11
7
  };
@@ -1,5 +1,5 @@
1
1
  import { RpcOptions } from '../types';
2
2
  import { MethodsBuilder } from '@coral-xyz/anchor/dist/cjs/program/namespace/methods';
3
3
  import { TriadProtocol } from '../types/triad_protocol';
4
- declare const sendTransactionWithOptions: (method: MethodsBuilder<TriadProtocol, any, any>, options?: RpcOptions) => Promise<string>;
5
- export default sendTransactionWithOptions;
4
+ declare const sendMethod: (method: MethodsBuilder<TriadProtocol, any, any>, options?: RpcOptions) => Promise<string>;
5
+ export default sendMethod;
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const web3_js_1 = require("@solana/web3.js");
16
16
  const getPriorityFee_1 = __importDefault(require("./getPriorityFee"));
17
- const sendTransactionWithOptions = (method, options) => __awaiter(void 0, void 0, void 0, function* () {
17
+ const sendMethod = (method, options) => __awaiter(void 0, void 0, void 0, function* () {
18
18
  if (options === null || options === void 0 ? void 0 : options.microLamports) {
19
19
  method.postInstructions([
20
20
  web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
@@ -32,4 +32,4 @@ const sendTransactionWithOptions = (method, options) => __awaiter(void 0, void 0
32
32
  }
33
33
  return method.rpc({ skipPreflight: options === null || options === void 0 ? void 0 : options.skipPreflight });
34
34
  });
35
- exports.default = sendTransactionWithOptions;
35
+ exports.default = sendMethod;
@@ -1,7 +1,8 @@
1
1
  import { TransactionInstruction } from '@solana/web3.js';
2
2
  import { RpcOptions } from '../types';
3
3
  import { AddressLookupTableAccount } from '@solana/web3.js';
4
- import { AnchorProvider } from '@coral-xyz/anchor';
4
+ import { Program } from '@coral-xyz/anchor';
5
5
  import { Keypair } from '@solana/web3.js';
6
- declare const sendVersionedTransaction: (provider: AnchorProvider, ixs: TransactionInstruction[], options?: RpcOptions, payer?: Keypair, addressLookupTableAccounts?: AddressLookupTableAccount[], verifier?: Keypair) => Promise<string>;
6
+ import { TriadProtocol } from '../types/triad_protocol';
7
+ declare const sendVersionedTransaction: (program: Program<TriadProtocol>, ixs: TransactionInstruction[], options?: RpcOptions, addressLookupTableAccounts?: AddressLookupTableAccount[], verifier?: Keypair) => Promise<string>;
7
8
  export default sendVersionedTransaction;
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const web3_js_1 = require("@solana/web3.js");
16
16
  const getPriorityFee_1 = __importDefault(require("./getPriorityFee"));
17
- const sendVersionedTransaction = (provider, ixs, options, payer, addressLookupTableAccounts, verifier) => __awaiter(void 0, void 0, void 0, function* () {
17
+ const sendVersionedTransaction = (program, ixs, options, addressLookupTableAccounts, verifier) => __awaiter(void 0, void 0, void 0, function* () {
18
18
  if (options === null || options === void 0 ? void 0 : options.microLamports) {
19
19
  ixs.push(web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
20
20
  microLamports: options.microLamports
@@ -26,22 +26,18 @@ const sendVersionedTransaction = (provider, ixs, options, payer, addressLookupTa
26
26
  microLamports: priorityFee
27
27
  }));
28
28
  }
29
- const { blockhash } = yield provider.connection.getLatestBlockhash();
29
+ const { blockhash } = yield program.provider.connection.getLatestBlockhash();
30
30
  const tx = new web3_js_1.VersionedTransaction(new web3_js_1.TransactionMessage({
31
31
  instructions: ixs,
32
32
  recentBlockhash: blockhash,
33
- payerKey: provider.publicKey
33
+ payerKey: program.provider.publicKey
34
34
  }).compileToV0Message(addressLookupTableAccounts));
35
35
  let signers = [];
36
- if (payer) {
37
- tx.sign([payer]);
38
- signers.push(payer);
39
- }
40
36
  if (verifier) {
41
37
  tx.sign([verifier]);
42
38
  signers.push(verifier);
43
39
  }
44
- return provider.sendAndConfirm(tx, signers, {
40
+ return program.provider.sendAndConfirm(tx, signers, {
45
41
  skipPreflight: options === null || options === void 0 ? void 0 : options.skipPreflight,
46
42
  commitment: 'confirmed'
47
43
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "1.9.8-beta",
3
+ "version": "2.0.0-beta",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -23,11 +23,11 @@
23
23
  "blockchain",
24
24
  "protocol",
25
25
  "triad",
26
- "trading protocols",
27
- "dex",
28
- "SPL 404"
26
+ "prediction markets",
27
+ "prediction markets on solana",
28
+ "only possible on solana"
29
29
  ],
30
- "author": "Triad Labs",
30
+ "author": "Triad Markets",
31
31
  "license": "ISC",
32
32
  "dependencies": {
33
33
  "@coral-xyz/anchor": "0.30.1",
@@ -1,3 +0,0 @@
1
- import { BN } from '@coral-xyz/anchor';
2
- declare const formatNumber: (number: bigint | BN, decimals?: number) => number;
3
- export default formatNumber;
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const formatNumber = (number, decimals = 6) => {
4
- return Number(number.toString()) / Math.pow(10, decimals);
5
- };
6
- exports.default = formatNumber;
@@ -1,5 +0,0 @@
1
- import { PublicKey } from '@solana/web3.js';
2
- export declare const getMarketPDA: (programId: PublicKey, marketId: number) => PublicKey;
3
- export declare const getCustomerPDA: (programId: PublicKey, customerId: number) => PublicKey;
4
- export declare const getUserTradePDA: (programId: PublicKey, wallet: PublicKey) => PublicKey;
5
- export declare const getSubUserTradePDA: (programId: PublicKey, wallet: PublicKey, nonce: number) => PublicKey;
@@ -1,28 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getSubUserTradePDA = exports.getUserTradePDA = exports.getCustomerPDA = exports.getMarketPDA = void 0;
7
- const web3_js_1 = require("@solana/web3.js");
8
- const bn_js_1 = __importDefault(require("bn.js"));
9
- const getMarketPDA = (programId, marketId) => {
10
- return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('market'), new bn_js_1.default(marketId).toArrayLike(Buffer, 'le', 8)], programId)[0];
11
- };
12
- exports.getMarketPDA = getMarketPDA;
13
- const getCustomerPDA = (programId, customerId) => {
14
- return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('customer'), new bn_js_1.default(customerId).toArrayLike(Buffer, 'le', 8)], programId)[0];
15
- };
16
- exports.getCustomerPDA = getCustomerPDA;
17
- const getUserTradePDA = (programId, wallet) => {
18
- return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('user_trade'), wallet.toBuffer()], programId)[0];
19
- };
20
- exports.getUserTradePDA = getUserTradePDA;
21
- const getSubUserTradePDA = (programId, wallet, nonce) => {
22
- return web3_js_1.PublicKey.findProgramAddressSync([
23
- Buffer.from('sub_user_trade'),
24
- wallet.toBuffer(),
25
- new bn_js_1.default(nonce).toArrayLike(Buffer, 'le', 8)
26
- ], programId)[0];
27
- };
28
- exports.getSubUserTradePDA = getSubUserTradePDA;