@triadxyz/triad-protocol 1.6.6-beta → 1.6.7-beta-dev

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.
@@ -9,3 +9,4 @@ export declare const formatMarket: (account: any, address: PublicKey) => Market;
9
9
  export declare const formatOrder: (order: any) => Order;
10
10
  export declare const formatUserTrade: (account: any, publicKey: PublicKey) => UserTrade;
11
11
  export declare const calculateStakeRewards: (stake: Stake, multiplier: number) => number;
12
+ export declare const getTokenProgram: (mint: PublicKey) => PublicKey;
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.calculateStakeRewards = exports.formatUserTrade = exports.formatOrder = exports.formatMarket = exports.formatStake = exports.formatStakeVault = exports.decodeString = exports.encodeString = void 0;
3
+ exports.getTokenProgram = exports.calculateStakeRewards = exports.formatUserTrade = exports.formatOrder = exports.formatMarket = exports.formatStake = exports.formatStakeVault = exports.decodeString = exports.encodeString = void 0;
4
4
  const trade_1 = require("../types/trade");
5
5
  const constants_1 = require("./constants");
6
+ const spl_token_1 = require("@solana/spl-token");
7
+ const spl_token_2 = require("@solana/spl-token");
6
8
  const encodeString = (value, alloc = 32) => {
7
9
  const buffer = Buffer.alloc(alloc, 32);
8
10
  buffer.write(value);
@@ -133,3 +135,10 @@ const calculateStakeRewards = (stake, multiplier) => {
133
135
  return (rewards + stake.available) / Math.pow(10, constants_1.TRD_DECIMALS);
134
136
  };
135
137
  exports.calculateStakeRewards = calculateStakeRewards;
138
+ const getTokenProgram = (mint) => {
139
+ if (mint.toBase58() === constants_1.TRD_MINT.toBase58()) {
140
+ return spl_token_2.TOKEN_2022_PROGRAM_ID;
141
+ }
142
+ return spl_token_1.TOKEN_PROGRAM_ID;
143
+ };
144
+ exports.getTokenProgram = getTokenProgram;
package/dist/wheel.d.ts CHANGED
@@ -51,7 +51,7 @@ export default class Wheel {
51
51
  * Get Spin Wheel
52
52
  *
53
53
  */
54
- getSpinWheel(amount: number): Promise<any[] | 999>;
54
+ getSpinWheel(amount: number): Promise<number[]>;
55
55
  /**
56
56
  * Swap Wheel Token
57
57
  * @param amount - Amount of tokens to buy
package/dist/wheel.js CHANGED
@@ -100,8 +100,8 @@ class Wheel {
100
100
  mint: constants_1.WHEEL_MINT
101
101
  })
102
102
  .instruction());
103
- return (0, sendVersionedTransaction_1.default)(this.provider, ixs, options, undefined, [], args.verifier);
104
103
  }
104
+ return (0, sendVersionedTransaction_1.default)(this.provider, ixs, options, undefined, [], args.verifier);
105
105
  });
106
106
  }
107
107
  /**
@@ -118,9 +118,9 @@ class Wheel {
118
118
  randomNumber <= p.rangeMax.toNumber() &&
119
119
  p.status.claimed);
120
120
  if (!prize) {
121
- return 999;
121
+ prizes.push(999);
122
122
  }
123
- prizes.push(prize.prize);
123
+ prizes.push(prize.prize.toNumber());
124
124
  }
125
125
  return prizes;
126
126
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "1.6.6-beta",
3
+ "version": "1.6.7-beta-dev",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -1 +0,0 @@
1
- export {};
@@ -1,528 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const fs_1 = __importDefault(require("fs"));
16
- const __1 = __importDefault(require(".."));
17
- const anchor_1 = require("@coral-xyz/anchor");
18
- const web3_js_1 = require("@solana/web3.js");
19
- const trade_1 = require("../types/trade");
20
- const spl_token_1 = require("@solana/spl-token");
21
- const constants_1 = require("../utils/constants");
22
- const simulate_market_1 = require("./simulate-market");
23
- const init_market_1 = require("./init-market");
24
- const sdk_1 = require("@shadow-drive/sdk");
25
- const pda_1 = require("../utils/pda");
26
- const file = fs_1.default.readFileSync('/Users/dannpl/.config/solana/id.json');
27
- const rpc_file = fs_1.default.readFileSync('/Users/dannpl/.config/solana/rpc.txt');
28
- const keypair = web3_js_1.Keypair.fromSecretKey(new Uint8Array(JSON.parse(file.toString())));
29
- const connection = new web3_js_1.Connection(rpc_file.toString());
30
- const wallet = new anchor_1.Wallet(keypair);
31
- const triadProtocol = new __1.default(connection, wallet);
32
- const marketId = 1001;
33
- const simulateMarket = new simulate_market_1.SimulateMarket(triadProtocol);
34
- const initMarket = new init_market_1.InitMarket(triadProtocol);
35
- const updateStakeVault = () => __awaiter(void 0, void 0, void 0, function* () {
36
- const response = yield triadProtocol.stake.updateStakeVault({
37
- amount: new anchor_1.BN(1000 * Math.pow(10, 6)),
38
- isLocked: false
39
- });
40
- console.log(response);
41
- });
42
- const getStakeVault = () => __awaiter(void 0, void 0, void 0, function* () {
43
- const response = yield triadProtocol.stake.getStakeVaults();
44
- console.log(response);
45
- });
46
- const getStakeByWallet = () => __awaiter(void 0, void 0, void 0, function* () {
47
- const response = yield triadProtocol.stake.getStakeByWallet(new web3_js_1.PublicKey('4k8qFA1i7fv6YGWJnoLZPSHj9nhLn3bokAdXWnuAteBV'), 1);
48
- let sum = 0;
49
- for (const stake of response) {
50
- sum += stake.amount / Math.pow(10, 6);
51
- }
52
- console.log(sum);
53
- });
54
- const getAllStakes = () => __awaiter(void 0, void 0, void 0, function* () {
55
- const stakes = yield triadProtocol.stake.getStakes();
56
- console.log(stakes.length);
57
- });
58
- const getStakes = () => __awaiter(void 0, void 0, void 0, function* () {
59
- const stakes = yield triadProtocol.stake.getStakes();
60
- fs_1.default.writeFileSync('stakes.json', JSON.stringify(stakes, null, 2));
61
- const stakesJson = JSON.parse(fs_1.default.readFileSync('stakes.json', 'utf8'));
62
- let amountLocked = 0;
63
- let amountUnlocked = 0;
64
- let uniqueStakersLocked = new Set();
65
- let uniqueStakersUnlocked = new Set();
66
- let usersUnlocked = [];
67
- let usersLocked = [];
68
- for (const stake of stakesJson) {
69
- if (stake.withdrawTs === 0) {
70
- amountLocked += stake.amount / Math.pow(10, 6);
71
- uniqueStakersLocked.add(stake.authority);
72
- if (!usersLocked.find((user) => user.address === stake.authority)) {
73
- usersLocked.push({
74
- address: stake.authority,
75
- amount: stake.amount / Math.pow(10, 6)
76
- });
77
- }
78
- else {
79
- const user = usersLocked === null || usersLocked === void 0 ? void 0 : usersLocked.find((user) => user.address === stake.authority);
80
- if (user) {
81
- user.amount += stake.amount / Math.pow(10, 6);
82
- }
83
- }
84
- }
85
- else {
86
- amountUnlocked += stake.amount / Math.pow(10, 6);
87
- uniqueStakersUnlocked.add(stake.authority);
88
- if (!usersUnlocked.find((user) => user.address === stake.authority)) {
89
- usersUnlocked.push({
90
- address: stake.authority,
91
- amount: stake.amount / Math.pow(10, 6)
92
- });
93
- }
94
- else {
95
- const user = usersUnlocked.find((user) => user.address === stake.authority);
96
- if (user) {
97
- user.amount += stake.amount / Math.pow(10, 6);
98
- }
99
- }
100
- }
101
- }
102
- const orders = usersLocked.sort((a, b) => b.amount - a.amount);
103
- const ordersUnlocked = usersUnlocked.sort((a, b) => b.amount - a.amount);
104
- console.log('Amount locked:', amountLocked);
105
- console.log('Amount unlocked:', amountUnlocked);
106
- console.log('Unique stakers:', uniqueStakersLocked.size);
107
- console.log('Unique stakers unlocked:', uniqueStakersUnlocked.size);
108
- console.log(JSON.stringify(orders, null, 2));
109
- console.log('--------------------------------');
110
- console.log(JSON.stringify(ordersUnlocked, null, 2));
111
- });
112
- const getAllMarkets = () => __awaiter(void 0, void 0, void 0, function* () {
113
- let markets = yield triadProtocol.trade.getAllMarkets();
114
- markets = markets.sort((a, b) => Number(a.marketId) - Number(b.marketId));
115
- let totalFlopToPay = 0;
116
- let totalHypeToPay = 0;
117
- let totalLiquidity = 0;
118
- let profit = 0;
119
- const items = {};
120
- for (const market of markets) {
121
- if (Number(market.marketId) < 39) {
122
- continue;
123
- }
124
- let liquidity = (Number(market.hypeLiquidity) + Number(market.flopLiquidity)) / Math.pow(10, 6);
125
- // liquidity -= Number(market.marketLiquidityAtStart) / 10 ** 6
126
- console.log('Market ID:', market.question);
127
- console.log('Liquidity:', liquidity);
128
- console.log('Hype Shares:', Number(market.hypeShares) / Math.pow(10, 6));
129
- console.log('Flop Shares:', Number(market.flopShares) / Math.pow(10, 6));
130
- let innerProfit = 0;
131
- if (market.winningDirection === trade_1.WinningDirection.HYPE ||
132
- Number(market.hypePrice) > Number(market.flopPrice)) {
133
- innerProfit += liquidity - Number(market.hypeShares) / Math.pow(10, 6);
134
- console.log('Profit:', innerProfit);
135
- }
136
- if (market.winningDirection === trade_1.WinningDirection.FLOP ||
137
- Number(market.hypePrice) < Number(market.flopPrice)) {
138
- innerProfit += liquidity - Number(market.flopShares) / Math.pow(10, 6);
139
- console.log('Profit:', profit);
140
- }
141
- totalFlopToPay += Number(market.flopShares) / Math.pow(10, 6);
142
- totalHypeToPay += Number(market.hypeShares) / Math.pow(10, 6);
143
- totalLiquidity += liquidity;
144
- profit += innerProfit;
145
- items[market.marketId] = {
146
- question: market.question,
147
- liquidity: liquidity,
148
- hypeShares: Number(market.hypeShares) / Math.pow(10, 6),
149
- flopShares: Number(market.flopShares) / Math.pow(10, 6),
150
- profit: innerProfit
151
- };
152
- console.log('--------------------------------');
153
- }
154
- console.log('Total Liquidity:', totalLiquidity);
155
- console.log('Total Hype to Pay:', totalHypeToPay);
156
- console.log('Total Flop to Pay:', totalFlopToPay);
157
- console.log('Triad Profit:', profit);
158
- console.table(items);
159
- });
160
- const getMarket = () => __awaiter(void 0, void 0, void 0, function* () {
161
- const market = yield triadProtocol.trade.getMarketById(marketId);
162
- console.log(market);
163
- });
164
- const getOrders = (walletAddress) => __awaiter(void 0, void 0, void 0, function* () {
165
- const response = (yield triadProtocol.program.account.userTrade.all()).find((userTrade) => userTrade.account.authority.toBase58() === walletAddress.toBase58());
166
- if (!response) {
167
- return [];
168
- }
169
- let orders = [];
170
- for (const order of response.account.orders) {
171
- console.log(order);
172
- if (!order.status.open) {
173
- continue;
174
- }
175
- orders.push({
176
- marketId: order.marketId.toNumber(),
177
- orderId: order.orderId.toNumber(),
178
- totalShares: order.totalShares.toString(),
179
- amount: order.totalAmount.toString(),
180
- direction: order.direction,
181
- questionId: order.questionId,
182
- price: order.price.toString(),
183
- status: order.status
184
- });
185
- }
186
- console.log(orders);
187
- return orders;
188
- });
189
- const getAllTraders = () => __awaiter(void 0, void 0, void 0, function* () {
190
- const response = yield triadProtocol.program.account.userTrade.all();
191
- console.log(response);
192
- });
193
- const getLiquidityToRecovery = () => __awaiter(void 0, void 0, void 0, function* () {
194
- const response = yield triadProtocol.program.account.userTrade.all();
195
- const allMarkets = yield triadProtocol.trade.getAllMarkets();
196
- const liquidityToRecovery = {};
197
- for (const market of allMarkets) {
198
- let currentMarket = liquidityToRecovery[market.marketId];
199
- if (market.marketId === '58') {
200
- // market.winningDirection = WinningDirection.FLOP
201
- }
202
- if (market.winningDirection.toLowerCase() === 'none') {
203
- continue;
204
- }
205
- if (!currentMarket) {
206
- currentMarket = {
207
- address: market.address,
208
- name: market.question,
209
- liquidityAvailable: 0,
210
- openOrders: 0,
211
- amountInPDA: 0,
212
- sharesToPay: 0,
213
- direction: market.winningDirection.toLowerCase()
214
- };
215
- liquidityToRecovery[market.marketId] = currentMarket;
216
- }
217
- const marketLiquidityAtStart = parseFloat(market.marketLiquidityAtStart.toString()) / Math.pow(10, 6);
218
- if (currentMarket.direction === 'flop') {
219
- currentMarket.liquidityAvailable =
220
- parseFloat(market.hypeLiquidity.toString()) / Math.pow(10, 6);
221
- currentMarket.liquidityAvailable =
222
- currentMarket.liquidityAvailable - marketLiquidityAtStart / 2;
223
- }
224
- if (currentMarket.direction === 'hype') {
225
- currentMarket.liquidityAvailable =
226
- parseFloat(market.flopLiquidity.toString()) / Math.pow(10, 6);
227
- currentMarket.liquidityAvailable =
228
- currentMarket.liquidityAvailable - marketLiquidityAtStart / 2;
229
- }
230
- const token = yield (0, spl_token_1.getAssociatedTokenAddress)(constants_1.TRD_MINT, new web3_js_1.PublicKey(market.address), true, spl_token_1.TOKEN_2022_PROGRAM_ID);
231
- const account = yield (0, spl_token_1.getAccount)(connection, token, 'finalized', spl_token_1.TOKEN_2022_PROGRAM_ID);
232
- currentMarket.amountInPDA = Number(account.amount) / Math.pow(10, 6);
233
- }
234
- for (const userTrade of response) {
235
- for (const order of userTrade.account.orders) {
236
- const market = liquidityToRecovery[order.marketId.toNumber()];
237
- if (!market) {
238
- continue;
239
- }
240
- if (order.status.open &&
241
- Object.keys(order.direction)[0] === market.direction) {
242
- market.openOrders += 1;
243
- const payout = parseFloat(order.totalShares.toString());
244
- market.sharesToPay += payout / Math.pow(10, 6);
245
- }
246
- }
247
- }
248
- console.log(JSON.stringify(liquidityToRecovery, null, 2));
249
- let amountAllowToWithdraw = 0;
250
- let amountToPay = 0;
251
- let amountInPDA = 0;
252
- for (const market of Object.values(liquidityToRecovery)) {
253
- amountAllowToWithdraw += market.amountInPDA - market.sharesToPay;
254
- amountToPay += market.sharesToPay;
255
- amountInPDA += market.amountInPDA;
256
- }
257
- console.log('Amount allow to withdraw:', amountAllowToWithdraw);
258
- console.log('Amount to pay:', amountToPay);
259
- console.log('Amount in PDA:', amountInPDA);
260
- });
261
- const closeOrders = () => __awaiter(void 0, void 0, void 0, function* () {
262
- for (const order of yield getOrders(wallet.publicKey)) {
263
- try {
264
- const response = yield triadProtocol.trade.closeOrder({
265
- marketId: order.marketId,
266
- orderId: order.orderId,
267
- userNonce: 0
268
- });
269
- console.log(response);
270
- }
271
- catch (e) {
272
- console.log(e);
273
- }
274
- }
275
- });
276
- const resolveMarket = () => __awaiter(void 0, void 0, void 0, function* () {
277
- const marketsToResolve = [
278
- { marketId: 123, winningDirection: { flop: {} } },
279
- { marketId: 125, winningDirection: { flop: {} } },
280
- { marketId: 124, winningDirection: { flop: {} } }
281
- ];
282
- for (const market of marketsToResolve) {
283
- const response = yield triadProtocol.trade.resolveMarket({
284
- marketId: market.marketId,
285
- winningDirection: market.winningDirection
286
- });
287
- console.log(response);
288
- }
289
- });
290
- const collectRemainingLiquidityFromAllMarkets = () => __awaiter(void 0, void 0, void 0, function* () {
291
- console.log('Collecting fees');
292
- const allMarkets = yield triadProtocol.trade.getAllMarkets();
293
- for (const market of allMarkets) {
294
- console.log(`Collecting fees for market ${market.marketId}`);
295
- console.log(market);
296
- if (market.openedOrders !== '0') {
297
- continue;
298
- }
299
- try {
300
- const response = yield triadProtocol.trade.collectRemainingLiquidity(Number(market.marketId));
301
- console.log(response);
302
- }
303
- catch (_a) { }
304
- }
305
- });
306
- const burnLP = () => __awaiter(void 0, void 0, void 0, function* () {
307
- const SOL_LP = new web3_js_1.PublicKey('8yXmXEQh8M1vyjKKhN6L12EZiXCY3cJS4xL45wwQExep');
308
- const getTokenAccount = yield (0, spl_token_1.getAssociatedTokenAddress)(SOL_LP, wallet.publicKey, true);
309
- console.log(getTokenAccount);
310
- const amount = 191.360098123 * Math.pow(10, 9);
311
- const response = yield (0, spl_token_1.burn)(connection, keypair, getTokenAccount, SOL_LP, wallet.publicKey, amount);
312
- console.log(response);
313
- });
314
- const mintToken = () => __awaiter(void 0, void 0, void 0, function* () {
315
- const filekey = fs_1.default.readFileSync('./tCMraBSGHeMcQS76hNnBhnfbMzrtnnT3nbt3vAnSCE2.json');
316
- const token = web3_js_1.Keypair.fromSecretKey(new Uint8Array(JSON.parse(filekey.toString())));
317
- try {
318
- const decimals = 6; // Common decimal places for tokens
319
- const amount = 1000000 * Math.pow(10, decimals); // 1,000,000 tokens with decimals
320
- // Calculate space needed for mint account including metadata pointer
321
- // const mintLen = getMintLen([ExtensionType.MetadataPointer])
322
- // const mintTransaction = new Transaction().add(
323
- // // Create mint account
324
- // SystemProgram.createAccount({
325
- // fromPubkey: wallet.publicKey,
326
- // newAccountPubkey: token.publicKey,
327
- // space: mintLen,
328
- // lamports: 6786240,
329
- // programId: TOKEN_2022_PROGRAM_ID
330
- // }),
331
- // createInitializeMetadataPointerInstruction(
332
- // token.publicKey,
333
- // wallet.publicKey,
334
- // token.publicKey,
335
- // TOKEN_2022_PROGRAM_ID
336
- // ),
337
- // createInitializeMintInstruction(
338
- // token.publicKey,
339
- // decimals,
340
- // wallet.publicKey,
341
- // null,
342
- // TOKEN_2022_PROGRAM_ID
343
- // ),
344
- // createInitializeInstruction({
345
- // programId: TOKEN_2022_PROGRAM_ID,
346
- // metadata: token.publicKey,
347
- // updateAuthority: wallet.publicKey,
348
- // mint: token.publicKey,
349
- // mintAuthority: wallet.publicKey,
350
- // name: 'Triad Christmas',
351
- // symbol: 'tCMAS',
352
- // uri: 'https://shdw-drive.genesysgo.net/DRRe9dZkP199W6GLrySn2xj2ayfr8gin8iaBt1YVMN9M/tCMAS.json'
353
- // })
354
- // )
355
- // const transactionSignature = await sendAndConfirmTransaction(
356
- // connection,
357
- // mintTransaction,
358
- // [keypair, token], // Signers,
359
- // { skipPreflight: false }
360
- // )
361
- // console.log(
362
- // '\nCreate Mint Account:',
363
- // `https://solana.fm/tx/${transactionSignature}?cluster=devnet-solana`
364
- // )
365
- // const associatedTokenAccount = await getOrCreateAssociatedTokenAccount(
366
- // connection,
367
- // keypair,
368
- // token.publicKey,
369
- // wallet.publicKey,
370
- // true,
371
- // undefined,
372
- // undefined,
373
- // TOKEN_2022_PROGRAM_ID
374
- // )
375
- // const mintToResponse = await mintTo(
376
- // connection,
377
- // keypair,
378
- // token.publicKey,
379
- // associatedTokenAccount.address,
380
- // wallet.publicKey,
381
- // amount,
382
- // [keypair, token],
383
- // undefined,
384
- // TOKEN_2022_PROGRAM_ID
385
- // )
386
- // console.log('Token created:', token.publicKey.toString())
387
- // console.log('Associated Token Account:', associatedTokenAccount.toString())
388
- // console.log('Mint tx:', mintToResponse)
389
- }
390
- catch (e) {
391
- console.log(e);
392
- }
393
- });
394
- const updateTokenMetadata = () => __awaiter(void 0, void 0, void 0, function* () {
395
- const mintTransaction = new web3_js_1.Transaction().add((0, spl_token_1.createUpdateFieldInstruction)({
396
- programId: spl_token_1.TOKEN_2022_PROGRAM_ID,
397
- metadata: new web3_js_1.PublicKey('tCMraBSGHeMcQS76hNnBhnfbMzrtnnT3nbt3vAnSCE2'),
398
- updateAuthority: wallet.publicKey,
399
- field: 'uri',
400
- value: 'https://shdw-drive.genesysgo.net/DRRe9dZkP199W6GLrySn2xj2ayfr8gin8iaBt1YVMN9M/tEVENT.json'
401
- }));
402
- const transactionSignature = yield (0, web3_js_1.sendAndConfirmTransaction)(connection, mintTransaction, [keypair] // Signers,
403
- );
404
- console.log(transactionSignature);
405
- });
406
- const withdrawPoseidon = () => __awaiter(void 0, void 0, void 0, function* () {
407
- const response = yield triadProtocol.withdrawPoseidon({
408
- poseidonAsset: new web3_js_1.PublicKey('DMoyQ6pAj9bGu3WoMcVeYv4rgrU96Xjzyzudfs4fkJw3'),
409
- nft: 430
410
- });
411
- console.log(response);
412
- });
413
- const openOrderTriad = () => __awaiter(void 0, void 0, void 0, function* () {
414
- const response3 = yield triadProtocol.trade.openOrder({
415
- marketId: marketId,
416
- amount: 1000,
417
- direction: {
418
- hype: {}
419
- },
420
- token: constants_1.TRD_MINT.toBase58()
421
- });
422
- console.log(response3);
423
- yield getMarket();
424
- });
425
- const closeOrderTriad = () => __awaiter(void 0, void 0, void 0, function* () {
426
- const response = yield triadProtocol.trade.closeOrder({
427
- marketId: marketId,
428
- orderId: 1,
429
- userNonce: 8
430
- });
431
- console.log(response);
432
- });
433
- const collectRoyalties = () => __awaiter(void 0, void 0, void 0, function* () {
434
- const response = yield triadProtocol.collectRoyalty(constants_1.POSEIDON_COLLECTION_SYMBOL, {
435
- skipPreflight: false
436
- });
437
- console.log(response);
438
- });
439
- const collectRemainingLiquidity = () => __awaiter(void 0, void 0, void 0, function* () {
440
- const markets = [105];
441
- for (const market of markets) {
442
- const response = yield triadProtocol.trade.collectRemainingLiquidity(market);
443
- console.log(response);
444
- }
445
- });
446
- const allowMarketToPayout = () => __awaiter(void 0, void 0, void 0, function* () {
447
- const markets = [123, 124, 125];
448
- for (const market of markets) {
449
- try {
450
- const response = yield triadProtocol.trade.allowMarketToPayout(Number(market));
451
- console.log(response);
452
- }
453
- catch (error) {
454
- console.log(error);
455
- }
456
- }
457
- });
458
- const getUserOrders = () => __awaiter(void 0, void 0, void 0, function* () {
459
- const response = yield triadProtocol.trade.getUserOrders(wallet.publicKey);
460
- const filteredResponse = response.filter((order) => order.marketId === marketId.toString());
461
- console.log(response);
462
- });
463
- const updateMarket = () => __awaiter(void 0, void 0, void 0, function* () {
464
- const response = yield triadProtocol.trade.updateMarket(128, 1751327940);
465
- console.log(response);
466
- });
467
- const getStorage = () => __awaiter(void 0, void 0, void 0, function* () {
468
- const drive = yield new sdk_1.ShdwDrive(triadProtocol.provider.connection, triadProtocol.provider.wallet).init();
469
- console.log(yield drive.getStorageAccount(new web3_js_1.PublicKey('DRRe9dZkP199W6GLrySn2xj2ayfr8gin8iaBt1YVMN9M')));
470
- const jsonFile = {
471
- name: `tCMAS.json`,
472
- file: fs_1.default.readFileSync(`./src/tCMAS.json`)
473
- };
474
- const file = yield drive.editFile(new web3_js_1.PublicKey('DRRe9dZkP199W6GLrySn2xj2ayfr8gin8iaBt1YVMN9M'), jsonFile);
475
- console.log(file);
476
- return file;
477
- });
478
- const deployImage = (image) => __awaiter(void 0, void 0, void 0, function* () {
479
- const TRIAD_STORAGE_ACCOUNT = new web3_js_1.PublicKey('DRRe9dZkP199W6GLrySn2xj2ayfr8gin8iaBt1YVMN9M');
480
- const drive = yield new sdk_1.ShdwDrive(triadProtocol.provider.connection, triadProtocol.provider.wallet).init();
481
- const jsonFile = {
482
- name: `${image}`,
483
- file: fs_1.default.readFileSync(`./src/${image}`)
484
- };
485
- const file = yield drive.uploadFile(TRIAD_STORAGE_ACCOUNT, jsonFile);
486
- console.log(file);
487
- return file;
488
- });
489
- // 1 - TRD 10k - 10,000
490
- // 2 - TRD 50 - 10,000
491
- // 3 - TRD 5 - 50,000
492
- // 4 - Honeyland NFT - 30 NFT
493
- // 5 - Poseidon NFT - 20 NFT
494
- // 6 - SMB 3 - 2 NFT
495
- // 7 - 500 tridents
496
- // 8 - 2k tridents
497
- // 9 - 50 HXD - 10,000
498
- // 10 - 0.01 ORE - 10 ORE
499
- // 11 - PYTH 20 - 5,000
500
- // 12 - 10 STREAM - 15K STREAM
501
- const addWheelPrize = () => __awaiter(void 0, void 0, void 0, function* () {
502
- const response = yield triadProtocol.wheel.addWheelPrize({
503
- prize: 11,
504
- amount: 20,
505
- rangeMin: 922970,
506
- rangeMax: 923970,
507
- availableQuantity: 30
508
- });
509
- console.log(response);
510
- });
511
- const getWheel = () => __awaiter(void 0, void 0, void 0, function* () {
512
- const [response] = yield triadProtocol.program.account.wheel.all();
513
- const prizes = response.account.prizes
514
- .filter((prize) => prize.status.claimed)
515
- .map((prize) => ({
516
- prize: prize.prize.toString(),
517
- amount: prize.amount.toString(),
518
- rangeMin: prize.rangeMin.toString(),
519
- rangeMax: prize.rangeMax.toString(),
520
- availableQuantity: prize.availableQuantity.toString()
521
- }));
522
- console.table(prizes);
523
- });
524
- getWheel();
525
- const spinWheel = () => __awaiter(void 0, void 0, void 0, function* () {
526
- const spin = (0, pda_1.getWheelPDA)(triadProtocol.program.programId, constants_1.VALENT_SPIN_NAME);
527
- console.log(spin);
528
- });
@@ -1,8 +0,0 @@
1
- import TriadProtocol from '..';
2
- export declare class InitMarket {
3
- private triadProtocol;
4
- markets: Partial<any>[];
5
- constructor(triadProtocol: TriadProtocol);
6
- initializeMarkets: () => Promise<void>;
7
- deployImage: (image: string) => Promise<import("@shadow-drive/sdk").ShadowUploadResponse>;
8
- }
@@ -1,63 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.InitMarket = void 0;
16
- const fs_1 = __importDefault(require("fs"));
17
- const web3_js_1 = require("@solana/web3.js");
18
- const sdk_1 = require("@shadow-drive/sdk");
19
- class InitMarket {
20
- constructor(triadProtocol) {
21
- this.triadProtocol = triadProtocol;
22
- this.markets = [
23
- {
24
- marketId: 131,
25
- question: 'Will $HXD be above $0.015 on february 17 at 11PM UTC?',
26
- startTime: 1239663940,
27
- endTime: 1739833140,
28
- image: 'hxd.png'
29
- }
30
- ];
31
- this.initializeMarkets = () => __awaiter(this, void 0, void 0, function* () {
32
- for (const market of this.markets) {
33
- try {
34
- const response = yield this.triadProtocol.trade.initializeMarket({
35
- marketId: market.marketId,
36
- question: market.question,
37
- startTime: market.startTime,
38
- endTime: market.endTime
39
- });
40
- if (market.image) {
41
- yield this.deployImage(market.image);
42
- }
43
- console.log(`Initialized market ${market.question}:`, response);
44
- }
45
- catch (error) {
46
- console.error(`Error initializing market ${market.question}:`, error);
47
- }
48
- }
49
- });
50
- this.deployImage = (image) => __awaiter(this, void 0, void 0, function* () {
51
- const TRIAD_STORAGE_ACCOUNT = new web3_js_1.PublicKey('8Tp66VQmgHXQfd8ui2VZHPLZfkKu8mMwywmRsnVfTRBm');
52
- const drive = yield new sdk_1.ShdwDrive(this.triadProtocol.provider.connection, this.triadProtocol.provider.wallet).init();
53
- const jsonFile = {
54
- name: `${image}`,
55
- file: fs_1.default.readFileSync(`./src/${image}`)
56
- };
57
- const file = yield drive.uploadFile(TRIAD_STORAGE_ACCOUNT, jsonFile);
58
- console.log(file);
59
- return file;
60
- });
61
- }
62
- }
63
- exports.InitMarket = InitMarket;