hedge-web3 0.1.13 → 0.1.16
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/{lib/types/src → declarations}/Constants.d.ts +8 -8
- package/{lib/types/src → declarations}/HedgeDecimal.d.ts +2 -3
- package/{lib/types/src → declarations}/StakingPools.d.ts +0 -1
- package/{lib/types/src → declarations}/Vaults.d.ts +0 -1
- package/{lib/types/src → declarations}/idl/idl.d.ts +0 -1
- package/declarations/idl/vault.d.ts +2283 -0
- package/{lib/types/src → declarations}/index.d.ts +6 -1
- package/declarations/instructions/claimLiquidationPoolPosition.d.ts +4 -0
- package/declarations/instructions/closeLiquidationPoolPosition.d.ts +4 -0
- package/{lib/types/src → declarations}/instructions/createStakingPool.d.ts +0 -1
- package/declarations/instructions/createVault.d.ts +4 -0
- package/declarations/instructions/depositLiquidationPool.d.ts +4 -0
- package/{lib/types/src → declarations}/instructions/depositStakingPool.d.ts +0 -1
- package/declarations/instructions/depositVault.d.ts +4 -0
- package/declarations/instructions/initHedgeFoundation.d.ts +4 -0
- package/declarations/instructions/initHedgeFoundationTokens.d.ts +4 -0
- package/declarations/instructions/liquidateVault.d.ts +4 -0
- package/{lib/types/src → declarations}/instructions/loanVault.d.ts +2 -3
- package/declarations/instructions/redeemVault.d.ts +4 -0
- package/{lib/types/src → declarations}/instructions/refreshOraclePrice.d.ts +2 -3
- package/{lib/types/src → declarations}/instructions/repayVault.d.ts +2 -3
- package/declarations/instructions/setHalted.d.ts +4 -0
- package/{lib/types/src → declarations}/instructions/withdrawStakingPool.d.ts +0 -1
- package/declarations/instructions/withdrawVault.d.ts +4 -0
- package/{lib/types/src → declarations}/state/LiquidationPoolEra.d.ts +1 -2
- package/{lib/types/src → declarations}/state/LiquidationPoolState.d.ts +0 -1
- package/{lib/types/src → declarations}/state/LiquidationPosition.d.ts +8 -10
- package/{lib/types/src → declarations}/state/StakingPool.d.ts +0 -1
- package/{lib/types/src → declarations}/state/StakingPoolPosition.d.ts +0 -1
- package/{lib/types/src → declarations}/state/VaultAccount.d.ts +0 -1
- package/{lib/types/src → declarations}/state/VaultHistoryEvent.d.ts +0 -1
- package/{lib/types/src → declarations}/utils/Errors.d.ts +0 -1
- package/lib/Constants.js +86 -0
- package/lib/HedgeDecimal.js +24 -0
- package/lib/StakingPools.js +15 -0
- package/lib/Vaults.js +20 -0
- package/lib/idl/idl.js +1475 -0
- package/lib/idl/vault.js +2285 -0
- package/lib/index.js +37 -2156
- package/lib/instructions/claimLiquidationPoolPosition.js +53 -0
- package/lib/instructions/closeLiquidationPoolPosition.js +60 -0
- package/lib/instructions/createStakingPool.js +52 -0
- package/lib/instructions/createVault.js +92 -0
- package/lib/instructions/depositLiquidationPool.js +55 -0
- package/lib/instructions/depositStakingPool.js +52 -0
- package/lib/instructions/depositVault.js +87 -0
- package/lib/instructions/initHedgeFoundation.js +55 -0
- package/lib/instructions/initHedgeFoundationTokens.js +48 -0
- package/lib/instructions/liquidateVault.js +80 -0
- package/lib/instructions/loanVault.js +61 -0
- package/lib/instructions/redeemVault.js +65 -0
- package/lib/instructions/refreshOraclePrice.js +65 -0
- package/lib/instructions/repayVault.js +62 -0
- package/lib/instructions/setHalted.js +37 -0
- package/lib/instructions/withdrawStakingPool.js +64 -0
- package/lib/instructions/withdrawVault.js +62 -0
- package/lib/state/LiquidationPoolEra.js +19 -0
- package/lib/state/LiquidationPoolState.js +12 -0
- package/lib/state/LiquidationPosition.js +39 -0
- package/lib/state/StakingPool.js +22 -0
- package/lib/state/StakingPoolPosition.js +28 -0
- package/lib/state/VaultAccount.js +52 -0
- package/lib/state/VaultHistoryEvent.js +45 -0
- package/lib/utils/Errors.js +14 -0
- package/package.json +14 -8
- package/src/Constants.ts +24 -19
- package/src/HedgeDecimal.ts +3 -3
- package/src/idl/idl.ts +13 -13
- package/src/idl/vault.ts +4565 -0
- package/src/index.ts +6 -0
- package/src/instructions/claimLiquidationPoolPosition.ts +76 -0
- package/src/instructions/closeLiquidationPoolPosition.ts +82 -0
- package/src/instructions/createStakingPool.ts +4 -4
- package/src/instructions/createVault.ts +98 -27
- package/src/instructions/depositLiquidationPool.ts +67 -0
- package/src/instructions/depositStakingPool.ts +5 -3
- package/src/instructions/depositVault.ts +95 -27
- package/src/instructions/initHedgeFoundation.ts +64 -0
- package/src/instructions/initHedgeFoundationTokens.ts +55 -0
- package/src/instructions/liquidateVault.ts +87 -35
- package/src/instructions/loanVault.ts +30 -20
- package/src/instructions/redeemVault.ts +37 -24
- package/src/instructions/refreshOraclePrice.ts +6 -3
- package/src/instructions/repayVault.ts +30 -20
- package/src/instructions/setHalted.ts +48 -0
- package/src/instructions/withdrawStakingPool.ts +6 -6
- package/src/instructions/withdrawVault.ts +50 -17
- package/src/state/LiquidationPoolEra.ts +2 -8
- package/src/state/LiquidationPosition.ts +38 -39
- package/tsconfig.json +3 -2
- package/.github/workflows/npm-publish.yml +0 -34
- package/README.md +0 -44
- package/jsconfig.json +0 -12
- package/lib/index.js.map +0 -1
- package/lib/types/src/Constants.d.ts.map +0 -1
- package/lib/types/src/HedgeDecimal.d.ts.map +0 -1
- package/lib/types/src/StakingPools.d.ts.map +0 -1
- package/lib/types/src/Vaults.d.ts.map +0 -1
- package/lib/types/src/idl/idl.d.ts.map +0 -1
- package/lib/types/src/index.d.ts.map +0 -1
- package/lib/types/src/instructions/createStakingPool.d.ts.map +0 -1
- package/lib/types/src/instructions/createVault.d.ts +0 -5
- package/lib/types/src/instructions/createVault.d.ts.map +0 -1
- package/lib/types/src/instructions/depositStakingPool.d.ts.map +0 -1
- package/lib/types/src/instructions/depositVault.d.ts +0 -5
- package/lib/types/src/instructions/depositVault.d.ts.map +0 -1
- package/lib/types/src/instructions/liquidateVault.d.ts +0 -5
- package/lib/types/src/instructions/liquidateVault.d.ts.map +0 -1
- package/lib/types/src/instructions/loanVault.d.ts.map +0 -1
- package/lib/types/src/instructions/redeemVault.d.ts +0 -5
- package/lib/types/src/instructions/redeemVault.d.ts.map +0 -1
- package/lib/types/src/instructions/refreshOraclePrice.d.ts.map +0 -1
- package/lib/types/src/instructions/repayVault.d.ts.map +0 -1
- package/lib/types/src/instructions/withdrawStakingPool.d.ts.map +0 -1
- package/lib/types/src/instructions/withdrawVault.d.ts +0 -5
- package/lib/types/src/instructions/withdrawVault.d.ts.map +0 -1
- package/lib/types/src/state/LiquidationPoolEra.d.ts.map +0 -1
- package/lib/types/src/state/LiquidationPoolState.d.ts.map +0 -1
- package/lib/types/src/state/LiquidationPosition.d.ts.map +0 -1
- package/lib/types/src/state/StakingPool.d.ts.map +0 -1
- package/lib/types/src/state/StakingPoolPosition.d.ts.map +0 -1
- package/lib/types/src/state/VaultAccount.d.ts.map +0 -1
- package/lib/types/src/state/VaultHistoryEvent.d.ts.map +0 -1
- package/lib/types/src/utils/Errors.d.ts.map +0 -1
- package/lib/types/tsconfig.base.tsbuildinfo +0 -1
- package/rollup.config.js +0 -40
@@ -1,6 +1,9 @@
|
|
1
1
|
export * from './instructions/createStakingPool';
|
2
2
|
export * from './instructions/depositStakingPool';
|
3
3
|
export * from './instructions/withdrawStakingPool';
|
4
|
+
export * from './instructions/depositLiquidationPool';
|
5
|
+
export * from './instructions/closeLiquidationPoolPosition';
|
6
|
+
export * from './instructions/claimLiquidationPoolPosition';
|
4
7
|
export * from './instructions/createVault';
|
5
8
|
export * from './instructions/depositVault';
|
6
9
|
export * from './instructions/withdrawVault';
|
@@ -9,6 +12,9 @@ export * from './instructions/repayVault';
|
|
9
12
|
export * from './instructions/redeemVault';
|
10
13
|
export * from './instructions/liquidateVault';
|
11
14
|
export * from './instructions/refreshOraclePrice';
|
15
|
+
export * from './instructions/initHedgeFoundation';
|
16
|
+
export * from './instructions/initHedgeFoundationTokens';
|
17
|
+
export * from './instructions/setHalted';
|
12
18
|
export * from './HedgeDecimal';
|
13
19
|
export * from './Constants';
|
14
20
|
export * from './state/VaultAccount';
|
@@ -18,4 +24,3 @@ export * from './state/StakingPoolPosition';
|
|
18
24
|
export * from './state/LiquidationPoolEra';
|
19
25
|
export * from './state/LiquidationPoolState';
|
20
26
|
export * from './state/LiquidationPosition';
|
21
|
-
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import { Program, Provider } from '@project-serum/anchor';
|
2
|
+
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
|
+
export declare function claimLiquidationPoolPosition(program: Program, provider: Provider, poolPosition: PublicKey, payer: Signer, collateralType: string, overrideStartTime?: number): Promise<PublicKey>;
|
4
|
+
export declare function claimLiquidationPoolPositionInstruction(program: Program, poolState: PublicKey, poolAssociatedTokenAccount: PublicKey, vaultTypeAccount: PublicKey, collateralMint: PublicKey, poolPosition: PublicKey, payer: PublicKey, payerAssociatedTokenAccount: PublicKey, overrideStartTime?: number): Promise<TransactionInstruction>;
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import { Program, Provider } from '@project-serum/anchor';
|
2
|
+
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
|
+
export declare function closeLiquidationPoolPosition(program: Program, provider: Provider, poolPosition: PublicKey, payer: Signer, overrideStartTime?: number): Promise<PublicKey>;
|
4
|
+
export declare function closeLiquidationPoolPositionInstruction(program: Program, vaultSystemState: PublicKey, poolState: PublicKey, poolEra: PublicKey, poolPosition: PublicKey, poolUsdhAccount: PublicKey, payerPublicKey: PublicKey, payerUsdhAccount: PublicKey, hedgeMint: PublicKey, payerAssociatedHedgeAccount: PublicKey, communityAssociatedHedgeTokenAccount: PublicKey, overrideStartTime?: number): Promise<TransactionInstruction>;
|
@@ -2,4 +2,3 @@ import { Program, Provider } from '@project-serum/anchor';
|
|
2
2
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
3
|
export declare function createStakingPool(program: Program, provider: Provider, payer: Signer, mintPublicKey: PublicKey, hedgeTokensToBeMinted: number, overrideStartTime?: number): Promise<PublicKey>;
|
4
4
|
export declare function createStakingPoolInstruction(program: Program, payerPublicKey: PublicKey, mintPublicKey: PublicKey, hedgeTokensToBeMinted: number, overrideStartTime?: number): Promise<TransactionInstruction>;
|
5
|
-
//# sourceMappingURL=createStakingPool.d.ts.map
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import { Program, Provider } from '@project-serum/anchor';
|
2
|
+
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
|
+
export declare function createVault(program: Program, provider: Provider, payer: Signer, collateralType: string, depositAmount: number, overrideTime?: number): Promise<PublicKey>;
|
4
|
+
export declare function createVaultInstruction(program: Program, salt: string, vaultSystemStatePublicKey: PublicKey, payerPublicKey: PublicKey, payerTokenAccountPublicKey: PublicKey, vaultPublicKey: PublicKey, vaultAssociatedTokenAccount: PublicKey, feePool: PublicKey, feePoolAssociatedUsdhTokenAccount: PublicKey, vaultTypeAccount: PublicKey, collateralMint: PublicKey, historyPublicKey: PublicKey, usdhMintPublickey: PublicKey, depositAmount: number, overrideTime?: number): Promise<TransactionInstruction>;
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import { Program, Provider } from '@project-serum/anchor';
|
2
|
+
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
|
+
export declare function depositLiquidationPool(program: Program, provider: Provider, payer: Signer, depositAmount: number, overrideStartTime?: number): Promise<PublicKey>;
|
4
|
+
export declare function depositLiquidationPoolInstruction(program: Program, payerPublicKey: PublicKey, payerUsdhAccount: PublicKey, poolPositionPublicKey: PublicKey, depositAmount: number, overrideStartTime?: number): Promise<TransactionInstruction>;
|
@@ -2,4 +2,3 @@ import { Program, Provider } from '@project-serum/anchor';
|
|
2
2
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
3
|
export declare function depositStakingPool(program: Program, provider: Provider, payer: Signer, mintPublicKey: PublicKey, depositAmount: number, overrideStartTime?: number): Promise<PublicKey>;
|
4
4
|
export declare function depositStakingPoolInstruction(program: Program, payerPublicKey: PublicKey, poolPositionPublicKey: PublicKey, stakedTokenMintPublicKey: PublicKey, depositAmount: number, overrideStartTime?: number): Promise<TransactionInstruction>;
|
5
|
-
//# sourceMappingURL=depositStakingPool.d.ts.map
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import { Program, Provider } from '@project-serum/anchor';
|
2
|
+
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
|
+
export declare function depositVault(program: Program, provider: Provider, payer: Signer, vaultPublicKey: PublicKey, depositAmount: number, overrideTime?: number): Promise<PublicKey>;
|
4
|
+
export declare function depositVaultInstruction(program: Program, vaultSystemStatePublicKey: PublicKey, vaultOwner: PublicKey, vaultOwnerTokenAccount: PublicKey, vaultPublicKey: PublicKey, vaultAssociatedTokenAccount: PublicKey, historyPublicKey: PublicKey, vaultTypeAccountPublicKey: PublicKey, vaultTypeAssociatedTokenAccount: PublicKey, hedgeStakingPoolPublicKey: PublicKey, hedgeStakingPoolAssociatedUsdhTokenAccount: PublicKey, collateralMint: PublicKey, usdhMintPublickey: PublicKey, depositAmount: number, overrideTime?: number): Promise<TransactionInstruction>;
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import { Program, Provider } from '@project-serum/anchor';
|
2
|
+
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
|
+
export declare function initHedgeFoundation(program: Program, provider: Provider, payer: Signer): Promise<PublicKey>;
|
4
|
+
export declare function initHedgeFoundationInstruction(program: Program, poolEraPublicKey: PublicKey, payerPublicKey: PublicKey): Promise<TransactionInstruction>;
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import { Program, Provider } from '@project-serum/anchor';
|
2
|
+
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
|
+
export declare function initHedgeFoundationTokens(program: Program, provider: Provider, payer: Signer): Promise<PublicKey>;
|
4
|
+
export declare function initHedgeFoundationTokensInstruction(program: Program, payerPublicKey: PublicKey): Promise<TransactionInstruction>;
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import { Program, Provider } from '@project-serum/anchor';
|
2
|
+
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
|
+
export declare function liquidateVault(program: Program, provider: Provider, payer: Signer, vaultPublicKey: PublicKey, overrideTime?: number): Promise<PublicKey>;
|
4
|
+
export declare function liquidateVaultInstruction(program: Program, payerPublicKey: PublicKey, payerAssociatedTokenAccount: PublicKey, vaultPublickey: PublicKey, vaultAssociatedTokenAccount: PublicKey, poolState: PublicKey, poolEra: PublicKey, poolAssociatedTokenAccount: PublicKey, historyPublicKey: PublicKey, newEraPublicKey: PublicKey, feePool: PublicKey, feePoolAssociatedTokenAccount: PublicKey, hedgeStakingPoolAssociatedUsdhTokenAccount: PublicKey, collateralMint: PublicKey, vaultTypeAssociatedTokenAccount: PublicKey, collateralType: string, overrideTime?: number): Promise<TransactionInstruction>;
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import { Program, Provider } from '@project-serum/anchor';
|
2
2
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
|
-
export declare function loanVault(program: Program, provider: Provider, payer: Signer, vaultPublicKey: PublicKey, loanAmount: number): Promise<PublicKey>;
|
4
|
-
export declare function loanVaultInstruction(program: Program, payerPublicKey: PublicKey, ownerUsdhAccount: PublicKey, vaultPublickey: PublicKey, historyPublicKey: PublicKey, loanAmount: number): Promise<TransactionInstruction>;
|
5
|
-
//# sourceMappingURL=loanVault.d.ts.map
|
3
|
+
export declare function loanVault(program: Program, provider: Provider, payer: Signer, vaultPublicKey: PublicKey, loanAmount: number, overrideTime?: number): Promise<PublicKey>;
|
4
|
+
export declare function loanVaultInstruction(program: Program, payerPublicKey: PublicKey, ownerUsdhAccount: PublicKey, vaultPublickey: PublicKey, vaultAssociatedTokenAccount: PublicKey, historyPublicKey: PublicKey, vaultTypeAccount: PublicKey, vaultTypeAssociatedTokenAccount: PublicKey, loanAmount: number, overrideTime?: number): Promise<TransactionInstruction>;
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import { Program, Provider } from '@project-serum/anchor';
|
2
|
+
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
|
+
export declare function redeemVault(program: Program, provider: Provider, payer: Signer, vaultPublicKey: PublicKey, redeemAmount: number, transactionOverrideTime?: number): Promise<PublicKey>;
|
4
|
+
export declare function redeemVaultInstruction(program: Program, payerPublicKey: PublicKey, payerUsdhAccount: PublicKey, destinationTokenAccount: PublicKey, vaultPublickey: PublicKey, vaultAssociatedTokenAccount: PublicKey, historyPublicKey: PublicKey, vaultTypeAccount: PublicKey, vaultTypeAssociatedTokenAccount: PublicKey, redeemAmount: number, transactionOverrideTime?: number): Promise<TransactionInstruction>;
|
@@ -1,11 +1,10 @@
|
|
1
1
|
import { Program, Provider } from '@project-serum/anchor';
|
2
2
|
import { Signer, TransactionInstruction } from '@solana/web3.js';
|
3
|
-
export declare function refreshOraclePrice(program: Program, provider: Provider, payer: Signer, network: Cluster, overridePrice?: number, overrideTime?: number): Promise<string>;
|
4
|
-
export declare function refreshOraclePriceInstruction(program: Program, network: Cluster, overridePrice?: number, overrideTime?: number): Promise<TransactionInstruction>;
|
3
|
+
export declare function refreshOraclePrice(program: Program, provider: Provider, payer: Signer, collateralType: string, network: Cluster, overridePrice?: number, overrideTime?: number): Promise<string>;
|
4
|
+
export declare function refreshOraclePriceInstruction(program: Program, collateralType: string, network: Cluster, overridePrice?: number, overrideTime?: number): Promise<TransactionInstruction>;
|
5
5
|
declare enum Cluster {
|
6
6
|
Testing = "Testing",
|
7
7
|
Devnet = "Devnet",
|
8
8
|
MainnetBeta = "MainnetBeta"
|
9
9
|
}
|
10
10
|
export {};
|
11
|
-
//# sourceMappingURL=refreshOraclePrice.d.ts.map
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import { Program, Provider } from '@project-serum/anchor';
|
2
2
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
|
-
export declare function repayVault(program: Program, provider: Provider, payer: Signer, vaultPublicKey: PublicKey, repayAmount: number): Promise<PublicKey>;
|
4
|
-
export declare function repayVaultInstruction(program: Program, payerPublicKey: PublicKey, ownerUsdhAccount: PublicKey, vaultPublickey: PublicKey, historyPublicKey: PublicKey, repayAmount: number): Promise<TransactionInstruction>;
|
5
|
-
//# sourceMappingURL=repayVault.d.ts.map
|
3
|
+
export declare function repayVault(program: Program, provider: Provider, payer: Signer, vaultPublicKey: PublicKey, repayAmount: number, overrideTime?: number): Promise<PublicKey>;
|
4
|
+
export declare function repayVaultInstruction(program: Program, payerPublicKey: PublicKey, ownerUsdhAccount: PublicKey, vaultPublickey: PublicKey, vaultAssociatedTokenAccount: PublicKey, historyPublicKey: PublicKey, vaultTypeAccount: PublicKey, vaultTypeAssociatedTokenAccount: PublicKey, repayAmount: number, overrideTime?: number): Promise<TransactionInstruction>;
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import { Program, Provider } from '@project-serum/anchor';
|
2
|
+
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
|
+
export declare function setHalted(program: Program, provider: Provider, payer: Signer, halted: boolean): Promise<PublicKey>;
|
4
|
+
export declare function setHaltedInstruction(program: Program, vaultSystemStatePublicKey: PublicKey, payerPublicKey: PublicKey, halted: boolean): Promise<TransactionInstruction>;
|
@@ -2,4 +2,3 @@ import { Program, Provider } from '@project-serum/anchor';
|
|
2
2
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
3
|
export declare function withdrawStakingPool(program: Program, provider: Provider, payer: Signer, poolPositionPublicKey: PublicKey, stakedTokenMintPublicKey: PublicKey, overrideStartTime?: number): Promise<PublicKey>;
|
4
4
|
export declare function withdrawStakingPoolInstruction(program: Program, payerPublicKey: PublicKey, poolPositionPublicKey: PublicKey, stakedTokenMintPublicKey: PublicKey, overrideStartTime?: number): Promise<TransactionInstruction>;
|
5
|
-
//# sourceMappingURL=withdrawStakingPool.d.ts.map
|
@@ -0,0 +1,4 @@
|
|
1
|
+
import { Program, Provider } from '@project-serum/anchor';
|
2
|
+
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
|
+
export declare function withdrawVault(program: Program, provider: Provider, payer: Signer, vaultPublicKey: PublicKey, withdrawAmount: number, overrideTime?: number): Promise<PublicKey>;
|
4
|
+
export declare function withdrawVaultInstruction(program: Program, vaultSystemStatePublicKey: PublicKey, payerPublicKey: PublicKey, destinationTokenAccount: PublicKey, vaultPublickey: PublicKey, vaultAssociatedCollateralPublicKey: PublicKey, vaultTypeAccount: PublicKey, vaultTypeAssociatedTokenAccount: PublicKey, hedgeStakingPoolPublicKey: PublicKey, hedgeStakingPoolAssociatedUsdhTokenAccount: PublicKey, usdhMint: PublicKey, historyPublicKey: PublicKey, withdrawAmount: number, overrideTime?: number): Promise<TransactionInstruction>;
|
@@ -7,9 +7,8 @@ export declare class LiquidationPoolEra {
|
|
7
7
|
liquidyPoolEra: any;
|
8
8
|
totalDeposits: number;
|
9
9
|
product: Decimal;
|
10
|
-
sum: Decimal;
|
10
|
+
sum: [Decimal];
|
11
11
|
hedgeRewardsAccumulator: Decimal;
|
12
12
|
hedgeRewardsTimestamp: number;
|
13
13
|
constructor(liquidyPoolEra: any);
|
14
14
|
}
|
15
|
-
//# sourceMappingURL=LiquidationPoolEra.d.ts.map
|
@@ -5,21 +5,19 @@ import { LiquidationPoolState } from './LiquidationPoolState';
|
|
5
5
|
export declare class LiquidationPosition {
|
6
6
|
publicKey: PublicKey;
|
7
7
|
eraPublicKey: PublicKey;
|
8
|
-
|
9
|
-
liquidationPoolState: LiquidationPoolState;
|
8
|
+
liquidationPoolState?: LiquidationPoolState;
|
10
9
|
ownerAccount: PublicKey;
|
11
10
|
deposit: number;
|
12
11
|
closedUsdh: number;
|
13
|
-
closedSol: number;
|
14
12
|
timestampOpened: Date;
|
15
13
|
timestampClosed: Date;
|
16
|
-
|
17
|
-
|
14
|
+
productSnapshotEntry: Decimal;
|
15
|
+
productSnapshotClosed: Decimal;
|
16
|
+
sumSnapshotsEntry: [Decimal];
|
17
|
+
sumSnapshotsClosed: [Decimal];
|
18
18
|
hedgeRewardsSnapshot: Decimal;
|
19
19
|
open: boolean;
|
20
|
-
constructor(poolPositionInfo: any, key: PublicKey
|
21
|
-
getUsdhAvailable(): Decimal;
|
22
|
-
|
23
|
-
getHedgeAvailable(): Decimal;
|
20
|
+
constructor(poolPositionInfo: any, key: PublicKey);
|
21
|
+
getUsdhAvailable(era: LiquidationPoolEra): Decimal;
|
22
|
+
getTokensAvailable(era: LiquidationPoolEra, index: number): Decimal;
|
24
23
|
}
|
25
|
-
//# sourceMappingURL=LiquidationPosition.d.ts.map
|
package/lib/Constants.js
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
exports.findAssociatedTokenAddress = exports.findVaultAddress = exports.getVaultTypeAccountPublicKey = exports.getPoolPublicKeyForMint = exports.getHedgeMintPublicKey = exports.getVaultSystemStatePublicKey = exports.getUsdhMintPublicKey = exports.getLiquidationPoolUsdhAccountPublicKey = exports.getLiquidationPoolStatePublicKey = exports.CHAINLINK_SOL_USD_PUBLICKEY = exports.CHAINLINK_SOL_USD_ID = exports.HEDGE_PROGRAM_PUBLICKEY = exports.HEDGE_PROGRAM_ID = void 0;
|
13
|
+
const spl_token_1 = require("@solana/spl-token");
|
14
|
+
const web3_js_1 = require("@solana/web3.js");
|
15
|
+
exports.HEDGE_PROGRAM_ID = 'h4sPyjiRvWLquKRULRND9jHCPKqRYZZukvrjMZn21Pz';
|
16
|
+
exports.HEDGE_PROGRAM_PUBLICKEY = new web3_js_1.PublicKey(exports.HEDGE_PROGRAM_ID);
|
17
|
+
exports.CHAINLINK_SOL_USD_ID = 'FmAmfoyPXiA8Vhhe6MZTr3U6rZfEZ1ctEHay1ysqCqcf';
|
18
|
+
exports.CHAINLINK_SOL_USD_PUBLICKEY = new web3_js_1.PublicKey(exports.CHAINLINK_SOL_USD_ID);
|
19
|
+
const enc = new TextEncoder();
|
20
|
+
function getLiquidationPoolStatePublicKey() {
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
22
|
+
const [poolPublicKey] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode('LiquidationPoolStateV1')], exports.HEDGE_PROGRAM_PUBLICKEY);
|
23
|
+
return poolPublicKey;
|
24
|
+
});
|
25
|
+
}
|
26
|
+
exports.getLiquidationPoolStatePublicKey = getLiquidationPoolStatePublicKey;
|
27
|
+
function getLiquidationPoolUsdhAccountPublicKey() {
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
29
|
+
const [poolPublicKey] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode('LiquidationPoolUSDHAccountV1')], exports.HEDGE_PROGRAM_PUBLICKEY);
|
30
|
+
return poolPublicKey;
|
31
|
+
});
|
32
|
+
}
|
33
|
+
exports.getLiquidationPoolUsdhAccountPublicKey = getLiquidationPoolUsdhAccountPublicKey;
|
34
|
+
function getUsdhMintPublicKey() {
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
36
|
+
const [findMintPublicKey] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode('UsdhMintV1')], exports.HEDGE_PROGRAM_PUBLICKEY);
|
37
|
+
return findMintPublicKey;
|
38
|
+
});
|
39
|
+
}
|
40
|
+
exports.getUsdhMintPublicKey = getUsdhMintPublicKey;
|
41
|
+
function getVaultSystemStatePublicKey() {
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
43
|
+
const [publicKey] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode('VaultSystemStateV1')], exports.HEDGE_PROGRAM_PUBLICKEY);
|
44
|
+
return publicKey;
|
45
|
+
});
|
46
|
+
}
|
47
|
+
exports.getVaultSystemStatePublicKey = getVaultSystemStatePublicKey;
|
48
|
+
function getHedgeMintPublicKey() {
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
50
|
+
const [publicKey] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode('HEDGEMintV1')], exports.HEDGE_PROGRAM_PUBLICKEY);
|
51
|
+
return publicKey;
|
52
|
+
});
|
53
|
+
}
|
54
|
+
exports.getHedgeMintPublicKey = getHedgeMintPublicKey;
|
55
|
+
function getPoolPublicKeyForMint(mintPublicKey) {
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
57
|
+
const strToEncode = (mintPublicKey.toString().substring(0, 12));
|
58
|
+
const [publicKey, bump] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode(strToEncode)], exports.HEDGE_PROGRAM_PUBLICKEY);
|
59
|
+
return [publicKey, bump, strToEncode];
|
60
|
+
});
|
61
|
+
}
|
62
|
+
exports.getPoolPublicKeyForMint = getPoolPublicKeyForMint;
|
63
|
+
function getVaultTypeAccountPublicKey(collateralType) {
|
64
|
+
return __awaiter(this, void 0, void 0, function* () {
|
65
|
+
const [vaultTypeAccount] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode(collateralType), enc.encode('State')], exports.HEDGE_PROGRAM_PUBLICKEY);
|
66
|
+
return vaultTypeAccount;
|
67
|
+
});
|
68
|
+
}
|
69
|
+
exports.getVaultTypeAccountPublicKey = getVaultTypeAccountPublicKey;
|
70
|
+
function findVaultAddress(vaultSalt) {
|
71
|
+
return __awaiter(this, void 0, void 0, function* () {
|
72
|
+
const [vaultAddress] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode('Vault'), enc.encode(vaultSalt)], exports.HEDGE_PROGRAM_PUBLICKEY);
|
73
|
+
return vaultAddress;
|
74
|
+
});
|
75
|
+
}
|
76
|
+
exports.findVaultAddress = findVaultAddress;
|
77
|
+
function findAssociatedTokenAddress(walletAddress, tokenMintAddress) {
|
78
|
+
return __awaiter(this, void 0, void 0, function* () {
|
79
|
+
return (yield web3_js_1.PublicKey.findProgramAddress([
|
80
|
+
walletAddress.toBuffer(),
|
81
|
+
spl_token_1.TOKEN_PROGRAM_ID.toBuffer(),
|
82
|
+
tokenMintAddress.toBuffer()
|
83
|
+
], spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID))[0];
|
84
|
+
});
|
85
|
+
}
|
86
|
+
exports.findAssociatedTokenAddress = findAssociatedTokenAddress;
|
@@ -0,0 +1,24 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.DecimalFromU128 = void 0;
|
7
|
+
const decimal_js_1 = __importDefault(require("decimal.js"));
|
8
|
+
/**
|
9
|
+
* Convert a U128 to a Decimal
|
10
|
+
*
|
11
|
+
* On chain, u128s are used to store Decimal numbers. These values
|
12
|
+
* are simply stored as u128 where the actual value is divided by
|
13
|
+
* 1.0e+18. This gives 24 digits of percision on decimal numbers.
|
14
|
+
*
|
15
|
+
* Example: the number 1.5 is stored as a u128: 1.5 * 10^18
|
16
|
+
*
|
17
|
+
* @param value the value to be converted to Decimal
|
18
|
+
* @returns the converted value as a decimal.js object
|
19
|
+
*/
|
20
|
+
function DecimalFromU128(value) {
|
21
|
+
const adjustedValue = new decimal_js_1.default(value.toString());
|
22
|
+
return adjustedValue.div(new decimal_js_1.default('1e+18'));
|
23
|
+
}
|
24
|
+
exports.DecimalFromU128 = DecimalFromU128;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
5
|
+
}) : (function(o, m, k, k2) {
|
6
|
+
if (k2 === undefined) k2 = k;
|
7
|
+
o[k2] = m[k];
|
8
|
+
}));
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
11
|
+
};
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
13
|
+
__exportStar(require("./instructions/createStakingPool"), exports);
|
14
|
+
__exportStar(require("./instructions/depositStakingPool"), exports);
|
15
|
+
__exportStar(require("./instructions/withdrawStakingPool"), exports);
|
package/lib/Vaults.js
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
5
|
+
}) : (function(o, m, k, k2) {
|
6
|
+
if (k2 === undefined) k2 = k;
|
7
|
+
o[k2] = m[k];
|
8
|
+
}));
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
11
|
+
};
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
13
|
+
__exportStar(require("./instructions/createVault"), exports);
|
14
|
+
__exportStar(require("./instructions/depositVault"), exports);
|
15
|
+
__exportStar(require("./instructions/withdrawVault"), exports);
|
16
|
+
__exportStar(require("./instructions/loanVault"), exports);
|
17
|
+
__exportStar(require("./instructions/repayVault"), exports);
|
18
|
+
__exportStar(require("./instructions/redeemVault"), exports);
|
19
|
+
__exportStar(require("./instructions/liquidateVault"), exports);
|
20
|
+
__exportStar(require("./state/VaultAccount"), exports);
|