@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
|
|
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(
|
|
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
|
|
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
|
}
|
package/dist/types/index.d.ts
CHANGED