hedge-web3 0.2.31 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) 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 +60 -744
  6. package/declarations/index.d.ts +1 -10
  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 +3 -3
  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 +3 -3
  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 +60 -744
  44. package/lib/index.js +6 -11
  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 +13 -17
  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 +12 -16
  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 +2382 -3750
  82. package/src/index.ts +3 -10
  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 -15
  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 +12 -18
  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/createCompoundStakingPool.d.ts +0 -5
  117. package/declarations/instructions/createCompoundStakingPoolPosition.d.ts +0 -6
  118. package/declarations/instructions/depositCompoundStakingPoolPosition.d.ts +0 -6
  119. package/declarations/instructions/depositRewardsToCompoundPool.d.ts +0 -6
  120. package/declarations/instructions/setCompoundPoolActive.d.ts +0 -5
  121. package/declarations/instructions/setDelegateWallet.d.ts +0 -5
  122. package/declarations/instructions/setVaultTypeStatus.d.ts +0 -4
  123. package/declarations/instructions/withdrawCompoundStakingPoolPosition.d.ts +0 -6
  124. package/declarations/utils/Sender.d.ts +0 -2
  125. package/lib/instructions/adminWithdrawCol.js +0 -60
  126. package/lib/instructions/adminWithdrawUsh.js +0 -57
  127. package/lib/instructions/createCompoundStakingPool.js +0 -58
  128. package/lib/instructions/createCompoundStakingPoolPosition.js +0 -56
  129. package/lib/instructions/depositCompoundStakingPoolPosition.js +0 -55
  130. package/lib/instructions/depositRewardsToCompoundPool.js +0 -64
  131. package/lib/instructions/setCompoundPoolActive.js +0 -43
  132. package/lib/instructions/setDelegateWallet.js +0 -43
  133. package/lib/instructions/setVaultTypeStatus.js +0 -38
  134. package/lib/instructions/withdrawCompoundStakingPoolPosition.js +0 -64
  135. package/lib/utils/Sender.js +0 -32
  136. package/src/instructions/adminWithdrawCol.ts +0 -87
  137. package/src/instructions/adminWithdrawUsh.ts +0 -78
  138. package/src/instructions/createCompoundStakingPool.ts +0 -63
  139. package/src/instructions/createCompoundStakingPoolPosition.ts +0 -85
  140. package/src/instructions/depositCompoundStakingPoolPosition.ts +0 -78
  141. package/src/instructions/depositRewardsToCompoundPool.ts +0 -110
  142. package/src/instructions/setCompoundPoolActive.ts +0 -51
  143. package/src/instructions/setDelegateWallet.ts +0 -51
  144. package/src/instructions/withdrawCompoundStakingPoolPosition.ts +0 -100
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from './Constants'
1
+ export * from './HedgeConstants'
2
2
  export * from './HedgeDecimal'
3
3
  export * from './idl/vault'
4
4
  export * from './instructions/claimLiquidationPoolPosition'
@@ -24,15 +24,6 @@ export * from './instructions/refreshOraclePrice'
24
24
  export * from './instructions/repayVault'
25
25
  export * from './instructions/setHalted'
26
26
  export * from './instructions/transferVault'
27
- export * from './instructions/createCompoundStakingPool'
28
- export * from './instructions/createCompoundStakingPoolPosition'
29
- export * from './instructions/depositCompoundStakingPoolPosition'
30
- export * from './instructions/withdrawCompoundStakingPoolPosition'
31
- export * from './instructions/setDelegateWallet'
32
- export * from './instructions/setCompoundPoolActive'
33
- export * from './instructions/adminWithdrawCol'
34
- export * from './instructions/adminWithdrawUsh'
35
- export * from './instructions/depositRewardsToCompoundPool'
36
27
  export * from './instructions/updateReferralAccount'
37
28
  export * from './instructions/updateReferralState'
38
29
  export * from './instructions/updateVaultType'
@@ -46,3 +37,5 @@ export * from './state/StakingPoolPosition'
46
37
  export * from './state/VaultAccount'
47
38
  export * from './state/VaultHistoryEvent'
48
39
  export * from './utils/getLinkedListAccounts'
