@triadxyz/triad-protocol 1.9.3-beta → 1.9.5-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/stake.d.ts CHANGED
@@ -26,10 +26,9 @@ export default class Stake {
26
26
  /**
27
27
  * Get Stake By Wallet
28
28
  * @param wallet - User Wallet
29
- * @param multiplier - Multiplier
30
29
  *
31
30
  */
32
- getStakeByWallet(wallet: PublicKey, collections: number): Promise<StakeResponse[]>;
31
+ getStakeByWallet(wallet: PublicKey): Promise<StakeResponse[]>;
33
32
  /**
34
33
  * Stake Token
35
34
  * @param args.name - Index for finding the PDA
@@ -78,14 +77,5 @@ export default class Stake {
78
77
  * @param options - RPC options
79
78
  *
80
79
  */
81
- claimStakeRewards({ wallet, collections, ranks, verifier }: {
82
- wallet: PublicKey;
83
- collections: number;
84
- ranks: {
85
- onchainId: string;
86
- name: string;
87
- rarityRankHrtt: number;
88
- }[];
89
- verifier: string;
90
- }, options?: RpcOptions): Promise<string>;
80
+ claimStakeRewards(wallet: PublicKey, options?: RpcOptions): Promise<string>;
91
81
  }
package/dist/stake.js CHANGED
@@ -18,7 +18,6 @@ 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
20
  const sendTransactionWithOptions_1 = __importDefault(require("./utils/sendTransactionWithOptions"));
