@triadxyz/triad-protocol 1.6.7-beta-dev → 1.6.8-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.
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -2
- package/dist/stake.d.ts +1 -9
- package/dist/stake.js +4 -10
- package/dist/trade.d.ts +55 -41
- package/dist/trade.js +242 -80
- package/dist/types/idl_triad_protocol.json +392 -590
- package/dist/types/trade.d.ts +72 -36
- package/dist/types/trade.js +25 -1
- package/dist/types/triad_protocol.d.ts +370 -626
- package/dist/utils/constants.d.ts +1 -0
- package/dist/utils/constants.js +2 -1
- package/dist/utils/helpers.d.ts +31 -3
- package/dist/utils/helpers.js +64 -18
- package/package.json +1 -1
- package/dist/wheel.d.ts +0 -62
- package/dist/wheel.js +0 -149
package/dist/index.d.ts
CHANGED
|
@@ -4,13 +4,11 @@ import { TriadProtocol } from './types/triad_protocol';
|
|
|
4
4
|
import Trade from './trade';
|
|
5
5
|
import Stake from './stake';
|
|
6
6
|
import { RpcOptions, TransferPoseidonArgs } from './types';
|
|
7
|
-
import Wheel from './wheel';
|
|
8
7
|
export default class TriadProtocolClient {
|
|
9
8
|
program: Program<TriadProtocol>;
|
|
10
9
|
provider: AnchorProvider;
|
|
11
10
|
trade: Trade;
|
|
12
11
|
stake: Stake;
|
|
13
|
-
wheel: Wheel;
|
|
14
12
|
constructor(connection: Connection, wallet: Wallet);
|
|
15
13
|
/**
|
|
16
14
|
* Transfer Poseidon
|
package/dist/index.js
CHANGED
|
@@ -20,7 +20,6 @@ const stake_1 = __importDefault(require("./stake"));
|
|
|
20
20
|
const sendVersionedTransaction_1 = __importDefault(require("./utils/sendVersionedTransaction"));
|
|
21
21
|
const constants_1 = require("./utils/constants");
|
|
22
22
|
const sendTransactionWithOptions_1 = __importDefault(require("./utils/sendTransactionWithOptions"));
|
|
23
|
-
const wheel_1 = __importDefault(require("./wheel"));
|
|
24
23
|
class TriadProtocolClient {
|
|
25
24
|
constructor(connection, wallet) {
|
|
26
25
|
this.provider = new anchor_1.AnchorProvider(connection, wallet, {
|
|
@@ -29,7 +28,6 @@ class TriadProtocolClient {
|
|
|
29
28
|
this.program = new anchor_1.Program(idl_triad_protocol_json_1.default, this.provider);
|
|
30
29
|
this.trade = new trade_1.default(this.program, this.provider);
|
|
31
30
|
this.stake = new stake_1.default(this.program, this.provider);
|
|
32
|
-
this.wheel = new wheel_1.default(this.program, this.provider);
|
|
33
31
|
}
|
|
34
32
|
/**
|
|
35
33
|
* Transfer Poseidon
|
package/dist/stake.d.ts
CHANGED
|
@@ -72,20 +72,12 @@ export default class Stake {
|
|
|
72
72
|
* Claim Stake Rewards
|
|
73
73
|
* @param args.wallet - User wallet
|
|
74
74
|
* @param args.collections - NFT collections
|
|
75
|
-
* @param args.ranks - Tensor ranks
|
|
76
75
|
* @param args.verifier - Verifier
|
|
77
76
|
*
|
|
78
77
|
* @param options - RPC options
|
|
79
78
|
*
|
|
80
79
|
*/
|
|
81
|
-
claimStakeRewards({ wallet
|
|
80
|
+
claimStakeRewards({ wallet }: {
|
|
82
81
|
wallet: PublicKey;
|
|
83
|
-
collections: number;
|
|
84
|
-
ranks: {
|
|
85
|
-
onchainId: string;
|
|
86
|
-
name: string;
|
|
87
|
-
rarityRankHrtt: number;
|
|
88
|
-
}[];
|
|
89
|
-
verifier: string;
|
|
90
82
|
}, options?: RpcOptions): Promise<string>;
|
|
91
83
|
}
|
package/dist/stake.js
CHANGED
|
@@ -18,7 +18,6 @@ const stake_1 = require("./utils/pda/stake");
|
|
|
18
18
|
const constants_1 = require("./utils/constants");
|
|
19
19
|
const sendVersionedTransaction_1 = __importDefault(require("./utils/sendVersionedTransaction"));
|
|
20
20
|
const sendTransactionWithOptions_1 = __importDefault(require("./utils/sendTransactionWithOptions"));
|
|
21
|
-
const convertSecretKeyToKeypair_1 = require("./utils/convertSecretKeyToKeypair");
|
|
22
21
|
class Stake {
|
|
23
22
|
constructor(program, provider) {
|
|
24
23
|
this.program = program;
|
|
@@ -175,13 +174,12 @@ class Stake {
|
|
|
175
174
|
* Claim Stake Rewards
|
|
176
175
|
* @param args.wallet - User wallet
|
|
177
176
|
* @param args.collections - NFT collections
|
|
178
|
-
* @param args.ranks - Tensor ranks
|
|
179
177
|
* @param args.verifier - Verifier
|
|
180
178
|
*
|
|
181
179
|
* @param options - RPC options
|
|
182
180
|
*
|
|
183
181
|
*/
|
|
184
|
-
claimStakeRewards({ wallet
|
|
182
|
+
claimStakeRewards({ wallet }, options) {
|
|
185
183
|
return __awaiter(this, void 0, void 0, function* () {
|
|
186
184
|
const stakes = (yield this.getUserStakes(wallet)).sort((a, b) => a.claimedTs - b.claimedTs);
|
|
187
185
|
const ixs = [];
|
|
@@ -199,20 +197,16 @@ class Stake {
|
|
|
199
197
|
const stakeVaultPDA = (0, stake_1.getStakeVaultPDA)(this.program.programId, constants_1.STAKE_VAULT_NAME);
|
|
200
198
|
const stakePDA = (0, stake_1.getStakePDA)(this.program.programId, wallet, stake.name);
|
|
201
199
|
ixs.push(yield this.program.methods
|
|
202
|
-
.claimStakeRewards(
|
|
203
|
-
collections,
|
|
204
|
-
rank: 963
|
|
205
|
-
})
|
|
200
|
+
.claimStakeRewards()
|
|
206
201
|
.accounts({
|
|
207
202
|
signer: wallet,
|
|
208
203
|
mint: constants_1.TRD_MINT,
|
|
209
204
|
stake: stakePDA,
|
|
210
|
-
stakeVault: stakeVaultPDA
|
|
211
|
-
verifier: constants_1.VERIFIER
|
|
205
|
+
stakeVault: stakeVaultPDA
|
|
212
206
|
})
|
|
213
207
|
.instruction());
|
|
214
208
|
}
|
|
215
|
-
return (0, sendVersionedTransaction_1.default)(this.provider, ixs, options
|
|
209
|
+
return (0, sendVersionedTransaction_1.default)(this.provider, ixs, options);
|
|
216
210
|
});
|
|
217
211
|
}
|
|
218
212
|
}
|
package/dist/trade.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
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 { InitializeMarketArgs, PlaceOrderArgs,
|
|
4
|
+
import { InitializeMarketArgs, PlaceOrderArgs, UpdateMarketArgs, CreateCustomerArgs, UserTrade, OpenOrderArgs } from './types/trade';
|
|
5
5
|
import { RpcOptions } from './types';
|
|
6
6
|
import BN from 'bn.js';
|
|
7
7
|
export default class Trade {
|
|
8
8
|
private program;
|
|
9
9
|
private provider;
|
|
10
|
+
mint: PublicKey;
|
|
11
|
+
decimals: number;
|
|
10
12
|
constructor(program: Program<TriadProtocol>, provider: AnchorProvider);
|
|
11
13
|
/**
|
|
12
14
|
* Get All Markets
|
|
@@ -31,19 +33,15 @@ export default class Trade {
|
|
|
31
33
|
*
|
|
32
34
|
*/
|
|
33
35
|
getLimitOrdersByMarketId(marketId: number): Promise<{
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
orderType: import("./types/trade").OrderType;
|
|
44
|
-
direction: OrderDirection;
|
|
45
|
-
userNonce: string;
|
|
46
|
-
}[]>;
|
|
36
|
+
hype: {
|
|
37
|
+
bid: any[];
|
|
38
|
+
ask: any[];
|
|
39
|
+
};
|
|
40
|
+
flop: {
|
|
41
|
+
bid: any[];
|
|
42
|
+
ask: any[];
|
|
43
|
+
};
|
|
44
|
+
}>;
|
|
47
45
|
/**
|
|
48
46
|
* Get Market By ID
|
|
49
47
|
* @param marketId - The ID of the market
|
|
@@ -123,8 +121,8 @@ export default class Trade {
|
|
|
123
121
|
waiting: Record<string, never>;
|
|
124
122
|
});
|
|
125
123
|
price: BN;
|
|
126
|
-
|
|
127
|
-
|
|
124
|
+
amount: BN;
|
|
125
|
+
shares: BN;
|
|
128
126
|
orderType: ({
|
|
129
127
|
limit?: never;
|
|
130
128
|
} & {
|
|
@@ -153,6 +151,7 @@ export default class Trade {
|
|
|
153
151
|
} & {
|
|
154
152
|
ask: Record<string, never>;
|
|
155
153
|
});
|
|
154
|
+
linkedOrderId: BN;
|
|
156
155
|
padding: number[];
|
|
157
156
|
}[];
|
|
158
157
|
nonce: number;
|
|
@@ -161,7 +160,7 @@ export default class Trade {
|
|
|
161
160
|
padding: number[];
|
|
162
161
|
}>;
|
|
163
162
|
/**
|
|
164
|
-
*
|
|
163
|
+
* Create Market
|
|
165
164
|
* @param args.marketId - new markert id - length + 1
|
|
166
165
|
* @param args.startTime - start time
|
|
167
166
|
* @param args.endTime - end time
|
|
@@ -170,7 +169,7 @@ export default class Trade {
|
|
|
170
169
|
* @param options - RPC options
|
|
171
170
|
*
|
|
172
171
|
*/
|
|
173
|
-
|
|
172
|
+
createMarket({ marketId, startTime, endTime, question, feeBps, customer }: InitializeMarketArgs, options?: RpcOptions): Promise<string>;
|
|
174
173
|
/**
|
|
175
174
|
* Get User Trade Nonce With Slots
|
|
176
175
|
* @param userTrades - User Trades
|
|
@@ -182,7 +181,6 @@ export default class Trade {
|
|
|
182
181
|
* @param args.marketId - The ID of the Market
|
|
183
182
|
* @param args.amount - The amount of the Order
|
|
184
183
|
* @param args.direction - The direction of the Order
|
|
185
|
-
* @param args.orderType - The type of the Order
|
|
186
184
|
* @param args.orderSide - The side of the Order
|
|
187
185
|
* @param args.mint - The mint of the Order
|
|
188
186
|
* @param args.price - The price of the Order
|
|
@@ -190,7 +188,7 @@ export default class Trade {
|
|
|
190
188
|
* @param options - RPC options
|
|
191
189
|
*
|
|
192
190
|
*/
|
|
193
|
-
placeOrder({ marketId, amount, direction,
|
|
191
|
+
placeOrder({ marketId, amount, direction, orderSide, mint, price }: PlaceOrderArgs, options?: RpcOptions): Promise<string>;
|
|
194
192
|
/**
|
|
195
193
|
* Cancel Order
|
|
196
194
|
* @param args.marketId - The ID of the Market
|
|
@@ -205,26 +203,6 @@ export default class Trade {
|
|
|
205
203
|
orderId: number;
|
|
206
204
|
userNonce: number;
|
|
207
205
|
}, options?: RpcOptions): Promise<string>;
|
|
208
|
-
/**
|
|
209
|
-
* Resolve Market
|
|
210
|
-
* @param args.marketId - The ID of the Market
|
|
211
|
-
* @param args.winningDirection - The Winning Direction of the Market
|
|
212
|
-
*
|
|
213
|
-
* @param options - RPC options
|
|
214
|
-
*
|
|
215
|
-
*/
|
|
216
|
-
resolveMarket({ marketId, winningDirection }: {
|
|
217
|
-
marketId: number;
|
|
218
|
-
winningDirection: {
|
|
219
|
-
hype: {};
|
|
220
|
-
} | {
|
|
221
|
-
flop: {};
|
|
222
|
-
} | {
|
|
223
|
-
none: {};
|
|
224
|
-
} | {
|
|
225
|
-
draw: {};
|
|
226
|
-
};
|
|
227
|
-
}, options?: RpcOptions): Promise<string>;
|
|
228
206
|
/**
|
|
229
207
|
* Collect Remaining Liquidity
|
|
230
208
|
* @param marketId - The ID of the market
|
|
@@ -267,9 +245,45 @@ export default class Trade {
|
|
|
267
245
|
* Update Market
|
|
268
246
|
* @param marketId - The ID of the market
|
|
269
247
|
* @param marketEnd - The end time of the market
|
|
248
|
+
* @param winningDirection - The winning direction of the market
|
|
270
249
|
*
|
|
271
250
|
* @param options - RPC options
|
|
272
251
|
*
|
|
273
252
|
*/
|
|
274
|
-
updateMarket(marketId
|
|
253
|
+
updateMarket({ marketId, marketEnd, winningDirection }: UpdateMarketArgs, options?: RpcOptions): Promise<string>;
|
|
254
|
+
/**
|
|
255
|
+
* Create Customer
|
|
256
|
+
* @param args.id - The ID of the customer
|
|
257
|
+
* @param args.name - The name of the customer
|
|
258
|
+
* @param args.authority - The authority of the customer
|
|
259
|
+
* @param args.shadowStorage - The shadow storage of the customer
|
|
260
|
+
*
|
|
261
|
+
* @param options - RPC options
|
|
262
|
+
*
|
|
263
|
+
*/
|
|
264
|
+
createCustomer({ id, name, authority, shadowStorage }: CreateCustomerArgs, options?: RpcOptions): Promise<string>;
|
|
265
|
+
/**
|
|
266
|
+
* Open Order
|
|
267
|
+
* @param args.marketId - The ID of the Market
|
|
268
|
+
* @param args.amount - The amount of the Order
|
|
269
|
+
* @param args.direction - The direction of the Order
|
|
270
|
+
*
|
|
271
|
+
* @param options - RPC options
|
|
272
|
+
*
|
|
273
|
+
*/
|
|
274
|
+
openOrder({ marketId, amount, direction }: OpenOrderArgs, options?: RpcOptions): Promise<string>;
|
|
275
|
+
/**
|
|
276
|
+
* Close Order
|
|
277
|
+
* @param args.marketId - The ID of the Market
|
|
278
|
+
* @param args.orderId - The ID of the Order
|
|
279
|
+
* @param args.userNonce - The nonce of the user
|
|
280
|
+
*
|
|
281
|
+
* @param options - RPC options
|
|
282
|
+
*
|
|
283
|
+
*/
|
|
284
|
+
closeOrder({ marketId, orderId, userNonce }: {
|
|
285
|
+
marketId: number;
|
|
286
|
+
orderId: number;
|
|
287
|
+
userNonce: number;
|
|
288
|
+
}, options?: RpcOptions): Promise<string>;
|
|
275
289
|
}
|