hedge-web3 0.2.31 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/declarations/Constants.d.ts +0 -12
- package/declarations/HedgeConstants.d.ts +76 -0
- package/declarations/idl/pyth.d.ts +1 -1
- package/declarations/idl/switchboard.d.ts +1 -1
- package/declarations/idl/vault.d.ts +60 -744
- package/declarations/index.d.ts +1 -10
- package/declarations/instructions/claimLiquidationPoolPosition.d.ts +1 -1
- package/declarations/instructions/claimStakingPoolPosition.d.ts +1 -1
- package/declarations/instructions/closeClaimedLiquidationPoolPosition.d.ts +1 -1
- package/declarations/instructions/closeLiquidationPoolPosition.d.ts +1 -1
- package/declarations/instructions/createReferralAccount.d.ts +3 -3
- package/declarations/instructions/createStakingPool.d.ts +1 -1
- package/declarations/instructions/createUserReferralAccount.d.ts +1 -1
- package/declarations/instructions/createVault.d.ts +1 -2
- package/declarations/instructions/depositLiquidationPool.d.ts +1 -2
- package/declarations/instructions/depositStakingPool.d.ts +1 -2
- package/declarations/instructions/depositVault.d.ts +1 -2
- package/declarations/instructions/initHedgeFoundation.d.ts +1 -1
- package/declarations/instructions/initHedgeFoundationTokens.d.ts +1 -1
- package/declarations/instructions/liquidateVault.d.ts +1 -1
- package/declarations/instructions/loanVault.d.ts +1 -2
- package/declarations/instructions/psmEditAccount.d.ts +1 -2
- package/declarations/instructions/psmMintUsh.d.ts +1 -2
- package/declarations/instructions/psmRedeemUsh.d.ts +1 -2
- package/declarations/instructions/redeemVault.d.ts +1 -2
- package/declarations/instructions/referralClaimFees.d.ts +3 -3
- package/declarations/instructions/refreshOraclePrice.d.ts +1 -1
- package/declarations/instructions/repayVault.d.ts +1 -2
- package/declarations/instructions/setHalted.d.ts +1 -1
- package/declarations/instructions/transferVault.d.ts +1 -1
- package/declarations/instructions/updateReferralAccount.d.ts +1 -2
- package/declarations/instructions/updateReferralState.d.ts +1 -2
- package/declarations/instructions/updateVaultType.d.ts +1 -2
- package/declarations/instructions/withdrawStakingPool.d.ts +1 -1
- package/declarations/instructions/withdrawVault.d.ts +1 -2
- package/declarations/state/VaultAccount.d.ts +2 -3
- package/declarations/utils/getLinkedListAccounts.d.ts +1 -2
- package/lib/Constants.js +27 -54
- package/lib/HedgeConstants.js +170 -0
- package/lib/HedgeDecimal.js +1 -2
- package/lib/StakingPools.js +5 -1
- package/lib/Vaults.js +5 -1
- package/lib/idl/vault.js +60 -744
- package/lib/index.js +6 -11
- package/lib/instructions/claimLiquidationPoolPosition.js +7 -8
- package/lib/instructions/claimStakingPoolPosition.js +7 -8
- package/lib/instructions/closeClaimedLiquidationPoolPosition.js +2 -3
- package/lib/instructions/closeLiquidationPoolPosition.js +16 -17
- package/lib/instructions/createReferralAccount.js +13 -17
- package/lib/instructions/createStakingPool.js +10 -11
- package/lib/instructions/createUserReferralAccount.js +9 -10
- package/lib/instructions/createVault.js +20 -21
- package/lib/instructions/depositLiquidationPool.js +12 -13
- package/lib/instructions/depositStakingPool.js +8 -9
- package/lib/instructions/depositVault.js +10 -11
- package/lib/instructions/initHedgeFoundation.js +10 -11
- package/lib/instructions/initHedgeFoundationTokens.js +7 -8
- package/lib/instructions/liquidateVault.js +12 -19
- package/lib/instructions/loanVault.js +16 -23
- package/lib/instructions/psmEditAccount.js +11 -11
- package/lib/instructions/psmMintUsh.js +18 -19
- package/lib/instructions/psmRedeemUsh.js +18 -19
- package/lib/instructions/redeemVault.js +10 -11
- package/lib/instructions/referralClaimFees.js +12 -16
- package/lib/instructions/refreshOraclePrice.js +9 -9
- package/lib/instructions/repayVault.js +12 -13
- package/lib/instructions/setHalted.js +4 -5
- package/lib/instructions/transferVault.js +2 -3
- package/lib/instructions/updateReferralAccount.js +6 -7
- package/lib/instructions/updateReferralState.js +6 -7
- package/lib/instructions/updateVaultType.js +5 -6
- package/lib/instructions/withdrawStakingPool.js +14 -15
- package/lib/instructions/withdrawVault.js +8 -9
- package/lib/state/VaultAccount.js +22 -8
- package/lib/state/VaultHistoryEvent.js +2 -2
- package/lib/utils/Errors.js +2 -3
- package/lib/utils/getLinkedListAccounts.js +2 -3
- package/lib/utils/sendAndConfirmWithDebug.js +1 -1
- package/package.json +9 -8
- package/src/{Constants.ts → HedgeConstants.ts} +13 -43
- package/src/idl/vault.ts +2382 -3750
- package/src/index.ts +3 -10
- package/src/instructions/claimLiquidationPoolPosition.ts +2 -2
- package/src/instructions/claimStakingPoolPosition.ts +2 -2
- package/src/instructions/closeClaimedLiquidationPoolPosition.ts +1 -1
- package/src/instructions/closeLiquidationPoolPosition.ts +2 -2
- package/src/instructions/createReferralAccount.ts +11 -15
- package/src/instructions/createStakingPool.ts +11 -4
- package/src/instructions/createUserReferralAccount.ts +2 -2
- package/src/instructions/createVault.ts +2 -2
- package/src/instructions/depositLiquidationPool.ts +2 -2
- package/src/instructions/depositStakingPool.ts +2 -2
- package/src/instructions/depositVault.ts +2 -2
- package/src/instructions/initHedgeFoundation.ts +2 -2
- package/src/instructions/initHedgeFoundationTokens.ts +2 -2
- package/src/instructions/liquidateVault.ts +29 -39
- package/src/instructions/loanVault.ts +23 -36
- package/src/instructions/psmEditAccount.ts +3 -3
- package/src/instructions/psmMintUsh.ts +3 -3
- package/src/instructions/psmRedeemUsh.ts +3 -3
- package/src/instructions/redeemVault.ts +2 -2
- package/src/instructions/referralClaimFees.ts +12 -18
- package/src/instructions/refreshOraclePrice.ts +4 -4
- package/src/instructions/repayVault.ts +2 -2
- package/src/instructions/setHalted.ts +2 -2
- package/src/instructions/transferVault.ts +1 -1
- package/src/instructions/updateReferralAccount.ts +2 -2
- package/src/instructions/updateReferralState.ts +2 -2
- package/src/instructions/updateVaultType.ts +2 -2
- package/src/instructions/withdrawStakingPool.ts +2 -2
- package/src/instructions/withdrawVault.ts +2 -2
- package/src/utils/Errors.ts +1 -1
- package/src/utils/getLinkedListAccounts.ts +1 -1
- package/declarations/instructions/adminWithdrawCol.d.ts +0 -5
- package/declarations/instructions/adminWithdrawUsh.d.ts +0 -5
- package/declarations/instructions/createCompoundStakingPool.d.ts +0 -5
- package/declarations/instructions/createCompoundStakingPoolPosition.d.ts +0 -6
- package/declarations/instructions/depositCompoundStakingPoolPosition.d.ts +0 -6
- package/declarations/instructions/depositRewardsToCompoundPool.d.ts +0 -6
- package/declarations/instructions/setCompoundPoolActive.d.ts +0 -5
- package/declarations/instructions/setDelegateWallet.d.ts +0 -5
- package/declarations/instructions/setVaultTypeStatus.d.ts +0 -4
- package/declarations/instructions/withdrawCompoundStakingPoolPosition.d.ts +0 -6
- package/declarations/utils/Sender.d.ts +0 -2
- package/lib/instructions/adminWithdrawCol.js +0 -60
- package/lib/instructions/adminWithdrawUsh.js +0 -57
- package/lib/instructions/createCompoundStakingPool.js +0 -58
- package/lib/instructions/createCompoundStakingPoolPosition.js +0 -56
- package/lib/instructions/depositCompoundStakingPoolPosition.js +0 -55
- package/lib/instructions/depositRewardsToCompoundPool.js +0 -64
- package/lib/instructions/setCompoundPoolActive.js +0 -43
- package/lib/instructions/setDelegateWallet.js +0 -43
- package/lib/instructions/setVaultTypeStatus.js +0 -38
- package/lib/instructions/withdrawCompoundStakingPoolPosition.js +0 -64
- package/lib/utils/Sender.js +0 -32
- package/src/instructions/adminWithdrawCol.ts +0 -87
- package/src/instructions/adminWithdrawUsh.ts +0 -78
- package/src/instructions/createCompoundStakingPool.ts +0 -63
- package/src/instructions/createCompoundStakingPoolPosition.ts +0 -85
- package/src/instructions/depositCompoundStakingPoolPosition.ts +0 -78
- package/src/instructions/depositRewardsToCompoundPool.ts +0 -110
- package/src/instructions/setCompoundPoolActive.ts +0 -51
- package/src/instructions/setDelegateWallet.ts +0 -51
- package/src/instructions/withdrawCompoundStakingPoolPosition.ts +0 -100
package/src/index.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
export * from './
|
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 '@
|
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 '../
|
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 '@
|
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 '../
|
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 '@
|
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 '@
|
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 '../
|
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 '@
|
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
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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 '@
|
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 {
|
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 '../
|
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 '@
|
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 '../
|
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 '@
|
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 '../
|
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 '@
|
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 '../
|
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 '@
|
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 '../
|
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 '@
|
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 '../
|
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 '@
|
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 '../
|
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 '@
|
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 '../
|
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 '@
|
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
|
-
|
19
|
-
|
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
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
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 '@
|
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
|
-
|
17
|
-
|
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
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
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 '@
|
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 '../
|
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.
|
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 '@
|
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 '../
|
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.
|
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 '@
|
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 '../
|
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.
|
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 '@
|
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 '../
|
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 '@
|
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
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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,
|