@triadxyz/triad-protocol 1.1.9-beta → 1.2.1-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.
@@ -17,28 +17,94 @@ const _1 = __importDefault(require("./"));
17
17
  const anchor_1 = require("@coral-xyz/anchor");
18
18
  const axios_1 = __importDefault(require("axios"));
19
19
  const web3_js_1 = require("@solana/web3.js");
20
+ const spl_token_1 = require("@solana/spl-token");
20
21
  const file = fs_1.default.readFileSync('/Users/dannpl/.config/solana/id.json');
21
22
  const rpc_file = fs_1.default.readFileSync('/Users/dannpl/.config/solana/rpc.txt');
22
23
  const keypair = web3_js_1.Keypair.fromSecretKey(new Uint8Array(JSON.parse(file.toString())));
23
- const connection = new web3_js_1.Connection(rpc_file.toString(), 'confirmed');
24
+ const connection = new web3_js_1.Connection('https://mainnet.helius-rpc.com/?api-key=428d811e-ba57-4def-8876-de95d53b7c9d');
24
25
  const wallet = new anchor_1.Wallet(keypair);
25
26
  const triadProtocol = new _1.default(connection, wallet);
26
- const markets = [{ name: 'Triad', marketId: 0 }];
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
+ ];
27
95
  const ordersHypeAndFloopBot = [
28
96
  {
29
- marketId: 0,
30
- amount: 0.001,
97
+ marketId: 7,
98
+ amount: 5000,
31
99
  direction: {
32
100
  flop: {}
33
- },
34
- orderType: {
35
- market: {}
36
101
  }
37
102
  }
38
103
  ];
39
104
  const updateStakeVault = () => __awaiter(void 0, void 0, void 0, function* () {
40
105
  const response = yield triadProtocol.stake.updateStakeVault({
41
- wallet: wallet.publicKey
106
+ wallet: wallet.publicKey,
107
+ amount: new anchor_1.BN(5000 * Math.pow(10, 6))
42
108
  });
43
109
  console.log(response);
44
110
  });
@@ -46,16 +112,8 @@ const getStakeVault = () => __awaiter(void 0, void 0, void 0, function* () {
46
112
  const response = yield triadProtocol.stake.getStakeVaults();
47
113
  console.log(response);
48
114
  });
