@triadxyz/triad-protocol 3.0.1-beta → 3.0.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.d.ts CHANGED
@@ -411,11 +411,10 @@ export default class TriadProtocolClient {
411
411
  * @param args.orderId - The ID of the Order
412
412
  * @param args.userNonce - The nonce of the user
413
413
  * @param args.direction - The direction of the Order
414
- * @param args.isTrdPayout - Whether to payout in TRD or not
415
414
  *
416
415
  * @param options - RPC options
417
416
  */
418
- cancelBidOrder({ marketId, orderId, userNonce, mint, direction, isTrdPayout, remainingShares, price }: CancelBidOrderArgs, options?: RpcOptions): Promise<string>;
417
+ cancelBidOrder({ marketId, orderId, userNonce, mint, direction }: CancelBidOrderArgs, options?: RpcOptions): Promise<string>;
419
418
  /**
420
419
  * Cancel Ask Order
421
420
  * @param args.marketId - The ID of the Market
package/dist/index.js CHANGED
@@ -745,12 +745,14 @@ class TriadProtocolClient {
745
745
  const addressLookupTableAccounts = [];
746
746
  let amountInUSDC = new bn_js_1.default(amount * Math.pow(10, this.decimals));
747
747
  if (isTrdPayout) {
748
+ const trdPrice = yield (0, swap_1.getPrice)(constants_1.TRD_MINT.toString());
749
+ const amountInTRD = amount / trdPrice;
748
750
  const { swapIxs, addressLookupTableAccounts: swapAddressLookupTableAccounts, outAmount, setupInstructions } = yield (0, swap_1.swap)({
749
751
  connection: this.program.provider.connection,
750
752
  wallet: this.program.provider.publicKey.toBase58(),
751
753
  inToken: constants_1.TRD_MINT.toString(),
752
754
  outToken: constants_1.USDC_MINT.toString(),
753
- amount: Math.floor(amount)
755
+ amount: Math.floor(amountInTRD)
754
756
  });
755
757
  if (swapIxs.length === 0) {
756
758
  return;
@@ -768,8 +770,7 @@ class TriadProtocolClient {
768
770
  .placeBidOrder({
769
771
  amount: amountInUSDC,
770
772
  price: new bn_js_1.default(price * Math.pow(10, this.decimals)),
771
- orderDirection: direction,
772
- isTrdPayout
773
+ orderDirection: direction
773
774
  })
774
775
  .accounts({
775
776
  signer: this.program.provider.publicKey,
@@ -822,14 +823,12 @@ class TriadProtocolClient {
822
823
  * @param args.orderId - The ID of the Order
823
824
  * @param args.userNonce - The nonce of the user
824
825
  * @param args.direction - The direction of the Order
825
- * @param args.isTrdPayout - Whether to payout in TRD or not
826
826
  *
827
827
  * @param options - RPC options
828
828
  */
829
- cancelBidOrder({ marketId, orderId, userNonce, mint, direction, isTrdPayout, remainingShares, price }, options) {
829
+ cancelBidOrder({ marketId, orderId, userNonce, mint, direction }, options) {
830
830
  return __awaiter(this, void 0, void 0, function* () {
831
831
  const ixs = [];
832
- const addressLookupTableAccounts = [];
833
832
  ixs.push(yield this.program.methods
834
833
  .cancelBidOrder({
835
834
  orderId: new bn_js_1.default(orderId),
@@ -844,21 +843,6 @@ class TriadProtocolClient {
844
843
  tokenProgram: (0, helpers_1.getTokenProgram)(mint)
845
844
  })
846
845
  .instruction());
847
- if (isTrdPayout) {
848
- const { swapIxs, addressLookupTableAccounts: swapAddressLookupTableAccounts, setupInstructions } = yield (0, swap_1.swap)({
849
- connection: this.program.provider.connection,
850
- wallet: this.program.provider.publicKey.toBase58(),
851
- inToken: constants_1.USDC_MINT.toString(),
852
- outToken: constants_1.TRD_MINT.toString(),
853
- amount: Math.floor((remainingShares * price) / Math.pow(10, this.decimals))
854
- });
855
- if (swapIxs.length === 0) {
856
- return;
857
- }
858
- ixs.push(...setupInstructions);
859
- ixs.push(...swapIxs);
860
- addressLookupTableAccounts.push(...swapAddressLookupTableAccounts);
861
- }
862
846
  return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
863
847
  });
864
848
  }
@@ -3646,10 +3646,6 @@
3646
3646
  "name": "OrderDirection"
3647
3647
  }
3648
3648
  }
3649
- },
3650
- {
3651
- "name": "is_trd_payout",
3652
- "type": "bool"
3653
3649
  }
3654
3650
  ]
3655
3651
  }
@@ -196,9 +196,6 @@ export type CancelBidOrderArgs = {
196
196
  } | {
197
197
  flop: {};
198
198
  };
199
- isTrdPayout: boolean;
200
- remainingShares: number;
201
- price: number;
202
199
  };
203
200
  export type CancelAskOrderArgs = {
204
201
  marketId: number;
@@ -4466,10 +4466,6 @@ export type TriadProtocol = {
4466
4466
  name: 'orderDirection';
4467
4467
  };
4468
4468
  };
4469
- },
4470
- {
4471
- name: 'isTrdPayout';
4472
- type: 'bool';
4473
4469
  }
4474
4470
  ];
4475
4471
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "3.0.1-beta",
3
+ "version": "3.0.3-beta",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",