hedge-web3 0.2.27 → 0.2.31

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.
Files changed (51) hide show
  1. package/declarations/Constants.d.ts +12 -0
  2. package/declarations/idl/vault.d.ts +743 -59
  3. package/declarations/index.d.ts +9 -0
  4. package/declarations/instructions/adminWithdrawCol.d.ts +5 -0
  5. package/declarations/instructions/adminWithdrawUsh.d.ts +5 -0
  6. package/declarations/instructions/createCompoundStakingPool.d.ts +5 -0
  7. package/declarations/instructions/createCompoundStakingPoolPosition.d.ts +6 -0
  8. package/declarations/instructions/createReferralAccount.d.ts +2 -2
  9. package/declarations/instructions/depositCompoundStakingPoolPosition.d.ts +6 -0
  10. package/declarations/instructions/depositRewardsToCompoundPool.d.ts +6 -0
  11. package/declarations/instructions/referralClaimFees.d.ts +2 -2
  12. package/declarations/instructions/setCompoundPoolActive.d.ts +5 -0
  13. package/declarations/instructions/setDelegateWallet.d.ts +5 -0
  14. package/declarations/instructions/withdrawCompoundStakingPoolPosition.d.ts +6 -0
  15. package/declarations/utils/getLinkedListAccounts.d.ts +2 -1
  16. package/lib/Constants.js +28 -1
  17. package/lib/idl/vault.js +741 -57
  18. package/lib/index.js +9 -0
  19. package/lib/instructions/adminWithdrawCol.js +60 -0
  20. package/lib/instructions/adminWithdrawUsh.js +57 -0
  21. package/lib/instructions/createCompoundStakingPool.js +58 -0
  22. package/lib/instructions/createCompoundStakingPoolPosition.js +56 -0
  23. package/lib/instructions/createReferralAccount.js +6 -3
  24. package/lib/instructions/depositCompoundStakingPoolPosition.js +55 -0
  25. package/lib/instructions/depositRewardsToCompoundPool.js +64 -0
  26. package/lib/instructions/liquidateVault.js +7 -1
  27. package/lib/instructions/loanVault.js +7 -1
  28. package/lib/instructions/referralClaimFees.js +6 -3
  29. package/lib/instructions/setCompoundPoolActive.js +43 -0
  30. package/lib/instructions/setDelegateWallet.js +43 -0
  31. package/lib/instructions/withdrawCompoundStakingPoolPosition.js +64 -0
  32. package/lib/utils/getLinkedListAccounts.js +5 -21
  33. package/package.json +5 -2
  34. package/src/Constants.ts +30 -0
  35. package/src/idl/vault.ts +3638 -2270
  36. package/src/index.ts +9 -2
  37. package/src/instructions/adminWithdrawCol.ts +87 -0
  38. package/src/instructions/adminWithdrawUsh.ts +78 -0
  39. package/src/instructions/createCompoundStakingPool.ts +63 -0
  40. package/src/instructions/createCompoundStakingPoolPosition.ts +85 -0
  41. package/src/instructions/createReferralAccount.ts +13 -9
  42. package/src/instructions/createStakingPool.ts +2 -9
  43. package/src/instructions/depositCompoundStakingPoolPosition.ts +78 -0
  44. package/src/instructions/depositRewardsToCompoundPool.ts +110 -0
  45. package/src/instructions/liquidateVault.ts +37 -27
  46. package/src/instructions/loanVault.ts +34 -21
  47. package/src/instructions/referralClaimFees.ts +16 -10
  48. package/src/instructions/setCompoundPoolActive.ts +51 -0
  49. package/src/instructions/setDelegateWallet.ts +51 -0
  50. package/src/instructions/withdrawCompoundStakingPoolPosition.ts +100 -0
  51. package/src/utils/getLinkedListAccounts.ts +6 -20
package/lib/index.js CHANGED
@@ -36,6 +36,15 @@ __exportStar(require("./instructions/refreshOraclePrice"), exports);
36
36
  __exportStar(require("./instructions/repayVault"), exports);
37
37
  __exportStar(require("./instructions/setHalted"), exports);
38
38
  __exportStar(require("./instructions/transferVault"), exports);