21
- const convertSecretKeyToKeypair_1 = require("./utils/convertSecretKeyToKeypair");
22
21
  class Stake {
23
22
  constructor(program, provider) {
24
23
  this.program = program;
@@ -59,15 +58,14 @@ class Stake {
59
58
  /**
60
59
  * Get Stake By Wallet
61
60
  * @param wallet - User Wallet
62
- * @param multiplier - Multiplier
63
61
  *
64
62
  */
65
- getStakeByWallet(wallet, collections) {
63
+ getStakeByWallet(wallet) {
66
64
  return __awaiter(this, void 0, void 0, function* () {
67
65
  const response = yield this.getUserStakes(wallet);
68
66
  const data = [];
69
67
  for (const stake of response) {
70
- let available = (0, helpers_1.calculateStakeRewards)(stake, collections);
68
+ let available = (0, helpers_1.calculateStakeRewards)(stake);
71
69
  data.push(Object.assign(Object.assign({}, stake), { available }));
72
70
  }
73
71
  return data;
@@ -135,7 +133,6 @@ class Stake {
135
133
  .requestWithdrawStake()
136
134
  .accounts({
137
135
  signer: wallet,
138
- mint: nft.mint,
139
136
  stake: stakePDA
140
137
  })
141
138
  .instruction());
@@ -175,7 +172,7 @@ class Stake {
175
172
  * @param options - RPC options
176
173
  *
177
174
  */
178
- claimStakeRewards({ wallet, collections, ranks, verifier }, options) {
175
+ claimStakeRewards(wallet, options) {
179
176
  return __awaiter(this, void 0, void 0, function* () {
180
177
  const stakes = (yield this.getUserStakes(wallet)).sort((a, b) => a.claimedTs - b.claimedTs);
181
178
  const ixs = [];
@@ -193,20 +190,16 @@ class Stake {
193
190
  const stakeVaultPDA = (0, stake_1.getStakeVaultPDA)(this.program.programId, constants_1.STAKE_VAULT_NAME);
194
191
  const stakePDA = (0, stake_1.getStakePDA)(this.program.programId, wallet, stake.name);
195
192
  ixs.push(yield this.program.methods
196
- .claimStakeRewards({
197
- collections,
198
- rank: 963
199
- })
193
+ .claimStakeRewards()
200
194
  .accounts({
201
195
  signer: wallet,
202
196
  mint: constants_1.TRD_MINT,
203
197
  stake: stakePDA,
204
- stakeVault: stakeVaultPDA,
205
- verifier: constants_1.VERIFIER
198
+ stakeVault: stakeVaultPDA
206
199
  })
207
200
  .instruction());
208
201
  }
209
- return (0, sendVersionedTransaction_1.default)(this.provider, ixs, options, (0, convertSecretKeyToKeypair_1.convertSecretKeyToKeypair)(verifier));
202
+ return (0, sendVersionedTransaction_1.default)(this.provider, ixs, options);
210
203
  });
211
204
  }
212
205
  }
package/dist/trade.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { AnchorProvider, 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, PlaceOrderArgs, CancelOrderArgs, Order, MarketBidOrderArgs, UpdateMarketAdminArgs } from './types/trade';
4
+ import { CreateMarketArgs, OpenOrderArgs, UserTrade, CreateCustomerArgs, Order, MarketBidOrderArgs, CancelBidOrderArgs, CancelAskOrderArgs, PlaceBidOrderArgs, PlaceAskOrderArgs } from './types/trade';
5
5
  import { RpcOptions } from './types';
6
6
  import BN from 'bn.js';
7
7
  export default class Trade {
@@ -277,28 +277,48 @@ export default class Trade {
277
277
  nonce?: undefined;
278
278
  }>;
279
279
  /**
280
- * Place Order
280
+ * Place Bid Order
281
281
  * @param args.marketId - The ID of the Market
282
282
  * @param args.amount - The amount of the Order
283
283
  * @param args.direction - The direction of the Order
284
- * @param args.orderSide - The side of the Order
285
284
  * @param args.mint - The mint of the Order
286
285
  * @param args.price - The price of the Order
287
286
  *
288
287
  * @param options - RPC options
288
+ */
289
+ placeBidOrder({ marketId, amount, direction, mint, price }: PlaceBidOrderArgs, options?: RpcOptions): Promise<string>;
290
+ /**
291
+ * Place Ask Order
292
+ * @param args.marketId - The ID of the Market
293
+ * @param args.amount - The amount of the Order
294
+ * @param args.direction - The direction of the Order
295
+ * @param args.price - The price of the Order
296
+ * @param args.bidOrderId - The ID of the Bid Order
297
+ * @param args.bidNonce - The nonce of the Bid Order
298
+ *
299
+ * @param options - RPC options
289
300
  *
290
301
  */
291
- placeOrder({ marketId, amount, direction, orderSide, mint, price, bidOrderId, bidNonce }: PlaceOrderArgs, options?: RpcOptions): Promise<string>;
302
+ placeAskOrder({ marketId, amount, direction, price, bidOrderId, bidNonce }: PlaceAskOrderArgs, options?: RpcOptions): Promise<string>;
292
303
  /**
293
- * Cancel Order
304
+ * Cancel Bid Order
294
305
  * @param args.marketId - The ID of the Market
295
306
  * @param args.orderId - The ID of the Order
296
307
  * @param args.userNonce - The nonce of the user
297
- * @param args.orderSide - The side of the Order
298
308
  *
299
309
  * @param options - RPC options
300
310
  */
301
- cancelOrder({ marketId, orderId, userNonce, orderSide, mint, userNonceBidOrder }: CancelOrderArgs, options?: RpcOptions): Promise<string>;
311
+ cancelBidOrder({ marketId, orderId, userNonce, mint }: CancelBidOrderArgs, options?: RpcOptions): Promise<string>;
312
+ /**
313
+ * Cancel Ask Order
314
+ * @param args.marketId - The ID of the Market
315
+ * @param args.orderId - The ID of the Order
316
+ * @param args.userNonce - The nonce of the user
317
+ * @param args.userNonceBidOrder - The nonce of the bid user
318
+ *
319
+ * @param options - RPC options
320
+ */
321
+ cancelAskOrder({ marketId, orderId, userNonce, userNonceBidOrder }: CancelAskOrderArgs, options?: RpcOptions): Promise<string>;
302
322
  /**
303
323
  * Market Bid Order
304
324
  * @param args.marketId - The ID of the Market
@@ -324,12 +344,4 @@ export default class Trade {
324
344
  ask: Order[];
325
345
  };
326
346
  }>;
327
- /**
328
- * Update Market Admin
329
- * @param args.payoutFee - The payout fee of the market
330
- * @param args.feeBps - The fee bps of the market
331
- *
332
- * @param options - RPC options
333
- */
334
- updateMarketAdmin(args: UpdateMarketAdminArgs, options?: RpcOptions): Promise<string>;
335
347
  }
package/dist/trade.js CHANGED
@@ -232,9 +232,6 @@ class Trade {
232
232
  return __awaiter(this, void 0, void 0, function* () {
233
233
  const marketPDA = (0, trade_2.getMarketPDA)(this.program.programId, marketId);
234
234
  const market = yield this.getMarketByAddress(marketPDA);
235
- if (market.isAllowedToPayout) {
236
- return;
237
- }
238
235
  return (0, sendTransactionWithOptions_1.default)(this.program.methods.collectRemainingLiquidity().accounts({
239
236
  signer: this.provider.publicKey,
240
237
  market: marketPDA,
@@ -413,18 +410,16 @@ class Trade {
413
410
  });
414
411
  }
415
412
  /**
416
- * Place Order
413
+ * Place Bid Order
417
414
  * @param args.marketId - The ID of the Market
418
415
  * @param args.amount - The amount of the Order
419
416
  * @param args.direction - The direction of the Order
420
- * @param args.orderSide - The side of the Order
421
417
  * @param args.mint - The mint of the Order
422
418
  * @param args.price - The price of the Order
423
419
  *
424
420
  * @param options - RPC options
425
- *
426
421
  */
427
- placeOrder({ marketId, amount, direction, orderSide, mint, price, bidOrderId, bidNonce }, options) {
422
+ placeBidOrder({ marketId, amount, direction, mint, price }, options) {
428
423
  return __awaiter(this, void 0, void 0, function* () {
429
424
  const marketPDA = (0, trade_2.getMarketPDA)(this.program.programId, marketId);
430
425
  const ixs = [];
@@ -432,81 +427,116 @@ class Trade {
432
427
  if (userTradeIxs.length > 0) {
433
428
  ixs.push(...userTradeIxs);
434
429
  }
435
- if (Object.keys(orderSide)[0] === 'bid') {
436
- ixs.push(yield this.program.methods
437
- .placeBidOrder({
438
- amount: new bn_js_1.default(amount * Math.pow(10, this.decimals)),
439
- price: new bn_js_1.default(price * Math.pow(10, this.decimals)),
440
- orderDirection: direction
441
- })
442
- .accounts({
443
- signer: this.provider.publicKey,
444
- market: marketPDA,
445
- userTrade: userTradePDA,
446
- mint,
447
- tokenProgram: (0, helpers_1.getTokenProgram)(mint)
448
- })
449
- .instruction());
430
+ ixs.push(yield this.program.methods
431
+ .placeBidOrder({
432
+ amount: new bn_js_1.default(amount * Math.pow(10, this.decimals)),
433
+ price: new bn_js_1.default(price * Math.pow(10, this.decimals)),
434
+ orderDirection: direction
435
+ })
436
+ .accounts({
437
+ signer: this.provider.publicKey,
438
+ market: marketPDA,
439
+ userTrade: userTradePDA,
440
+ mint,
441
+ tokenProgram: (0, helpers_1.getTokenProgram)(mint)
442
+ })
443
+ .instruction());
444
+ return (0, sendVersionedTransaction_1.default)(this.provider, ixs, options);
445
+ });
446
+ }
447
+ /**
448
+ * Place Ask Order
449
+ * @param args.marketId - The ID of the Market
450
+ * @param args.amount - The amount of the Order
451
+ * @param args.direction - The direction of the Order
452
+ * @param args.price - The price of the Order
453
+ * @param args.bidOrderId - The ID of the Bid Order
454
+ * @param args.bidNonce - The nonce of the Bid Order
455
+ *
456
+ * @param options - RPC options
457
+ *
458
+ */
459
+ placeAskOrder({ marketId, amount, direction, price, bidOrderId, bidNonce }, options) {
460
+ return __awaiter(this, void 0, void 0, function* () {
461
+ const marketPDA = (0, trade_2.getMarketPDA)(this.program.programId, marketId);
462
+ const ixs = [];
463
+ const { userTradePDA: askUserTradePDA, ixs: userTradeIxs } = yield this.getUserTradeIxs();
464
+ if (userTradeIxs.length > 0) {
465
+ ixs.push(...userTradeIxs);
450
466
  }
451
- if (Object.keys(orderSide)[0] === 'ask' && bidOrderId) {
452
- let bidUserTradePDA = (0, trade_2.getUserTradePDA)(this.program.programId, this.provider.publicKey);
453
- if (bidNonce !== 0) {
454
- const subUserTradePDA = (0, trade_2.getSubUserTradePDA)(this.program.programId, this.provider.publicKey, bidNonce);
455
- bidUserTradePDA = (0, trade_2.getUserTradePDA)(this.program.programId, subUserTradePDA);
456
- }
457
- ixs.push(yield this.program.methods
458
- .placeAskOrder({
459
- shares: new bn_js_1.default(amount * Math.pow(10, this.decimals)),
460
- price: new bn_js_1.default(price * Math.pow(10, this.decimals)),
461
- bidOrderId: new bn_js_1.default(bidOrderId),
462
- orderDirection: direction
463
- })
464
- .accounts({
465
- signer: this.provider.publicKey,
466
- market: marketPDA,
467
- askUserTrade: userTradePDA,
468
- bidUserTrade: bidUserTradePDA
469
- })
470
- .instruction());
467
+ let bidUserTradePDA = (0, trade_2.getUserTradePDA)(this.program.programId, this.provider.publicKey);
468
+ if (bidNonce !== 0) {
469
+ const subUserTradePDA = (0, trade_2.getSubUserTradePDA)(this.program.programId, this.provider.publicKey, bidNonce);
470
+ bidUserTradePDA = (0, trade_2.getUserTradePDA)(this.program.programId, subUserTradePDA);
471
471
  }
472
+ ixs.push(yield this.program.methods
473
+ .placeAskOrder({
474
+ shares: new bn_js_1.default(amount * Math.pow(10, this.decimals)),
475
+ price: new bn_js_1.default(price * Math.pow(10, this.decimals)),
476
+ bidOrderId: new bn_js_1.default(bidOrderId),
477
+ orderDirection: direction
478
+ })
479
+ .accounts({
480
+ signer: this.provider.publicKey,
481
+ market: marketPDA,
482
+ askUserTrade: askUserTradePDA,
483
+ bidUserTrade: bidUserTradePDA
484
+ })
485
+ .instruction());
472
486
  return (0, sendVersionedTransaction_1.default)(this.provider, ixs, options);
473
487
  });
474
488
  }
475
489
  /**
476
- * Cancel Order
490
+ * Cancel Bid Order
477
491
  * @param args.marketId - The ID of the Market
478
492
  * @param args.orderId - The ID of the Order
479
493
  * @param args.userNonce - The nonce of the user
480
- * @param args.orderSide - The side of the Order
481
494
  *
482
495
  * @param options - RPC options
483
496
  */
484
- cancelOrder({ marketId, orderId, userNonce, orderSide, mint, userNonceBidOrder }, options) {
497
+ cancelBidOrder({ marketId, orderId, userNonce, mint }, options) {
485
498
  return __awaiter(this, void 0, void 0, function* () {
486
499
  const marketPDA = (0, trade_2.getMarketPDA)(this.program.programId, marketId);
487
500
  let userTradePDA = (0, trade_2.getUserTradePDA)(this.program.programId, this.provider.publicKey);
488
- let bidUserTradePDA = (0, trade_2.getUserTradePDA)(this.program.programId, this.provider.publicKey);
489
501
  if (userNonce !== 0) {
490
502
  const subUserTradePDA = (0, trade_2.getSubUserTradePDA)(this.program.programId, this.provider.publicKey, userNonce);
491
503
  userTradePDA = (0, trade_2.getUserTradePDA)(this.program.programId, subUserTradePDA);
492
504
  }
493
- if (userNonceBidOrder !== null && userNonceBidOrder !== 0) {
505
+ return (0, sendTransactionWithOptions_1.default)(this.program.methods.cancelBidOrder(new bn_js_1.default(orderId)).accounts({
506
+ signer: this.provider.publicKey,
507
+ market: marketPDA,
508
+ userTrade: userTradePDA,
509
+ mint,
510
+ tokenProgram: (0, helpers_1.getTokenProgram)(mint)
511
+ }), options);
512
+ });
513
+ }
514
+ /**
515
+ * Cancel Ask Order
516
+ * @param args.marketId - The ID of the Market
517
+ * @param args.orderId - The ID of the Order
518
+ * @param args.userNonce - The nonce of the user
519
+ * @param args.userNonceBidOrder - The nonce of the bid user
520
+ *
521
+ * @param options - RPC options
522
+ */
523
+ cancelAskOrder({ marketId, orderId, userNonce, userNonceBidOrder }, options) {
524
+ return __awaiter(this, void 0, void 0, function* () {
525
+ const marketPDA = (0, trade_2.getMarketPDA)(this.program.programId, marketId);
526
+ let askUserTradePDA = (0, trade_2.getUserTradePDA)(this.program.programId, this.provider.publicKey);
527
+ if (userNonce !== 0) {
528
+ const subUserTradePDA = (0, trade_2.getSubUserTradePDA)(this.program.programId, this.provider.publicKey, userNonce);
529
+ askUserTradePDA = (0, trade_2.getUserTradePDA)(this.program.programId, subUserTradePDA);
530
+ }
531
+ let bidUserTradePDA = (0, trade_2.getUserTradePDA)(this.program.programId, this.provider.publicKey);
532
+ if (userNonceBidOrder !== 0) {
494
533
  const subUserTradePDA = (0, trade_2.getSubUserTradePDA)(this.program.programId, this.provider.publicKey, userNonceBidOrder);
495
534
  bidUserTradePDA = (0, trade_2.getUserTradePDA)(this.program.programId, subUserTradePDA);
496
535
  }
497
- if (orderSide === trade_1.OrderSide.BID) {
498
- return (0, sendTransactionWithOptions_1.default)(this.program.methods.cancelBidOrder(new bn_js_1.default(orderId)).accounts({
499
- signer: this.provider.publicKey,
500
- market: marketPDA,
501
- userTrade: userTradePDA,
502
- mint,
503
- tokenProgram: (0, helpers_1.getTokenProgram)(mint)
504
- }), options);
505
- }
506
536
  return (0, sendTransactionWithOptions_1.default)(this.program.methods.cancelAskOrder(new bn_js_1.default(orderId)).accounts({
507
537
  signer: this.provider.publicKey,
508
538
  market: marketPDA,
509
- askUserTrade: userTradePDA,
539
+ askUserTrade: askUserTradePDA,
510
540
  bidUserTrade: bidUserTradePDA
511
541
  }), options);
512
542
  });
@@ -637,21 +667,5 @@ class Trade {
637
667
  return orderBook;
638
668
  });
639
669
  }
640
- /**
641
- * Update Market Admin
642
- * @param args.payoutFee - The payout fee of the market
643
- * @param args.feeBps - The fee bps of the market
644
- *
645
- * @param options - RPC options
646
- */
647
- updateMarketAdmin(args, options) {
648
- return __awaiter(this, void 0, void 0, function* () {
649
- const marketPDA = (0, trade_2.getMarketPDA)(this.program.programId, args.marketId);
650
- return (0, sendTransactionWithOptions_1.default)(this.program.methods.updateMarketAdmin(args).accounts({
651
- signer: this.provider.publicKey,
652
- market: marketPDA
653
- }), options);
654
- });
655
- }
656
670
  }
657
671
  exports.default = Trade;
@@ -202,11 +202,6 @@
202
202
  "writable": true,
203
203
  "signer": true
204
204
  },
205
- {
206
- "name": "verifier",
207
- "writable": true,
208
- "signer": true
209
- },
210
205
  {
211
206
  "name": "stake_vault",
212
207
  "writable": true
@@ -288,16 +283,7 @@
288
283
  "address": "11111111111111111111111111111111"
289
284
  }
290
285
  ],
291
- "args": [
292
- {
293
- "name": "args",
294
- "type": {
295
- "defined": {
296
- "name": "ClaimStakeRewardsArgs"
297
- }
298
- }
299
- }
300
- ],
286
+ "args": [],
301
287
  "returns": "u64"
302
288
  },
303
289
  {
@@ -1099,7 +1085,7 @@
1099
1085
  }
1100
1086
  },
1101
1087
  {
1102
- "name": "market_vault",
1088
+ "name": "market_ata",
1103
1089
  "writable": true,
1104
1090
  "pda": {
1105
1091
  "seeds": [
@@ -1127,8 +1113,7 @@
1127
1113
  }
1128
1114
  },
1129
1115
  {
1130
- "name": "token_program",
1131
- "address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
1116
+ "name": "token_program"
1132
1117
  },
1133
1118
  {
1134
1119
  "name": "associated_token_program",
@@ -1343,14 +1328,6 @@
1343
1328
  "name": "stake",
1344
1329
  "writable": true
1345
1330
  },
1346
- {
1347
- "name": "mint",
1348
- "writable": true
1349
- },
1350
- {
1351
- "name": "token_program",
1352
- "address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
1353
- },
1354
1331
  {
1355
1332
  "name": "system_program",
1356
1333
  "address": "11111111111111111111111111111111"
@@ -1594,35 +1571,6 @@
1594
1571
  }
1595
1572
  ]
1596
1573
  },
1597
- {
1598
- "name": "update_market_admin",
1599
- "discriminator": [167, 63, 152, 152, 112, 165, 97, 114],
1600
- "accounts": [
1601
- {
1602
- "name": "signer",
1603
- "writable": true,
1604
- "signer": true
1605
- },
1606
- {
1607
- "name": "market",
1608
- "writable": true
1609
- },
1610
- {
1611
- "name": "system_program",
1612
- "address": "11111111111111111111111111111111"
1613
- }
1614
- ],
1615
- "args": [
1616
- {
1617
- "name": "args",
1618
- "type": {
1619
- "defined": {
1620
- "name": "UpdateMarketAdminArgs"
1621
- }
1622
- }
1623
- }
1624
- ]
1625
- },
1626
1574
  {
1627
1575
  "name": "update_stake_vault",
1628
1576
  "discriminator": [84, 171, 100, 153, 126, 215, 229, 68],
@@ -2132,22 +2080,6 @@
2132
2080
  ]
2133
2081
  }
2134
2082
  },
2135
- {
2136
- "name": "ClaimStakeRewardsArgs",
2137
- "type": {
2138
- "kind": "struct",
2139
- "fields": [
2140
- {
2141
- "name": "rank",
2142
- "type": "u16"
2143
- },
2144
- {
2145
- "name": "collections",
2146
- "type": "u8"
2147
- }
2148
- ]
2149
- }
2150
- },
2151
2083
  {
2152
2084
  "name": "Collection",
2153
2085
  "type": {
@@ -3152,26 +3084,6 @@
3152
3084
  ]
3153
3085
  }
3154
3086
  },
3155
- {
3156
- "name": "UpdateMarketAdminArgs",
3157
- "type": {
3158
- "kind": "struct",
3159
- "fields": [
3160
- {
3161
- "name": "payout_fee",
3162
- "type": {
3163
- "option": "u16"
3164
- }
3165
- },
3166
- {
3167
- "name": "fee_bps",
3168
- "type": {
3169
- "option": "u16"
3170
- }
3171
- }
3172
- ]
3173
- }
3174
- },
3175
3087
  {
3176
3088
  "name": "UpdateStakeVaultArgs",
3177
3089
  "type": {
@@ -82,7 +82,7 @@ export declare enum OrderSide {
82
82
  BID = "bid",
83
83
  ASK = "ask"
84
84
  }
85
- export type PlaceOrderArgs = {
85
+ export type PlaceBidOrderArgs = {
86
86
  marketId: number;
87
87
  amount: number;
88
88
  price: number;
@@ -91,15 +91,22 @@ export type PlaceOrderArgs = {
91
91
  } | {
92
92
  flop: {};
93
93
  };
94
- orderSide: {
95
- bid: {};
96
- } | {
97
- ask: {};
98
- };
99
94
  mint: PublicKey;
100
95
  bidOrderId: number | null;
101
96
  bidNonce: number | null;
102
97
  };
98
+ export type PlaceAskOrderArgs = {
99
+ marketId: number;
100
+ amount: number;
101
+ price: number;
102
+ direction: {
103
+ hype: {};
104
+ } | {
105
+ flop: {};
106
+ };
107
+ bidOrderId: number;
108
+ bidNonce: number;
109
+ };
103
110
  export type InitializeMarketArgs = {
104
111
  marketId: number;
105
112
  startTime: number;
@@ -147,13 +154,17 @@ export type CreateMarketArgs = {
147
154
  payoutFee: number;
148
155
  mint: PublicKey;
149
156
  };
150
- export type CancelOrderArgs = {
157
+ export type CancelBidOrderArgs = {
151
158
  marketId: number;
152
159
  orderId: number;
153
160
  userNonce: number;
154
- orderSide: OrderSide;
155
161
  mint: PublicKey;
156
- userNonceBidOrder: number | null;
162
+ };
163
+ export type CancelAskOrderArgs = {
164
+ marketId: number;
165
+ orderId: number;
166
+ userNonce: number;
167
+ userNonceBidOrder: number;
157
168
  };
158
169
  export type MarketBidOrderArgs = {
159
170
  marketId: number;
@@ -165,8 +176,3 @@ export type MarketBidOrderArgs = {
165
176
  };
166
177
  mint: PublicKey;
167
178
  };
168
- export type UpdateMarketAdminArgs = {
169
- marketId: number;
170
- payoutFee: number | null;
171
- feeBps: number | null;
172
- };
@@ -266,11 +266,6 @@ export type TriadProtocol = {
266
266
  writable: true;
267
267
  signer: true;
268
268
  },
269
- {
270
- name: 'verifier';
271
- writable: true;
272
- signer: true;
273
- },
274
269
  {
275
270
  name: 'stakeVault';
276
271
  writable: true;
@@ -410,16 +405,7 @@ export type TriadProtocol = {
410
405
  address: '11111111111111111111111111111111';
411
406
  }
412
407
  ];
413
- args: [
414
- {
415
- name: 'args';
416
- type: {
417
- defined: {
418
- name: 'claimStakeRewardsArgs';
419
- };
420
- };
421
- }
422
- ];
408
+ args: [];
423
409
  returns: 'u64';
424
410
  },
425
411
  {
@@ -1540,7 +1526,7 @@ export type TriadProtocol = {
1540
1526
  };
1541
1527
  },
1542
1528
  {
1543
- name: 'marketVault';
1529
+ name: 'marketAta';
1544
1530
  writable: true;
1545
1531
  pda: {
1546
1532
  seeds: [
@@ -1598,7 +1584,6 @@ export type TriadProtocol = {
1598
1584
  },
1599
1585
  {
1600
1586
  name: 'tokenProgram';
1601
- address: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb';
1602
1587
  },
1603
1588
  {
1604
1589
  name: 'associatedTokenProgram';
@@ -1871,14 +1856,6 @@ export type TriadProtocol = {
1871
1856
  name: 'stake';
1872
1857
  writable: true;
1873
1858
  },
1874
- {
1875
- name: 'mint';
1876
- writable: true;
1877
- },
1878
- {
1879
- name: 'tokenProgram';
1880
- address: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb';
1881
- },
1882
1859
  {
1883
1860
  name: 'systemProgram';
1884
1861
  address: '11111111111111111111111111111111';
@@ -2180,35 +2157,6 @@ export type TriadProtocol = {
2180
2157
  }
2181
2158
  ];
2182
2159
  },
2183
- {
2184
- name: 'updateMarketAdmin';
2185
- discriminator: [167, 63, 152, 152, 112, 165, 97, 114];
2186
- accounts: [
2187
- {
2188
- name: 'signer';
2189
- writable: true;
2190
- signer: true;
2191
- },
2192
- {
2193
- name: 'market';
2194
- writable: true;
2195
- },
2196
- {
2197
- name: 'systemProgram';
2198
- address: '11111111111111111111111111111111';
2199
- }
2200
- ];
2201
- args: [
2202
- {
2203
- name: 'args';
2204
- type: {
2205
- defined: {
2206
- name: 'updateMarketAdminArgs';
2207
- };
2208
- };
2209
- }
2210
- ];
2211
- },
2212
2160
  {
2213
2161
  name: 'updateStakeVault';
2214
2162
  discriminator: [84, 171, 100, 153, 126, 215, 229, 68];
@@ -2834,22 +2782,6 @@ export type TriadProtocol = {
2834
2782
  ];
2835
2783
  };
2836
2784
  },
2837
- {
2838
- name: 'claimStakeRewardsArgs';
2839
- type: {
2840
- kind: 'struct';
2841
- fields: [
2842
- {
2843
- name: 'rank';
2844
- type: 'u16';
2845
- },
2846
- {
2847
- name: 'collections';
2848
- type: 'u8';
2849
- }
2850
- ];
2851
- };
2852
- },
2853
2785
  {
2854
2786
  name: 'collection';
2855
2787
  type: {
@@ -3854,26 +3786,6 @@ export type TriadProtocol = {
3854
3786
  ];
3855
3787
  };
3856
3788
  },
3857
- {
3858
- name: 'updateMarketAdminArgs';
3859
- type: {
3860
- kind: 'struct';
3861
- fields: [
3862
- {
3863
- name: 'payoutFee';
3864
- type: {
3865
- option: 'u16';
3866
- };
3867
- },
3868
- {
3869
- name: 'feeBps';
3870
- type: {
3871
- option: 'u16';
3872
- };
3873
- }
3874
- ];
3875
- };
3876
- },
3877
3789
  {
3878
3790
  name: 'updateStakeVaultArgs';
3879
3791
  type: {
@@ -1,6 +1,6 @@
1
1
  import { Stake, StakeVault } from './../types/stake';
2
2
  import { Market, Order, OrderDirection, OrderSide, OrderStatus, OrderType, UserTrade } from '../types/trade';
3
- import { PublicKey, AddressLookupTableAccount } from '@solana/web3.js';
3
+ import { PublicKey } from '@solana/web3.js';
4
4
  export declare const encodeString: (value: string, alloc?: number) => number[];
5
5
  export declare const decodeString: (bytes: number[]) => string;
6
6
  export declare const formatStakeVault: (stakeVault: any) => StakeVault;
@@ -8,7 +8,7 @@ export declare const formatStake: (stake: any) => Stake;
8
8
  export declare const formatMarket: (account: any, address: PublicKey) => Market;
9
9
  export declare const formatOrder: (order: any, authority?: string) => Order;
10
10
  export declare const formatUserTrade: (account: any, publicKey: PublicKey) => UserTrade;
11
- export declare const calculateStakeRewards: (stake: Stake, multiplier: number) => number;
11
+ export declare const calculateStakeRewards: (stake: Stake) => number;
12
12
  export declare const getTokenProgram: (mint: PublicKey) => PublicKey;
13
13
  export declare const getOrderDirection: (direction: {
14
14
  hype: {};
@@ -38,4 +38,3 @@ export declare const getOrderStatus: (status: {
38
38
  } | {
39
39
  waiting: {};
40
40
  }) => OrderStatus;
41
- export declare const defaultLookupTable: AddressLookupTableAccount;
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defaultLookupTable = 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.formatUserTrade = exports.formatOrder = exports.formatMarket = exports.formatStake = exports.formatStakeVault = exports.decodeString = exports.encodeString = void 0;
4
4
  const trade_1 = require("../types/trade");
5
- const web3_js_1 = require("@solana/web3.js");
6
5
  const constants_1 = require("./constants");
7
6
  const spl_token_1 = require("@solana/spl-token");
8
7
  const spl_token_2 = require("@solana/spl-token");
@@ -123,19 +122,16 @@ const formatUserTrade = (account, publicKey) => {
123
122
  };
124
123
  };
125
124
  exports.formatUserTrade = formatUserTrade;
126
- const calculateStakeRewards = (stake, multiplier) => {
125
+ const calculateStakeRewards = (stake) => {
127
126
  if (stake.withdrawTs !== 0)
128
127
  return 0;
129
- if (multiplier > 3)
130
- return 0;
131
- const collectionsMultiplier = multiplier * 150;
132
128
  const maxRank = 1633;
133
- const rank = 963;
129
+ const rank = 639;
134
130
  const rankWeight = (maxRank - rank + 1) / maxRank;
135
131
  const userStakedAmount = stake.mint === constants_1.TRD_MINT.toBase58()
136
132
  ? stake.amount
137
133
  : stake.amount * 10000 * Math.pow(10, constants_1.TRD_DECIMALS);
138
- const formattedAmount = userStakedAmount / Math.pow(10, constants_1.TRD_DECIMALS) + collectionsMultiplier;
134
+ const formattedAmount = userStakedAmount / Math.pow(10, constants_1.TRD_DECIMALS);
139
135
  const adjustedAmount = formattedAmount * rankWeight;
140
136
  const lastClaim = stake.claimedTs === 0 ? stake.initTs : stake.claimedTs;
141
137
  const currentTime = Math.floor(Date.now() / 1000);
@@ -193,19 +189,3 @@ const getOrderStatus = (status) => {
193
189
  }
194
190
  };
195
191
  exports.getOrderStatus = getOrderStatus;
196
- exports.defaultLookupTable = {
197
- isActive: () => true,
198
- key: new web3_js_1.PublicKey('A2wLWeXEHjmeRvSAyijS9ofv87N1GzFyQfdYPgPoQhZf'),
199
- state: {
200
- deactivationSlot: BigInt(18446744073709551615),
201
- lastExtendedSlot: 328789868,
202
- lastExtendedSlotStartIndex: 0,
203
- authority: new web3_js_1.PublicKey('82ppCojm3yrEKgdpH8B5AmBJTU1r1uAWXFWhxvPs9UCR'),
204
- addresses: [
205
- new web3_js_1.PublicKey('t3DohmswhKk94PPbPYwA6ZKACyY3y5kbcqeQerAJjmV'),
206
- new web3_js_1.PublicKey('6fcSf6qfwPNR9AUUNC1UWYZDy5cQ4TzTb2aaipN2zFdq'),
207
- new web3_js_1.PublicKey('TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb'),
208
- new web3_js_1.PublicKey('ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL')
209
- ]
210
- }
211
- };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "1.9.3-beta",
3
+ "version": "1.9.5-beta",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",