@triadxyz/triad-protocol 2.5.2-beta → 2.5.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/stake.d.ts +2 -2
- package/dist/stake.js +4 -3
- package/dist/types/stake.d.ts +2 -1
- package/dist/utils/helpers.d.ts +4 -4
- package/dist/utils/helpers.js +2 -1
- package/package.json +1 -1
package/dist/stake.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export default class Stake {
|
|
|
20
20
|
* Get all Stakes
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
getStakes(): Promise<import("./types/stake").
|
|
23
|
+
getStakes(): Promise<import("./types/stake").Stake[]>;
|
|
24
24
|
/**
|
|
25
25
|
* Get Stake By Wallet
|
|
26
26
|
* @param wallet - User wallet
|
|
@@ -70,7 +70,7 @@ export default class Stake {
|
|
|
70
70
|
* @param options - RPC options
|
|
71
71
|
*
|
|
72
72
|
*/
|
|
73
|
-
unstakeToken(options?: RpcOptions): Promise<string>;
|
|
73
|
+
unstakeToken(unstakePDA: PublicKey, options?: RpcOptions): Promise<string>;
|
|
74
74
|
/**
|
|
75
75
|
* Claim Stake Rewards
|
|
76
76
|
* @param options - RPC options
|
package/dist/stake.js
CHANGED
|
@@ -80,7 +80,7 @@ class Stake {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
]);
|
|
83
|
-
return stake.map((stake) => (0, helpers_1.formatUnstake)(stake.account));
|
|
83
|
+
return stake.map((stake) => (0, helpers_1.formatUnstake)(stake.account, stake.publicKey));
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
@@ -155,13 +155,14 @@ class Stake {
|
|
|
155
155
|
* @param options - RPC options
|
|
156
156
|
*
|
|
157
157
|
*/
|
|
158
|
-
unstakeToken(options) {
|
|
158
|
+
unstakeToken(unstakePDA, options) {
|
|
159
159
|
return __awaiter(this, void 0, void 0, function* () {
|
|
160
160
|
const ixs = [];
|
|
161
161
|
ixs.push(yield this.program.methods
|
|
162
162
|
.unstakeToken()
|
|
163
163
|
.accounts({
|
|
164
|
-
signer: this.program.provider.publicKey
|
|
164
|
+
signer: this.program.provider.publicKey,
|
|
165
|
+
unstake: unstakePDA
|
|
165
166
|
})
|
|
166
167
|
.instruction());
|
|
167
168
|
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
|
package/dist/types/stake.d.ts
CHANGED
|
@@ -33,11 +33,12 @@ export type StakeV2 = {
|
|
|
33
33
|
amount: number;
|
|
34
34
|
};
|
|
35
35
|
export type Unstake = {
|
|
36
|
+
address: string;
|
|
36
37
|
authority: string;
|
|
37
38
|
amount: number;
|
|
38
39
|
withdrawTs: number;
|
|
39
40
|
};
|
|
40
|
-
export type
|
|
41
|
+
export type Stake = {
|
|
41
42
|
authority: string;
|
|
42
43
|
initTs: number;
|
|
43
44
|
checkedTs: number;
|
package/dist/utils/helpers.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { PublicKey } from '@solana/web3.js';
|
|
2
2
|
import { IdlAccounts } from '@coral-xyz/anchor';
|
|
3
|
-
import { StakeV2,
|
|
3
|
+
import { StakeV2, Stake, StakeVault, Unstake } from './../types/stake';
|
|
4
4
|
import { Market, Order, OrderDirection, OrderSide, OrderStatus, OrderType, UserTrade, Pool, BookOrder, Refer } from '../types';
|
|
5
5
|
import { TriadProtocol } from '../types/triad_protocol';
|
|
6
6
|
export declare const encodeString: (value: string, alloc?: number) => number[];
|
|
7
7
|
export declare const decodeString: (bytes: number[]) => string;
|
|
8
8
|
export declare const formatStakeVault: (stakeVault: IdlAccounts<TriadProtocol>['stakeVault']) => StakeVault;
|
|
9
9
|
export declare const formatStakeV2: (stake: IdlAccounts<TriadProtocol>['stakeV2']) => StakeV2;
|
|
10
|
-
export declare const formatStake: (stake: IdlAccounts<TriadProtocol>['stakeV3']) =>
|
|
11
|
-
export declare const formatUnstake: (unstake: IdlAccounts<TriadProtocol>['unstake']) => Unstake;
|
|
10
|
+
export declare const formatStake: (stake: IdlAccounts<TriadProtocol>['stakeV3']) => Stake;
|
|
11
|
+
export declare const formatUnstake: (unstake: IdlAccounts<TriadProtocol>['unstake'], address: PublicKey) => Unstake;
|
|
12
12
|
export declare const formatPool: (account: IdlAccounts<TriadProtocol>['pool'], address: PublicKey) => Pool;
|
|
13
13
|
export declare const formatMarket: (account: IdlAccounts<TriadProtocol>['marketV2'], address: PublicKey) => Market;
|
|
14
14
|
export declare const formatUserTrade: (account: IdlAccounts<TriadProtocol>['userTrade'], publicKey: PublicKey) => UserTrade;
|
|
15
15
|
export declare const formatOrder: (order: IdlAccounts<TriadProtocol>['userTrade']['orders'][number], authority?: string) => Order;
|
|
16
16
|
export declare const formatBookOrder: (order: IdlAccounts<TriadProtocol>['orderBook']['hypeOrders'][number] | IdlAccounts<TriadProtocol>['orderBook']['flopOrders'][number]) => BookOrder;
|
|
17
|
-
export declare const calculateStakeRewards: (stake:
|
|
17
|
+
export declare const calculateStakeRewards: (stake: Stake) => number;
|
|
18
18
|
export declare const getTokenProgram: (mint: PublicKey) => PublicKey;
|
|
19
19
|
export declare const getOrderDirection: (direction: {
|
|
20
20
|
hype: {};
|
package/dist/utils/helpers.js
CHANGED
|
@@ -63,8 +63,9 @@ const formatStake = (stake) => {
|
|
|
63
63
|
};
|
|
64
64
|
};
|
|
65
65
|
exports.formatStake = formatStake;
|
|
66
|
-
const formatUnstake = (unstake) => {
|
|
66
|
+
const formatUnstake = (unstake, address) => {
|
|
67
67
|
return {
|
|
68
|
+
address: address.toBase58(),
|
|
68
69
|
authority: unstake.authority.toBase58(),
|
|
69
70
|
amount: unstake.amount.toNumber() / Math.pow(10, 6),
|
|
70
71
|
withdrawTs: unstake.withdrawTs.toNumber()
|