39
+ __exportStar(require("./instructions/createCompoundStakingPool"), exports);
40
+ __exportStar(require("./instructions/createCompoundStakingPoolPosition"), exports);
41
+ __exportStar(require("./instructions/depositCompoundStakingPoolPosition"), exports);
42
+ __exportStar(require("./instructions/withdrawCompoundStakingPoolPosition"), exports);
43
+ __exportStar(require("./instructions/setDelegateWallet"), exports);
44
+ __exportStar(require("./instructions/setCompoundPoolActive"), exports);
45
+ __exportStar(require("./instructions/adminWithdrawCol"), exports);
46
+ __exportStar(require("./instructions/adminWithdrawUsh"), exports);
47
+ __exportStar(require("./instructions/depositRewardsToCompoundPool"), exports);
39
48
  __exportStar(require("./instructions/updateReferralAccount"), exports);
40
49
  __exportStar(require("./instructions/updateReferralState"), exports);
41
50
  __exportStar(require("./instructions/updateVaultType"), exports);
@@ -0,0 +1,60 @@
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.adminWithdrawCollateralInstruction = exports.adminWithdrawCollateral = void 0;
16
+ const spl_token_1 = require("@solana/spl-token");
17
+ const web3_js_1 = require("@solana/web3.js");
18
+ const Constants_1 = require("../Constants");
19
+ const Errors_1 = require("../utils/Errors");
20
+ const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
21
+ function adminWithdrawCollateral(program, provider, payer, mintPublicKey, collateralType) {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ const [poolPublickey] = yield (0, Constants_1.getPoolPublicKeyForMint)(program.programId, mintPublicKey);
24
+ const vaultTypeAccountPublicKey = yield (0, Constants_1.getVaultTypeAccountPublicKey)(program.programId, collateralType);
25
+ const vaultTypeAccountInfo = yield program.account.vaultType.fetch(vaultTypeAccountPublicKey);
26
+ const stakingPoolAccountObject = yield program.account.stakingPool.fetch(poolPublickey);
27
+ const payerAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccountInfo.collateralMint, stakingPoolAccountObject.compoundPoolDelegateWallet);
28
+ const poolAssociatedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, poolPublickey, vaultTypeAccountInfo.collateralMint);
29
+ const transaction = new web3_js_1.Transaction().add(yield adminWithdrawCollateralInstruction(program, payer.publicKey, mintPublicKey, vaultTypeAccountPublicKey));
30
+ yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer]).catch(Errors_1.parseAnchorErrors);
31
+ return poolPublickey;
32
+ });
33
+ }
34
+ exports.adminWithdrawCollateral = adminWithdrawCollateral;
35
+ function adminWithdrawCollateralInstruction(program, payerPublicKey, stakedTokenMintPublicKey, vaultTypeAccountPublicKey) {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ const [poolPublickey] = yield (0, Constants_1.getPoolPublicKeyForMint)(program.programId, stakedTokenMintPublicKey);
38
+ const vaultTypeAccountInfo = yield program.account.vaultType.fetch(vaultTypeAccountPublicKey);
39
+ const stakingPoolAccountObject = yield program.account.stakingPool.fetch(poolPublickey);
40
+ const poolAssociatedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, poolPublickey, vaultTypeAccountInfo.collateralMint);
41
+ const delegateAssociatedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, stakingPoolAccountObject.compoundPoolDelegateWallet, vaultTypeAccountInfo.collateralMint);
42
+ const vaultSystemState = yield (0, Constants_1.getVaultSystemStatePublicKey)(program.programId);
43
+ return yield program.methods
44
+ .adminWithdrawColAta()
45
+ .accounts({
46
+ payer: payerPublicKey,
47
+ vaultSystemState: vaultSystemState,
48
+ pool: poolPublickey,
49
+ vaultTypeAccount: vaultTypeAccountPublicKey,
50
+ stakedTokenMint: stakedTokenMintPublicKey,
51
+ poolAssociatedTokenAccount: poolAssociatedTokenAccount,
52
+ delegateAssociatedColAccount: delegateAssociatedTokenAccount,
53
+ associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
54
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
55
+ systemProgram: web3_js_1.SystemProgram.programId,
56
+ })
57
+ .instruction();
58
+ });
59
+ }
60
+ exports.adminWithdrawCollateralInstruction = adminWithdrawCollateralInstruction;
@@ -0,0 +1,57 @@
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.adminWithdrawUshInstruction = exports.adminWithdrawUsh = void 0;
16
+ const spl_token_1 = require("@solana/spl-token");
17
+ const web3_js_1 = require("@solana/web3.js");
18
+ const Constants_1 = require("../Constants");
19
+ const Errors_1 = require("../utils/Errors");
20
+ const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
21
+ function adminWithdrawUsh(program, provider, payer, mintPublicKey) {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ const [poolPublickey] = yield (0, Constants_1.getPoolPublicKeyForMint)(program.programId, mintPublicKey);
24
+ const stakingPoolAccountObject = yield program.account.stakingPool.fetch(poolPublickey);
25
+ const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)(program.programId);
26
+ const payerAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, ushMintPublickey, stakingPoolAccountObject.compoundPoolDelegateWallet);
27
+ const transaction = new web3_js_1.Transaction().add(yield adminWithdrawUshInstruction(program, payer.publicKey, mintPublicKey, poolPublickey));
28
+ yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer]).catch(Errors_1.parseAnchorErrors);
29
+ return poolPublickey;
30
+ });
31
+ }
32
+ exports.adminWithdrawUsh = adminWithdrawUsh;
33
+ function adminWithdrawUshInstruction(program, payerPublicKey, stakedTokenMintPublicKey, poolPublickey) {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)(program.programId);
36
+ const vaultSystemState = yield (0, Constants_1.getVaultSystemStatePublicKey)(program.programId);
37
+ const poolAssociatedStakedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, poolPublickey, ushMintPublickey);
38
+ const stakingPoolAccountObject = yield program.account.stakingPool.fetch(poolPublickey);
39
+ const delegateWalletAssociatedStakedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, stakingPoolAccountObject.compoundPoolDelegateWallet, ushMintPublickey);
40
+ return yield program.methods
41
+ .adminWithdrawUshAta()
42
+ .accounts({
43
+ payer: payerPublicKey,
44
+ vaultSystemState: vaultSystemState,
45
+ pool: poolPublickey,
46
+ ushMint: ushMintPublickey,
47
+ stakedTokenMint: stakedTokenMintPublicKey,
48
+ poolAssociatedTokenAccount: poolAssociatedStakedTokenAccount,
49
+ delegateAssociatedUshAccount: delegateWalletAssociatedStakedTokenAccount,
50
+ associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
51
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
52
+ systemProgram: web3_js_1.SystemProgram.programId,
53
+ })
54
+ .instruction();
55
+ });
56
+ }
57
+ exports.adminWithdrawUshInstruction = adminWithdrawUshInstruction;
@@ -0,0 +1,58 @@
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.createCompoundStakingPoolInstruction = exports.createCompoundStakingPool = 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 createCompoundStakingPool(program, provider, payer, mintPublicKey, overrideStartTime) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ const transaction = new web3_js_1.Transaction().add(yield createCompoundStakingPoolInstruction(program, payer.publicKey, mintPublicKey, overrideStartTime));
25
+ yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer]).catch(Errors_1.parseAnchorErrors);
26
+ const [poolPublickey] = yield (0, Constants_1.getCompoundPoolPublicKeyForMint)(program.programId, mintPublicKey);
27
+ return poolPublickey;
28
+ });
29
+ }
30
+ exports.createCompoundStakingPool = createCompoundStakingPool;
31
+ function createCompoundStakingPoolInstruction(program, payerPublicKey, mintPublicKey, overrideStartTime) {
32
+ return __awaiter(this, void 0, void 0, function* () {
33
+ const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)(program.programId);
34
+ const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)(program.programId);
35
+ const hedgeMintPublickey = yield (0, Constants_1.getHedgeMintPublicKey)(program.programId);
36
+ const [poolPublickey, poolBump] = yield (0, Constants_1.getCompoundPoolPublicKeyForMint)(program.programId, mintPublicKey);
37
+ const poolAssociatedStakedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, poolPublickey, mintPublicKey);
38
+ const poolAssociatedUshTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, poolPublickey, ushMintPublickey);
39
+ return yield program.methods
40
+ .createCompoundStakingPool(new anchor_1.BN(overrideStartTime !== null && overrideStartTime !== void 0 ? overrideStartTime : Math.floor(Date.now() / 1000)))
41
+ .accounts({
42
+ signer: payerPublicKey,
43
+ vaultSystemState: vaultSystemStatePublicKey,
44
+ pool: poolPublickey,
45
+ stakedTokenMint: mintPublicKey,
46
+ ushMint: ushMintPublickey,
47
+ hedgeMint: hedgeMintPublickey,
48
+ poolAssociatedStakedTokenAccount: poolAssociatedStakedTokenAccount,
49
+ poolAssociatedUshTokenAccount: poolAssociatedUshTokenAccount,
50
+ rent: web3_js_1.SYSVAR_RENT_PUBKEY,
51
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
52
+ associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
53
+ systemProgram: web3_js_1.SystemProgram.programId,
54
+ })
55
+ .instruction();
56
+ });
57
+ }
58
+ exports.createCompoundStakingPoolInstruction = createCompoundStakingPoolInstruction;
@@ -0,0 +1,56 @@
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.createCompoundStakingPoolPositionInstruction = exports.createCompoundStakingPoolPosition = 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 createCompoundStakingPoolPosition(program, provider, payer, mintPublicKey, depositAmount, overrideStartTime) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ const [poolPublickey, poolBump] = yield (0, Constants_1.getCompoundPoolPublicKeyForMint)(program.programId, mintPublicKey);
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, mintPublicKey, payer.publicKey);
27
+ const transaction = new web3_js_1.Transaction().add(yield createCompoundStakingPoolPositionInstruction(program, payer.publicKey, poolPosition, mintPublicKey, new anchor_1.BN(depositAmount), overrideStartTime));
28
+ yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer]).catch(Errors_1.parseAnchorErrors);
29
+ return poolPosition;
30
+ });
31
+ }
32
+ exports.createCompoundStakingPoolPosition = createCompoundStakingPoolPosition;
33
+ function createCompoundStakingPoolPositionInstruction(program, payerPublicKey, poolPositionPublicKey, stakedTokenMintPublicKey, depositAmount, overrideStartTime) {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ const [poolPublickey] = yield (0, Constants_1.getCompoundPoolPublicKeyForMint)(program.programId, stakedTokenMintPublicKey);
36
+ const poolAssociatedStakedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, poolPublickey, stakedTokenMintPublicKey);
37
+ const payersArbitraryTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, payerPublicKey, stakedTokenMintPublicKey);
38
+ const vaultSystemState = yield (0, Constants_1.getVaultSystemStatePublicKey)(program.programId);
39
+ return yield program.methods
40
+ .createCompoundStakingPoolPosition(depositAmount, new anchor_1.BN(overrideStartTime !== null && overrideStartTime !== void 0 ? overrideStartTime : Math.floor(Date.now() / 1000)) // override current time
41
+ )
42
+ .accounts({
43
+ payer: payerPublicKey,
44
+ vaultSystemState: vaultSystemState,
45
+ pool: poolPublickey,
46
+ poolPosition: poolPositionPublicKey,
47
+ stakedTokenMint: stakedTokenMintPublicKey,
48
+ poolAssociatedStakedTokenAccount: poolAssociatedStakedTokenAccount,
49
+ payerAssociatedStakedTokenAccount: payersArbitraryTokenAccount,
50
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
51
+ systemProgram: web3_js_1.SystemProgram.programId,
52
+ })
53
+ .instruction();
54
+ });
55
+ }
56
+ exports.createCompoundStakingPoolPositionInstruction = createCompoundStakingPoolPositionInstruction;
@@ -31,7 +31,7 @@ const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfi
31
31
  * - referrer: PublicKey