40
+
41
+
@@ -1,4 +1,4 @@
1
- import { Program, Provider } from '@project-serum/anchor'
1
+ import { Program, Provider } from '@coral-xyz/anchor'
2
2
  import { ASSOCIATED_TOKEN_PROGRAM_ID, getOrCreateAssociatedTokenAccount, TOKEN_PROGRAM_ID } from '@solana/spl-token'
3
3
  import {
4
4
  PublicKey, Signer,
@@ -10,7 +10,7 @@ import {
10
10
  import {
11
11
  findAssociatedTokenAddress, getLiquidationPoolStatePublicKey,
12
12
  getVaultSystemStatePublicKey, getVaultTypeAccountPublicKey
13
- } from '../Constants'
13
+ } from '../HedgeConstants'
14
14
  import { Vault } from '../idl/vault'
15
15
  import { parseAnchorErrors } from '../utils/Errors'
16
16
  import sendAndConfirmWithDebug from '../utils/sendAndConfirmWithDebug'
@@ -1,4 +1,4 @@
1
- import { Program, Provider } from '@project-serum/anchor'
1
+ import { Program, Provider } from '@coral-xyz/anchor'
2
2
  import { ASSOCIATED_TOKEN_PROGRAM_ID, getOrCreateAssociatedTokenAccount, TOKEN_PROGRAM_ID } from '@solana/spl-token'
3
3
  import {
4
4
  PublicKey, Signer,
@@ -10,7 +10,7 @@ import {
10
10
  import {
11
11
  getHedgeMintPublicKey, getPoolPublicKeyForMint,
12
12
  getVaultSystemStatePublicKey, getVaultTypeAccountPublicKey
13
- } from '../Constants'
13
+ } from '../HedgeConstants'
14
14
  import { Vault } from '../idl/vault'
15
15
  import { parseAnchorErrors } from '../utils/Errors'
16
16
  import sendAndConfirmWithDebug from '../utils/sendAndConfirmWithDebug'
@@ -1,4 +1,4 @@
1
- import { Program, Provider } from '@project-serum/anchor'
1
+ import { Program, Provider } from '@coral-xyz/anchor'
2
2
  import { PublicKey, Signer, Transaction, TransactionInstruction } from '@solana/web3.js'
3
3
  import { parseAnchorErrors } from '../utils/Errors'
4
4
  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 { ASSOCIATED_TOKEN_PROGRAM_ID, getOrCreateAssociatedTokenAccount, TOKEN_PROGRAM_ID } from '@solana/spl-token'
3
3
  import {
4
4
  PublicKey, Signer,
@@ -12,7 +12,7 @@ import {
12
12
  getLiquidationPoolStatePublicKey,
13
13
  getLiquidationPoolUshAccountPublicKey, getReferralAccountPublicKey, getReferralStatePublicKey, getUserReferralAccountPublicKey, 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,14 +1,16 @@
1
- import { BN, Program, Provider } from '@project-serum/anchor'
1
+ import { BN, Program, Provider } from '@coral-xyz/anchor'
2
2
  import { getOrCreateAssociatedTokenAccount, TOKEN_PROGRAM_ID } from '@solana/spl-token'
3
- import { PublicKey, Signer, SystemProgram, SYSVAR_RENT_PUBKEY, Transaction, TransactionInstruction } from '@solana/web3.js'
4
3
  import {
5
- getCompoundPoolPublicKeyForMint,
6
- getHedgeMintPublicKey,
7
- getReferralAccountPublicKey,
8
- getReferralStatePublicKey,
9
- getUserReferralAccountPublicKey,
10
- getVaultSystemStatePublicKey,
11
- } from '../Constants'
4
+ PublicKey, Signer,
5
+ SystemProgram,
6
+ SYSVAR_RENT_PUBKEY,
7
+ Transaction,
8
+ TransactionInstruction
9
+ } from '@solana/web3.js'
10
+ import {
11
+ getHedgeMintPublicKey, getReferralAccountPublicKey, getReferralStatePublicKey,
12
+ getUserReferralAccountPublicKey, getVaultSystemStatePublicKey
13
+ } from '../HedgeConstants'
12
14
 
13
15
  import { Vault } from '../idl/vault'
14
16
  import { parseAnchorErrors } from '../utils/Errors'
@@ -31,7 +33,6 @@ export async function createReferralAccount(
31
33
  provider: Provider,
32
34
  payer: Signer,
33
35
  poolPosition: PublicKey,
34
- stakedTokenMintPublicKey: PublicKey,
35
36
  overrideTime?: number
36
37
  ): Promise<PublicKey> {
37
38
  // setup transaction
@@ -67,7 +68,6 @@ export async function createReferralAccount(
67
68
  program,
68
69
  payer.publicKey,
69
70
  poolPosition,
70
- stakedTokenMintPublicKey,
71
71
  referralAccountPublicKey,
72
72
  referallStatePublicKey,
73
73
  hedgeMintPublicKey,
@@ -85,7 +85,6 @@ export async function createReferralAccountInstruction(
85
85
  program: Program<Vault>,
86
86
  payerPublicKey: PublicKey,
87
87
  poolPositionPublicKey: PublicKey,
88
- stakedTokenMintPublicKey: PublicKey,
89
88
  referralAccountPublicKey: PublicKey,
90
89
  referralStatePublicKey: PublicKey,
91
90
  hedgeMintPublicKey: PublicKey,
@@ -94,7 +93,6 @@ export async function createReferralAccountInstruction(
94
93
  overrideTime?: number
95
94
  ): Promise<TransactionInstruction> {
96
95
  const vaultSystemStatePublicKey = await getVaultSystemStatePublicKey(program.programId)
97
- const [poolPublickey] = await getCompoundPoolPublicKeyForMint(program.programId, stakedTokenMintPublicKey)
98
96
 
99
97
  return await program.methods
100
98
  .createReferralAccount(
@@ -107,8 +105,6 @@ export async function createReferralAccountInstruction(
107
105
  referralAccount: referralAccountPublicKey,
108
106
  userReferralAccount: userReferralAccountPublicKey,
109
107
  poolPosition: poolPositionPublicKey,
110
- pool: poolPublickey,
111
- stakedTokenMint: stakedTokenMintPublicKey,
112
108
  hedgeMint: hedgeMintPublicKey,
113
109
  hdgAta: hdgAssociatedTokenAccountPublicKey,
114
110
  systemProgram: SystemProgram.programId,
@@ -1,12 +1,18 @@
1
- import { BN, Program, Provider } from '@project-serum/anchor'
1
+ import { BN, Program, Provider } from '@coral-xyz/anchor'
2
2
  import { ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID } from '@solana/spl-token'
3
- import { PublicKey, Signer, SystemProgram, SYSVAR_RENT_PUBKEY, Transaction, TransactionInstruction } from '@solana/web3.js'
3
+ import {
4
+ PublicKey, Signer,
5
+ SystemProgram,
6
+ SYSVAR_RENT_PUBKEY,
7
+ Transaction,
8
+ TransactionInstruction
9
+ } from '@solana/web3.js'
4
10
  import {
5
11
  findAssociatedTokenAddress,
6
12
  getPoolPublicKeyForMint,
7
13
  getUshMintPublicKey,
8
- getVaultSystemStatePublicKey,
9
- } from '../Constants'
14
+ getVaultSystemStatePublicKey
15
+ } from '../HedgeConstants'
10
16
  import { Vault } from '../idl/vault'
11
17
  import { parseAnchorErrors } from '../utils/Errors'
12
18
  import sendAndConfirmWithDebug from '../utils/sendAndConfirmWithDebug'
@@ -37,6 +43,7 @@ export async function createStakingPoolInstruction(
37
43
  const vaultSystemStatePublicKey = await getVaultSystemStatePublicKey(program.programId)
38
44
  const ushMintPublickey = await getUshMintPublicKey(program.programId)
39
45
  const [poolPublickey, poolBump] = await getPoolPublicKeyForMint(program.programId, mintPublicKey)
46
+
40
47
  const poolAssociatedStakedTokenAccount = await findAssociatedTokenAddress(program.programId, poolPublickey, mintPublicKey)
41
48
  const poolAssociatedUshTokenAccount = await findAssociatedTokenAddress(program.programId, poolPublickey, ushMintPublickey)
42
49
  return await program.methods
@@ -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
  PublicKey, Signer,
@@ -7,7 +7,7 @@ import {
7
7
  Transaction,
8
8
  TransactionInstruction
9
9
  } from '@solana/web3.js'
10
- import { getReferralAccountPublicKey, getUserReferralAccountPublicKey, getVaultSystemStatePublicKey } from '../Constants'
10
+ import { getReferralAccountPublicKey, getUserReferralAccountPublicKey, getVaultSystemStatePublicKey } from '../HedgeConstants'
11
11
 
12
12
  import { Vault } from '../idl/vault'
13
13
  import { parseAnchorErrors } from '../utils/Errors'
@@ -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 { ASSOCIATED_TOKEN_PROGRAM_ID, getOrCreateAssociatedTokenAccount, TOKEN_PROGRAM_ID } from '@solana/spl-token'
4
4
  import {
@@ -18,7 +18,7 @@ import {
18
18
  getUshMintPublicKey,
19
19
  getVaultSystemStatePublicKey,
20
20
  getVaultTypeAccountPublicKey,
21
- } from '../Constants'
21
+ } from '../HedgeConstants'
22
22
 
23
23
  import { v4 as uuidv4 } from 'uuid'
24
24
  import { Vault } from '../idl/vault'
@@ -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 { getOrCreateAssociatedTokenAccount, TOKEN_PROGRAM_ID } from '@solana/spl-token'
3
3
  import {
4
4
  Keypair,
@@ -10,7 +10,7 @@ import {
10
10
  getLiquidationPoolStatePublicKey,
11
11
  getLiquidationPoolUshAccountPublicKey, getReferralAccountPublicKey, getUserReferralAccountPublicKey, getUshMintPublicKey,
12
12
  getVaultSystemStatePublicKey
13
- } from '../Constants'
13
+ } from '../HedgeConstants'
14
14
  import { Vault } from '../idl/vault'
15
15
  import { parseAnchorErrors } from '../utils/Errors'
16
16
  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,
@@ -6,7 +6,7 @@ import {
6
6
  SystemProgram, Transaction,
7
7
  TransactionInstruction
8
8
  } from '@solana/web3.js'
9
- import { findAssociatedTokenAddress, getPoolPublicKeyForMint, getVaultSystemStatePublicKey } from '../Constants'
9
+ import { findAssociatedTokenAddress, getPoolPublicKeyForMint, getVaultSystemStatePublicKey } from '../HedgeConstants'
10
10
  import { Vault } from '../idl/vault'
11
11
  import { parseAnchorErrors } from '../utils/Errors'
12
12
  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 { WRAPPED_SOL_MINT } from '@project-serum/serum/lib/token-instructions'
4
4
  import { getOrCreateAssociatedTokenAccount, TOKEN_PROGRAM_ID } from '@solana/spl-token'
@@ -12,7 +12,7 @@ import {
12
12
  import {
13
13
  findAssociatedTokenAddress, getHedgeMintPublicKey, getPoolPublicKeyForMint, getUshMintPublicKey,
14
14
  getVaultSystemStatePublicKey
15
- } from '../Constants'
15
+ } from '../HedgeConstants'
16
16
  import { Vault } from '../idl/vault'
17
17
  import { getLinkedListAccounts } from '../utils/getLinkedListAccounts'
18
18
  import sendAndConfirmWithDebug from '../utils/sendAndConfirmWithDebug'
@@ -1,4 +1,4 @@
1
- import { Program, Provider } from '@project-serum/anchor'
1
+ import { Program, Provider } from '@coral-xyz/anchor'
2
2
  import { ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID } from '@solana/spl-token'
3
3
  import {
4
4
  Keypair,
@@ -15,7 +15,7 @@ import {
15
15
  getLiquidationPoolUshAccountPublicKey,
16
16
  getUshMintPublicKey,
17
17
  getVaultSystemStatePublicKey
18
- } from '../Constants'
18
+ } from '../HedgeConstants'
19
19
  import { Vault } from '../idl/vault'
20
20
  import { parseAnchorErrors } from '../utils/Errors'
21
21
  import sendAndConfirmWithDebug from '../utils/sendAndConfirmWithDebug'
@@ -1,4 +1,4 @@
1
- import { Program, Provider } from '@project-serum/anchor'
1
+ import { Program, Provider } from '@coral-xyz/anchor'
2
2
  import { ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID } from '@solana/spl-token'
3
3
  import {
4
4
  Keypair,
@@ -11,7 +11,7 @@ import {
11
11
  import {
12
12
  findAssociatedTokenAddress,
13
13
  getHedgeMintPublicKey, getVaultSystemStatePublicKey
14
- } from '../Constants'
14
+ } from '../HedgeConstants'
15
15
  import { parseAnchorErrors } from '../utils/Errors'
16
16
  import sendAndConfirmWithDebug from '../utils/sendAndConfirmWithDebug'
17
17
 
@@ -1,23 +1,20 @@
1
- import { BN, Program, Provider } from '@project-serum/anchor'
1
+ import { BN, Program, Provider } from '@coral-xyz/anchor'
2
2
  import { ASSOCIATED_TOKEN_PROGRAM_ID, getOrCreateAssociatedTokenAccount, TOKEN_PROGRAM_ID } from '@solana/spl-token'
3
3
  import {
4
- ComputeBudgetProgram,
5
4
  Keypair,
6
- PublicKey,
7
- Signer,
5
+ PublicKey, Signer,
8
6
  SystemProgram,
9
7
  SYSVAR_RENT_PUBKEY,
10
8
  Transaction,
11
- TransactionInstruction,
9
+ TransactionInstruction
12
10
  } from '@solana/web3.js'
13
11
  import {
14
12
  getHedgeMintPublicKey,
15
13
  getLiquidationPoolStatePublicKey,
16
14
  getLiquidationPoolUshAccountPublicKey,
17
- getPoolPublicKeyForMint,
18
- getUshMintPublicKey,
19
- getVaultSystemStatePublicKey,
20
- } from '../Constants'
15
+ getPoolPublicKeyForMint, getUshMintPublicKey,
16
+ getVaultSystemStatePublicKey
17
+ } from '../HedgeConstants'
21
18
  import { Vault } from '../idl/vault'
22
19
  import { getLinkedListAccounts } from '../utils/getLinkedListAccounts'
23
20
  import sendAndConfirmWithDebug from '../utils/sendAndConfirmWithDebug'
@@ -40,11 +37,6 @@ export async function liquidateVault(
40
37
  const liquidationPoolStatePublicKey = await getLiquidationPoolStatePublicKey(program.programId)
41
38
  const poolStateInfo = await program.account.liquidationPoolState.fetch(liquidationPoolStatePublicKey)
42
39
 
43
- const additionalComputationBudget = ComputeBudgetProgram.requestUnits({
44
- units: 300000,
45
- additionalFee: 0,
46
- })
47
-
48
40
  const payerAssociatedTokenAccount = await getOrCreateAssociatedTokenAccount(
49
41
  provider.connection,
50
42
  payer,
@@ -104,32 +96,30 @@ export async function liquidateVault(
104
96
  const newEra = Keypair.generate()
105
97
  const transaction = new Transaction()
106
98
 
107
- transaction
108
- .add(additionalComputationBudget)
109
- .add(
110
- await liquidateVaultInstruction(
111
- program,
112
- payer.publicKey,
113
- payerAssociatedTokenAccount.address,
114
- vaultPublicKey,
115
- vaultAssociatedTokenAccount.address,
116
- liquidationPoolStatePublicKey,
117
- poolStateInfo.currentEra,
118
- poolAssociatedTokenAccount.address,
119
- history.publicKey,
120
- newEra.publicKey,
121
- hedgeStakingPoolPublicKey,
122
- feePoolAssociatedTokenAccount.address,
123
- hedgeStakingPoolAssociatedUshTokenAccount.address,
124
- collateralMint,
125
- vaultTypeAssociatedTokenAccount.address,
126
- oldSmallerPublicKey,
127
- newSmallerPublicKey,
128
- newLargerPublicKey,
129
- vaultAccount.vaultType,
130
- overrideTime
131
- )
99
+ transaction.add(
100
+ await liquidateVaultInstruction(
101
+ program,
102
+ payer.publicKey,
103
+ payerAssociatedTokenAccount.address,
104
+ vaultPublicKey,
105
+ vaultAssociatedTokenAccount.address,
106
+ liquidationPoolStatePublicKey,
107
+ poolStateInfo.currentEra,
108
+ poolAssociatedTokenAccount.address,
109
+ history.publicKey,
110
+ newEra.publicKey,
111
+ hedgeStakingPoolPublicKey,
112
+ feePoolAssociatedTokenAccount.address,
113
+ hedgeStakingPoolAssociatedUshTokenAccount.address,
114
+ collateralMint,
115
+ vaultTypeAssociatedTokenAccount.address,
116
+ oldSmallerPublicKey,
117
+ newSmallerPublicKey,
118
+ newLargerPublicKey,
119
+ vaultAccount.vaultType,
120
+ overrideTime
132
121
  )
122
+ )
133
123
 
134
124
  await sendAndConfirmWithDebug(provider.connection, transaction, [payer, history, newEra])
135
125
  return vaultPublicKey
@@ -1,24 +1,18 @@
1
- import { BN, Program, Provider } from '@project-serum/anchor'
1
+ import { BN, Program, Provider } from '@coral-xyz/anchor'
2
2
  import { getOrCreateAssociatedTokenAccount, TOKEN_PROGRAM_ID } from '@solana/spl-token'
3
3
  import {
4
- ComputeBudgetProgram,
5
4
  Keypair,
6
- PublicKey,
7
- Signer,
5
+ PublicKey, Signer,
8
6
  SystemProgram,
9
7
  Transaction,
10
- TransactionInstruction,
8
+ TransactionInstruction
11
9
  } from '@solana/web3.js'
12
10
  import {
13
11
  findAssociatedTokenAddress,
14
12
  getHedgeMintPublicKey,
15
- getPoolPublicKeyForMint,
16
- getReferralAccountPublicKey,
17
- getReferralStatePublicKey,
18
- getUserReferralAccountPublicKey,
19
- getUshMintPublicKey,
20
- getVaultSystemStatePublicKey,
21
- } from '../Constants'
13
+ getPoolPublicKeyForMint, getReferralAccountPublicKey, getReferralStatePublicKey, getUserReferralAccountPublicKey, getUshMintPublicKey,
14
+ getVaultSystemStatePublicKey
15
+ } from '../HedgeConstants'
22
16
  import { Vault } from '../idl/vault'
23
17
  import { getLinkedListAccounts } from '../utils/getLinkedListAccounts'
24
18
  import sendAndConfirmWithDebug from '../utils/sendAndConfirmWithDebug'
@@ -32,11 +26,6 @@ export async function loanVault(
32
26
  overrideTime?: number,
33
27
  referrer?: PublicKey
34
28
  ): Promise<PublicKey> {
35
- const additionalComputationBudget = ComputeBudgetProgram.requestUnits({
36
- units: 300000,
37
- additionalFee: 0,
38
- })
39
-
40
29
  const ushMintPublickey = await getUshMintPublicKey(program.programId)
41
30
 
42
31
  const payerUshAccount = await getOrCreateAssociatedTokenAccount(
@@ -83,26 +72,24 @@ export async function loanVault(
83
72
  }
84
73
 
85
74
  const history = Keypair.generate()
86
- const transaction = new Transaction()
87
- .add(additionalComputationBudget)
88
- .add(
89
- await loanVaultInstruction(
90
- program,
91
- payer.publicKey,
92
- payerUshAccount.address,
93
- vaultPublicKey,
94
- vaultAssociatedTokenAccount.address,
95
- history.publicKey,
96
- vaultAccount.vaultType,
97
- vaultTypeAssociatedTokenAccount.address,
98
- oldSmallerPublicKey,
99
- newSmallerPublicKey,
100
- newLargerPublicKey,
101
- new BN(loanAmount),
102
- referralAccountPublicKey,
103
- overrideTime
104
- )
75
+ const transaction = new Transaction().add(
76
+ await loanVaultInstruction(
77
+ program,
78
+ payer.publicKey,
79
+ payerUshAccount.address,
80
+ vaultPublicKey,
81
+ vaultAssociatedTokenAccount.address,
82
+ history.publicKey,
83
+ vaultAccount.vaultType,
84
+ vaultTypeAssociatedTokenAccount.address,
85
+ oldSmallerPublicKey,
86
+ newSmallerPublicKey,
87
+ newLargerPublicKey,
88
+ new BN(loanAmount),
89
+ referralAccountPublicKey,
90
+ overrideTime
105
91
  )
92
+ )
106
93
  await sendAndConfirmWithDebug(provider.connection, transaction, [payer, history])
107
94
  return vaultPublicKey
108
95
  }
@@ -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 { getOrCreateAssociatedTokenAccount } from '@solana/spl-token'
3
3
  import {
4
4
  PublicKey, Signer,
@@ -11,7 +11,7 @@ import {
11
11
  getPoolPublicKeyForMint,
12
12
  getUshMintPublicKey,
13
13
  getVaultSystemStatePublicKey
14
- } from '../Constants'
14
+ } from '../HedgeConstants'
15
15
  import { Vault } from '../idl/vault'
16
16
  import sendAndConfirmWithDebug from '../utils/sendAndConfirmWithDebug'
17
17
 
@@ -51,7 +51,7 @@ export async function psmEditAccount(
51
51
 
52
52
 
53
53
  const enc = new TextEncoder()
54
- const [psmAccount] = await PublicKey.findProgramAddress(
54
+ const [psmAccount] = await PublicKey.findProgramAddressSync(
55
55
  [enc.encode(collateralMint.toString().slice(0, 12)), enc.encode('PSM')],
56
56
  program.programId
57
57
  )
@@ -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 { getOrCreateAssociatedTokenAccount, TOKEN_PROGRAM_ID } from '@solana/spl-token'
3
3
  import {
4
4
  PublicKey, Signer,
@@ -14,7 +14,7 @@ import {
14
14
  getReferralStatePublicKey,
15
15
  getUshMintPublicKey,
16
16
  getVaultSystemStatePublicKey
17
- } from '../Constants'
17
+ } from '../HedgeConstants'
18
18
  import { Vault } from '../idl/vault'
19
19
  import sendAndConfirmWithDebug from '../utils/sendAndConfirmWithDebug'
20
20
 
@@ -44,7 +44,7 @@ export async function psmMintUsh(
44
44
  )
45
45
 
46
46
  const enc = new TextEncoder()
47
- const [psmAccount] = await PublicKey.findProgramAddress(
47
+ const [psmAccount] = await PublicKey.findProgramAddressSync(
48
48
  [enc.encode(collateralMint.toString().slice(0, 12)), enc.encode('PSM')],
49
49
  program.programId
50
50
  )
@@ -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 { getOrCreateAssociatedTokenAccount, TOKEN_PROGRAM_ID } from '@solana/spl-token'
3
3
  import {
4
4
  PublicKey, Signer,
@@ -12,7 +12,7 @@ import {
12
12
  getPoolPublicKeyForMint, getReferralAccountPublicKey,
13
13
  getReferralStatePublicKey, getUshMintPublicKey,
14
14
  getVaultSystemStatePublicKey
15
- } from '../Constants'
15
+ } from '../HedgeConstants'
16
16
  import { Vault } from '../idl/vault'
17
17
  import sendAndConfirmWithDebug from '../utils/sendAndConfirmWithDebug'
18
18
 
@@ -42,7 +42,7 @@ export async function psmRedeemUsh(
42
42
  )
43
43
 
44
44
  const enc = new TextEncoder()
45
- const [psmAccount] = await PublicKey.findProgramAddress(
45
+ const [psmAccount] = await PublicKey.findProgramAddressSync(
46
46
  [enc.encode(collateralMint.toString().slice(0, 12)), enc.encode('PSM')],
47
47
  program.programId
48
48
  )
@@ -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 { getOrCreateAssociatedTokenAccount, TOKEN_PROGRAM_ID } from '@solana/spl-token'
3
3
  // import { TokenInstructions } from '@project-serum/serum'
4
4
  import {
@@ -13,7 +13,7 @@ import {
13
13
  getHedgeMintPublicKey,
14
14
  getPoolPublicKeyForMint, getUshMintPublicKey,
15
15
  getVaultSystemStatePublicKey
16
- } from '../Constants'
16
+ } from '../HedgeConstants'
17
17
  import { Vault } from '../idl/vault'
18
18
  import { getLinkedListAccounts } from '../utils/getLinkedListAccounts'
19
19
  import sendAndConfirmWithDebug from '../utils/sendAndConfirmWithDebug'
@@ -1,15 +1,16 @@
1
- import { Program, Provider } from '@project-serum/anchor'
1
+ import { Program, Provider } from '@coral-xyz/anchor'
2
2
  import { getOrCreateAssociatedTokenAccount, TOKEN_PROGRAM_ID } from '@solana/spl-token'
3
- import { PublicKey, Signer, SystemProgram, SYSVAR_RENT_PUBKEY, Transaction, TransactionInstruction } from '@solana/web3.js'
4
3
  import {
5
- getCompoundPoolPublicKeyForMint,
6
- getHedgeMintPublicKey,
7
- getPoolPublicKeyForMint,
8
- getReferralAccountPublicKey,
9
- getReferralStatePublicKey,
10
- getUshMintPublicKey,
11
- getVaultSystemStatePublicKey,
12
- } from '../Constants'
4
+ PublicKey, Signer,
5
+ SystemProgram,
6
+ SYSVAR_RENT_PUBKEY,
7
+ Transaction,
8
+ TransactionInstruction
9
+ } from '@solana/web3.js'
10
+ import {
11
+ getHedgeMintPublicKey, getPoolPublicKeyForMint, getReferralAccountPublicKey, getReferralStatePublicKey,
12
+ getUshMintPublicKey, getVaultSystemStatePublicKey
13
+ } from '../HedgeConstants'
13
14
 
14
15
  import { Vault } from '../idl/vault'
15
16
  import { parseAnchorErrors } from '../utils/Errors'
@@ -30,8 +31,7 @@ export async function referralClaimFees(
30
31
  program: Program<Vault>,
31
32
  provider: Provider,
32
33
  payer: Signer,
33
- poolPosition: PublicKey,
34
- stakedTokenMintPublicKey: PublicKey
34
+ poolPosition: PublicKey
35
35
  ): Promise<PublicKey> {
36
36
  // setup transaction
37
37
  const transaction = new Transaction()
@@ -91,7 +91,6 @@ export async function referralClaimFees(
91
91
  payer.publicKey,
92
92
  vaultSystemStatePublicKey,
93
93
  poolPosition,
94
- stakedTokenMintPublicKey,
95
94
  referralAccountPublicKey,
96
95
  referallStatePublicKey,
97
96
  hedgeMintPublicKey,
@@ -113,7 +112,6 @@ export async function referralClaimFeesInstruction(
113
112
  payerPublicKey: PublicKey,
114
113
  vaultSystemStatePublicKey: PublicKey,
115
114
  poolPositionPublicKey: PublicKey,
116
- stakedTokenMintPublicKey: PublicKey,
117
115
  referralAccountPublicKey: PublicKey,
118
116
  referralStatePublicKey: PublicKey,
119
117
  hedgeMintPublicKey: PublicKey,
@@ -124,8 +122,6 @@ export async function referralClaimFeesInstruction(
124
122
  feePoolPublicKey: PublicKey,
125
123
  feePoolAssociatedUshTokenAccountPublicKey: PublicKey
126
124
  ): Promise<TransactionInstruction> {
127
- const [poolPublickey] = await getCompoundPoolPublicKeyForMint(program.programId, stakedTokenMintPublicKey)
128
-
129
125
  return await program.methods
130
126
  .referralClaimFees()
131
127
  .accounts({
@@ -139,8 +135,6 @@ export async function referralClaimFeesInstruction(
139
135
  ushMint: ushMintPublicKey,
140
136
  signerUshAta: ushAssociatedTokenAccountPublicKey,
141
137
  communityAssociatedHedgeTokenAccount: communityAssociatedHedgeTokenAccountPublicKey,
142
- pool: poolPublickey,
143
- stakedTokenMint: stakedTokenMintPublicKey,
144
138
  feePool: feePoolPublicKey,
145
139
  feePoolAssociatedUshTokenAccount: feePoolAssociatedUshTokenAccountPublicKey,
146
140
  systemProgram: SystemProgram.programId,