hedge-web3 0.2.21 → 0.2.25
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 +25 -12
- package/declarations/idl/pyth.d.ts +44 -24
- package/declarations/idl/switchboard.d.ts +47 -0
- package/declarations/idl/vault.d.ts +905 -155
- package/declarations/index.d.ts +26 -20
- package/declarations/instructions/closeLiquidationPoolPosition.d.ts +2 -2
- package/declarations/instructions/createReferralAccount.d.ts +17 -0
- package/declarations/instructions/createUserReferralAccount.d.ts +5 -0
- package/declarations/instructions/depositLiquidationPool.d.ts +2 -2
- package/declarations/instructions/loanVault.d.ts +2 -2
- package/declarations/instructions/psmEditAccount.d.ts +12 -0
- package/declarations/instructions/psmMintUsh.d.ts +2 -2
- package/declarations/instructions/psmRedeemUsh.d.ts +2 -2
- package/declarations/instructions/referralClaimFees.d.ts +16 -0
- package/declarations/instructions/transferVault.d.ts +3 -17
- package/declarations/instructions/updateReferralAccount.d.ts +13 -0
- package/declarations/instructions/updateReferralState.d.ts +20 -0
- package/declarations/state/VaultAccount.d.ts +1 -1
- package/declarations/utils/getLinkedListAccounts.d.ts +2 -2
- package/lib/Constants.js +57 -28
- package/lib/idl/pyth.js +44 -24
- package/lib/idl/switchboard.js +49 -0
- package/lib/idl/vault.js +898 -148
- package/lib/index.js +26 -20
- package/lib/instructions/claimLiquidationPoolPosition.js +10 -7
- package/lib/instructions/claimStakingPoolPosition.js +5 -5
- package/lib/instructions/closeClaimedLiquidationPoolPosition.js +1 -1
- package/lib/instructions/closeLiquidationPoolPosition.js +25 -12
- package/lib/instructions/createReferralAccount.js +80 -0
- package/lib/instructions/createStakingPool.js +7 -7
- package/lib/instructions/createUserReferralAccount.js +61 -0
- package/lib/instructions/createVault.js +15 -15
- package/lib/instructions/depositLiquidationPool.js +21 -10
- package/lib/instructions/depositStakingPool.js +5 -5
- package/lib/instructions/depositVault.js +11 -9
- package/lib/instructions/initHedgeFoundation.js +8 -8
- package/lib/instructions/initHedgeFoundationTokens.js +5 -5
- package/lib/instructions/liquidateVault.js +8 -8
- package/lib/instructions/loanVault.js +23 -10
- package/lib/instructions/psmEditAccount.js +60 -0
- package/lib/instructions/psmMintUsh.js +24 -13
- package/lib/instructions/psmRedeemUsh.js +24 -13
- package/lib/instructions/redeemVault.js +7 -7
- package/lib/instructions/referralClaimFees.js +84 -0
- package/lib/instructions/refreshOraclePrice.js +3 -3
- package/lib/instructions/repayVault.js +9 -9
- package/lib/instructions/setHalted.js +1 -1
- package/lib/instructions/transferVault.js +10 -24
- package/lib/instructions/updateReferralAccount.js +50 -0
- package/lib/instructions/updateReferralState.js +57 -0
- package/lib/instructions/updateVaultType.js +1 -1
- package/lib/instructions/withdrawStakingPool.js +11 -11
- package/lib/instructions/withdrawVault.js +5 -5
- package/lib/state/VaultAccount.js +3 -1
- package/lib/utils/getLinkedListAccounts.js +2 -3
- package/package.json +1 -1
- package/src/Constants.ts +64 -63
- package/src/idl/pyth.ts +88 -48
- package/src/idl/switchboard.ts +93 -0
- package/src/idl/vault.ts +1851 -351
- package/src/index.ts +28 -24
- package/src/instructions/claimLiquidationPoolPosition.ts +31 -29
- package/src/instructions/claimStakingPoolPosition.ts +10 -15
- package/src/instructions/closeClaimedLiquidationPoolPosition.ts +4 -2
- package/src/instructions/closeLiquidationPoolPosition.ts +36 -18
- package/src/instructions/createReferralAccount.ts +115 -0
- package/src/instructions/createStakingPool.ts +11 -13
- package/src/instructions/createUserReferralAccount.ts +75 -0
- package/src/instructions/createVault.ts +44 -26
- package/src/instructions/depositLiquidationPool.ts +34 -21
- package/src/instructions/depositStakingPool.ts +18 -14
- package/src/instructions/depositVault.ts +23 -18
- package/src/instructions/initHedgeFoundation.ts +16 -14
- package/src/instructions/initHedgeFoundationTokens.ts +12 -14
- package/src/instructions/liquidateVault.ts +15 -20
- package/src/instructions/loanVault.ts +29 -19
- package/src/instructions/{psmEditAccount.rs → psmEditAccount.ts} +10 -18
- package/src/instructions/psmMintUsh.ts +35 -38
- package/src/instructions/psmRedeemUsh.ts +35 -40
- package/src/instructions/redeemVault.ts +12 -15
- package/src/instructions/referralClaimFees.ts +145 -0
- package/src/instructions/refreshOraclePrice.ts +6 -8
- package/src/instructions/repayVault.ts +18 -16
- package/src/instructions/setHalted.ts +5 -24
- package/src/instructions/transferVault.ts +57 -0
- package/src/instructions/updateReferralAccount.ts +70 -0
- package/src/instructions/updateReferralState.ts +86 -0
- package/src/instructions/updateVaultType.ts +9 -23
- package/src/instructions/withdrawStakingPool.ts +17 -21
- package/src/instructions/withdrawVault.ts +10 -16
- package/src/state/VaultAccount.ts +9 -10
- package/src/utils/getLinkedListAccounts.ts +4 -7
package/declarations/index.d.ts
CHANGED
|
@@ -1,33 +1,39 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './instructions/claimStakingPoolPosition';
|
|
5
|
-
export * from './instructions/depositLiquidationPool';
|
|
6
|
-
export * from './instructions/closeLiquidationPoolPosition';
|
|
1
|
+
export * from './Constants';
|
|
2
|
+
export * from './HedgeDecimal';
|
|
3
|
+
export * from './idl/vault';
|
|
7
4
|
export * from './instructions/claimLiquidationPoolPosition';
|
|
5
|
+
export * from './instructions/claimStakingPoolPosition';
|
|
8
6
|
export * from './instructions/closeClaimedLiquidationPoolPosition';
|
|
7
|
+
export * from './instructions/closeLiquidationPoolPosition';
|
|
8
|
+
export * from './instructions/createReferralAccount';
|
|
9
|
+
export * from './instructions/createStakingPool';
|
|
10
|
+
export * from './instructions/createUserReferralAccount';
|
|
9
11
|
export * from './instructions/createVault';
|
|
10
|
-
export * from './instructions/
|
|
11
|
-
export * from './instructions/
|
|
12
|
+
export * from './instructions/depositLiquidationPool';
|
|
13
|
+
export * from './instructions/depositStakingPool';
|
|
12
14
|
export * from './instructions/depositVault';
|
|
13
|
-
export * from './instructions/
|
|
15
|
+
export * from './instructions/initHedgeFoundation';
|
|
16
|
+
export * from './instructions/initHedgeFoundationTokens';
|
|
17
|
+
export * from './instructions/liquidateVault';
|
|
14
18
|
export * from './instructions/loanVault';
|
|
15
|
-
export * from './instructions/
|
|
19
|
+
export * from './instructions/psmMintUsh';
|
|
20
|
+
export * from './instructions/psmRedeemUsh';
|
|
16
21
|
export * from './instructions/redeemVault';
|
|
17
|
-
export * from './instructions/
|
|
22
|
+
export * from './instructions/referralClaimFees';
|
|
18
23
|
export * from './instructions/refreshOraclePrice';
|
|
19
|
-
export * from './instructions/
|
|
20
|
-
export * from './instructions/initHedgeFoundationTokens';
|
|
24
|
+
export * from './instructions/repayVault';
|
|
21
25
|
export * from './instructions/setHalted';
|
|
26
|
+
export * from './instructions/transferVault';
|
|
27
|
+
export * from './instructions/updateReferralAccount';
|
|
28
|
+
export * from './instructions/updateReferralState';
|
|
22
29
|
export * from './instructions/updateVaultType';
|
|
23
|
-
export * from './
|
|
24
|
-
export * from './
|
|
25
|
-
export * from './state/VaultAccount';
|
|
26
|
-
export * from './state/VaultHistoryEvent';
|
|
27
|
-
export * from './state/StakingPool';
|
|
28
|
-
export * from './state/StakingPoolPosition';
|
|
30
|
+
export * from './instructions/withdrawStakingPool';
|
|
31
|
+
export * from './instructions/withdrawVault';
|
|
29
32
|
export * from './state/LiquidationPoolEra';
|
|
30
33
|
export * from './state/LiquidationPoolState';
|
|
31
34
|
export * from './state/LiquidationPosition';
|
|
35
|
+
export * from './state/StakingPool';
|
|
36
|
+
export * from './state/StakingPoolPosition';
|
|
37
|
+
export * from './state/VaultAccount';
|
|
38
|
+
export * from './state/VaultHistoryEvent';
|
|
32
39
|
export * from './utils/getLinkedListAccounts';
|
|
33
|
-
export * from './idl/vault';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Program, Provider } from '@project-serum/anchor';
|
|
2
2
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
|
3
3
|
import { Vault } from '../idl/vault';
|
|
4
|
-
export declare function closeLiquidationPoolPosition(program: Program<Vault>, provider: Provider, poolPosition: PublicKey, payer: Signer, overrideStartTime?: number): Promise<PublicKey>;
|
|
5
|
-
export declare function closeLiquidationPoolPositionInstruction(program: Program<Vault>, poolEra: PublicKey, poolPosition: PublicKey, payerPublicKey: PublicKey, payerUshAccount: PublicKey, payerAssociatedHedgeAccount: PublicKey, communityAssociatedHedgeTokenAccount: PublicKey, overrideStartTime?: number): Promise<TransactionInstruction>;
|
|
4
|
+
export declare function closeLiquidationPoolPosition(program: Program<Vault>, provider: Provider, poolPosition: PublicKey, payer: Signer, overrideStartTime?: number, referrer?: PublicKey): Promise<PublicKey>;
|
|
5
|
+
export declare function closeLiquidationPoolPositionInstruction(program: Program<Vault>, poolEra: PublicKey, poolPosition: PublicKey, payerPublicKey: PublicKey, payerUshAccount: PublicKey, payerAssociatedHedgeAccount: PublicKey, communityAssociatedHedgeTokenAccount: PublicKey, userReferralAccountPublicKey: PublicKey, referralAccountPublicKey: PublicKey, referralStatePublicKey: PublicKey, overrideStartTime?: number): Promise<TransactionInstruction>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Program, Provider } from '@project-serum/anchor';
|
|
2
|
+
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
|
3
|
+
import { Vault } from '../idl/vault';
|
|
4
|
+
/** @type {Function} - Creates a new referral account.
|
|
5
|
+
* This checks the user has enough HDG in their wallet or staked and
|
|
6
|
+
* then allows them to create a referral account. If they meet the PSM referral threshold,
|
|
7
|
+
* they will be eligible for PSM cut.
|
|
8
|
+
* Params:
|
|
9
|
+
* - program: Program<Vault> : The program instance of Hedge Vault program
|
|
10
|
+
* - provider: Provider : Current connection
|
|
11
|
+
* - payer: Signer : who we are creating the referral account for
|
|
12
|
+
* - poolPublicKey: PublicKey : a key to a pool position. If the position is closed or does not belong to the signer it will be ignored
|
|
13
|
+
* - referrer: PublicKey
|
|
14
|
+
* - overrideTime?: number
|
|
15
|
+
*/
|
|
16
|
+
export declare function 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>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Program, Provider } from '@project-serum/anchor';
|
|
2
|
+
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
|
3
|
+
import { Vault } from '../idl/vault';
|
|
4
|
+
export declare function createUserReferralAccount(program: Program<Vault>, provider: Provider, payer: Signer, referrer?: PublicKey, overrideTime?: number): Promise<PublicKey>;
|
|
5
|
+
export declare function createUserReferralAccountInstruction(program: Program<Vault>, payerPublicKey: PublicKey, referralAccount: PublicKey, userReferralAccount: PublicKey, overrideTime?: number): Promise<TransactionInstruction>;
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
import { BN, Program, Provider } from '@project-serum/anchor';
|
|
3
3
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
|
4
4
|
import { Vault } from '../idl/vault';
|
|
5
|
-
export declare function depositLiquidationPool(program: Program<Vault>, provider: Provider, payer: Signer, depositAmount:
|
|
6
|
-
export declare function depositLiquidationPoolInstruction(program: Program<Vault>, payerPublicKey: PublicKey, payerUshAccount: PublicKey, poolPositionPublicKey: PublicKey, depositAmount: BN, overrideStartTime?: number): Promise<TransactionInstruction>;
|
|
5
|
+
export declare function depositLiquidationPool(program: Program<Vault>, provider: Provider, payer: Signer, depositAmount: number, overrideStartTime?: number, referrer?: PublicKey): Promise<PublicKey>;
|
|
6
|
+
export declare function depositLiquidationPoolInstruction(program: Program<Vault>, payerPublicKey: PublicKey, vaultSystemStatePublicKey: PublicKey, payerUshAccount: PublicKey, poolPositionPublicKey: PublicKey, depositAmount: BN, userReferralAccountPublicKey: PublicKey, referralAccountPublicKey: PublicKey, overrideStartTime?: number): Promise<TransactionInstruction>;
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
import { BN, Program, Provider } from '@project-serum/anchor';
|
|
3
3
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
|
4
4
|
import { Vault } from '../idl/vault';
|
|
5
|
-
export declare function loanVault(program: Program<Vault>, provider: Provider, payer: Signer, vaultPublicKey: PublicKey, loanAmount: number, overrideTime?: number): Promise<PublicKey>;
|
|
6
|
-
export declare function loanVaultInstruction(program: Program<Vault>, payerPublicKey: PublicKey, ownerUshAccount: PublicKey, vaultPublickey: PublicKey, vaultAssociatedTokenAccount: PublicKey, historyPublicKey: PublicKey, vaultTypeAccount: PublicKey, vaultTypeAssociatedTokenAccount: PublicKey, oldSmallerPublicKey: PublicKey, newSmallerPublicKey: PublicKey, newLargerPublicKey: PublicKey, loanAmount: BN, overrideTime?: number): Promise<TransactionInstruction>;
|
|
5
|
+
export declare function loanVault(program: Program<Vault>, provider: Provider, payer: Signer, vaultPublicKey: PublicKey, loanAmount: number, overrideTime?: number, referrer?: PublicKey): Promise<PublicKey>;
|
|
6
|
+
export declare function loanVaultInstruction(program: Program<Vault>, payerPublicKey: PublicKey, ownerUshAccount: PublicKey, vaultPublickey: PublicKey, vaultAssociatedTokenAccount: PublicKey, historyPublicKey: PublicKey, vaultTypeAccount: PublicKey, vaultTypeAssociatedTokenAccount: PublicKey, oldSmallerPublicKey: PublicKey, newSmallerPublicKey: PublicKey, newLargerPublicKey: PublicKey, loanAmount: BN, referralAccountPublicKey: PublicKey, overrideTime?: number): Promise<TransactionInstruction>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="bn.js" />
|
|
2
|
+
import { BN, Program, Provider } from '@project-serum/anchor';
|
|
3
|
+
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
|
4
|
+
import { Vault } from '../idl/vault';
|
|
5
|
+
export declare enum psmStatus {
|
|
6
|
+
PsmEnabled = 0,
|
|
7
|
+
PsmDisabled = 1,
|
|
8
|
+
MintOnly = 2,
|
|
9
|
+
RedeemOnly = 3
|
|
10
|
+
}
|
|
11
|
+
export declare function psmEditAccount(program: Program<Vault>, provider: Provider, payer: Signer, collateralMint: PublicKey, mintFee: number, redeemFee: number, debtLimit: number, minSwap: number, overrideTime?: number): Promise<PublicKey>;
|
|
12
|
+
export declare function psmEditAccountInstruction(program: Program<Vault>, payerPublicKey: PublicKey, psmAccount: PublicKey, collateralMint: PublicKey, mintFee: BN, redeemFee: BN, debtLimit: BN, minSwap: BN, overrideTime?: number): Promise<TransactionInstruction>;
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
import { BN, Program, Provider } from '@project-serum/anchor';
|
|
3
3
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
|
4
4
|
import { Vault } from '../idl/vault';
|
|
5
|
-
export declare function psmMintUsh(program: Program<Vault>, provider: Provider, payer: Signer, collateralMint: PublicKey, collateralAmount: number, overrideTime?: number): Promise<PublicKey>;
|
|
6
|
-
export declare function psmMintUshInstruction(program: Program<Vault>, payerPublicKey: PublicKey, psmAccount: PublicKey, collateralMint: PublicKey, collateralAmount: BN, overrideTime?: number): Promise<TransactionInstruction>;
|
|
5
|
+
export declare function psmMintUsh(program: Program<Vault>, provider: Provider, payer: Signer, collateralMint: PublicKey, collateralAmount: number, overrideTime?: number, referrer?: PublicKey): Promise<PublicKey>;
|
|
6
|
+
export declare function psmMintUshInstruction(program: Program<Vault>, payerPublicKey: PublicKey, psmAccount: PublicKey, collateralMint: PublicKey, collateralAmount: BN, referralStatePublicKey: PublicKey, referralAccountPublicKey: PublicKey, overrideTime?: number): Promise<TransactionInstruction>;
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
import { BN, Program, Provider } from '@project-serum/anchor';
|
|
3
3
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
|
4
4
|
import { Vault } from '../idl/vault';
|
|
5
|
-
export declare function psmRedeemUsh(program: Program<Vault>, provider: Provider, payer: Signer, collateralMint: PublicKey, ushAmount: number, overrideTime?: number): Promise<PublicKey>;
|
|
6
|
-
export declare function psmRedeemUshInstruction(program: Program<Vault>, payerPublicKey: PublicKey, psmAccount: PublicKey, collateralMint: PublicKey, ushAmount: BN, overrideTime?: number): Promise<TransactionInstruction>;
|
|
5
|
+
export declare function psmRedeemUsh(program: Program<Vault>, provider: Provider, payer: Signer, collateralMint: PublicKey, ushAmount: number, overrideTime?: number, referrer?: PublicKey): Promise<PublicKey>;
|
|
6
|
+
export declare function psmRedeemUshInstruction(program: Program<Vault>, payerPublicKey: PublicKey, psmAccount: PublicKey, collateralMint: PublicKey, ushAmount: BN, referralStatePublicKey: PublicKey, referralAccountPublicKey: PublicKey, overrideTime?: number): Promise<TransactionInstruction>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Program, Provider } from '@project-serum/anchor';
|
|
2
|
+
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
|
3
|
+
import { Vault } from '../idl/vault';
|
|
4
|
+
/** @type {Function} - Allows a referrer to claims their fees.
|
|
5
|
+
* This checks the user has enough HDG in their wallet or staked and
|
|
6
|
+
* then allows them to claim earned fees. If they meet the PSM referral threshold,
|
|
7
|
+
* they will be eligible for PSM cut.
|
|
8
|
+
* Params:
|
|
9
|
+
* - program: Program<Vault> : The program instance of Hedge Vault program
|
|
10
|
+
* - provider: Provider : Current connection
|
|
11
|
+
* - payer: Signer : who we are creating the referral account for
|
|
12
|
+
* - poolPublicKey: PublicKey : a key to a pool position. If the position is closed or does not belong to the signer it will be ignored
|
|
13
|
+
* - referrer: PublicKey
|
|
14
|
+
*/
|
|
15
|
+
export declare function 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,19 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import { BN, Program, Provider } from '@project-serum/anchor';
|
|
1
|
+
import { Program, Provider } from '@project-serum/anchor';
|
|
3
2
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
|
4
3
|
import { Vault } from '../idl/vault';
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
minDebtPerVault?: BN;
|
|
8
|
-
loanInitFee?: BN;
|
|
9
|
-
emergencyModeThreshold?: BN;
|
|
10
|
-
oracleChainlink?: PublicKey;
|
|
11
|
-
oraclePyth?: PublicKey;
|
|
12
|
-
oracleSwitchboard?: PublicKey;
|
|
13
|
-
priorityPyth?: number;
|
|
14
|
-
priorityChainlink?: number;
|
|
15
|
-
prioritySwitchboard?: number;
|
|
16
|
-
deprecated?: boolean;
|
|
17
|
-
}
|
|
18
|
-
export declare function transferVault(program: Program<Vault>, provider: Provider, payer: Signer, vaultTypeAccount: PublicKey, oracleInfoAccount: PublicKey, config: VaultTypeConfig): Promise<PublicKey>;
|
|
19
|
-
export declare function transferVaultInstruction(program: Program<Vault>, vaultSystemStatePublicKey: PublicKey, payerPublicKey: PublicKey, vaultTypeAccount: PublicKey, oracleInfoAccount: PublicKey, vaultTypeConfig: VaultTypeConfig): Promise<TransactionInstruction>;
|
|
4
|
+
export declare function transferVault(program: Program<Vault>, provider: Provider, payer: Signer, vaultPublicKey: PublicKey, vaultSystemStatePublicKey: PublicKey, vaultTypeAccount: PublicKey, newOwner: PublicKey): Promise<PublicKey>;
|
|
5
|
+
export declare function transferVaultInstruction(vaultPublickey: PublicKey, vaultSystemStatePublicKey: PublicKey, vaultTypeAccount: PublicKey, historyPublicKey: PublicKey, vaultOwner: PublicKey, program: Program<Vault>, newOwner: PublicKey): Promise<TransactionInstruction>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="bn.js" />
|
|
2
|
+
import { BN, Program, Provider } from '@project-serum/anchor';
|
|
3
|
+
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
|
4
|
+
import { Vault } from '../idl/vault';
|
|
5
|
+
export interface ReferralAccountConfig {
|
|
6
|
+
setupCut?: BN;
|
|
7
|
+
referredUserDiscount?: BN;
|
|
8
|
+
stabilityCut?: BN;
|
|
9
|
+
psmCut?: BN;
|
|
10
|
+
hdgThreshold?: BN;
|
|
11
|
+
}
|
|
12
|
+
export declare function updateReferralAccount(program: Program<Vault>, provider: Provider, payer: Signer, referrer: PublicKey, config: ReferralAccountConfig): Promise<PublicKey>;
|
|
13
|
+
export declare function updateReferralAccountInstruction(program: Program<Vault>, vaultSystemStatePublicKey: PublicKey, referralAccountPublicKey: PublicKey, payerPublicKey: PublicKey, referralAccountConfig: ReferralAccountConfig): Promise<TransactionInstruction>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types="bn.js" />
|
|
2
|
+
import { BN, Program, Provider } from '@project-serum/anchor';
|
|
3
|
+
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
|
4
|
+
import { Vault } from '../idl/vault';
|
|
5
|
+
export interface ReferralStateConfig {
|
|
6
|
+
setupCut?: BN;
|
|
7
|
+
referredUserDiscount?: BN;
|
|
8
|
+
stabilityCut?: BN;
|
|
9
|
+
psmCut?: BN;
|
|
10
|
+
maxSetupCut?: BN;
|
|
11
|
+
maxReferredDiscount?: BN;
|
|
12
|
+
maxStabilityCut?: BN;
|
|
13
|
+
maxPsmCut?: BN;
|
|
14
|
+
hdgThreshold?: BN;
|
|
15
|
+
hdgPsmThreshold?: BN;
|
|
16
|
+
referralThreshold?: BN;
|
|
17
|
+
referralEnabled?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare function updateReferralState(program: Program<Vault>, provider: Provider, payer: Signer, config: ReferralStateConfig): Promise<PublicKey>;
|
|
20
|
+
export declare function updateReferralStateInstruction(program: Program<Vault>, vaultSystemStatePublicKey: PublicKey, referralStatePublicKey: PublicKey, payerPublicKey: PublicKey, referralStateConfig: ReferralStateConfig): Promise<TransactionInstruction>;
|
|
@@ -11,7 +11,7 @@ export declare class VaultAccount {
|
|
|
11
11
|
publicKey: PublicKey;
|
|
12
12
|
/** The public key of the vault owner. */
|
|
13
13
|
vaultOwner: PublicKey;
|
|
14
|
-
/** The
|
|
14
|
+
/** The salt used to derive the PDA for the vault. */
|
|
15
15
|
pdaSalt: string;
|
|
16
16
|
/** The deposited collateral of the vault (in SOL Lamports). */
|
|
17
17
|
deposited: BN;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="bn.js" />
|
|
2
|
-
import {
|
|
2
|
+
import { BN, Program } from '@project-serum/anchor';
|
|
3
3
|
import { PublicKey } from '@solana/web3.js';
|
|
4
|
-
import { VaultAccount } from '../state/VaultAccount';
|
|
5
4
|
import { Vault } from '../idl/vault';
|
|
5
|
+
import { VaultAccount } from '../state/VaultAccount';
|
|
6
6
|
/**
|
|
7
7
|
* Get the accounts the left and right for re-inserting in the linked list
|
|
8
8
|
*
|
package/lib/Constants.js
CHANGED
|
@@ -9,21 +9,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.findAssociatedTokenAddress = exports.findVaultAddress = exports.getVaultTypeOracleAccountPublicKey = exports.getVaultTypeAccountPublicKey = exports.getPoolPublicKeyForMint = exports.getHedgeMintPublicKey = exports.
|
|
12
|
+
exports.findAssociatedTokenAddress = exports.findVaultAddress = exports.getVaultTypeOracleAccountPublicKey = exports.getVaultTypeAccountPublicKey = exports.getPoolPublicKeyForMint = exports.getHedgeMintPublicKey = exports.getUserReferralAccountPublicKey = exports.getReferralAccountPublicKey = exports.getReferralStatePublicKey = exports.getVaultSystemStatePublicKey = exports.getUshMintPublicKey = exports.getLiquidationPoolUshAccountPublicKey = exports.getLiquidationPoolStatePublicKey = exports.CHAINLINK_PROGRAM_ID = exports.CHAINLINK_SOL_USD_PUBLICKEY = exports.CHAINLINK_SOL_USD_ID = void 0;
|
|
13
13
|
const spl_token_1 = require("@solana/spl-token");
|
|
14
14
|
const web3_js_1 = require("@solana/web3.js");
|
|
15
|
-
exports.HEDGE_PROGRAM_ID = 'HedgeEohwU6RqokrvPU4Hb6XKPub8NuKbnPmY7FoMMtN';
|
|
16
|
-
exports.HEDGE_PROGRAM_PUBLICKEY = new web3_js_1.PublicKey(exports.HEDGE_PROGRAM_ID);
|
|
17
15
|
exports.CHAINLINK_SOL_USD_ID = 'FmAmfoyPXiA8Vhhe6MZTr3U6rZfEZ1ctEHay1ysqCqcf';
|
|
18
16
|
exports.CHAINLINK_SOL_USD_PUBLICKEY = new web3_js_1.PublicKey(exports.CHAINLINK_SOL_USD_ID);
|
|
19
|
-
exports.CHAINLINK_PROGRAM_ID =
|
|
17
|
+
exports.CHAINLINK_PROGRAM_ID = 'HEvSKofvBgfaexv23kMabbYqxasxU3mQ4ibBMEmJWHny';
|
|
20
18
|
const enc = new TextEncoder();
|
|
21
19
|
/**
|
|
22
20
|
* @returns The Liquidation pool public key
|
|
23
21
|
*/
|
|
24
|
-
function getLiquidationPoolStatePublicKey() {
|
|
22
|
+
function getLiquidationPoolStatePublicKey(hedgeProgramId) {
|
|
25
23
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
const [poolPublicKey] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode('LiquidationPoolStateV1')],
|
|
24
|
+
const [poolPublicKey] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode('LiquidationPoolStateV1')], hedgeProgramId);
|
|
27
25
|
return poolPublicKey;
|
|
28
26
|
});
|
|
29
27
|
}
|
|
@@ -32,9 +30,9 @@ exports.getLiquidationPoolStatePublicKey = getLiquidationPoolStatePublicKey;
|
|
|
32
30
|
*
|
|
33
31
|
* @returns The liquidation pool ush account public key
|
|
34
32
|
*/
|
|
35
|
-
function getLiquidationPoolUshAccountPublicKey() {
|
|
33
|
+
function getLiquidationPoolUshAccountPublicKey(hedgeProgramId) {
|
|
36
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
const [poolPublicKey] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode('LiquidationPoolUSHAccountV1')],
|
|
35
|
+
const [poolPublicKey] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode('LiquidationPoolUSHAccountV1')], hedgeProgramId);
|
|
38
36
|
return poolPublicKey;
|
|
39
37
|
});
|
|
40
38
|
}
|
|
@@ -43,9 +41,9 @@ exports.getLiquidationPoolUshAccountPublicKey = getLiquidationPoolUshAccountPubl
|
|
|
43
41
|
*
|
|
44
42
|
* @returns The USH mint public key
|
|
45
43
|
*/
|
|
46
|
-
function getUshMintPublicKey() {
|
|
44
|
+
function getUshMintPublicKey(hedgeProgramId) {
|
|
47
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
-
const [findMintPublicKey] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode('UshMintV1')],
|
|
46
|
+
const [findMintPublicKey] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode('UshMintV1')], hedgeProgramId);
|
|
49
47
|
return findMintPublicKey;
|
|
50
48
|
});
|
|
51
49
|
}
|
|
@@ -54,20 +52,55 @@ exports.getUshMintPublicKey = getUshMintPublicKey;
|
|
|
54
52
|
*
|
|
55
53
|
* @returns The Vault System State public key
|
|
56
54
|
*/
|
|
57
|
-
function getVaultSystemStatePublicKey() {
|
|
55
|
+
function getVaultSystemStatePublicKey(hedgeProgramId) {
|
|
58
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
const [publicKey] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode('VaultSystemStateV1')],
|
|
57
|
+
const [publicKey] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode('VaultSystemStateV1')], hedgeProgramId);
|
|
60
58
|
return publicKey;
|
|
61
59
|
});
|
|
62
60
|
}
|
|
63
61
|
exports.getVaultSystemStatePublicKey = getVaultSystemStatePublicKey;
|
|
62
|
+
/**
|
|
63
|
+
*
|
|
64
|
+
* @returns The Referral State public key
|
|
65
|
+
*/
|
|
66
|
+
function getReferralStatePublicKey(hedgeProgramId) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
const [publicKey] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode('ReferralStateV1')], hedgeProgramId);
|
|
69
|
+
return publicKey;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
exports.getReferralStatePublicKey = getReferralStatePublicKey;
|
|
73
|
+
/**
|
|
74
|
+
*
|
|
75
|
+
* @returns The Referral State public key based off the owner's public key
|
|
76
|
+
*/
|
|
77
|
+
function getReferralAccountPublicKey(hedgeProgramId, ownerPublicKey) {
|
|
78
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
const strToEncode = ownerPublicKey.toBuffer(); //.substring(0, 28)
|
|
80
|
+
const [publicKey] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode('refer_acct'), strToEncode], hedgeProgramId);
|
|
81
|
+
return publicKey;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
exports.getReferralAccountPublicKey = getReferralAccountPublicKey;
|
|
85
|
+
/**
|
|
86
|
+
*
|
|
87
|
+
* @returns The user referral account public key based off the user's public key
|
|
88
|
+
*/
|
|
89
|
+
function getUserReferralAccountPublicKey(hedgeProgramId, ownerPublicKey) {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
const strToEncode = ownerPublicKey.toBuffer(); //.substring(0, 28)
|
|
92
|
+
const [publicKey] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode('user_ref'), strToEncode], hedgeProgramId);
|
|
93
|
+
return publicKey;
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
exports.getUserReferralAccountPublicKey = getUserReferralAccountPublicKey;
|
|
64
97
|
/**
|
|
65
98
|
*
|
|
66
99
|
* @returns The HDG mint public key
|
|
67
100
|
*/
|
|
68
|
-
function getHedgeMintPublicKey() {
|
|
101
|
+
function getHedgeMintPublicKey(hedgeProgramId) {
|
|
69
102
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
const [publicKey] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode('HEDGEMintV1')],
|
|
103
|
+
const [publicKey] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode('HEDGEMintV1')], hedgeProgramId);
|
|
71
104
|
return publicKey;
|
|
72
105
|
});
|
|
73
106
|
}
|
|
@@ -78,10 +111,10 @@ exports.getHedgeMintPublicKey = getHedgeMintPublicKey;
|
|
|
78
111
|
* @param mintPublicKey Staked collateral mint public key
|
|
79
112
|
* @returns the public key for that staking pool
|
|
80
113
|
*/
|
|
81
|
-
function getPoolPublicKeyForMint(mintPublicKey) {
|
|
114
|
+
function getPoolPublicKeyForMint(hedgeProgramId, mintPublicKey) {
|
|
82
115
|
return __awaiter(this, void 0, void 0, function* () {
|
|
83
116
|
const strToEncode = mintPublicKey.toString().substring(0, 12);
|
|
84
|
-
const [publicKey, bump] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode(strToEncode)],
|
|
117
|
+
const [publicKey, bump] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode(strToEncode)], hedgeProgramId);
|
|
85
118
|
return [publicKey, bump, strToEncode];
|
|
86
119
|
});
|
|
87
120
|
}
|
|
@@ -91,9 +124,9 @@ exports.getPoolPublicKeyForMint = getPoolPublicKeyForMint;
|
|
|
91
124
|
* @param collateralType String name of the collateral type (must be 16 chars)
|
|
92
125
|
* @returns The public key for that Vault Type account
|
|
93
126
|
*/
|
|
94
|
-
function getVaultTypeAccountPublicKey(collateralType) {
|
|
127
|
+
function getVaultTypeAccountPublicKey(hedgeProgramId, collateralType) {
|
|
95
128
|
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
-
const [vaultTypeAccount] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode(collateralType), enc.encode('State')],
|
|
129
|
+
const [vaultTypeAccount] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode(collateralType), enc.encode('State')], hedgeProgramId);
|
|
97
130
|
return vaultTypeAccount;
|
|
98
131
|
});
|
|
99
132
|
}
|
|
@@ -103,9 +136,9 @@ exports.getVaultTypeAccountPublicKey = getVaultTypeAccountPublicKey;
|
|
|
103
136
|
* @param collateralType String name of the collateral type (must be 16 chars)
|
|
104
137
|
* @returns The public key for that Vault Type oracle info
|
|
105
138
|
*/
|
|
106
|
-
function getVaultTypeOracleAccountPublicKey(collateralType) {
|
|
139
|
+
function getVaultTypeOracleAccountPublicKey(hedgeProgramId, collateralType) {
|
|
107
140
|
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
-
const [vaultTypeOracleAccount] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode(collateralType), enc.encode('Oracle')],
|
|
141
|
+
const [vaultTypeOracleAccount] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode(collateralType), enc.encode('Oracle')], hedgeProgramId);
|
|
109
142
|
return vaultTypeOracleAccount;
|
|
110
143
|
});
|
|
111
144
|
}
|
|
@@ -116,9 +149,9 @@ exports.getVaultTypeOracleAccountPublicKey = getVaultTypeOracleAccountPublicKey;
|
|
|
116
149
|
* @param vaultSalt String salt for the vault (must be 8 chars)
|
|
117
150
|
* @returns The public key for that Vault Type oracle info
|
|
118
151
|
*/
|
|
119
|
-
function findVaultAddress(vaultSalt) {
|
|
152
|
+
function findVaultAddress(hedgeProgramId, vaultSalt) {
|
|
120
153
|
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
-
const [vaultAddress] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode('Vault'), enc.encode(vaultSalt)],
|
|
154
|
+
const [vaultAddress] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode('Vault'), enc.encode(vaultSalt)], hedgeProgramId);
|
|
122
155
|
return vaultAddress;
|
|
123
156
|
});
|
|
124
157
|
}
|
|
@@ -129,13 +162,9 @@ exports.findVaultAddress = findVaultAddress;
|
|
|
129
162
|
* @param tokenMintAddress Token mint
|
|
130
163
|
* @returns The associated token account public key
|
|
131
164
|
*/
|
|
132
|
-
function findAssociatedTokenAddress(walletAddress, tokenMintAddress) {
|
|
165
|
+
function findAssociatedTokenAddress(hedgeProgramId, walletAddress, tokenMintAddress) {
|
|
133
166
|
return __awaiter(this, void 0, void 0, function* () {
|
|
134
|
-
return (yield web3_js_1.PublicKey.findProgramAddress([
|
|
135
|
-
walletAddress.toBuffer(),
|
|
136
|
-
spl_token_1.TOKEN_PROGRAM_ID.toBuffer(),
|
|
137
|
-
tokenMintAddress.toBuffer(),
|
|
138
|
-
], spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID))[0];
|
|
167
|
+
return (yield web3_js_1.PublicKey.findProgramAddress([walletAddress.toBuffer(), spl_token_1.TOKEN_PROGRAM_ID.toBuffer(), tokenMintAddress.toBuffer()], spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID))[0];
|
|
139
168
|
});
|
|
140
169
|
}
|
|
141
170
|
exports.findAssociatedTokenAddress = findAssociatedTokenAddress;
|
package/lib/idl/pyth.js
CHANGED
|
@@ -8,19 +8,9 @@ exports.IDL = {
|
|
|
8
8
|
{
|
|
9
9
|
"name": "initialize",
|
|
10
10
|
"accounts": [
|
|
11
|
-
{
|
|
12
|
-
"name": "payer",
|
|
13
|
-
"isMut": true,
|
|
14
|
-
"isSigner": true
|
|
15
|
-
},
|
|
16
11
|
{
|
|
17
12
|
"name": "price",
|
|
18
13
|
"isMut": true,
|
|
19
|
-
"isSigner": true
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
"name": "systemProgram",
|
|
23
|
-
"isMut": false,
|
|
24
14
|
"isSigner": false
|
|
25
15
|
}
|
|
26
16
|
],
|
|
@@ -56,27 +46,57 @@ exports.IDL = {
|
|
|
56
46
|
]
|
|
57
47
|
}
|
|
58
48
|
],
|
|
59
|
-
"
|
|
49
|
+
"types": [
|
|
60
50
|
{
|
|
61
|
-
"name": "
|
|
51
|
+
"name": "PriceStatus",
|
|
62
52
|
"type": {
|
|
63
|
-
"kind": "
|
|
64
|
-
"
|
|
53
|
+
"kind": "enum",
|
|
54
|
+
"variants": [
|
|
55
|
+
{
|
|
56
|
+
"name": "Unknown"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"name": "Trading"
|
|
60
|
+
},
|
|
65
61
|
{
|
|
66
|
-
"name": "
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
62
|
+
"name": "Halted"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"name": "Auction"
|
|
70
66
|
}
|
|
71
67
|
]
|
|
72
68
|
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"name": "CorpAction",
|
|
72
|
+
"type": {
|
|
73
|
+
"kind": "enum",
|
|
74
|
+
"variants": [
|
|
75
|
+
{
|
|
76
|
+
"name": "NoCorpAct"
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
},
|
|
76
81
|
{
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
|
|
82
|
+
"name": "PriceType",
|
|
83
|
+
"type": {
|
|
84
|
+
"kind": "enum",
|
|
85
|
+
"variants": [
|
|
86
|
+
{
|
|
87
|
+
"name": "Unknown"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"name": "Price"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"name": "TWAP"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"name": "Volatility"
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
}
|
|
80
100
|
}
|
|
81
101
|
]
|
|
82
102
|
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IDL = void 0;
|
|
4
|
+
exports.IDL = {
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"name": "switchboard",
|
|
7
|
+
"instructions": [
|
|
8
|
+
{
|
|
9
|
+
"name": "initialize",
|
|
10
|
+
"accounts": [
|
|
11
|
+
{
|
|
12
|
+
"name": "aggregator",
|
|
13
|
+
"isMut": true,
|
|
14
|
+
"isSigner": false
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"args": [
|
|
18
|
+
{
|
|
19
|
+
"name": "price",
|
|
20
|
+
"type": "u64"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "scale",
|
|
24
|
+
"type": "u16"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"name": "setPrice",
|
|
30
|
+
"accounts": [
|
|
31
|
+
{
|
|
32
|
+
"name": "aggregator",
|
|
33
|
+
"isMut": true,
|
|
34
|
+
"isSigner": false
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"args": [
|
|
38
|
+
{
|
|
39
|
+
"name": "price",
|
|
40
|
+
"type": "u64"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"name": "scale",
|
|
44
|
+
"type": "u16"
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
};
|