@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.
- package/dist/index.js +20 -20
- package/dist/stake.d.ts +2 -3
- package/dist/stake.js +30 -46
- package/dist/trade.d.ts +3 -4
- package/dist/trade.js +152 -162
- package/dist/types/idl_triad_protocol.json +93 -103
- package/dist/types/triad_protocol.d.ts +138 -129
- package/dist/utils/constants.d.ts +0 -3
- package/dist/utils/constants.js +1 -4
- package/dist/utils/helpers.d.ts +7 -5
- package/dist/utils/helpers.js +15 -15
- package/dist/utils/pda/index.d.ts +4 -5
- package/dist/utils/pda/index.js +17 -17
- package/dist/utils/pda/poseidon.d.ts +4 -0
- package/dist/utils/pda/poseidon.js +20 -0
- package/dist/utils/pda/stake.d.ts +0 -1
- package/dist/utils/pda/stake.js +1 -5
- package/dist/utils/{sendTransactionWithOptions.d.ts → sendMethod.d.ts} +2 -2
- package/dist/utils/{sendTransactionWithOptions.js → sendMethod.js} +2 -2
- package/dist/utils/sendVersionedTransaction.d.ts +3 -2
- package/dist/utils/sendVersionedTransaction.js +4 -8
- package/package.json +5 -5
- package/dist/utils/formatNumber.d.ts +0 -3
- package/dist/utils/formatNumber.js +0 -6
- package/dist/utils/pda/trade.d.ts +0 -5
- package/dist/utils/pda/trade.js +0 -28
|
@@ -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";
|
package/dist/utils/constants.js
CHANGED
|
@@ -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.
|
|
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';
|
package/dist/utils/helpers.d.ts
CHANGED
|
@@ -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:
|
|
7
|
-
export declare const formatStake: (stake:
|
|
8
|
-
export declare const formatMarket: (account:
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const
|
|
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: {
|
package/dist/utils/helpers.js
CHANGED
|
@@ -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.
|
|
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.
|
|
82
|
+
marketLiquidityAtStart: account.marketLiquidityAtStart.toNumber() > 0
|
|
83
83
|
? account.marketLiquidityAtStart.toString()
|
|
84
84
|
: '0',
|
|
85
85
|
payoutFee: account.payoutFee,
|
|
86
|
-
customer: account.
|
|
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
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
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;
|
package/dist/utils/pda/index.js
CHANGED
|
@@ -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.
|
|
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
|
|
19
|
-
return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('
|
|
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.
|
|
22
|
-
const
|
|
23
|
-
return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('
|
|
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.
|
|
26
|
-
const
|
|
27
|
-
return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('
|
|
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.
|
|
30
|
-
const
|
|
31
|
-
return web3_js_1.PublicKey.findProgramAddressSync([
|
|
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.
|
|
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;
|
package/dist/utils/pda/stake.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getStakePDA =
|
|
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
|
|
5
|
-
export default
|
|
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
|
|
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 =
|
|
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 {
|
|
4
|
+
import { Program } from '@coral-xyz/anchor';
|
|
5
5
|
import { Keypair } from '@solana/web3.js';
|
|
6
|
-
|
|
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 = (
|
|
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": "
|
|
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
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
26
|
+
"prediction markets",
|
|
27
|
+
"prediction markets on solana",
|
|
28
|
+
"only possible on solana"
|
|
29
29
|
],
|
|
30
|
-
"author": "Triad
|
|
30
|
+
"author": "Triad Markets",
|
|
31
31
|
"license": "ISC",
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@coral-xyz/anchor": "0.30.1",
|
|
@@ -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;
|
package/dist/utils/pda/trade.js
DELETED
|
@@ -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;
|