@triadxyz/triad-protocol 2.1.1-beta → 2.1.3-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 +51 -24
- package/dist/stake.js +41 -25
- package/dist/trade.d.ts +11 -2
- package/dist/trade.js +164 -65
- package/dist/types/idl_triad_protocol.json +161 -18
- package/dist/types/trade.d.ts +14 -1
- package/dist/types/triad_protocol.d.ts +161 -18
- package/dist/utils/helpers.js +0 -1
- package/dist/utils/pda/index.d.ts +1 -0
- package/dist/utils/pda/index.js +5 -1
- package/package.json +1 -1
- package/dist/utils/sendMethod.d.ts +0 -5
- package/dist/utils/sendMethod.js +0 -35
package/dist/index.js
CHANGED
|
@@ -19,7 +19,6 @@ const poseidon_1 = require("./utils/pda/poseidon");
|
|
|
19
19
|
const stake_1 = __importDefault(require("./stake"));
|
|
20
20
|
const sendVersionedTransaction_1 = __importDefault(require("./utils/sendVersionedTransaction"));
|
|
21
21
|
const constants_1 = require("./utils/constants");
|
|
22
|
-
const sendMethod_1 = __importDefault(require("./utils/sendMethod"));
|
|
23
22
|
const pda_1 = require("./utils/pda");
|
|
24
23
|
class TriadProtocolClient {
|
|
25
24
|
constructor(connection, wallet) {
|
|
@@ -68,13 +67,20 @@ class TriadProtocolClient {
|
|
|
68
67
|
* @param options - RPC options
|
|
69
68
|
*/
|
|
70
69
|
withdrawPoseidon({ poseidonAsset, nft }, options) {
|
|
71
|
-
return (0,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
const ixs = [];
|
|
72
|
+
ixs.push(yield this.program.methods
|
|
73
|
+
.withdrawPoseidon()
|
|
74
|
+
.accounts({
|
|
75
|
+
signer: this.provider.wallet.publicKey,
|
|
76
|
+
nft: (0, poseidon_1.getPoseidonPDA)(this.program.programId, nft),
|
|
77
|
+
poseidonAsset,
|
|
78
|
+
poseidonCollection: (0, poseidon_1.getCollectionPDA)(this.program.programId, constants_1.POSEIDON_COLLECTION_SYMBOL),
|
|
79
|
+
corePoseidonCollection: constants_1.POSEIDON_CORE_COLLECTION
|
|
80
|
+
})
|
|
81
|
+
.instruction());
|
|
82
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
|
|
83
|
+
});
|
|
78
84
|
}
|
|
79
85
|
/**
|
|
80
86
|
* Collect Royalty
|
|
@@ -83,10 +89,17 @@ class TriadProtocolClient {
|
|
|
83
89
|
* @param options - RPC options
|
|
84
90
|
*/
|
|
85
91
|
collectRoyalty(collection, options) {
|
|
86
|
-
return (0,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
92
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
const ixs = [];
|
|
94
|
+
ixs.push(yield this.program.methods
|
|
95
|
+
.collectRoyalty()
|
|
96
|
+
.accounts({
|
|
97
|
+
signer: this.provider.wallet.publicKey,
|
|
98
|
+
collection: (0, poseidon_1.getCollectionPDA)(this.program.programId, collection)
|
|
99
|
+
})
|
|
100
|
+
.instruction());
|
|
101
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
|
|
102
|
+
});
|
|
90
103
|
}
|
|
91
104
|
/**
|
|
92
105
|
* Add Trader Poseidon
|
|
@@ -96,12 +109,19 @@ class TriadProtocolClient {
|
|
|
96
109
|
* @param options - RPC options
|
|
97
110
|
*/
|
|
98
111
|
addTraderPoseidon({ user, poseidonAsset }, options) {
|
|
99
|
-
return (0,
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
112
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
+
const ixs = [];
|
|
114
|
+
ixs.push(yield this.program.methods
|
|
115
|
+
.addTraderPoseidon()
|
|
116
|
+
.accounts({
|
|
117
|
+
poseidonAsset,
|
|
118
|
+
userTrade: (0, pda_1.getUserTradePDA)(this.program.programId, user),
|
|
119
|
+
corePoseidonCollection: constants_1.POSEIDON_CORE_COLLECTION,
|
|
120
|
+
poseidonCollection: (0, poseidon_1.getCollectionPDA)(this.program.programId, constants_1.POSEIDON_COLLECTION_SYMBOL)
|
|
121
|
+
})
|
|
122
|
+
.instruction());
|
|
123
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
|
|
124
|
+
});
|
|
105
125
|
}
|
|
106
126
|
/**
|
|
107
127
|
* Remove Trader Poseidon
|
|
@@ -110,12 +130,19 @@ class TriadProtocolClient {
|
|
|
110
130
|
* @param options - RPC options
|
|
111
131
|
*/
|
|
112
132
|
removeTraderPoseidon({ user, poseidonAsset }, options) {
|
|
113
|
-
return (0,
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
133
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
134
|
+
const ixs = [];
|
|
135
|
+
ixs.push(yield this.program.methods
|
|
136
|
+
.removeTraderPoseidon()
|
|
137
|
+
.accounts({
|
|
138
|
+
userTrade: (0, pda_1.getUserTradePDA)(this.program.programId, user),
|
|
139
|
+
poseidonAsset,
|
|
140
|
+
corePoseidonCollection: constants_1.POSEIDON_CORE_COLLECTION,
|
|
141
|
+
poseidonCollection: (0, poseidon_1.getCollectionPDA)(this.program.programId, constants_1.POSEIDON_COLLECTION_SYMBOL)
|
|
142
|
+
})
|
|
143
|
+
.instruction());
|
|
144
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
|
|
145
|
+
});
|
|
119
146
|
}
|
|
120
147
|
}
|
|
121
148
|
exports.default = TriadProtocolClient;
|
package/dist/stake.js
CHANGED
|
@@ -17,7 +17,6 @@ const helpers_1 = require("./utils/helpers");
|
|
|
17
17
|
const stake_1 = require("./utils/pda/stake");
|
|
18
18
|
const constants_1 = require("./utils/constants");
|
|
19
19
|
const sendVersionedTransaction_1 = __importDefault(require("./utils/sendVersionedTransaction"));
|
|
20
|
-
const sendMethod_1 = __importDefault(require("./utils/sendMethod"));
|
|
21
20
|
class Stake {
|
|
22
21
|
constructor(program) {
|
|
23
22
|
this.program = program;
|
|
@@ -80,15 +79,20 @@ class Stake {
|
|
|
80
79
|
*
|
|
81
80
|
*/
|
|
82
81
|
stakeToken({ name, wallet, amount }, options) {
|
|
83
|
-
return (0,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
const ixs = [];
|
|
84
|
+
ixs.push(yield this.program.methods
|
|
85
|
+
.stakeToken({
|
|
86
|
+
name,
|
|
87
|
+
amount: new anchor_1.BN(amount * Math.pow(10, 6))
|
|
88
|
+
})
|
|
89
|
+
.accounts({
|
|
90
|
+
signer: wallet,
|
|
91
|
+
mint: constants_1.TRD_MINT
|
|
92
|
+
})
|
|
93
|
+
.instruction());
|
|
94
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
|
|
95
|
+
});
|
|
92
96
|
}
|
|
93
97
|
/**
|
|
94
98
|
* Update Stake Vault
|
|
@@ -99,15 +103,20 @@ class Stake {
|
|
|
99
103
|
*
|
|
100
104
|
*/
|
|
101
105
|
updateStakeVault({ amount, isLocked }, options) {
|
|
102
|
-
return (0,
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
106
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
const ixs = [];
|
|
108
|
+
ixs.push(yield this.program.methods
|
|
109
|
+
.updateStakeVault({
|
|
110
|
+
amount,
|
|
111
|
+
isLocked
|
|
112
|
+
})
|
|
113
|
+
.accounts({
|
|
114
|
+
signer: this.program.provider.publicKey,
|
|
115
|
+
mint: constants_1.TRD_MINT
|
|
116
|
+
})
|
|
117
|
+
.instruction());
|
|
118
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
|
|
119
|
+
});
|
|
111
120
|
}
|
|
112
121
|
/**
|
|
113
122
|
* Request Withdraw
|
|
@@ -142,12 +151,19 @@ class Stake {
|
|
|
142
151
|
*
|
|
143
152
|
*/
|
|
144
153
|
withdrawStake({ wallet, name, mint }, options) {
|
|
145
|
-
return (0,
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
154
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
155
|
+
const ixs = [];
|
|
156
|
+
ixs.push(yield this.program.methods
|
|
157
|
+
.withdrawStake()
|
|
158
|
+
.accounts({
|
|
159
|
+
signer: wallet,
|
|
160
|
+
stake: (0, stake_1.getStakePDA)(this.program.programId, wallet, name),
|
|
161
|
+
admin: constants_1.TRIAD_ADMIN,
|
|
162
|
+
mint: mint
|
|
163
|
+
})
|
|
164
|
+
.instruction());
|
|
165
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
|
|
166
|
+
});
|
|
151
167
|
}
|
|
152
168
|
/**
|
|
153
169
|
* Claim Stake Rewards
|
package/dist/trade.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Program } from '@coral-xyz/anchor';
|
|
2
2
|
import { TriadProtocol } from './types/triad_protocol';
|
|
3
3
|
import { PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
4
|
-
import { CreateMarketArgs, OpenOrderArgs, UserTrade, CreateCustomerArgs, Order, MarketBidOrderArgs, CancelBidOrderArgs, CancelAskOrderArgs, PlaceBidOrderArgs, PlaceAskOrderArgs } from './types/trade';
|
|
4
|
+
import { CreateMarketArgs, OpenOrderArgs, UserTrade, CreateCustomerArgs, Order, MarketBidOrderArgs, CancelBidOrderArgs, CancelAskOrderArgs, PlaceBidOrderArgs, PlaceAskOrderArgs, CreatePoolArgs } from './types/trade';
|
|
5
5
|
import { RpcOptions } from './types';
|
|
6
6
|
import BN from 'bn.js';
|
|
7
7
|
export default class Trade {
|
|
@@ -48,7 +48,7 @@ export default class Trade {
|
|
|
48
48
|
authority: PublicKey;
|
|
49
49
|
totalDeposits: BN;
|
|
50
50
|
totalWithdraws: BN;
|
|
51
|
-
|
|
51
|
+
version: BN;
|
|
52
52
|
orders: {
|
|
53
53
|
ts: BN;
|
|
54
54
|
orderId: BN;
|
|
@@ -157,6 +157,15 @@ export default class Trade {
|
|
|
157
157
|
*
|
|
158
158
|
*/
|
|
159
159
|
createMarket({ marketId, startTime, endTime, question, feeBps, customer, payoutFee, mint }: CreateMarketArgs, options?: RpcOptions): Promise<string>;
|
|
160
|
+
/**
|
|
161
|
+
* Create Pool
|
|
162
|
+
* @param poolId - The ID of the pool
|
|
163
|
+
* @param question - The question of the pool
|
|
164
|
+
* @param markets - The markets of the pool
|
|
165
|
+
*
|
|
166
|
+
* @param options - RPC options
|
|
167
|
+
*/
|
|
168
|
+
createPool({ poolId, question, markets, mint, customer, startTime, endTime, feeBps, payoutFee }: CreatePoolArgs, options?: RpcOptions): Promise<string>;
|
|
160
169
|
/**
|
|
161
170
|
* Open Order
|
|
162
171
|
* @param args.marketId - The ID of the Market
|
package/dist/trade.js
CHANGED
|
@@ -19,7 +19,6 @@ const constants_1 = require("./utils/constants");
|
|
|
19
19
|
const helpers_1 = require("./utils/helpers");
|
|
20
20
|
const pda_1 = require("./utils/pda");
|
|
21
21
|
const sendVersionedTransaction_1 = __importDefault(require("./utils/sendVersionedTransaction"));
|
|
22
|
-
const sendMethod_1 = __importDefault(require("./utils/sendMethod"));
|
|
23
22
|
const bytes_1 = require("@coral-xyz/anchor/dist/cjs/utils/bytes");
|
|
24
23
|
const pda_2 = require("./utils/pda");
|
|
25
24
|
class Trade {
|
|
@@ -118,24 +117,79 @@ class Trade {
|
|
|
118
117
|
*
|
|
119
118
|
*/
|
|
120
119
|
createMarket({ marketId, startTime, endTime, question, feeBps, customer, payoutFee, mint }, options) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
120
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
+
if (question.length > 80) {
|
|
122
|
+
throw new Error('Question must be less than 80 characters');
|
|
123
|
+
}
|
|
124
|
+
const ixs = [];
|
|
125
|
+
ixs.push(yield this.program.methods
|
|
126
|
+
.createMarket({
|
|
127
|
+
marketId: new bn_js_1.default(marketId),
|
|
128
|
+
question: (0, helpers_1.encodeString)(question, 80),
|
|
129
|
+
marketStart: new bn_js_1.default(startTime),
|
|
130
|
+
marketEnd: new bn_js_1.default(endTime),
|
|
131
|
+
feeBps,
|
|
132
|
+
payoutFee
|
|
133
|
+
})
|
|
134
|
+
.accounts({
|
|
135
|
+
signer: this.program.provider.publicKey,
|
|
136
|
+
mint,
|
|
137
|
+
tokenProgram: (0, helpers_1.getTokenProgram)(mint),
|
|
138
|
+
customer,
|
|
139
|
+
pool: null
|
|
140
|
+
})
|
|
141
|
+
.instruction());
|
|
142
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Create Pool
|
|
147
|
+
* @param poolId - The ID of the pool
|
|
148
|
+
* @param question - The question of the pool
|
|
149
|
+
* @param markets - The markets of the pool
|
|
150
|
+
*
|
|
151
|
+
* @param options - RPC options
|
|
152
|
+
*/
|
|
153
|
+
createPool({ poolId, question, markets, mint, customer, startTime, endTime, feeBps, payoutFee }, options) {
|
|
154
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
155
|
+
if (question.length > 80) {
|
|
156
|
+
throw new Error('Pool question must be less than 80 characters');
|
|
157
|
+
}
|
|
158
|
+
const ixs = [];
|
|
159
|
+
const poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
|
|
160
|
+
ixs.push(yield this.program.methods
|
|
161
|
+
.createPool({
|
|
162
|
+
poolId: new bn_js_1.default(poolId),
|
|
163
|
+
question: (0, helpers_1.encodeString)(question, 80)
|
|
164
|
+
})
|
|
165
|
+
.accounts({
|
|
166
|
+
signer: this.program.provider.publicKey
|
|
167
|
+
})
|
|
168
|
+
.instruction());
|
|
169
|
+
for (const market of markets) {
|
|
170
|
+
if (market.question.length > 80) {
|
|
171
|
+
throw new Error('Market question must be less than 80 characters');
|
|
172
|
+
}
|
|
173
|
+
ixs.push(yield this.program.methods
|
|
174
|
+
.createMarket({
|
|
175
|
+
marketId: new bn_js_1.default(market.marketId),
|
|
176
|
+
question: (0, helpers_1.encodeString)(market.question, 80),
|
|
177
|
+
marketStart: new bn_js_1.default(startTime),
|
|
178
|
+
marketEnd: new bn_js_1.default(endTime),
|
|
179
|
+
feeBps,
|
|
180
|
+
payoutFee
|
|
181
|
+
})
|
|
182
|
+
.accounts({
|
|
183
|
+
signer: this.program.provider.publicKey,
|
|
184
|
+
mint,
|
|
185
|
+
tokenProgram: (0, helpers_1.getTokenProgram)(mint),
|
|
186
|
+
pool: poolPDA,
|
|
187
|
+
customer
|
|
188
|
+
})
|
|
189
|
+
.instruction());
|
|
190
|
+
}
|
|
191
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
|
|
192
|
+
});
|
|
139
193
|
}
|
|
140
194
|
/**
|
|
141
195
|
* Open Order
|
|
@@ -181,17 +235,22 @@ class Trade {
|
|
|
181
235
|
*/
|
|
182
236
|
closeOrder({ marketId, orderId, userNonce }, options) {
|
|
183
237
|
return __awaiter(this, void 0, void 0, function* () {
|
|
238
|
+
const ixs = [];
|
|
184
239
|
let userTradePDA = (0, pda_1.getUserTradePDA)(this.program.programId, this.program.provider.publicKey);
|
|
185
240
|
if (userNonce !== 0) {
|
|
186
241
|
const subUserTradePDA = (0, pda_1.getSubUserTradePDA)(this.program.programId, this.program.provider.publicKey, userNonce);
|
|
187
242
|
userTradePDA = (0, pda_1.getUserTradePDA)(this.program.programId, subUserTradePDA);
|
|
188
243
|
}
|
|
189
|
-
|
|
244
|
+
ixs.push(yield this.program.methods
|
|
245
|
+
.closeOrder(new bn_js_1.default(orderId))
|
|
246
|
+
.accounts({
|
|
190
247
|
signer: this.program.provider.publicKey,
|
|
191
248
|
market: (0, pda_1.getMarketPDA)(this.program.programId, marketId),
|
|
192
249
|
mint: constants_1.TRD_MINT,
|
|
193
250
|
userTrade: userTradePDA
|
|
194
|
-
})
|
|
251
|
+
})
|
|
252
|
+
.instruction());
|
|
253
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
|
|
195
254
|
});
|
|
196
255
|
}
|
|
197
256
|
/**
|
|
@@ -203,16 +262,21 @@ class Trade {
|
|
|
203
262
|
*
|
|
204
263
|
*/
|
|
205
264
|
resolveMarket({ marketId, winningDirection }, options) {
|
|
206
|
-
return (0,
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
265
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
266
|
+
const ixs = [];
|
|
267
|
+
ixs.push(yield this.program.methods
|
|
268
|
+
.updateMarket({
|
|
269
|
+
winningDirection,
|
|
270
|
+
allowPayout: null,
|
|
271
|
+
marketEnd: null
|
|
272
|
+
})
|
|
273
|
+
.accounts({
|
|
274
|
+
signer: this.program.provider.publicKey,
|
|
275
|
+
market: (0, pda_1.getMarketPDA)(this.program.programId, marketId)
|
|
276
|
+
})
|
|
277
|
+
.instruction());
|
|
278
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
|
|
279
|
+
});
|
|
216
280
|
}
|
|
217
281
|
/**
|
|
218
282
|
* Collect Remaining Liquidity
|
|
@@ -223,13 +287,18 @@ class Trade {
|
|
|
223
287
|
*/
|
|
224
288
|
collectRemainingLiquidity(marketId, options) {
|
|
225
289
|
return __awaiter(this, void 0, void 0, function* () {
|
|
290
|
+
const ixs = [];
|
|
226
291
|
const marketPDA = (0, pda_1.getMarketPDA)(this.program.programId, marketId);
|
|
227
292
|
const market = yield this.getMarketByAddress(marketPDA);
|
|
228
|
-
|
|
293
|
+
ixs.push(yield this.program.methods
|
|
294
|
+
.collectRemainingLiquidity()
|
|
295
|
+
.accounts({
|
|
229
296
|
signer: this.program.provider.publicKey,
|
|
230
297
|
market: marketPDA,
|
|
231
298
|
mint: market.mint
|
|
232
|
-
})
|
|
299
|
+
})
|
|
300
|
+
.instruction());
|
|
301
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
|
|
233
302
|
});
|
|
234
303
|
}
|
|
235
304
|
/**
|
|
@@ -275,16 +344,21 @@ class Trade {
|
|
|
275
344
|
*
|
|
276
345
|
*/
|
|
277
346
|
allowMarketToPayout(marketId, options) {
|
|
278
|
-
return (0,
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
347
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
348
|
+
const ixs = [];
|
|
349
|
+
ixs.push(yield this.program.methods
|
|
350
|
+
.updateMarket({
|
|
351
|
+
winningDirection: null,
|
|
352
|
+
allowPayout: true,
|
|
353
|
+
marketEnd: null
|
|
354
|
+
})
|
|
355
|
+
.accounts({
|
|
356
|
+
signer: this.program.provider.publicKey,
|
|
357
|
+
market: (0, pda_1.getMarketPDA)(this.program.programId, marketId)
|
|
358
|
+
})
|
|
359
|
+
.instruction());
|
|
360
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
|
|
361
|
+
});
|
|
288
362
|
}
|
|
289
363
|
/**
|
|
290
364
|
* Create Sub User Trade
|
|
@@ -295,11 +369,16 @@ class Trade {
|
|
|
295
369
|
*/
|
|
296
370
|
createSubUserTrade(user, options) {
|
|
297
371
|
return __awaiter(this, void 0, void 0, function* () {
|
|
372
|
+
const ixs = [];
|
|
298
373
|
const userTrade = yield this.getUserTrade(user);
|
|
299
374
|
const subUserTradePDA = (0, pda_1.getSubUserTradePDA)(this.program.programId, user, userTrade.nonce + 1);
|
|
300
|
-
|
|
375
|
+
ixs.push(yield this.program.methods
|
|
376
|
+
.createSubUserTrade(subUserTradePDA)
|
|
377
|
+
.accounts({
|
|
301
378
|
signer: this.program.provider.publicKey
|
|
302
|
-
})
|
|
379
|
+
})
|
|
380
|
+
.instruction());
|
|
381
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
|
|
303
382
|
});
|
|
304
383
|
}
|
|
305
384
|
/**
|
|
@@ -311,16 +390,21 @@ class Trade {
|
|
|
311
390
|
*
|
|
312
391
|
*/
|
|
313
392
|
updateMarket(marketId, marketEnd, options) {
|
|
314
|
-
return (0,
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
393
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
394
|
+
const ixs = [];
|
|
395
|
+
ixs.push(yield this.program.methods
|
|
396
|
+
.updateMarket({
|
|
397
|
+
marketEnd: new bn_js_1.default(marketEnd),
|
|
398
|
+
winningDirection: null,
|
|
399
|
+
allowPayout: null
|
|
400
|
+
})
|
|
401
|
+
.accounts({
|
|
402
|
+
signer: this.program.provider.publicKey,
|
|
403
|
+
market: (0, pda_1.getMarketPDA)(this.program.programId, marketId)
|
|
404
|
+
})
|
|
405
|
+
.instruction());
|
|
406
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
|
|
407
|
+
});
|
|
324
408
|
}
|
|
325
409
|
/**
|
|
326
410
|
* Create Customer
|
|
@@ -332,11 +416,16 @@ class Trade {
|
|
|
332
416
|
*
|
|
333
417
|
*/
|
|
334
418
|
createCustomer({ id, name, authority, feeRecipient }, options) {
|
|
335
|
-
return (0,
|
|
336
|
-
|
|
337
|
-
.
|
|
338
|
-
|
|
339
|
-
|
|
419
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
420
|
+
const ixs = [];
|
|
421
|
+
ixs.push(yield this.program.methods
|
|
422
|
+
.createCustomer({ id, name, authority, feeRecipient })
|
|
423
|
+
.accounts({
|
|
424
|
+
signer: this.program.provider.publicKey
|
|
425
|
+
})
|
|
426
|
+
.instruction());
|
|
427
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
|
|
428
|
+
});
|
|
340
429
|
}
|
|
341
430
|
/**
|
|
342
431
|
* Get User Trade Nonce With Slots
|
|
@@ -499,18 +588,23 @@ class Trade {
|
|
|
499
588
|
*/
|
|
500
589
|
cancelBidOrder({ marketId, orderId, userNonce, mint }, options) {
|
|
501
590
|
return __awaiter(this, void 0, void 0, function* () {
|
|
591
|
+
const ixs = [];
|
|
502
592
|
let userTradePDA = (0, pda_1.getUserTradePDA)(this.program.programId, this.program.provider.publicKey);
|
|
503
593
|
if (userNonce !== 0) {
|
|
504
594
|
const subUserTradePDA = (0, pda_1.getSubUserTradePDA)(this.program.programId, this.program.provider.publicKey, userNonce);
|
|
505
595
|
userTradePDA = (0, pda_1.getUserTradePDA)(this.program.programId, subUserTradePDA);
|
|
506
596
|
}
|
|
507
|
-
|
|
597
|
+
ixs.push(yield this.program.methods
|
|
598
|
+
.cancelBidOrder(new bn_js_1.default(orderId))
|
|
599
|
+
.accounts({
|
|
508
600
|
signer: this.program.provider.publicKey,
|
|
509
601
|
market: (0, pda_1.getMarketPDA)(this.program.programId, marketId),
|
|
510
|
-
|
|
602
|
+
bidUserTrade: userTradePDA,
|
|
511
603
|
mint,
|
|
512
604
|
tokenProgram: (0, helpers_1.getTokenProgram)(mint)
|
|
513
|
-
})
|
|
605
|
+
})
|
|
606
|
+
.instruction());
|
|
607
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
|
|
514
608
|
});
|
|
515
609
|
}
|
|
516
610
|
/**
|
|
@@ -524,6 +618,7 @@ class Trade {
|
|
|
524
618
|
*/
|
|
525
619
|
cancelAskOrder({ marketId, orderId, userNonce, userNonceBidOrder }, options) {
|
|
526
620
|
return __awaiter(this, void 0, void 0, function* () {
|
|
621
|
+
const ixs = [];
|
|
527
622
|
let askUserTradePDA = (0, pda_1.getUserTradePDA)(this.program.programId, this.program.provider.publicKey);
|
|
528
623
|
if (userNonce !== 0) {
|
|
529
624
|
const subUserTradePDA = (0, pda_1.getSubUserTradePDA)(this.program.programId, this.program.provider.publicKey, userNonce);
|
|
@@ -534,12 +629,16 @@ class Trade {
|
|
|
534
629
|
const subUserTradePDA = (0, pda_1.getSubUserTradePDA)(this.program.programId, this.program.provider.publicKey, userNonceBidOrder);
|
|
535
630
|
bidUserTradePDA = (0, pda_1.getUserTradePDA)(this.program.programId, subUserTradePDA);
|
|
536
631
|
}
|
|
537
|
-
|
|
632
|
+
ixs.push(yield this.program.methods
|
|
633
|
+
.cancelAskOrder(new bn_js_1.default(orderId))
|
|
634
|
+
.accounts({
|
|
538
635
|
signer: this.program.provider.publicKey,
|
|
539
636
|
market: (0, pda_1.getMarketPDA)(this.program.programId, marketId),
|
|
540
637
|
askUserTrade: askUserTradePDA,
|
|
541
638
|
bidUserTrade: bidUserTradePDA
|
|
542
|
-
})
|
|
639
|
+
})
|
|
640
|
+
.instruction());
|
|
641
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
|
|
543
642
|
});
|
|
544
643
|
}
|
|
545
644
|
/**
|
|
@@ -54,11 +54,11 @@
|
|
|
54
54
|
"signer": true
|
|
55
55
|
},
|
|
56
56
|
{
|
|
57
|
-
"name": "
|
|
57
|
+
"name": "bid_user_trade",
|
|
58
58
|
"writable": true
|
|
59
59
|
},
|
|
60
60
|
{
|
|
61
|
-
"name": "
|
|
61
|
+
"name": "ask_user_trade",
|
|
62
62
|
"writable": true
|
|
63
63
|
},
|
|
64
64
|
{
|
|
@@ -87,11 +87,11 @@
|
|
|
87
87
|
"signer": true
|
|
88
88
|
},
|
|
89
89
|
{
|
|
90
|
-
"name": "
|
|
90
|
+
"name": "market",
|
|
91
91
|
"writable": true
|
|
92
92
|
},
|
|
93
93
|
{
|
|
94
|
-
"name": "
|
|
94
|
+
"name": "bid_user_trade",
|
|
95
95
|
"writable": true
|
|
96
96
|
},
|
|
97
97
|
{
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
}
|
|
128
128
|
},
|
|
129
129
|
{
|
|
130
|
-
"name": "
|
|
130
|
+
"name": "market_ata",
|
|
131
131
|
"writable": true,
|
|
132
132
|
"pda": {
|
|
133
133
|
"seeds": [
|
|
@@ -560,6 +560,11 @@
|
|
|
560
560
|
"writable": true,
|
|
561
561
|
"optional": true
|
|
562
562
|
},
|
|
563
|
+
{
|
|
564
|
+
"name": "pool",
|
|
565
|
+
"writable": true,
|
|
566
|
+
"optional": true
|
|
567
|
+
},
|
|
563
568
|
{
|
|
564
569
|
"name": "market",
|
|
565
570
|
"writable": true,
|
|
@@ -631,6 +636,47 @@
|
|
|
631
636
|
}
|
|
632
637
|
]
|
|
633
638
|
},
|
|
639
|
+
{
|
|
640
|
+
"name": "create_pool",
|
|
641
|
+
"discriminator": [233, 146, 209, 142, 207, 104, 64, 188],
|
|
642
|
+
"accounts": [
|
|
643
|
+
{
|
|
644
|
+
"name": "signer",
|
|
645
|
+
"writable": true,
|
|
646
|
+
"signer": true
|
|
647
|
+
},
|
|
648
|
+
{
|
|
649
|
+
"name": "pool",
|
|
650
|
+
"writable": true,
|
|
651
|
+
"pda": {
|
|
652
|
+
"seeds": [
|
|
653
|
+
{
|
|
654
|
+
"kind": "const",
|
|
655
|
+
"value": [112, 111, 111, 108]
|
|
656
|
+
},
|
|
657
|
+
{
|
|
658
|
+
"kind": "arg",
|
|
659
|
+
"path": "args.pool_id"
|
|
660
|
+
}
|
|
661
|
+
]
|
|
662
|
+
}
|
|
663
|
+
},
|
|
664
|
+
{
|
|
665
|
+
"name": "system_program",
|
|
666
|
+
"address": "11111111111111111111111111111111"
|
|
667
|
+
}
|
|
668
|
+
],
|
|
669
|
+
"args": [
|
|
670
|
+
{
|
|
671
|
+
"name": "args",
|
|
672
|
+
"type": {
|
|
673
|
+
"defined": {
|
|
674
|
+
"name": "CreatePoolArgs"
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
]
|
|
679
|
+
},
|
|
634
680
|
{
|
|
635
681
|
"name": "create_sub_user_trade",
|
|
636
682
|
"discriminator": [77, 201, 111, 73, 47, 229, 244, 161],
|
|
@@ -1120,11 +1166,11 @@
|
|
|
1120
1166
|
"writable": true
|
|
1121
1167
|
},
|
|
1122
1168
|
{
|
|
1123
|
-
"name": "
|
|
1169
|
+
"name": "bid_user_trade",
|
|
1124
1170
|
"writable": true
|
|
1125
1171
|
},
|
|
1126
1172
|
{
|
|
1127
|
-
"name": "
|
|
1173
|
+
"name": "ask_user_trade",
|
|
1128
1174
|
"writable": true
|
|
1129
1175
|
},
|
|
1130
1176
|
{
|
|
@@ -1796,6 +1842,10 @@
|
|
|
1796
1842
|
"name": "Nft",
|
|
1797
1843
|
"discriminator": [88, 10, 146, 176, 101, 11, 40, 217]
|
|
1798
1844
|
},
|
|
1845
|
+
{
|
|
1846
|
+
"name": "Pool",
|
|
1847
|
+
"discriminator": [241, 154, 109, 4, 17, 177, 109, 188]
|
|
1848
|
+
},
|
|
1799
1849
|
{
|
|
1800
1850
|
"name": "StakeV2",
|
|
1801
1851
|
"discriminator": [207, 98, 130, 13, 118, 181, 238, 47]
|
|
@@ -1818,6 +1868,10 @@
|
|
|
1818
1868
|
"name": "OrderEvent",
|
|
1819
1869
|
"discriminator": [209, 51, 146, 206, 88, 127, 112, 69]
|
|
1820
1870
|
},
|
|
1871
|
+
{
|
|
1872
|
+
"name": "PoolEvent",
|
|
1873
|
+
"discriminator": [76, 227, 205, 183, 1, 218, 164, 244]
|
|
1874
|
+
},
|
|
1821
1875
|
{
|
|
1822
1876
|
"name": "PriceEvent",
|
|
1823
1877
|
"discriminator": [31, 40, 141, 125, 132, 253, 225, 229]
|
|
@@ -1967,6 +2021,11 @@
|
|
|
1967
2021
|
"code": 6027,
|
|
1968
2022
|
"name": "LinkedBidOrderNotFound",
|
|
1969
2023
|
"msg": "Linked bid order not found"
|
|
2024
|
+
},
|
|
2025
|
+
{
|
|
2026
|
+
"code": 6028,
|
|
2027
|
+
"name": "MarketAlreadyAggregated",
|
|
2028
|
+
"msg": "Market already aggregated"
|
|
1970
2029
|
}
|
|
1971
2030
|
],
|
|
1972
2031
|
"types": [
|
|
@@ -2140,6 +2199,26 @@
|
|
|
2140
2199
|
]
|
|
2141
2200
|
}
|
|
2142
2201
|
},
|
|
2202
|
+
{
|
|
2203
|
+
"name": "CreatePoolArgs",
|
|
2204
|
+
"type": {
|
|
2205
|
+
"kind": "struct",
|
|
2206
|
+
"fields": [
|
|
2207
|
+
{
|
|
2208
|
+
"name": "pool_id",
|
|
2209
|
+
"type": "u64"
|
|
2210
|
+
},
|
|
2211
|
+
{
|
|
2212
|
+
"name": "question",
|
|
2213
|
+
"type": {
|
|
2214
|
+
"option": {
|
|
2215
|
+
"array": ["u8", 80]
|
|
2216
|
+
}
|
|
2217
|
+
}
|
|
2218
|
+
}
|
|
2219
|
+
]
|
|
2220
|
+
}
|
|
2221
|
+
},
|
|
2143
2222
|
{
|
|
2144
2223
|
"name": "Customer",
|
|
2145
2224
|
"type": {
|
|
@@ -2293,10 +2372,6 @@
|
|
|
2293
2372
|
"name": "update_ts",
|
|
2294
2373
|
"type": "i64"
|
|
2295
2374
|
},
|
|
2296
|
-
{
|
|
2297
|
-
"name": "opened_orders",
|
|
2298
|
-
"type": "u64"
|
|
2299
|
-
},
|
|
2300
2375
|
{
|
|
2301
2376
|
"name": "next_order_id",
|
|
2302
2377
|
"type": "u64"
|
|
@@ -2358,6 +2433,10 @@
|
|
|
2358
2433
|
{
|
|
2359
2434
|
"name": "payout_fee",
|
|
2360
2435
|
"type": "u16"
|
|
2436
|
+
},
|
|
2437
|
+
{
|
|
2438
|
+
"name": "pool_id",
|
|
2439
|
+
"type": "u64"
|
|
2361
2440
|
}
|
|
2362
2441
|
]
|
|
2363
2442
|
}
|
|
@@ -2416,8 +2495,10 @@
|
|
|
2416
2495
|
"type": "i64"
|
|
2417
2496
|
},
|
|
2418
2497
|
{
|
|
2419
|
-
"name": "
|
|
2420
|
-
"type":
|
|
2498
|
+
"name": "padding_1",
|
|
2499
|
+
"type": {
|
|
2500
|
+
"array": ["u8", 8]
|
|
2501
|
+
}
|
|
2421
2502
|
},
|
|
2422
2503
|
{
|
|
2423
2504
|
"name": "next_order_id",
|
|
@@ -2485,10 +2566,14 @@
|
|
|
2485
2566
|
"name": "version",
|
|
2486
2567
|
"type": "u64"
|
|
2487
2568
|
},
|
|
2569
|
+
{
|
|
2570
|
+
"name": "pool_id",
|
|
2571
|
+
"type": "u64"
|
|
2572
|
+
},
|
|
2488
2573
|
{
|
|
2489
2574
|
"name": "padding",
|
|
2490
2575
|
"type": {
|
|
2491
|
-
"array": ["u8",
|
|
2576
|
+
"array": ["u8", 72]
|
|
2492
2577
|
}
|
|
2493
2578
|
}
|
|
2494
2579
|
]
|
|
@@ -2815,6 +2900,66 @@
|
|
|
2815
2900
|
]
|
|
2816
2901
|
}
|
|
2817
2902
|
},
|
|
2903
|
+
{
|
|
2904
|
+
"name": "Pool",
|
|
2905
|
+
"type": {
|
|
2906
|
+
"kind": "struct",
|
|
2907
|
+
"fields": [
|
|
2908
|
+
{
|
|
2909
|
+
"name": "bump",
|
|
2910
|
+
"type": "u8"
|
|
2911
|
+
},
|
|
2912
|
+
{
|
|
2913
|
+
"name": "id",
|
|
2914
|
+
"type": "u64"
|
|
2915
|
+
},
|
|
2916
|
+
{
|
|
2917
|
+
"name": "question",
|
|
2918
|
+
"type": {
|
|
2919
|
+
"array": ["u8", 80]
|
|
2920
|
+
}
|
|
2921
|
+
},
|
|
2922
|
+
{
|
|
2923
|
+
"name": "authority",
|
|
2924
|
+
"type": "pubkey"
|
|
2925
|
+
},
|
|
2926
|
+
{
|
|
2927
|
+
"name": "padding",
|
|
2928
|
+
"type": {
|
|
2929
|
+
"array": ["u8", 64]
|
|
2930
|
+
}
|
|
2931
|
+
}
|
|
2932
|
+
]
|
|
2933
|
+
}
|
|
2934
|
+
},
|
|
2935
|
+
{
|
|
2936
|
+
"name": "PoolEvent",
|
|
2937
|
+
"type": {
|
|
2938
|
+
"kind": "struct",
|
|
2939
|
+
"fields": [
|
|
2940
|
+
{
|
|
2941
|
+
"name": "pool_id",
|
|
2942
|
+
"type": "u64"
|
|
2943
|
+
},
|
|
2944
|
+
{
|
|
2945
|
+
"name": "question",
|
|
2946
|
+
"type": {
|
|
2947
|
+
"array": ["u8", 80]
|
|
2948
|
+
}
|
|
2949
|
+
},
|
|
2950
|
+
{
|
|
2951
|
+
"name": "authority",
|
|
2952
|
+
"type": "pubkey"
|
|
2953
|
+
},
|
|
2954
|
+
{
|
|
2955
|
+
"name": "markets",
|
|
2956
|
+
"type": {
|
|
2957
|
+
"array": ["u64", 60]
|
|
2958
|
+
}
|
|
2959
|
+
}
|
|
2960
|
+
]
|
|
2961
|
+
}
|
|
2962
|
+
},
|
|
2818
2963
|
{
|
|
2819
2964
|
"name": "PriceEvent",
|
|
2820
2965
|
"type": {
|
|
@@ -3108,10 +3253,8 @@
|
|
|
3108
3253
|
"type": "u64"
|
|
3109
3254
|
},
|
|
3110
3255
|
{
|
|
3111
|
-
"name": "
|
|
3112
|
-
"type":
|
|
3113
|
-
"array": ["u8", 8]
|
|
3114
|
-
}
|
|
3256
|
+
"name": "version",
|
|
3257
|
+
"type": "u64"
|
|
3115
3258
|
},
|
|
3116
3259
|
{
|
|
3117
3260
|
"name": "orders",
|
package/dist/types/trade.d.ts
CHANGED
|
@@ -13,7 +13,6 @@ export type Market = {
|
|
|
13
13
|
volume: string;
|
|
14
14
|
mint: string;
|
|
15
15
|
updateTs: string;
|
|
16
|
-
openedOrders: string;
|
|
17
16
|
nextOrderId: string;
|
|
18
17
|
feeBps: number;
|
|
19
18
|
isAllowedToPayout: boolean;
|
|
@@ -139,6 +138,20 @@ export type CreateMarketArgs = {
|
|
|
139
138
|
payoutFee: number;
|
|
140
139
|
mint: PublicKey;
|
|
141
140
|
};
|
|
141
|
+
export type CreatePoolArgs = {
|
|
142
|
+
poolId: number;
|
|
143
|
+
question: string;
|
|
144
|
+
startTime: number;
|
|
145
|
+
endTime: number;
|
|
146
|
+
feeBps: number;
|
|
147
|
+
payoutFee: number;
|
|
148
|
+
mint: PublicKey;
|
|
149
|
+
customer: PublicKey | null;
|
|
150
|
+
markets: {
|
|
151
|
+
marketId: number;
|
|
152
|
+
question: string;
|
|
153
|
+
}[];
|
|
154
|
+
};
|
|
142
155
|
export type CancelBidOrderArgs = {
|
|
143
156
|
marketId: number;
|
|
144
157
|
orderId: number;
|
|
@@ -60,11 +60,11 @@ export type TriadProtocol = {
|
|
|
60
60
|
signer: true;
|
|
61
61
|
},
|
|
62
62
|
{
|
|
63
|
-
name: '
|
|
63
|
+
name: 'bidUserTrade';
|
|
64
64
|
writable: true;
|
|
65
65
|
},
|
|
66
66
|
{
|
|
67
|
-
name: '
|
|
67
|
+
name: 'askUserTrade';
|
|
68
68
|
writable: true;
|
|
69
69
|
},
|
|
70
70
|
{
|
|
@@ -93,11 +93,11 @@ export type TriadProtocol = {
|
|
|
93
93
|
signer: true;
|
|
94
94
|
},
|
|
95
95
|
{
|
|
96
|
-
name: '
|
|
96
|
+
name: 'market';
|
|
97
97
|
writable: true;
|
|
98
98
|
},
|
|
99
99
|
{
|
|
100
|
-
name: '
|
|
100
|
+
name: 'bidUserTrade';
|
|
101
101
|
writable: true;
|
|
102
102
|
},
|
|
103
103
|
{
|
|
@@ -162,7 +162,7 @@ export type TriadProtocol = {
|
|
|
162
162
|
};
|
|
163
163
|
},
|
|
164
164
|
{
|
|
165
|
-
name: '
|
|
165
|
+
name: 'marketAta';
|
|
166
166
|
writable: true;
|
|
167
167
|
pda: {
|
|
168
168
|
seeds: [
|
|
@@ -810,6 +810,11 @@ export type TriadProtocol = {
|
|
|
810
810
|
writable: true;
|
|
811
811
|
optional: true;
|
|
812
812
|
},
|
|
813
|
+
{
|
|
814
|
+
name: 'pool';
|
|
815
|
+
writable: true;
|
|
816
|
+
optional: true;
|
|
817
|
+
},
|
|
813
818
|
{
|
|
814
819
|
name: 'market';
|
|
815
820
|
writable: true;
|
|
@@ -910,6 +915,47 @@ export type TriadProtocol = {
|
|
|
910
915
|
}
|
|
911
916
|
];
|
|
912
917
|
},
|
|
918
|
+
{
|
|
919
|
+
name: 'createPool';
|
|
920
|
+
discriminator: [233, 146, 209, 142, 207, 104, 64, 188];
|
|
921
|
+
accounts: [
|
|
922
|
+
{
|
|
923
|
+
name: 'signer';
|
|
924
|
+
writable: true;
|
|
925
|
+
signer: true;
|
|
926
|
+
},
|
|
927
|
+
{
|
|
928
|
+
name: 'pool';
|
|
929
|
+
writable: true;
|
|
930
|
+
pda: {
|
|
931
|
+
seeds: [
|
|
932
|
+
{
|
|
933
|
+
kind: 'const';
|
|
934
|
+
value: [112, 111, 111, 108];
|
|
935
|
+
},
|
|
936
|
+
{
|
|
937
|
+
kind: 'arg';
|
|
938
|
+
path: 'args.pool_id';
|
|
939
|
+
}
|
|
940
|
+
];
|
|
941
|
+
};
|
|
942
|
+
},
|
|
943
|
+
{
|
|
944
|
+
name: 'systemProgram';
|
|
945
|
+
address: '11111111111111111111111111111111';
|
|
946
|
+
}
|
|
947
|
+
];
|
|
948
|
+
args: [
|
|
949
|
+
{
|
|
950
|
+
name: 'args';
|
|
951
|
+
type: {
|
|
952
|
+
defined: {
|
|
953
|
+
name: 'createPoolArgs';
|
|
954
|
+
};
|
|
955
|
+
};
|
|
956
|
+
}
|
|
957
|
+
];
|
|
958
|
+
},
|
|
913
959
|
{
|
|
914
960
|
name: 'createSubUserTrade';
|
|
915
961
|
discriminator: [77, 201, 111, 73, 47, 229, 244, 161];
|
|
@@ -1573,11 +1619,11 @@ export type TriadProtocol = {
|
|
|
1573
1619
|
writable: true;
|
|
1574
1620
|
},
|
|
1575
1621
|
{
|
|
1576
|
-
name: '
|
|
1622
|
+
name: 'bidUserTrade';
|
|
1577
1623
|
writable: true;
|
|
1578
1624
|
},
|
|
1579
1625
|
{
|
|
1580
|
-
name: '
|
|
1626
|
+
name: 'askUserTrade';
|
|
1581
1627
|
writable: true;
|
|
1582
1628
|
},
|
|
1583
1629
|
{
|
|
@@ -2517,6 +2563,10 @@ export type TriadProtocol = {
|
|
|
2517
2563
|
name: 'nft';
|
|
2518
2564
|
discriminator: [88, 10, 146, 176, 101, 11, 40, 217];
|
|
2519
2565
|
},
|
|
2566
|
+
{
|
|
2567
|
+
name: 'pool';
|
|
2568
|
+
discriminator: [241, 154, 109, 4, 17, 177, 109, 188];
|
|
2569
|
+
},
|
|
2520
2570
|
{
|
|
2521
2571
|
name: 'stakeV2';
|
|
2522
2572
|
discriminator: [207, 98, 130, 13, 118, 181, 238, 47];
|
|
@@ -2539,6 +2589,10 @@ export type TriadProtocol = {
|
|
|
2539
2589
|
name: 'orderEvent';
|
|
2540
2590
|
discriminator: [209, 51, 146, 206, 88, 127, 112, 69];
|
|
2541
2591
|
},
|
|
2592
|
+
{
|
|
2593
|
+
name: 'poolEvent';
|
|
2594
|
+
discriminator: [76, 227, 205, 183, 1, 218, 164, 244];
|
|
2595
|
+
},
|
|
2542
2596
|
{
|
|
2543
2597
|
name: 'priceEvent';
|
|
2544
2598
|
discriminator: [31, 40, 141, 125, 132, 253, 225, 229];
|
|
@@ -2688,6 +2742,11 @@ export type TriadProtocol = {
|
|
|
2688
2742
|
code: 6027;
|
|
2689
2743
|
name: 'linkedBidOrderNotFound';
|
|
2690
2744
|
msg: 'Linked bid order not found';
|
|
2745
|
+
},
|
|
2746
|
+
{
|
|
2747
|
+
code: 6028;
|
|
2748
|
+
name: 'marketAlreadyAggregated';
|
|
2749
|
+
msg: 'Market already aggregated';
|
|
2691
2750
|
}
|
|
2692
2751
|
];
|
|
2693
2752
|
types: [
|
|
@@ -2861,6 +2920,26 @@ export type TriadProtocol = {
|
|
|
2861
2920
|
];
|
|
2862
2921
|
};
|
|
2863
2922
|
},
|
|
2923
|
+
{
|
|
2924
|
+
name: 'createPoolArgs';
|
|
2925
|
+
type: {
|
|
2926
|
+
kind: 'struct';
|
|
2927
|
+
fields: [
|
|
2928
|
+
{
|
|
2929
|
+
name: 'poolId';
|
|
2930
|
+
type: 'u64';
|
|
2931
|
+
},
|
|
2932
|
+
{
|
|
2933
|
+
name: 'question';
|
|
2934
|
+
type: {
|
|
2935
|
+
option: {
|
|
2936
|
+
array: ['u8', 80];
|
|
2937
|
+
};
|
|
2938
|
+
};
|
|
2939
|
+
}
|
|
2940
|
+
];
|
|
2941
|
+
};
|
|
2942
|
+
},
|
|
2864
2943
|
{
|
|
2865
2944
|
name: 'customer';
|
|
2866
2945
|
type: {
|
|
@@ -3014,10 +3093,6 @@ export type TriadProtocol = {
|
|
|
3014
3093
|
name: 'updateTs';
|
|
3015
3094
|
type: 'i64';
|
|
3016
3095
|
},
|
|
3017
|
-
{
|
|
3018
|
-
name: 'openedOrders';
|
|
3019
|
-
type: 'u64';
|
|
3020
|
-
},
|
|
3021
3096
|
{
|
|
3022
3097
|
name: 'nextOrderId';
|
|
3023
3098
|
type: 'u64';
|
|
@@ -3079,6 +3154,10 @@ export type TriadProtocol = {
|
|
|
3079
3154
|
{
|
|
3080
3155
|
name: 'payoutFee';
|
|
3081
3156
|
type: 'u16';
|
|
3157
|
+
},
|
|
3158
|
+
{
|
|
3159
|
+
name: 'poolId';
|
|
3160
|
+
type: 'u64';
|
|
3082
3161
|
}
|
|
3083
3162
|
];
|
|
3084
3163
|
};
|
|
@@ -3137,8 +3216,10 @@ export type TriadProtocol = {
|
|
|
3137
3216
|
type: 'i64';
|
|
3138
3217
|
},
|
|
3139
3218
|
{
|
|
3140
|
-
name: '
|
|
3141
|
-
type:
|
|
3219
|
+
name: 'padding1';
|
|
3220
|
+
type: {
|
|
3221
|
+
array: ['u8', 8];
|
|
3222
|
+
};
|
|
3142
3223
|
},
|
|
3143
3224
|
{
|
|
3144
3225
|
name: 'nextOrderId';
|
|
@@ -3206,10 +3287,14 @@ export type TriadProtocol = {
|
|
|
3206
3287
|
name: 'version';
|
|
3207
3288
|
type: 'u64';
|
|
3208
3289
|
},
|
|
3290
|
+
{
|
|
3291
|
+
name: 'poolId';
|
|
3292
|
+
type: 'u64';
|
|
3293
|
+
},
|
|
3209
3294
|
{
|
|
3210
3295
|
name: 'padding';
|
|
3211
3296
|
type: {
|
|
3212
|
-
array: ['u8',
|
|
3297
|
+
array: ['u8', 72];
|
|
3213
3298
|
};
|
|
3214
3299
|
}
|
|
3215
3300
|
];
|
|
@@ -3536,6 +3621,66 @@ export type TriadProtocol = {
|
|
|
3536
3621
|
];
|
|
3537
3622
|
};
|
|
3538
3623
|
},
|
|
3624
|
+
{
|
|
3625
|
+
name: 'pool';
|
|
3626
|
+
type: {
|
|
3627
|
+
kind: 'struct';
|
|
3628
|
+
fields: [
|
|
3629
|
+
{
|
|
3630
|
+
name: 'bump';
|
|
3631
|
+
type: 'u8';
|
|
3632
|
+
},
|
|
3633
|
+
{
|
|
3634
|
+
name: 'id';
|
|
3635
|
+
type: 'u64';
|
|
3636
|
+
},
|
|
3637
|
+
{
|
|
3638
|
+
name: 'question';
|
|
3639
|
+
type: {
|
|
3640
|
+
array: ['u8', 80];
|
|
3641
|
+
};
|
|
3642
|
+
},
|
|
3643
|
+
{
|
|
3644
|
+
name: 'authority';
|
|
3645
|
+
type: 'pubkey';
|
|
3646
|
+
},
|
|
3647
|
+
{
|
|
3648
|
+
name: 'padding';
|
|
3649
|
+
type: {
|
|
3650
|
+
array: ['u8', 64];
|
|
3651
|
+
};
|
|
3652
|
+
}
|
|
3653
|
+
];
|
|
3654
|
+
};
|
|
3655
|
+
},
|
|
3656
|
+
{
|
|
3657
|
+
name: 'poolEvent';
|
|
3658
|
+
type: {
|
|
3659
|
+
kind: 'struct';
|
|
3660
|
+
fields: [
|
|
3661
|
+
{
|
|
3662
|
+
name: 'poolId';
|
|
3663
|
+
type: 'u64';
|
|
3664
|
+
},
|
|
3665
|
+
{
|
|
3666
|
+
name: 'question';
|
|
3667
|
+
type: {
|
|
3668
|
+
array: ['u8', 80];
|
|
3669
|
+
};
|
|
3670
|
+
},
|
|
3671
|
+
{
|
|
3672
|
+
name: 'authority';
|
|
3673
|
+
type: 'pubkey';
|
|
3674
|
+
},
|
|
3675
|
+
{
|
|
3676
|
+
name: 'markets';
|
|
3677
|
+
type: {
|
|
3678
|
+
array: ['u64', 60];
|
|
3679
|
+
};
|
|
3680
|
+
}
|
|
3681
|
+
];
|
|
3682
|
+
};
|
|
3683
|
+
},
|
|
3539
3684
|
{
|
|
3540
3685
|
name: 'priceEvent';
|
|
3541
3686
|
type: {
|
|
@@ -3829,10 +3974,8 @@ export type TriadProtocol = {
|
|
|
3829
3974
|
type: 'u64';
|
|
3830
3975
|
},
|
|
3831
3976
|
{
|
|
3832
|
-
name: '
|
|
3833
|
-
type:
|
|
3834
|
-
array: ['u8', 8];
|
|
3835
|
-
};
|
|
3977
|
+
name: 'version';
|
|
3978
|
+
type: 'u64';
|
|
3836
3979
|
},
|
|
3837
3980
|
{
|
|
3838
3981
|
name: 'orders';
|
package/dist/utils/helpers.js
CHANGED
|
@@ -67,7 +67,6 @@ const formatMarket = (account, address) => {
|
|
|
67
67
|
volume: account.volume.toString(),
|
|
68
68
|
mint: account.mint.toString(),
|
|
69
69
|
updateTs: account.updateTs.toString(),
|
|
70
|
-
openedOrders: account.openedOrders.toString(),
|
|
71
70
|
nextOrderId: account.nextOrderId.toString(),
|
|
72
71
|
feeBps: account.feeBps,
|
|
73
72
|
isAllowedToPayout: account.isAllowedToPayout,
|
|
@@ -4,3 +4,4 @@ export declare const getMarketPDA: (programId: PublicKey, marketId: number) => P
|
|
|
4
4
|
export declare const getCustomerPDA: (programId: PublicKey, customerId: number) => PublicKey;
|
|
5
5
|
export declare const getUserTradePDA: (programId: PublicKey, wallet: PublicKey) => PublicKey;
|
|
6
6
|
export declare const getSubUserTradePDA: (programId: PublicKey, wallet: PublicKey, nonce: number) => PublicKey;
|
|
7
|
+
export declare const getPoolPDA: (programId: PublicKey, poolId: number) => PublicKey;
|
package/dist/utils/pda/index.js
CHANGED
|
@@ -3,7 +3,7 @@ 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.getSubUserTradePDA = exports.getUserTradePDA = exports.getCustomerPDA = exports.getMarketPDA = exports.getTokenATA = void 0;
|
|
6
|
+
exports.getPoolPDA = 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");
|
|
@@ -31,3 +31,7 @@ const getSubUserTradePDA = (programId, wallet, nonce) => {
|
|
|
31
31
|
], programId)[0];
|
|
32
32
|
};
|
|
33
33
|
exports.getSubUserTradePDA = getSubUserTradePDA;
|
|
34
|
+
const getPoolPDA = (programId, poolId) => {
|
|
35
|
+
return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('pool'), new bn_js_1.default(poolId).toArrayLike(Buffer, 'le', 8)], programId)[0];
|
|
36
|
+
};
|
|
37
|
+
exports.getPoolPDA = getPoolPDA;
|
package/package.json
CHANGED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { RpcOptions } from '../types';
|
|
2
|
-
import { MethodsBuilder } from '@coral-xyz/anchor/dist/cjs/program/namespace/methods';
|
|
3
|
-
import { TriadProtocol } from '../types/triad_protocol';
|
|
4
|
-
declare const sendMethod: (method: MethodsBuilder<TriadProtocol, any, any>, options?: RpcOptions) => Promise<string>;
|
|
5
|
-
export default sendMethod;
|
package/dist/utils/sendMethod.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const web3_js_1 = require("@solana/web3.js");
|
|
16
|
-
const getPriorityFee_1 = __importDefault(require("./getPriorityFee"));
|
|
17
|
-
const sendMethod = (method, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
-
if (options === null || options === void 0 ? void 0 : options.microLamports) {
|
|
19
|
-
method.postInstructions([
|
|
20
|
-
web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
|
|
21
|
-
microLamports: options.microLamports
|
|
22
|
-
})
|
|
23
|
-
]);
|
|
24
|
-
}
|
|
25
|
-
if (!(options === null || options === void 0 ? void 0 : options.microLamports)) {
|
|
26
|
-
const priorityFee = yield (0, getPriorityFee_1.default)();
|
|
27
|
-
method.postInstructions([
|
|
28
|
-
web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({
|
|
29
|
-
microLamports: priorityFee
|
|
30
|
-
})
|
|
31
|
-
]);
|
|
32
|
-
}
|
|
33
|
-
return method.rpc({ skipPreflight: options === null || options === void 0 ? void 0 : options.skipPreflight });
|
|
34
|
-
});
|
|
35
|
-
exports.default = sendMethod;
|