@triadxyz/triad-protocol 1.2.7-beta → 1.2.9-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/local-test.js +39 -144
- package/dist/stake.d.ts +12 -4
- package/dist/stake.js +15 -16
- package/dist/trade.d.ts +1 -1
- package/dist/trade.js +4 -2
- package/dist/types/idl_triad_protocol.json +169 -42
- package/dist/types/index.d.ts +0 -3
- package/dist/types/trade.d.ts +0 -1
- package/dist/types/triad_protocol.d.ts +285 -42
- package/dist/utils/helpers.js +2 -6
- package/package.json +1 -1
package/dist/local-test.js
CHANGED
|
@@ -15,23 +15,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
const fs_1 = __importDefault(require("fs"));
|
|
16
16
|
const _1 = __importDefault(require("./"));
|
|
17
17
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
18
|
-
const axios_1 = __importDefault(require("axios"));
|
|
19
18
|
const web3_js_1 = require("@solana/web3.js");
|
|
20
19
|
const spl_token_1 = require("@solana/spl-token");
|
|
21
|
-
const file = fs_1.default.readFileSync('/Users/dannpl/.config/solana/
|
|
20
|
+
const file = fs_1.default.readFileSync('/Users/dannpl/.config/solana/triad.json');
|
|
22
21
|
const rpc_file = fs_1.default.readFileSync('/Users/dannpl/.config/solana/rpc.txt');
|
|
23
22
|
const keypair = web3_js_1.Keypair.fromSecretKey(new Uint8Array(JSON.parse(file.toString())));
|
|
24
|
-
const connection = new web3_js_1.Connection(
|
|
23
|
+
const connection = new web3_js_1.Connection(rpc_file.toString());
|
|
25
24
|
const wallet = new anchor_1.Wallet(keypair);
|
|
26
25
|
const triadProtocol = new _1.default(connection, wallet);
|
|
27
26
|
const mint = new web3_js_1.PublicKey('X41iRJUPkKaEvhqWdxqrS5P7M5d8A9oathki5sT47KR');
|
|
28
27
|
const markets = [
|
|
29
28
|
{
|
|
30
|
-
marketId:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
endTime: 1731715200
|
|
29
|
+
marketId: 24,
|
|
30
|
+
question: 'Will $CORN be above $2.1M in MarketCap on November 22?',
|
|
31
|
+
startTime: 1732040456,
|
|
32
|
+
endTime: 1732935600
|
|
35
33
|
}
|
|
36
34
|
];
|
|
37
35
|
const ordersHypeAndFloopBot = [
|
|
@@ -46,7 +44,7 @@ const ordersHypeAndFloopBot = [
|
|
|
46
44
|
const updateStakeVault = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
45
|
const response = yield triadProtocol.stake.updateStakeVault({
|
|
48
46
|
wallet: wallet.publicKey,
|
|
49
|
-
amount: new anchor_1.BN(
|
|
47
|
+
amount: new anchor_1.BN(3000 * Math.pow(10, 6)),
|
|
50
48
|
isLocked: false
|
|
51
49
|
});
|
|
52
50
|
console.log(response);
|
|
@@ -55,25 +53,11 @@ const getStakeVault = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
55
53
|
const response = yield triadProtocol.stake.getStakeVaults();
|
|
56
54
|
console.log(response);
|
|
57
55
|
});
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
for (const stake of stakes) {
|
|
64
|
-
if (update.length >= 10) {
|
|
65
|
-
break;
|
|
66
|
-
}
|
|
67
|
-
if (response.includes(stake.mint) && !stake.boost) {
|
|
68
|
-
update.push({ name: stake.name, wallet: stake.authority });
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
console.log(update);
|
|
72
|
-
const updateBoostResponse = yield triadProtocol.stake.updateBoost({
|
|
73
|
-
wallet: wallet.publicKey,
|
|
74
|
-
nfts: update
|
|
75
|
-
});
|
|
76
|
-
console.log(updateBoostResponse);
|
|
56
|
+
const getStaked = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
|
+
const user = yield triadProtocol.getUser(new web3_js_1.PublicKey('3umHQwkz2r8E6K6xWJuSDziDoWgkWwRckDPGEYzD8TPf'));
|
|
58
|
+
const response = yield triadProtocol.stake.getUserStakes(new web3_js_1.PublicKey('3umHQwkz2r8E6K6xWJuSDziDoWgkWwRckDPGEYzD8TPf'));
|
|
59
|
+
console.log(user);
|
|
60
|
+
console.log(response);
|
|
77
61
|
});
|
|
78
62
|
const getAllMarkets = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
79
63
|
const markets = yield triadProtocol.trade.getAllMarkets();
|
|
@@ -89,10 +73,10 @@ const initializeAllMarkets = () => __awaiter(void 0, void 0, void 0, function* (
|
|
|
89
73
|
const response = yield triadProtocol.trade.initializeMarket(market, {
|
|
90
74
|
microLamports: 5000
|
|
91
75
|
});
|
|
92
|
-
console.log(`Initialized market ${market.
|
|
76
|
+
console.log(`Initialized market ${market.question}:`, response);
|
|
93
77
|
}
|
|
94
78
|
catch (error) {
|
|
95
|
-
console.error(`Error initializing market ${market.
|
|
79
|
+
console.error(`Error initializing market ${market.question}:`, error);
|
|
96
80
|
}
|
|
97
81
|
}
|
|
98
82
|
});
|
|
@@ -120,125 +104,35 @@ const getOrders = (walletAddress) => __awaiter(void 0, void 0, void 0, function*
|
|
|
120
104
|
const getLiquidityToRecovery = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
121
105
|
const response = yield triadProtocol.program.account.userTrade.all();
|
|
122
106
|
const allMarkets = yield triadProtocol.trade.getAllMarkets();
|
|
123
|
-
const liquidityToRecovery = {
|
|
124
|
-
0: {
|
|
125
|
-
name: 'triad',
|
|
126
|
-
liquidityToPay: 0,
|
|
127
|
-
sharesToPay: 0,
|
|
128
|
-
openOrders: 0,
|
|
129
|
-
medPrice: 0,
|
|
130
|
-
direction: {
|
|
131
|
-
flop: {}
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
1: {
|
|
135
|
-
name: 'pyth',
|
|
136
|
-
liquidityToPay: 0,
|
|
137
|
-
sharesToPay: 0,
|
|
138
|
-
openOrders: 0,
|
|
139
|
-
medPrice: 0,
|
|
140
|
-
direction: {
|
|
141
|
-
flop: {}
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
2: {
|
|
145
|
-
name: 'drift',
|
|
146
|
-
liquidityToPay: 0,
|
|
147
|
-
sharesToPay: 0,
|
|
148
|
-
openOrders: 0,
|
|
149
|
-
medPrice: 0,
|
|
150
|
-
direction: {
|
|
151
|
-
flop: {}
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
3: {
|
|
155
|
-
name: 'symmetry',
|
|
156
|
-
liquidityToPay: 0,
|
|
157
|
-
sharesToPay: 0,
|
|
158
|
-
openOrders: 0,
|
|
159
|
-
medPrice: 0,
|
|
160
|
-
direction: {
|
|
161
|
-
flop: {}
|
|
162
|
-
}
|
|
163
|
-
},
|
|
164
|
-
4: {
|
|
165
|
-
name: 'ore',
|
|
166
|
-
liquidityToPay: 0,
|
|
167
|
-
sharesToPay: 0,
|
|
168
|
-
openOrders: 0,
|
|
169
|
-
medPrice: 0,
|
|
170
|
-
direction: {
|
|
171
|
-
hype: {}
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
5: {
|
|
175
|
-
name: 'coleta',
|
|
176
|
-
liquidityToPay: 0,
|
|
177
|
-
sharesToPay: 0,
|
|
178
|
-
openOrders: 0,
|
|
179
|
-
medPrice: 0,
|
|
180
|
-
direction: {
|
|
181
|
-
flop: {}
|
|
182
|
-
}
|
|
183
|
-
},
|
|
184
|
-
6: {
|
|
185
|
-
name: 'undead',
|
|
186
|
-
liquidityToPay: 0,
|
|
187
|
-
sharesToPay: 0,
|
|
188
|
-
openOrders: 0,
|
|
189
|
-
medPrice: 0,
|
|
190
|
-
direction: {
|
|
191
|
-
hype: {}
|
|
192
|
-
}
|
|
193
|
-
},
|
|
194
|
-
7: {
|
|
195
|
-
name: 'solxeth',
|
|
196
|
-
liquidityToPay: 0,
|
|
197
|
-
sharesToPay: 0,
|
|
198
|
-
openOrders: 0,
|
|
199
|
-
medPrice: 0,
|
|
200
|
-
direction: {
|
|
201
|
-
flop: {}
|
|
202
|
-
}
|
|
203
|
-
},
|
|
204
|
-
8: {
|
|
205
|
-
name: 'solxeth2',
|
|
206
|
-
liquidityToPay: 0,
|
|
207
|
-
sharesToPay: 0,
|
|
208
|
-
openOrders: 0,
|
|
209
|
-
medPrice: 0,
|
|
210
|
-
direction: {
|
|
211
|
-
flop: {}
|
|
212
|
-
}
|
|
213
|
-
},
|
|
214
|
-
9: {
|
|
215
|
-
name: 'solxeth3',
|
|
216
|
-
liquidityToPay: 0,
|
|
217
|
-
sharesToPay: 0,
|
|
218
|
-
openOrders: 0,
|
|
219
|
-
medPrice: 0,
|
|
220
|
-
direction: {
|
|
221
|
-
flop: {}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
};
|
|
107
|
+
const liquidityToRecovery = {};
|
|
225
108
|
for (const market of allMarkets) {
|
|
226
109
|
let currentMarket = liquidityToRecovery[market.marketId];
|
|
227
110
|
if (!currentMarket) {
|
|
228
|
-
|
|
111
|
+
currentMarket = {
|
|
112
|
+
address: market.address,
|
|
113
|
+
name: market.question,
|
|
114
|
+
liquidityToPay: 0,
|
|
115
|
+
sharesToPay: 0,
|
|
116
|
+
openOrders: 0,
|
|
117
|
+
direction: market.winningDirection.toLowerCase() === 'flop'
|
|
118
|
+
? { flop: {} }
|
|
119
|
+
: { hype: {} },
|
|
120
|
+
totalLiquidity: 0
|
|
121
|
+
};
|
|
122
|
+
liquidityToRecovery[market.marketId] = currentMarket;
|
|
229
123
|
}
|
|
124
|
+
currentMarket.totalLiquidity +=
|
|
125
|
+
parseFloat(market.flopLiquidity.toString()) / Math.pow(10, 6);
|
|
126
|
+
currentMarket.totalLiquidity +=
|
|
127
|
+
parseFloat(market.hypeLiquidity.toString()) / Math.pow(10, 6);
|
|
230
128
|
if ('flop' in currentMarket.direction) {
|
|
231
129
|
let shares = parseFloat(market.flopShares.toString()) / Math.pow(10, 6);
|
|
232
|
-
currentMarket.medPrice =
|
|
233
|
-
parseFloat(market.hypeLiquidity.toString()) / Math.pow(10, 6) / shares;
|
|
234
130
|
currentMarket.sharesToPay = shares;
|
|
235
131
|
currentMarket.liquidityToPay =
|
|
236
132
|
parseFloat(market.hypeLiquidity.toString()) / Math.pow(10, 6);
|
|
237
133
|
}
|
|
238
134
|
else {
|
|
239
135
|
let shares = parseFloat(market.hypeShares.toString()) / Math.pow(10, 6);
|
|
240
|
-
currentMarket.medPrice =
|
|
241
|
-
parseFloat(market.flopLiquidity.toString()) / Math.pow(10, 6) / shares;
|
|
242
136
|
currentMarket.sharesToPay = shares;
|
|
243
137
|
currentMarket.liquidityToPay =
|
|
244
138
|
parseFloat(market.flopLiquidity.toString()) / Math.pow(10, 6);
|
|
@@ -257,6 +151,7 @@ const getLiquidityToRecovery = () => __awaiter(void 0, void 0, void 0, function*
|
|
|
257
151
|
}
|
|
258
152
|
console.log(liquidityToRecovery);
|
|
259
153
|
});
|
|
154
|
+
getLiquidityToRecovery();
|
|
260
155
|
const openOrder = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
261
156
|
yield getMarket();
|
|
262
157
|
for (const order of ordersHypeAndFloopBot) {
|
|
@@ -312,7 +207,7 @@ const mintTokens = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
312
207
|
console.log(mintTx);
|
|
313
208
|
});
|
|
314
209
|
const resolveMarket = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
315
|
-
const marketsToResolve = [{ marketId:
|
|
210
|
+
const marketsToResolve = [{ marketId: 22, winningDirection: { hype: {} } }];
|
|
316
211
|
for (const market of marketsToResolve) {
|
|
317
212
|
const response = yield triadProtocol.trade.resolveMarket({
|
|
318
213
|
marketId: market.marketId,
|
|
@@ -342,9 +237,9 @@ const collectFees = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
342
237
|
try {
|
|
343
238
|
const response = yield triadProtocol.trade.collectFee({
|
|
344
239
|
marketId: Number(market.marketId),
|
|
345
|
-
vault: new web3_js_1.PublicKey('
|
|
240
|
+
vault: new web3_js_1.PublicKey('Hk1r2NUL4LbUhx1agg1w44tyZiNr72mbeLsg6suF5MA4')
|
|
346
241
|
}, {
|
|
347
|
-
microLamports:
|
|
242
|
+
microLamports: 180000,
|
|
348
243
|
skipPreflight: true
|
|
349
244
|
});
|
|
350
245
|
console.log(response);
|
|
@@ -353,7 +248,6 @@ const collectFees = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
353
248
|
console.log(e);
|
|
354
249
|
}
|
|
355
250
|
}
|
|
356
|
-
fs_1.default.writeFileSync(`fees-collected.json`, JSON.stringify(currentFees, null, 2));
|
|
357
251
|
});
|
|
358
252
|
const mintTicket = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
359
253
|
console.log(wallet.publicKey.toBase58());
|
|
@@ -361,9 +255,10 @@ const mintTicket = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
361
255
|
discount: 0,
|
|
362
256
|
isBoosted: false,
|
|
363
257
|
rarity: { uncommon: {} },
|
|
364
|
-
verifier: '',
|
|
365
|
-
nftMint: new web3_js_1.PublicKey('')
|
|
258
|
+
verifier: '43bkRb3xj4Vv77Y76TjQuNiPGUsnun4tFSMYXY2Y2K5LfRT79YDpHhc7jruWmDGdygUBPXYQQZntCQz6V6cRGz8F',
|
|
259
|
+
nftMint: new web3_js_1.PublicKey('A5dk1WqN9qcq1ZaWEh1UaMJR3SQeAsMirEEnLWbpp6fu')
|
|
260
|
+
}, {
|
|
261
|
+
skipPreflight: true
|
|
366
262
|
});
|
|
367
263
|
console.log(response);
|
|
368
264
|
});
|
|
369
|
-
mintTicket();
|
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, RequestWithdrawArgs, WithdrawArgs, Stake as StakeResponse, ClaimStakeRewardsArgs, StakeTokenArgs
|
|
5
|
+
import { UpdateStakeVaultArgs, RequestWithdrawArgs, WithdrawArgs, Stake as StakeResponse, ClaimStakeRewardsArgs, StakeTokenArgs } from './types/stake';
|
|
6
6
|
export default class Stake {
|
|
7
7
|
program: Program<TriadProtocol>;
|
|
8
8
|
provider: AnchorProvider;
|
|
@@ -85,10 +85,18 @@ export default class Stake {
|
|
|
85
85
|
isToken?: boolean;
|
|
86
86
|
}, options?: RpcOptions): Promise<string>;
|
|
87
87
|
/**
|
|
88
|
-
*
|
|
88
|
+
* Withdraw NFT
|
|
89
89
|
* @param wallet - User wallet
|
|
90
|
-
* @param
|
|
90
|
+
* @param name - Stake name
|
|
91
|
+
* @param mint - NFT mint
|
|
91
92
|
*
|
|
92
93
|
*/
|
|
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>;
|
|
94
102
|
}
|
package/dist/stake.js
CHANGED
|
@@ -13,7 +13,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
16
|
-
const web3_js_1 = require("@solana/web3.js");
|
|
17
16
|
const helpers_1 = require("./utils/helpers");
|
|
18
17
|
const stake_1 = require("./utils/pda/stake");
|
|
19
18
|
const pda_1 = require("./utils/pda");
|
|
@@ -256,25 +255,25 @@ class Stake {
|
|
|
256
255
|
});
|
|
257
256
|
}
|
|
258
257
|
/**
|
|
259
|
-
*
|
|
258
|
+
* Withdraw NFT
|
|
260
259
|
* @param wallet - User wallet
|
|
261
|
-
* @param
|
|
260
|
+
* @param name - Stake name
|
|
261
|
+
* @param mint - NFT mint
|
|
262
262
|
*
|
|
263
263
|
*/
|
|
264
|
-
|
|
264
|
+
withdrawNft({ wallet, name, nftMint, tokenMint, rank, collections }, options) {
|
|
265
265
|
return __awaiter(this, void 0, void 0, function* () {
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
}
|
|
277
|
-
return (0, sendVersionedTransaction_1.default)(this.provider, ixs, options);
|
|
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);
|
|
278
277
|
});
|
|
279
278
|
}
|
|
280
279
|
}
|
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,
|
|
113
|
+
initializeMarket({ marketId, startTime, endTime, question }: InitializeMarketArgs, options?: RpcOptions): Promise<any>;
|
|
114
114
|
/**
|
|
115
115
|
* Open Order
|
|
116
116
|
* @param marketId - The ID of the market
|
package/dist/trade.js
CHANGED
|
@@ -84,12 +84,14 @@ class Trade {
|
|
|
84
84
|
* @param options - RPC options
|
|
85
85
|
*
|
|
86
86
|
*/
|
|
87
|
-
initializeMarket({ marketId,
|
|
87
|
+
initializeMarket({ marketId, startTime, endTime, question }, options) {
|
|
88
88
|
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
if (question.length > 80) {
|
|
90
|
+
throw new Error('Question must be less than 80 characters');
|
|
91
|
+
}
|
|
89
92
|
return (0, sendTransactionWithOptions_1.default)(this.program.methods
|
|
90
93
|
.initializeMarket({
|
|
91
94
|
marketId: new bn_js_1.default(marketId),
|
|
92
|
-
name: name,
|
|
93
95
|
question: (0, helpers_1.encodeString)(question, 80),
|
|
94
96
|
startTime: new bn_js_1.default(startTime),
|
|
95
97
|
endTime: new bn_js_1.default(endTime)
|
|
@@ -1261,26 +1261,6 @@
|
|
|
1261
1261
|
}
|
|
1262
1262
|
]
|
|
1263
1263
|
},
|
|
1264
|
-
{
|
|
1265
|
-
"name": "update_stake_boost",
|
|
1266
|
-
"discriminator": [239, 85, 19, 140, 235, 236, 88, 70],
|
|
1267
|
-
"accounts": [
|
|
1268
|
-
{
|
|
1269
|
-
"name": "signer",
|
|
1270
|
-
"writable": true,
|
|
1271
|
-
"signer": true
|
|
1272
|
-
},
|
|
1273
|
-
{
|
|
1274
|
-
"name": "stake",
|
|
1275
|
-
"writable": true
|
|
1276
|
-
},
|
|
1277
|
-
{
|
|
1278
|
-
"name": "system_program",
|
|
1279
|
-
"address": "11111111111111111111111111111111"
|
|
1280
|
-
}
|
|
1281
|
-
],
|
|
1282
|
-
"args": []
|
|
1283
|
-
},
|
|
1284
1264
|
{
|
|
1285
1265
|
"name": "update_stake_vault",
|
|
1286
1266
|
"discriminator": [84, 171, 100, 153, 126, 215, 229, 68],
|
|
@@ -1390,6 +1370,171 @@
|
|
|
1390
1370
|
}
|
|
1391
1371
|
]
|
|
1392
1372
|
},
|
|
1373
|
+
{
|
|
1374
|
+
"name": "withdraw_nft",
|
|
1375
|
+
"discriminator": [142, 181, 191, 149, 82, 175, 216, 100],
|
|
1376
|
+
"accounts": [
|
|
1377
|
+
{
|
|
1378
|
+
"name": "signer",
|
|
1379
|
+
"writable": true,
|
|
1380
|
+
"signer": true
|
|
1381
|
+
},
|
|
1382
|
+
{
|
|
1383
|
+
"name": "stake_vault",
|
|
1384
|
+
"writable": true
|
|
1385
|
+
},
|
|
1386
|
+
{
|
|
1387
|
+
"name": "user",
|
|
1388
|
+
"writable": true
|
|
1389
|
+
},
|
|
1390
|
+
{
|
|
1391
|
+
"name": "stake",
|
|
1392
|
+
"writable": true
|
|
1393
|
+
},
|
|
1394
|
+
{
|
|
1395
|
+
"name": "nft_mint",
|
|
1396
|
+
"writable": true
|
|
1397
|
+
},
|
|
1398
|
+
{
|
|
1399
|
+
"name": "token_mint",
|
|
1400
|
+
"writable": true
|
|
1401
|
+
},
|
|
1402
|
+
{
|
|
1403
|
+
"name": "nft_from_ata",
|
|
1404
|
+
"writable": true,
|
|
1405
|
+
"pda": {
|
|
1406
|
+
"seeds": [
|
|
1407
|
+
{
|
|
1408
|
+
"kind": "account",
|
|
1409
|
+
"path": "stake_vault"
|
|
1410
|
+
},
|
|
1411
|
+
{
|
|
1412
|
+
"kind": "account",
|
|
1413
|
+
"path": "token_program"
|
|
1414
|
+
},
|
|
1415
|
+
{
|
|
1416
|
+
"kind": "account",
|
|
1417
|
+
"path": "nft_mint"
|
|
1418
|
+
}
|
|
1419
|
+
],
|
|
1420
|
+
"program": {
|
|
1421
|
+
"kind": "const",
|
|
1422
|
+
"value": [
|
|
1423
|
+
140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
|
|
1424
|
+
13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
|
|
1425
|
+
219, 233, 248, 89
|
|
1426
|
+
]
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
},
|
|
1430
|
+
{
|
|
1431
|
+
"name": "nft_to_ata",
|
|
1432
|
+
"writable": true,
|
|
1433
|
+
"pda": {
|
|
1434
|
+
"seeds": [
|
|
1435
|
+
{
|
|
1436
|
+
"kind": "account",
|
|
1437
|
+
"path": "user"
|
|
1438
|
+
},
|
|
1439
|
+
{
|
|
1440
|
+
"kind": "account",
|
|
1441
|
+
"path": "token_program"
|
|
1442
|
+
},
|
|
1443
|
+
{
|
|
1444
|
+
"kind": "account",
|
|
1445
|
+
"path": "nft_mint"
|
|
1446
|
+
}
|
|
1447
|
+
],
|
|
1448
|
+
"program": {
|
|
1449
|
+
"kind": "const",
|
|
1450
|
+
"value": [
|
|
1451
|
+
140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
|
|
1452
|
+
13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
|
|
1453
|
+
219, 233, 248, 89
|
|
1454
|
+
]
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
},
|
|
1458
|
+
{
|
|
1459
|
+
"name": "token_from_ata",
|
|
1460
|
+
"writable": true,
|
|
1461
|
+
"pda": {
|
|
1462
|
+
"seeds": [
|
|
1463
|
+
{
|
|
1464
|
+
"kind": "account",
|
|
1465
|
+
"path": "stake_vault"
|
|
1466
|
+
},
|
|
1467
|
+
{
|
|
1468
|
+
"kind": "account",
|
|
1469
|
+
"path": "token_program"
|
|
1470
|
+
},
|
|
1471
|
+
{
|
|
1472
|
+
"kind": "account",
|
|
1473
|
+
"path": "token_mint"
|
|
1474
|
+
}
|
|
1475
|
+
],
|
|
1476
|
+
"program": {
|
|
1477
|
+
"kind": "const",
|
|
1478
|
+
"value": [
|
|
1479
|
+
140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
|
|
1480
|
+
13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
|
|
1481
|
+
219, 233, 248, 89
|
|
1482
|
+
]
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
},
|
|
1486
|
+
{
|
|
1487
|
+
"name": "token_to_ata",
|
|
1488
|
+
"writable": true,
|
|
1489
|
+
"pda": {
|
|
1490
|
+
"seeds": [
|
|
1491
|
+
{
|
|
1492
|
+
"kind": "account",
|
|
1493
|
+
"path": "user"
|
|
1494
|
+
},
|
|
1495
|
+
{
|
|
1496
|
+
"kind": "account",
|
|
1497
|
+
"path": "token_program"
|
|
1498
|
+
},
|
|
1499
|
+
{
|
|
1500
|
+
"kind": "account",
|
|
1501
|
+
"path": "token_mint"
|
|
1502
|
+
}
|
|
1503
|
+
],
|
|
1504
|
+
"program": {
|
|
1505
|
+
"kind": "const",
|
|
1506
|
+
"value": [
|
|
1507
|
+
140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142,
|
|
1508
|
+
13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216,
|
|
1509
|
+
219, 233, 248, 89
|
|
1510
|
+
]
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
},
|
|
1514
|
+
{
|
|
1515
|
+
"name": "token_program",
|
|
1516
|
+
"address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
|
|
1517
|
+
},
|
|
1518
|
+
{
|
|
1519
|
+
"name": "associated_token_program",
|
|
1520
|
+
"address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
|
|
1521
|
+
},
|
|
1522
|
+
{
|
|
1523
|
+
"name": "system_program",
|
|
1524
|
+
"address": "11111111111111111111111111111111"
|
|
1525
|
+
}
|
|
1526
|
+
],
|
|
1527
|
+
"args": [
|
|
1528
|
+
{
|
|
1529
|
+
"name": "rank",
|
|
1530
|
+
"type": "u16"
|
|
1531
|
+
},
|
|
1532
|
+
{
|
|
1533
|
+
"name": "collections",
|
|
1534
|
+
"type": "f64"
|
|
1535
|
+
}
|
|
1536
|
+
]
|
|
1537
|
+
},
|
|
1393
1538
|
{
|
|
1394
1539
|
"name": "withdraw_stake",
|
|
1395
1540
|
"discriminator": [153, 8, 22, 138, 105, 176, 87, 66],
|
|
@@ -1851,10 +1996,6 @@
|
|
|
1851
1996
|
"type": {
|
|
1852
1997
|
"kind": "struct",
|
|
1853
1998
|
"fields": [
|
|
1854
|
-
{
|
|
1855
|
-
"name": "name",
|
|
1856
|
-
"type": "string"
|
|
1857
|
-
},
|
|
1858
1999
|
{
|
|
1859
2000
|
"name": "market_id",
|
|
1860
2001
|
"type": "u64"
|
|
@@ -2913,24 +3054,10 @@
|
|
|
2913
3054
|
"type": "string"
|
|
2914
3055
|
},
|
|
2915
3056
|
{
|
|
2916
|
-
"name": "
|
|
2917
|
-
"type":
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
"name": "swaps_made",
|
|
2921
|
-
"type": "i16"
|
|
2922
|
-
},
|
|
2923
|
-
{
|
|
2924
|
-
"name": "staked",
|
|
2925
|
-
"type": "u64"
|
|
2926
|
-
},
|
|
2927
|
-
{
|
|
2928
|
-
"name": "first_swap",
|
|
2929
|
-
"type": "i64"
|
|
2930
|
-
},
|
|
2931
|
-
{
|
|
2932
|
-
"name": "user_trade",
|
|
2933
|
-
"type": "pubkey"
|
|
3057
|
+
"name": "padding",
|
|
3058
|
+
"type": {
|
|
3059
|
+
"array": ["u8", 50]
|
|
3060
|
+
}
|
|
2934
3061
|
}
|
|
2935
3062
|
]
|
|
2936
3063
|
}
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/trade.d.ts
CHANGED
|
@@ -1789,26 +1789,6 @@ export type TriadProtocol = {
|
|
|
1789
1789
|
}
|
|
1790
1790
|
];
|
|
1791
1791
|
},
|
|
1792
|
-
{
|
|
1793
|
-
name: 'updateStakeBoost';
|
|
1794
|
-
discriminator: [239, 85, 19, 140, 235, 236, 88, 70];
|
|
1795
|
-
accounts: [
|
|
1796
|
-
{
|
|
1797
|
-
name: 'signer';
|
|
1798
|
-
writable: true;
|
|
1799
|
-
signer: true;
|
|
1800
|
-
},
|
|
1801
|
-
{
|
|
1802
|
-
name: 'stake';
|
|
1803
|
-
writable: true;
|
|
1804
|
-
},
|
|
1805
|
-
{
|
|
1806
|
-
name: 'systemProgram';
|
|
1807
|
-
address: '11111111111111111111111111111111';
|
|
1808
|
-
}
|
|
1809
|
-
];
|
|
1810
|
-
args: [];
|
|
1811
|
-
},
|
|
1812
1792
|
{
|
|
1813
1793
|
name: 'updateStakeVault';
|
|
1814
1794
|
discriminator: [84, 171, 100, 153, 126, 215, 229, 68];
|
|
@@ -1976,6 +1956,287 @@ export type TriadProtocol = {
|
|
|
1976
1956
|
}
|
|
1977
1957
|
];
|
|
1978
1958
|
},
|
|
1959
|
+
{
|
|
1960
|
+
name: 'withdrawNft';
|
|
1961
|
+
discriminator: [142, 181, 191, 149, 82, 175, 216, 100];
|
|
1962
|
+
accounts: [
|
|
1963
|
+
{
|
|
1964
|
+
name: 'signer';
|
|
1965
|
+
writable: true;
|
|
1966
|
+
signer: true;
|
|
1967
|
+
},
|
|
1968
|
+
{
|
|
1969
|
+
name: 'stakeVault';
|
|
1970
|
+
writable: true;
|
|
1971
|
+
},
|
|
1972
|
+
{
|
|
1973
|
+
name: 'user';
|
|
1974
|
+
writable: true;
|
|
1975
|
+
},
|
|
1976
|
+
{
|
|
1977
|
+
name: 'stake';
|
|
1978
|
+
writable: true;
|
|
1979
|
+
},
|
|
1980
|
+
{
|
|
1981
|
+
name: 'nftMint';
|
|
1982
|
+
writable: true;
|
|
1983
|
+
},
|
|
1984
|
+
{
|
|
1985
|
+
name: 'tokenMint';
|
|
1986
|
+
writable: true;
|
|
1987
|
+
},
|
|
1988
|
+
{
|
|
1989
|
+
name: 'nftFromAta';
|
|
1990
|
+
writable: true;
|
|
1991
|
+
pda: {
|
|
1992
|
+
seeds: [
|
|
1993
|
+
{
|
|
1994
|
+
kind: 'account';
|
|
1995
|
+
path: 'stakeVault';
|
|
1996
|
+
},
|
|
1997
|
+
{
|
|
1998
|
+
kind: 'account';
|
|
1999
|
+
path: 'tokenProgram';
|
|
2000
|
+
},
|
|
2001
|
+
{
|
|
2002
|
+
kind: 'account';
|
|
2003
|
+
path: 'nftMint';
|
|
2004
|
+
}
|
|
2005
|
+
];
|
|
2006
|
+
program: {
|
|
2007
|
+
kind: 'const';
|
|
2008
|
+
value: [
|
|
2009
|
+
140,
|
|
2010
|
+
151,
|
|
2011
|
+
37,
|
|
2012
|
+
143,
|
|
2013
|
+
78,
|
|
2014
|
+
36,
|
|
2015
|
+
137,
|
|
2016
|
+
241,
|
|
2017
|
+
187,
|
|
2018
|
+
61,
|
|
2019
|
+
16,
|
|
2020
|
+
41,
|
|
2021
|
+
20,
|
|
2022
|
+
142,
|
|
2023
|
+
13,
|
|
2024
|
+
131,
|
|
2025
|
+
11,
|
|
2026
|
+
90,
|
|
2027
|
+
19,
|
|
2028
|
+
153,
|
|
2029
|
+
218,
|
|
2030
|
+
255,
|
|
2031
|
+
16,
|
|
2032
|
+
132,
|
|
2033
|
+
4,
|
|
2034
|
+
142,
|
|
2035
|
+
123,
|
|
2036
|
+
216,
|
|
2037
|
+
219,
|
|
2038
|
+
233,
|
|
2039
|
+
248,
|
|
2040
|
+
89
|
|
2041
|
+
];
|
|
2042
|
+
};
|
|
2043
|
+
};
|
|
2044
|
+
},
|
|
2045
|
+
{
|
|
2046
|
+
name: 'nftToAta';
|
|
2047
|
+
writable: true;
|
|
2048
|
+
pda: {
|
|
2049
|
+
seeds: [
|
|
2050
|
+
{
|
|
2051
|
+
kind: 'account';
|
|
2052
|
+
path: 'user';
|
|
2053
|
+
},
|
|
2054
|
+
{
|
|
2055
|
+
kind: 'account';
|
|
2056
|
+
path: 'tokenProgram';
|
|
2057
|
+
},
|
|
2058
|
+
{
|
|
2059
|
+
kind: 'account';
|
|
2060
|
+
path: 'nftMint';
|
|
2061
|
+
}
|
|
2062
|
+
];
|
|
2063
|
+
program: {
|
|
2064
|
+
kind: 'const';
|
|
2065
|
+
value: [
|
|
2066
|
+
140,
|
|
2067
|
+
151,
|
|
2068
|
+
37,
|
|
2069
|
+
143,
|
|
2070
|
+
78,
|
|
2071
|
+
36,
|
|
2072
|
+
137,
|
|
2073
|
+
241,
|
|
2074
|
+
187,
|
|
2075
|
+
61,
|
|
2076
|
+
16,
|
|
2077
|
+
41,
|
|
2078
|
+
20,
|
|
2079
|
+
142,
|
|
2080
|
+
13,
|
|
2081
|
+
131,
|
|
2082
|
+
11,
|
|
2083
|
+
90,
|
|
2084
|
+
19,
|
|
2085
|
+
153,
|
|
2086
|
+
218,
|
|
2087
|
+
255,
|
|
2088
|
+
16,
|
|
2089
|
+
132,
|
|
2090
|
+
4,
|
|
2091
|
+
142,
|
|
2092
|
+
123,
|
|
2093
|
+
216,
|
|
2094
|
+
219,
|
|
2095
|
+
233,
|
|
2096
|
+
248,
|
|
2097
|
+
89
|
|
2098
|
+
];
|
|
2099
|
+
};
|
|
2100
|
+
};
|
|
2101
|
+
},
|
|
2102
|
+
{
|
|
2103
|
+
name: 'tokenFromAta';
|
|
2104
|
+
writable: true;
|
|
2105
|
+
pda: {
|
|
2106
|
+
seeds: [
|
|
2107
|
+
{
|
|
2108
|
+
kind: 'account';
|
|
2109
|
+
path: 'stakeVault';
|
|
2110
|
+
},
|
|
2111
|
+
{
|
|
2112
|
+
kind: 'account';
|
|
2113
|
+
path: 'tokenProgram';
|
|
2114
|
+
},
|
|
2115
|
+
{
|
|
2116
|
+
kind: 'account';
|
|
2117
|
+
path: 'tokenMint';
|
|
2118
|
+
}
|
|
2119
|
+
];
|
|
2120
|
+
program: {
|
|
2121
|
+
kind: 'const';
|
|
2122
|
+
value: [
|
|
2123
|
+
140,
|
|
2124
|
+
151,
|
|
2125
|
+
37,
|
|
2126
|
+
143,
|
|
2127
|
+
78,
|
|
2128
|
+
36,
|
|
2129
|
+
137,
|
|
2130
|
+
241,
|
|
2131
|
+
187,
|
|
2132
|
+
61,
|
|
2133
|
+
16,
|
|
2134
|
+
41,
|
|
2135
|
+
20,
|
|
2136
|
+
142,
|
|
2137
|
+
13,
|
|
2138
|
+
131,
|
|
2139
|
+
11,
|
|
2140
|
+
90,
|
|
2141
|
+
19,
|
|
2142
|
+
153,
|
|
2143
|
+
218,
|
|
2144
|
+
255,
|
|
2145
|
+
16,
|
|
2146
|
+
132,
|
|
2147
|
+
4,
|
|
2148
|
+
142,
|
|
2149
|
+
123,
|
|
2150
|
+
216,
|
|
2151
|
+
219,
|
|
2152
|
+
233,
|
|
2153
|
+
248,
|
|
2154
|
+
89
|
|
2155
|
+
];
|
|
2156
|
+
};
|
|
2157
|
+
};
|
|
2158
|
+
},
|
|
2159
|
+
{
|
|
2160
|
+
name: 'tokenToAta';
|
|
2161
|
+
writable: true;
|
|
2162
|
+
pda: {
|
|
2163
|
+
seeds: [
|
|
2164
|
+
{
|
|
2165
|
+
kind: 'account';
|
|
2166
|
+
path: 'user';
|
|
2167
|
+
},
|
|
2168
|
+
{
|
|
2169
|
+
kind: 'account';
|
|
2170
|
+
path: 'tokenProgram';
|
|
2171
|
+
},
|
|
2172
|
+
{
|
|
2173
|
+
kind: 'account';
|
|
2174
|
+
path: 'tokenMint';
|
|
2175
|
+
}
|
|
2176
|
+
];
|
|
2177
|
+
program: {
|
|
2178
|
+
kind: 'const';
|
|
2179
|
+
value: [
|
|
2180
|
+
140,
|
|
2181
|
+
151,
|
|
2182
|
+
37,
|
|
2183
|
+
143,
|
|
2184
|
+
78,
|
|
2185
|
+
36,
|
|
2186
|
+
137,
|
|
2187
|
+
241,
|
|
2188
|
+
187,
|
|
2189
|
+
61,
|
|
2190
|
+
16,
|
|
2191
|
+
41,
|
|
2192
|
+
20,
|
|
2193
|
+
142,
|
|
2194
|
+
13,
|
|
2195
|
+
131,
|
|
2196
|
+
11,
|
|
2197
|
+
90,
|
|
2198
|
+
19,
|
|
2199
|
+
153,
|
|
2200
|
+
218,
|
|
2201
|
+
255,
|
|
2202
|
+
16,
|
|
2203
|
+
132,
|
|
2204
|
+
4,
|
|
2205
|
+
142,
|
|
2206
|
+
123,
|
|
2207
|
+
216,
|
|
2208
|
+
219,
|
|
2209
|
+
233,
|
|
2210
|
+
248,
|
|
2211
|
+
89
|
|
2212
|
+
];
|
|
2213
|
+
};
|
|
2214
|
+
};
|
|
2215
|
+
},
|
|
2216
|
+
{
|
|
2217
|
+
name: 'tokenProgram';
|
|
2218
|
+
address: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb';
|
|
2219
|
+
},
|
|
2220
|
+
{
|
|
2221
|
+
name: 'associatedTokenProgram';
|
|
2222
|
+
address: 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';
|
|
2223
|
+
},
|
|
2224
|
+
{
|
|
2225
|
+
name: 'systemProgram';
|
|
2226
|
+
address: '11111111111111111111111111111111';
|
|
2227
|
+
}
|
|
2228
|
+
];
|
|
2229
|
+
args: [
|
|
2230
|
+
{
|
|
2231
|
+
name: 'rank';
|
|
2232
|
+
type: 'u16';
|
|
2233
|
+
},
|
|
2234
|
+
{
|
|
2235
|
+
name: 'collections';
|
|
2236
|
+
type: 'f64';
|
|
2237
|
+
}
|
|
2238
|
+
];
|
|
2239
|
+
},
|
|
1979
2240
|
{
|
|
1980
2241
|
name: 'withdrawStake';
|
|
1981
2242
|
discriminator: [153, 8, 22, 138, 105, 176, 87, 66];
|
|
@@ -2495,10 +2756,6 @@ export type TriadProtocol = {
|
|
|
2495
2756
|
type: {
|
|
2496
2757
|
kind: 'struct';
|
|
2497
2758
|
fields: [
|
|
2498
|
-
{
|
|
2499
|
-
name: 'name';
|
|
2500
|
-
type: 'string';
|
|
2501
|
-
},
|
|
2502
2759
|
{
|
|
2503
2760
|
name: 'marketId';
|
|
2504
2761
|
type: 'u64';
|
|
@@ -3553,24 +3810,10 @@ export type TriadProtocol = {
|
|
|
3553
3810
|
type: 'string';
|
|
3554
3811
|
},
|
|
3555
3812
|
{
|
|
3556
|
-
name: '
|
|
3557
|
-
type:
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
name: 'swapsMade';
|
|
3561
|
-
type: 'i16';
|
|
3562
|
-
},
|
|
3563
|
-
{
|
|
3564
|
-
name: 'staked';
|
|
3565
|
-
type: 'u64';
|
|
3566
|
-
},
|
|
3567
|
-
{
|
|
3568
|
-
name: 'firstSwap';
|
|
3569
|
-
type: 'i64';
|
|
3570
|
-
},
|
|
3571
|
-
{
|
|
3572
|
-
name: 'userTrade';
|
|
3573
|
-
type: 'pubkey';
|
|
3813
|
+
name: 'padding';
|
|
3814
|
+
type: {
|
|
3815
|
+
array: ['u8', 50];
|
|
3816
|
+
};
|
|
3574
3817
|
}
|
|
3575
3818
|
];
|
|
3576
3819
|
};
|
package/dist/utils/helpers.js
CHANGED
|
@@ -3,9 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.accountToMarketV1 = exports.formatMarket = exports.formatUser = exports.formatStake = exports.formatStakeVault = exports.decodeString = exports.encodeString = void 0;
|
|
4
4
|
const trade_1 = require("../types/trade");
|
|
5
5
|
const encodeString = (value, alloc = 32) => {
|
|
6
|
-
const buffer = Buffer.alloc(alloc);
|
|
7
|
-
buffer.
|
|
8
|
-
buffer.fill(' ', value.length);
|
|
6
|
+
const buffer = Buffer.alloc(alloc, 32);
|
|
7
|
+
buffer.write(value);
|
|
9
8
|
return Array(...buffer);
|
|
10
9
|
};
|
|
11
10
|
exports.encodeString = encodeString;
|
|
@@ -56,9 +55,6 @@ const formatUser = (user) => {
|
|
|
56
55
|
authority: user.authority.toBase58(),
|
|
57
56
|
referral: user.referral,
|
|
58
57
|
referred: user.referred.toNumber(),
|
|
59
|
-
swapsMade: user.swapsMade,
|
|
60
|
-
swaps: user.swaps,
|
|
61
|
-
staked: user.staked.toNumber(),
|
|
62
58
|
name: user.name
|
|
63
59
|
};
|
|
64
60
|
};
|