hedge-web3 0.2.33 → 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.
Files changed (150) hide show
  1. package/declarations/Constants.d.ts +0 -12
  2. package/declarations/HedgeConstants.d.ts +76 -0
  3. package/declarations/idl/pyth.d.ts +1 -1
  4. package/declarations/idl/switchboard.d.ts +1 -1
  5. package/declarations/idl/vault.d.ts +2 -843
  6. package/declarations/index.d.ts +1 -12
  7. package/declarations/instructions/claimLiquidationPoolPosition.d.ts +1 -1
  8. package/declarations/instructions/claimStakingPoolPosition.d.ts +1 -1
  9. package/declarations/instructions/closeClaimedLiquidationPoolPosition.d.ts +1 -1
  10. package/declarations/instructions/closeLiquidationPoolPosition.d.ts +1 -1
  11. package/declarations/instructions/createReferralAccount.d.ts +1 -1
  12. package/declarations/instructions/createStakingPool.d.ts +1 -1
  13. package/declarations/instructions/createUserReferralAccount.d.ts +1 -1
  14. package/declarations/instructions/createVault.d.ts +1 -2
  15. package/declarations/instructions/depositLiquidationPool.d.ts +1 -2
  16. package/declarations/instructions/depositStakingPool.d.ts +1 -2
  17. package/declarations/instructions/depositVault.d.ts +1 -2
  18. package/declarations/instructions/initHedgeFoundation.d.ts +1 -1
  19. package/declarations/instructions/initHedgeFoundationTokens.d.ts +1 -1
  20. package/declarations/instructions/liquidateVault.d.ts +1 -1
  21. package/declarations/instructions/loanVault.d.ts +1 -2
  22. package/declarations/instructions/psmEditAccount.d.ts +1 -2
  23. package/declarations/instructions/psmMintUsh.d.ts +1 -2
  24. package/declarations/instructions/psmRedeemUsh.d.ts +1 -2
  25. package/declarations/instructions/redeemVault.d.ts +1 -2
  26. package/declarations/instructions/referralClaimFees.d.ts +1 -1
  27. package/declarations/instructions/refreshOraclePrice.d.ts +1 -1
  28. package/declarations/instructions/repayVault.d.ts +1 -2
  29. package/declarations/instructions/setHalted.d.ts +1 -1
  30. package/declarations/instructions/transferVault.d.ts +1 -1
  31. package/declarations/instructions/updateReferralAccount.d.ts +1 -2
  32. package/declarations/instructions/updateReferralState.d.ts +1 -2
  33. package/declarations/instructions/updateVaultType.d.ts +1 -2
  34. package/declarations/instructions/withdrawStakingPool.d.ts +1 -1
  35. package/declarations/instructions/withdrawVault.d.ts +1 -2
  36. package/declarations/state/VaultAccount.d.ts +2 -3
  37. package/declarations/utils/getLinkedListAccounts.d.ts +1 -2
  38. package/lib/Constants.js +27 -54
  39. package/lib/HedgeConstants.js +170 -0
  40. package/lib/HedgeDecimal.js +1 -2
  41. package/lib/StakingPools.js +5 -1
  42. package/lib/Vaults.js +5 -1
  43. package/lib/idl/vault.js +1 -842
  44. package/lib/index.js +6 -13
  45. package/lib/instructions/claimLiquidationPoolPosition.js +7 -8
  46. package/lib/instructions/claimStakingPoolPosition.js +7 -8
  47. package/lib/instructions/closeClaimedLiquidationPoolPosition.js +2 -3
  48. package/lib/instructions/closeLiquidationPoolPosition.js +16 -17
  49. package/lib/instructions/createReferralAccount.js +10 -11
  50. package/lib/instructions/createStakingPool.js +10 -11
  51. package/lib/instructions/createUserReferralAccount.js +9 -10
  52. package/lib/instructions/createVault.js +20 -21
  53. package/lib/instructions/depositLiquidationPool.js +12 -13
  54. package/lib/instructions/depositStakingPool.js +8 -9
  55. package/lib/instructions/depositVault.js +10 -11
  56. package/lib/instructions/initHedgeFoundation.js +10 -11
  57. package/lib/instructions/initHedgeFoundationTokens.js +7 -8
  58. package/lib/instructions/liquidateVault.js +12 -19
  59. package/lib/instructions/loanVault.js +16 -23
  60. package/lib/instructions/psmEditAccount.js +11 -11
  61. package/lib/instructions/psmMintUsh.js +18 -19
  62. package/lib/instructions/psmRedeemUsh.js +18 -19
  63. package/lib/instructions/redeemVault.js +10 -11
  64. package/lib/instructions/referralClaimFees.js +9 -10
  65. package/lib/instructions/refreshOraclePrice.js +9 -9
  66. package/lib/instructions/repayVault.js +12 -13
  67. package/lib/instructions/setHalted.js +4 -5
  68. package/lib/instructions/transferVault.js +2 -3
  69. package/lib/instructions/updateReferralAccount.js +6 -7
  70. package/lib/instructions/updateReferralState.js +6 -7
  71. package/lib/instructions/updateVaultType.js +5 -6
  72. package/lib/instructions/withdrawStakingPool.js +14 -15
  73. package/lib/instructions/withdrawVault.js +8 -9
  74. package/lib/state/VaultAccount.js +22 -8
  75. package/lib/state/VaultHistoryEvent.js +2 -2
  76. package/lib/utils/Errors.js +2 -3
  77. package/lib/utils/getLinkedListAccounts.js +2 -3
  78. package/lib/utils/sendAndConfirmWithDebug.js +1 -1
  79. package/package.json +9 -8
  80. package/src/{Constants.ts → HedgeConstants.ts} +13 -43
  81. package/src/idl/vault.ts +2342 -4024
  82. package/src/index.ts +3 -12
  83. package/src/instructions/claimLiquidationPoolPosition.ts +2 -2
  84. package/src/instructions/claimStakingPoolPosition.ts +2 -2
  85. package/src/instructions/closeClaimedLiquidationPoolPosition.ts +1 -1
  86. package/src/instructions/closeLiquidationPoolPosition.ts +2 -2
  87. package/src/instructions/createReferralAccount.ts +11 -8
  88. package/src/instructions/createStakingPool.ts +11 -4
  89. package/src/instructions/createUserReferralAccount.ts +2 -2
  90. package/src/instructions/createVault.ts +2 -2
  91. package/src/instructions/depositLiquidationPool.ts +2 -2
  92. package/src/instructions/depositStakingPool.ts +2 -2
  93. package/src/instructions/depositVault.ts +2 -2
  94. package/src/instructions/initHedgeFoundation.ts +2 -2
  95. package/src/instructions/initHedgeFoundationTokens.ts +2 -2
  96. package/src/instructions/liquidateVault.ts +29 -39
  97. package/src/instructions/loanVault.ts +23 -36
  98. package/src/instructions/psmEditAccount.ts +3 -3
  99. package/src/instructions/psmMintUsh.ts +3 -3
  100. package/src/instructions/psmRedeemUsh.ts +3 -3
  101. package/src/instructions/redeemVault.ts +2 -2
  102. package/src/instructions/referralClaimFees.ts +11 -9
  103. package/src/instructions/refreshOraclePrice.ts +4 -4
  104. package/src/instructions/repayVault.ts +2 -2
  105. package/src/instructions/setHalted.ts +2 -2
  106. package/src/instructions/transferVault.ts +1 -1
  107. package/src/instructions/updateReferralAccount.ts +2 -2
  108. package/src/instructions/updateReferralState.ts +2 -2
  109. package/src/instructions/updateVaultType.ts +2 -2
  110. package/src/instructions/withdrawStakingPool.ts +2 -2
  111. package/src/instructions/withdrawVault.ts +2 -2
  112. package/src/utils/Errors.ts +1 -1
  113. package/src/utils/getLinkedListAccounts.ts +1 -1
  114. package/declarations/instructions/adminWithdrawCol.d.ts +0 -5
  115. package/declarations/instructions/adminWithdrawUsh.d.ts +0 -5
  116. package/declarations/instructions/compoundCreateReferralAccount.d.ts +0 -17
  117. package/declarations/instructions/compoundReferralClaimFees.d.ts +0 -16
  118. package/declarations/instructions/createCompoundStakingPool.d.ts +0 -5
  119. package/declarations/instructions/createCompoundStakingPoolPosition.d.ts +0 -6
  120. package/declarations/instructions/depositCompoundStakingPoolPosition.d.ts +0 -6
  121. package/declarations/instructions/depositRewardsToCompoundPool.d.ts +0 -6
  122. package/declarations/instructions/setCompoundPoolActive.d.ts +0 -5
  123. package/declarations/instructions/setDelegateWallet.d.ts +0 -5
  124. package/declarations/instructions/setVaultTypeStatus.d.ts +0 -4
  125. package/declarations/instructions/withdrawCompoundStakingPoolPosition.d.ts +0 -6
  126. package/declarations/utils/Sender.d.ts +0 -2
  127. package/lib/instructions/adminWithdrawCol.js +0 -60
  128. package/lib/instructions/adminWithdrawUsh.js +0 -57
  129. package/lib/instructions/compoundCreateReferralAccount.js +0 -83
  130. package/lib/instructions/compoundReferralClaimFees.js +0 -87
  131. package/lib/instructions/createCompoundStakingPool.js +0 -58
  132. package/lib/instructions/createCompoundStakingPoolPosition.js +0 -56
  133. package/lib/instructions/depositCompoundStakingPoolPosition.js +0 -55
  134. package/lib/instructions/depositRewardsToCompoundPool.js +0 -64
  135. package/lib/instructions/setCompoundPoolActive.js +0 -43
  136. package/lib/instructions/setDelegateWallet.js +0 -43
  137. package/lib/instructions/setVaultTypeStatus.js +0 -38
  138. package/lib/instructions/withdrawCompoundStakingPoolPosition.js +0 -64
  139. package/lib/utils/Sender.js +0 -32
  140. package/src/instructions/adminWithdrawCol.ts +0 -87
  141. package/src/instructions/adminWithdrawUsh.ts +0 -78
  142. package/src/instructions/compoundCreateReferralAccount.ts +0 -119
  143. package/src/instructions/compoundReferralClaimFees.ts +0 -151
  144. package/src/instructions/createCompoundStakingPool.ts +0 -63
  145. package/src/instructions/createCompoundStakingPoolPosition.ts +0 -85
  146. package/src/instructions/depositCompoundStakingPoolPosition.ts +0 -78
  147. package/src/instructions/depositRewardsToCompoundPool.ts +0 -110
  148. package/src/instructions/setCompoundPoolActive.ts +0 -51
  149. package/src/instructions/setDelegateWallet.ts +0 -51
  150. package/src/instructions/withdrawCompoundStakingPoolPosition.ts +0 -100
