@triadxyz/triad-protocol 2.2.8-beta → 2.3.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/trade.d.ts +15 -2
- package/dist/trade.js +41 -5
- package/dist/types/idl_triad_protocol.json +96 -15
- package/dist/types/trade.d.ts +10 -0
- package/dist/types/triad_protocol.d.ts +125 -15
- package/dist/utils/helpers.d.ts +2 -1
- package/dist/utils/helpers.js +13 -2
- package/package.json +1 -1
package/dist/trade.d.ts
CHANGED
|
@@ -8,6 +8,11 @@ export default class Trade {
|
|
|
8
8
|
private program;
|
|
9
9
|
decimals: number;
|
|
10
10
|
constructor(program: Program<TriadProtocol>);
|
|
11
|
+
/**
|
|
12
|
+
* Get All Pools
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
getAllPools(): Promise<import("./types/trade").Pool[]>;
|
|
11
16
|
/**
|
|
12
17
|
* Get All Markets
|
|
13
18
|
*
|
|
@@ -25,6 +30,12 @@ export default class Trade {
|
|
|
25
30
|
*
|
|
26
31
|
*/
|
|
27
32
|
getUserOrders(user: PublicKey): Promise<Order[]>;
|
|
33
|
+
/**
|
|
34
|
+
* Get Pool By ID
|
|
35
|
+
* @param poolId - The ID of the pool
|
|
36
|
+
*
|
|
37
|
+
*/
|
|
38
|
+
getPoolById(poolId: number): Promise<import("./types/trade").Pool>;
|
|
28
39
|
/**
|
|
29
40
|
* Get Market By ID
|
|
30
41
|
* @param marketId - The ID of the market
|
|
@@ -152,6 +163,7 @@ export default class Trade {
|
|
|
152
163
|
* @param args.question - question (max 80 characters)
|
|
153
164
|
* @param args.liquidityAtStart - liquidity at start
|
|
154
165
|
* @param args.payoutFee - payout fee (to add affiliate system)
|
|
166
|
+
* @param args.currentMarketId - if fast market, we need check the pool parameters
|
|
155
167
|
*
|
|
156
168
|
* @param options - RPC options
|
|
157
169
|
*
|
|
@@ -165,7 +177,7 @@ export default class Trade {
|
|
|
165
177
|
*
|
|
166
178
|
* @param options - RPC options
|
|
167
179
|
*/
|
|
168
|
-
createPool({ poolId, question, markets, mint, customer, startTime, endTime, feeBps, payoutFee }: CreatePoolArgs, options?: RpcOptions): Promise<string>;
|
|
180
|
+
createPool({ poolId, question, markets, mint, customer, startTime, endTime, feeBps, payoutFee, isFast }: CreatePoolArgs, options?: RpcOptions): Promise<string>;
|
|
169
181
|
/**
|
|
170
182
|
* Open Order
|
|
171
183
|
* @param args.marketId - The ID of the Market
|
|
@@ -200,8 +212,9 @@ export default class Trade {
|
|
|
200
212
|
* @param options - RPC options
|
|
201
213
|
*
|
|
202
214
|
*/
|
|
203
|
-
resolveMarket({ marketId, winningDirection }: {
|
|
215
|
+
resolveMarket({ marketId, poolId, winningDirection }: {
|
|
204
216
|
marketId: number;
|
|
217
|
+
poolId?: number;
|
|
205
218
|
winningDirection: {
|
|
206
219
|
hype: {};
|
|
207
220
|
} | {
|
package/dist/trade.js
CHANGED
|
@@ -27,6 +27,16 @@ class Trade {
|
|
|
27
27
|
this.program = program;
|
|
28
28
|
this.decimals = constants_1.TRD_DECIMALS; // We're using only TRD or USDC so we can use the same decimals 6
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Get All Pools
|
|
32
|
+
*
|
|
33
|
+
*/
|
|
34
|
+
getAllPools() {
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
const poolV2 = yield this.program.account.pool.all();
|
|
37
|
+
return poolV2.map(({ account, publicKey }) => (0, helpers_1.formatPool)(account, publicKey));
|
|
38
|
+
});
|
|
39
|
+
}
|
|
30
40
|
/**
|
|
31
41
|
* Get All Markets
|
|
32
42
|
*
|
|
@@ -66,6 +76,18 @@ class Trade {
|
|
|
66
76
|
return myUserTrades.flatMap((userTrade) => userTrade.orders);
|
|
67
77
|
});
|
|
68
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Get Pool By ID
|
|
81
|
+
* @param poolId - The ID of the pool
|
|
82
|
+
*
|
|
83
|
+
*/
|
|
84
|
+
getPoolById(poolId) {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
const poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
|
|
87
|
+
const response = yield this.program.account.pool.fetch(poolPDA);
|
|
88
|
+
return (0, helpers_1.formatPool)(response, poolPDA);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
69
91
|
/**
|
|
70
92
|
* Get Market By ID
|
|
71
93
|
* @param marketId - The ID of the market
|
|
@@ -113,6 +135,7 @@ class Trade {
|
|
|
113
135
|
* @param args.question - question (max 80 characters)
|
|
114
136
|
* @param args.liquidityAtStart - liquidity at start
|
|
115
137
|
* @param args.payoutFee - payout fee (to add affiliate system)
|
|
138
|
+
* @param args.currentMarketId - if fast market, we need check the pool parameters
|
|
116
139
|
*
|
|
117
140
|
* @param options - RPC options
|
|
118
141
|
*
|
|
@@ -162,7 +185,7 @@ class Trade {
|
|
|
162
185
|
*
|
|
163
186
|
* @param options - RPC options
|
|
164
187
|
*/
|
|
165
|
-
createPool({ poolId, question, markets, mint, customer, startTime, endTime, feeBps, payoutFee }, options) {
|
|
188
|
+
createPool({ poolId, question, markets, mint, customer, startTime, endTime, feeBps, payoutFee, isFast }, options) {
|
|
166
189
|
return __awaiter(this, void 0, void 0, function* () {
|
|
167
190
|
if (question.length > 80) {
|
|
168
191
|
throw new Error('Pool question must be less than 80 characters');
|
|
@@ -172,12 +195,19 @@ class Trade {
|
|
|
172
195
|
ixs.push(yield this.program.methods
|
|
173
196
|
.createPool({
|
|
174
197
|
poolId: new bn_js_1.default(poolId),
|
|
175
|
-
question: (0, helpers_1.encodeString)(question, 80)
|
|
198
|
+
question: (0, helpers_1.encodeString)(question, 80),
|
|
199
|
+
isFast
|
|
176
200
|
})
|
|
177
201
|
.accounts({
|
|
178
202
|
signer: this.program.provider.publicKey
|
|
179
203
|
})
|
|
180
204
|
.instruction());
|
|
205
|
+
let userTrade = null;
|
|
206
|
+
try {
|
|
207
|
+
yield this.getUserTrade(this.program.provider.publicKey);
|
|
208
|
+
userTrade = (0, pda_1.getUserTradePDA)(this.program.programId, this.program.provider.publicKey);
|
|
209
|
+
}
|
|
210
|
+
catch (_a) { }
|
|
181
211
|
for (const market of markets) {
|
|
182
212
|
if (market.question.length > 80) {
|
|
183
213
|
throw new Error('Market question must be less than 80 characters');
|
|
@@ -196,7 +226,8 @@ class Trade {
|
|
|
196
226
|
mint,
|
|
197
227
|
tokenProgram: (0, helpers_1.getTokenProgram)(mint),
|
|
198
228
|
pool: poolPDA,
|
|
199
|
-
customer
|
|
229
|
+
customer,
|
|
230
|
+
userTrade
|
|
200
231
|
})
|
|
201
232
|
.instruction());
|
|
202
233
|
}
|
|
@@ -290,9 +321,13 @@ class Trade {
|
|
|
290
321
|
* @param options - RPC options
|
|
291
322
|
*
|
|
292
323
|
*/
|
|
293
|
-
resolveMarket({ marketId, winningDirection }, options) {
|
|
324
|
+
resolveMarket({ marketId, poolId, winningDirection }, options) {
|
|
294
325
|
return __awaiter(this, void 0, void 0, function* () {
|
|
295
326
|
const ixs = [];
|
|
327
|
+
let poolPDA = null;
|
|
328
|
+
if (poolId) {
|
|
329
|
+
poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
|
|
330
|
+
}
|
|
296
331
|
ixs.push(yield this.program.methods
|
|
297
332
|
.updateMarket({
|
|
298
333
|
winningDirection,
|
|
@@ -301,7 +336,8 @@ class Trade {
|
|
|
301
336
|
})
|
|
302
337
|
.accounts({
|
|
303
338
|
signer: this.program.provider.publicKey,
|
|
304
|
-
market: (0, pda_1.getMarketPDA)(this.program.programId, marketId)
|
|
339
|
+
market: (0, pda_1.getMarketPDA)(this.program.programId, marketId),
|
|
340
|
+
pool: poolPDA
|
|
305
341
|
})
|
|
306
342
|
.instruction());
|
|
307
343
|
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
|
|
@@ -1299,21 +1299,25 @@
|
|
|
1299
1299
|
"writable": true,
|
|
1300
1300
|
"signer": true
|
|
1301
1301
|
},
|
|
1302
|
+
{
|
|
1303
|
+
"name": "market",
|
|
1304
|
+
"writable": true
|
|
1305
|
+
},
|
|
1302
1306
|
{
|
|
1303
1307
|
"name": "squads",
|
|
1304
1308
|
"writable": true,
|
|
1305
1309
|
"address": "6fcSf6qfwPNR9AUUNC1UWYZDy5cQ4TzTb2aaipN2zFdq"
|
|
1306
1310
|
},
|
|
1307
1311
|
{
|
|
1308
|
-
"name": "
|
|
1312
|
+
"name": "buyer_authority",
|
|
1309
1313
|
"writable": true
|
|
1310
1314
|
},
|
|
1311
1315
|
{
|
|
1312
|
-
"name": "
|
|
1316
|
+
"name": "seller_trade",
|
|
1313
1317
|
"writable": true
|
|
1314
1318
|
},
|
|
1315
1319
|
{
|
|
1316
|
-
"name": "
|
|
1320
|
+
"name": "buyer_trade",
|
|
1317
1321
|
"writable": true
|
|
1318
1322
|
},
|
|
1319
1323
|
{
|
|
@@ -1348,6 +1352,34 @@
|
|
|
1348
1352
|
}
|
|
1349
1353
|
}
|
|
1350
1354
|
},
|
|
1355
|
+
{
|
|
1356
|
+
"name": "buyer_ata",
|
|
1357
|
+
"writable": true,
|
|
1358
|
+
"pda": {
|
|
1359
|
+
"seeds": [
|
|
1360
|
+
{
|
|
1361
|
+
"kind": "account",
|
|
1362
|
+
"path": "buyer_authority"
|
|
1363
|
+
},
|
|
1364
|
+
{
|
|
1365
|
+
"kind": "account",
|
|
1366
|
+
"path": "token_program"
|
|
1367
|
+
},
|
|
1368
|
+
{
|
|
1369
|
+
"kind": "account",
|
|
1370
|
+
"path": "mint"
|
|
1371
|
+
}
|
|
1372
|
+
],
|
|
1373
|
+
"program": {
|
|
1374
|
+
"kind": "const",
|
|
1375
|
+
"value": [
|
|
1376
|
+
140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
|
|
1377
|
+
13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
|
|
1378
|
+
219, 233, 248, 89
|
|
1379
|
+
]
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
},
|
|
1351
1383
|
{
|
|
1352
1384
|
"name": "market_ata",
|
|
1353
1385
|
"writable": true
|
|
@@ -1364,7 +1396,16 @@
|
|
|
1364
1396
|
"address": "11111111111111111111111111111111"
|
|
1365
1397
|
}
|
|
1366
1398
|
],
|
|
1367
|
-
"args": [
|
|
1399
|
+
"args": [
|
|
1400
|
+
{
|
|
1401
|
+
"name": "args",
|
|
1402
|
+
"type": {
|
|
1403
|
+
"defined": {
|
|
1404
|
+
"name": "MarketAskOrderArgs"
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
]
|
|
1368
1409
|
},
|
|
1369
1410
|
{
|
|
1370
1411
|
"name": "market_bid_order",
|
|
@@ -1404,10 +1445,6 @@
|
|
|
1404
1445
|
"name": "buyer_ata",
|
|
1405
1446
|
"writable": true
|
|
1406
1447
|
},
|
|
1407
|
-
{
|
|
1408
|
-
"name": "market_ata",
|
|
1409
|
-
"writable": true
|
|
1410
|
-
},
|
|
1411
1448
|
{
|
|
1412
1449
|
"name": "seller_ata",
|
|
1413
1450
|
"writable": true,
|
|
@@ -1436,6 +1473,10 @@
|
|
|
1436
1473
|
}
|
|
1437
1474
|
}
|
|
1438
1475
|
},
|
|
1476
|
+
{
|
|
1477
|
+
"name": "market_ata",
|
|
1478
|
+
"writable": true
|
|
1479
|
+
},
|
|
1439
1480
|
{
|
|
1440
1481
|
"name": "token_program"
|
|
1441
1482
|
},
|
|
@@ -2052,6 +2093,11 @@
|
|
|
2052
2093
|
"name": "market",
|
|
2053
2094
|
"writable": true
|
|
2054
2095
|
},
|
|
2096
|
+
{
|
|
2097
|
+
"name": "pool",
|
|
2098
|
+
"writable": true,
|
|
2099
|
+
"optional": true
|
|
2100
|
+
},
|
|
2055
2101
|
{
|
|
2056
2102
|
"name": "system_program",
|
|
2057
2103
|
"address": "11111111111111111111111111111111"
|
|
@@ -2555,11 +2601,16 @@
|
|
|
2555
2601
|
},
|
|
2556
2602
|
{
|
|
2557
2603
|
"code": 6030,
|
|
2604
|
+
"name": "CurrentFastPoolMarketStillActive",
|
|
2605
|
+
"msg": "Current fast pool market still active"
|
|
2606
|
+
},
|
|
2607
|
+
{
|
|
2608
|
+
"code": 6031,
|
|
2558
2609
|
"name": "MarketAlreadyAggregated",
|
|
2559
2610
|
"msg": "Market already aggregated"
|
|
2560
2611
|
},
|
|
2561
2612
|
{
|
|
2562
|
-
"code":
|
|
2613
|
+
"code": 6032,
|
|
2563
2614
|
"name": "MarketAlreadyPaidOut",
|
|
2564
2615
|
"msg": "Market already paid out"
|
|
2565
2616
|
}
|
|
@@ -2895,6 +2946,10 @@
|
|
|
2895
2946
|
"array": ["u8", 80]
|
|
2896
2947
|
}
|
|
2897
2948
|
}
|
|
2949
|
+
},
|
|
2950
|
+
{
|
|
2951
|
+
"name": "is_fast",
|
|
2952
|
+
"type": "bool"
|
|
2898
2953
|
}
|
|
2899
2954
|
]
|
|
2900
2955
|
}
|
|
@@ -2959,6 +3014,22 @@
|
|
|
2959
3014
|
]
|
|
2960
3015
|
}
|
|
2961
3016
|
},
|
|
3017
|
+
{
|
|
3018
|
+
"name": "MarketAskOrderArgs",
|
|
3019
|
+
"type": {
|
|
3020
|
+
"kind": "struct",
|
|
3021
|
+
"fields": [
|
|
3022
|
+
{
|
|
3023
|
+
"name": "shares",
|
|
3024
|
+
"type": "u64"
|
|
3025
|
+
},
|
|
3026
|
+
{
|
|
3027
|
+
"name": "bid_order_id",
|
|
3028
|
+
"type": "u64"
|
|
3029
|
+
}
|
|
3030
|
+
]
|
|
3031
|
+
}
|
|
3032
|
+
},
|
|
2962
3033
|
{
|
|
2963
3034
|
"name": "MarketBidOrderArgs",
|
|
2964
3035
|
"type": {
|
|
@@ -3585,10 +3656,18 @@
|
|
|
3585
3656
|
"name": "authority",
|
|
3586
3657
|
"type": "pubkey"
|
|
3587
3658
|
},
|
|
3659
|
+
{
|
|
3660
|
+
"name": "is_fast",
|
|
3661
|
+
"type": "bool"
|
|
3662
|
+
},
|
|
3663
|
+
{
|
|
3664
|
+
"name": "is_fast_market_active",
|
|
3665
|
+
"type": "bool"
|
|
3666
|
+
},
|
|
3588
3667
|
{
|
|
3589
3668
|
"name": "padding",
|
|
3590
3669
|
"type": {
|
|
3591
|
-
"array": ["u8",
|
|
3670
|
+
"array": ["u8", 62]
|
|
3592
3671
|
}
|
|
3593
3672
|
}
|
|
3594
3673
|
]
|
|
@@ -3600,7 +3679,7 @@
|
|
|
3600
3679
|
"kind": "struct",
|
|
3601
3680
|
"fields": [
|
|
3602
3681
|
{
|
|
3603
|
-
"name": "
|
|
3682
|
+
"name": "id",
|
|
3604
3683
|
"type": "u64"
|
|
3605
3684
|
},
|
|
3606
3685
|
{
|
|
@@ -3614,10 +3693,12 @@
|
|
|
3614
3693
|
"type": "pubkey"
|
|
3615
3694
|
},
|
|
3616
3695
|
{
|
|
3617
|
-
"name": "
|
|
3618
|
-
"type":
|
|
3619
|
-
|
|
3620
|
-
|
|
3696
|
+
"name": "is_fast",
|
|
3697
|
+
"type": "bool"
|
|
3698
|
+
},
|
|
3699
|
+
{
|
|
3700
|
+
"name": "is_fast_market_active",
|
|
3701
|
+
"type": "bool"
|
|
3621
3702
|
}
|
|
3622
3703
|
]
|
|
3623
3704
|
}
|
package/dist/types/trade.d.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { PublicKey } from '@solana/web3.js';
|
|
2
|
+
export type Pool = {
|
|
3
|
+
address: string;
|
|
4
|
+
id: number;
|
|
5
|
+
question: string;
|
|
6
|
+
authority: string;
|
|
7
|
+
isFast: boolean;
|
|
8
|
+
isFastMarketActive: boolean;
|
|
9
|
+
};
|
|
2
10
|
export type Market = {
|
|
3
11
|
address: string;
|
|
4
12
|
bump: number;
|
|
@@ -148,6 +156,7 @@ export type CreateMarketArgs = {
|
|
|
148
156
|
payoutFee: number;
|
|
149
157
|
mint: PublicKey;
|
|
150
158
|
poolId?: number;
|
|
159
|
+
currentMarketId?: number;
|
|
151
160
|
};
|
|
152
161
|
export type CreatePoolArgs = {
|
|
153
162
|
poolId: number;
|
|
@@ -162,6 +171,7 @@ export type CreatePoolArgs = {
|
|
|
162
171
|
marketId: number;
|
|
163
172
|
question: string;
|
|
164
173
|
}[];
|
|
174
|
+
isFast?: boolean;
|
|
165
175
|
};
|
|
166
176
|
export type CancelBidOrderArgs = {
|
|
167
177
|
marketId: number;
|
|
@@ -1897,21 +1897,25 @@ export type TriadProtocol = {
|
|
|
1897
1897
|
writable: true;
|
|
1898
1898
|
signer: true;
|
|
1899
1899
|
},
|
|
1900
|
+
{
|
|
1901
|
+
name: 'market';
|
|
1902
|
+
writable: true;
|
|
1903
|
+
},
|
|
1900
1904
|
{
|
|
1901
1905
|
name: 'squads';
|
|
1902
1906
|
writable: true;
|
|
1903
1907
|
address: '6fcSf6qfwPNR9AUUNC1UWYZDy5cQ4TzTb2aaipN2zFdq';
|
|
1904
1908
|
},
|
|
1905
1909
|
{
|
|
1906
|
-
name: '
|
|
1910
|
+
name: 'buyerAuthority';
|
|
1907
1911
|
writable: true;
|
|
1908
1912
|
},
|
|
1909
1913
|
{
|
|
1910
|
-
name: '
|
|
1914
|
+
name: 'sellerTrade';
|
|
1911
1915
|
writable: true;
|
|
1912
1916
|
},
|
|
1913
1917
|
{
|
|
1914
|
-
name: '
|
|
1918
|
+
name: 'buyerTrade';
|
|
1915
1919
|
writable: true;
|
|
1916
1920
|
},
|
|
1917
1921
|
{
|
|
@@ -1975,6 +1979,63 @@ export type TriadProtocol = {
|
|
|
1975
1979
|
};
|
|
1976
1980
|
};
|
|
1977
1981
|
},
|
|
1982
|
+
{
|
|
1983
|
+
name: 'buyerAta';
|
|
1984
|
+
writable: true;
|
|
1985
|
+
pda: {
|
|
1986
|
+
seeds: [
|
|
1987
|
+
{
|
|
1988
|
+
kind: 'account';
|
|
1989
|
+
path: 'buyerAuthority';
|
|
1990
|
+
},
|
|
1991
|
+
{
|
|
1992
|
+
kind: 'account';
|
|
1993
|
+
path: 'tokenProgram';
|
|
1994
|
+
},
|
|
1995
|
+
{
|
|
1996
|
+
kind: 'account';
|
|
1997
|
+
path: 'mint';
|
|
1998
|
+
}
|
|
1999
|
+
];
|
|
2000
|
+
program: {
|
|
2001
|
+
kind: 'const';
|
|
2002
|
+
value: [
|
|
2003
|
+
140,
|
|
2004
|
+
151,
|
|
2005
|
+
37,
|
|
2006
|
+
143,
|
|
2007
|
+
78,
|
|
2008
|
+
36,
|
|
2009
|
+
137,
|
|
2010
|
+
241,
|
|
2011
|
+
187,
|
|
2012
|
+
61,
|
|
2013
|
+
16,
|
|
2014
|
+
41,
|
|
2015
|
+
20,
|
|
2016
|
+
142,
|
|
2017
|
+
13,
|
|
2018
|
+
131,
|
|
2019
|
+
11,
|
|
2020
|
+
90,
|
|
2021
|
+
19,
|
|
2022
|
+
153,
|
|
2023
|
+
218,
|
|
2024
|
+
255,
|
|
2025
|
+
16,
|
|
2026
|
+
132,
|
|
2027
|
+
4,
|
|
2028
|
+
142,
|
|
2029
|
+
123,
|
|
2030
|
+
216,
|
|
2031
|
+
219,
|
|
2032
|
+
233,
|
|
2033
|
+
248,
|
|
2034
|
+
89
|
|
2035
|
+
];
|
|
2036
|
+
};
|
|
2037
|
+
};
|
|
2038
|
+
},
|
|
1978
2039
|
{
|
|
1979
2040
|
name: 'marketAta';
|
|
1980
2041
|
writable: true;
|
|
@@ -1991,7 +2052,16 @@ export type TriadProtocol = {
|
|
|
1991
2052
|
address: '11111111111111111111111111111111';
|
|
1992
2053
|
}
|
|
1993
2054
|
];
|
|
1994
|
-
args: [
|
|
2055
|
+
args: [
|
|
2056
|
+
{
|
|
2057
|
+
name: 'args';
|
|
2058
|
+
type: {
|
|
2059
|
+
defined: {
|
|
2060
|
+
name: 'marketAskOrderArgs';
|
|
2061
|
+
};
|
|
2062
|
+
};
|
|
2063
|
+
}
|
|
2064
|
+
];
|
|
1995
2065
|
},
|
|
1996
2066
|
{
|
|
1997
2067
|
name: 'marketBidOrder';
|
|
@@ -2031,10 +2101,6 @@ export type TriadProtocol = {
|
|
|
2031
2101
|
name: 'buyerAta';
|
|
2032
2102
|
writable: true;
|
|
2033
2103
|
},
|
|
2034
|
-
{
|
|
2035
|
-
name: 'marketAta';
|
|
2036
|
-
writable: true;
|
|
2037
|
-
},
|
|
2038
2104
|
{
|
|
2039
2105
|
name: 'sellerAta';
|
|
2040
2106
|
writable: true;
|
|
@@ -2092,6 +2158,10 @@ export type TriadProtocol = {
|
|
|
2092
2158
|
};
|
|
2093
2159
|
};
|
|
2094
2160
|
},
|
|
2161
|
+
{
|
|
2162
|
+
name: 'marketAta';
|
|
2163
|
+
writable: true;
|
|
2164
|
+
},
|
|
2095
2165
|
{
|
|
2096
2166
|
name: 'tokenProgram';
|
|
2097
2167
|
},
|
|
@@ -2952,6 +3022,11 @@ export type TriadProtocol = {
|
|
|
2952
3022
|
name: 'market';
|
|
2953
3023
|
writable: true;
|
|
2954
3024
|
},
|
|
3025
|
+
{
|
|
3026
|
+
name: 'pool';
|
|
3027
|
+
writable: true;
|
|
3028
|
+
optional: true;
|
|
3029
|
+
},
|
|
2955
3030
|
{
|
|
2956
3031
|
name: 'systemProgram';
|
|
2957
3032
|
address: '11111111111111111111111111111111';
|
|
@@ -3595,11 +3670,16 @@ export type TriadProtocol = {
|
|
|
3595
3670
|
},
|
|
3596
3671
|
{
|
|
3597
3672
|
code: 6030;
|
|
3673
|
+
name: 'currentFastPoolMarketStillActive';
|
|
3674
|
+
msg: 'Current fast pool market still active';
|
|
3675
|
+
},
|
|
3676
|
+
{
|
|
3677
|
+
code: 6031;
|
|
3598
3678
|
name: 'marketAlreadyAggregated';
|
|
3599
3679
|
msg: 'Market already aggregated';
|
|
3600
3680
|
},
|
|
3601
3681
|
{
|
|
3602
|
-
code:
|
|
3682
|
+
code: 6032;
|
|
3603
3683
|
name: 'marketAlreadyPaidOut';
|
|
3604
3684
|
msg: 'Market already paid out';
|
|
3605
3685
|
}
|
|
@@ -3935,6 +4015,10 @@ export type TriadProtocol = {
|
|
|
3935
4015
|
array: ['u8', 80];
|
|
3936
4016
|
};
|
|
3937
4017
|
};
|
|
4018
|
+
},
|
|
4019
|
+
{
|
|
4020
|
+
name: 'isFast';
|
|
4021
|
+
type: 'bool';
|
|
3938
4022
|
}
|
|
3939
4023
|
];
|
|
3940
4024
|
};
|
|
@@ -3999,6 +4083,22 @@ export type TriadProtocol = {
|
|
|
3999
4083
|
];
|
|
4000
4084
|
};
|
|
4001
4085
|
},
|
|
4086
|
+
{
|
|
4087
|
+
name: 'marketAskOrderArgs';
|
|
4088
|
+
type: {
|
|
4089
|
+
kind: 'struct';
|
|
4090
|
+
fields: [
|
|
4091
|
+
{
|
|
4092
|
+
name: 'shares';
|
|
4093
|
+
type: 'u64';
|
|
4094
|
+
},
|
|
4095
|
+
{
|
|
4096
|
+
name: 'bidOrderId';
|
|
4097
|
+
type: 'u64';
|
|
4098
|
+
}
|
|
4099
|
+
];
|
|
4100
|
+
};
|
|
4101
|
+
},
|
|
4002
4102
|
{
|
|
4003
4103
|
name: 'marketBidOrderArgs';
|
|
4004
4104
|
type: {
|
|
@@ -4625,10 +4725,18 @@ export type TriadProtocol = {
|
|
|
4625
4725
|
name: 'authority';
|
|
4626
4726
|
type: 'pubkey';
|
|
4627
4727
|
},
|
|
4728
|
+
{
|
|
4729
|
+
name: 'isFast';
|
|
4730
|
+
type: 'bool';
|
|
4731
|
+
},
|
|
4732
|
+
{
|
|
4733
|
+
name: 'isFastMarketActive';
|
|
4734
|
+
type: 'bool';
|
|
4735
|
+
},
|
|
4628
4736
|
{
|
|
4629
4737
|
name: 'padding';
|
|
4630
4738
|
type: {
|
|
4631
|
-
array: ['u8',
|
|
4739
|
+
array: ['u8', 62];
|
|
4632
4740
|
};
|
|
4633
4741
|
}
|
|
4634
4742
|
];
|
|
@@ -4640,7 +4748,7 @@ export type TriadProtocol = {
|
|
|
4640
4748
|
kind: 'struct';
|
|
4641
4749
|
fields: [
|
|
4642
4750
|
{
|
|
4643
|
-
name: '
|
|
4751
|
+
name: 'id';
|
|
4644
4752
|
type: 'u64';
|
|
4645
4753
|
},
|
|
4646
4754
|
{
|
|
@@ -4654,10 +4762,12 @@ export type TriadProtocol = {
|
|
|
4654
4762
|
type: 'pubkey';
|
|
4655
4763
|
},
|
|
4656
4764
|
{
|
|
4657
|
-
name: '
|
|
4658
|
-
type:
|
|
4659
|
-
|
|
4660
|
-
|
|
4765
|
+
name: 'isFast';
|
|
4766
|
+
type: 'bool';
|
|
4767
|
+
},
|
|
4768
|
+
{
|
|
4769
|
+
name: 'isFastMarketActive';
|
|
4770
|
+
type: 'bool';
|
|
4661
4771
|
}
|
|
4662
4772
|
];
|
|
4663
4773
|
};
|
package/dist/utils/helpers.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Stake, StakeVault } from './../types/stake';
|
|
2
|
-
import { Market, Order, OrderDirection, OrderSide, OrderStatus, OrderType, UserTrade, Chest } from '../types/trade';
|
|
2
|
+
import { Market, Order, OrderDirection, OrderSide, OrderStatus, OrderType, UserTrade, Chest, Pool } from '../types/trade';
|
|
3
3
|
import { PublicKey } from '@solana/web3.js';
|
|
4
4
|
import { IdlAccounts } from '@coral-xyz/anchor';
|
|
5
5
|
import { TriadProtocol } from '../types/triad_protocol';
|
|
@@ -7,6 +7,7 @@ export declare const encodeString: (value: string, alloc?: number) => number[];
|
|
|
7
7
|
export declare const decodeString: (bytes: number[]) => string;
|
|
8
8
|
export declare const formatStakeVault: (stakeVault: IdlAccounts<TriadProtocol>['stakeVault']) => StakeVault;
|
|
9
9
|
export declare const formatStake: (stake: IdlAccounts<TriadProtocol>['stakeV2']) => Stake;
|
|
10
|
+
export declare const formatPool: (account: IdlAccounts<TriadProtocol>['pool'], address: PublicKey) => Pool;
|
|
10
11
|
export declare const formatMarket: (account: IdlAccounts<TriadProtocol>['marketV2'], address: PublicKey) => Market;
|
|
11
12
|
export declare const formatUserTrade: (account: IdlAccounts<TriadProtocol>['userTrade'], publicKey: PublicKey) => UserTrade;
|
|
12
13
|
export declare const formatOrder: (order: IdlAccounts<TriadProtocol>['userTrade']['orders'][number], authority?: string) => Order;
|
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.formatChest = exports.formatOrder = exports.formatUserTrade = 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.formatChest = exports.formatOrder = exports.formatUserTrade = exports.formatMarket = exports.formatPool = 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");
|
|
@@ -52,6 +52,17 @@ const formatStake = (stake) => {
|
|
|
52
52
|
};
|
|
53
53
|
};
|
|
54
54
|
exports.formatStake = formatStake;
|
|
55
|
+
const formatPool = (account, address) => {
|
|
56
|
+
return {
|
|
57
|
+
address: address.toString(),
|
|
58
|
+
id: account.id.toNumber(),
|
|
59
|
+
question: Buffer.from(account.question).toString().replace(/\0+$/, ''),
|
|
60
|
+
authority: account.authority.toString(),
|
|
61
|
+
isFast: account.isFast,
|
|
62
|
+
isFastMarketActive: account.isFastMarketActive
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
exports.formatPool = formatPool;
|
|
55
66
|
const formatMarket = (account, address) => {
|
|
56
67
|
return {
|
|
57
68
|
bump: account.bump,
|
|
@@ -137,7 +148,7 @@ const calculateStakeRewards = (stake) => {
|
|
|
137
148
|
if (stake.withdrawTs !== 0)
|
|
138
149
|
return 0;
|
|
139
150
|
const maxRank = 1633;
|
|
140
|
-
const rank =
|
|
151
|
+
const rank = 369;
|
|
141
152
|
const rankWeight = (maxRank - rank + 1) / maxRank;
|
|
142
153
|
const userStakedAmount = stake.mint === constants_1.TRD_MINT.toBase58()
|
|
143
154
|
? stake.amount
|