@triadxyz/triad-protocol 1.1.2-beta → 1.1.4-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 +1 -2
- package/dist/index.js +3 -2
- package/dist/local-test.js +26 -2
- package/dist/stake.d.ts +2 -2
- package/dist/stake.js +17 -10
- package/dist/types/stake.d.ts +4 -2
- package/dist/types/trade.d.ts +0 -1
- package/dist/utils/helpers.js +0 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -78,9 +78,8 @@ export default class TriadProtocolClient {
|
|
|
78
78
|
pnl: import("bn.js");
|
|
79
79
|
}[];
|
|
80
80
|
}[]>;
|
|
81
|
-
withdrawV1({ wallet, ticker,
|
|
81
|
+
withdrawV1({ wallet, ticker, positionIndex }: {
|
|
82
82
|
wallet: PublicKey;
|
|
83
|
-
userPosition: PublicKey;
|
|
84
83
|
ticker: PublicKey;
|
|
85
84
|
positionIndex: number;
|
|
86
85
|
}, options?: RpcOptions): Promise<any>;
|
package/dist/index.js
CHANGED
|
@@ -143,14 +143,15 @@ class TriadProtocolClient {
|
|
|
143
143
|
parseFloat(item.totalWithdrawn.toString()));
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
|
-
withdrawV1({ wallet, ticker,
|
|
146
|
+
withdrawV1({ wallet, ticker, positionIndex }, options) {
|
|
147
147
|
return __awaiter(this, void 0, void 0, function* () {
|
|
148
148
|
const vaultPDA = (0, pda_1.getVaultAddressSync)(this.program.programId, ticker);
|
|
149
|
+
const userPositionPDA = (0, pda_1.getUserPositionPDA)(this.program.programId, wallet, ticker);
|
|
149
150
|
const VaultTokenAccountPDA = (0, pda_1.getTokenVaultAddressSync)(this.program.programId, vaultPDA);
|
|
150
151
|
const userTokenAccount = yield (0, spl_token_1.getAssociatedTokenAddress)(new web3_js_1.PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'), this.provider.wallet.publicKey);
|
|
151
152
|
return (0, sendTransactionWithOptions_1.default)(this.program.methods.withdrawV1(positionIndex).accounts({
|
|
152
153
|
signer: wallet,
|
|
153
|
-
userPosition,
|
|
154
|
+
userPosition: userPositionPDA,
|
|
154
155
|
userTokenAccount,
|
|
155
156
|
vault: vaultPDA,
|
|
156
157
|
ticker,
|
package/dist/local-test.js
CHANGED
|
@@ -17,6 +17,9 @@ 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");
|
|
21
|
+
const constants_1 = require("./utils/constants");
|
|
22
|
+
const pda_1 = require("./utils/pda");
|
|
20
23
|
const file = fs_1.default.readFileSync('/Users/dannpl/.config/solana/triad.json');
|
|
21
24
|
const rpc_file = fs_1.default.readFileSync('/Users/dannpl/.config/solana/rpc.txt');
|
|
22
25
|
const keypair = web3_js_1.Keypair.fromSecretKey(new Uint8Array(JSON.parse(file.toString())));
|
|
@@ -74,6 +77,7 @@ const getAllMarkets = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
74
77
|
const markets = yield triadProtocol.trade.getAllMarkets();
|
|
75
78
|
console.log(markets);
|
|
76
79
|
});
|
|
80
|
+
getAllMarkets();
|
|
77
81
|
const getMarket = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
78
82
|
const market = yield triadProtocol.trade.getMarketById(1);
|
|
79
83
|
console.log(market);
|
|
@@ -165,7 +169,27 @@ const getReferral = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
165
169
|
console.log(response);
|
|
166
170
|
});
|
|
167
171
|
const getUserPositions = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
168
|
-
const response = yield triadProtocol.getUserPositionsWithAmount(
|
|
172
|
+
const response = yield triadProtocol.getUserPositionsWithAmount(new web3_js_1.PublicKey('5U4TmSUBqDaefmamimoSGak8GK5xwXoM5nAaCZJpynpL'));
|
|
169
173
|
console.log(response);
|
|
170
174
|
});
|
|
171
|
-
|
|
175
|
+
const getTickers = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
176
|
+
const response = yield triadProtocol.getTickers();
|
|
177
|
+
console.log(response);
|
|
178
|
+
});
|
|
179
|
+
// Claim 3 TRD
|
|
180
|
+
const claim3Trd = (user) => __awaiter(void 0, void 0, void 0, function* () {
|
|
181
|
+
const adminATA = (0, pda_1.getTokenATA)(keypair.publicKey, constants_1.TRD_MINT);
|
|
182
|
+
const userATA = (0, pda_1.getTokenATA)(user, constants_1.TRD_MINT);
|
|
183
|
+
const ixs = [
|
|
184
|
+
(0, spl_token_1.createAssociatedTokenAccountIdempotentInstruction)(user, userATA, user, constants_1.TRD_MINT, spl_token_1.TOKEN_2022_PROGRAM_ID),
|
|
185
|
+
(0, spl_token_1.createTransferCheckedInstruction)(adminATA, constants_1.TRD_MINT, userATA, keypair.publicKey, 3 * Math.pow(10, 6), constants_1.TRD_DECIMALS, [], spl_token_1.TOKEN_2022_PROGRAM_ID)
|
|
186
|
+
];
|
|
187
|
+
const tx = new web3_js_1.Transaction().add(...ixs);
|
|
188
|
+
tx.recentBlockhash = (yield connection.getLatestBlockhash()).blockhash;
|
|
189
|
+
tx.feePayer = user;
|
|
190
|
+
tx.sign(keypair);
|
|
191
|
+
// add wallet as signer FE
|
|
192
|
+
const signature = yield connection.sendRawTransaction(tx.serialize());
|
|
193
|
+
console.log(signature);
|
|
194
|
+
});
|
|
195
|
+
claim3Trd(new web3_js_1.PublicKey('FbegLWayrXB7pEhtNXqzLQ8KWcWALpfwetf65oBodAsc'));
|
package/dist/stake.d.ts
CHANGED
|
@@ -61,10 +61,10 @@ export default class Stake {
|
|
|
61
61
|
/**
|
|
62
62
|
* Request Withdraw
|
|
63
63
|
* @param wallet - User wallet
|
|
64
|
-
* @param
|
|
64
|
+
* @param nfts - NFTs to Request withdraw
|
|
65
65
|
*
|
|
66
66
|
*/
|
|
67
|
-
requestWithdraw({ wallet,
|
|
67
|
+
requestWithdraw({ wallet, nfts }: RequestWithdrawArgs, options?: RpcOptions): Promise<string>;
|
|
68
68
|
/**
|
|
69
69
|
* Withdraw Stake
|
|
70
70
|
* @param wallet - User wallet
|
package/dist/stake.js
CHANGED
|
@@ -186,21 +186,28 @@ class Stake {
|
|
|
186
186
|
/**
|
|
187
187
|
* Request Withdraw
|
|
188
188
|
* @param wallet - User wallet
|
|
189
|
-
* @param
|
|
189
|
+
* @param nfts - NFTs to Request withdraw
|
|
190
190
|
*
|
|
191
191
|
*/
|
|
192
|
-
requestWithdraw({ wallet,
|
|
192
|
+
requestWithdraw({ wallet, nfts }, options) {
|
|
193
193
|
return __awaiter(this, void 0, void 0, function* () {
|
|
194
|
+
const ixs = [];
|
|
194
195
|
const stakeVaultPDA = (0, stake_1.getStakeVaultPDA)(this.program.programId, this.stakeVaultName);
|
|
195
|
-
const stakePDA = (0, stake_1.getStakePDA)(this.program.programId, wallet, name);
|
|
196
196
|
const userPDA = (0, pda_1.getUserPDA)(this.program.programId, wallet);
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
197
|
+
for (const nft of nfts) {
|
|
198
|
+
const stakePDA = (0, stake_1.getStakePDA)(this.program.programId, wallet, nft.name);
|
|
199
|
+
ixs.push(yield this.program.methods
|
|
200
|
+
.requestWithdrawStake()
|
|
201
|
+
.accounts({
|
|
202
|
+
signer: wallet,
|
|
203
|
+
mint: nft.mint,
|
|
204
|
+
user: userPDA,
|
|
205
|
+
stake: stakePDA,
|
|
206
|
+
stakeVault: stakeVaultPDA
|
|
207
|
+
})
|
|
208
|
+
.instruction());
|
|
209
|
+
}
|
|
210
|
+
return (0, sendVersionedTransaction_1.default)(this.provider, ixs, options);
|
|
204
211
|
});
|
|
205
212
|
}
|
|
206
213
|
/**
|
package/dist/types/stake.d.ts
CHANGED
|
@@ -26,8 +26,10 @@ export type UpdateStakeVaultArgs = {
|
|
|
26
26
|
};
|
|
27
27
|
export type RequestWithdrawArgs = {
|
|
28
28
|
wallet: PublicKey;
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
nfts: {
|
|
30
|
+
name: string;
|
|
31
|
+
mint: PublicKey;
|
|
32
|
+
}[];
|
|
31
33
|
};
|
|
32
34
|
export type WithdrawArgs = {
|
|
33
35
|
wallet: PublicKey;
|
package/dist/types/trade.d.ts
CHANGED
package/dist/utils/helpers.js
CHANGED
|
@@ -86,7 +86,6 @@ const accountToMarket = (account, address) => {
|
|
|
86
86
|
feeVault: account.feeVault.toBase58(),
|
|
87
87
|
isActive: account.isActive,
|
|
88
88
|
marketPrice: account.marketPrice.toString(),
|
|
89
|
-
isOfficial: account.isOfficial,
|
|
90
89
|
previousResolvedQuestion: accountToResolvedQuestion(account.previousResolvedQuestion),
|
|
91
90
|
currentQuestionId: account.currentQuestionId.toString(),
|
|
92
91
|
currentQuestionStart: account.currentQuestionStart.toString(),
|