49
- const updateStakeVaultStatus = () => __awaiter(void 0, void 0, void 0, function* () {
50
- const response = yield triadProtocol.stake.updateStakeVault({
51
- wallet: wallet.publicKey,
52
- amount: new anchor_1.BN(0),
53
- status: false
54
- });
55
- console.log(response);
56
- });
57
115
  const updateBoost = () => __awaiter(void 0, void 0, void 0, function* () {
58
- const response = (yield axios_1.default.get('https://api.triadfi.co/boost'))
116
+ const response = (yield axios_1.default.get('http://localhost:8080/boost'))
59
117
  .data;
60
118
  const stakes = yield triadProtocol.stake.getStakes();
61
119
  const update = [];
@@ -78,8 +136,9 @@ const getAllMarkets = () => __awaiter(void 0, void 0, void 0, function* () {
78
136
  const markets = yield triadProtocol.trade.getAllMarkets();
79
137
  console.log(markets);
80
138
  });
139
+ getAllMarkets();
81
140
  const getMarket = () => __awaiter(void 0, void 0, void 0, function* () {
82
- const market = yield triadProtocol.trade.getMarketById(0);
141
+ const market = yield triadProtocol.trade.getMarketById(7);
83
142
  console.log(market);
84
143
  });
85
144
  const initializeAllMarkets = () => __awaiter(void 0, void 0, void 0, function* () {
@@ -95,69 +154,96 @@ const initializeAllMarkets = () => __awaiter(void 0, void 0, void 0, function* (
95
154
  }
96
155
  }
97
156
  });
98
- const getOrders = () => __awaiter(void 0, void 0, void 0, function* () {
99
- const response = (yield triadProtocol.program.account.userTrade.all()).find((userTrade) => userTrade.account.authority.toBase58() === wallet.publicKey.toBase58());
100
- return response.account.orders.map((order) => order.orderId.toNumber());
157
+ const getOrders = (walletAddress) => __awaiter(void 0, void 0, void 0, function* () {
158
+ const response = (yield triadProtocol.program.account.userTrade.all()).find((userTrade) => userTrade.account.authority.toBase58() === walletAddress.toBase58());
159
+ let orders = [];
160
+ for (const order of response.account.orders) {
161
+ if (!order.status.open) {
162
+ continue;
163
+ }
164
+ orders.push({
165
+ marketId: order.marketId,
166
+ orderId: order.orderId.toNumber(),
167
+ totalShares: order.totalShares.toString(),
168
+ amount: order.totalAmount.toString(),
169
+ direction: order.direction,
170
+ questionId: order.questionId,
171
+ price: order.price.toString(),
172
+ status: order.status
173
+ });
174
+ }
175
+ console.log(orders);
176
+ return orders;
101
177
  });
178
+ // getOrders(new PublicKey('HjJQdfTHgC3EBX3471w4st8BXbBmtbaMyCAXNgcUb7dq'))
102
179
  const openOrder = () => __awaiter(void 0, void 0, void 0, function* () {
180
+ yield getMarket();
103
181
  for (const order of ordersHypeAndFloopBot) {
104
182
  const response = yield triadProtocol.trade.openOrder({
105
- marketId: 0,
183
+ marketId: order.marketId,
106
184
  amount: order.amount,
107
185
  direction: order.direction,
108
- token: 'So11111111111111111111111111111111111111112',
186
+ token: mint.toBase58(),
109
187
  comment: `hype/flop bot ${order.amount} - ${order.direction}`
110
- }, {
111
- skipPreflight: true
112
188
  });
113
189
  console.log(response);
114
190
  }
191
+ yield new Promise((resolve) => setTimeout(resolve, 50000));
192
+ getMarket();
193
+ });
194
+ const closeOrder = (orderId) => __awaiter(void 0, void 0, void 0, function* () {
195
+ const response = yield triadProtocol.trade.closeOrder({
196
+ marketId: 7,
197
+ orderId: orderId
198
+ });
199
+ console.log(response);
115
200
  });
116
- openOrder();
117
- const closeOrder = () => __awaiter(void 0, void 0, void 0, function* () {
118
- for (const order of yield getOrders()) {
201
+ const closeOrders = () => __awaiter(void 0, void 0, void 0, function* () {
202
+ for (const order of yield getOrders(wallet.publicKey)) {
119
203
  try {
120
204
  const response = yield triadProtocol.trade.closeOrder({
121
- marketId: 1,
122
- orderId: order
205
+ marketId: order.marketId,
206
+ orderId: order.orderId
123
207
  });
124
208
  console.log(response);
125
209
  }
126
210
  catch (e) {
127
- console.log('Error closing order');
211
+ console.log(e);
128
212
  }
129
213
  }
130
214
  });
131
- const runBot = () => __awaiter(void 0, void 0, void 0, function* () {
132
- while (true) {
133
- const hasOpenOrders = (yield getOrders()).find((order) => order !== 0);
134
- if (hasOpenOrders) {
135
- yield closeOrder();
136
- }
137
- yield openOrder();
138
- yield new Promise((resolve) => setTimeout(resolve, 40000));
139
- }
215
+ const mintTokens = () => __awaiter(void 0, void 0, void 0, function* () {
216
+ // const mint = await createMint(
217
+ // connection,
218
+ // keypair,
219
+ // keypair.publicKey,
220
+ // null,
221
+ // 6,
222
+ // undefined,
223
+ // undefined,
224
+ // TOKEN_2022_PROGRAM_ID
225
+ // )
226
+ // console.log(mint)
227
+ const ataAddress = yield (0, spl_token_1.getAssociatedTokenAddress)(keypair.publicKey, mint);
228
+ console.log(ataAddress);
229
+ const ata = yield (0, spl_token_1.createAssociatedTokenAccount)(connection, keypair, mint, keypair.publicKey, undefined, spl_token_1.TOKEN_2022_PROGRAM_ID);
230
+ 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
+ console.log(mintTx);
140
232
  });
141
- const initializeQuestion = () => __awaiter(void 0, void 0, void 0, function* () {
142
- const currentTime = Math.floor(Date.now() / 1000) + 10; // Current time in seconds
143
- try {
144
- const response = yield triadProtocol.trade.initializeQuestion({
145
- marketId: 0,
146
- question: 'Will Triad send the project to the Radar Hackathon?',
147
- startTime: currentTime,
148
- endTime: 1728320400
233
+ const resolveQuestion = () => __awaiter(void 0, void 0, void 0, function* () {
234
+ const marketsToResolve = [
235
+ { marketId: 1, winningDirection: { flop: {} } },
236
+ { marketId: 2, winningDirection: { flop: {} } },
237
+ { marketId: 3, winningDirection: { flop: {} } },
238
+ { marketId: 5, winningDirection: { flop: {} } }
239
+ ];
240
+ for (const market of marketsToResolve) {
241
+ const response = yield triadProtocol.trade.resolveQuestion({
242
+ marketId: market.marketId,
243
+ winningDirection: market.winningDirection
244
+ }, {
245
+ microLamports: 5000
149
246
  });
150
247
  console.log(response);
151
248
  }
152
- catch (e) {
153
- console.log(e);
154
- }
155
- });
156
- const resolveQuestion = () => __awaiter(void 0, void 0, void 0, function* () {
157
- const response = yield triadProtocol.trade.resolveQuestion(0);
158
- console.log(response);
159
- });
160
- const getReferral = () => __awaiter(void 0, void 0, void 0, function* () {
161
- const response = yield triadProtocol.getReferral('dannpl');
162
- console.log(response);
163
249
  });
package/dist/stake.d.ts CHANGED
@@ -54,10 +54,10 @@ export default class Stake {
54
54
  * Update Stake Vault
55
55
  * @param wallet - User wallet
56
56
  * @param amount - Reward amount to deposit (optional)
57
- * @param status - Status of the stake vault (optional)
57
+ * @param isLocked - is locked stake vault (optional)
58
58
  *
59
59
  */
60
- updateStakeVault({ wallet, amount, status }: UpdateStakeVaultArgs, options?: RpcOptions): Promise<any>;
60
+ updateStakeVault({ wallet, amount, isLocked }: UpdateStakeVaultArgs, options?: RpcOptions): Promise<any>;
61
61
  /**
62
62
  * Request Withdraw
63
63
  * @param wallet - User wallet
package/dist/stake.js CHANGED
@@ -166,15 +166,15 @@ class Stake {
166
166
  * Update Stake Vault
167
167
  * @param wallet - User wallet
168
168
  * @param amount - Reward amount to deposit (optional)
169
- * @param status - Status of the stake vault (optional)
169
+ * @param isLocked - is locked stake vault (optional)
170
170
  *
171
171
  */
172
- updateStakeVault({ wallet, amount, status }, options) {
172
+ updateStakeVault({ wallet, amount, isLocked }, options) {
173
173
  return __awaiter(this, void 0, void 0, function* () {
174
174
  return (0, sendTransactionWithOptions_1.default)(this.program.methods
175
175
  .updateStakeVault({
176
176
  amount,
177
- status,
177
+ isLocked,
178
178
  stakeVault: this.stakeVaultName
179
179
  })
180
180
  .accounts({
@@ -243,17 +243,24 @@ class Stake {
243
243
  return __awaiter(this, void 0, void 0, function* () {
244
244
  const stakes = (yield this.getUserStakes(wallet)).sort((a, b) => a.claimedTs - b.claimedTs);
245
245
  const ixs = [];
246
- for (const stake of stakes) {
246
+ let tokenStakes = [];
247
+ let nftStakes = [];
248
+ stakes.forEach((stake) => {
247
249
  if (stake.withdrawTs !== 0) {
248
- continue;
250
+ return;
249
251
  }
252
+ if (stake.mint === constants_1.TRD_MINT.toBase58()) {
253
+ tokenStakes.push(stake);
254
+ return;
255
+ }
256
+ nftStakes.push(stake);
257
+ });
258
+ let items = isToken ? tokenStakes : nftStakes;
259
+ for (const stake of items) {
250
260
  const rank = (0, getRarityRank_1.default)(ranks, stake.mint, stake.name);
251
261
  if (ixs.length >= 10) {
252
262
  break;
253
263
  }
254
- if (isToken && stake.mint !== constants_1.TRD_MINT.toBase58()) {
255
- continue;
256
- }
257
264
  const stakeVaultPDA = (0, stake_1.getStakeVaultPDA)(this.program.programId, this.stakeVaultName);
258
265
  const stakePDA = (0, stake_1.getStakePDA)(this.program.programId, wallet, stake.name);
259
266
  ixs.push(yield this.program.methods
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 { FeeVault, InitializeQuestionArgs, Market, OpenOrderArgs } from './types/trade';
4
+ import { FeeVault, InitializeQuestionArgs, 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 {
@@ -157,7 +157,16 @@ export default class Trade {
157
157
  * @param options - RPC options
158
158
  *
159
159
  */
160
- resolveQuestion(marketId: number, options?: RpcOptions): Promise<string>;
160
+ resolveQuestion({ marketId, winningDirection }: {
161
+ marketId: number;
162
+ winningDirection: {
163
+ hype: {};
164
+ } | {
165
+ flop: {};
166
+ } | {
167
+ none: {};
168
+ };
169
+ }, options?: RpcOptions): Promise<string>;
161
170
  /**
162
171
  * Settle an order
163
172
  * @param marketId - The ID of the market
@@ -170,4 +179,18 @@ export default class Trade {
170
179
  marketId: number;
171
180
  orderId: number;
172
181
  }, options?: RpcOptions): Promise<string>;
182
+ /**
183
+ * Add Liquidity
184
+ * @param marketId - The ID of the market
185
+ * @param amount - The amount of the order
186
+ * @param direction - The direction of the order
187
+ *
188
+ * @param options - RPC options
189
+ *
190
+ */
191
+ addLiquidity({ marketId, amount, direction }: {
192
+ marketId: number;
193
+ amount: number;
194
+ direction: OrderDirection;
195
+ }, options?: RpcOptions): Promise<string>;
173
196
  }
package/dist/trade.js CHANGED
@@ -227,10 +227,12 @@ class Trade {
227
227
  * @param options - RPC options
228
228
  *
229
229
  */
230
- resolveQuestion(marketId, options) {
230
+ resolveQuestion({ marketId, winningDirection }, options) {
231
231
  return __awaiter(this, void 0, void 0, function* () {
232
232
  const marketPDA = (0, trade_1.getMarketPDA)(this.program.programId, marketId);
233
- const method = this.program.methods.resolveQuestion().accounts({
233
+ const method = this.program.methods
234
+ .resolveQuestion(winningDirection)
235
+ .accounts({
234
236
  signer: this.provider.publicKey,
235
237
  market: marketPDA
236
238
  });
@@ -257,5 +259,30 @@ class Trade {
257
259
  }), options);
258
260
  });
259
261
  }
262
+ /**
263
+ * Add Liquidity
264
+ * @param marketId - The ID of the market
265
+ * @param amount - The amount of the order
266
+ * @param direction - The direction of the order
267
+ *
268
+ * @param options - RPC options
269
+ *
270
+ */
271
+ addLiquidity({ marketId, amount, direction }, options) {
272
+ return __awaiter(this, void 0, void 0, function* () {
273
+ const marketPDA = (0, trade_1.getMarketPDA)(this.program.programId, marketId);
274
+ const method = this.program.methods
275
+ .addLiquidity({
276
+ amount: new bn_js_1.default(amount * Math.pow(10, constants_1.TRD_DECIMALS)),
277
+ direction: direction
278
+ })
279
+ .accounts({
280
+ signer: this.provider.publicKey,
281
+ market: marketPDA,
282
+ mint: this.mint
283
+ });
284
+ return (0, sendTransactionWithOptions_1.default)(method, options);
285
+ });
286
+ }
260
287
  }
261
288
  exports.default = Trade;
@@ -7,6 +7,103 @@
7
7
  "description": "Triad protocol, trade solana projects"
8
8
  },
9
9
  "instructions": [
10
+ {
11
+ "name": "add_liquidity",
12
+ "discriminator": [181, 157, 89, 67, 143, 182, 52, 72],
13
+ "accounts": [
14
+ {
15
+ "name": "signer",
16
+ "writable": true,
17
+ "signer": true
18
+ },
19
+ {
20
+ "name": "market",
21
+ "writable": true
22
+ },
23
+ {
24
+ "name": "mint",
25
+ "writable": true
26
+ },
27
+ {
28
+ "name": "user_from_ata",
29
+ "writable": true,
30
+ "pda": {
31
+ "seeds": [
32
+ {
33
+ "kind": "account",
34
+ "path": "signer"
35
+ },
36
+ {
37
+ "kind": "account",
38
+ "path": "token_program"
39
+ },
40
+ {
41
+ "kind": "account",
42
+ "path": "mint"
43
+ }
44
+ ],
45
+ "program": {
46
+ "kind": "const",
47
+ "value": [
48
+ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
49
+ 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
50
+ 219, 233, 248, 89
51
+ ]
52
+ }
53
+ }
54
+ },
55
+ {
56
+ "name": "market_to_ata",
57
+ "writable": true,
58
+ "pda": {
59
+ "seeds": [
60
+ {
61
+ "kind": "account",
62
+ "path": "market"
63
+ },
64
+ {
65
+ "kind": "account",
66
+ "path": "token_program"
67
+ },
68
+ {
69
+ "kind": "account",
70
+ "path": "mint"
71
+ }
72
+ ],
73
+ "program": {
74
+ "kind": "const",
75
+ "value": [
76
+ 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
77
+ 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
78
+ 219, 233, 248, 89
79
+ ]
80
+ }
81
+ }
82
+ },
83
+ {
84
+ "name": "token_program",
85
+ "address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
86
+ },
87
+ {
88
+ "name": "associated_token_program",
89
+ "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
90
+ },
91
+ {
92
+ "name": "system_program",
93
+ "address": "11111111111111111111111111111111"
94
+ }
95
+ ],
96
+ "args": [
97
+ {
98
+ "name": "args",
99
+ "type": {
100
+ "defined": {
101
+ "name": "AddLiquidityArgs"
102
+ }
103
+ }
104
+ }
105
+ ]
106
+ },
10
107
  {
11
108
  "name": "claim_stake_rewards",
12
109
  "discriminator": [107, 91, 233, 196, 211, 47, 218, 21],
@@ -240,22 +337,6 @@
240
337
  ]
241
338
  }
242
339
  },
243
- {
244
- "name": "user_trade",
245
- "writable": true,
246
- "pda": {
247
- "seeds": [
248
- {
249
- "kind": "const",
250
- "value": [117, 115, 101, 114, 95, 116, 114, 97, 100, 101]
251
- },
252
- {
253
- "kind": "account",
254
- "path": "signer"
255
- }
256
- ]
257
- }
258
- },
259
340
  {
260
341
  "name": "system_program",
261
342
  "address": "11111111111111111111111111111111"
@@ -621,7 +702,16 @@
621
702
  "address": "11111111111111111111111111111111"
622
703
  }
623
704
  ],
624
- "args": []
705
+ "args": [
706
+ {
707
+ "name": "winning_direction",
708
+ "type": {
709
+ "defined": {
710
+ "name": "WinningDirection"
711
+ }
712
+ }
713
+ }
714
+ ]
625
715
  },
626
716
  {
627
717
  "name": "settle_order",
@@ -1522,9 +1612,59 @@
1522
1612
  "code": 6040,
1523
1613
  "name": "MarketStillActive",
1524
1614
  "msg": "Market still active"
1615
+ },
1616
+ {
1617
+ "code": 6041,
1618
+ "name": "OrderNotOpen",
1619
+ "msg": "Order not open"
1620
+ },
1621
+ {
1622
+ "code": 6042,
1623
+ "name": "HasOpenedOrders",
1624
+ "msg": "Has opened orders"
1625
+ },
1626
+ {
1627
+ "code": 6043,
1628
+ "name": "InsufficientLiquidity",
1629
+ "msg": "Insufficient liquidity"
1630
+ },
1631
+ {
1632
+ "code": 6044,
1633
+ "name": "MarketNotResolved",
1634
+ "msg": "Market not resolved"
1635
+ },
1636
+ {
1637
+ "code": 6045,
1638
+ "name": "MarketAlreadyResolved",
1639
+ "msg": "Market already resolved"
1640
+ },
1641
+ {
1642
+ "code": 6046,
1643
+ "name": "ConcurrentTransaction",
1644
+ "msg": "Concurrent transaction"
1525
1645
  }
1526
1646
  ],
1527
1647
  "types": [
1648
+ {
1649
+ "name": "AddLiquidityArgs",
1650
+ "type": {
1651
+ "kind": "struct",
1652
+ "fields": [
1653
+ {
1654
+ "name": "amount",
1655
+ "type": "u64"
1656
+ },
1657
+ {
1658
+ "name": "direction",
1659
+ "type": {
1660
+ "defined": {
1661
+ "name": "OrderDirection"
1662
+ }
1663
+ }
1664
+ }
1665
+ ]
1666
+ }
1667
+ },
1528
1668
  {
1529
1669
  "name": "ClaimStakeRewardsArgs",
1530
1670
  "type": {
@@ -1743,7 +1883,7 @@
1743
1883
  {
1744
1884
  "name": "fee_bps",
1745
1885
  "docs": [
1746
- "Fees applied to trades (in basis points, e.g., 1.131% fee)"
1886
+ "Fees applied to trades (in basis points, e.g., 2.131% fee)"
1747
1887
  ],
1748
1888
  "type": "u16"
1749
1889
  },
@@ -1791,6 +1931,10 @@
1791
1931
  "array": ["u8", 80]
1792
1932
  }
1793
1933
  },
1934
+ {
1935
+ "name": "liquidity",
1936
+ "type": "u64"
1937
+ },
1794
1938
  {
1795
1939
  "name": "padding",
1796
1940
  "type": {
@@ -2530,7 +2674,7 @@
2530
2674
  }
2531
2675
  },
2532
2676
  {
2533
- "name": "status",
2677
+ "name": "is_locked",
2534
2678
  "type": {
2535
2679
  "option": "bool"
2536
2680
  }
@@ -2780,9 +2924,6 @@
2780
2924
  },
2781
2925
  {
2782
2926
  "name": "Flop"
2783
- },
2784
- {
2785
- "name": "Draw"
2786
2927
  }
2787
2928
  ]
2788
2929
  }
@@ -22,7 +22,7 @@ export type InitializeStakeArgs = {
22
22
  export type UpdateStakeVaultArgs = {
23
23
  wallet: PublicKey;
24
24
  amount?: BN;
25
- status?: boolean;
25
+ isLocked?: boolean;
26
26
  };
27
27
  export type RequestWithdrawArgs = {
28
28
  wallet: PublicKey;
@@ -39,9 +39,9 @@ export type ResolvedQuestion = {
39
39
  finalFlopPrice: string;
40
40
  };
41
41
  export declare enum WinningDirection {
42
- Hype = "Hype",
43
- Flop = "Flop",
44
- None = "None"
42
+ HYPE = "Hype",
43
+ FLOP = "Flop",
44
+ NONE = "None"
45
45
  }
46
46
  export type OrderDirection = {
47
47
  hype: {};
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WinningDirection = void 0;
4
4
  var WinningDirection;
5
5
  (function (WinningDirection) {
6
- WinningDirection["Hype"] = "Hype";
7
- WinningDirection["Flop"] = "Flop";
8
- WinningDirection["None"] = "None";
6
+ WinningDirection["HYPE"] = "Hype";
7
+ WinningDirection["FLOP"] = "Flop";
8
+ WinningDirection["NONE"] = "None";
9
9
  })(WinningDirection || (exports.WinningDirection = WinningDirection = {}));
@@ -13,6 +13,161 @@ export type TriadProtocol = {
13
13
  description: 'Triad protocol, trade solana projects';
14
14
  };
15
15
  instructions: [
16
+ {
17
+ name: 'addLiquidity';
18
+ discriminator: [181, 157, 89, 67, 143, 182, 52, 72];
19
+ accounts: [
20
+ {
21
+ name: 'signer';
22
+ writable: true;
23
+ signer: true;
24
+ },
25
+ {
26
+ name: 'market';
27
+ writable: true;
28
+ },
29
+ {
30
+ name: 'mint';
31
+ writable: true;
32
+ },
33
+ {
34
+ name: 'userFromAta';
35
+ writable: true;
36
+ pda: {
37
+ seeds: [
38
+ {
39
+ kind: 'account';
40
+ path: 'signer';
41
+ },
42
+ {
43
+ kind: 'account';
44
+ path: 'tokenProgram';
45
+ },
46
+ {
47
+ kind: 'account';
48
+ path: 'mint';
49
+ }
50
+ ];
51
+ program: {
52
+ kind: 'const';
53
+ value: [
54
+ 140,
55
+ 151,
56
+ 37,
57
+ 143,
58
+ 78,
59
+ 36,
60
+ 137,
61
+ 241,
62
+ 187,
63
+ 61,
64
+ 16,
65
+ 41,
66
+ 20,
67
+ 142,
68
+ 13,
69
+ 131,
70
+ 11,
71
+ 90,
72
+ 19,
73
+ 153,
74
+ 218,
75
+ 255,
76
+ 16,
77
+ 132,
78
+ 4,
79
+ 142,
80
+ 123,
81
+ 216,
82
+ 219,
83
+ 233,
84
+ 248,
85
+ 89
86
+ ];
87
+ };
88
+ };
89
+ },
90
+ {
91
+ name: 'marketToAta';
92
+ writable: true;
93
+ pda: {
94
+ seeds: [
95
+ {
96
+ kind: 'account';
97
+ path: 'market';
98
+ },
99
+ {
100
+ kind: 'account';
101
+ path: 'tokenProgram';
102
+ },
103
+ {
104
+ kind: 'account';
105
+ path: 'mint';
106
+ }
107
+ ];
108
+ program: {
109
+ kind: 'const';
110
+ value: [
111
+ 140,
112
+ 151,
113
+ 37,
114
+ 143,
115
+ 78,
116
+ 36,
117
+ 137,
118
+ 241,
119
+ 187,
120
+ 61,
121
+ 16,
122
+ 41,
123
+ 20,
124
+ 142,
125
+ 13,
126
+ 131,
127
+ 11,
128
+ 90,
129
+ 19,
130
+ 153,
131
+ 218,
132
+ 255,
133
+ 16,
134
+ 132,
135
+ 4,
136
+ 142,
137
+ 123,
138
+ 216,
139
+ 219,
140
+ 233,
141
+ 248,
142
+ 89
143
+ ];
144
+ };
145
+ };
146
+ },
147
+ {
148
+ name: 'tokenProgram';
149
+ address: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb';
150
+ },
151
+ {
152
+ name: 'associatedTokenProgram';
153
+ address: 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
154
+ },
155
+ {
156
+ name: 'systemProgram';
157
+ address: '11111111111111111111111111111111';
158
+ }
159
+ ];
160
+ args: [
161
+ {
162
+ name: 'args';
163
+ type: {
164
+ defined: {
165
+ name: 'addLiquidityArgs';
166
+ };
167
+ };
168
+ }
169
+ ];
170
+ },
16
171
  {
17
172
  name: 'claimStakeRewards';
18
173
  discriminator: [107, 91, 233, 196, 211, 47, 218, 21];
@@ -362,22 +517,6 @@ export type TriadProtocol = {
362
517
  ];
363
518
  };
364
519
  },
365
- {
366
- name: 'userTrade';
367
- writable: true;
368
- pda: {
369
- seeds: [
370
- {
371
- kind: 'const';
372
- value: [117, 115, 101, 114, 95, 116, 114, 97, 100, 101];
373
- },
374
- {
375
- kind: 'account';
376
- path: 'signer';
377
- }
378
- ];
379
- };
380
- },
381
520
  {
382
521
  name: 'systemProgram';
383
522
  address: '11111111111111111111111111111111';
@@ -859,7 +998,16 @@ export type TriadProtocol = {
859
998
  address: '11111111111111111111111111111111';
860
999
  }
861
1000
  ];
862
- args: [];
1001
+ args: [
1002
+ {
1003
+ name: 'winningDirection';
1004
+ type: {
1005
+ defined: {
1006
+ name: 'winningDirection';
1007
+ };
1008
+ };
1009
+ }
1010
+ ];
863
1011
  },
864
1012
  {
865
1013
  name: 'settleOrder';
@@ -2050,9 +2198,59 @@ export type TriadProtocol = {
2050
2198
  code: 6040;
2051
2199
  name: 'marketStillActive';
2052
2200
  msg: 'Market still active';
2201
+ },
2202
+ {
2203
+ code: 6041;
2204
+ name: 'orderNotOpen';
2205
+ msg: 'Order not open';
2206
+ },
2207
+ {
2208
+ code: 6042;
2209
+ name: 'hasOpenedOrders';
2210
+ msg: 'Has opened orders';
2211
+ },
2212
+ {
2213
+ code: 6043;
2214
+ name: 'insufficientLiquidity';
2215
+ msg: 'Insufficient liquidity';
2216
+ },
2217
+ {
2218
+ code: 6044;
2219
+ name: 'marketNotResolved';
2220
+ msg: 'Market not resolved';
2221
+ },
2222
+ {
2223
+ code: 6045;
2224
+ name: 'marketAlreadyResolved';
2225
+ msg: 'Market already resolved';
2226
+ },
2227
+ {
2228
+ code: 6046;
2229
+ name: 'concurrentTransaction';
2230
+ msg: 'Concurrent transaction';
2053
2231
  }
2054
2232
  ];
2055
2233
  types: [
2234
+ {
2235
+ name: 'addLiquidityArgs';
2236
+ type: {
2237
+ kind: 'struct';
2238
+ fields: [
2239
+ {
2240
+ name: 'amount';
2241
+ type: 'u64';
2242
+ },
2243
+ {
2244
+ name: 'direction';
2245
+ type: {
2246
+ defined: {
2247
+ name: 'orderDirection';
2248
+ };
2249
+ };
2250
+ }
2251
+ ];
2252
+ };
2253
+ },
2056
2254
  {
2057
2255
  name: 'claimStakeRewardsArgs';
2058
2256
  type: {
@@ -2270,7 +2468,7 @@ export type TriadProtocol = {
2270
2468
  },
2271
2469
  {
2272
2470
  name: 'feeBps';
2273
- docs: ['Fees applied to trades (in basis points, e.g., 1.131% fee)'];
2471
+ docs: ['Fees applied to trades (in basis points, e.g., 2.131% fee)'];
2274
2472
  type: 'u16';
2275
2473
  },
2276
2474
  {
@@ -2317,6 +2515,10 @@ export type TriadProtocol = {
2317
2515
  array: ['u8', 80];
2318
2516
  };
2319
2517
  },
2518
+ {
2519
+ name: 'liquidity';
2520
+ type: 'u64';
2521
+ },
2320
2522
  {
2321
2523
  name: 'padding';
2322
2524
  type: {
@@ -3056,7 +3258,7 @@ export type TriadProtocol = {
3056
3258
  };
3057
3259
  },
3058
3260
  {
3059
- name: 'status';
3261
+ name: 'isLocked';
3060
3262
  type: {
3061
3263
  option: 'bool';
3062
3264
  };
@@ -3306,9 +3508,6 @@ export type TriadProtocol = {
3306
3508
  },
3307
3509
  {
3308
3510
  name: 'flop';
3309
- },
3310
- {
3311
- name: 'draw';
3312
3511
  }
3313
3512
  ];
3314
3513
  };
@@ -97,13 +97,14 @@ const accountToMarket = (account, address) => {
97
97
  };
98
98
  exports.accountToMarket = accountToMarket;
99
99
  const accountToResolvedQuestion = (question) => {
100
+ console.log(question);
100
101
  return {
101
102
  question: Buffer.from(question.question).toString().replace(/\0+$/, ''),
102
103
  startTime: question.startTime.toString(),
103
104
  endTime: question.endTime.toString(),
104
105
  hypeLiquidity: question.hypeLiquidity.toString(),
105
106
  flopLiquidity: question.flopLiquidity.toString(),
106
- winningDirection: trade_1.WinningDirection[question.winningDirection],
107
+ winningDirection: trade_1.WinningDirection[Object.keys(question.winningDirection)[0].toUpperCase()],
107
108
  marketPrice: question.marketPrice.toString(),
108
109
  finalHypePrice: question.finalHypePrice.toString(),
109
110
  finalFlopPrice: question.finalFlopPrice.toString()
@@ -21,7 +21,7 @@ const sendVersionedTransaction = (provider, ixs, options, payer, addressLookupTa
21
21
  instructions: ixs,
22
22
  recentBlockhash: blockhash,
23
23
  payerKey: provider.publicKey
24
- }).compileToV0Message(addressLookupTableAccounts || []));
24
+ }).compileToV0Message(addressLookupTableAccounts));
25
25
  if (payer) {
26
26
  tx.sign([payer]);
27
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "1.1.9-beta",
3
+ "version": "1.2.1-beta",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",