@triadxyz/triad-protocol 1.3.0-beta → 1.3.2-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
@@ -1,10 +1,9 @@
1
- /// <reference types="bn.js" />
2
- import { AnchorProvider, BN, Program, Wallet } from '@coral-xyz/anchor';
3
- import { Connection, PublicKey } from '@solana/web3.js';
1
+ import { AnchorProvider, Program, Wallet } from '@coral-xyz/anchor';
2
+ import { Connection, Keypair, PublicKey } from '@solana/web3.js';
4
3
  import { TriadProtocol } from './types/triad_protocol';
5
4
  import Trade from './trade';
6
5
  import Stake from './stake';
7
- import { CreateUserArgs, MintTicketArgs, RpcOptions } from './types';
6
+ import { CreateUserArgs, MintTicketArgs, PrizeType, RpcOptions } from './types';
8
7
  export default class TriadProtocolClient {
9
8
  program: Program<TriadProtocol>;
10
9
  provider: AnchorProvider;
@@ -44,39 +43,44 @@ export default class TriadProtocolClient {
44
43
  * @param options - RPC options
45
44
  *
46
45
  */
47
- createUser({ wallet, name, referral }: CreateUserArgs, options?: RpcOptions): Promise<any>;
46
+ createUser({ wallet, name, referral }: CreateUserArgs, options?: RpcOptions): Promise<string>;
48
47
  /**
49
- * Get User Positions with amount
50
- * @param wallet - User wallet
48
+ * Create Collection
49
+ * @param args - Collection args
50
+ * @param options - RPC options
51
51
  *
52
52
  */
53
- getUserPositionsWithAmount(wallet: PublicKey): Promise<{
54
- ts: BN;
55
- bump: number;
56
- totalDeposited: BN;
57
- totalWithdrawn: BN;
58
- lpShare: BN;
59
- totalPositions: number;
60
- ticker: PublicKey;
61
- authority: PublicKey;
62
- positions: {
63
- amount: BN;
64
- entryPrice: BN;
65
- ts: BN;
66
- isLong: boolean;
67
- isOpen: boolean;
68
- pnl: BN;
69
- }[];
70
- }[]>;
71
- withdrawV1({ wallet, ticker, positionIndex }: {
72
- wallet: PublicKey;
73
- ticker: PublicKey;
74
- positionIndex: number;
75
- }, options?: RpcOptions): Promise<any>;
76
53
  createCollection(args: {
77
54
  collectionName: string;
78
55
  collectionSymbol: string;
79
56
  supply: number;
80
57
  }, options?: RpcOptions): Promise<string>;
81
58
  mintTicket({ discount, isBoosted, rarity, verifier, nftMint }: MintTicketArgs, options?: RpcOptions): Promise<string>;
59
+ /**
60
+ * Add Spin Prize
61
+ * @param args - Spin prize args
62
+ * @param options - RPC options
63
+ *
64
+ */
65
+ addSpinPrize(args: {
66
+ rangeMin: number;
67
+ rangeMax: number;
68
+ prizeType: PrizeType;
69
+ availableQuantity: number;
70
+ }, options?: RpcOptions): Promise<string>;
71
+ /**
72
+ * Claim Spin Token
73
+ * @param amount - Amount of tokens to claim
74
+ * @param verifier - Verifier keypair
75
+ * @param options - RPC options
76
+ *
77
+ */
78
+ claimSpinToken(amount: number, verifier: Keypair, options?: RpcOptions): Promise<string>;
79
+ /**
80
+ * Spin Roulette
81
+ * @param isSol - Whether to pay with SOL or token
82
+ * @param verifier - Verifier keypair
83
+ * @param options - RPC options
84
+ */
85
+ spinRoulette(isSol: boolean, options?: RpcOptions): Promise<string>;
82
86
  }
package/dist/index.js CHANGED
@@ -17,7 +17,6 @@ const web3_js_1 = require("@solana/web3.js");
17
17
  const idl_triad_protocol_json_1 = __importDefault(require("./types/idl_triad_protocol.json"));
18
18
  const trade_1 = __importDefault(require("./trade"));
19
19
  const helpers_1 = require("./utils/helpers");
20
- const spl_token_1 = require("@solana/spl-token");
21
20
  const pda_1 = require("./utils/pda");
22
21
  const stake_1 = __importDefault(require("./stake"));
23
22
  const sendTransactionWithOptions_1 = __importDefault(require("./utils/sendTransactionWithOptions"));
@@ -123,36 +122,11 @@ class TriadProtocolClient {
123
122
  });
