@triadxyz/triad-protocol 3.1.1-beta → 3.1.2-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 +77 -145
- package/dist/index.js +154 -239
- package/dist/poseidon.d.ts +19 -25
- package/dist/poseidon.js +69 -75
- package/dist/stake.d.ts +24 -36
- package/dist/stake.js +86 -86
- package/dist/types/idl_triad_protocol.json +800 -339
- package/dist/types/index.d.ts +81 -45
- package/dist/types/triad_protocol.d.ts +1051 -464
- package/dist/utils/constants.d.ts +2 -3
- package/dist/utils/constants.js +3 -4
- package/dist/utils/helpers.d.ts +8 -32
- package/dist/utils/helpers.js +25 -26
- package/dist/utils/{pda/index.d.ts → pda.d.ts} +4 -0
- package/dist/utils/{pda/index.js → pda.js} +17 -1
- package/dist/utils/sendVersionedTransaction.js +1 -1
- package/dist/utils/swap.js +3 -3
- package/package.json +2 -1
- package/dist/types/poseidon.d.ts +0 -18
- package/dist/types/poseidon.js +0 -2
- package/dist/types/stake.d.ts +0 -35
- package/dist/types/stake.js +0 -2
- package/dist/utils/pda/poseidon.d.ts +0 -4
- package/dist/utils/pda/poseidon.js +0 -20
- package/dist/utils/pda/stake.d.ts +0 -3
- package/dist/utils/pda/stake.js +0 -12
package/dist/poseidon.d.ts
CHANGED
|
@@ -1,49 +1,43 @@
|
|
|
1
1
|
import { Program } from '@coral-xyz/anchor';
|
|
2
|
+
import { PublicKey } from '@solana/web3.js';
|
|
2
3
|
import { TriadProtocol } from './types/triad_protocol';
|
|
3
4
|
import { RpcOptions } from './types';
|
|
4
|
-
import { AddTraderPoseidonArgs, RemoveTraderPoseidonArgs, TransferPoseidonArgs, WithdrawPoseidonArgs } from './types/poseidon';
|
|
5
5
|
export default class Poseidon {
|
|
6
6
|
private program;
|
|
7
|
-
|
|
7
|
+
private rpcOptions;
|
|
8
|
+
constructor(program: Program<TriadProtocol>, rpcOptions: RpcOptions);
|
|
8
9
|
/**
|
|
9
10
|
* Transfer Poseidon
|
|
10
11
|
* @param args.poseidonAsset - Poseidon Asset
|
|
11
12
|
* @param args.ticketAsset - Ticket Asset
|
|
12
13
|
* @param args.ticketNumber - Ticket Number
|
|
13
|
-
*
|
|
14
|
-
* @param options - RPC options
|
|
15
|
-
*
|
|
16
14
|
*/
|
|
17
|
-
transferPoseidon(
|
|
15
|
+
transferPoseidon(poseidons: {
|
|
16
|
+
poseidonAsset: PublicKey;
|
|
17
|
+
ticketAsset: PublicKey;
|
|
18
|
+
ticketNumber: number;
|
|
19
|
+
}[]): Promise<string>;
|
|
18
20
|
/**
|
|
19
21
|
* Withdraw Poseidon
|
|
20
|
-
* @param
|
|
21
|
-
* @param
|
|
22
|
-
*
|
|
23
|
-
* @param options - RPC options
|
|
22
|
+
* @param poseidonAsset - Poseidon Asset - CORE PublicKey
|
|
23
|
+
* @param nft - NFT Poseidon Number
|
|
24
24
|
*/
|
|
25
|
-
withdrawPoseidon(
|
|
25
|
+
withdrawPoseidon(poseidonAsset: PublicKey, nft: number): Promise<string>;
|
|
26
26
|
/**
|
|
27
27
|
* Collect Royalty
|
|
28
|
-
* @param
|
|
29
|
-
*
|
|
30
|
-
* @param options - RPC options
|
|
28
|
+
* @param collectionSymbol - Collection Symbol
|
|
31
29
|
*/
|
|
32
|
-
collectRoyalty(
|
|
30
|
+
collectRoyalty(collectionSymbol: string): Promise<string>;
|
|
33
31
|
/**
|
|
34
32
|
* Add Trader Poseidon
|
|
35
|
-
* @param
|
|
36
|
-
* @param
|
|
37
|
-
*
|
|
38
|
-
* @param options - RPC options
|
|
33
|
+
* @param user - User Public Key
|
|
34
|
+
* @param poseidonAsset - Poseidon Asset
|
|
39
35
|
*/
|
|
40
|
-
addTraderPoseidon(
|
|
36
|
+
addTraderPoseidon(user: PublicKey, poseidonAsset: PublicKey): Promise<string>;
|
|
41
37
|
/**
|
|
42
38
|
* Remove Trader Poseidon
|
|
43
|
-
* @param
|
|
44
|
-
* @param
|
|
45
|
-
*
|
|
46
|
-
* @param options - RPC options
|
|
39
|
+
* @param user - User Public Key
|
|
40
|
+
* @param poseidonAsset - Poseidon Asset
|
|
47
41
|
*/
|
|
48
|
-
removeTraderPoseidon(
|
|
42
|
+
removeTraderPoseidon(user: PublicKey, poseidonAsset: PublicKey): Promise<string>;
|
|
49
43
|
}
|
package/dist/poseidon.js
CHANGED
|
@@ -14,126 +14,120 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const constants_1 = require("./utils/constants");
|
|
16
16
|
const sendVersionedTransaction_1 = __importDefault(require("./utils/sendVersionedTransaction"));
|
|
17
|
-
const poseidon_1 = require("./utils/pda/poseidon");
|
|
18
17
|
const pda_1 = require("./utils/pda");
|
|
18
|
+
const pda_2 = require("./utils/pda");
|
|
19
19
|
class Poseidon {
|
|
20
|
-
constructor(program) {
|
|
20
|
+
constructor(program, rpcOptions) {
|
|
21
21
|
this.program = program;
|
|
22
|
+
this.rpcOptions = rpcOptions;
|
|
22
23
|
}
|
|
23
24
|
/**
|
|
24
25
|
* Transfer Poseidon
|
|
25
26
|
* @param args.poseidonAsset - Poseidon Asset
|
|
26
27
|
* @param args.ticketAsset - Ticket Asset
|
|
27
28
|
* @param args.ticketNumber - Ticket Number
|
|
28
|
-
*
|
|
29
|
-
* @param options - RPC options
|
|
30
|
-
*
|
|
31
29
|
*/
|
|
32
|
-
transferPoseidon(
|
|
30
|
+
transferPoseidon(poseidons) {
|
|
33
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
32
|
const ixs = [];
|
|
35
|
-
for (const
|
|
33
|
+
for (const poseidon of poseidons) {
|
|
36
34
|
ixs.push(yield this.program.methods
|
|
37
35
|
.transferPoseidon()
|
|
38
36
|
.accounts({
|
|
39
37
|
signer: this.program.provider.publicKey,
|
|
40
|
-
nft: (0,
|
|
41
|
-
poseidonAsset:
|
|
42
|
-
ticketAsset:
|
|
43
|
-
poseidonCollection: (0,
|
|
44
|
-
ticketCollection: (0,
|
|
38
|
+
nft: (0, pda_1.getNftPDA)(this.program.programId, poseidon.ticketNumber),
|
|
39
|
+
poseidonAsset: poseidon.poseidonAsset,
|
|
40
|
+
ticketAsset: poseidon.ticketAsset,
|
|
41
|
+
poseidonCollection: (0, pda_1.getCollectionPDA)(this.program.programId, constants_1.POSEIDON_COLLECTION_SYMBOL),
|
|
42
|
+
ticketCollection: (0, pda_1.getCollectionPDA)(this.program.programId, constants_1.TICKET_COLLECTION_SYMBOL),
|
|
45
43
|
coreTicketCollection: constants_1.TICKET_CORE_COLLECTION,
|
|
46
44
|
corePoseidonCollection: constants_1.POSEIDON_CORE_COLLECTION
|
|
47
45
|
})
|
|
48
46
|
.instruction());
|
|
49
47
|
}
|
|
50
|
-
return (0, sendVersionedTransaction_1.default)(this.program, ixs,
|
|
48
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
51
49
|
});
|
|
52
50
|
}
|
|
53
51
|
/**
|
|
54
52
|
* Withdraw Poseidon
|
|
55
|
-
* @param
|
|
56
|
-
* @param
|
|
57
|
-
*
|
|
58
|
-
* @param options - RPC options
|
|
53
|
+
* @param poseidonAsset - Poseidon Asset - CORE PublicKey
|
|
54
|
+
* @param nft - NFT Poseidon Number
|
|
59
55
|
*/
|
|
60
|
-
withdrawPoseidon(
|
|
56
|
+
withdrawPoseidon(poseidonAsset, nft) {
|
|
61
57
|
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
-
const ixs = [
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
58
|
+
const ixs = [
|
|
59
|
+
yield this.program.methods
|
|
60
|
+
.withdrawPoseidon()
|
|
61
|
+
.accounts({
|
|
62
|
+
signer: this.program.provider.publicKey,
|
|
63
|
+
nft: (0, pda_1.getPoseidonPDA)(this.program.programId, nft),
|
|
64
|
+
poseidonAsset,
|
|
65
|
+
poseidonCollection: (0, pda_1.getCollectionPDA)(this.program.programId, constants_1.POSEIDON_COLLECTION_SYMBOL),
|
|
66
|
+
corePoseidonCollection: constants_1.POSEIDON_CORE_COLLECTION
|
|
67
|
+
})
|
|
68
|
+
.instruction()
|
|
69
|
+
];
|
|
70
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
74
71
|
});
|
|
75
72
|
}
|
|
76
73
|
/**
|
|
77
74
|
* Collect Royalty
|
|
78
|
-
* @param
|
|
79
|
-
*
|
|
80
|
-
* @param options - RPC options
|
|
75
|
+
* @param collectionSymbol - Collection Symbol
|
|
81
76
|
*/
|
|
82
|
-
collectRoyalty(
|
|
77
|
+
collectRoyalty(collectionSymbol) {
|
|
83
78
|
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
-
const ixs = [
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
79
|
+
const ixs = [
|
|
80
|
+
yield this.program.methods
|
|
81
|
+
.collectRoyalty()
|
|
82
|
+
.accounts({
|
|
83
|
+
signer: this.program.provider.publicKey,
|
|
84
|
+
collection: (0, pda_1.getCollectionPDA)(this.program.programId, collectionSymbol)
|
|
85
|
+
})
|
|
86
|
+
.instruction()
|
|
87
|
+
];
|
|
88
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
93
89
|
});
|
|
94
90
|
}
|
|
95
91
|
/**
|
|
96
92
|
* Add Trader Poseidon
|
|
97
|
-
* @param
|
|
98
|
-
* @param
|
|
99
|
-
*
|
|
100
|
-
* @param options - RPC options
|
|
93
|
+
* @param user - User Public Key
|
|
94
|
+
* @param poseidonAsset - Poseidon Asset
|
|
101
95
|
*/
|
|
102
|
-
addTraderPoseidon(
|
|
96
|
+
addTraderPoseidon(user, poseidonAsset) {
|
|
103
97
|
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
-
const ixs = [
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
98
|
+
const ixs = [
|
|
99
|
+
yield this.program.methods
|
|
100
|
+
.addTraderPoseidon()
|
|
101
|
+
.accounts({
|
|
102
|
+
poseidonAsset,
|
|
103
|
+
userTrade: (0, pda_2.getUserTradePDA)(this.program.programId, user),
|
|
104
|
+
corePoseidonCollection: constants_1.POSEIDON_CORE_COLLECTION,
|
|
105
|
+
poseidonCollection: (0, pda_1.getCollectionPDA)(this.program.programId, constants_1.POSEIDON_COLLECTION_SYMBOL)
|
|
106
|
+
})
|
|
107
|
+
.instruction()
|
|
108
|
+
];
|
|
109
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
115
110
|
});
|
|
116
111
|
}
|
|
117
112
|
/**
|
|
118
113
|
* Remove Trader Poseidon
|
|
119
|
-
* @param
|
|
120
|
-
* @param
|
|
121
|
-
*
|
|
122
|
-
* @param options - RPC options
|
|
114
|
+
* @param user - User Public Key
|
|
115
|
+
* @param poseidonAsset - Poseidon Asset
|
|
123
116
|
*/
|
|
124
|
-
removeTraderPoseidon(
|
|
117
|
+
removeTraderPoseidon(user, poseidonAsset) {
|
|
125
118
|
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
-
const ixs = [
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
119
|
+
const ixs = [
|
|
120
|
+
yield this.program.methods
|
|
121
|
+
.removeTraderPoseidon()
|
|
122
|
+
.accounts({
|
|
123
|
+
userTrade: (0, pda_2.getUserTradePDA)(this.program.programId, user),
|
|
124
|
+
poseidonAsset,
|
|
125
|
+
corePoseidonCollection: constants_1.POSEIDON_CORE_COLLECTION,
|
|
126
|
+
poseidonCollection: (0, pda_1.getCollectionPDA)(this.program.programId, constants_1.POSEIDON_COLLECTION_SYMBOL)
|
|
127
|
+
})
|
|
128
|
+
.instruction()
|
|
129
|
+
];
|
|
130
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
137
131
|
});
|
|
138
132
|
}
|
|
139
133
|
}
|
package/dist/stake.d.ts
CHANGED
|
@@ -2,24 +2,21 @@ 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 { UpdateStakeVaultArgs } from './types/stake';
|
|
6
5
|
export default class Stake {
|
|
7
6
|
private program;
|
|
8
|
-
|
|
7
|
+
private rpcOptions;
|
|
8
|
+
constructor(program: Program<TriadProtocol>, rpcOptions: RpcOptions);
|
|
9
9
|
/**
|
|
10
10
|
* Get all Stake Vaults
|
|
11
|
-
*
|
|
12
11
|
*/
|
|
13
|
-
getStakeVaults(): Promise<import("./types
|
|
12
|
+
getStakeVaults(): Promise<import("./types").StakeVault[]>;
|
|
14
13
|
/**
|
|
15
14
|
* Get all Stakes
|
|
16
|
-
*
|
|
17
15
|
*/
|
|
18
|
-
getStakes(): Promise<import("./types
|
|
16
|
+
getStakes(): Promise<import("./types").Stake[]>;
|
|
19
17
|
/**
|
|
20
18
|
* Get Stake By Wallet
|
|
21
19
|
* @param wallet - User wallet
|
|
22
|
-
*
|
|
23
20
|
*/
|
|
24
21
|
getStakeByWallet(wallet: PublicKey): Promise<{
|
|
25
22
|
available: number;
|
|
@@ -32,44 +29,35 @@ export default class Stake {
|
|
|
32
29
|
/**
|
|
33
30
|
* Get Unstake By Wallet
|
|
34
31
|
* @param wallet - User wallet
|
|
35
|
-
*
|
|
36
32
|
*/
|
|
37
|
-
getUnstakeByWallet(wallet: PublicKey): Promise<import("./types
|
|
33
|
+
getUnstakeByWallet(wallet: PublicKey): Promise<import("./types").Unstake[]>;
|
|
38
34
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* @param options - RPC options
|
|
43
|
-
*
|
|
35
|
+
* Stake Token
|
|
36
|
+
* @param amount - Amount to stake
|
|
44
37
|
*/
|
|
45
|
-
stakeToken(amount: number
|
|
38
|
+
stakeToken(amount: number): Promise<string>;
|
|
46
39
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* @param args.isLocked - is locked stake vault (optional)
|
|
50
|
-
*
|
|
51
|
-
* @param options - RPC options
|
|
52
|
-
*
|
|
40
|
+
* Update Stake Vault
|
|
41
|
+
* @param amount - Reward amount to deposit
|
|
53
42
|
*/
|
|
54
|
-
|
|
43
|
+
addStakeVaultRewards(amount: number): Promise<string>;
|
|
55
44
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* @param options - RPC options
|
|
60
|
-
*
|
|
45
|
+
* Update Stake Vault Is Locked
|
|
46
|
+
* @param isLocked - Whether the stake vault is locked
|
|
61
47
|
*/
|
|
62
|
-
|
|
48
|
+
updateStakeVaultIsLocked(isLocked: boolean): Promise<string>;
|
|
63
49
|
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
50
|
+
* Request Unstake
|
|
51
|
+
* @param amount - Amount to unstake
|
|
67
52
|
*/
|
|
68
|
-
|
|
53
|
+
requestUnstake(amount: number): Promise<string>;
|
|
69
54
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
55
|
+
* Unstake Token
|
|
56
|
+
* @param unstakePDA - Unstake Public Key
|
|
73
57
|
*/
|
|
74
|
-
|
|
58
|
+
unstakeToken(unstakePDA: PublicKey): Promise<string>;
|
|
59
|
+
/**
|
|
60
|
+
* Claim Stake Rewards
|
|
61
|
+
*/
|
|
62
|
+
claimStakeRewards(): Promise<string>;
|
|
75
63
|
}
|
package/dist/stake.js
CHANGED
|
@@ -14,16 +14,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
16
16
|
const helpers_1 = require("./utils/helpers");
|
|
17
|
-
const
|
|
17
|
+
const pda_1 = require("./utils/pda");
|
|
18
18
|
const constants_1 = require("./utils/constants");
|
|
19
19
|
const sendVersionedTransaction_1 = __importDefault(require("./utils/sendVersionedTransaction"));
|
|
20
20
|
class Stake {
|
|
21
|
-
constructor(program) {
|
|
21
|
+
constructor(program, rpcOptions) {
|
|
22
22
|
this.program = program;
|
|
23
|
+
this.rpcOptions = rpcOptions;
|
|
23
24
|
}
|
|
24
25
|
/**
|
|
25
26
|
* Get all Stake Vaults
|
|
26
|
-
*
|
|
27
27
|
*/
|
|
28
28
|
getStakeVaults() {
|
|
29
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -33,7 +33,6 @@ class Stake {
|
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
35
|
* Get all Stakes
|
|
36
|
-
*
|
|
37
36
|
*/
|
|
38
37
|
getStakes() {
|
|
39
38
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -44,12 +43,11 @@ class Stake {
|
|
|
44
43
|
/**
|
|
45
44
|
* Get Stake By Wallet
|
|
46
45
|
* @param wallet - User wallet
|
|
47
|
-
*
|
|
48
46
|
*/
|
|
49
47
|
getStakeByWallet(wallet) {
|
|
50
48
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
49
|
const stake = yield this.program.account.stakeV3
|
|
52
|
-
.fetch((0,
|
|
50
|
+
.fetch((0, pda_1.getStakePDA)(this.program.programId, wallet))
|
|
53
51
|
.then((stake) => (0, helpers_1.formatStake)(stake));
|
|
54
52
|
return Object.assign(Object.assign({}, stake), { available: (0, helpers_1.calculateStakeRewards)(stake) });
|
|
55
53
|
});
|
|
@@ -57,7 +55,6 @@ class Stake {
|
|
|
57
55
|
/**
|
|
58
56
|
* Get Unstake By Wallet
|
|
59
57
|
* @param wallet - User wallet
|
|
60
|
-
*
|
|
61
58
|
*/
|
|
62
59
|
getUnstakeByWallet(wallet) {
|
|
63
60
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -73,107 +70,110 @@ class Stake {
|
|
|
73
70
|
});
|
|
74
71
|
}
|
|
75
72
|
/**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* @param options - RPC options
|
|
80
|
-
*
|
|
73
|
+
* Stake Token
|
|
74
|
+
* @param amount - Amount to stake
|
|
81
75
|
*/
|
|
82
|
-
stakeToken(amount
|
|
76
|
+
stakeToken(amount) {
|
|
83
77
|
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
-
const ixs = [
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
78
|
+
const ixs = [
|
|
79
|
+
yield this.program.methods
|
|
80
|
+
.stakeToken({
|
|
81
|
+
amount: new anchor_1.BN(amount * Math.pow(10, 6))
|
|
82
|
+
})
|
|
83
|
+
.accounts({
|
|
84
|
+
mint: constants_1.TRD_MINT
|
|
85
|
+
})
|
|
86
|
+
.instruction()
|
|
87
|
+
];
|
|
88
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
94
89
|
});
|
|
95
90
|
}
|
|
96
91
|
/**
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* @param args.isLocked - is locked stake vault (optional)
|
|
100
|
-
*
|
|
101
|
-
* @param options - RPC options
|
|
102
|
-
*
|
|
92
|
+
* Update Stake Vault
|
|
93
|
+
* @param amount - Reward amount to deposit
|
|
103
94
|
*/
|
|
104
|
-
|
|
95
|
+
addStakeVaultRewards(amount) {
|
|
105
96
|
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
-
const ixs = [
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
.instruction());
|
|
116
|
-
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
|
|
97
|
+
const ixs = [
|
|
98
|
+
yield this.program.methods
|
|
99
|
+
.addStakeVaultRewards(new anchor_1.BN(amount * Math.pow(10, 6)))
|
|
100
|
+
.accounts({
|
|
101
|
+
mint: constants_1.TRD_MINT
|
|
102
|
+
})
|
|
103
|
+
.instruction()
|
|
104
|
+
];
|
|
105
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
117
106
|
});
|
|
118
107
|
}
|
|
119
108
|
/**
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
* @param options - RPC options
|
|
124
|
-
*
|
|
109
|
+
* Update Stake Vault Is Locked
|
|
110
|
+
* @param isLocked - Whether the stake vault is locked
|
|
125
111
|
*/
|
|
126
|
-
|
|
112
|
+
updateStakeVaultIsLocked(isLocked) {
|
|
127
113
|
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
-
const ixs = [
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
.accounts({
|
|
135
|
-
signer: this.program.provider.publicKey,
|
|
136
|
-
mint: constants_1.TRD_MINT
|
|
137
|
-
})
|
|
138
|
-
.instruction());
|
|
139
|
-
return (0, sendVersionedTransaction_1.default)(this.program, ixs, options);
|
|
114
|
+
const ixs = [
|
|
115
|
+
yield this.program.methods
|
|
116
|
+
.updateStakeVaultIsLocked(isLocked)
|
|
117
|
+
.instruction()
|
|
118
|
+
];
|
|
119
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
140
120
|
});
|
|
141
121
|
}
|
|
142
122
|
/**
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
123
|
+
* Request Unstake
|
|
124
|
+
* @param amount - Amount to unstake
|
|
146
125
|
*/
|
|
147
|
-
|
|
126
|
+
requestUnstake(amount) {
|
|
148
127
|
return __awaiter(this, void 0, void 0, function* () {
|
|
149
|
-
const ixs = [
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
128
|
+
const ixs = [
|
|
129
|
+
yield this.program.methods
|
|
130
|
+
.requestUnstake({
|
|
131
|
+
amount: new anchor_1.BN(amount * Math.pow(10, 6)),
|
|
132
|
+
ts: new anchor_1.BN(Date.now())
|
|
133
|
+
})
|
|
134
|
+
.accounts({
|
|
135
|
+
signer: this.program.provider.publicKey,
|
|
136
|
+
mint: constants_1.TRD_MINT
|
|
137
|
+
})
|
|
138
|
+
.instruction()
|
|
139
|
+
];
|
|
140
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
159
141
|
});
|
|
160
142
|
}
|
|
161
143
|
/**
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
144
|
+
* Unstake Token
|
|
145
|
+
* @param unstakePDA - Unstake Public Key
|
|
165
146
|
*/
|
|
166
|
-
|
|
147
|
+
unstakeToken(unstakePDA) {
|
|
167
148
|
return __awaiter(this, void 0, void 0, function* () {
|
|
168
|
-
const ixs = [
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
149
|
+
const ixs = [
|
|
150
|
+
yield this.program.methods
|
|
151
|
+
.unstakeToken()
|
|
152
|
+
.accounts({
|
|
153
|
+
signer: this.program.provider.publicKey,
|
|
154
|
+
unstake: unstakePDA,
|
|
155
|
+
mint: constants_1.TRD_MINT
|
|
156
|
+
})
|
|
157
|
+
.instruction()
|
|
158
|
+
];
|
|
159
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Claim Stake Rewards
|
|
164
|
+
*/
|
|
165
|
+
claimStakeRewards() {
|
|
166
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
167
|
+
const ixs = [
|
|
168
|
+
yield this.program.methods
|
|
169
|
+
.claimStakeRewards()
|
|
170
|
+
.accounts({
|
|
171
|
+
signer: this.program.provider.publicKey,
|
|
172
|
+
mint: constants_1.TRD_MINT
|
|
173
|
+
})
|
|
174
|
+
.instruction()
|
|
175
|
+
];
|
|
176
|
+
return (0, sendVersionedTransaction_1.default)(this.program, ixs, this.rpcOptions);
|
|
177
177
|
});
|
|
178
178
|
}
|
|
179
179
|
}
|