hedge-web3 0.2.31 → 0.3.0
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/declarations/Constants.d.ts +0 -12
- package/declarations/HedgeConstants.d.ts +76 -0
- package/declarations/idl/pyth.d.ts +1 -1
- package/declarations/idl/switchboard.d.ts +1 -1
- package/declarations/idl/vault.d.ts +60 -744
- package/declarations/index.d.ts +1 -10
- package/declarations/instructions/claimLiquidationPoolPosition.d.ts +1 -1
- package/declarations/instructions/claimStakingPoolPosition.d.ts +1 -1
- package/declarations/instructions/closeClaimedLiquidationPoolPosition.d.ts +1 -1
- package/declarations/instructions/closeLiquidationPoolPosition.d.ts +1 -1
- package/declarations/instructions/createReferralAccount.d.ts +3 -3
- package/declarations/instructions/createStakingPool.d.ts +1 -1
- package/declarations/instructions/createUserReferralAccount.d.ts +1 -1
- package/declarations/instructions/createVault.d.ts +1 -2
- package/declarations/instructions/depositLiquidationPool.d.ts +1 -2
- package/declarations/instructions/depositStakingPool.d.ts +1 -2
- package/declarations/instructions/depositVault.d.ts +1 -2
- package/declarations/instructions/initHedgeFoundation.d.ts +1 -1
- package/declarations/instructions/initHedgeFoundationTokens.d.ts +1 -1
- package/declarations/instructions/liquidateVault.d.ts +1 -1
- package/declarations/instructions/loanVault.d.ts +1 -2
- package/declarations/instructions/psmEditAccount.d.ts +1 -2
- package/declarations/instructions/psmMintUsh.d.ts +1 -2
- package/declarations/instructions/psmRedeemUsh.d.ts +1 -2
- package/declarations/instructions/redeemVault.d.ts +1 -2
- package/declarations/instructions/referralClaimFees.d.ts +3 -3
- package/declarations/instructions/refreshOraclePrice.d.ts +1 -1
- package/declarations/instructions/repayVault.d.ts +1 -2
- package/declarations/instructions/setHalted.d.ts +1 -1
- package/declarations/instructions/transferVault.d.ts +1 -1
- package/declarations/instructions/updateReferralAccount.d.ts +1 -2
- package/declarations/instructions/updateReferralState.d.ts +1 -2
- package/declarations/instructions/updateVaultType.d.ts +1 -2
- package/declarations/instructions/withdrawStakingPool.d.ts +1 -1
- package/declarations/instructions/withdrawVault.d.ts +1 -2
- package/declarations/state/VaultAccount.d.ts +2 -3
- package/declarations/utils/getLinkedListAccounts.d.ts +1 -2
- package/lib/Constants.js +27 -54
- package/lib/HedgeConstants.js +170 -0
- package/lib/HedgeDecimal.js +1 -2
- package/lib/StakingPools.js +5 -1
- package/lib/Vaults.js +5 -1
- package/lib/idl/vault.js +60 -744
- package/lib/index.js +6 -11
- package/lib/instructions/claimLiquidationPoolPosition.js +7 -8
- package/lib/instructions/claimStakingPoolPosition.js +7 -8
- package/lib/instructions/closeClaimedLiquidationPoolPosition.js +2 -3
- package/lib/instructions/closeLiquidationPoolPosition.js +16 -17
- package/lib/instructions/createReferralAccount.js +13 -17
- package/lib/instructions/createStakingPool.js +10 -11
- package/lib/instructions/createUserReferralAccount.js +9 -10
- package/lib/instructions/createVault.js +20 -21
- package/lib/instructions/depositLiquidationPool.js +12 -13
- package/lib/instructions/depositStakingPool.js +8 -9
- package/lib/instructions/depositVault.js +10 -11
- package/lib/instructions/initHedgeFoundation.js +10 -11
- package/lib/instructions/initHedgeFoundationTokens.js +7 -8
- package/lib/instructions/liquidateVault.js +12 -19
- package/lib/instructions/loanVault.js +16 -23
- package/lib/instructions/psmEditAccount.js +11 -11
- package/lib/instructions/psmMintUsh.js +18 -19
- package/lib/instructions/psmRedeemUsh.js +18 -19
- package/lib/instructions/redeemVault.js +10 -11
- package/lib/instructions/referralClaimFees.js +12 -16
- package/lib/instructions/refreshOraclePrice.js +9 -9
- package/lib/instructions/repayVault.js +12 -13
- package/lib/instructions/setHalted.js +4 -5
- package/lib/instructions/transferVault.js +2 -3
- package/lib/instructions/updateReferralAccount.js +6 -7
- package/lib/instructions/updateReferralState.js +6 -7
- package/lib/instructions/updateVaultType.js +5 -6
- package/lib/instructions/withdrawStakingPool.js +14 -15
- package/lib/instructions/withdrawVault.js +8 -9
- package/lib/state/VaultAccount.js +22 -8
- package/lib/state/VaultHistoryEvent.js +2 -2
- package/lib/utils/Errors.js +2 -3
- package/lib/utils/getLinkedListAccounts.js +2 -3
- package/lib/utils/sendAndConfirmWithDebug.js +1 -1
- package/package.json +9 -8
- package/src/{Constants.ts → HedgeConstants.ts} +13 -43
- package/src/idl/vault.ts +2382 -3750
- package/src/index.ts +3 -10
- package/src/instructions/claimLiquidationPoolPosition.ts +2 -2
- package/src/instructions/claimStakingPoolPosition.ts +2 -2
- package/src/instructions/closeClaimedLiquidationPoolPosition.ts +1 -1
- package/src/instructions/closeLiquidationPoolPosition.ts +2 -2
- package/src/instructions/createReferralAccount.ts +11 -15
- package/src/instructions/createStakingPool.ts +11 -4
- package/src/instructions/createUserReferralAccount.ts +2 -2
- package/src/instructions/createVault.ts +2 -2
- package/src/instructions/depositLiquidationPool.ts +2 -2
- package/src/instructions/depositStakingPool.ts +2 -2
- package/src/instructions/depositVault.ts +2 -2
- package/src/instructions/initHedgeFoundation.ts +2 -2
- package/src/instructions/initHedgeFoundationTokens.ts +2 -2
- package/src/instructions/liquidateVault.ts +29 -39
- package/src/instructions/loanVault.ts +23 -36
- package/src/instructions/psmEditAccount.ts +3 -3
- package/src/instructions/psmMintUsh.ts +3 -3
- package/src/instructions/psmRedeemUsh.ts +3 -3
- package/src/instructions/redeemVault.ts +2 -2
- package/src/instructions/referralClaimFees.ts +12 -18
- package/src/instructions/refreshOraclePrice.ts +4 -4
- package/src/instructions/repayVault.ts +2 -2
- package/src/instructions/setHalted.ts +2 -2
- package/src/instructions/transferVault.ts +1 -1
- package/src/instructions/updateReferralAccount.ts +2 -2
- package/src/instructions/updateReferralState.ts +2 -2
- package/src/instructions/updateVaultType.ts +2 -2
- package/src/instructions/withdrawStakingPool.ts +2 -2
- package/src/instructions/withdrawVault.ts +2 -2
- package/src/utils/Errors.ts +1 -1
- package/src/utils/getLinkedListAccounts.ts +1 -1
- package/declarations/instructions/adminWithdrawCol.d.ts +0 -5
- package/declarations/instructions/adminWithdrawUsh.d.ts +0 -5
- package/declarations/instructions/createCompoundStakingPool.d.ts +0 -5
- package/declarations/instructions/createCompoundStakingPoolPosition.d.ts +0 -6
- package/declarations/instructions/depositCompoundStakingPoolPosition.d.ts +0 -6
- package/declarations/instructions/depositRewardsToCompoundPool.d.ts +0 -6
- package/declarations/instructions/setCompoundPoolActive.d.ts +0 -5
- package/declarations/instructions/setDelegateWallet.d.ts +0 -5
- package/declarations/instructions/setVaultTypeStatus.d.ts +0 -4
- package/declarations/instructions/withdrawCompoundStakingPoolPosition.d.ts +0 -6
- package/declarations/utils/Sender.d.ts +0 -2
- package/lib/instructions/adminWithdrawCol.js +0 -60
- package/lib/instructions/adminWithdrawUsh.js +0 -57
- package/lib/instructions/createCompoundStakingPool.js +0 -58
- package/lib/instructions/createCompoundStakingPoolPosition.js +0 -56
- package/lib/instructions/depositCompoundStakingPoolPosition.js +0 -55
- package/lib/instructions/depositRewardsToCompoundPool.js +0 -64
- package/lib/instructions/setCompoundPoolActive.js +0 -43
- package/lib/instructions/setDelegateWallet.js +0 -43
- package/lib/instructions/setVaultTypeStatus.js +0 -38
- package/lib/instructions/withdrawCompoundStakingPoolPosition.js +0 -64
- package/lib/utils/Sender.js +0 -32
- package/src/instructions/adminWithdrawCol.ts +0 -87
- package/src/instructions/adminWithdrawUsh.ts +0 -78
- package/src/instructions/createCompoundStakingPool.ts +0 -63
- package/src/instructions/createCompoundStakingPoolPosition.ts +0 -85
- package/src/instructions/depositCompoundStakingPoolPosition.ts +0 -78
- package/src/instructions/depositRewardsToCompoundPool.ts +0 -110
- package/src/instructions/setCompoundPoolActive.ts +0 -51
- package/src/instructions/setDelegateWallet.ts +0 -51
- package/src/instructions/withdrawCompoundStakingPoolPosition.ts +0 -100
@@ -1,43 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
-
});
|
10
|
-
};
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
-
};
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
-
exports.setCompoundPoolActiveInstruction = exports.setCompoundPoolActive = void 0;
|
16
|
-
const web3_js_1 = require("@solana/web3.js");
|
17
|
-
const Constants_1 = require("../Constants");
|
18
|
-
const Errors_1 = require("../utils/Errors");
|
19
|
-
const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
|
20
|
-
function setCompoundPoolActive(program, provider, payer, mintPublicKey, setActive) {
|
21
|
-
return __awaiter(this, void 0, void 0, function* () {
|
22
|
-
const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)(program.programId);
|
23
|
-
const [poolPublickey] = yield (0, Constants_1.getPoolPublicKeyForMint)(program.programId, mintPublicKey);
|
24
|
-
const transaction = new web3_js_1.Transaction().add(yield setCompoundPoolActiveInstruction(program, vaultSystemStatePublicKey, payer.publicKey, poolPublickey, mintPublicKey, setActive));
|
25
|
-
yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer]).catch(Errors_1.parseAnchorErrors);
|
26
|
-
return poolPublickey;
|
27
|
-
});
|
28
|
-
}
|
29
|
-
exports.setCompoundPoolActive = setCompoundPoolActive;
|
30
|
-
function setCompoundPoolActiveInstruction(program, vaultSystemStatePublicKey, payerPublicKey, poolPublicKey, stakedTokenMintPublicKey, setActive) {
|
31
|
-
return __awaiter(this, void 0, void 0, function* () {
|
32
|
-
return yield program.methods
|
33
|
-
.setCompoundPoolActive(setActive)
|
34
|
-
.accounts({
|
35
|
-
payer: payerPublicKey,
|
36
|
-
vaultSystemState: vaultSystemStatePublicKey,
|
37
|
-
pool: poolPublicKey,
|
38
|
-
stakedTokenMint: stakedTokenMintPublicKey,
|
39
|
-
})
|
40
|
-
.instruction();
|
41
|
-
});
|
42
|
-
}
|
43
|
-
exports.setCompoundPoolActiveInstruction = setCompoundPoolActiveInstruction;
|
@@ -1,43 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
-
});
|
10
|
-
};
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
-
};
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
-
exports.setDelegateWalletInstruction = exports.setDelegateWallet = void 0;
|
16
|
-
const web3_js_1 = require("@solana/web3.js");
|
17
|
-
const Constants_1 = require("../Constants");
|
18
|
-
const Errors_1 = require("../utils/Errors");
|
19
|
-
const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
|
20
|
-
function setDelegateWallet(program, provider, payer, mintPublicKey, delegateWallet) {
|
21
|
-
return __awaiter(this, void 0, void 0, function* () {
|
22
|
-
const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)(program.programId);
|
23
|
-
const [poolPublickey] = yield (0, Constants_1.getPoolPublicKeyForMint)(program.programId, mintPublicKey);
|
24
|
-
const transaction = new web3_js_1.Transaction().add(yield setDelegateWalletInstruction(program, vaultSystemStatePublicKey, payer.publicKey, poolPublickey, mintPublicKey, delegateWallet));
|
25
|
-
yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer]).catch(Errors_1.parseAnchorErrors);
|
26
|
-
return delegateWallet;
|
27
|
-
});
|
28
|
-
}
|
29
|
-
exports.setDelegateWallet = setDelegateWallet;
|
30
|
-
function setDelegateWalletInstruction(program, vaultSystemStatePublicKey, payerPublicKey, poolPublicKey, stakedTokenMintPublicKey, delegateWallet) {
|
31
|
-
return __awaiter(this, void 0, void 0, function* () {
|
32
|
-
return yield program.methods
|
33
|
-
.setDelegateWallet(delegateWallet)
|
34
|
-
.accounts({
|
35
|
-
payer: payerPublicKey,
|
36
|
-
vaultSystemState: vaultSystemStatePublicKey,
|
37
|
-
pool: poolPublicKey,
|
38
|
-
stakedTokenMint: stakedTokenMintPublicKey,
|
39
|
-
})
|
40
|
-
.instruction();
|
41
|
-
});
|
42
|
-
}
|
43
|
-
exports.setDelegateWalletInstruction = setDelegateWalletInstruction;
|
@@ -1,38 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
-
});
|
10
|
-
};
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
-
exports.setVaultTypeStatusInstruction = exports.setVaultTypeStatus = void 0;
|
13
|
-
const web3_js_1 = require("@solana/web3.js");
|
14
|
-
const Constants_1 = require("../Constants");
|
15
|
-
const Errors_1 = require("../utils/Errors");
|
16
|
-
function setVaultTypeStatus(program, provider, payer, vaultTypeAccount, deprecated) {
|
17
|
-
return __awaiter(this, void 0, void 0, function* () {
|
18
|
-
const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
|
19
|
-
const transaction = new web3_js_1.Transaction().add(yield setVaultTypeStatusInstruction(program, vaultSystemStatePublicKey, payer.publicKey, vaultTypeAccount, deprecated));
|
20
|
-
yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer], provider === null || provider === void 0 ? void 0 : provider.opts).catch(Errors_1.parseAnchorErrors);
|
21
|
-
return vaultSystemStatePublicKey;
|
22
|
-
});
|
23
|
-
}
|
24
|
-
exports.setVaultTypeStatus = setVaultTypeStatus;
|
25
|
-
function setVaultTypeStatusInstruction(program, vaultSystemStatePublicKey, payerPublicKey, vaultTypeAccount, deprecated) {
|
26
|
-
return __awaiter(this, void 0, void 0, function* () {
|
27
|
-
const ix = program.instruction.setVaultTypeStatus(deprecated, {
|
28
|
-
accounts: {
|
29
|
-
payer: payerPublicKey,
|
30
|
-
vaultSystemState: vaultSystemStatePublicKey,
|
31
|
-
vaultType: vaultTypeAccount,
|
32
|
-
},
|
33
|
-
signers: []
|
34
|
-
});
|
35
|
-
return ix;
|
36
|
-
});
|
37
|
-
}
|
38
|
-
exports.setVaultTypeStatusInstruction = setVaultTypeStatusInstruction;
|
@@ -1,64 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
-
});
|
10
|
-
};
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
-
};
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
-
exports.withdrawCompoundStakingPoolPositionInstruction = exports.withdrawCompoundStakingPoolPosition = void 0;
|
16
|
-
const anchor_1 = require("@project-serum/anchor");
|
17
|
-
const spl_token_1 = require("@solana/spl-token");
|
18
|
-
const web3_js_1 = require("@solana/web3.js");
|
19
|
-
const Constants_1 = require("../Constants");
|
20
|
-
const Errors_1 = require("../utils/Errors");
|
21
|
-
const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
|
22
|
-
function withdrawCompoundStakingPoolPosition(program, provider, payer, poolPositionPublicKey, stakedTokenMintPublicKey, claimAmount, overrideStartTime) {
|
23
|
-
return __awaiter(this, void 0, void 0, function* () {
|
24
|
-
const [poolPublickey, poolBump] = yield (0, Constants_1.getCompoundPoolPublicKeyForMint)(program.programId, stakedTokenMintPublicKey);
|
25
|
-
const poolPosition = yield (0, Constants_1.getCompoundPoolPositionAddress)(program.programId, poolPublickey, payer.publicKey);
|
26
|
-
const payerAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, stakedTokenMintPublicKey, payer.publicKey);
|
27
|
-
const transaction = new web3_js_1.Transaction().add(yield withdrawCompoundStakingPoolPositionInstruction(program, payer.publicKey, poolPositionPublicKey, stakedTokenMintPublicKey, new anchor_1.BN(claimAmount), overrideStartTime));
|
28
|
-
yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer]).catch(Errors_1.parseAnchorErrors);
|
29
|
-
return payerAssociatedTokenAccount.address;
|
30
|
-
});
|
31
|
-
}
|
32
|
-
exports.withdrawCompoundStakingPoolPosition = withdrawCompoundStakingPoolPosition;
|
33
|
-
function withdrawCompoundStakingPoolPositionInstruction(program, payerPublicKey, poolPositionPublicKey, stakedTokenMintPublicKey, claimAmount, overrideStartTime) {
|
34
|
-
return __awaiter(this, void 0, void 0, function* () {
|
35
|
-
const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)(program.programId);
|
36
|
-
const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)(program.programId);
|
37
|
-
const hedgeMintPublickey = yield (0, Constants_1.getHedgeMintPublicKey)(program.programId);
|
38
|
-
const [poolPublickey, poolBump] = yield (0, Constants_1.getCompoundPoolPublicKeyForMint)(program.programId, stakedTokenMintPublicKey);
|
39
|
-
const poolAssociatedStakedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, poolPublickey, stakedTokenMintPublicKey);
|
40
|
-
const poolAssociatedUshTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, poolPublickey, ushMintPublickey);
|
41
|
-
const payerAssociatedStakedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, payerPublicKey, stakedTokenMintPublicKey);
|
42
|
-
const payerAssociatedHedgeAccount = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, payerPublicKey, hedgeMintPublickey);
|
43
|
-
const payerAssociatedUshAccount = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, payerPublicKey, ushMintPublickey);
|
44
|
-
const communityHedgeTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, vaultSystemStatePublicKey, hedgeMintPublickey);
|
45
|
-
return yield program.methods
|
46
|
-
.withdrawCompoundStakingPoolPosition(new anchor_1.BN(overrideStartTime !== null && overrideStartTime !== void 0 ? overrideStartTime : Math.floor(Date.now() / 1000)), // override current time
|
47
|
-
claimAmount //amount to be claimed
|
48
|
-
)
|
49
|
-
.accounts({
|
50
|
-
payer: payerPublicKey,
|
51
|
-
vaultSystemState: vaultSystemStatePublicKey,
|
52
|
-
pool: poolPublickey,
|
53
|
-
poolPosition: poolPositionPublicKey,
|
54
|
-
poolAssociatedStakedTokenAccount: poolAssociatedStakedTokenAccount,
|
55
|
-
payerAssociatedStakedTokenAccount: payerAssociatedStakedTokenAccount,
|
56
|
-
hedgeMint: hedgeMintPublickey,
|
57
|
-
stakedTokenMint: stakedTokenMintPublicKey,
|
58
|
-
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
59
|
-
systemProgram: web3_js_1.SystemProgram.programId,
|
60
|
-
})
|
61
|
-
.instruction();
|
62
|
-
});
|
63
|
-
}
|
64
|
-
exports.withdrawCompoundStakingPoolPositionInstruction = withdrawCompoundStakingPoolPositionInstruction;
|
package/lib/utils/Sender.js
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
-
});
|
10
|
-
};
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
-
exports.sendAndConfirmWithDebug = void 0;
|
13
|
-
function sendAndConfirmWithDebug(connection, transaction, signers) {
|
14
|
-
return __awaiter(this, void 0, void 0, function* () {
|
15
|
-
return connection
|
16
|
-
.sendTransaction(transaction, signers)
|
17
|
-
.then((signature) => {
|
18
|
-
return connection
|
19
|
-
.confirmTransaction(signature)
|
20
|
-
.then((signatureContext) => {
|
21
|
-
return signature;
|
22
|
-
})
|
23
|
-
.catch((error) => {
|
24
|
-
console.log('There was an error confirming the transaction', error);
|
25
|
-
});
|
26
|
-
})
|
27
|
-
.catch((error) => {
|
28
|
-
console.log('There was an error sending the transaction', error);
|
29
|
-
});
|
30
|
-
});
|
31
|
-
}
|
32
|
-
exports.sendAndConfirmWithDebug = sendAndConfirmWithDebug;
|
@@ -1,87 +0,0 @@
|
|
1
|
-
import { BN, Program, Provider } from '@project-serum/anchor'
|
2
|
-
import { ASSOCIATED_TOKEN_PROGRAM_ID, getOrCreateAssociatedTokenAccount, TOKEN_PROGRAM_ID } from '@solana/spl-token'
|
3
|
-
import { Keypair, PublicKey, Signer, SystemProgram, Transaction, TransactionInstruction } from '@solana/web3.js'
|
4
|
-
import {
|
5
|
-
findAssociatedTokenAddress,
|
6
|
-
getPoolPublicKeyForMint,
|
7
|
-
getVaultSystemStatePublicKey,
|
8
|
-
getVaultTypeAccountPublicKey,
|
9
|
-
} from '../Constants'
|
10
|
-
import { Vault } from '../idl/vault'
|
11
|
-
import { parseAnchorErrors } from '../utils/Errors'
|
12
|
-
import sendAndConfirmWithDebug from '../utils/sendAndConfirmWithDebug'
|
13
|
-
|
14
|
-
export async function adminWithdrawCollateral(
|
15
|
-
program: Program<Vault>,
|
16
|
-
provider: Provider,
|
17
|
-
payer: Signer,
|
18
|
-
mintPublicKey: PublicKey,
|
19
|
-
collateralType: string
|
20
|
-
): Promise<PublicKey> {
|
21
|
-
const [poolPublickey] = await getPoolPublicKeyForMint(program.programId, mintPublicKey)
|
22
|
-
const vaultTypeAccountPublicKey = await getVaultTypeAccountPublicKey(program.programId, collateralType)
|
23
|
-
const vaultTypeAccountInfo = await program.account.vaultType.fetch(vaultTypeAccountPublicKey)
|
24
|
-
const stakingPoolAccountObject = await program.account.stakingPool.fetch(poolPublickey)
|
25
|
-
|
26
|
-
const payerAssociatedTokenAccount = await getOrCreateAssociatedTokenAccount(
|
27
|
-
provider.connection,
|
28
|
-
payer,
|
29
|
-
vaultTypeAccountInfo.collateralMint,
|
30
|
-
stakingPoolAccountObject.compoundPoolDelegateWallet
|
31
|
-
)
|
32
|
-
|
33
|
-
const poolAssociatedTokenAccount = await findAssociatedTokenAddress(
|
34
|
-
program.programId,
|
35
|
-
poolPublickey,
|
36
|
-
vaultTypeAccountInfo.collateralMint
|
37
|
-
)
|
38
|
-
|
39
|
-
const transaction = new Transaction().add(
|
40
|
-
await adminWithdrawCollateralInstruction(program, payer.publicKey, mintPublicKey, vaultTypeAccountPublicKey)
|
41
|
-
)
|
42
|
-
await sendAndConfirmWithDebug(provider.connection, transaction, [payer]).catch(parseAnchorErrors)
|
43
|
-
|
44
|
-
return poolPublickey
|
45
|
-
}
|
46
|
-
|
47
|
-
export async function adminWithdrawCollateralInstruction(
|
48
|
-
program: Program<Vault>,
|
49
|
-
payerPublicKey: PublicKey,
|
50
|
-
stakedTokenMintPublicKey: PublicKey,
|
51
|
-
vaultTypeAccountPublicKey: PublicKey
|
52
|
-
): Promise<TransactionInstruction> {
|
53
|
-
const [poolPublickey] = await getPoolPublicKeyForMint(program.programId, stakedTokenMintPublicKey)
|
54
|
-
|
55
|
-
const vaultTypeAccountInfo = await program.account.vaultType.fetch(vaultTypeAccountPublicKey)
|
56
|
-
const stakingPoolAccountObject = await program.account.stakingPool.fetch(poolPublickey)
|
57
|
-
|
58
|
-
const poolAssociatedTokenAccount = await findAssociatedTokenAddress(
|
59
|
-
program.programId,
|
60
|
-
poolPublickey,
|
61
|
-
vaultTypeAccountInfo.collateralMint
|
62
|
-
)
|
63
|
-
|
64
|
-
const delegateAssociatedTokenAccount = await findAssociatedTokenAddress(
|
65
|
-
program.programId,
|
66
|
-
stakingPoolAccountObject.compoundPoolDelegateWallet,
|
67
|
-
vaultTypeAccountInfo.collateralMint
|
68
|
-
)
|
69
|
-
|
70
|
-
const vaultSystemState = await getVaultSystemStatePublicKey(program.programId)
|
71
|
-
|
72
|
-
return await program.methods
|
73
|
-
.adminWithdrawColAta()
|
74
|
-
.accounts({
|
75
|
-
payer: payerPublicKey,
|
76
|
-
vaultSystemState: vaultSystemState,
|
77
|
-
pool: poolPublickey,
|
78
|
-
vaultTypeAccount: vaultTypeAccountPublicKey,
|
79
|
-
stakedTokenMint: stakedTokenMintPublicKey,
|
80
|
-
poolAssociatedTokenAccount: poolAssociatedTokenAccount,
|
81
|
-
delegateAssociatedColAccount: delegateAssociatedTokenAccount,
|
82
|
-
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
|
83
|
-
tokenProgram: TOKEN_PROGRAM_ID,
|
84
|
-
systemProgram: SystemProgram.programId,
|
85
|
-
})
|
86
|
-
.instruction()
|
87
|
-
}
|
@@ -1,78 +0,0 @@
|
|
1
|
-
import { BN, Program, Provider } from '@project-serum/anchor'
|
2
|
-
import { ASSOCIATED_TOKEN_PROGRAM_ID, getOrCreateAssociatedTokenAccount, TOKEN_PROGRAM_ID } from '@solana/spl-token'
|
3
|
-
import { Keypair, PublicKey, Signer, SystemProgram, Transaction, TransactionInstruction } from '@solana/web3.js'
|
4
|
-
import {
|
5
|
-
findAssociatedTokenAddress,
|
6
|
-
getPoolPublicKeyForMint,
|
7
|
-
getUshMintPublicKey,
|
8
|
-
getVaultSystemStatePublicKey,
|
9
|
-
} from '../Constants'
|
10
|
-
import { Vault } from '../idl/vault'
|
11
|
-
import { parseAnchorErrors } from '../utils/Errors'
|
12
|
-
import sendAndConfirmWithDebug from '../utils/sendAndConfirmWithDebug'
|
13
|
-
|
14
|
-
export async function adminWithdrawUsh(
|
15
|
-
program: Program<Vault>,
|
16
|
-
provider: Provider,
|
17
|
-
payer: Signer,
|
18
|
-
mintPublicKey: PublicKey
|
19
|
-
): Promise<PublicKey> {
|
20
|
-
const [poolPublickey] = await getPoolPublicKeyForMint(program.programId, mintPublicKey)
|
21
|
-
|
22
|
-
const stakingPoolAccountObject = await program.account.stakingPool.fetch(poolPublickey)
|
23
|
-
|
24
|
-
const ushMintPublickey = await getUshMintPublicKey(program.programId)
|
25
|
-
|
26
|
-
const payerAssociatedTokenAccount = await getOrCreateAssociatedTokenAccount(
|
27
|
-
provider.connection,
|
28
|
-
payer,
|
29
|
-
ushMintPublickey,
|
30
|
-
stakingPoolAccountObject.compoundPoolDelegateWallet
|
31
|
-
)
|
32
|
-
|
33
|
-
const transaction = new Transaction().add(
|
34
|
-
await adminWithdrawUshInstruction(program, payer.publicKey, mintPublicKey, poolPublickey)
|
35
|
-
)
|
36
|
-
await sendAndConfirmWithDebug(provider.connection, transaction, [payer]).catch(parseAnchorErrors)
|
37
|
-
return poolPublickey
|
38
|
-
}
|
39
|
-
|
40
|
-
export async function adminWithdrawUshInstruction(
|
41
|
-
program: Program<Vault>,
|
42
|
-
payerPublicKey: PublicKey,
|
43
|
-
stakedTokenMintPublicKey: PublicKey,
|
44
|
-
poolPublickey: PublicKey
|
45
|
-
): Promise<TransactionInstruction> {
|
46
|
-
const ushMintPublickey = await getUshMintPublicKey(program.programId)
|
47
|
-
const vaultSystemState = await getVaultSystemStatePublicKey(program.programId)
|
48
|
-
|
49
|
-
const poolAssociatedStakedTokenAccount = await findAssociatedTokenAddress(
|
50
|
-
program.programId,
|
51
|
-
poolPublickey,
|
52
|
-
ushMintPublickey
|
53
|
-
)
|
54
|
-
|
55
|
-
const stakingPoolAccountObject = await program.account.stakingPool.fetch(poolPublickey)
|
56
|
-
|
57
|
-
const delegateWalletAssociatedStakedTokenAccount = await findAssociatedTokenAddress(
|
58
|
-
program.programId,
|
59
|
-
stakingPoolAccountObject.compoundPoolDelegateWallet,
|
60
|
-
ushMintPublickey
|
61
|
-
)
|
62
|
-
|
63
|
-
return await program.methods
|
64
|
-
.adminWithdrawUshAta()
|
65
|
-
.accounts({
|
66
|
-
payer: payerPublicKey,
|
67
|
-
vaultSystemState: vaultSystemState,
|
68
|
-
pool: poolPublickey,
|
69
|
-
ushMint: ushMintPublickey,
|
70
|
-
stakedTokenMint: stakedTokenMintPublicKey,
|
71
|
-
poolAssociatedTokenAccount: poolAssociatedStakedTokenAccount,
|
72
|
-
delegateAssociatedUshAccount: delegateWalletAssociatedStakedTokenAccount,
|
73
|
-
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
|
74
|
-
tokenProgram: TOKEN_PROGRAM_ID,
|
75
|
-
systemProgram: SystemProgram.programId,
|
76
|
-
})
|
77
|
-
.instruction()
|
78
|
-
}
|
@@ -1,63 +0,0 @@
|
|
1
|
-
import { BN, Program, Provider } from '@project-serum/anchor'
|
2
|
-
import { ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID } from '@solana/spl-token'
|
3
|
-
import { PublicKey, Signer, SystemProgram, SYSVAR_RENT_PUBKEY, Transaction, TransactionInstruction } from '@solana/web3.js'
|
4
|
-
import {
|
5
|
-
findAssociatedTokenAddress,
|
6
|
-
getCompoundPoolPublicKeyForMint,
|
7
|
-
getHedgeMintPublicKey,
|
8
|
-
getPoolPublicKeyForMint,
|
9
|
-
getUshMintPublicKey,
|
10
|
-
getVaultSystemStatePublicKey,
|
11
|
-
} from '../Constants'
|
12
|
-
import { Vault } from '../idl/vault'
|
13
|
-
import { parseAnchorErrors } from '../utils/Errors'
|
14
|
-
import sendAndConfirmWithDebug from '../utils/sendAndConfirmWithDebug'
|
15
|
-
|
16
|
-
export async function createCompoundStakingPool(
|
17
|
-
program: Program<Vault>,
|
18
|
-
provider: Provider,
|
19
|
-
payer: Signer,
|
20
|
-
mintPublicKey: PublicKey,
|
21
|
-
overrideStartTime?: number
|
22
|
-
): Promise<PublicKey> {
|
23
|
-
const transaction = new Transaction().add(
|
24
|
-
await createCompoundStakingPoolInstruction(program, payer.publicKey, mintPublicKey, overrideStartTime)
|
25
|
-
)
|
26
|
-
await sendAndConfirmWithDebug(provider.connection, transaction, [payer]).catch(parseAnchorErrors)
|
27
|
-
const [poolPublickey] = await getCompoundPoolPublicKeyForMint(program.programId, mintPublicKey)
|
28
|
-
return poolPublickey
|
29
|
-
}
|
30
|
-
|
31
|
-
export async function createCompoundStakingPoolInstruction(
|
32
|
-
program: Program<Vault>,
|
33
|
-
payerPublicKey: PublicKey,
|
34
|
-
mintPublicKey: PublicKey,
|
35
|
-
overrideStartTime?: number
|
36
|
-
): Promise<TransactionInstruction> {
|
37
|
-
const vaultSystemStatePublicKey = await getVaultSystemStatePublicKey(program.programId)
|
38
|
-
const ushMintPublickey = await getUshMintPublicKey(program.programId)
|
39
|
-
const hedgeMintPublickey = await getHedgeMintPublicKey(program.programId)
|
40
|
-
|
41
|
-
const [poolPublickey, poolBump] = await getCompoundPoolPublicKeyForMint(program.programId, mintPublicKey)
|
42
|
-
|
43
|
-
const poolAssociatedStakedTokenAccount = await findAssociatedTokenAddress(program.programId, poolPublickey, mintPublicKey)
|
44
|
-
const poolAssociatedUshTokenAccount = await findAssociatedTokenAddress(program.programId, poolPublickey, ushMintPublickey)
|
45
|
-
|
46
|
-
return await program.methods
|
47
|
-
.createCompoundStakingPool(new BN(overrideStartTime ?? Math.floor(Date.now() / 1000)))
|
48
|
-
.accounts({
|
49
|
-
signer: payerPublicKey,
|
50
|
-
vaultSystemState: vaultSystemStatePublicKey,
|
51
|
-
pool: poolPublickey,
|
52
|
-
stakedTokenMint: mintPublicKey,
|
53
|
-
ushMint: ushMintPublickey,
|
54
|
-
hedgeMint: hedgeMintPublickey,
|
55
|
-
poolAssociatedStakedTokenAccount: poolAssociatedStakedTokenAccount,
|
56
|
-
poolAssociatedUshTokenAccount: poolAssociatedUshTokenAccount,
|
57
|
-
rent: SYSVAR_RENT_PUBKEY,
|
58
|
-
tokenProgram: TOKEN_PROGRAM_ID,
|
59
|
-
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
|
60
|
-
systemProgram: SystemProgram.programId,
|
61
|
-
})
|
62
|
-
.instruction()
|
63
|
-
}
|
@@ -1,85 +0,0 @@
|
|
1
|
-
import { BN, Program, Provider } from '@project-serum/anchor'
|
2
|
-
import { getOrCreateAssociatedTokenAccount, TOKEN_PROGRAM_ID } from '@solana/spl-token'
|
3
|
-
import { Keypair, PublicKey, Signer, SystemProgram, Transaction, TransactionInstruction } from '@solana/web3.js'
|
4
|
-
import {
|
5
|
-
findAssociatedTokenAddress,
|
6
|
-
getCompoundPoolPositionAddress,
|
7
|
-
getCompoundPoolPublicKeyForMint,
|
8
|
-
getPoolPublicKeyForMint,
|
9
|
-
getVaultSystemStatePublicKey,
|
10
|
-
} from '../Constants'
|
11
|
-
import { Vault } from '../idl/vault'
|
12
|
-
import { parseAnchorErrors } from '../utils/Errors'
|
13
|
-
import sendAndConfirmWithDebug from '../utils/sendAndConfirmWithDebug'
|
14
|
-
|
15
|
-
export async function createCompoundStakingPoolPosition(
|
16
|
-
program: Program<Vault>,
|
17
|
-
provider: Provider,
|
18
|
-
payer: Signer,
|
19
|
-
mintPublicKey: PublicKey,
|
20
|
-
depositAmount: number,
|
21
|
-
overrideStartTime?: number
|
22
|
-
): Promise<PublicKey> {
|
23
|
-
const [poolPublickey, poolBump] = await getCompoundPoolPublicKeyForMint(program.programId, mintPublicKey)
|
24
|
-
const poolPosition = await getCompoundPoolPositionAddress(program.programId, poolPublickey, payer.publicKey)
|
25
|
-
|
26
|
-
const payerAssociatedTokenAccount = await getOrCreateAssociatedTokenAccount(
|
27
|
-
provider.connection,
|
28
|
-
payer,
|
29
|
-
mintPublicKey,
|
30
|
-
payer.publicKey
|
31
|
-
)
|
32
|
-
|
33
|
-
const transaction = new Transaction().add(
|
34
|
-
await createCompoundStakingPoolPositionInstruction(
|
35
|
-
program,
|
36
|
-
payer.publicKey,
|
37
|
-
poolPosition,
|
38
|
-
mintPublicKey,
|
39
|
-
new BN(depositAmount),
|
40
|
-
overrideStartTime
|
41
|
-
)
|
42
|
-
)
|
43
|
-
await sendAndConfirmWithDebug(provider.connection, transaction, [payer]).catch(parseAnchorErrors)
|
44
|
-
return poolPosition
|
45
|
-
}
|
46
|
-
export async function createCompoundStakingPoolPositionInstruction(
|
47
|
-
program: Program<Vault>,
|
48
|
-
payerPublicKey: PublicKey,
|
49
|
-
poolPositionPublicKey: PublicKey,
|
50
|
-
stakedTokenMintPublicKey: PublicKey,
|
51
|
-
depositAmount: BN,
|
52
|
-
overrideStartTime?: number
|
53
|
-
): Promise<TransactionInstruction> {
|
54
|
-
const [poolPublickey] = await getCompoundPoolPublicKeyForMint(program.programId, stakedTokenMintPublicKey)
|
55
|
-
|
56
|
-
const poolAssociatedStakedTokenAccount = await findAssociatedTokenAddress(
|
57
|
-
program.programId,
|
58
|
-
poolPublickey,
|
59
|
-
stakedTokenMintPublicKey
|
60
|
-
)
|
61
|
-
const payersArbitraryTokenAccount = await findAssociatedTokenAddress(
|
62
|
-
program.programId,
|
63
|
-
payerPublicKey,
|
64
|
-
stakedTokenMintPublicKey
|
65
|
-
)
|
66
|
-
const vaultSystemState = await getVaultSystemStatePublicKey(program.programId)
|
67
|
-
|
68
|
-
return await program.methods
|
69
|
-
.createCompoundStakingPoolPosition(
|
70
|
-
depositAmount,
|
71
|
-
new BN(overrideStartTime ?? Math.floor(Date.now() / 1000)) // override current time
|
72
|
-
)
|
73
|
-
.accounts({
|
74
|
-
payer: payerPublicKey,
|
75
|
-
vaultSystemState: vaultSystemState,
|
76
|
-
pool: poolPublickey,
|
77
|
-
poolPosition: poolPositionPublicKey,
|
78
|
-
stakedTokenMint: stakedTokenMintPublicKey,
|
79
|
-
poolAssociatedStakedTokenAccount: poolAssociatedStakedTokenAccount,
|
80
|
-
payerAssociatedStakedTokenAccount: payersArbitraryTokenAccount,
|
81
|
-
tokenProgram: TOKEN_PROGRAM_ID,
|
82
|
-
systemProgram: SystemProgram.programId,
|
83
|
-
})
|
84
|
-
.instruction()
|
85
|
-
}
|
@@ -1,78 +0,0 @@
|
|
1
|
-
import { BN, Program, Provider } from '@project-serum/anchor'
|
2
|
-
import { TOKEN_PROGRAM_ID } from '@solana/spl-token'
|
3
|
-
import { Keypair, PublicKey, Signer, SystemProgram, Transaction, TransactionInstruction } from '@solana/web3.js'
|
4
|
-
import {
|
5
|
-
findAssociatedTokenAddress,
|
6
|
-
getCompoundPoolPositionAddress,
|
7
|
-
getCompoundPoolPublicKeyForMint,
|
8
|
-
getPoolPublicKeyForMint,
|
9
|
-
getVaultSystemStatePublicKey,
|
10
|
-
} from '../Constants'
|
11
|
-
import { Vault } from '../idl/vault'
|
12
|
-
import { parseAnchorErrors } from '../utils/Errors'
|
13
|
-
import sendAndConfirmWithDebug from '../utils/sendAndConfirmWithDebug'
|
14
|
-
|
15
|
-
export async function depositCompoundStakingPoolPosition(
|
16
|
-
program: Program<Vault>,
|
17
|
-
provider: Provider,
|
18
|
-
payer: Signer,
|
19
|
-
mintPublicKey: PublicKey,
|
20
|
-
depositAmount: number,
|
21
|
-
overrideStartTime?: number
|
22
|
-
): Promise<PublicKey> {
|
23
|
-
const [poolPublickey, poolBump] = await getCompoundPoolPublicKeyForMint(program.programId, mintPublicKey)
|
24
|
-
|
25
|
-
const poolPosition = await getCompoundPoolPositionAddress(program.programId, poolPublickey, payer.publicKey)
|
26
|
-
const transaction = new Transaction().add(
|
27
|
-
await depositCompoundStakingPoolPositionInstruction(
|
28
|
-
program,
|
29
|
-
payer.publicKey,
|
30
|
-
poolPosition,
|
31
|
-
mintPublicKey,
|
32
|
-
new BN(depositAmount),
|
33
|
-
overrideStartTime
|
34
|
-
)
|
35
|
-
)
|
36
|
-
await sendAndConfirmWithDebug(provider.connection, transaction, [payer]).catch(parseAnchorErrors)
|
37
|
-
return poolPosition
|
38
|
-
}
|
39
|
-
|
40
|
-
export async function depositCompoundStakingPoolPositionInstruction(
|
41
|
-
program: Program<Vault>,
|
42
|
-
payerPublicKey: PublicKey,
|
43
|
-
poolPositionPublicKey: PublicKey,
|
44
|
-
stakedTokenMintPublicKey: PublicKey,
|
45
|
-
depositAmount: BN,
|
46
|
-
overrideStartTime?: number
|
47
|
-
): Promise<TransactionInstruction> {
|
48
|
-
const [poolPublickey] = await getCompoundPoolPublicKeyForMint(program.programId, stakedTokenMintPublicKey)
|
49
|
-
const poolAssociatedStakedTokenAccount = await findAssociatedTokenAddress(
|
50
|
-
program.programId,
|
51
|
-
poolPublickey,
|
52
|
-
stakedTokenMintPublicKey
|
53
|
-
)
|
54
|
-
const payersArbitraryTokenAccount = await findAssociatedTokenAddress(
|
55
|
-
program.programId,
|
56
|
-
payerPublicKey,
|
57
|
-
stakedTokenMintPublicKey
|
58
|
-
)
|
59
|
-
const vaultSystemState = await getVaultSystemStatePublicKey(program.programId)
|
60
|
-
|
61
|
-
return await program.methods
|
62
|
-
.depositCompoundStakingPoolPosition(
|
63
|
-
depositAmount,
|
64
|
-
new BN(overrideStartTime ?? Math.floor(Date.now() / 1000)) // override current time
|
65
|
-
)
|
66
|
-
.accounts({
|
67
|
-
payer: payerPublicKey,
|
68
|
-
vaultSystemState: vaultSystemState,
|
69
|
-
pool: poolPublickey,
|
70
|
-
poolPosition: poolPositionPublicKey,
|
71
|
-
stakedTokenMint: stakedTokenMintPublicKey,
|
72
|
-
poolAssociatedStakedTokenAccount: poolAssociatedStakedTokenAccount,
|
73
|
-
payerAssociatedStakedTokenAccount: payersArbitraryTokenAccount,
|
74
|
-
tokenProgram: TOKEN_PROGRAM_ID,
|
75
|
-
systemProgram: SystemProgram.programId,
|
76
|
-
})
|
77
|
-
.instruction()
|
78
|
-
}
|