@triadxyz/triad-protocol 1.2.1-beta → 1.2.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 +0 -10
- package/dist/index.js +2 -11
- package/dist/local-test.js +175 -78
- package/dist/stake.d.ts +1 -8
- package/dist/stake.js +0 -25
- package/dist/trade.d.ts +20 -20
- package/dist/trade.js +77 -63
- package/dist/types/idl_triad_protocol.json +362 -670
- package/dist/types/trade.d.ts +16 -42
- package/dist/types/triad_protocol.d.ts +387 -726
- package/dist/utils/constants.d.ts +1 -0
- package/dist/utils/constants.js +2 -1
- package/dist/utils/helpers.d.ts +2 -1
- package/dist/utils/helpers.js +44 -29
- package/dist/utils/jup-swap.d.ts +15 -0
- package/dist/utils/jup-swap.js +66 -0
- package/dist/utils/pda/trade.d.ts +0 -1
- package/dist/utils/pda/trade.js +1 -5
- 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,77 +21,11 @@ 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
|
-
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: 'PYTH x LINK', marketId: 8 },
|
|
38
|
-
{ name: 'SOL PRICE', marketId: 9 }
|
|
39
|
-
];
|
|
40
|
-
const questions = [
|
|
41
|
-
{
|
|
42
|
-
name: 'Pyth',
|
|
43
|
-
marketId: 1,
|
|
44
|
-
question: 'test 2',
|
|
45
|
-
startTime: 1719513866,
|
|
46
|
-
endTime: 1730394000
|
|
47
|
-
}
|
|
48
|
-
// },
|
|
49
|
-
// {
|
|
50
|
-
// name: 'Pyth',
|
|
51
|
-
// marketId: 1,
|
|
52
|
-
// question: "$PYTH's market cap exceed $1.5B by the end of October?",
|
|
53
|
-
// startTime: 1728415578,
|
|
54
|
-
// endTime: 1730394000
|
|
55
|
-
// },
|
|
56
|
-
// {
|
|
57
|
-
// name: 'Drift',
|
|
58
|
-
// marketId: 2,
|
|
59
|
-
// question:
|
|
60
|
-
// 'Drift surpass $33M in volume on prediction markets by the end of October?',
|
|
61
|
-
// startTime: 1728415578,
|
|
62
|
-
// endTime: 1730394000
|
|
63
|
-
// },
|
|
64
|
-
// {
|
|
65
|
-
// name: 'Symmetry',
|
|
66
|
-
// marketId: 3,
|
|
67
|
-
// question: "Symmetry's TVL exceed $5.5M by the end of October?",
|
|
68
|
-
// startTime: 1728415578,
|
|
69
|
-
// endTime: 1730394000
|
|
70
|
-
// },
|
|
71
|
-
// {
|
|
72
|
-
// name: 'Ore',
|
|
73
|
-
// marketId: 4,
|
|
74
|
-
// question: 'ORE surpass 20k on-chain miners by the end of October?',
|
|
75
|
-
// startTime: 1728415578,
|
|
76
|
-
// endTime: 1730394000
|
|
77
|
-
// },
|
|
78
|
-
// {
|
|
79
|
-
// name: 'Coleta',
|
|
80
|
-
// marketId: 5,
|
|
81
|
-
// question:
|
|
82
|
-
// 'COLETA PFP reach 500 SOL in total volume by the end of October (based on Tensor)?',
|
|
83
|
-
// startTime: 1728415578,
|
|
84
|
-
// endTime: 1730394000
|
|
85
|
-
// },
|
|
86
|
-
// {
|
|
87
|
-
// name: 'Undeads',
|
|
88
|
-
// marketId: 6,
|
|
89
|
-
// question:
|
|
90
|
-
// 'The Undeads reach more than 1,600 holders by the end of October?',
|
|
91
|
-
// startTime: 1728415578,
|
|
92
|
-
// endTime: 1730394000
|
|
93
|
-
// }
|
|
94
|
-
];
|
|
28
|
+
const markets = [];
|
|
95
29
|
const ordersHypeAndFloopBot = [
|
|
96
30
|
{
|
|
97
31
|
marketId: 7,
|
|
@@ -104,7 +38,8 @@ const ordersHypeAndFloopBot = [
|
|
|
104
38
|
const updateStakeVault = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
105
39
|
const response = yield triadProtocol.stake.updateStakeVault({
|
|
106
40
|
wallet: wallet.publicKey,
|
|
107
|
-
amount: new anchor_1.BN(
|
|
41
|
+
amount: new anchor_1.BN(10000 * Math.pow(10, 6)),
|
|
42
|
+
isLocked: false
|
|
108
43
|
});
|
|
109
44
|
console.log(response);
|
|
110
45
|
});
|
|
@@ -136,16 +71,15 @@ const getAllMarkets = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
136
71
|
const markets = yield triadProtocol.trade.getAllMarkets();
|
|
137
72
|
console.log(markets);
|
|
138
73
|
});
|
|
139
|
-
getAllMarkets();
|
|
140
74
|
const getMarket = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
141
|
-
const market = yield triadProtocol.trade.getMarketById(
|
|
75
|
+
const market = yield triadProtocol.trade.getMarketById(12);
|
|
142
76
|
console.log(market);
|
|
143
77
|
});
|
|
144
78
|
const initializeAllMarkets = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
145
79
|
for (const market of markets) {
|
|
146
80
|
try {
|
|
147
81
|
const response = yield triadProtocol.trade.initializeMarket(market, {
|
|
148
|
-
|
|
82
|
+
microLamports: 5000
|
|
149
83
|
});
|
|
150
84
|
console.log(`Initialized market ${market.name}:`, response);
|
|
151
85
|
}
|
|
@@ -176,6 +110,140 @@ const getOrders = (walletAddress) => __awaiter(void 0, void 0, void 0, function*
|
|
|
176
110
|
return orders;
|
|
177
111
|
});
|
|
178
112
|
// getOrders(new PublicKey('HjJQdfTHgC3EBX3471w4st8BXbBmtbaMyCAXNgcUb7dq'))
|
|
113
|
+
const getLiquidityToRecovery = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
114
|
+
const response = yield triadProtocol.program.account.userTrade.all();
|
|
115
|
+
const allMarkets = yield triadProtocol.trade.getAllMarkets();
|
|
116
|
+
const liquidityToRecovery = {
|
|
117
|
+
0: {
|
|
118
|
+
name: 'triad',
|
|
119
|
+
liquidityToPay: 0,
|
|
120
|
+
sharesToPay: 0,
|
|
121
|
+
openOrders: 0,
|
|
122
|
+
medPrice: 0,
|
|
123
|
+
direction: {
|
|
124
|
+
flop: {}
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
1: {
|
|
128
|
+
name: 'pyth',
|
|
129
|
+
liquidityToPay: 0,
|
|
130
|
+
sharesToPay: 0,
|
|
131
|
+
openOrders: 0,
|
|
132
|
+
medPrice: 0,
|
|
133
|
+
direction: {
|
|
134
|
+
flop: {}
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
2: {
|
|
138
|
+
name: 'drift',
|
|
139
|
+
liquidityToPay: 0,
|
|
140
|
+
sharesToPay: 0,
|
|
141
|
+
openOrders: 0,
|
|
142
|
+
medPrice: 0,
|
|
143
|
+
direction: {
|
|
144
|
+
flop: {}
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
3: {
|
|
148
|
+
name: 'symmetry',
|
|
149
|
+
liquidityToPay: 0,
|
|
150
|
+
sharesToPay: 0,
|
|
151
|
+
openOrders: 0,
|
|
152
|
+
medPrice: 0,
|
|
153
|
+
direction: {
|
|
154
|
+
flop: {}
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
4: {
|
|
158
|
+
name: 'ore',
|
|
159
|
+
liquidityToPay: 0,
|
|
160
|
+
sharesToPay: 0,
|
|
161
|
+
openOrders: 0,
|
|
162
|
+
medPrice: 0,
|
|
163
|
+
direction: {
|
|
164
|
+
hype: {}
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
5: {
|
|
168
|
+
name: 'coleta',
|
|
169
|
+
liquidityToPay: 0,
|
|
170
|
+
sharesToPay: 0,
|
|
171
|
+
openOrders: 0,
|
|
172
|
+
medPrice: 0,
|
|
173
|
+
direction: {
|
|
174
|
+
flop: {}
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
6: {
|
|
178
|
+
name: 'undead',
|
|
179
|
+
liquidityToPay: 0,
|
|
180
|
+
sharesToPay: 0,
|
|
181
|
+
openOrders: 0,
|
|
182
|
+
medPrice: 0,
|
|
183
|
+
direction: {
|
|
184
|
+
hype: {}
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
7: {
|
|
188
|
+
name: 'solxeth',
|
|
189
|
+
liquidityToPay: 0,
|
|
190
|
+
sharesToPay: 0,
|
|
191
|
+
openOrders: 0,
|
|
192
|
+
medPrice: 0,
|
|
193
|
+
direction: {
|
|
194
|
+
flop: {}
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
8: {
|
|
198
|
+
name: 'solxeth2',
|
|
199
|
+
liquidityToPay: 0,
|
|
200
|
+
sharesToPay: 0,
|
|
201
|
+
openOrders: 0,
|
|
202
|
+
medPrice: 0,
|
|
203
|
+
direction: {
|
|
204
|
+
flop: {}
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
9: {
|
|
208
|
+
name: 'solxeth3',
|
|
209
|
+
liquidityToPay: 0,
|
|
210
|
+
sharesToPay: 0,
|
|
211
|
+
openOrders: 0,
|
|
212
|
+
medPrice: 0,
|
|
213
|
+
direction: {
|
|
214
|
+
flop: {}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
for (const market of allMarkets) {
|
|
219
|
+
let currentMarket = liquidityToRecovery[market.marketId];
|
|
220
|
+
if ('flop' in currentMarket.direction) {
|
|
221
|
+
let shares = parseFloat(market.flopShares.toString()) / Math.pow(10, 6);
|
|
222
|
+
currentMarket.medPrice =
|
|
223
|
+
parseFloat(market.hypeLiquidity.toString()) / Math.pow(10, 6) / shares;
|
|
224
|
+
currentMarket.sharesToPay = shares;
|
|
225
|
+
currentMarket.liquidityToPay =
|
|
226
|
+
parseFloat(market.hypeLiquidity.toString()) / Math.pow(10, 6);
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
let shares = parseFloat(market.hypeShares.toString()) / Math.pow(10, 6);
|
|
230
|
+
currentMarket.medPrice =
|
|
231
|
+
parseFloat(market.flopLiquidity.toString()) / Math.pow(10, 6) / shares;
|
|
232
|
+
currentMarket.sharesToPay = shares;
|
|
233
|
+
currentMarket.liquidityToPay =
|
|
234
|
+
parseFloat(market.flopLiquidity.toString()) / Math.pow(10, 6);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
for (const userTrade of response) {
|
|
238
|
+
for (const order of userTrade.account.orders) {
|
|
239
|
+
const market = liquidityToRecovery[order.marketId.toNumber()];
|
|
240
|
+
if (Object.keys(order.direction)[0] === Object.keys(market.direction)[0]) {
|
|
241
|
+
market.openOrders += 1;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
console.log(liquidityToRecovery);
|
|
246
|
+
});
|
|
179
247
|
const openOrder = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
180
248
|
yield getMarket();
|
|
181
249
|
for (const order of ordersHypeAndFloopBot) {
|
|
@@ -230,15 +298,13 @@ const mintTokens = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
230
298
|
const mintTx = yield (0, spl_token_1.mintTo)(connection, keypair, mint, ata, keypair, 1000000 * Math.pow(10, 6), [keypair], undefined, spl_token_1.TOKEN_2022_PROGRAM_ID);
|
|
231
299
|
console.log(mintTx);
|
|
232
300
|
});
|
|
233
|
-
const
|
|
301
|
+
const resolveMarket = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
234
302
|
const marketsToResolve = [
|
|
235
|
-
{ marketId:
|
|
236
|
-
{ marketId:
|
|
237
|
-
{ marketId: 3, winningDirection: { flop: {} } },
|
|
238
|
-
{ marketId: 5, winningDirection: { flop: {} } }
|
|
303
|
+
{ marketId: 8, winningDirection: { flop: {} } },
|
|
304
|
+
{ marketId: 9, winningDirection: { flop: {} } }
|
|
239
305
|
];
|
|
240
306
|
for (const market of marketsToResolve) {
|
|
241
|
-
const response = yield triadProtocol.trade.
|
|
307
|
+
const response = yield triadProtocol.trade.resolveMarket({
|
|
242
308
|
marketId: market.marketId,
|
|
243
309
|
winningDirection: market.winningDirection
|
|
244
310
|
}, {
|
|
@@ -247,3 +313,34 @@ const resolveQuestion = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
247
313
|
console.log(response);
|
|
248
314
|
}
|
|
249
315
|
});
|
|
316
|
+
const addLiquidity = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
317
|
+
const response = yield triadProtocol.trade.addLiquidity({
|
|
318
|
+
marketId: 5,
|
|
319
|
+
amount: 4729,
|
|
320
|
+
direction: {
|
|
321
|
+
hype: {}
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
console.log(response);
|
|
325
|
+
});
|
|
326
|
+
const collectFees = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
327
|
+
console.log('Collecting fees');
|
|
328
|
+
const allMarkets = yield triadProtocol.trade.getAllMarkets();
|
|
329
|
+
let currentFees = {};
|
|
330
|
+
for (const market of allMarkets) {
|
|
331
|
+
console.log(`Collecting fees for market ${market.marketId}`);
|
|
332
|
+
try {
|
|
333
|
+
const response = yield triadProtocol.trade.collectFee({
|
|
334
|
+
marketId: Number(market.marketId),
|
|
335
|
+
vault: new web3_js_1.PublicKey('6fcSf6qfwPNR9AUUNC1UWYZDy5cQ4TzTb2aaipN2zFdq')
|
|
336
|
+
}, {
|
|
337
|
+
microLamports: 70000
|
|
338
|
+
});
|
|
339
|
+
console.log(response);
|
|
340
|
+
}
|
|
341
|
+
catch (e) {
|
|
342
|
+
console.log(e);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
fs_1.default.writeFileSync(`fees-collected.json`, JSON.stringify(currentFees, null, 2));
|
|
346
|
+
});
|
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
|
@@ -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 } from '@solana/web3.js';
|
|
4
|
-
import {
|
|
4
|
+
import { InitializeMarketArgs, Market, OpenOrderArgs, OrderDirection } from './types/trade';
|
|
5
5
|
import { RpcOptions } from './types';
|
|
6
6
|
import BN from 'bn.js';
|
|
7
7
|
export default class Trade {
|
|
@@ -13,7 +13,6 @@ export default class Trade {
|
|
|
13
13
|
* Get all Markets
|
|
14
14
|
*/
|
|
15
15
|
getAllMarkets(): Promise<Market[]>;
|
|
16
|
-
getFeeVault(marketId: number): Promise<FeeVault>;
|
|
17
16
|
/**
|
|
18
17
|
* Get Market by ID
|
|
19
18
|
* @param marketId - The ID of the market
|
|
@@ -111,10 +110,7 @@ export default class Trade {
|
|
|
111
110
|
* @param options - RPC options
|
|
112
111
|
*
|
|
113
112
|
*/
|
|
114
|
-
initializeMarket({ marketId, name }:
|
|
115
|
-
marketId: number;
|
|
116
|
-
name: string;
|
|
117
|
-
}, options?: RpcOptions): Promise<any>;
|
|
113
|
+
initializeMarket({ marketId, name, startTime, endTime, question }: InitializeMarketArgs, options?: RpcOptions): Promise<any>;
|
|
118
114
|
/**
|
|
119
115
|
* Open Order
|
|
120
116
|
* @param marketId - The ID of the market
|
|
@@ -126,7 +122,7 @@ export default class Trade {
|
|
|
126
122
|
* @param options - RPC options
|
|
127
123
|
*
|
|
128
124
|
*/
|
|
129
|
-
openOrder({ marketId, amount, direction, token
|
|
125
|
+
openOrder({ marketId, amount, direction, token }: OpenOrderArgs, options?: RpcOptions): Promise<string>;
|
|
130
126
|
/**
|
|
131
127
|
* Close Order
|
|
132
128
|
* @param marketId - The ID of the market
|
|
@@ -140,24 +136,14 @@ export default class Trade {
|
|
|
140
136
|
orderId: number;
|
|
141
137
|
}, options?: RpcOptions): Promise<string>;
|
|
142
138
|
/**
|
|
143
|
-
*
|
|
144
|
-
* @param marketId - The ID of the market
|
|
145
|
-
* @param question - The question to initialize
|
|
146
|
-
* @param startTime - The start time of the question
|
|
147
|
-
* @param endTime - The end time of the question
|
|
148
|
-
*
|
|
149
|
-
* @param options - RPC options
|
|
150
|
-
*
|
|
151
|
-
*/
|
|
152
|
-
initializeQuestion({ marketId, question, startTime, endTime }: InitializeQuestionArgs, options?: RpcOptions): Promise<string>;
|
|
153
|
-
/**
|
|
154
|
-
* Resolve the current question for a market
|
|
139
|
+
* Resolve Market
|
|
155
140
|
* @param marketId - The ID of the market
|
|
141
|
+
* @param winningDirection - The winning direction of the market
|
|
156
142
|
*
|
|
157
143
|
* @param options - RPC options
|
|
158
144
|
*
|
|
159
145
|
*/
|
|
160
|
-
|
|
146
|
+
resolveMarket({ marketId, winningDirection }: {
|
|
161
147
|
marketId: number;
|
|
162
148
|
winningDirection: {
|
|
163
149
|
hype: {};
|
|
@@ -193,4 +179,18 @@ export default class Trade {
|
|
|
193
179
|
amount: number;
|
|
194
180
|
direction: OrderDirection;
|
|
195
181
|
}, options?: RpcOptions): Promise<string>;
|
|
182
|
+
/**
|
|
183
|
+
* Collect Fee
|
|
184
|
+
* @param marketId - The ID of the market
|
|
185
|
+
*
|
|
186
|
+
* @param options - RPC options
|
|
187
|
+
*
|
|
188
|
+
*/
|
|
189
|
+
collectFee({ marketId, vault }: {
|
|
190
|
+
marketId: number;
|
|
191
|
+
vault: PublicKey;
|
|
192
|
+
}, options?: RpcOptions): Promise<{
|
|
193
|
+
feeToSwap: number;
|
|
194
|
+
lamport: number;
|
|
195
|
+
}>;
|
|
196
196
|
}
|