@triadxyz/triad-protocol 1.2.2-beta → 1.2.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/index.d.ts +0 -10
- package/dist/index.js +2 -11
- package/dist/local-test.js +32 -88
- package/dist/stake.d.ts +1 -8
- package/dist/stake.js +0 -25
- package/dist/trade.d.ts +18 -2
- package/dist/trade.js +62 -5
- package/dist/types/idl_triad_protocol.json +98 -341
- package/dist/types/trade.d.ts +1 -0
- package/dist/types/triad_protocol.d.ts +97 -340
- package/dist/utils/constants.d.ts +1 -0
- package/dist/utils/constants.js +2 -1
- package/dist/utils/helpers.js +6 -2
- package/dist/utils/jup-swap.d.ts +15 -0
- package/dist/utils/jup-swap.js +66 -0
- package/dist/utils/swap.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -23,16 +23,6 @@ export default class TriadProtocolClient {
|
|
|
23
23
|
*
|
|
24
24
|
*/
|
|
25
25
|
getUsers(): Promise<import("./types").User[]>;
|
|
26
|
-
getTickers(): Promise<import("@coral-xyz/anchor").ProgramAccount<{
|
|
27
|
-
initTs: import("bn.js");
|
|
28
|
-
updatedTs: import("bn.js");
|
|
29
|
-
bump: number;
|
|
30
|
-
authority: PublicKey;
|
|
31
|
-
name: string;
|
|
32
|
-
protocolProgramId: PublicKey;
|
|
33
|
-
price: import("bn.js");
|
|
34
|
-
vault: PublicKey;
|
|
35
|
-
}>[]>;
|
|
36
26
|
/**
|
|
37
27
|
* Check if user exists
|
|
38
28
|
* @param username - User name
|
package/dist/index.js
CHANGED
|
@@ -55,11 +55,6 @@ class TriadProtocolClient {
|
|
|
55
55
|
.sort((a, b) => b.referred - a.referred);
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
|
-
getTickers() {
|
|
59
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
-
return yield this.program.account.ticker.all();
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
58
|
/**
|
|
64
59
|
* Check if user exists
|
|
65
60
|
* @param username - User name
|
|
@@ -131,12 +126,9 @@ class TriadProtocolClient {
|
|
|
131
126
|
*/
|
|
132
127
|
getUserPositionsWithAmount(wallet) {
|
|
133
128
|
return __awaiter(this, void 0, void 0, function* () {
|
|
134
|
-
const tickers = yield this.program.account.ticker.all();
|
|
135
129
|
const userPositions = [];
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
userPositions.push(userPositionPDA);
|
|
139
|
-
}
|
|
130
|
+
const userPositionPDA = (0, pda_1.getUserPositionPDA)(this.program.programId, wallet, new web3_js_1.PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'));
|
|
131
|
+
userPositions.push(userPositionPDA);
|
|
140
132
|
const userPositionsWithAmount = yield this.program.account.userPosition.fetchMultiple(userPositions);
|
|
141
133
|
return userPositionsWithAmount.filter((item) => item &&
|
|
142
134
|
parseFloat(item.totalDeposited.toString()) >
|
|
@@ -154,7 +146,6 @@ class TriadProtocolClient {
|
|
|
154
146
|
userPosition: userPositionPDA,
|
|
155
147
|
userTokenAccount,
|
|
156
148
|
vault: vaultPDA,
|
|
157
|
-
ticker,
|
|
158
149
|
vaultTokenAccount: VaultTokenAccountPDA
|
|
159
150
|
}), options);
|
|
160
151
|
});
|
package/dist/local-test.js
CHANGED
|
@@ -21,78 +21,18 @@ const spl_token_1 = require("@solana/spl-token");
|
|
|
21
21
|
const file = fs_1.default.readFileSync('/Users/dannpl/.config/solana/id.json');
|
|
22
22
|
const rpc_file = fs_1.default.readFileSync('/Users/dannpl/.config/solana/rpc.txt');
|
|
23
23
|
const keypair = web3_js_1.Keypair.fromSecretKey(new Uint8Array(JSON.parse(file.toString())));
|
|
24
|
-
const connection = new web3_js_1.Connection('https://mainnet.
|
|
24
|
+
const connection = new web3_js_1.Connection('https://triad-solanam-a5ee.mainnet.rpcpool.com/34797434-86a9-4a15-abb1-6b5f6cb7a8ff');
|
|
25
25
|
const wallet = new anchor_1.Wallet(keypair);
|
|
26
26
|
const triadProtocol = new _1.default(connection, wallet);
|
|
27
27
|
const mint = new web3_js_1.PublicKey('X41iRJUPkKaEvhqWdxqrS5P7M5d8A9oathki5sT47KR');
|
|
28
28
|
const markets = [
|
|
29
|
-
// { name: 'Triad', marketId: 0 },
|
|
30
|
-
// { name: 'PYTH', marketId: 1 }
|
|
31
|
-
// { name: 'DRIFT', marketId: 2 }
|
|
32
|
-
// { name: 'SYMMETRY', marketId: 3 }
|
|
33
|
-
// { name: 'ORE', marketId: 4 }
|
|
34
|
-
// { name: 'COLETA', marketId: 5 }
|
|
35
|
-
// { name: 'UNDEADS', marketId: 6 },
|
|
36
|
-
// { name: 'SOL x ETH', marketId: 7 }
|
|
37
|
-
// { name: 'SOL vs ETH', marketId: 8 }
|
|
38
|
-
{ name: 'SOL vs ETH 2', marketId: 9 }
|
|
39
|
-
// { name: 'PYTH x LINK', marketId: 8 },
|
|
40
|
-
// { name: 'SOL PRICE', marketId: 9 }
|
|
41
|
-
];
|
|
42
|
-
const questions = [
|
|
43
29
|
{
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
question: '
|
|
47
|
-
startTime:
|
|
48
|
-
endTime:
|
|
30
|
+
marketId: 14,
|
|
31
|
+
name: 'BTC',
|
|
32
|
+
question: 'Will $BTC be above $85k on November 18th?',
|
|
33
|
+
startTime: 1731429209,
|
|
34
|
+
endTime: 1731812400
|
|
49
35
|
}
|
|
50
|
-
// },
|
|
51
|
-
// {
|
|
52
|
-
// name: 'Pyth',
|
|
53
|
-
// marketId: 1,
|
|
54
|
-
// question: "$PYTH's market cap exceed $1.5B by the end of October?",
|
|
55
|
-
// startTime: 1728415578,
|
|
56
|
-
// endTime: 1730394000
|
|
57
|
-
// },
|
|
58
|
-
// {
|
|
59
|
-
// name: 'Drift',
|
|
60
|
-
// marketId: 2,
|
|
61
|
-
// question:
|
|
62
|
-
// 'Drift surpass $33M in volume on prediction markets by the end of October?',
|
|
63
|
-
// startTime: 1728415578,
|
|
64
|
-
// endTime: 1730394000
|
|
65
|
-
// },
|
|
66
|
-
// {
|
|
67
|
-
// name: 'Symmetry',
|
|
68
|
-
// marketId: 3,
|
|
69
|
-
// question: "Symmetry's TVL exceed $5.5M by the end of October?",
|
|
70
|
-
// startTime: 1728415578,
|
|
71
|
-
// endTime: 1730394000
|
|
72
|
-
// },
|
|
73
|
-
// {
|
|
74
|
-
// name: 'Ore',
|
|
75
|
-
// marketId: 4,
|
|
76
|
-
// question: 'ORE surpass 20k on-chain miners by the end of October?',
|
|
77
|
-
// startTime: 1728415578,
|
|
78
|
-
// endTime: 1730394000
|
|
79
|
-
// },
|
|
80
|
-
// {
|
|
81
|
-
// name: 'Coleta',
|
|
82
|
-
// marketId: 5,
|
|
83
|
-
// question:
|
|
84
|
-
// 'COLETA PFP reach 500 SOL in total volume by the end of October (based on Tensor)?',
|
|
85
|
-
// startTime: 1728415578,
|
|
86
|
-
// endTime: 1730394000
|
|
87
|
-
// },
|
|
88
|
-
// {
|
|
89
|
-
// name: 'Undeads',
|
|
90
|
-
// marketId: 6,
|
|
91
|
-
// question:
|
|
92
|
-
// 'The Undeads reach more than 1,600 holders by the end of October?',
|
|
93
|
-
// startTime: 1728415578,
|
|
94
|
-
// endTime: 1730394000
|
|
95
|
-
// }
|
|
96
36
|
];
|
|
97
37
|
const ordersHypeAndFloopBot = [
|
|
98
38
|
{
|
|
@@ -106,7 +46,7 @@ const ordersHypeAndFloopBot = [
|
|
|
106
46
|
const updateStakeVault = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
107
47
|
const response = yield triadProtocol.stake.updateStakeVault({
|
|
108
48
|
wallet: wallet.publicKey,
|
|
109
|
-
amount: new anchor_1.BN(
|
|
49
|
+
amount: new anchor_1.BN(10000 * Math.pow(10, 6)),
|
|
110
50
|
isLocked: false
|
|
111
51
|
});
|
|
112
52
|
console.log(response);
|
|
@@ -139,23 +79,24 @@ const getAllMarkets = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
139
79
|
const markets = yield triadProtocol.trade.getAllMarkets();
|
|
140
80
|
console.log(markets);
|
|
141
81
|
});
|
|
82
|
+
getAllMarkets();
|
|
142
83
|
const getMarket = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
143
|
-
const market = yield triadProtocol.trade.getMarketById(
|
|
84
|
+
const market = yield triadProtocol.trade.getMarketById(12);
|
|
144
85
|
console.log(market);
|
|
145
86
|
});
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
87
|
+
const initializeAllMarkets = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
88
|
+
for (const market of markets) {
|
|
89
|
+
try {
|
|
90
|
+
const response = yield triadProtocol.trade.initializeMarket(market, {
|
|
91
|
+
microLamports: 5000
|
|
92
|
+
});
|
|
93
|
+
console.log(`Initialized market ${market.name}:`, response);
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
console.error(`Error initializing market ${market.name}:`, error);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
});
|
|
159
100
|
const getOrders = (walletAddress) => __awaiter(void 0, void 0, void 0, function* () {
|
|
160
101
|
const response = (yield triadProtocol.program.account.userTrade.all()).find((userTrade) => userTrade.account.authority.toBase58() === walletAddress.toBase58());
|
|
161
102
|
let orders = [];
|
|
@@ -312,7 +253,6 @@ const getLiquidityToRecovery = () => __awaiter(void 0, void 0, void 0, function*
|
|
|
312
253
|
}
|
|
313
254
|
console.log(liquidityToRecovery);
|
|
314
255
|
});
|
|
315
|
-
getLiquidityToRecovery();
|
|
316
256
|
const openOrder = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
317
257
|
yield getMarket();
|
|
318
258
|
for (const order of ordersHypeAndFloopBot) {
|
|
@@ -369,8 +309,10 @@ const mintTokens = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
369
309
|
});
|
|
370
310
|
const resolveMarket = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
371
311
|
const marketsToResolve = [
|
|
372
|
-
{ marketId:
|
|
373
|
-
{ marketId:
|
|
312
|
+
{ marketId: 10, winningDirection: { hype: {} } },
|
|
313
|
+
{ marketId: 11, winningDirection: { flop: {} } },
|
|
314
|
+
{ marketId: 12, winningDirection: { hype: {} } },
|
|
315
|
+
{ marketId: 13, winningDirection: { hype: {} } }
|
|
374
316
|
];
|
|
375
317
|
for (const market of marketsToResolve) {
|
|
376
318
|
const response = yield triadProtocol.trade.resolveMarket({
|
|
@@ -395,14 +337,15 @@ const addLiquidity = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
395
337
|
const collectFees = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
396
338
|
console.log('Collecting fees');
|
|
397
339
|
const allMarkets = yield triadProtocol.trade.getAllMarkets();
|
|
340
|
+
let currentFees = {};
|
|
398
341
|
for (const market of allMarkets) {
|
|
399
|
-
if (Number(market.marketId) === 0 || Number(market.marketId) === 7) {
|
|
400
|
-
continue;
|
|
401
|
-
}
|
|
402
342
|
console.log(`Collecting fees for market ${market.marketId}`);
|
|
403
343
|
try {
|
|
404
344
|
const response = yield triadProtocol.trade.collectFee({
|
|
405
|
-
marketId: Number(market.marketId)
|
|
345
|
+
marketId: Number(market.marketId),
|
|
346
|
+
vault: new web3_js_1.PublicKey('6fcSf6qfwPNR9AUUNC1UWYZDy5cQ4TzTb2aaipN2zFdq')
|
|
347
|
+
}, {
|
|
348
|
+
microLamports: 70000
|
|
406
349
|
});
|
|
407
350
|
console.log(response);
|
|
408
351
|
}
|
|
@@ -410,4 +353,5 @@ const collectFees = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
410
353
|
console.log(e);
|
|
411
354
|
}
|
|
412
355
|
}
|
|
356
|
+
fs_1.default.writeFileSync(`fees-collected.json`, JSON.stringify(currentFees, null, 2));
|
|
413
357
|
});
|
package/dist/stake.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { AnchorProvider, Program } from '@coral-xyz/anchor';
|
|
|
2
2
|
import { PublicKey } from '@solana/web3.js';
|
|
3
3
|
import { TriadProtocol } from './types/triad_protocol';
|
|
4
4
|
import { RpcOptions } from './types';
|
|
5
|
-
import { UpdateStakeVaultArgs,
|
|
5
|
+
import { UpdateStakeVaultArgs, RequestWithdrawArgs, WithdrawArgs, Stake as StakeResponse, ClaimStakeRewardsArgs, StakeTokenArgs, UpdateBoostArgs } from './types/stake';
|
|
6
6
|
export default class Stake {
|
|
7
7
|
program: Program<TriadProtocol>;
|
|
8
8
|
provider: AnchorProvider;
|
|
@@ -35,13 +35,6 @@ export default class Stake {
|
|
|
35
35
|
name: string;
|
|
36
36
|
rarityRankHrtt: number;
|
|
37
37
|
}[]): Promise<StakeResponse[]>;
|
|
38
|
-
/**
|
|
39
|
-
* Stake NFT
|
|
40
|
-
* @param mint - NFT mint
|
|
41
|
-
* @param items - NFT items
|
|
42
|
-
*
|
|
43
|
-
*/
|
|
44
|
-
stakeNft({ wallet, items }: StakeNftArgs, options?: RpcOptions): Promise<string>;
|
|
45
38
|
/**
|
|
46
39
|
* Stake Token
|
|
47
40
|
* @param name - Index
|
package/dist/stake.js
CHANGED
|
@@ -114,31 +114,6 @@ class Stake {
|
|
|
114
114
|
return data;
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
|
-
/**
|
|
118
|
-
* Stake NFT
|
|
119
|
-
* @param mint - NFT mint
|
|
120
|
-
* @param items - NFT items
|
|
121
|
-
*
|
|
122
|
-
*/
|
|
123
|
-
stakeNft({ wallet, items }, options) {
|
|
124
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
125
|
-
let ixs = [];
|
|
126
|
-
for (let i = 0; i < items.length; i++) {
|
|
127
|
-
let item = items[i];
|
|
128
|
-
ixs.push(yield this.program.methods
|
|
129
|
-
.stakeNft({
|
|
130
|
-
name: item.name,
|
|
131
|
-
stakeVault: this.stakeVaultName
|
|
132
|
-
})
|
|
133
|
-
.accounts({
|
|
134
|
-
signer: wallet,
|
|
135
|
-
mint: item.mint
|
|
136
|
-
})
|
|
137
|
-
.instruction());
|
|
138
|
-
}
|
|
139
|
-
return (0, sendVersionedTransaction_1.default)(this.provider, ixs, options);
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
117
|
/**
|
|
143
118
|
* Stake Token
|
|
144
119
|
* @param name - Index
|
package/dist/trade.d.ts
CHANGED
|
@@ -122,7 +122,7 @@ export default class Trade {
|
|
|
122
122
|
* @param options - RPC options
|
|
123
123
|
*
|
|
124
124
|
*/
|
|
125
|
-
openOrder({ marketId, amount, direction, token
|
|
125
|
+
openOrder({ marketId, amount, direction, token }: OpenOrderArgs, options?: RpcOptions): Promise<string>;
|
|
126
126
|
/**
|
|
127
127
|
* Close Order
|
|
128
128
|
* @param marketId - The ID of the market
|
|
@@ -186,7 +186,23 @@ export default class Trade {
|
|
|
186
186
|
* @param options - RPC options
|
|
187
187
|
*
|
|
188
188
|
*/
|
|
189
|
-
collectFee({ marketId }: {
|
|
189
|
+
collectFee({ marketId, vault }: {
|
|
190
190
|
marketId: number;
|
|
191
|
+
vault: PublicKey;
|
|
192
|
+
}, options?: RpcOptions): Promise<{
|
|
193
|
+
feeToSwap: number;
|
|
194
|
+
lamport: number;
|
|
195
|
+
}>;
|
|
196
|
+
/**
|
|
197
|
+
* Payout an order
|
|
198
|
+
* @param marketId - The ID of the market
|
|
199
|
+
* @param orderId - The ID of the order to payout
|
|
200
|
+
*
|
|
201
|
+
* @param options - RPC options
|
|
202
|
+
*
|
|
203
|
+
*/
|
|
204
|
+
payoutOrder({ marketId, orderId }: {
|
|
205
|
+
marketId: number;
|
|
206
|
+
orderId: number;
|
|
191
207
|
}, options?: RpcOptions): Promise<string>;
|
|
192
208
|
}
|
package/dist/trade.js
CHANGED
|
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
15
16
|
const bn_js_1 = __importDefault(require("bn.js"));
|
|
16
17
|
const constants_1 = require("./utils/constants");
|
|
17
18
|
const helpers_1 = require("./utils/helpers");
|
|
@@ -20,6 +21,7 @@ const pda_1 = require("./utils/pda");
|
|
|
20
21
|
const sendVersionedTransaction_1 = __importDefault(require("./utils/sendVersionedTransaction"));
|
|
21
22
|
const sendTransactionWithOptions_1 = __importDefault(require("./utils/sendTransactionWithOptions"));
|
|
22
23
|
const swap_1 = require("./utils/swap");
|
|
24
|
+
const jup_swap_1 = require("./utils/jup-swap");
|
|
23
25
|
class Trade {
|
|
24
26
|
constructor(program, provider) {
|
|
25
27
|
this.mint = constants_1.TRD_MINT;
|
|
@@ -109,7 +111,7 @@ class Trade {
|
|
|
109
111
|
* @param options - RPC options
|
|
110
112
|
*
|
|
111
113
|
*/
|
|
112
|
-
openOrder({ marketId, amount, direction, token
|
|
114
|
+
openOrder({ marketId, amount, direction, token }, options) {
|
|
113
115
|
return __awaiter(this, void 0, void 0, function* () {
|
|
114
116
|
const marketPDA = (0, trade_1.getMarketPDA)(this.program.programId, marketId);
|
|
115
117
|
const userTradePDA = (0, trade_1.getUserTradePDA)(this.program.programId, this.provider.publicKey);
|
|
@@ -147,8 +149,7 @@ class Trade {
|
|
|
147
149
|
ixs.push(yield this.program.methods
|
|
148
150
|
.openOrder({
|
|
149
151
|
amount: new bn_js_1.default(amountInTRD),
|
|
150
|
-
direction: direction
|
|
151
|
-
comment: (0, helpers_1.encodeString)(comment, 64)
|
|
152
|
+
direction: direction
|
|
152
153
|
})
|
|
153
154
|
.accounts({
|
|
154
155
|
signer: this.provider.publicKey,
|
|
@@ -251,13 +252,69 @@ class Trade {
|
|
|
251
252
|
* @param options - RPC options
|
|
252
253
|
*
|
|
253
254
|
*/
|
|
254
|
-
collectFee({ marketId }, options) {
|
|
255
|
+
collectFee({ marketId, vault }, options) {
|
|
255
256
|
return __awaiter(this, void 0, void 0, function* () {
|
|
256
257
|
const marketPDA = (0, trade_1.getMarketPDA)(this.program.programId, marketId);
|
|
257
|
-
|
|
258
|
+
const ixs = [];
|
|
259
|
+
ixs.push(yield this.program.methods
|
|
260
|
+
.collectFee()
|
|
261
|
+
.accounts({
|
|
258
262
|
signer: this.provider.publicKey,
|
|
259
263
|
market: marketPDA,
|
|
260
264
|
mint: this.mint
|
|
265
|
+
})
|
|
266
|
+
.instruction());
|
|
267
|
+
const market = yield this.getMarketById(marketId);
|
|
268
|
+
const marketFee = parseFloat(market.marketFeeAvailable) -
|
|
269
|
+
parseFloat(market.marketFeeClaimed);
|
|
270
|
+
const nftFee = parseFloat(market.nftHoldersFeeAvailable) -
|
|
271
|
+
parseFloat(market.nftHoldersFeeClaimed);
|
|
272
|
+
const totalFee = marketFee + nftFee;
|
|
273
|
+
if (totalFee / Math.pow(10, constants_1.TRD_DECIMALS) < 100) {
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
const { setupInstructions, swapIxs, addressLookupTableAccounts, cleanupInstruction, otherAmountThreshold } = yield (0, jup_swap_1.jupSwap)({
|
|
277
|
+
connection: this.provider.connection,
|
|
278
|
+
wallet: this.provider.publicKey.toBase58(),
|
|
279
|
+
inToken: constants_1.TRD_MINT.toBase58(),
|
|
280
|
+
outToken: constants_1.SOL_MINT.toBase58(),
|
|
281
|
+
amount: parseInt(totalFee.toFixed())
|
|
282
|
+
});
|
|
283
|
+
ixs.push(...setupInstructions);
|
|
284
|
+
ixs.push(web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({
|
|
285
|
+
units: 500000
|
|
286
|
+
}));
|
|
287
|
+
ixs.push(...swapIxs);
|
|
288
|
+
ixs.push(cleanupInstruction);
|
|
289
|
+
ixs.push(web3_js_1.SystemProgram.transfer({
|
|
290
|
+
fromPubkey: this.provider.publicKey,
|
|
291
|
+
toPubkey: vault,
|
|
292
|
+
lamports: otherAmountThreshold
|
|
293
|
+
}));
|
|
294
|
+
yield (0, sendVersionedTransaction_1.default)(this.provider, ixs, options, undefined, addressLookupTableAccounts);
|
|
295
|
+
return {
|
|
296
|
+
feeToSwap: totalFee,
|
|
297
|
+
lamport: otherAmountThreshold
|
|
298
|
+
};
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Payout an order
|
|
303
|
+
* @param marketId - The ID of the market
|
|
304
|
+
* @param orderId - The ID of the order to payout
|
|
305
|
+
*
|
|
306
|
+
* @param options - RPC options
|
|
307
|
+
*
|
|
308
|
+
*/
|
|
309
|
+
payoutOrder({ marketId, orderId }, options) {
|
|
310
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
311
|
+
const marketPDA = (0, trade_1.getMarketPDA)(this.program.programId, marketId);
|
|
312
|
+
const userTradePDA = (0, trade_1.getUserTradePDA)(this.program.programId, this.provider.publicKey);
|
|
313
|
+
return (0, sendTransactionWithOptions_1.default)(this.program.methods.payoutOrder(new bn_js_1.default(orderId)).accounts({
|
|
314
|
+
signer: this.provider.publicKey,
|
|
315
|
+
userTrade: userTradePDA,
|
|
316
|
+
market: marketPDA,
|
|
317
|
+
mint: this.mint
|
|
261
318
|
}), options);
|
|
262
319
|
});
|
|
263
320
|
}
|