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/declarations/index.d.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';
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Program, Provider } from '@
|
1
|
+
import { Program, Provider } from '@coral-xyz/anchor';
|
2
2
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
3
|
import { Vault } from '../idl/vault';
|
4
4
|
export declare function claimLiquidationPoolPosition(program: Program<Vault>, provider: Provider, poolPosition: PublicKey, payer: Signer, collateralType: string, overrideStartTime?: number): Promise<PublicKey>;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Program, Provider } from '@
|
1
|
+
import { Program, Provider } from '@coral-xyz/anchor';
|
2
2
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
3
|
import { Vault } from '../idl/vault';
|
4
4
|
export declare function claimStakingPoolPosition(program: Program<Vault>, provider: Provider, poolPosition: PublicKey, payer: Signer, collateralType: string): Promise<PublicKey>;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Program, Provider } from '@
|
1
|
+
import { Program, Provider } from '@coral-xyz/anchor';
|
2
2
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
3
|
import { Vault } from '../idl/vault';
|
4
4
|
export declare function closeClaimedLiquidationPoolPosition(program: Program<Vault>, provider: Provider, poolPosition: PublicKey, payer: Signer): Promise<PublicKey>;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Program, Provider } from '@
|
1
|
+
import { Program, Provider } from '@coral-xyz/anchor';
|
2
2
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
3
|
import { Vault } from '../idl/vault';
|
4
4
|
export declare function closeLiquidationPoolPosition(program: Program<Vault>, provider: Provider, poolPosition: PublicKey, payer: Signer, overrideStartTime?: number, referrer?: PublicKey): Promise<PublicKey>;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Program, Provider } from '@
|
1
|
+
import { Program, Provider } from '@coral-xyz/anchor';
|
2
2
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
3
|
import { Vault } from '../idl/vault';
|
4
4
|
/** @type {Function} - Creates a new referral account.
|
@@ -13,5 +13,5 @@ import { Vault } from '../idl/vault';
|
|
13
13
|
* - referrer: PublicKey
|
14
14
|
* - overrideTime?: number
|
15
15
|
*/
|
16
|
-
export declare function createReferralAccount(program: Program<Vault>, provider: Provider, payer: Signer, poolPosition: PublicKey,
|
17
|
-
export declare function createReferralAccountInstruction(program: Program<Vault>, payerPublicKey: PublicKey, poolPositionPublicKey: PublicKey,
|
16
|
+
export declare function createReferralAccount(program: Program<Vault>, provider: Provider, payer: Signer, poolPosition: PublicKey, overrideTime?: number): Promise<PublicKey>;
|
17
|
+
export declare function createReferralAccountInstruction(program: Program<Vault>, payerPublicKey: PublicKey, poolPositionPublicKey: PublicKey, referralAccountPublicKey: PublicKey, referralStatePublicKey: PublicKey, hedgeMintPublicKey: PublicKey, hdgAssociatedTokenAccountPublicKey: PublicKey, userReferralAccountPublicKey: PublicKey, overrideTime?: number): Promise<TransactionInstruction>;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Program, Provider } from '@
|
1
|
+
import { Program, Provider } from '@coral-xyz/anchor';
|
2
2
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
3
|
import { Vault } from '../idl/vault';
|
4
4
|
export declare function createStakingPool(program: Program<Vault>, provider: Provider, payer: Signer, mintPublicKey: PublicKey, hedgeTokensToBeMinted: number, overrideStartTime?: number): Promise<PublicKey>;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Program, Provider } from '@
|
1
|
+
import { Program, Provider } from '@coral-xyz/anchor';
|
2
2
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
3
|
import { Vault } from '../idl/vault';
|
4
4
|
export declare function createUserReferralAccount(program: Program<Vault>, provider: Provider, payer: Signer, referrer?: PublicKey, overrideTime?: number): Promise<PublicKey>;
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
import { BN, Program, Provider } from '@project-serum/anchor';
|
1
|
+
import { BN, Program, Provider } from '@coral-xyz/anchor';
|
3
2
|
import { PublicKey, Signer, Transaction, TransactionInstruction } from '@solana/web3.js';
|
4
3
|
import { Vault } from '../idl/vault';
|
5
4
|
export declare function createVault(program: Program<Vault>, provider: Provider, payer: Signer, collateralType: string, depositAmount: number, overrideTime?: number): Promise<PublicKey>;
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
import { BN, Program, Provider } from '@project-serum/anchor';
|
1
|
+
import { BN, Program, Provider } from '@coral-xyz/anchor';
|
3
2
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
4
3
|
import { Vault } from '../idl/vault';
|
5
4
|
export declare function depositLiquidationPool(program: Program<Vault>, provider: Provider, payer: Signer, depositAmount: number, overrideStartTime?: number, referrer?: PublicKey): Promise<PublicKey>;
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
import { BN, Program, Provider } from '@project-serum/anchor';
|
1
|
+
import { BN, Program, Provider } from '@coral-xyz/anchor';
|
3
2
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
4
3
|
import { Vault } from '../idl/vault';
|
5
4
|
export declare function depositStakingPool(program: Program<Vault>, provider: Provider, payer: Signer, mintPublicKey: PublicKey, depositAmount: number, overrideStartTime?: number): Promise<PublicKey>;
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
import { BN, Program, Provider } from '@project-serum/anchor';
|
1
|
+
import { BN, Program, Provider } from '@coral-xyz/anchor';
|
3
2
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
4
3
|
import { Vault } from '../idl/vault';
|
5
4
|
export declare function depositVault(program: Program<Vault>, provider: Provider, payer: Signer, vaultPublicKey: PublicKey, depositAmount: number, overrideTime?: number): Promise<PublicKey>;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Program, Provider } from '@
|
1
|
+
import { Program, Provider } from '@coral-xyz/anchor';
|
2
2
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
3
|
import { Vault } from '../idl/vault';
|
4
4
|
export declare function initHedgeFoundation(program: Program<Vault>, provider: Provider, payer: Signer): Promise<PublicKey>;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Program, Provider } from '@
|
1
|
+
import { Program, Provider } from '@coral-xyz/anchor';
|
2
2
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
3
|
export declare function initHedgeFoundationTokens(program: Program, provider: Provider, payer: Signer): Promise<PublicKey>;
|
4
4
|
export declare function initHedgeFoundationTokensInstruction(program: Program, payerPublicKey: PublicKey): Promise<TransactionInstruction>;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Program, Provider } from '@
|
1
|
+
import { Program, Provider } from '@coral-xyz/anchor';
|
2
2
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
3
|
import { Vault } from '../idl/vault';
|
4
4
|
export declare function liquidateVault(program: Program<Vault>, provider: Provider, payer: Signer, vaultPublicKey: PublicKey, overrideTime?: number): Promise<PublicKey>;
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
import { BN, Program, Provider } from '@project-serum/anchor';
|
1
|
+
import { BN, Program, Provider } from '@coral-xyz/anchor';
|
3
2
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
4
3
|
import { Vault } from '../idl/vault';
|
5
4
|
export declare function loanVault(program: Program<Vault>, provider: Provider, payer: Signer, vaultPublicKey: PublicKey, loanAmount: number, overrideTime?: number, referrer?: PublicKey): Promise<PublicKey>;
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
import { BN, Program, Provider } from '@project-serum/anchor';
|
1
|
+
import { BN, Program, Provider } from '@coral-xyz/anchor';
|
3
2
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
4
3
|
import { Vault } from '../idl/vault';
|
5
4
|
export declare enum psmStatus {
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
import { BN, Program, Provider } from '@project-serum/anchor';
|
1
|
+
import { BN, Program, Provider } from '@coral-xyz/anchor';
|
3
2
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
4
3
|
import { Vault } from '../idl/vault';
|
5
4
|
export declare function psmMintUsh(program: Program<Vault>, provider: Provider, payer: Signer, collateralMint: PublicKey, collateralAmount: number, overrideTime?: number, referrer?: PublicKey): Promise<PublicKey>;
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
import { BN, Program, Provider } from '@project-serum/anchor';
|
1
|
+
import { BN, Program, Provider } from '@coral-xyz/anchor';
|
3
2
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
4
3
|
import { Vault } from '../idl/vault';
|
5
4
|
export declare function psmRedeemUsh(program: Program<Vault>, provider: Provider, payer: Signer, collateralMint: PublicKey, ushAmount: number, overrideTime?: number, referrer?: PublicKey): Promise<PublicKey>;
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
import { BN, Program, Provider } from '@project-serum/anchor';
|
1
|
+
import { BN, Program, Provider } from '@coral-xyz/anchor';
|
3
2
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
4
3
|
import { Vault } from '../idl/vault';
|
5
4
|
export declare function redeemVault(program: Program<Vault>, provider: Provider, payer: Signer, vaultPublicKey: PublicKey, redeemAmount: number, transactionOverrideTime?: number): Promise<PublicKey>;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Program, Provider } from '@
|
1
|
+
import { Program, Provider } from '@coral-xyz/anchor';
|
2
2
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
3
|
import { Vault } from '../idl/vault';
|
4
4
|
/** @type {Function} - Allows a referrer to claims their fees.
|
@@ -12,5 +12,5 @@ import { Vault } from '../idl/vault';
|
|
12
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
13
|
* - referrer: PublicKey
|
14
14
|
*/
|
15
|
-
export declare function referralClaimFees(program: Program<Vault>, provider: Provider, payer: Signer, poolPosition: PublicKey
|
16
|
-
export declare function referralClaimFeesInstruction(program: Program<Vault>, payerPublicKey: PublicKey, vaultSystemStatePublicKey: PublicKey, poolPositionPublicKey: PublicKey,
|
15
|
+
export declare function referralClaimFees(program: Program<Vault>, provider: Provider, payer: Signer, poolPosition: PublicKey): Promise<PublicKey>;
|
16
|
+
export declare function referralClaimFeesInstruction(program: Program<Vault>, payerPublicKey: PublicKey, vaultSystemStatePublicKey: PublicKey, poolPositionPublicKey: PublicKey, referralAccountPublicKey: PublicKey, referralStatePublicKey: PublicKey, hedgeMintPublicKey: PublicKey, hdgAssociatedTokenAccountPublicKey: PublicKey, ushMintPublicKey: PublicKey, ushAssociatedTokenAccountPublicKey: PublicKey, communityAssociatedHedgeTokenAccountPublicKey: PublicKey, feePoolPublicKey: PublicKey, feePoolAssociatedUshTokenAccountPublicKey: PublicKey): Promise<TransactionInstruction>;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Program, Provider } from '@
|
1
|
+
import { Program, Provider } from '@coral-xyz/anchor';
|
2
2
|
import { Signer, TransactionInstruction, TransactionSignature } from '@solana/web3.js';
|
3
3
|
import { Vault } from '../idl/vault';
|
4
4
|
export declare function refreshOraclePrice(program: Program<Vault>, provider: Provider, payer: Signer, collateralType: string, network: Cluster, overridePrice?: number, overrideTime?: number): Promise<TransactionSignature | void>;
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
import { BN, Program, Provider } from '@project-serum/anchor';
|
1
|
+
import { BN, Program, Provider } from '@coral-xyz/anchor';
|
3
2
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
4
3
|
import { Vault } from '../idl/vault';
|
5
4
|
export declare function repayVault(program: Program<Vault>, provider: Provider, payer: Signer, vaultPublicKey: PublicKey, repayAmount: number, overrideTime?: number): Promise<PublicKey>;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Program, Provider } from '@
|
1
|
+
import { Program, Provider } from '@coral-xyz/anchor';
|
2
2
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
3
|
import { Vault } from '../idl/vault';
|
4
4
|
export declare function setHalted(program: Program<Vault>, provider: Provider, payer: Signer, halted: boolean): Promise<PublicKey>;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Program, Provider } from '@
|
1
|
+
import { Program, Provider } from '@coral-xyz/anchor';
|
2
2
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
3
|
import { Vault } from '../idl/vault';
|
4
4
|
export declare function transferVault(program: Program<Vault>, provider: Provider, payer: Signer, vaultPublicKey: PublicKey, vaultSystemStatePublicKey: PublicKey, vaultTypeAccount: PublicKey, newOwner: PublicKey): Promise<PublicKey>;
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
import { BN, Program, Provider } from '@project-serum/anchor';
|
1
|
+
import { BN, Program, Provider } from '@coral-xyz/anchor';
|
3
2
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
4
3
|
import { Vault } from '../idl/vault';
|
5
4
|
export interface ReferralAccountConfig {
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
import { BN, Program, Provider } from '@project-serum/anchor';
|
1
|
+
import { BN, Program, Provider } from '@coral-xyz/anchor';
|
3
2
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
4
3
|
import { Vault } from '../idl/vault';
|
5
4
|
export interface ReferralStateConfig {
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
import { BN, Program, Provider } from '@project-serum/anchor';
|
1
|
+
import { BN, Program, Provider } from '@coral-xyz/anchor';
|
3
2
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
4
3
|
import { Vault } from '../idl/vault';
|
5
4
|
export interface VaultTypeConfig {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Program, Provider } from '@
|
1
|
+
import { Program, Provider } from '@coral-xyz/anchor';
|
2
2
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
3
|
import { Vault } from '../idl/vault';
|
4
4
|
export declare function withdrawStakingPool(program: Program<Vault>, provider: Provider, payer: Signer, poolPositionPublicKey: PublicKey, stakedTokenMintPublicKey: PublicKey, overrideStartTime?: number): Promise<PublicKey>;
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
import { BN, Program, Provider } from '@project-serum/anchor';
|
1
|
+
import { BN, Program, Provider } from '@coral-xyz/anchor';
|
3
2
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
4
3
|
import { Vault } from '../idl/vault';
|
5
4
|
export declare function withdrawVault(program: Program<Vault>, provider: Provider, payer: Signer, vaultPublicKey: PublicKey, withdrawAmount: number, overrideTime?: number): Promise<PublicKey>;
|
@@ -1,9 +1,8 @@
|
|
1
|
-
/// <reference types="node" />
|
2
1
|
import { PublicKey } from '@solana/web3.js';
|
3
2
|
import Decimal from 'decimal.js';
|
4
3
|
import BN from 'bn.js';
|
5
4
|
import VaultType from './VaultType';
|
6
|
-
export
|
5
|
+
export type VaultAccountData = {
|
7
6
|
vaultOwner: PublicKey;
|
8
7
|
pdaSalt: string;
|
9
8
|
deposited: BN;
|
@@ -116,5 +115,5 @@ export declare class VaultAccount {
|
|
116
115
|
*
|
117
116
|
* @returns Buffer of the encoded string
|
118
117
|
*/
|
119
|
-
static getBufferForString(string: string): Buffer
|
118
|
+
static getBufferForString(string: string): Buffer<ArrayBuffer>;
|
120
119
|
}
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
import { BN, Program } from '@project-serum/anchor';
|
1
|
+
import { BN, Program } from '@coral-xyz/anchor';
|
3
2
|
import { PublicKey } from '@solana/web3.js';
|
4
3
|
import { Vault } from '../idl/vault';
|
5
4
|
import { VaultAccount } from '../state/VaultAccount';
|
package/lib/Constants.js
CHANGED
@@ -9,7 +9,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
9
9
|
});
|
10
10
|
};
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
-
exports.
|
12
|
+
exports.CHAINLINK_PROGRAM_ID = exports.CHAINLINK_SOL_USD_PUBLICKEY = exports.CHAINLINK_SOL_USD_ID = void 0;
|
13
|
+
exports.getLiquidationPoolStatePublicKey = getLiquidationPoolStatePublicKey;
|
14
|
+
exports.getLiquidationPoolUshAccountPublicKey = getLiquidationPoolUshAccountPublicKey;
|
15
|
+
exports.getUshMintPublicKey = getUshMintPublicKey;
|
16
|
+
exports.getVaultSystemStatePublicKey = getVaultSystemStatePublicKey;
|
17
|
+
exports.getReferralStatePublicKey = getReferralStatePublicKey;
|
18
|
+
exports.getReferralAccountPublicKey = getReferralAccountPublicKey;
|
19
|
+
exports.getUserReferralAccountPublicKey = getUserReferralAccountPublicKey;
|
20
|
+
exports.getHedgeMintPublicKey = getHedgeMintPublicKey;
|
21
|
+
exports.getPoolPublicKeyForMint = getPoolPublicKeyForMint;
|
22
|
+
exports.getVaultTypeAccountPublicKey = getVaultTypeAccountPublicKey;
|
23
|
+
exports.getVaultTypeOracleAccountPublicKey = getVaultTypeOracleAccountPublicKey;
|
24
|
+
exports.findVaultAddress = findVaultAddress;
|
25
|
+
exports.findAssociatedTokenAddress = findAssociatedTokenAddress;
|
13
26
|
const spl_token_1 = require("@solana/spl-token");
|
14
27
|
const web3_js_1 = require("@solana/web3.js");
|
15
28
|
exports.CHAINLINK_SOL_USD_ID = 'FmAmfoyPXiA8Vhhe6MZTr3U6rZfEZ1ctEHay1ysqCqcf';
|
@@ -21,55 +34,50 @@ const enc = new TextEncoder();
|
|
21
34
|
*/
|
22
35
|
function getLiquidationPoolStatePublicKey(hedgeProgramId) {
|
23
36
|
return __awaiter(this, void 0, void 0, function* () {
|
24
|
-
const [poolPublicKey] = yield web3_js_1.PublicKey.
|
37
|
+
const [poolPublicKey] = yield web3_js_1.PublicKey.findProgramAddressSync([enc.encode('LiquidationPoolStateV1')], hedgeProgramId);
|
25
38
|
return poolPublicKey;
|
26
39
|
});
|
27
40
|
}
|
28
|
-
exports.getLiquidationPoolStatePublicKey = getLiquidationPoolStatePublicKey;
|
29
41
|
/**
|
30
42
|
*
|
31
43
|
* @returns The liquidation pool ush account public key
|
32
44
|
*/
|
33
45
|
function getLiquidationPoolUshAccountPublicKey(hedgeProgramId) {
|
34
46
|
return __awaiter(this, void 0, void 0, function* () {
|
35
|
-
const [poolPublicKey] = yield web3_js_1.PublicKey.
|
47
|
+
const [poolPublicKey] = yield web3_js_1.PublicKey.findProgramAddressSync([enc.encode('LiquidationPoolUSHAccountV1')], hedgeProgramId);
|
36
48
|
return poolPublicKey;
|
37
49
|
});
|
38
50
|
}
|
39
|
-
exports.getLiquidationPoolUshAccountPublicKey = getLiquidationPoolUshAccountPublicKey;
|
40
51
|
/**
|
41
52
|
*
|
42
53
|
* @returns The USH mint public key
|
43
54
|
*/
|
44
55
|
function getUshMintPublicKey(hedgeProgramId) {
|
45
56
|
return __awaiter(this, void 0, void 0, function* () {
|
46
|
-
const [findMintPublicKey] = yield web3_js_1.PublicKey.
|
57
|
+
const [findMintPublicKey] = yield web3_js_1.PublicKey.findProgramAddressSync([enc.encode('UshMintV1')], hedgeProgramId);
|
47
58
|
return findMintPublicKey;
|
48
59
|
});
|
49
60
|
}
|
50
|
-
exports.getUshMintPublicKey = getUshMintPublicKey;
|
51
61
|
/**
|
52
62
|
*
|
53
63
|
* @returns The Vault System State public key
|
54
64
|
*/
|
55
65
|
function getVaultSystemStatePublicKey(hedgeProgramId) {
|
56
66
|
return __awaiter(this, void 0, void 0, function* () {
|
57
|
-
const [publicKey] = yield web3_js_1.PublicKey.
|
67
|
+
const [publicKey] = yield web3_js_1.PublicKey.findProgramAddressSync([enc.encode('VaultSystemStateV1')], hedgeProgramId);
|
58
68
|
return publicKey;
|
59
69
|
});
|
60
70
|
}
|
61
|
-
exports.getVaultSystemStatePublicKey = getVaultSystemStatePublicKey;
|
62
71
|
/**
|
63
72
|
*
|
64
73
|
* @returns The Referral State public key
|
65
74
|
*/
|
66
75
|
function getReferralStatePublicKey(hedgeProgramId) {
|
67
76
|
return __awaiter(this, void 0, void 0, function* () {
|
68
|
-
const [publicKey] = yield web3_js_1.PublicKey.
|
77
|
+
const [publicKey] = yield web3_js_1.PublicKey.findProgramAddressSync([enc.encode('ReferralStateV1')], hedgeProgramId);
|
69
78
|
return publicKey;
|
70
79
|
});
|
71
80
|
}
|
72
|
-
exports.getReferralStatePublicKey = getReferralStatePublicKey;
|
73
81
|
/**
|
74
82
|
*
|
75
83
|
* @returns The Referral State public key based off the owner's public key
|
@@ -77,11 +85,10 @@ exports.getReferralStatePublicKey = getReferralStatePublicKey;
|
|
77
85
|
function getReferralAccountPublicKey(hedgeProgramId, ownerPublicKey) {
|
78
86
|
return __awaiter(this, void 0, void 0, function* () {
|
79
87
|
const strToEncode = ownerPublicKey.toBuffer(); //.substring(0, 28)
|
80
|
-
const [publicKey] = yield web3_js_1.PublicKey.
|
88
|
+
const [publicKey] = yield web3_js_1.PublicKey.findProgramAddressSync([enc.encode('refer_acct'), strToEncode], hedgeProgramId);
|
81
89
|
return publicKey;
|
82
90
|
});
|
83
91
|
}
|
84
|
-
exports.getReferralAccountPublicKey = getReferralAccountPublicKey;
|
85
92
|
/**
|
86
93
|
*
|
87
94
|
* @returns The user referral account public key based off the user's public key
|
@@ -89,35 +96,20 @@ exports.getReferralAccountPublicKey = getReferralAccountPublicKey;
|
|
89
96
|
function getUserReferralAccountPublicKey(hedgeProgramId, ownerPublicKey) {
|
90
97
|
return __awaiter(this, void 0, void 0, function* () {
|
91
98
|
const strToEncode = ownerPublicKey.toBuffer(); //.substring(0, 28)
|
92
|
-
const [publicKey] = yield web3_js_1.PublicKey.
|
99
|
+
const [publicKey] = yield web3_js_1.PublicKey.findProgramAddressSync([enc.encode('user_ref'), strToEncode], hedgeProgramId);
|
93
100
|
return publicKey;
|
94
101
|
});
|
95
102
|
}
|
96
|
-
exports.getUserReferralAccountPublicKey = getUserReferralAccountPublicKey;
|
97
|
-
/**
|
98
|
-
*
|
99
|
-
* @returns The compound pool position address for the given user
|
100
|
-
*/
|
101
|
-
function getCompoundPoolPositionAddress(hedgeProgramId, poolPublicKey, ownerPublicKey) {
|
102
|
-
return __awaiter(this, void 0, void 0, function* () {
|
103
|
-
const strToEncode = poolPublicKey.toBuffer();
|
104
|
-
const strToEncode2 = ownerPublicKey.toBuffer();
|
105
|
-
const [compoundPoolPosition] = yield web3_js_1.PublicKey.findProgramAddress([strToEncode, strToEncode2], hedgeProgramId);
|
106
|
-
return compoundPoolPosition;
|
107
|
-
});
|
108
|
-
}
|
109
|
-
exports.getCompoundPoolPositionAddress = getCompoundPoolPositionAddress;
|
110
103
|
/**
|
111
104
|
*
|
112
105
|
* @returns The HDG mint public key
|
113
106
|
*/
|
114
107
|
function getHedgeMintPublicKey(hedgeProgramId) {
|
115
108
|
return __awaiter(this, void 0, void 0, function* () {
|
116
|
-
const [publicKey] = yield web3_js_1.PublicKey.
|
109
|
+
const [publicKey] = yield web3_js_1.PublicKey.findProgramAddressSync([enc.encode('HEDGEMintV1')], hedgeProgramId);
|
117
110
|
return publicKey;
|
118
111
|
});
|
119
112
|
}
|
120
|
-
exports.getHedgeMintPublicKey = getHedgeMintPublicKey;
|
121
113
|
/**
|
122
114
|
* Get the public key for any staking pool
|
123
115
|
*
|
@@ -127,25 +119,10 @@ exports.getHedgeMintPublicKey = getHedgeMintPublicKey;
|
|
127
119
|
function getPoolPublicKeyForMint(hedgeProgramId, mintPublicKey) {
|
128
120
|
return __awaiter(this, void 0, void 0, function* () {
|
129
121
|
const strToEncode = mintPublicKey.toString().substring(0, 12);
|
130
|
-
const [publicKey, bump] = yield web3_js_1.PublicKey.
|
122
|
+
const [publicKey, bump] = yield web3_js_1.PublicKey.findProgramAddressSync([enc.encode(strToEncode)], hedgeProgramId);
|
131
123
|
return [publicKey, bump, strToEncode];
|
132
124
|
});
|
133
125
|
}
|
134
|
-
exports.getPoolPublicKeyForMint = getPoolPublicKeyForMint;
|
135
|
-
/**
|
136
|
-
* Get the public key for any compound staking pool
|
137
|
-
*
|
138
|
-
* @param mintPublicKey Staked collateral mint public key
|
139
|
-
* @returns the public key for that compound staking pool
|
140
|
-
*/
|
141
|
-
function getCompoundPoolPublicKeyForMint(hedgeProgramId, mintPublicKey) {
|
142
|
-
return __awaiter(this, void 0, void 0, function* () {
|
143
|
-
const strToEncode = mintPublicKey.toBuffer();
|
144
|
-
const [publicKey, bump] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode('CompoundPoolV1'), strToEncode], hedgeProgramId);
|
145
|
-
return [publicKey, bump];
|
146
|
-
});
|
147
|
-
}
|
148
|
-
exports.getCompoundPoolPublicKeyForMint = getCompoundPoolPublicKeyForMint;
|
149
126
|
/**
|
150
127
|
*
|
151
128
|
* @param collateralType String name of the collateral type (must be 16 chars)
|
@@ -153,11 +130,10 @@ exports.getCompoundPoolPublicKeyForMint = getCompoundPoolPublicKeyForMint;
|
|
153
130
|
*/
|
154
131
|
function getVaultTypeAccountPublicKey(hedgeProgramId, collateralType) {
|
155
132
|
return __awaiter(this, void 0, void 0, function* () {
|
156
|
-
const [vaultTypeAccount] = yield web3_js_1.PublicKey.
|
133
|
+
const [vaultTypeAccount] = yield web3_js_1.PublicKey.findProgramAddressSync([enc.encode(collateralType), enc.encode('State')], hedgeProgramId);
|
157
134
|
return vaultTypeAccount;
|
158
135
|
});
|
159
136
|
}
|
160
|
-
exports.getVaultTypeAccountPublicKey = getVaultTypeAccountPublicKey;
|
161
137
|
/**
|
162
138
|
*
|
163
139
|
* @param collateralType String name of the collateral type (must be 16 chars)
|
@@ -165,11 +141,10 @@ exports.getVaultTypeAccountPublicKey = getVaultTypeAccountPublicKey;
|
|
165
141
|
*/
|
166
142
|
function getVaultTypeOracleAccountPublicKey(hedgeProgramId, collateralType) {
|
167
143
|
return __awaiter(this, void 0, void 0, function* () {
|
168
|
-
const [vaultTypeOracleAccount] = yield web3_js_1.PublicKey.
|
144
|
+
const [vaultTypeOracleAccount] = yield web3_js_1.PublicKey.findProgramAddressSync([enc.encode(collateralType), enc.encode('Oracle')], hedgeProgramId);
|
169
145
|
return vaultTypeOracleAccount;
|
170
146
|
});
|
171
147
|
}
|
172
|
-
exports.getVaultTypeOracleAccountPublicKey = getVaultTypeOracleAccountPublicKey;
|
173
148
|
/**
|
174
149
|
* Vaults are stored in PDA accounts. Use this to get the address from a salt
|
175
150
|
*
|
@@ -178,11 +153,10 @@ exports.getVaultTypeOracleAccountPublicKey = getVaultTypeOracleAccountPublicKey;
|
|
178
153
|
*/
|
179
154
|
function findVaultAddress(hedgeProgramId, vaultSalt) {
|
180
155
|
return __awaiter(this, void 0, void 0, function* () {
|
181
|
-
const [vaultAddress] = yield web3_js_1.PublicKey.
|
156
|
+
const [vaultAddress] = yield web3_js_1.PublicKey.findProgramAddressSync([enc.encode('Vault'), enc.encode(vaultSalt)], hedgeProgramId);
|
182
157
|
return vaultAddress;
|
183
158
|
});
|
184
159
|
}
|
185
|
-
exports.findVaultAddress = findVaultAddress;
|
186
160
|
/**
|
187
161
|
*
|
188
162
|
* @param walletAddress Owner public key
|
@@ -191,7 +165,6 @@ exports.findVaultAddress = findVaultAddress;
|
|
191
165
|
*/
|
192
166
|
function findAssociatedTokenAddress(hedgeProgramId, walletAddress, tokenMintAddress) {
|
193
167
|
return __awaiter(this, void 0, void 0, function* () {
|
194
|
-
return (yield web3_js_1.PublicKey.
|
168
|
+
return (yield web3_js_1.PublicKey.findProgramAddressSync([walletAddress.toBuffer(), spl_token_1.TOKEN_PROGRAM_ID.toBuffer(), tokenMintAddress.toBuffer()], spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID))[0];
|
195
169
|
});
|
196
170
|
}
|
197
|
-
exports.findAssociatedTokenAddress = findAssociatedTokenAddress;
|