@triadxyz/triad-protocol 2.2.1-beta → 2.2.3-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/poseidon.d.ts +13 -0
- package/dist/poseidon.js +25 -0
- package/dist/trade.d.ts +1 -1
- package/dist/trade.js +6 -2
- package/dist/types/idl_triad_protocol.json +0 -5
- package/dist/types/trade.d.ts +15 -6
- package/dist/types/triad_protocol.d.ts +0 -5
- package/dist/utils/helpers.d.ts +2 -1
- package/dist/utils/helpers.js +12 -1
- package/package.json +1 -1
package/dist/poseidon.d.ts
CHANGED
|
@@ -85,4 +85,17 @@ export default class Poseidon {
|
|
|
85
85
|
* @param options - RPC options
|
|
86
86
|
*/
|
|
87
87
|
collectChestToken(id: number, options?: RpcOptions): Promise<string>;
|
|
88
|
+
/**
|
|
89
|
+
* Get Chest
|
|
90
|
+
* @param id - Chest ID
|
|
91
|
+
*
|
|
92
|
+
* @returns Chest
|
|
93
|
+
*/
|
|
94
|
+
getChest(id: number): Promise<import("./types/trade").Chest>;
|
|
95
|
+
/**
|
|
96
|
+
* Get Chests
|
|
97
|
+
*
|
|
98
|
+
* @returns Chests
|
|
99
|
+
*/
|
|
100
|
+
getChests(): Promise<import("./types/trade").Chest[]>;
|
|
88
101
|
}
|
package/dist/poseidon.js
CHANGED
|
@@ -17,6 +17,7 @@ const constants_1 = require("./utils/constants");
|
|
|
17
17
|
const sendVersionedTransaction_1 = __importDefault(require("./utils/sendVersionedTransaction"));
|
|
18
18
|
const poseidon_1 = require("./utils/pda/poseidon");
|
|
19
19
|
const pda_1 = require("./utils/pda");
|
|
20
|
+
const helpers_1 = require("./utils/helpers");
|
|
20
21
|
class Poseidon {
|
|
21
22
|
constructor(program) {
|
|
22
23
|
this.program = program;
|
|
@@ -218,5 +219,29 @@ class Poseidon {
|
|
|
218
219
|
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options, []);
|
|
219
220
|
});
|
|
220
221
|
}
|
|
222
|
+
/**
|
|
223
|
+
* Get Chest
|
|
224
|
+
* @param id - Chest ID
|
|
225
|
+
*
|
|
226
|
+
* @returns Chest
|
|
227
|
+
*/
|
|
228
|
+
getChest(id) {
|
|
229
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
230
|
+
const chestPDA = (0, poseidon_1.getChestPDA)(this.program.programId, id);
|
|
231
|
+
const chest = yield this.program.account.chest.fetch(chestPDA);
|
|
232
|
+
return (0, helpers_1.formatChest)(chest);
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Get Chests
|
|
237
|
+
*
|
|
238
|
+
* @returns Chests
|
|
239
|
+
*/
|
|
240
|
+
getChests() {
|
|
241
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
242
|
+
const chests = yield this.program.account.chest.all();
|
|
243
|
+
return chests.map((chest) => (0, helpers_1.formatChest)(chest.account));
|
|
244
|
+
});
|
|
245
|
+
}
|
|
221
246
|
}
|
|
222
247
|
exports.default = Poseidon;
|
package/dist/trade.d.ts
CHANGED
|
@@ -156,7 +156,7 @@ export default class Trade {
|
|
|
156
156
|
* @param options - RPC options
|
|
157
157
|
*
|
|
158
158
|
*/
|
|
159
|
-
createMarket({ marketId, startTime, endTime, question, feeBps, customer, payoutFee, mint }: CreateMarketArgs, options?: RpcOptions): Promise<string>;
|
|
159
|
+
createMarket({ marketId, startTime, endTime, question, feeBps, customer, payoutFee, mint, poolId }: CreateMarketArgs, options?: RpcOptions): Promise<string>;
|
|
160
160
|
/**
|
|
161
161
|
* Create Pool
|
|
162
162
|
* @param poolId - The ID of the pool
|
package/dist/trade.js
CHANGED
|
@@ -117,12 +117,16 @@ class Trade {
|
|
|
117
117
|
* @param options - RPC options
|
|
118
118
|
*
|
|
119
119
|
*/
|
|
120
|
-
createMarket({ marketId, startTime, endTime, question, feeBps, customer, payoutFee, mint }, options) {
|
|
120
|
+
createMarket({ marketId, startTime, endTime, question, feeBps, customer, payoutFee, mint, poolId }, options) {
|
|
121
121
|
return __awaiter(this, void 0, void 0, function* () {
|
|
122
122
|
if (question.length > 80) {
|
|
123
123
|
throw new Error('Question must be less than 80 characters');
|
|
124
124
|
}
|
|
125
125
|
const ixs = [];
|
|
126
|
+
let poolPDA = null;
|
|
127
|
+
if (poolId) {
|
|
128
|
+
poolPDA = (0, pda_1.getPoolPDA)(this.program.programId, poolId);
|
|
129
|
+
}
|
|
126
130
|
ixs.push(yield this.program.methods
|
|
127
131
|
.createMarket({
|
|
128
132
|
marketId: new bn_js_1.default(marketId),
|
|
@@ -137,7 +141,7 @@ class Trade {
|
|
|
137
141
|
mint,
|
|
138
142
|
tokenProgram: (0, helpers_1.getTokenProgram)(mint),
|
|
139
143
|
customer,
|
|
140
|
-
pool:
|
|
144
|
+
pool: poolPDA
|
|
141
145
|
})
|
|
142
146
|
.instruction());
|
|
143
147
|
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
|
package/dist/types/trade.d.ts
CHANGED
|
@@ -56,6 +56,14 @@ export type Order = {
|
|
|
56
56
|
authority: string;
|
|
57
57
|
createdAt: string;
|
|
58
58
|
};
|
|
59
|
+
export type Chest = {
|
|
60
|
+
id: number;
|
|
61
|
+
prizePool: number;
|
|
62
|
+
timer: number;
|
|
63
|
+
isFinished: boolean;
|
|
64
|
+
lastUser: string;
|
|
65
|
+
version: number;
|
|
66
|
+
};
|
|
59
67
|
export declare enum WinningDirection {
|
|
60
68
|
HYPE = "Hype",
|
|
61
69
|
DRAW = "Draw",
|
|
@@ -139,16 +147,17 @@ export type CreateMarketArgs = {
|
|
|
139
147
|
customer: PublicKey | null;
|
|
140
148
|
payoutFee: number;
|
|
141
149
|
mint: PublicKey;
|
|
150
|
+
poolId?: number;
|
|
142
151
|
};
|
|
143
152
|
export type CreatePoolArgs = {
|
|
144
153
|
poolId: number;
|
|
145
154
|
question: string;
|
|
146
|
-
startTime
|
|
147
|
-
endTime
|
|
148
|
-
feeBps
|
|
149
|
-
payoutFee
|
|
150
|
-
mint
|
|
151
|
-
customer
|
|
155
|
+
startTime?: number;
|
|
156
|
+
endTime?: number;
|
|
157
|
+
feeBps?: number;
|
|
158
|
+
payoutFee?: number;
|
|
159
|
+
mint?: PublicKey;
|
|
160
|
+
customer?: PublicKey | null;
|
|
152
161
|
markets: {
|
|
153
162
|
marketId: number;
|
|
154
163
|
question: string;
|
|
@@ -2833,11 +2833,6 @@ export type TriadProtocol = {
|
|
|
2833
2833
|
writable: true;
|
|
2834
2834
|
signer: true;
|
|
2835
2835
|
},
|
|
2836
|
-
{
|
|
2837
|
-
name: 'squads';
|
|
2838
|
-
writable: true;
|
|
2839
|
-
address: '6fcSf6qfwPNR9AUUNC1UWYZDy5cQ4TzTb2aaipN2zFdq';
|
|
2840
|
-
},
|
|
2841
2836
|
{
|
|
2842
2837
|
name: 'nft';
|
|
2843
2838
|
writable: true;
|
package/dist/utils/helpers.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Stake, StakeVault } from './../types/stake';
|
|
2
|
-
import { Market, Order, OrderDirection, OrderSide, OrderStatus, OrderType, UserTrade } from '../types/trade';
|
|
2
|
+
import { Market, Order, OrderDirection, OrderSide, OrderStatus, OrderType, UserTrade, Chest } from '../types/trade';
|
|
3
3
|
import { PublicKey } from '@solana/web3.js';
|
|
4
4
|
import { IdlAccounts } from '@coral-xyz/anchor';
|
|
5
5
|
import { TriadProtocol } from '../types/triad_protocol';
|
|
@@ -10,6 +10,7 @@ export declare const formatStake: (stake: IdlAccounts<TriadProtocol>['stakeV2'])
|
|
|
10
10
|
export declare const formatMarket: (account: IdlAccounts<TriadProtocol>['marketV2'], address: PublicKey) => Market;
|
|
11
11
|
export declare const formatUserTrade: (account: IdlAccounts<TriadProtocol>['userTrade'], publicKey: PublicKey) => UserTrade;
|
|
12
12
|
export declare const formatOrder: (order: IdlAccounts<TriadProtocol>['userTrade']['orders'][number], authority?: string) => Order;
|
|
13
|
+
export declare const formatChest: (chest: IdlAccounts<TriadProtocol>['chest']) => Chest;
|
|
13
14
|
export declare const calculateStakeRewards: (stake: Stake) => number;
|
|
14
15
|
export declare const getTokenProgram: (mint: PublicKey) => PublicKey;
|
|
15
16
|
export declare const getOrderDirection: (direction: {
|
package/dist/utils/helpers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getOrderStatus = exports.getOrderSide = exports.getOrderType = exports.getOrderDirection = exports.getTokenProgram = exports.calculateStakeRewards = exports.formatOrder = exports.formatUserTrade = exports.formatMarket = exports.formatStake = exports.formatStakeVault = exports.decodeString = exports.encodeString = void 0;
|
|
3
|
+
exports.getOrderStatus = exports.getOrderSide = exports.getOrderType = exports.getOrderDirection = exports.getTokenProgram = exports.calculateStakeRewards = exports.formatChest = exports.formatOrder = exports.formatUserTrade = exports.formatMarket = exports.formatStake = exports.formatStakeVault = exports.decodeString = exports.encodeString = void 0;
|
|
4
4
|
const trade_1 = require("../types/trade");
|
|
5
5
|
const constants_1 = require("./constants");
|
|
6
6
|
const spl_token_1 = require("@solana/spl-token");
|
|
@@ -122,6 +122,17 @@ const formatOrder = (order, authority) => {
|
|
|
122
122
|
};
|
|
123
123
|
};
|
|
124
124
|
exports.formatOrder = formatOrder;
|
|
125
|
+
const formatChest = (chest) => {
|
|
126
|
+
return {
|
|
127
|
+
id: chest.id.toNumber(),
|
|
128
|
+
prizePool: chest.prizePool.toNumber(),
|
|
129
|
+
timer: chest.timer.toNumber(),
|
|
130
|
+
isFinished: chest.isFinished,
|
|
131
|
+
lastUser: chest.lastUser.toString(),
|
|
132
|
+
version: chest.version.toNumber()
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
exports.formatChest = formatChest;
|
|
125
136
|
const calculateStakeRewards = (stake) => {
|
|
126
137
|
if (stake.withdrawTs !== 0)
|
|
127
138
|
return 0;
|