@@ -1,4 +1,4 @@
1
- import { BN, Program, Provider } from '@project-serum/anchor'
1
+ import { BN, Program, Provider } from '@coral-xyz/anchor'
2
2
  import {
3
3
  PublicKey, Signer,
4
4
  SystemProgram, Transaction,
@@ -6,7 +6,7 @@ import {
6
6
  } from '@solana/web3.js'
7
7
  import {
8
8
  getReferralStatePublicKey, getVaultSystemStatePublicKey
9
- } from '../Constants'
9
+ } from '../HedgeConstants'
10
10
 
11
11
  import { Vault } from '../idl/vault'
12
12
  import sendAndConfirmWithDebug from '../utils/sendAndConfirmWithDebug'
@@ -1,11 +1,11 @@
1
- import { BN, Program, Provider } from '@project-serum/anchor'
1
+ import { BN, Program, Provider } from '@coral-xyz/anchor'
2
2
  import {
3
3
  PublicKey, Signer, Transaction,
4
4
  TransactionInstruction
5
5
  } from '@solana/web3.js'
6
6
  import {
7
7
  getVaultSystemStatePublicKey
8
- } from '../Constants'
8
+ } from '../HedgeConstants'
9
9
 
10
10
  import { Vault } from '../idl/vault'
11
11
  import sendAndConfirmWithDebug from '../utils/sendAndConfirmWithDebug'
