@triadxyz/triad-protocol 2.4.8-beta → 2.5.0-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 +8 -1
- package/dist/index.js +24 -22
- package/dist/stake.d.ts +21 -14
- package/dist/stake.js +57 -42
- package/dist/types/idl_triad_protocol.json +492 -33
- package/dist/types/index.d.ts +9 -2
- package/dist/types/stake.d.ts +15 -16
- package/dist/types/triad_protocol.d.ts +731 -120
- package/dist/utils/helpers.d.ts +2 -1
- package/dist/utils/helpers.js +10 -1
- package/dist/utils/pda/stake.d.ts +2 -1
- package/dist/utils/pda/stake.js +6 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -297,7 +297,7 @@ export default class TriadProtocolClient {
|
|
|
297
297
|
* @param options - RPC options
|
|
298
298
|
*
|
|
299
299
|
*/
|
|
300
|
-
createCustomer({ id, name, authority, feeRecipient }: CreateCustomerArgs, options?: RpcOptions): Promise<string>;
|
|
300
|
+
createCustomer({ id, name, authority, feeRecipient, feeBps }: CreateCustomerArgs, options?: RpcOptions): Promise<string>;
|
|
301
301
|
/**
|
|
302
302
|
* Get User Trade Nonce With Slots
|
|
303
303
|
* @param userTrades - User Trades
|
|
@@ -416,4 +416,11 @@ export default class TriadProtocolClient {
|
|
|
416
416
|
* @param options - RPC options
|
|
417
417
|
*/
|
|
418
418
|
closeOrderBook(marketId: number, options?: RpcOptions): Promise<string>;
|
|
419
|
+
/**
|
|
420
|
+
* Create Refer
|
|
421
|
+
* @param id - The ID of the refer
|
|
422
|
+
*
|
|
423
|
+
* @param options - RPC options
|
|
424
|
+
*/
|
|
425
|
+
createRefer(id: number, options?: RpcOptions): Promise<string>;
|
|
419
426
|
}
|
package/dist/index.js
CHANGED
|
@@ -159,12 +159,6 @@ class TriadProtocolClient {
|
|
|
159
159
|
createMarket({ markets, customer, mint, poolId }, options) {
|
|
160
160
|
return __awaiter(this, void 0, void 0, function* () {
|
|
161
161
|
const ixs = [];
|
|
162
|
-
let userTrade = null;
|
|
163
|
-
try {
|
|
164
|
-
yield this.getUserTrade(this.program.provider.publicKey);
|
|
165
|
-
userTrade = (0, pda_1.getUserTradePDA)(this.program.programId, this.program.provider.publicKey);
|
|
166
|
-
}
|
|
167
|
-
catch (_a) { }
|
|
168
162
|
let poolPDA = null;
|
|
169
163
|
if (poolId) {
|
|
170
164
|
poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
|
|
@@ -184,11 +178,9 @@ class TriadProtocolClient {
|
|
|
184
178
|
})
|
|
185
179
|
.accounts({
|
|
186
180
|
signer: this.program.provider.publicKey,
|
|
187
|
-
mint,
|
|
188
181
|
tokenProgram: (0, helpers_1.getTokenProgram)(mint),
|
|
189
182
|
customer,
|
|
190
|
-
pool: poolPDA
|
|
191
|
-
userTrade
|
|
183
|
+
pool: poolPDA
|
|
192
184
|
})
|
|
193
185
|
.instruction());
|
|
194
186
|
ixs.push(yield this.program.methods
|
|
@@ -227,12 +219,6 @@ class TriadProtocolClient {
|
|
|
227
219
|
signer: this.program.provider.publicKey
|
|
228
220
|
})
|
|
229
221
|
.instruction());
|
|
230
|
-
let userTrade = null;
|
|
231
|
-
try {
|
|
232
|
-
yield this.getUserTrade(this.program.provider.publicKey);
|
|
233
|
-
userTrade = (0, pda_1.getUserTradePDA)(this.program.programId, this.program.provider.publicKey);
|
|
234
|
-
}
|
|
235
|
-
catch (_a) { }
|
|
236
222
|
for (const market of markets) {
|
|
237
223
|
if (market.question.length > 80) {
|
|
238
224
|
throw new Error('Market question must be less than 80 characters');
|
|
@@ -248,11 +234,9 @@ class TriadProtocolClient {
|
|
|
248
234
|
})
|
|
249
235
|
.accounts({
|
|
250
236
|
signer: this.program.provider.publicKey,
|
|
251
|
-
mint,
|
|
252
237
|
tokenProgram: (0, helpers_1.getTokenProgram)(mint),
|
|
253
238
|
pool: poolPDA,
|
|
254
|
-
customer
|
|
255
|
-
userTrade
|
|
239
|
+
customer
|
|
256
240
|
})
|
|
257
241
|
.instruction());
|
|
258
242
|
ixs.push(yield this.program.methods
|
|
@@ -511,11 +495,11 @@ class TriadProtocolClient {
|
|
|
511
495
|
* @param options - RPC options
|
|
512
496
|
*
|
|
513
497
|
*/
|
|
514
|
-
createCustomer({ id, name, authority, feeRecipient }, options) {
|
|
498
|
+
createCustomer({ id, name, authority, feeRecipient, feeBps }, options) {
|
|
515
499
|
return __awaiter(this, void 0, void 0, function* () {
|
|
516
500
|
const ixs = [];
|
|
517
501
|
ixs.push(yield this.program.methods
|
|
518
|
-
.createCustomer({ id, name, authority, feeRecipient })
|
|
502
|
+
.createCustomer({ id, name, authority, feeRecipient, feeBps })
|
|
519
503
|
.accounts({
|
|
520
504
|
signer: this.program.provider.publicKey
|
|
521
505
|
})
|
|
@@ -827,7 +811,8 @@ class TriadProtocolClient {
|
|
|
827
811
|
.marketAskOrder({
|
|
828
812
|
shares: new bn_js_1.default(sharesToSell),
|
|
829
813
|
orderDirection: direction,
|
|
830
|
-
bidOrderId: new bn_js_1.default(bidOrderId)
|
|
814
|
+
bidOrderId: new bn_js_1.default(bidOrderId),
|
|
815
|
+
bookOrderBidId: new bn_js_1.default(order.id)
|
|
831
816
|
})
|
|
832
817
|
.accounts({
|
|
833
818
|
signer: this.program.provider.publicKey,
|
|
@@ -902,7 +887,6 @@ class TriadProtocolClient {
|
|
|
902
887
|
.accounts({
|
|
903
888
|
signer: this.program.provider.publicKey,
|
|
904
889
|
market: (0, pda_1.getMarketPDA)(this.program.programId, marketId),
|
|
905
|
-
feeRecipient,
|
|
906
890
|
mint: constants_1.TRD_MINT
|
|
907
891
|
})
|
|
908
892
|
.instruction());
|
|
@@ -929,5 +913,23 @@ class TriadProtocolClient {
|
|
|
929
913
|
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
|
|
930
914
|
});
|
|
931
915
|
}
|
|
916
|
+
/**
|
|
917
|
+
* Create Refer
|
|
918
|
+
* @param id - The ID of the refer
|
|
919
|
+
*
|
|
920
|
+
* @param options - RPC options
|
|
921
|
+
*/
|
|
922
|
+
createRefer(id, options) {
|
|
923
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
924
|
+
const ixs = [];
|
|
925
|
+
ixs.push(yield this.program.methods
|
|
926
|
+
.createRefer(new bn_js_1.default(id))
|
|
927
|
+
.accounts({
|
|
928
|
+
signer: this.program.provider.publicKey
|
|
929
|
+
})
|
|
930
|
+
.instruction());
|
|
931
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
|
|
932
|
+
});
|
|
933
|
+
}
|
|
932
934
|
}
|
|
933
935
|
exports.default = TriadProtocolClient;
|
package/dist/stake.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { 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 {
|
|
5
|
+
import { Stake as StakeType, UpdateStakeVaultArgs, WithdrawArgs } from './types/stake';
|
|
6
6
|
export default class Stake {
|
|
7
7
|
private program;
|
|
8
8
|
constructor(program: Program<TriadProtocol>);
|
|
@@ -15,13 +15,13 @@ export default class Stake {
|
|
|
15
15
|
* Get all Stakes
|
|
16
16
|
*
|
|
17
17
|
*/
|
|
18
|
-
getStakes(): Promise<
|
|
18
|
+
getStakes(): Promise<StakeType[]>;
|
|
19
19
|
/**
|
|
20
20
|
* Get User Stakes By Wallet
|
|
21
21
|
* @param wallet - User wallet
|
|
22
22
|
*
|
|
23
23
|
*/
|
|
24
|
-
getUserStakes(wallet: PublicKey): Promise<
|
|
24
|
+
getUserStakes(wallet: PublicKey): Promise<StakeType[]>;
|
|
25
25
|
/**
|
|
26
26
|
* Get Stake By Wallet
|
|
27
27
|
* @param wallet - User Wallet
|
|
@@ -41,15 +41,13 @@ export default class Stake {
|
|
|
41
41
|
amount: number;
|
|
42
42
|
}[]>;
|
|
43
43
|
/**
|
|
44
|
-
* Stake
|
|
45
|
-
* @param
|
|
46
|
-
* @param args.wallet - User wallet
|
|
47
|
-
* @param args.amount - Amount to stake
|
|
44
|
+
* Stake
|
|
45
|
+
* @param amount - Amount to stake
|
|
48
46
|
*
|
|
49
47
|
* @param options - RPC options
|
|
50
48
|
*
|
|
51
49
|
*/
|
|
52
|
-
stakeToken(
|
|
50
|
+
stakeToken(amount: number, options?: RpcOptions): Promise<string>;
|
|
53
51
|
/**
|
|
54
52
|
* Update Stake Vault
|
|
55
53
|
* @param args.amount - Reward amount to deposit (optional)
|
|
@@ -60,14 +58,13 @@ export default class Stake {
|
|
|
60
58
|
*/
|
|
61
59
|
updateStakeVault({ amount, isLocked }: UpdateStakeVaultArgs, options?: RpcOptions): Promise<string>;
|
|
62
60
|
/**
|
|
63
|
-
* Request
|
|
64
|
-
* @param
|
|
65
|
-
* @param args.nfts - NFTs to Request withdraw
|
|
61
|
+
* Request Unstake
|
|
62
|
+
* @param amount - Amount to unstake
|
|
66
63
|
*
|
|
67
64
|
* @param options - RPC options
|
|
68
65
|
*
|
|
69
66
|
*/
|
|
70
|
-
|
|
67
|
+
requestUnstake(amount: number, options?: RpcOptions): Promise<string>;
|
|
71
68
|
/**
|
|
72
69
|
* Withdraw Stake
|
|
73
70
|
* @param args.wallet - User wallet
|
|
@@ -78,12 +75,22 @@ export default class Stake {
|
|
|
78
75
|
*
|
|
79
76
|
*/
|
|
80
77
|
withdrawStake({ wallet, name, mint }: WithdrawArgs, options?: RpcOptions): Promise<string>;
|
|
78
|
+
/**
|
|
79
|
+
* Unstake Token
|
|
80
|
+
* @param options - RPC options
|
|
81
|
+
*
|
|
82
|
+
*/
|
|
83
|
+
unstakeToken(options?: RpcOptions): Promise<string>;
|
|
81
84
|
/**
|
|
82
85
|
* Claim Stake Rewards
|
|
83
|
-
* @param
|
|
86
|
+
* @param options - RPC options
|
|
84
87
|
*
|
|
88
|
+
*/
|
|
89
|
+
claimStakeRewards(options?: RpcOptions): Promise<string>;
|
|
90
|
+
/**
|
|
91
|
+
* Migrate Stake
|
|
85
92
|
* @param options - RPC options
|
|
86
93
|
*
|
|
87
94
|
*/
|
|
88
|
-
|
|
95
|
+
migrateStake(stakes: StakeType[], options?: RpcOptions): Promise<string>;
|
|
89
96
|
}
|
package/dist/stake.js
CHANGED
|
@@ -13,6 +13,7 @@ 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");
|
|
16
17
|
const helpers_1 = require("./utils/helpers");
|
|
17
18
|
const stake_1 = require("./utils/pda/stake");
|
|
18
19
|
const constants_1 = require("./utils/constants");
|
|
@@ -68,24 +69,20 @@ class Stake {
|
|
|
68
69
|
});
|
|
69
70
|
}
|
|
70
71
|
/**
|
|
71
|
-
* Stake
|
|
72
|
-
* @param
|
|
73
|
-
* @param args.wallet - User wallet
|
|
74
|
-
* @param args.amount - Amount to stake
|
|
72
|
+
* Stake
|
|
73
|
+
* @param amount - Amount to stake
|
|
75
74
|
*
|
|
76
75
|
* @param options - RPC options
|
|
77
76
|
*
|
|
78
77
|
*/
|
|
79
|
-
stakeToken(
|
|
78
|
+
stakeToken(amount, options) {
|
|
80
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
81
80
|
const ixs = [];
|
|
82
81
|
ixs.push(yield this.program.methods
|
|
83
82
|
.stakeToken({
|
|
84
|
-
name,
|
|
85
83
|
amount: new anchor_1.BN(amount * Math.pow(10, 6))
|
|
86
84
|
})
|
|
87
85
|
.accounts({
|
|
88
|
-
signer: wallet,
|
|
89
86
|
mint: constants_1.TRD_MINT
|
|
90
87
|
})
|
|
91
88
|
.instruction());
|
|
@@ -109,7 +106,6 @@ class Stake {
|
|
|
109
106
|
isLocked
|
|
110
107
|
})
|
|
111
108
|
.accounts({
|
|
112
|
-
signer: this.program.provider.publicKey,
|
|
113
109
|
mint: constants_1.TRD_MINT
|
|
114
110
|
})
|
|
115
111
|
.instruction());
|
|
@@ -117,25 +113,25 @@ class Stake {
|
|
|
117
113
|
});
|
|
118
114
|
}
|
|
119
115
|
/**
|
|
120
|
-
* Request
|
|
121
|
-
* @param
|
|
122
|
-
* @param args.nfts - NFTs to Request withdraw
|
|
116
|
+
* Request Unstake
|
|
117
|
+
* @param amount - Amount to unstake
|
|
123
118
|
*
|
|
124
119
|
* @param options - RPC options
|
|
125
120
|
*
|
|
126
121
|
*/
|
|
127
|
-
|
|
122
|
+
requestUnstake(amount, options) {
|
|
128
123
|
return __awaiter(this, void 0, void 0, function* () {
|
|
129
124
|
const ixs = [];
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
125
|
+
ixs.push(yield this.program.methods
|
|
126
|
+
.requestUnstake({
|
|
127
|
+
amount: new anchor_1.BN(amount),
|
|
128
|
+
ts: new anchor_1.BN(Date.now())
|
|
129
|
+
})
|
|
130
|
+
.accounts({
|
|
131
|
+
stake: (0, stake_1.getStakePDA)(this.program.programId, this.program.provider.publicKey),
|
|
132
|
+
mint: constants_1.TRD_MINT
|
|
133
|
+
})
|
|
134
|
+
.instruction());
|
|
139
135
|
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
|
|
140
136
|
});
|
|
141
137
|
}
|
|
@@ -154,43 +150,62 @@ class Stake {
|
|
|
154
150
|
ixs.push(yield this.program.methods
|
|
155
151
|
.withdrawStake()
|
|
156
152
|
.accounts({
|
|
157
|
-
|
|
158
|
-
stake: (0, stake_1.getStakePDA)(this.program.programId, wallet, name),
|
|
159
|
-
admin: constants_1.TRIAD_ADMIN,
|
|
153
|
+
stake: (0, stake_1.getStakeV2PDA)(this.program.programId, wallet, name),
|
|
160
154
|
mint: mint
|
|
161
155
|
})
|
|
162
156
|
.instruction());
|
|
163
157
|
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
|
|
164
158
|
});
|
|
165
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* Unstake Token
|
|
162
|
+
* @param options - RPC options
|
|
163
|
+
*
|
|
164
|
+
*/
|
|
165
|
+
unstakeToken(options) {
|
|
166
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
167
|
+
const ixs = [];
|
|
168
|
+
ixs.push(yield this.program.methods
|
|
169
|
+
.unstakeToken()
|
|
170
|
+
.accounts({
|
|
171
|
+
signer: this.program.provider.publicKey
|
|
172
|
+
})
|
|
173
|
+
.instruction());
|
|
174
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
|
|
175
|
+
});
|
|
176
|
+
}
|
|
166
177
|
/**
|
|
167
178
|
* Claim Stake Rewards
|
|
168
|
-
* @param
|
|
179
|
+
* @param options - RPC options
|
|
169
180
|
*
|
|
181
|
+
*/
|
|
182
|
+
claimStakeRewards(options) {
|
|
183
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
184
|
+
const ixs = [];
|
|
185
|
+
ixs.push(yield this.program.methods
|
|
186
|
+
.claimStakeRewards()
|
|
187
|
+
.accounts({
|
|
188
|
+
mint: constants_1.TRD_MINT,
|
|
189
|
+
stake: (0, stake_1.getStakePDA)(this.program.programId, this.program.provider.publicKey)
|
|
190
|
+
})
|
|
191
|
+
.instruction());
|
|
192
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Migrate Stake
|
|
170
197
|
* @param options - RPC options
|
|
171
198
|
*
|
|
172
199
|
*/
|
|
173
|
-
|
|
200
|
+
migrateStake(stakes, options) {
|
|
174
201
|
return __awaiter(this, void 0, void 0, function* () {
|
|
175
|
-
const stakes = (yield this.getUserStakes(wallet)).sort((a, b) => a.claimedTs - b.claimedTs);
|
|
176
202
|
const ixs = [];
|
|
177
|
-
|
|
178
|
-
stakes.forEach((stake) => {
|
|
179
|
-
if (stake.withdrawTs !== 0) {
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
items.push(stake);
|
|
183
|
-
});
|
|
184
|
-
for (const stake of items) {
|
|
185
|
-
if (ixs.length >= 10) {
|
|
186
|
-
break;
|
|
187
|
-
}
|
|
203
|
+
for (const stake of stakes) {
|
|
188
204
|
ixs.push(yield this.program.methods
|
|
189
|
-
.
|
|
205
|
+
.migrateStake()
|
|
190
206
|
.accounts({
|
|
191
|
-
|
|
192
|
-
mint: constants_1.TRD_MINT
|
|
193
|
-
stake: (0, stake_1.getStakePDA)(this.program.programId, wallet, stake.name)
|
|
207
|
+
stakeV2: (0, stake_1.getStakeV2PDA)(this.program.programId, new web3_js_1.PublicKey(stake.authority), stake.name),
|
|
208
|
+
mint: constants_1.TRD_MINT
|
|
194
209
|
})
|
|
195
210
|
.instruction());
|
|
196
211
|
}
|