hedge-web3 0.2.20 → 0.2.24
Sign up to get free protection for your applications and to get access to all the features.
- package/declarations/Constants.d.ts +15 -0
- package/declarations/idl/pyth.d.ts +44 -24
- package/declarations/idl/switchboard.d.ts +47 -0
- package/declarations/idl/vault.d.ts +857 -157
- 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/instructions/updateVaultType.d.ts +1 -0
- package/declarations/state/VaultAccount.d.ts +2 -1
- package/lib/Constants.js +36 -1
- package/lib/idl/pyth.js +44 -24
- package/lib/idl/switchboard.js +49 -0
- package/lib/idl/vault.js +850 -150
- package/lib/index.js +26 -20
- package/lib/instructions/closeLiquidationPoolPosition.js +16 -3
- package/lib/instructions/createReferralAccount.js +80 -0
- package/lib/instructions/createUserReferralAccount.js +61 -0
- package/lib/instructions/depositLiquidationPool.js +16 -5
- package/lib/instructions/loanVault.js +16 -3
- package/lib/instructions/psmEditAccount.js +60 -0
- package/lib/instructions/psmMintUsh.js +14 -3
- package/lib/instructions/psmRedeemUsh.js +14 -3
- package/lib/instructions/referralClaimFees.js +84 -0
- 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 +10 -9
- package/package.json +1 -1
- package/src/Constants.ts +42 -0
- package/src/idl/pyth.ts +88 -48
- package/src/idl/switchboard.ts +93 -0
- package/src/idl/vault.ts +1762 -362
- package/src/index.ts +28 -24
- package/src/instructions/closeLiquidationPoolPosition.ts +25 -1
- package/src/instructions/createReferralAccount.ts +127 -0
- package/src/instructions/createUserReferralAccount.ts +86 -0
- package/src/instructions/depositLiquidationPool.ts +24 -4
- package/src/instructions/loanVault.ts +20 -1
- package/src/instructions/{psmEditAccount.rs → psmEditAccount.ts} +0 -0
- package/src/instructions/psmMintUsh.ts +20 -1
- package/src/instructions/psmRedeemUsh.ts +20 -1
- package/src/instructions/referralClaimFees.ts +159 -0
- package/src/instructions/transferVault.ts +21 -58
- package/src/instructions/updateReferralAccount.ts +77 -0
- package/src/instructions/updateReferralState.ts +93 -0
- package/src/instructions/updateVaultType.ts +3 -0
- package/src/state/VaultAccount.ts +1 -1
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: BN, overrideStartTime?: number): Promise<PublicKey>;
|
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: BN, 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,8 @@ 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
|
+
pdaSalt: string;
|
15
16
|
/** The deposited collateral of the vault (in SOL Lamports). */
|
16
17
|
deposited: BN;
|
17
18
|
/** The outstanding debt of the vault (in USH Lamports). Denormalized to time 0. */
|
package/lib/Constants.js
CHANGED
@@ -9,7 +9,7 @@ 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.getVaultSystemStatePublicKey = exports.getUshMintPublicKey = exports.getLiquidationPoolUshAccountPublicKey = exports.getLiquidationPoolStatePublicKey = exports.CHAINLINK_PROGRAM_ID = exports.CHAINLINK_SOL_USD_PUBLICKEY = exports.CHAINLINK_SOL_USD_ID = exports.HEDGE_PROGRAM_PUBLICKEY = exports.HEDGE_PROGRAM_ID = void 0;
|
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 = exports.HEDGE_PROGRAM_PUBLICKEY = exports.HEDGE_PROGRAM_ID = void 0;
|
13
13
|
const spl_token_1 = require("@solana/spl-token");
|
14
14
|
const web3_js_1 = require("@solana/web3.js");
|
15
15
|
exports.HEDGE_PROGRAM_ID = 'HedgeEohwU6RqokrvPU4Hb6XKPub8NuKbnPmY7FoMMtN';
|
@@ -61,6 +61,41 @@ function getVaultSystemStatePublicKey() {
|
|
61
61
|
});
|
62
62
|
}
|
63
63
|
exports.getVaultSystemStatePublicKey = getVaultSystemStatePublicKey;
|
64
|
+
/**
|
65
|
+
*
|
66
|
+
* @returns The Referral State public key
|
67
|
+
*/
|
68
|
+
function getReferralStatePublicKey() {
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
70
|
+
const [publicKey] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode('ReferralStateV1')], exports.HEDGE_PROGRAM_PUBLICKEY);
|
71
|
+
return publicKey;
|
72
|
+
});
|
73
|
+
}
|
74
|
+
exports.getReferralStatePublicKey = getReferralStatePublicKey;
|
75
|
+
/**
|
76
|
+
*
|
77
|
+
* @returns The Referral State public key based off the owner's public key
|
78
|
+
*/
|
79
|
+
function getReferralAccountPublicKey(ownerPublicKey) {
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
81
|
+
const strToEncode = ownerPublicKey.toBuffer(); //.substring(0, 28)
|
82
|
+
const [publicKey] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode('refer_acct'), strToEncode], exports.HEDGE_PROGRAM_PUBLICKEY);
|
83
|
+
return publicKey;
|
84
|
+
});
|
85
|
+
}
|
86
|
+
exports.getReferralAccountPublicKey = getReferralAccountPublicKey;
|
87
|
+
/**
|
88
|
+
*
|
89
|
+
* @returns The user referral account public key based off the user's public key
|
90
|
+
*/
|
91
|
+
function getUserReferralAccountPublicKey(ownerPublicKey) {
|
92
|
+
return __awaiter(this, void 0, void 0, function* () {
|
93
|
+
const strToEncode = ownerPublicKey.toBuffer(); //.substring(0, 28)
|
94
|
+
const [publicKey] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode('user_ref'), strToEncode], exports.HEDGE_PROGRAM_PUBLICKEY);
|
95
|
+
return publicKey;
|
96
|
+
});
|
97
|
+
}
|
98
|
+
exports.getUserReferralAccountPublicKey = getUserReferralAccountPublicKey;
|
64
99
|
/**
|
65
100
|
*
|
66
101
|
* @returns The HDG mint public key
|
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
|
+
};
|