32
32
  * - overrideTime?: number
33
33
  */
34
- function createReferralAccount(program, provider, payer, poolPosition, overrideTime) {
34
+ function createReferralAccount(program, provider, payer, poolPosition, stakedTokenMintPublicKey, overrideTime) {
35
35
  return __awaiter(this, void 0, void 0, function* () {
36
36
  // setup transaction
37
37
  const transaction = new web3_js_1.Transaction();
@@ -49,15 +49,16 @@ function createReferralAccount(program, provider, payer, poolPosition, overrideT
49
49
  const payerHdgAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, hedgeMintPublicKey, payer.publicKey);
50
50
  // Derive the user referral account public key
51
51
  const userReferralAccountPublicKey = yield (0, Constants_1.getUserReferralAccountPublicKey)(program.programId, payer.publicKey);
52
- transaction.add(yield createReferralAccountInstruction(program, payer.publicKey, poolPosition, referralAccountPublicKey, referallStatePublicKey, hedgeMintPublicKey, payerHdgAssociatedTokenAccount.address, userReferralAccountPublicKey, overrideTime));
52
+ transaction.add(yield createReferralAccountInstruction(program, payer.publicKey, poolPosition, stakedTokenMintPublicKey, referralAccountPublicKey, referallStatePublicKey, hedgeMintPublicKey, payerHdgAssociatedTokenAccount.address, userReferralAccountPublicKey, overrideTime));
53
53
  yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, signers).catch(Errors_1.parseAnchorErrors);
54
54
  return referralAccountPublicKey;
55
55
  });
56
56
  }