@@ -1,4 +1,4 @@
1
- import { BN, Program, Provider } from '@project-serum/anchor'
1
+ import { BN, Program, Provider } from '@coral-xyz/anchor'
2
2
  import { TOKEN_PROGRAM_ID } from '@solana/spl-token'
3
3
  import {
4
4
  Keypair,
@@ -12,7 +12,7 @@ import {
12
12
  getPoolPublicKeyForMint,
13
13
  getUshMintPublicKey,
14
14
  getVaultSystemStatePublicKey
15
- } from '../Constants'
15
+ } from '../HedgeConstants'
16
16
  import { Vault } from '../idl/vault'
17
17
  import { parseAnchorErrors } from '../utils/Errors'
18
18
  import sendAndConfirmWithDebug from '../utils/sendAndConfirmWithDebug'
@@ -1,4 +1,4 @@
1
- import { BN, Program, Provider } from '@project-serum/anchor'
1
+ import { BN, Program, Provider } from '@coral-xyz/anchor'
2
2
  import { TokenInstructions } from '@project-serum/serum'
3
3
  import { getOrCreateAssociatedTokenAccount, TOKEN_PROGRAM_ID } from '@solana/spl-token'
4
4
  import {
@@ -11,7 +11,7 @@ import {
11
11
  import {
12
12
  findAssociatedTokenAddress, getHedgeMintPublicKey, getPoolPublicKeyForMint, getUshMintPublicKey,
13
13
  getVaultSystemStatePublicKey
14
- } from '../Constants'
14
+ } from '../HedgeConstants'
15
15
  import { Vault } from '../idl/vault'
16
16
  import { getLinkedListAccounts } from '../utils/getLinkedListAccounts'
17
17
  import sendAndConfirmWithDebug from '../utils/sendAndConfirmWithDebug'
@@ -1,4 +1,4 @@
1
- import { parseIdlErrors, ProgramError } from '@project-serum/anchor'
1
+ import { parseIdlErrors, ProgramError } from '@coral-xyz/anchor'
2
2
  import { IDL } from '../idl/vault'
3
3
 
4
4
  export function parseAnchorErrors (error: any): void {
@@ -1,4 +1,4 @@
1
- import { BN, Program } from '@project-serum/anchor'
1
+ import { BN, Program } from '@coral-xyz/anchor'
2
2
  import { PublicKey } from '@solana/web3.js'
3
3
  import _ from 'underscore'
4
4
 
@@ -1,5 +0,0 @@
1
- import { Program, Provider } from '@project-serum/anchor';
2
- import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
3
- import { Vault } from '../idl/vault';
4
- export declare function adminWithdrawCollateral(program: Program<Vault>, provider: Provider, payer: Signer, mintPublicKey: PublicKey, collateralType: string): Promise<PublicKey>;
5
- export declare function adminWithdrawCollateralInstruction(program: Program<Vault>, payerPublicKey: PublicKey, stakedTokenMintPublicKey: PublicKey, vaultTypeAccountPublicKey: PublicKey): Promise<TransactionInstruction>;
@@ -1,5 +0,0 @@
1
- import { Program, Provider } from '@project-serum/anchor';
2
- import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
3
- import { Vault } from '../idl/vault';
4
- export declare function adminWithdrawUsh(program: Program<Vault>, provider: Provider, payer: Signer, mintPublicKey: PublicKey): Promise<PublicKey>;
5
- export declare function adminWithdrawUshInstruction(program: Program<Vault>, payerPublicKey: PublicKey, stakedTokenMintPublicKey: PublicKey, poolPublickey: PublicKey): Promise<TransactionInstruction>;
@@ -1,17 +0,0 @@
1
- import { Program, Provider } from '@project-serum/anchor';
2
- import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
3
- import { Vault } from '../idl/vault';
4
- /** @type {Function} - Creates a new referral account.
5
- * This checks the user has enough HDG in their wallet or staked and
6
- * then allows them to create a referral account. If they meet the PSM referral threshold,
7
- * they will be eligible for PSM cut.
8
- * Params:
9
- * - program: Program<Vault> : The program instance of Hedge Vault program
10
- * - provider: Provider : Current connection
11
- * - payer: Signer : who we are creating the referral account for
12
- * - poolPublicKey: PublicKey : a key to a pool position. If the position is closed or does not belong to the signer it will be ignored
13
- * - referrer: PublicKey
14
- * - overrideTime?: number
15
- */
16
- export declare function compoundCreateReferralAccount(program: Program<Vault>, provider: Provider, payer: Signer, poolPosition: PublicKey, stakedTokenMintPublicKey: PublicKey, overrideTime?: number): Promise<PublicKey>;
17
- export declare function compoundCreateReferralAccountInstruction(program: Program<Vault>, payerPublicKey: PublicKey, poolPositionPublicKey: PublicKey, stakedTokenMintPublicKey: PublicKey, referralAccountPublicKey: PublicKey, referralStatePublicKey: PublicKey, hedgeMintPublicKey: PublicKey, hdgAssociatedTokenAccountPublicKey: PublicKey, userReferralAccountPublicKey: PublicKey, overrideTime?: number): Promise<TransactionInstruction>;
@@ -1,16 +0,0 @@
1
- import { Program, Provider } from '@project-serum/anchor';
2
- import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
3
- import { Vault } from '../idl/vault';
4
- /** @type {Function} - Allows a referrer to claims their fees.
5
- * This checks the user has enough HDG in their wallet or staked and
6
- * then allows them to claim earned fees. If they meet the PSM referral threshold,
7
- * they will be eligible for PSM cut.
8
- * Params:
9
- * - program: Program<Vault> : The program instance of Hedge Vault program
10
- * - provider: Provider : Current connection
11
- * - payer: Signer : who we are creating the referral account for
12
- * - poolPublicKey: PublicKey : a key to a pool position. If the position is closed or does not belong to the signer it will be ignored
13
- * - referrer: PublicKey
14
- */
15
- export declare function compoundReferralClaimFees(program: Program<Vault>, provider: Provider, payer: Signer, poolPosition: PublicKey, stakedTokenMintPublicKey: PublicKey): Promise<PublicKey>;
16
- export declare function compoundReferralClaimFeesInstruction(program: Program<Vault>, payerPublicKey: PublicKey, vaultSystemStatePublicKey: PublicKey, poolPositionPublicKey: PublicKey, stakedTokenMintPublicKey: PublicKey, referralAccountPublicKey: PublicKey, referralStatePublicKey: PublicKey, hedgeMintPublicKey: PublicKey, hdgAssociatedTokenAccountPublicKey: PublicKey, ushMintPublicKey: PublicKey, ushAssociatedTokenAccountPublicKey: PublicKey, communityAssociatedHedgeTokenAccountPublicKey: PublicKey, feePoolPublicKey: PublicKey, feePoolAssociatedUshTokenAccountPublicKey: PublicKey): Promise<TransactionInstruction>;
@@ -1,5 +0,0 @@
1
- import { Program, Provider } from '@project-serum/anchor';
2
- import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
3
- import { Vault } from '../idl/vault';
4
- export declare function createCompoundStakingPool(program: Program<Vault>, provider: Provider, payer: Signer, mintPublicKey: PublicKey, overrideStartTime?: number): Promise<PublicKey>;
5
- export declare function createCompoundStakingPoolInstruction(program: Program<Vault>, payerPublicKey: PublicKey, mintPublicKey: PublicKey, overrideStartTime?: number): Promise<TransactionInstruction>;
@@ -1,6 +0,0 @@
1
- /// <reference types="bn.js" />
2
- import { BN, Program, Provider } from '@project-serum/anchor';
3
- import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
4
- import { Vault } from '../idl/vault';
5
- export declare function createCompoundStakingPoolPosition(program: Program<Vault>, provider: Provider, payer: Signer, mintPublicKey: PublicKey, depositAmount: number, overrideStartTime?: number): Promise<PublicKey>;
6
- export declare function createCompoundStakingPoolPositionInstruction(program: Program<Vault>, payerPublicKey: PublicKey, poolPositionPublicKey: PublicKey, stakedTokenMintPublicKey: PublicKey, depositAmount: BN, overrideStartTime?: number): Promise<TransactionInstruction>;
@@ -1,6 +0,0 @@
1
- /// <reference types="bn.js" />
2
- import { BN, Program, Provider } from '@project-serum/anchor';
3
- import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
4
- import { Vault } from '../idl/vault';
5
- export declare function depositCompoundStakingPoolPosition(program: Program<Vault>, provider: Provider, payer: Signer, mintPublicKey: PublicKey, depositAmount: number, overrideStartTime?: number): Promise<PublicKey>;
6
- export declare function depositCompoundStakingPoolPositionInstruction(program: Program<Vault>, payerPublicKey: PublicKey, poolPositionPublicKey: PublicKey, stakedTokenMintPublicKey: PublicKey, depositAmount: BN, overrideStartTime?: number): Promise<TransactionInstruction>;
@@ -1,6 +0,0 @@
1
- /// <reference types="bn.js" />
2
- import { BN, Program, Provider } from '@project-serum/anchor';
3
- import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
4
- import { Vault } from '../idl/vault';
5
- export declare function depositRewardsToCompoundStakingPool(program: Program<Vault>, provider: Provider, payer: Signer, mintPublicKey: PublicKey, depositAmount: number, overrideStartTime?: number): Promise<PublicKey>;
6
- export declare function depositRewardsToCompoundStakingPoolInstruction(program: Program<Vault>, payerPublicKey: PublicKey, mintPublicKey: PublicKey, historyPublicKey: PublicKey, amount: BN, overrideStartTime?: number): Promise<TransactionInstruction>;
@@ -1,5 +0,0 @@
1
- import { Program, Provider } from '@project-serum/anchor';
2
- import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
3
- import { Vault } from '../idl/vault';
4
- export declare function setCompoundPoolActive(program: Program<Vault>, provider: Provider, payer: Signer, mintPublicKey: PublicKey, setActive: boolean): Promise<PublicKey>;
5
- export declare function setCompoundPoolActiveInstruction(program: Program<Vault>, vaultSystemStatePublicKey: PublicKey, payerPublicKey: PublicKey, poolPublicKey: PublicKey, stakedTokenMintPublicKey: PublicKey, setActive: boolean): Promise<TransactionInstruction>;
@@ -1,5 +0,0 @@
1
- import { Program, Provider } from '@project-serum/anchor';
2
- import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
3
- import { Vault } from '../idl/vault';
4
- export declare function setDelegateWallet(program: Program<Vault>, provider: Provider, payer: Signer, mintPublicKey: PublicKey, delegateWallet: PublicKey): Promise<PublicKey>;
5
- export declare function setDelegateWalletInstruction(program: Program<Vault>, vaultSystemStatePublicKey: PublicKey, payerPublicKey: PublicKey, poolPublicKey: PublicKey, stakedTokenMintPublicKey: PublicKey, delegateWallet: PublicKey): Promise<TransactionInstruction>;
@@ -1,4 +0,0 @@
1
- import { Program, Provider } from '@project-serum/anchor';
2
- import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
3
- export declare function setVaultTypeStatus(program: Program, provider: Provider, payer: Signer, vaultTypeAccount: PublicKey, deprecated: boolean): Promise<PublicKey>;
4
- export declare function setVaultTypeStatusInstruction(program: Program, vaultSystemStatePublicKey: PublicKey, payerPublicKey: PublicKey, vaultTypeAccount: PublicKey, deprecated: boolean): Promise<TransactionInstruction>;
@@ -1,6 +0,0 @@
1
- /// <reference types="bn.js" />
2
- import { BN, Program, Provider } from '@project-serum/anchor';
3
- import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
4
- import { Vault } from '../idl/vault';
5
- export declare function withdrawCompoundStakingPoolPosition(program: Program<Vault>, provider: Provider, payer: Signer, poolPositionPublicKey: PublicKey, stakedTokenMintPublicKey: PublicKey, claimAmount: number, overrideStartTime?: number): Promise<PublicKey>;
6
- export declare function withdrawCompoundStakingPoolPositionInstruction(program: Program<Vault>, payerPublicKey: PublicKey, poolPositionPublicKey: PublicKey, stakedTokenMintPublicKey: PublicKey, claimAmount: BN, overrideStartTime?: number): Promise<TransactionInstruction>;
@@ -1,2 +0,0 @@
1
- import { Connection, Signer, Transaction, TransactionSignature } from '@solana/web3.js';
2
- export declare function sendAndConfirmWithDebug(connection: Connection, transaction: Transaction, signers: Signer[]): Promise<TransactionSignature | void>;
@@ -1,60 +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.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;
@@ -1,57 +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.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;
@@ -1,83 +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.compoundCreateReferralAccountInstruction = exports.compoundCreateReferralAccount = 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
- /** @type {Function} - Creates a new referral account.
23
- * This checks the user has enough HDG in their wallet or staked and
24
- * then allows them to create a referral account. If they meet the PSM referral threshold,
25
- * they will be eligible for PSM cut.
26
- * Params:
27
- * - program: Program<Vault> : The program instance of Hedge Vault program
28
- * - provider: Provider : Current connection
29
- * - payer: Signer : who we are creating the referral account for
30
- * - poolPublicKey: PublicKey : a key to a pool position. If the position is closed or does not belong to the signer it will be ignored
31
- * - referrer: PublicKey
32
- * - overrideTime?: number
33
- */
34
- function compoundCreateReferralAccount(program, provider, payer, poolPosition, stakedTokenMintPublicKey, overrideTime) {
35
- return __awaiter(this, void 0, void 0, function* () {
36
- // setup transaction
37
- const transaction = new web3_js_1.Transaction();
38
- const signers = [payer];
39
- const referrer = payer.publicKey;
40
- // Setup public keys
41
- const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)(program.programId);
42
- // Find referral account
43
- let referralAccountPublicKey = yield (0, Constants_1.getReferralAccountPublicKey)(program.programId, referrer);
44
- // Get the referral state PDA
45
- const referallStatePublicKey = yield (0, Constants_1.getReferralStatePublicKey)(program.programId);
46
- // Get HDG mint public key
47
- const hedgeMintPublicKey = yield (0, Constants_1.getHedgeMintPublicKey)(program.programId);
48
- // Get HDG account of signer
49
- const payerHdgAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, hedgeMintPublicKey, payer.publicKey);
50
- // Derive the user referral account public key
51
- const userReferralAccountPublicKey = yield (0, Constants_1.getUserReferralAccountPublicKey)(program.programId, payer.publicKey);
52
- transaction.add(yield compoundCreateReferralAccountInstruction(program, payer.publicKey, poolPosition, stakedTokenMintPublicKey, referralAccountPublicKey, referallStatePublicKey, hedgeMintPublicKey, payerHdgAssociatedTokenAccount.address, userReferralAccountPublicKey, overrideTime));
53
- yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, signers).catch(Errors_1.parseAnchorErrors);
54
- return referralAccountPublicKey;
55
- });
56
- }
57
- exports.compoundCreateReferralAccount = compoundCreateReferralAccount;
58
- function compoundCreateReferralAccountInstruction(program, payerPublicKey, poolPositionPublicKey, stakedTokenMintPublicKey, referralAccountPublicKey, referralStatePublicKey, hedgeMintPublicKey, hdgAssociatedTokenAccountPublicKey, userReferralAccountPublicKey, overrideTime) {
59
- return __awaiter(this, void 0, void 0, function* () {
60
- const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)(program.programId);
61
- const [poolPublickey] = yield (0, Constants_1.getCompoundPoolPublicKeyForMint)(program.programId, stakedTokenMintPublicKey);
62
- return yield program.methods
63
- .compoundCreateReferralAccount(new anchor_1.BN(overrideTime !== null && overrideTime !== void 0 ? overrideTime : Math.floor(Date.now() / 1000)) // override override times
64
- )
65
- .accounts({
66
- signer: payerPublicKey,
67
- vaultSystemState: vaultSystemStatePublicKey,
68
- referralState: referralStatePublicKey,
69
- referralAccount: referralAccountPublicKey,
70
- userReferralAccount: userReferralAccountPublicKey,
71
- poolPosition: poolPositionPublicKey,
72
- pool: poolPublickey,
73
- stakedTokenMint: stakedTokenMintPublicKey,
74
- hedgeMint: hedgeMintPublicKey,
75
- hdgAta: hdgAssociatedTokenAccountPublicKey,
76
- systemProgram: web3_js_1.SystemProgram.programId,
77
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
78
- rent: web3_js_1.SYSVAR_RENT_PUBKEY,
79
- })
80
- .instruction();
81
- });
82
- }
83
- exports.compoundCreateReferralAccountInstruction = compoundCreateReferralAccountInstruction;
@@ -1,87 +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.compoundReferralClaimFeesInstruction = exports.compoundReferralClaimFees = 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
- /** @type {Function} - Allows a referrer to claims their fees.
22
- * This checks the user has enough HDG in their wallet or staked and
23
- * then allows them to claim earned fees. If they meet the PSM referral threshold,
24
- * they will be eligible for PSM cut.
25
- * Params:
26
- * - program: Program<Vault> : The program instance of Hedge Vault program
27
- * - provider: Provider : Current connection
28
- * - payer: Signer : who we are creating the referral account for
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
- * - referrer: PublicKey
31
- */
32
- function compoundReferralClaimFees(program, provider, payer, poolPosition, stakedTokenMintPublicKey) {
33
- return __awaiter(this, void 0, void 0, function* () {
34
- // setup transaction
35
- const transaction = new web3_js_1.Transaction();
36
- const signers = [payer];
37
- // General variables
38
- const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)(program.programId);
39
- // Find referrer account
40
- const referrer = yield payer.publicKey;
41
- const referralAccountPublicKey = yield (0, Constants_1.getReferralAccountPublicKey)(program.programId, referrer);
42
- // Derive the user referral account public key
43
- const referallStatePublicKey = yield (0, Constants_1.getReferralStatePublicKey)(program.programId);
44
- const hedgeMintPublicKey = yield (0, Constants_1.getHedgeMintPublicKey)(program.programId);
45
- // Get HDG account of signer
46
- const payerHdgAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, hedgeMintPublicKey, payer.publicKey);
47
- const ushMintPublicKey = yield (0, Constants_1.getUshMintPublicKey)(program.programId);
48
- // Get USH account of signer
49
- const payerUshAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, ushMintPublicKey, payer.publicKey);
50
- // Get community_associated_hedge_token_account
51
- const communityAssociatedHedgeTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, hedgeMintPublicKey, vaultSystemStatePublicKey, true);
52
- const [feePoolPublicKey] = yield (0, Constants_1.getPoolPublicKeyForMint)(program.programId, hedgeMintPublicKey);
53
- const feePoolAssociatedUshTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, ushMintPublicKey, feePoolPublicKey, true);
54
- transaction.add(yield compoundReferralClaimFeesInstruction(program, payer.publicKey, vaultSystemStatePublicKey, poolPosition, stakedTokenMintPublicKey, referralAccountPublicKey, referallStatePublicKey, hedgeMintPublicKey, payerHdgAssociatedTokenAccount.address, ushMintPublicKey, payerUshAssociatedTokenAccount.address, communityAssociatedHedgeTokenAccount.address, feePoolPublicKey, feePoolAssociatedUshTokenAccount.address));
55
- yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, signers).catch(Errors_1.parseAnchorErrors);
56
- return referralAccountPublicKey;
57
- });
58
- }
59
- exports.compoundReferralClaimFees = compoundReferralClaimFees;
60
- function compoundReferralClaimFeesInstruction(program, payerPublicKey, vaultSystemStatePublicKey, poolPositionPublicKey, stakedTokenMintPublicKey, referralAccountPublicKey, referralStatePublicKey, hedgeMintPublicKey, hdgAssociatedTokenAccountPublicKey, ushMintPublicKey, ushAssociatedTokenAccountPublicKey, communityAssociatedHedgeTokenAccountPublicKey, feePoolPublicKey, feePoolAssociatedUshTokenAccountPublicKey) {
61
- return __awaiter(this, void 0, void 0, function* () {
62
- const [poolPublickey] = yield (0, Constants_1.getCompoundPoolPublicKeyForMint)(program.programId, stakedTokenMintPublicKey);
63
- return yield program.methods
64
- .compoundReferralClaimFees()
65
- .accounts({
66
- signer: payerPublicKey,
67
- vaultSystemState: vaultSystemStatePublicKey,
68
- referralState: referralStatePublicKey,
69
- referralAccount: referralAccountPublicKey,
70
- poolPosition: poolPositionPublicKey,
71
- hedgeMint: hedgeMintPublicKey,
72
- signerHdgAta: hdgAssociatedTokenAccountPublicKey,
73
- ushMint: ushMintPublicKey,
74
- signerUshAta: ushAssociatedTokenAccountPublicKey,
75
- communityAssociatedHedgeTokenAccount: communityAssociatedHedgeTokenAccountPublicKey,
76
- pool: poolPublickey,
77
- stakedTokenMint: stakedTokenMintPublicKey,
78
- feePool: feePoolPublicKey,
79
- feePoolAssociatedUshTokenAccount: feePoolAssociatedUshTokenAccountPublicKey,
80
- systemProgram: web3_js_1.SystemProgram.programId,
81
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
82
- rent: web3_js_1.SYSVAR_RENT_PUBKEY,
83
- })
84
- .instruction();
85
- });
86
- }
87
- exports.compoundReferralClaimFeesInstruction = compoundReferralClaimFeesInstruction;
@@ -1,58 +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.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;
@@ -1,56 +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.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;