124
123
  }
125
124
  /**
126
- * Get User Positions with amount
127
- * @param wallet - User wallet
125
+ * Create Collection
126
+ * @param args - Collection args
127
+ * @param options - RPC options
128
128
  *
129
129
  */
130
- getUserPositionsWithAmount(wallet) {
131
- return __awaiter(this, void 0, void 0, function* () {
132
- const userPositions = [];
133
- const userPositionPDA = (0, pda_1.getUserPositionPDA)(this.program.programId, wallet, new web3_js_1.PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'));
134
- userPositions.push(userPositionPDA);
135
- const userPositionsWithAmount = yield this.program.account.userPosition.fetchMultiple(userPositions);
136
- return userPositionsWithAmount.filter((item) => item &&
137
- parseFloat(item.totalDeposited.toString()) >
138
- parseFloat(item.totalWithdrawn.toString()));
139
- });
140
- }
141
- withdrawV1({ wallet, ticker, positionIndex }, options) {
142
- return __awaiter(this, void 0, void 0, function* () {
143
- const vaultPDA = (0, pda_1.getVaultAddressSync)(this.program.programId, ticker);
144
- const userPositionPDA = (0, pda_1.getUserPositionPDA)(this.program.programId, wallet, ticker);
145
- const VaultTokenAccountPDA = (0, pda_1.getTokenVaultAddressSync)(this.program.programId, vaultPDA);
146
- const userTokenAccount = yield (0, spl_token_1.getAssociatedTokenAddress)(new web3_js_1.PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'), this.provider.wallet.publicKey);
147
- return (0, sendTransactionWithOptions_1.default)(this.program.methods.withdrawV1(positionIndex).accounts({
148
- signer: wallet,
149
- userPosition: userPositionPDA,
150
- userTokenAccount,
151
- vault: vaultPDA,
152
- vaultTokenAccount: VaultTokenAccountPDA
153
- }), options);
154
- });
155
- }
156
130
  createCollection(args, options) {
157
131
  return __awaiter(this, void 0, void 0, function* () {
158
132
  const keyPair = web3_js_1.Keypair.generate();
@@ -203,5 +177,66 @@ class TriadProtocolClient {
203
177
  return (0, sendVersionedTransaction_1.default)(this.provider, ixs, options, asset, [], (0, convertSecretKeyToKeypair_1.convertSecretKeyToKeypair)(verifier));
204
178
  });
205
179
  }
180
+ /**
181
+ * Add Spin Prize
182
+ * @param args - Spin prize args
183
+ * @param options - RPC options
184
+ *
185
+ */
186
+ addSpinPrize(args, options) {
187
+ return __awaiter(this, void 0, void 0, function* () {
188
+ const method = this.program.methods
189
+ .addSpinPrize({
190
+ name: 'christmas',
191
+ rangeMin: new anchor_1.BN(args.rangeMin),
192
+ rangeMax: new anchor_1.BN(args.rangeMax),
193
+ prizeType: args.prizeType,
194
+ availableQuantity: new anchor_1.BN(args.availableQuantity)
195
+ })
196
+ .accounts({
197
+ signer: this.provider.wallet.publicKey
198
+ });
199
+ return (0, sendTransactionWithOptions_1.default)(method, options);
200
+ });
201
+ }
202
+ /**
203
+ * Claim Spin Token
204
+ * @param amount - Amount of tokens to claim
205
+ * @param verifier - Verifier keypair
206
+ * @param options - RPC options
207
+ *
208
+ */
209
+ claimSpinToken(amount, verifier, options) {
210
+ return __awaiter(this, void 0, void 0, function* () {
211
+ const spinPDA = (0, pda_1.getSpinPDA)(this.program.programId, 'christmas');
212
+ const ix = yield this.program.methods
213
+ .claimSpinToken(new anchor_1.BN(amount))
214
+ .accounts({
215
+ signer: this.provider.wallet.publicKey,
216
+ verifier: verifier.publicKey,
217
+ spin: spinPDA,
218
+ mint: new web3_js_1.PublicKey('9LGNCsQsoeJK2jBMKNiX8UGJv5NPyBHhouTcQLLqWTt9')
219
+ })
220
+ .instruction();
221
+ return (0, sendVersionedTransaction_1.default)(this.provider, [ix], options, undefined, [], verifier);
222
+ });
223
+ }
224
+ /**
225
+ * Spin Roulette
226
+ * @param isSol - Whether to pay with SOL or token
227
+ * @param verifier - Verifier keypair
228
+ * @param options - RPC options
229
+ */
230
+ spinRoulette(isSol, options) {
231
+ return __awaiter(this, void 0, void 0, function* () {
232
+ const spinPDA = (0, pda_1.getSpinPDA)(this.program.programId, 'christmas');
233
+ const method = this.program.methods.spinRoulette(isSol).accounts({
234
+ signer: this.provider.wallet.publicKey,
235
+ spin: spinPDA,
236
+ mint: new web3_js_1.PublicKey('9LGNCsQsoeJK2jBMKNiX8UGJv5NPyBHhouTcQLLqWTt9')
237
+ });
238
+ return (0, sendTransactionWithOptions_1.default)(method, options);
239
+ });
240
+ }
206
241
  }
207
242
  exports.default = TriadProtocolClient;
@@ -16,50 +16,21 @@ const fs_1 = __importDefault(require("fs"));
16
16
  const _1 = __importDefault(require("./"));
17
17
  const anchor_1 = require("@coral-xyz/anchor");
18
18
  const web3_js_1 = require("@solana/web3.js");
19
+ const trade_1 = require("./types/trade");
19
20
  const spl_token_1 = require("@solana/spl-token");
20
21
  const constants_1 = require("./utils/constants");
21
22
  const file = fs_1.default.readFileSync('/Users/dannpl/.config/solana/triad.json');
22
23
  const rpc_file = fs_1.default.readFileSync('/Users/dannpl/.config/solana/rpc.txt');
23
24
  const keypair = web3_js_1.Keypair.fromSecretKey(new Uint8Array(JSON.parse(file.toString())));
24
- const connection = new web3_js_1.Connection("");
25
+ const connection = new web3_js_1.Connection('https://mainnet.helius-rpc.com/?api-key=05843ded-2085-4567-aff3-85af84ea71d2');
25
26
  const wallet = new anchor_1.Wallet(keypair);
26
27
  const triadProtocol = new _1.default(connection, wallet);
27
28
  const markets = [
28
29
  {
29
- marketId: 31,
30
- question: 'Will $ETH hit new ATH before 2025?',
31
- startTime: 1733508000,
32
- endTime: 1735603200
33
- },
34
- {
35
- marketId: 32,
36
- question: 'Will $ME price be above $3.20 on December 11?',
37
- startTime: 1733508000,
38
- endTime: 1733788800
39
- },
40
- {
41
- marketId: 33,
42
- question: 'Will $SOL be above $245.00 on December 12?',
43
- startTime: 1733508000,
44
- endTime: 1733875200
45
- },
46
- {
47
- marketId: 34,
48
- question: 'Will $SOL flip $XRP again in 2024?',
49
- startTime: 1733508000,
50
- endTime: 1735603200
51
- },
52
- {
53
- marketId: 35,
54
- question: 'Will $XRP be above $USDT in MKC on December 31?',
55
- startTime: 1733508000,
56
- endTime: 1735603200
57
- },
58
- {
59
- marketId: 36,
60
- question: 'Will DOGE be above $0.45 on December 12?',
61
- startTime: 1733508000,
62
- endTime: 1733875200
30
+ marketId: 38,
31
+ question: 'Will $PENGU be above 0.10$ on December 18?',
32
+ startTime: 1734379200,
33
+ endTime: 1734440400
63
34
  }
64
35
  ];
65
36
  const ordersHypeAndFloopBot = [
@@ -74,7 +45,7 @@ const ordersHypeAndFloopBot = [
74
45
  const updateStakeVault = () => __awaiter(void 0, void 0, void 0, function* () {
75
46
  const response = yield triadProtocol.stake.updateStakeVault({
76
47
  wallet: wallet.publicKey,
77
- amount: new anchor_1.BN(2000 * Math.pow(10, 6)),
48
+ amount: new anchor_1.BN(1000 * Math.pow(10, 6)),
78
49
  isLocked: false
79
50
  });
80
51
  console.log(response);
@@ -83,9 +54,55 @@ const getStakeVault = () => __awaiter(void 0, void 0, void 0, function* () {
83
54
  const response = yield triadProtocol.stake.getStakeVaults();
84
55
  console.log(response);
85
56
  });
86
- const getStaked = () => __awaiter(void 0, void 0, void 0, function* () {
87
- const response = yield triadProtocol.stake.getUserStakes(new web3_js_1.PublicKey('3umHQwkz2r8E6K6xWJuSDziDoWgkWwRckDPGEYzD8TPf'));
88
- console.log(response);
57
+ const getStakes = () => __awaiter(void 0, void 0, void 0, function* () {
58
+ const stakes = yield triadProtocol.stake.getStakes();
59
+ fs_1.default.writeFileSync('stakes.json', JSON.stringify(stakes, null, 2));
60
+ const stakesJson = JSON.parse(fs_1.default.readFileSync('stakes.json', 'utf8'));
61
+ let amountLocked = 0;
62
+ let amountUnlocked = 0;
63
+ let uniqueStakersLocked = new Set();
64
+ let uniqueStakersUnlocked = new Set();
65
+ let usersUnlocked = [];
66
+ let usersLocked = [];
67
+ for (const stake of stakesJson) {
68
+ if (stake.withdrawTs === 0) {
69
+ amountLocked += stake.amount / Math.pow(10, 6);
70
+ uniqueStakersLocked.add(stake.authority);
71
+ if (!usersLocked.find((user) => user.address === stake.authority)) {
72
+ usersLocked.push({
73
+ address: stake.authority,
74
+ amount: stake.amount / Math.pow(10, 6)
75
+ });
76
+ }
77
+ else {
78
+ usersLocked.find((user) => user.address === stake.authority).amount +=
79
+ stake.amount / Math.pow(10, 6);
80
+ }
81
+ }
82
+ else {
83
+ amountUnlocked += stake.amount / Math.pow(10, 6);
84
+ uniqueStakersUnlocked.add(stake.authority);
85
+ if (!usersUnlocked.find((user) => user.address === stake.authority)) {
86
+ usersUnlocked.push({
87
+ address: stake.authority,
88
+ amount: stake.amount / Math.pow(10, 6)
89
+ });
90
+ }
91
+ else {
92
+ usersUnlocked.find((user) => user.address === stake.authority).amount +=
93
+ stake.amount / Math.pow(10, 6);
94
+ }
95
+ }
96
+ }
97
+ const orders = usersLocked.sort((a, b) => b.amount - a.amount);
98
+ const ordersUnlocked = usersUnlocked.sort((a, b) => b.amount - a.amount);
99
+ console.log('Amount locked:', amountLocked);
100
+ console.log('Amount unlocked:', amountUnlocked);
101
+ console.log('Unique stakers:', uniqueStakersLocked.size);
102
+ console.log('Unique stakers unlocked:', uniqueStakersUnlocked.size);
103
+ console.log(JSON.stringify(orders, null, 2));
104
+ console.log('--------------------------------');
105
+ console.log(JSON.stringify(ordersUnlocked, null, 2));
89
106
  });
90
107
  const getAllMarkets = () => __awaiter(void 0, void 0, void 0, function* () {
91
108
  const markets = yield triadProtocol.trade.getAllMarkets();
@@ -135,6 +152,10 @@ const getLiquidityToRecovery = () => __awaiter(void 0, void 0, void 0, function*
135
152
  const liquidityToRecovery = {};
136
153
  for (const market of allMarkets) {
137
154
  let currentMarket = liquidityToRecovery[market.marketId];
155
+ if (market.marketId === '31') {
156
+ console.log(market);
157
+ market.winningDirection = trade_1.WinningDirection.HYPE;
158
+ }
138
159
  if (market.winningDirection.toLowerCase() === 'none') {
139
160
  continue;
140
161
  }
@@ -164,7 +185,7 @@ const getLiquidityToRecovery = () => __awaiter(void 0, void 0, void 0, function*
164
185
  let liquidity_coeficient = 1;
165
186
  if ('flop' in currentMarket.direction) {
166
187
  let shares = parseFloat(market.flopShares.toString()) / Math.pow(10, 6);
167
- currentMarket.sharesToPay = shares + 10000;
188
+ currentMarket.sharesToPay = shares;
168
189
  currentMarket.liquidityToPay =
169
190
  parseFloat(market.hypeLiquidity.toString()) / Math.pow(10, 6);
170
191
  currentMarket.liquidityToPay =
@@ -172,7 +193,7 @@ const getLiquidityToRecovery = () => __awaiter(void 0, void 0, void 0, function*
172
193
  }
173
194
  else {
174
195
  let shares = parseFloat(market.hypeShares.toString()) / Math.pow(10, 6);
175
- currentMarket.sharesToPay = shares + 10000;
196
+ currentMarket.sharesToPay = shares;
176
197
  currentMarket.liquidityToPay =
177
198
  parseFloat(market.flopLiquidity.toString()) / Math.pow(10, 6);
178
199
  currentMarket.liquidityToPay =
@@ -235,7 +256,7 @@ const closeOrders = () => __awaiter(void 0, void 0, void 0, function* () {
235
256
  }
236
257
  });
237
258
  const resolveMarket = () => __awaiter(void 0, void 0, void 0, function* () {
238
- const marketsToResolve = [{ marketId: 32, winningDirection: { hype: {} } }];
259
+ const marketsToResolve = [{ marketId: 38, winningDirection: { flop: {} } }];
239
260
  for (const market of marketsToResolve) {
240
261
  const response = yield triadProtocol.trade.resolveMarket({
241
262
  marketId: market.marketId,
@@ -283,3 +304,111 @@ const burnLP = () => __awaiter(void 0, void 0, void 0, function* () {
283
304
  const response = yield (0, spl_token_1.burn)(connection, keypair, getTokenAccount, SOL_LP, wallet.publicKey, amount);
284
305
  console.log(response);
285
306
  });
307
+ const getReferral = () => __awaiter(void 0, void 0, void 0, function* () {
308
+ const response = yield triadProtocol.getUser(new web3_js_1.PublicKey('in6cFcFF2eawkdtrGvV4mM33dRhBymJcf1Fk8mrqGJt'));
309
+ console.log(response);
310
+ });
311
+ const resolveWithLiquidity = () => __awaiter(void 0, void 0, void 0, function* () {
312
+ const response = yield triadProtocol.trade.resolveMarketWithLiquidity({
313
+ marketId: 37,
314
+ winningDirection: { flop: {} },
315
+ marketToAddLiquidity: { hype: {} },
316
+ amount: 1000
317
+ });
318
+ console.log(response);
319
+ });
320
+ const mintToken = () => __awaiter(void 0, void 0, void 0, function* () {
321
+ const filekey = fs_1.default.readFileSync('./tCMraBSGHeMcQS76hNnBhnfbMzrtnnT3nbt3vAnSCE2.json');
322
+ const token = web3_js_1.Keypair.fromSecretKey(new Uint8Array(JSON.parse(filekey.toString())));
323
+ try {
324
+ const decimals = 6; // Common decimal places for tokens
325
+ const amount = 1000000 * Math.pow(10, decimals); // 1,000,000 tokens with decimals
326
+ // Calculate space needed for mint account including metadata pointer
327
+ // const mintLen = getMintLen([ExtensionType.MetadataPointer])
328
+ // const mintTransaction = new Transaction().add(
329
+ // // Create mint account
330
+ // SystemProgram.createAccount({
331
+ // fromPubkey: wallet.publicKey,
332
+ // newAccountPubkey: token.publicKey,
333
+ // space: mintLen,
334
+ // lamports: 6786240,
335
+ // programId: TOKEN_2022_PROGRAM_ID
336
+ // }),
337
+ // createInitializeMetadataPointerInstruction(
338
+ // token.publicKey,
339
+ // wallet.publicKey,
340
+ // token.publicKey,
341
+ // TOKEN_2022_PROGRAM_ID
342
+ // ),
343
+ // createInitializeMintInstruction(
344
+ // token.publicKey,
345
+ // decimals,
346
+ // wallet.publicKey,
347
+ // null,
348
+ // TOKEN_2022_PROGRAM_ID
349
+ // ),
350
+ // createInitializeInstruction({
351
+ // programId: TOKEN_2022_PROGRAM_ID,
352
+ // metadata: token.publicKey,
353
+ // updateAuthority: wallet.publicKey,
354
+ // mint: token.publicKey,
355
+ // mintAuthority: wallet.publicKey,
356
+ // name: 'Triad Christmas',
357
+ // symbol: 'tCMAS',
358
+ // uri: 'https://shdw-drive.genesysgo.net/DRRe9dZkP199W6GLrySn2xj2ayfr8gin8iaBt1YVMN9M/tCMAS.json'
359
+ // })
360
+ // )
361
+ // const transactionSignature = await sendAndConfirmTransaction(
362
+ // connection,
363
+ // mintTransaction,
364
+ // [keypair, token], // Signers,
365
+ // { skipPreflight: false }
366
+ // )
367
+ // console.log(
368
+ // '\nCreate Mint Account:',
369
+ // `https://solana.fm/tx/${transactionSignature}?cluster=devnet-solana`
370
+ // )
371
+ // const associatedTokenAccount = await getOrCreateAssociatedTokenAccount(
372
+ // connection,
373
+ // keypair,
374
+ // token.publicKey,
375
+ // wallet.publicKey,
376
+ // true,
377
+ // undefined,
378
+ // undefined,
379
+ // TOKEN_2022_PROGRAM_ID
380
+ // )
381
+ // const mintToResponse = await mintTo(
382
+ // connection,
383
+ // keypair,
384
+ // token.publicKey,
385
+ // associatedTokenAccount.address,
386
+ // wallet.publicKey,
387
+ // amount,
388
+ // [keypair, token],
389
+ // undefined,
390
+ // TOKEN_2022_PROGRAM_ID
391
+ // )
392
+ // console.log('Token created:', token.publicKey.toString())
393
+ // console.log('Associated Token Account:', associatedTokenAccount.toString())
394
+ // console.log('Mint tx:', mintToResponse)
395
+ }
396
+ catch (e) {
397
+ console.log(e);
398
+ }
399
+ });
400
+ const removeMintAuthority = () => __awaiter(void 0, void 0, void 0, function* () {
401
+ const filekey = fs_1.default.readFileSync('./tCMraBSGHeMcQS76hNnBhnfbMzrtnnT3nbt3vAnSCE2.json');
402
+ const token = web3_js_1.Keypair.fromSecretKey(new Uint8Array(JSON.parse(filekey.toString())));
403
+ try {
404
+ const response = yield (0, spl_token_1.setAuthority)(connection, keypair, token.publicKey, wallet.publicKey, spl_token_1.AuthorityType.MetadataPointer, null, [], undefined, spl_token_1.TOKEN_2022_PROGRAM_ID);
405
+ console.log('Mint authority removed:', response);
406
+ }
407
+ catch (error) {
408
+ console.error('Error removing mint authority:', error);
409
+ }
410
+ });
411
+ const getMinteds = () => __awaiter(void 0, void 0, void 0, function* () {
412
+ const response = yield triadProtocol.program.account.collection.all();
413
+ console.log(response);
414
+ });
package/dist/stake.d.ts CHANGED
@@ -30,11 +30,7 @@ export default class Stake {
30
30
  * @param collections - NFT collections
31
31
  * @param tensor rank
32
32
  */
33
- getStakeByWallet(wallet: PublicKey, collections: number, ranks: {
34
- onchainId: string;
35
- name: string;
36
- rarityRankHrtt: number;
37
- }[]): Promise<StakeResponse[]>;
33
+ getStakeByWallet(wallet: PublicKey, collections: number): Promise<StakeResponse[]>;
38
34
  /**
39
35
  * Stake Token
40
36
  * @param name - Index
@@ -42,7 +38,7 @@ export default class Stake {
42
38
  * @param amount - Amount to stake
43
39
  *
44
40
  */
45
- stakeToken({ name, wallet, amount }: StakeTokenArgs, options?: RpcOptions): Promise<any>;
41
+ stakeToken({ name, wallet, amount }: StakeTokenArgs, options?: RpcOptions): Promise<string>;
46
42
  /**
47
43
  * Update Stake Vault
48
44
  * @param wallet - User wallet
@@ -50,7 +46,7 @@ export default class Stake {
50
46
  * @param isLocked - is locked stake vault (optional)
51
47
  *
52
48
  */
53
- updateStakeVault({ wallet, amount, isLocked }: UpdateStakeVaultArgs, options?: RpcOptions): Promise<any>;
49
+ updateStakeVault({ wallet, amount, isLocked }: UpdateStakeVaultArgs, options?: RpcOptions): Promise<string>;
54
50
  /**
55
51
  * Request Withdraw
56
52
  * @param wallet - User wallet
@@ -65,7 +61,7 @@ export default class Stake {
65
61
  * @param mint - NFT mint
66
62
  *
67
63
  */
68
- withdrawStake({ wallet, name, mint }: WithdrawArgs, options?: RpcOptions): Promise<any>;
64
+ withdrawStake({ wallet, name, mint }: WithdrawArgs, options?: RpcOptions): Promise<string>;
69
65
  /**
70
66
  * Claim All Stake Rewards
71
67
  * @param wallet - User wallet
@@ -84,19 +80,4 @@ export default class Stake {
84
80
  verifier: string;
85
81
  isToken?: boolean;
86
82
  }, options?: RpcOptions): Promise<string>;
87
- /**
88
- * Withdraw NFT
89
- * @param wallet - User wallet
90
- * @param name - Stake name
91
- * @param mint - NFT mint
92
- *
93
- */
94
- withdrawNft({ wallet, name, nftMint, tokenMint, rank, collections }: {
95
- wallet: PublicKey;
96
- name: string;
97
- nftMint: PublicKey;
98
- tokenMint: PublicKey;
99
- rank: number;
100
- collections: number;
101
- }, options?: RpcOptions): Promise<any>;
102
83
  }
package/dist/stake.js CHANGED
@@ -92,18 +92,17 @@ class Stake {
92
92
  * @param collections - NFT collections
93
93
  * @param tensor rank
94
94
  */
95
- getStakeByWallet(wallet, collections, ranks) {
95
+ getStakeByWallet(wallet, collections) {
96
96
  return __awaiter(this, void 0, void 0, function* () {
97
97
  const response = yield this.getUserStakes(wallet);
98
98
  const data = [];
99
99
  for (const stake of response) {
100
- const rank = (0, getRarityRank_1.default)(ranks, stake.mint, stake.name);
101
100
  let available = 0;
102
101
  try {
103
102
  available = yield this.getStakeRewards({
104
103
  wallet,
105
104
  nftName: stake.name,
106
- rank,
105
+ rank: 963,
107
106
  collections
108
107
  });
109
108
  }
@@ -254,27 +253,5 @@ class Stake {
254
253
  return (0, sendVersionedTransaction_1.default)(this.provider, ixs, options, (0, convertSecretKeyToKeypair_1.convertSecretKeyToKeypair)(verifier));
255
254
  });
256
255
  }
257
- /**
258
- * Withdraw NFT
259
- * @param wallet - User wallet
260
- * @param name - Stake name
261
- * @param mint - NFT mint
262
- *
263
- */
264
- withdrawNft({ wallet, name, nftMint, tokenMint, rank, collections }, options) {
265
- return __awaiter(this, void 0, void 0, function* () {
266
- const stakeVaultPDA = (0, stake_1.getStakeVaultPDA)(this.program.programId, this.stakeVaultName);
267
- const userPDA = (0, pda_1.getUserPDA)(this.program.programId, wallet);
268
- const stakePDA = (0, stake_1.getStakePDA)(this.program.programId, wallet, name);
269
- return (0, sendTransactionWithOptions_1.default)(this.program.methods.withdrawNft(rank, collections).accounts({
270
- signer: this.provider.wallet.publicKey,
271
- stake: stakePDA,
272
- stakeVault: stakeVaultPDA,
273
- tokenMint: tokenMint,
274
- nftMint: nftMint,
275
- user: userPDA
276
- }), options);
277
- });
278
- }
279
256
  }
280
257
  exports.default = Stake;
package/dist/trade.d.ts CHANGED
@@ -110,7 +110,7 @@ export default class Trade {
110
110
  * @param options - RPC options
111
111
  *
112
112
  */
113
- initializeMarket({ marketId, startTime, endTime, question }: InitializeMarketArgs, options?: RpcOptions): Promise<any>;
113
+ initializeMarket({ marketId, startTime, endTime, question }: InitializeMarketArgs, options?: RpcOptions): Promise<string>;
114
114
  /**
115
115
  * Open Order
116
116
  * @param marketId - The ID of the market
@@ -153,6 +153,22 @@ export default class Trade {
153
153
  none: {};
154
154
  };
155
155
  }, options?: RpcOptions): Promise<string>;
156
+ /**
157
+ * Resolve Market With Liquidity
158
+ * @param marketId - The ID of the market
159
+ * @param winningDirection - The winning direction of the market
160
+ * @param marketToAddLiquidity - The market to add liquidity
161
+ * @param amount - The amount of the order
162
+ *
163
+ * @param options - RPC options
164
+ *
165
+ */
166
+ resolveMarketWithLiquidity({ marketId, winningDirection, marketToAddLiquidity, amount }: {
167
+ marketId: number;
168
+ winningDirection: OrderDirection;
169
+ marketToAddLiquidity: OrderDirection;
170
+ amount: number;
171
+ }, options?: RpcOptions): Promise<string>;
156
172
  /**
157
173
  * Settle an order
158
174
  * @param marketId - The ID of the market
package/dist/trade.js CHANGED
@@ -203,6 +203,41 @@ class Trade {
203
203
  return (0, sendTransactionWithOptions_1.default)(method, options);
204
204
  });
205
205
  }
206
+ /**
207
+ * Resolve Market With Liquidity
208
+ * @param marketId - The ID of the market
209
+ * @param winningDirection - The winning direction of the market
210
+ * @param marketToAddLiquidity - The market to add liquidity
211
+ * @param amount - The amount of the order
212
+ *
213
+ * @param options - RPC options
214
+ *
215
+ */
216
+ resolveMarketWithLiquidity({ marketId, winningDirection, marketToAddLiquidity, amount }, options) {
217
+ return __awaiter(this, void 0, void 0, function* () {
218
+ const marketPDA = (0, trade_1.getMarketPDA)(this.program.programId, marketId);
219
+ const ixs = [];
220
+ ixs.push(yield this.program.methods
221
+ .resolveMarket(winningDirection)
222
+ .accounts({
223
+ signer: this.provider.publicKey,
224
+ market: marketPDA
225
+ })
226
+ .instruction());
227
+ ixs.push(yield this.program.methods
228
+ .addLiquidity({
229
+ amount: new bn_js_1.default(amount * Math.pow(10, constants_1.TRD_DECIMALS)),
230
+ direction: marketToAddLiquidity
231
+ })
232
+ .accounts({
233
+ signer: this.provider.publicKey,
234
+ market: marketPDA,
235
+ mint: this.mint
236
+ })
237
+ .instruction());
238
+ return (0, sendVersionedTransaction_1.default)(this.provider, ixs, options);
239
+ });
240
+ }
206
241
  /**
207
242
  * Settle an order
208
243
  * @param marketId - The ID of the market