57
57
  exports.createReferralAccount = createReferralAccount;
58
- function createReferralAccountInstruction(program, payerPublicKey, poolPositionPublicKey, referralAccountPublicKey, referralStatePublicKey, hedgeMintPublicKey, hdgAssociatedTokenAccountPublicKey, userReferralAccountPublicKey, overrideTime) {
58
+ function createReferralAccountInstruction(program, payerPublicKey, poolPositionPublicKey, stakedTokenMintPublicKey, referralAccountPublicKey, referralStatePublicKey, hedgeMintPublicKey, hdgAssociatedTokenAccountPublicKey, userReferralAccountPublicKey, overrideTime) {
59
59
  return __awaiter(this, void 0, void 0, function* () {
60
60
  const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)(program.programId);
61
+ const [poolPublickey] = yield (0, Constants_1.getCompoundPoolPublicKeyForMint)(program.programId, stakedTokenMintPublicKey);
61
62
  return yield program.methods
62
63
  .createReferralAccount(new anchor_1.BN(overrideTime !== null && overrideTime !== void 0 ? overrideTime : Math.floor(Date.now() / 1000)) // override override times
63
64
  )
@@ -68,6 +69,8 @@ function createReferralAccountInstruction(program, payerPublicKey, poolPositionP
68
69
  referralAccount: referralAccountPublicKey,
69
70
  userReferralAccount: userReferralAccountPublicKey,
70
71
  poolPosition: poolPositionPublicKey,
72
+ pool: poolPublickey,
73
+ stakedTokenMint: stakedTokenMintPublicKey,
71
74
  hedgeMint: hedgeMintPublicKey,
72
75
  hdgAta: hdgAssociatedTokenAccountPublicKey,
73
76
  systemProgram: web3_js_1.SystemProgram.programId,
@@ -0,0 +1,55 @@
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.depositCompoundStakingPoolPositionInstruction = exports.depositCompoundStakingPoolPosition = 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 depositCompoundStakingPoolPosition(program, provider, payer, mintPublicKey, depositAmount, overrideStartTime) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ const [poolPublickey, poolBump] = yield (0, Constants_1.getCompoundPoolPublicKeyForMint)(program.programId, mintPublicKey);
25
+ const poolPosition = yield (0, Constants_1.getCompoundPoolPositionAddress)(program.programId, poolPublickey, payer.publicKey);
26
+ const transaction = new web3_js_1.Transaction().add(yield depositCompoundStakingPoolPositionInstruction(program, payer.publicKey, poolPosition, mintPublicKey, new anchor_1.BN(depositAmount), overrideStartTime));
27
+ yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer]).catch(Errors_1.parseAnchorErrors);
28
+ return poolPosition;
29
+ });
30
+ }
31
+ exports.depositCompoundStakingPoolPosition = depositCompoundStakingPoolPosition;
32
+ function depositCompoundStakingPoolPositionInstruction(program, payerPublicKey, poolPositionPublicKey, stakedTokenMintPublicKey, depositAmount, overrideStartTime) {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ const [poolPublickey] = yield (0, Constants_1.getCompoundPoolPublicKeyForMint)(program.programId, stakedTokenMintPublicKey);
35
+ const poolAssociatedStakedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, poolPublickey, stakedTokenMintPublicKey);
36
+ const payersArbitraryTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, payerPublicKey, stakedTokenMintPublicKey);
37
+ const vaultSystemState = yield (0, Constants_1.getVaultSystemStatePublicKey)(program.programId);
38
+ return yield program.methods
39
+ .depositCompoundStakingPoolPosition(depositAmount, new anchor_1.BN(overrideStartTime !== null && overrideStartTime !== void 0 ? overrideStartTime : Math.floor(Date.now() / 1000)) // override current time
40
+ )
41
+ .accounts({
42
+ payer: payerPublicKey,
43
+ vaultSystemState: vaultSystemState,
44
+ pool: poolPublickey,
45
+ poolPosition: poolPositionPublicKey,
46
+ stakedTokenMint: stakedTokenMintPublicKey,
47
+ poolAssociatedStakedTokenAccount: poolAssociatedStakedTokenAccount,
48
+ payerAssociatedStakedTokenAccount: payersArbitraryTokenAccount,
49
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
50
+ systemProgram: web3_js_1.SystemProgram.programId,
51
+ })
52
+ .instruction();
53
+ });
54
+ }
55
+ exports.depositCompoundStakingPoolPositionInstruction = depositCompoundStakingPoolPositionInstruction;
@@ -0,0 +1,64 @@
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.depositRewardsToCompoundStakingPoolInstruction = exports.depositRewardsToCompoundStakingPool = 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 depositRewardsToCompoundStakingPool(program, provider, payer, mintPublicKey, depositAmount, overrideStartTime) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ const history = web3_js_1.Keypair.generate();
25
+ const [poolPublickey] = yield (0, Constants_1.getCompoundPoolPublicKeyForMint)(program.programId, mintPublicKey);
26
+ const [poolStakingPublickey] = yield (0, Constants_1.getPoolPublicKeyForMint)(program.programId, mintPublicKey);
27
+ const hedgeMintPublickey = yield (0, Constants_1.getHedgeMintPublicKey)(program.programId);
28
+ const stakingPoolAccountObject = yield program.account.stakingPool.fetch(poolStakingPublickey);
29
+ const payerAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, hedgeMintPublickey, stakingPoolAccountObject.compoundPoolDelegateWallet);
30
+ const transaction = new web3_js_1.Transaction().add(yield depositRewardsToCompoundStakingPoolInstruction(program, payer.publicKey, mintPublicKey, history.publicKey, new anchor_1.BN(depositAmount), overrideStartTime));
31
+ yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer, history]).catch(Errors_1.parseAnchorErrors);
32
+ return poolPublickey;
33
+ });
34
+ }
35
+ exports.depositRewardsToCompoundStakingPool = depositRewardsToCompoundStakingPool;
36
+ function depositRewardsToCompoundStakingPoolInstruction(program, payerPublicKey, mintPublicKey, historyPublicKey, amount, overrideStartTime) {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)(program.programId);
39
+ const hedgeMintPublickey = yield (0, Constants_1.getHedgeMintPublicKey)(program.programId);
40
+ const [poolPublickey, poolBump] = yield (0, Constants_1.getCompoundPoolPublicKeyForMint)(program.programId, mintPublicKey);
41
+ const [poolStakingPublickey] = yield (0, Constants_1.getPoolPublicKeyForMint)(program.programId, mintPublicKey);
42
+ const poolAssociatedHedgeTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, poolPublickey, hedgeMintPublickey);
43
+ const payerAssociatedHedgeTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, payerPublicKey, hedgeMintPublickey);
44
+ return yield program.methods
45
+ .depositRewardsToCompoundPool(amount, new anchor_1.BN(overrideStartTime !== null && overrideStartTime !== void 0 ? overrideStartTime : Math.floor(Date.now() / 1000)) // override current time
46
+ )
47
+ .accounts({
48
+ payer: payerPublicKey,
49
+ vaultSystemState: vaultSystemStatePublicKey,
50
+ history: historyPublicKey,
51
+ compoundPool: poolPublickey,
52
+ pool: poolStakingPublickey,
53
+ stakedTokenMint: mintPublicKey,
54
+ hedgeMint: hedgeMintPublickey,
55
+ poolAssociatedHedgeAccount: poolAssociatedHedgeTokenAccount,
56
+ payerAssociatedHedgeAccount: payerAssociatedHedgeTokenAccount,
57
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
58
+ associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
59
+ systemProgram: web3_js_1.SystemProgram.programId,
60
+ })
61
+ .instruction();
62
+ });
63
+ }
64
+ exports.depositRewardsToCompoundStakingPoolInstruction = depositRewardsToCompoundStakingPoolInstruction;
@@ -29,6 +29,10 @@ function liquidateVault(program, provider, payer, vaultPublicKey, overrideTime)
29
29
  const [hedgeStakingPoolPublicKey] = yield (0, Constants_1.getPoolPublicKeyForMint)(program.programId, hedgeMintPublickey);
