@triadxyz/triad-protocol 2.2.2-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/types/trade.d.ts +8 -0
- 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/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",
|
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;
|