hedge-web3 0.2.33 → 0.3.2
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 +278 -1259
- package/declarations/index.d.ts +1 -12
- 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 +1 -1
- 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 +1 -1
- 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/declarations/utils/sendAndConfirmWithDebug.d.ts +2 -2
- package/lib/Constants.js +14 -41
- 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 +277 -1258
- package/lib/index.js +6 -13
- 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 +10 -11
- package/lib/instructions/createStakingPool.js +10 -11
- package/lib/instructions/createUserReferralAccount.js +9 -10
- package/lib/instructions/createVault.js +35 -50
- package/lib/instructions/depositLiquidationPool.js +12 -13
- package/lib/instructions/depositStakingPool.js +8 -9
- package/lib/instructions/depositVault.js +15 -26
- package/lib/instructions/initHedgeFoundation.js +24 -13
- package/lib/instructions/initHedgeFoundationTokens.js +7 -8
- package/lib/instructions/liquidateVault.js +12 -19
- package/lib/instructions/loanVault.js +17 -24
- 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 -12
- package/lib/instructions/referralClaimFees.js +9 -10
- package/lib/instructions/refreshOraclePrice.js +10 -10
- 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 +10 -11
- package/lib/state/VaultAccount.js +23 -9
- 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 +50 -14
- package/package.json +9 -8
- package/src/{Constants.ts → HedgeConstants.ts} +13 -43
- package/src/idl/vault.ts +2004 -3966
- package/src/index.ts +3 -12
- 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 -8
- package/src/instructions/createStakingPool.ts +11 -4
- package/src/instructions/createUserReferralAccount.ts +2 -2
- package/src/instructions/createVault.ts +26 -37
- package/src/instructions/depositLiquidationPool.ts +2 -2
- package/src/instructions/depositStakingPool.ts +2 -2
- package/src/instructions/depositVault.ts +24 -18
- package/src/instructions/initHedgeFoundation.ts +19 -4
- package/src/instructions/initHedgeFoundationTokens.ts +2 -2
- package/src/instructions/liquidateVault.ts +29 -39
- package/src/instructions/loanVault.ts +24 -37
- 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 -3
- package/src/instructions/referralClaimFees.ts +11 -9
- package/src/instructions/refreshOraclePrice.ts +5 -5
- 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 +4 -4
- package/src/state/VaultAccount.ts +1 -1
- package/src/utils/Errors.ts +1 -1
- package/src/utils/getLinkedListAccounts.ts +1 -1
- package/src/utils/sendAndConfirmWithDebug.ts +72 -23
- package/declarations/instructions/adminWithdrawCol.d.ts +0 -5
- package/declarations/instructions/adminWithdrawUsh.d.ts +0 -5
- package/declarations/instructions/compoundCreateReferralAccount.d.ts +0 -17
- package/declarations/instructions/compoundReferralClaimFees.d.ts +0 -16
- 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/compoundCreateReferralAccount.js +0 -83
- package/lib/instructions/compoundReferralClaimFees.js +0 -87
- 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/compoundCreateReferralAccount.ts +0 -119
- package/src/instructions/compoundReferralClaimFees.ts +0 -151
- 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,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,119 +0,0 @@
|
|
1
|
-
import { BN, Program, Provider } from '@project-serum/anchor'
|
2
|
-
import { getOrCreateAssociatedTokenAccount, TOKEN_PROGRAM_ID } from '@solana/spl-token'
|
3
|
-
import { PublicKey, Signer, SystemProgram, SYSVAR_RENT_PUBKEY, Transaction, TransactionInstruction } from '@solana/web3.js'
|
4
|
-
import {
|
5
|
-
getCompoundPoolPublicKeyForMint,
|
6
|
-
getHedgeMintPublicKey,
|
7
|
-
getReferralAccountPublicKey,
|
8
|
-
getReferralStatePublicKey,
|
9
|
-
getUserReferralAccountPublicKey,
|
10
|
-
getVaultSystemStatePublicKey,
|
11
|
-
} from '../Constants'
|
12
|
-
|
13
|
-
import { Vault } from '../idl/vault'
|
14
|
-
import { parseAnchorErrors } from '../utils/Errors'
|
15
|
-
import sendAndConfirmWithDebug from '../utils/sendAndConfirmWithDebug'
|
16
|
-
|
17
|
-
/** @type {Function} - Creates a new referral account.
|
18
|
-
* This checks the user has enough HDG in their wallet or staked and
|
19
|
-
* then allows them to create a referral account. If they meet the PSM referral threshold,
|
20
|
-
* they will be eligible for PSM cut.
|
21
|
-
* Params:
|
22
|
-
* - program: Program<Vault> : The program instance of Hedge Vault program
|
23
|
-
* - provider: Provider : Current connection
|
24
|
-
* - payer: Signer : who we are creating the referral account for
|
25
|
-
* - poolPublicKey: PublicKey : a key to a pool position. If the position is closed or does not belong to the signer it will be ignored
|
26
|
-
* - referrer: PublicKey
|
27
|
-
* - overrideTime?: number
|
28
|
-
*/
|
29
|
-
export async function compoundCreateReferralAccount(
|
30
|
-
program: Program<Vault>,
|
31
|
-
provider: Provider,
|
32
|
-
payer: Signer,
|
33
|
-
poolPosition: PublicKey,
|
34
|
-
stakedTokenMintPublicKey: PublicKey,
|
35
|
-
overrideTime?: number
|
36
|
-
): Promise<PublicKey> {
|
37
|
-
// setup transaction
|
38
|
-
const transaction = new Transaction()
|
39
|
-
const signers = [payer]
|
40
|
-
const referrer = payer.publicKey
|
41
|
-
|
42
|
-
// Setup public keys
|
43
|
-
const vaultSystemStatePublicKey = await getVaultSystemStatePublicKey(program.programId)
|
44
|
-
|
45
|
-
// Find referral account
|
46
|
-
let referralAccountPublicKey = await getReferralAccountPublicKey(program.programId, referrer)
|
47
|
-
|
48
|
-
// Get the referral state PDA
|
49
|
-
const referallStatePublicKey = await getReferralStatePublicKey(program.programId)
|
50
|
-
|
51
|
-
// Get HDG mint public key
|
52
|
-
const hedgeMintPublicKey = await getHedgeMintPublicKey(program.programId)
|
53
|
-
|
54
|
-
// Get HDG account of signer
|
55
|
-
const payerHdgAssociatedTokenAccount = await getOrCreateAssociatedTokenAccount(
|
56
|
-
provider.connection,
|
57
|
-
payer,
|
58
|
-
hedgeMintPublicKey,
|
59
|
-
payer.publicKey
|
60
|
-
)
|
61
|
-
|
62
|
-
// Derive the user referral account public key
|
63
|
-
const userReferralAccountPublicKey = await getUserReferralAccountPublicKey(program.programId, payer.publicKey)
|
64
|
-
|
65
|
-
transaction.add(
|
66
|
-
await compoundCreateReferralAccountInstruction(
|
67
|
-
program,
|
68
|
-
payer.publicKey,
|
69
|
-
poolPosition,
|
70
|
-
stakedTokenMintPublicKey,
|
71
|
-
referralAccountPublicKey,
|
72
|
-
referallStatePublicKey,
|
73
|
-
hedgeMintPublicKey,
|
74
|
-
payerHdgAssociatedTokenAccount.address,
|
75
|
-
userReferralAccountPublicKey,
|
76
|
-
overrideTime
|
77
|
-
)
|
78
|
-
)
|
79
|
-
|
80
|
-
await sendAndConfirmWithDebug(provider.connection, transaction, signers).catch(parseAnchorErrors)
|
81
|
-
return referralAccountPublicKey
|
82
|
-
}
|
83
|
-
|
84
|
-
export async function compoundCreateReferralAccountInstruction(
|
85
|
-
program: Program<Vault>,
|
86
|
-
payerPublicKey: PublicKey,
|
87
|
-
poolPositionPublicKey: PublicKey,
|
88
|
-
stakedTokenMintPublicKey: PublicKey,
|
89
|
-
referralAccountPublicKey: PublicKey,
|
90
|
-
referralStatePublicKey: PublicKey,
|
91
|
-
hedgeMintPublicKey: PublicKey,
|
92
|
-
hdgAssociatedTokenAccountPublicKey: PublicKey,
|
93
|
-
userReferralAccountPublicKey: PublicKey,
|
94
|
-
overrideTime?: number
|
95
|
-
): Promise<TransactionInstruction> {
|
96
|
-
const vaultSystemStatePublicKey = await getVaultSystemStatePublicKey(program.programId)
|
97
|
-
const [poolPublickey] = await getCompoundPoolPublicKeyForMint(program.programId, stakedTokenMintPublicKey)
|
98
|
-
|
99
|
-
return await program.methods
|
100
|
-
.compoundCreateReferralAccount(
|
101
|
-
new BN(overrideTime ?? Math.floor(Date.now() / 1000)) // override override times
|
102
|
-
)
|
103
|
-
.accounts({
|
104
|
-
signer: payerPublicKey,
|
105
|
-
vaultSystemState: vaultSystemStatePublicKey,
|
106
|
-
referralState: referralStatePublicKey,
|
107
|
-
referralAccount: referralAccountPublicKey,
|
108
|
-
userReferralAccount: userReferralAccountPublicKey,
|
109
|
-
poolPosition: poolPositionPublicKey,
|
110
|
-
pool: poolPublickey,
|
111
|
-
stakedTokenMint: stakedTokenMintPublicKey,
|
112
|
-
hedgeMint: hedgeMintPublicKey,
|
113
|
-
hdgAta: hdgAssociatedTokenAccountPublicKey,
|
114
|
-
systemProgram: SystemProgram.programId,
|
115
|
-
tokenProgram: TOKEN_PROGRAM_ID,
|
116
|
-
rent: SYSVAR_RENT_PUBKEY,
|
117
|
-
})
|
118
|
-
.instruction()
|
119
|
-
}
|
@@ -1,151 +0,0 @@
|
|
1
|
-
import { Program, Provider } from '@project-serum/anchor'
|
2
|
-
import { getOrCreateAssociatedTokenAccount, TOKEN_PROGRAM_ID } from '@solana/spl-token'
|
3
|
-
import { PublicKey, Signer, SystemProgram, SYSVAR_RENT_PUBKEY, Transaction, TransactionInstruction } from '@solana/web3.js'
|
4
|
-
import {
|
5
|
-
getCompoundPoolPublicKeyForMint,
|
6
|
-
getHedgeMintPublicKey,
|
7
|
-
getPoolPublicKeyForMint,
|
8
|
-
getReferralAccountPublicKey,
|
9
|
-
getReferralStatePublicKey,
|
10
|
-
getUshMintPublicKey,
|
11
|
-
getVaultSystemStatePublicKey,
|
12
|
-
} from '../Constants'
|
13
|
-
|
14
|
-
import { Vault } from '../idl/vault'
|
15
|
-
import { parseAnchorErrors } from '../utils/Errors'
|
16
|
-
import sendAndConfirmWithDebug from '../utils/sendAndConfirmWithDebug'
|
17
|
-
|
18
|
-
/** @type {Function} - Allows a referrer to claims their fees.
|
19
|
-
* This checks the user has enough HDG in their wallet or staked and
|
20
|
-
* then allows them to claim earned fees. If they meet the PSM referral threshold,
|
21
|
-
* they will be eligible for PSM cut.
|
22
|
-
* Params:
|
23
|
-
* - program: Program<Vault> : The program instance of Hedge Vault program
|
24
|
-
* - provider: Provider : Current connection
|
25
|
-
* - payer: Signer : who we are creating the referral account for
|
26
|
-
* - poolPublicKey: PublicKey : a key to a pool position. If the position is closed or does not belong to the signer it will be ignored
|
27
|
-
* - referrer: PublicKey
|
28
|
-
*/
|
29
|
-
export async function compoundReferralClaimFees(
|
30
|
-
program: Program<Vault>,
|
31
|
-
provider: Provider,
|
32
|
-
payer: Signer,
|
33
|
-
poolPosition: PublicKey,
|
34
|
-
stakedTokenMintPublicKey: PublicKey
|
35
|
-
): Promise<PublicKey> {
|
36
|
-
// setup transaction
|
37
|
-
const transaction = new Transaction()
|
38
|
-
const signers = [payer]
|
39
|
-
|
40
|
-
// General variables
|
41
|
-
const vaultSystemStatePublicKey = await getVaultSystemStatePublicKey(program.programId)
|
42
|
-
|
43
|
-
// Find referrer account
|
44
|
-
const referrer = await payer.publicKey
|
45
|
-
const referralAccountPublicKey = await getReferralAccountPublicKey(program.programId, referrer)
|
46
|
-
|
47
|
-
// Derive the user referral account public key
|
48
|
-
const referallStatePublicKey = await getReferralStatePublicKey(program.programId)
|
49
|
-
|
50
|
-
const hedgeMintPublicKey = await getHedgeMintPublicKey(program.programId)
|
51
|
-
|
52
|
-
// Get HDG account of signer
|
53
|
-
const payerHdgAssociatedTokenAccount = await getOrCreateAssociatedTokenAccount(
|
54
|
-
provider.connection,
|
55
|
-
payer,
|
56
|
-
hedgeMintPublicKey,
|
57
|
-
payer.publicKey
|
58
|
-
)
|
59
|
-
|
60
|
-
const ushMintPublicKey = await getUshMintPublicKey(program.programId)
|
61
|
-
|
62
|
-
// Get USH account of signer
|
63
|
-
const payerUshAssociatedTokenAccount = await getOrCreateAssociatedTokenAccount(
|
64
|
-
provider.connection,
|
65
|
-
payer,
|
66
|
-
ushMintPublicKey,
|
67
|
-
payer.publicKey
|
68
|
-
)
|
69
|
-
|
70
|
-
// Get community_associated_hedge_token_account
|
71
|
-
const communityAssociatedHedgeTokenAccount = await getOrCreateAssociatedTokenAccount(
|
72
|
-
provider.connection,
|
73
|
-
payer,
|
74
|
-
hedgeMintPublicKey,
|
75
|
-
vaultSystemStatePublicKey,
|
76
|
-
true
|
77
|
-
)
|
78
|
-
|
79
|
-
const [feePoolPublicKey] = await getPoolPublicKeyForMint(program.programId, hedgeMintPublicKey)
|
80
|
-
|
81
|
-
const feePoolAssociatedUshTokenAccount = await getOrCreateAssociatedTokenAccount(
|
82
|
-
provider.connection,
|
83
|
-
payer,
|
84
|
-
ushMintPublicKey,
|
85
|
-
feePoolPublicKey,
|
86
|
-
true
|
87
|
-
)
|
88
|
-
transaction.add(
|
89
|
-
await compoundReferralClaimFeesInstruction(
|
90
|
-
program,
|
91
|
-
payer.publicKey,
|
92
|
-
vaultSystemStatePublicKey,
|
93
|
-
poolPosition,
|
94
|
-
stakedTokenMintPublicKey,
|
95
|
-
referralAccountPublicKey,
|
96
|
-
referallStatePublicKey,
|
97
|
-
hedgeMintPublicKey,
|
98
|
-
payerHdgAssociatedTokenAccount.address,
|
99
|
-
ushMintPublicKey,
|
100
|
-
payerUshAssociatedTokenAccount.address,
|
101
|
-
communityAssociatedHedgeTokenAccount.address,
|
102
|
-
feePoolPublicKey,
|
103
|
-
feePoolAssociatedUshTokenAccount.address
|
104
|
-
)
|
105
|
-
)
|
106
|
-
|
107
|
-
await sendAndConfirmWithDebug(provider.connection, transaction, signers).catch(parseAnchorErrors)
|
108
|
-
return referralAccountPublicKey
|
109
|
-
}
|
110
|
-
|
111
|
-
export async function compoundReferralClaimFeesInstruction(
|
112
|
-
program: Program<Vault>,
|
113
|
-
payerPublicKey: PublicKey,
|
114
|
-
vaultSystemStatePublicKey: PublicKey,
|
115
|
-
poolPositionPublicKey: PublicKey,
|
116
|
-
stakedTokenMintPublicKey: PublicKey,
|
117
|
-
referralAccountPublicKey: PublicKey,
|
118
|
-
referralStatePublicKey: PublicKey,
|
119
|
-
hedgeMintPublicKey: PublicKey,
|
120
|
-
hdgAssociatedTokenAccountPublicKey: PublicKey,
|
121
|
-
ushMintPublicKey: PublicKey,
|
122
|
-
ushAssociatedTokenAccountPublicKey: PublicKey,
|
123
|
-
communityAssociatedHedgeTokenAccountPublicKey: PublicKey,
|
124
|
-
feePoolPublicKey: PublicKey,
|
125
|
-
feePoolAssociatedUshTokenAccountPublicKey: PublicKey
|
126
|
-
): Promise<TransactionInstruction> {
|
127
|
-
const [poolPublickey] = await getCompoundPoolPublicKeyForMint(program.programId, stakedTokenMintPublicKey)
|
128
|
-
|
129
|
-
return await program.methods
|
130
|
-
.compoundReferralClaimFees()
|
131
|
-
.accounts({
|
132
|
-
signer: payerPublicKey,
|
133
|
-
vaultSystemState: vaultSystemStatePublicKey,
|
134
|
-
referralState: referralStatePublicKey,
|
135
|
-
referralAccount: referralAccountPublicKey,
|
136
|
-
poolPosition: poolPositionPublicKey,
|
137
|
-
hedgeMint: hedgeMintPublicKey,
|
138
|
-
signerHdgAta: hdgAssociatedTokenAccountPublicKey,
|
139
|
-
ushMint: ushMintPublicKey,
|
140
|
-
signerUshAta: ushAssociatedTokenAccountPublicKey,
|
141
|
-
communityAssociatedHedgeTokenAccount: communityAssociatedHedgeTokenAccountPublicKey,
|
142
|
-
pool: poolPublickey,
|
143
|
-
stakedTokenMint: stakedTokenMintPublicKey,
|
144
|
-
feePool: feePoolPublicKey,
|
145
|
-
feePoolAssociatedUshTokenAccount: feePoolAssociatedUshTokenAccountPublicKey,
|
146
|
-
systemProgram: SystemProgram.programId,
|
147
|
-
tokenProgram: TOKEN_PROGRAM_ID,
|
148
|
-
rent: SYSVAR_RENT_PUBKEY,
|
149
|
-
})
|
150
|
-
.instruction()
|
151
|
-
}
|
@@ -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
|
-
}
|