30
30
  const liquidationPoolStatePublicKey = yield (0, Constants_1.getLiquidationPoolStatePublicKey)(program.programId);
31
31
  const poolStateInfo = yield program.account.liquidationPoolState.fetch(liquidationPoolStatePublicKey);
32
+ const additionalComputationBudget = web3_js_1.ComputeBudgetProgram.requestUnits({
33
+ units: 300000,
34
+ additionalFee: 0,
35
+ });
32
36
  const payerAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMint, payer.publicKey, true);
33
37
  const feePoolAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMint, hedgeStakingPoolPublicKey, true);
34
38
  const vaultAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMint, vaultPublicKey, true);
@@ -39,7 +43,9 @@ function liquidateVault(program, provider, payer, vaultPublicKey, overrideTime)
39
43
  const history = web3_js_1.Keypair.generate();
40
44
  const newEra = web3_js_1.Keypair.generate();
41
45
  const transaction = new web3_js_1.Transaction();
42
- transaction.add(yield liquidateVaultInstruction(program, payer.publicKey, payerAssociatedTokenAccount.address, vaultPublicKey, vaultAssociatedTokenAccount.address, liquidationPoolStatePublicKey, poolStateInfo.currentEra, poolAssociatedTokenAccount.address, history.publicKey, newEra.publicKey, hedgeStakingPoolPublicKey, feePoolAssociatedTokenAccount.address, hedgeStakingPoolAssociatedUshTokenAccount.address, collateralMint, vaultTypeAssociatedTokenAccount.address, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, vaultAccount.vaultType, overrideTime));
46
+ transaction
47
+ .add(additionalComputationBudget)
48
+ .add(yield liquidateVaultInstruction(program, payer.publicKey, payerAssociatedTokenAccount.address, vaultPublicKey, vaultAssociatedTokenAccount.address, liquidationPoolStatePublicKey, poolStateInfo.currentEra, poolAssociatedTokenAccount.address, history.publicKey, newEra.publicKey, hedgeStakingPoolPublicKey, feePoolAssociatedTokenAccount.address, hedgeStakingPoolAssociatedUshTokenAccount.address, collateralMint, vaultTypeAssociatedTokenAccount.address, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, vaultAccount.vaultType, overrideTime));
43
49
  yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer, history, newEra]);
44
50
  return vaultPublicKey;
45
51
  });
@@ -21,6 +21,10 @@ const getLinkedListAccounts_1 = require("../utils/getLinkedListAccounts");
21
21
  const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
22
22
  function loanVault(program, provider, payer, vaultPublicKey, loanAmount, overrideTime, referrer) {
23
23
  return __awaiter(this, void 0, void 0, function* () {
24
+ const additionalComputationBudget = web3_js_1.ComputeBudgetProgram.requestUnits({
25
+ units: 300000,
26
+ additionalFee: 0,
27
+ });
24
28
  const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)(program.programId);
25
29
  const payerUshAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, ushMintPublickey, payer.publicKey);
26
30
  const vaultAccount = yield program.account.vault.fetch(vaultPublicKey);
@@ -37,7 +41,9 @@ function loanVault(program, provider, payer, vaultPublicKey, loanAmount, overrid
37
41
  referralAccountPublicKey = yield (0, Constants_1.getReferralAccountPublicKey)(program.programId, referrer);
38
42
  }
39
43
  const history = web3_js_1.Keypair.generate();
40
- const transaction = new web3_js_1.Transaction().add(yield loanVaultInstruction(program, payer.publicKey, payerUshAccount.address, vaultPublicKey, vaultAssociatedTokenAccount.address, history.publicKey, vaultAccount.vaultType, vaultTypeAssociatedTokenAccount.address, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, new anchor_1.BN(loanAmount), referralAccountPublicKey, overrideTime));
44
+ const transaction = new web3_js_1.Transaction()
45
+ .add(additionalComputationBudget)
46
+ .add(yield loanVaultInstruction(program, payer.publicKey, payerUshAccount.address, vaultPublicKey, vaultAssociatedTokenAccount.address, history.publicKey, vaultAccount.vaultType, vaultTypeAssociatedTokenAccount.address, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, new anchor_1.BN(loanAmount), referralAccountPublicKey, overrideTime));
41
47
  yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer, history]);
42
48
  return vaultPublicKey;
43
49
  });
@@ -29,7 +29,7 @@ const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfi
29
29
  * - poolPublicKey: PublicKey : a key to a pool position. If the position is closed or does not belong to the signer it will be ignored
30
30
  * - referrer: PublicKey
31
31
  */
32
- function referralClaimFees(program, provider, payer, poolPosition) {
32
+ function referralClaimFees(program, provider, payer, poolPosition, stakedTokenMintPublicKey) {
33
33
  return __awaiter(this, void 0, void 0, function* () {
34
34
  // setup transaction
35
35
  const transaction = new web3_js_1.Transaction();
@@ -51,14 +51,15 @@ function referralClaimFees(program, provider, payer, poolPosition) {
51
51
  const communityAssociatedHedgeTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, hedgeMintPublicKey, vaultSystemStatePublicKey, true);
52
52
  const [feePoolPublicKey] = yield (0, Constants_1.getPoolPublicKeyForMint)(program.programId, hedgeMintPublicKey);
53
53
  const feePoolAssociatedUshTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, ushMintPublicKey, feePoolPublicKey, true);
54
- transaction.add(yield referralClaimFeesInstruction(program, payer.publicKey, vaultSystemStatePublicKey, poolPosition, referralAccountPublicKey, referallStatePublicKey, hedgeMintPublicKey, payerHdgAssociatedTokenAccount.address, ushMintPublicKey, payerUshAssociatedTokenAccount.address, communityAssociatedHedgeTokenAccount.address, feePoolPublicKey, feePoolAssociatedUshTokenAccount.address));
54
+ transaction.add(yield referralClaimFeesInstruction(program, payer.publicKey, vaultSystemStatePublicKey, poolPosition, stakedTokenMintPublicKey, referralAccountPublicKey, referallStatePublicKey, hedgeMintPublicKey, payerHdgAssociatedTokenAccount.address, ushMintPublicKey, payerUshAssociatedTokenAccount.address, communityAssociatedHedgeTokenAccount.address, feePoolPublicKey, feePoolAssociatedUshTokenAccount.address));
55
55
  yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, signers).catch(Errors_1.parseAnchorErrors);
56
56
  return referralAccountPublicKey;
57
57
  });
58
58
  }
59
59
  exports.referralClaimFees = referralClaimFees;
60
- function referralClaimFeesInstruction(program, payerPublicKey, vaultSystemStatePublicKey, poolPositionPublicKey, referralAccountPublicKey, referralStatePublicKey, hedgeMintPublicKey, hdgAssociatedTokenAccountPublicKey, ushMintPublicKey, ushAssociatedTokenAccountPublicKey, communityAssociatedHedgeTokenAccountPublicKey, feePoolPublicKey, feePoolAssociatedUshTokenAccountPublicKey) {
60
+ function referralClaimFeesInstruction(program, payerPublicKey, vaultSystemStatePublicKey, poolPositionPublicKey, stakedTokenMintPublicKey, referralAccountPublicKey, referralStatePublicKey, hedgeMintPublicKey, hdgAssociatedTokenAccountPublicKey, ushMintPublicKey, ushAssociatedTokenAccountPublicKey, communityAssociatedHedgeTokenAccountPublicKey, feePoolPublicKey, feePoolAssociatedUshTokenAccountPublicKey) {
61
61
  return __awaiter(this, void 0, void 0, function* () {
62
+ const [poolPublickey] = yield (0, Constants_1.getCompoundPoolPublicKeyForMint)(program.programId, stakedTokenMintPublicKey);
62
63
  return yield program.methods
63
64
  .referralClaimFees()
64
65
  .accounts({
@@ -72,6 +73,8 @@ function referralClaimFeesInstruction(program, payerPublicKey, vaultSystemStateP
72
73
  ushMint: ushMintPublicKey,
73
74
  signerUshAta: ushAssociatedTokenAccountPublicKey,
74
75
  communityAssociatedHedgeTokenAccount: communityAssociatedHedgeTokenAccountPublicKey,
76
+ pool: poolPublickey,
77
+ stakedTokenMint: stakedTokenMintPublicKey,
75
78
  feePool: feePoolPublicKey,
76
79
  feePoolAssociatedUshTokenAccount: feePoolAssociatedUshTokenAccountPublicKey,
77
80
  systemProgram: web3_js_1.SystemProgram.programId,
@@ -0,0 +1,43 @@
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;
@@ -0,0 +1,43 @@
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;