hedge-web3 0.2.21 → 0.2.25
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -1,63 +1,76 @@
|
|
1
1
|
import { PublicKey } from '@solana/web3.js';
|
2
|
-
export declare const HEDGE_PROGRAM_ID = "HedgeEohwU6RqokrvPU4Hb6XKPub8NuKbnPmY7FoMMtN";
|
3
|
-
export declare const HEDGE_PROGRAM_PUBLICKEY: PublicKey;
|
4
2
|
export declare const CHAINLINK_SOL_USD_ID = "FmAmfoyPXiA8Vhhe6MZTr3U6rZfEZ1ctEHay1ysqCqcf";
|
5
3
|
export declare const CHAINLINK_SOL_USD_PUBLICKEY: PublicKey;
|
6
4
|
export declare const CHAINLINK_PROGRAM_ID = "HEvSKofvBgfaexv23kMabbYqxasxU3mQ4ibBMEmJWHny";
|
7
5
|
/**
|
8
6
|
* @returns The Liquidation pool public key
|
9
7
|
*/
|
10
|
-
export declare function getLiquidationPoolStatePublicKey(): Promise<PublicKey>;
|
8
|
+
export declare function getLiquidationPoolStatePublicKey(hedgeProgramId: PublicKey): Promise<PublicKey>;
|
11
9
|
/**
|
12
10
|
*
|
13
11
|
* @returns The liquidation pool ush account public key
|
14
12
|
*/
|
15
|
-
export declare function getLiquidationPoolUshAccountPublicKey(): Promise<PublicKey>;
|
13
|
+
export declare function getLiquidationPoolUshAccountPublicKey(hedgeProgramId: PublicKey): Promise<PublicKey>;
|
16
14
|
/**
|
17
15
|
*
|
18
16
|
* @returns The USH mint public key
|
19
17
|
*/
|
20
|
-
export declare function getUshMintPublicKey(): Promise<PublicKey>;
|
18
|
+
export declare function getUshMintPublicKey(hedgeProgramId: PublicKey): Promise<PublicKey>;
|
21
19
|
/**
|
22
20
|
*
|
23
21
|
* @returns The Vault System State public key
|
24
22
|
*/
|
25
|
-
export declare function getVaultSystemStatePublicKey(): Promise<PublicKey>;
|
23
|
+
export declare function getVaultSystemStatePublicKey(hedgeProgramId: PublicKey): Promise<PublicKey>;
|
24
|
+
/**
|
25
|
+
*
|
26
|
+
* @returns The Referral State public key
|
27
|
+
*/
|
28
|
+
export declare function getReferralStatePublicKey(hedgeProgramId: PublicKey): Promise<PublicKey>;
|
29
|
+
/**
|
30
|
+
*
|
31
|
+
* @returns The Referral State public key based off the owner's public key
|
32
|
+
*/
|
33
|
+
export declare function getReferralAccountPublicKey(hedgeProgramId: PublicKey, ownerPublicKey: PublicKey): Promise<PublicKey>;
|
34
|
+
/**
|
35
|
+
*
|
36
|
+
* @returns The user referral account public key based off the user's public key
|
37
|
+
*/
|
38
|
+
export declare function getUserReferralAccountPublicKey(hedgeProgramId: PublicKey, ownerPublicKey: PublicKey): Promise<PublicKey>;
|
26
39
|
/**
|
27
40
|
*
|
28
41
|
* @returns The HDG mint public key
|
29
42
|
*/
|
30
|
-
export declare function getHedgeMintPublicKey(): Promise<PublicKey>;
|
43
|
+
export declare function getHedgeMintPublicKey(hedgeProgramId: PublicKey): Promise<PublicKey>;
|
31
44
|
/**
|
32
45
|
* Get the public key for any staking pool
|
33
46
|
*
|
34
47
|
* @param mintPublicKey Staked collateral mint public key
|
35
48
|
* @returns the public key for that staking pool
|
36
49
|
*/
|
37
|
-
export declare function getPoolPublicKeyForMint(mintPublicKey: PublicKey): Promise<[PublicKey, number, string]>;
|
50
|
+
export declare function getPoolPublicKeyForMint(hedgeProgramId: PublicKey, mintPublicKey: PublicKey): Promise<[PublicKey, number, string]>;
|
38
51
|
/**
|
39
52
|
*
|
40
53
|
* @param collateralType String name of the collateral type (must be 16 chars)
|
41
54
|
* @returns The public key for that Vault Type account
|
42
55
|
*/
|
43
|
-
export declare function getVaultTypeAccountPublicKey(collateralType: string): Promise<PublicKey>;
|
56
|
+
export declare function getVaultTypeAccountPublicKey(hedgeProgramId: PublicKey, collateralType: string): Promise<PublicKey>;
|
44
57
|
/**
|
45
58
|
*
|
46
59
|
* @param collateralType String name of the collateral type (must be 16 chars)
|
47
60
|
* @returns The public key for that Vault Type oracle info
|
48
61
|
*/
|
49
|
-
export declare function getVaultTypeOracleAccountPublicKey(collateralType: string): Promise<PublicKey>;
|
62
|
+
export declare function getVaultTypeOracleAccountPublicKey(hedgeProgramId: PublicKey, collateralType: string): Promise<PublicKey>;
|
50
63
|
/**
|
51
64
|
* Vaults are stored in PDA accounts. Use this to get the address from a salt
|
52
65
|
*
|
53
66
|
* @param vaultSalt String salt for the vault (must be 8 chars)
|
54
67
|
* @returns The public key for that Vault Type oracle info
|
55
68
|
*/
|
56
|
-
export declare function findVaultAddress(vaultSalt: string): Promise<PublicKey>;
|
69
|
+
export declare function findVaultAddress(hedgeProgramId: PublicKey, vaultSalt: string): Promise<PublicKey>;
|
57
70
|
/**
|
58
71
|
*
|
59
72
|
* @param walletAddress Owner public key
|
60
73
|
* @param tokenMintAddress Token mint
|
61
74
|
* @returns The associated token account public key
|
62
75
|
*/
|
63
|
-
export declare function findAssociatedTokenAddress(walletAddress: PublicKey, tokenMintAddress: PublicKey): Promise<PublicKey>;
|
76
|
+
export declare function findAssociatedTokenAddress(hedgeProgramId: PublicKey, walletAddress: PublicKey, tokenMintAddress: PublicKey): Promise<PublicKey>;
|
@@ -5,19 +5,9 @@ export declare type Pyth = {
|
|
5
5
|
{
|
6
6
|
"name": "initialize";
|
7
7
|
"accounts": [
|
8
|
-
{
|
9
|
-
"name": "payer";
|
10
|
-
"isMut": true;
|
11
|
-
"isSigner": true;
|
12
|
-
},
|
13
8
|
{
|
14
9
|
"name": "price";
|
15
10
|
"isMut": true;
|
16
|
-
"isSigner": true;
|
17
|
-
},
|
18
|
-
{
|
19
|
-
"name": "systemProgram";
|
20
|
-
"isMut": false;
|
21
11
|
"isSigner": false;
|
22
12
|
}
|
23
13
|
];
|
@@ -53,27 +43,57 @@ export declare type Pyth = {
|
|
53
43
|
];
|
54
44
|
}
|
55
45
|
];
|
56
|
-
"
|
46
|
+
"types": [
|
57
47
|
{
|
58
|
-
"name": "
|
48
|
+
"name": "PriceStatus";
|
59
49
|
"type": {
|
60
|
-
"kind": "
|
61
|
-
"
|
50
|
+
"kind": "enum";
|
51
|
+
"variants": [
|
52
|
+
{
|
53
|
+
"name": "Unknown";
|
54
|
+
},
|
55
|
+
{
|
56
|
+
"name": "Trading";
|
57
|
+
},
|
62
58
|
{
|
63
|
-
"name": "
|
64
|
-
|
65
|
-
|
66
|
-
|
59
|
+
"name": "Halted";
|
60
|
+
},
|
61
|
+
{
|
62
|
+
"name": "Auction";
|
67
63
|
}
|
68
64
|
];
|
69
65
|
};
|
70
|
-
}
|
71
|
-
|
72
|
-
|
66
|
+
},
|
67
|
+
{
|
68
|
+
"name": "CorpAction";
|
69
|
+
"type": {
|
70
|
+
"kind": "enum";
|
71
|
+
"variants": [
|
72
|
+
{
|
73
|
+
"name": "NoCorpAct";
|
74
|
+
}
|
75
|
+
];
|
76
|
+
};
|
77
|
+
},
|
73
78
|
{
|
74
|
-
"
|
75
|
-
"
|
76
|
-
|
79
|
+
"name": "PriceType";
|
80
|
+
"type": {
|
81
|
+
"kind": "enum";
|
82
|
+
"variants": [
|
83
|
+
{
|
84
|
+
"name": "Unknown";
|
85
|
+
},
|
86
|
+
{
|
87
|
+
"name": "Price";
|
88
|
+
},
|
89
|
+
{
|
90
|
+
"name": "TWAP";
|
91
|
+
},
|
92
|
+
{
|
93
|
+
"name": "Volatility";
|
94
|
+
}
|
95
|
+
];
|
96
|
+
};
|
77
97
|
}
|
78
98
|
];
|
79
99
|
};
|
@@ -0,0 +1,47 @@
|
|
1
|
+
export declare type Switchboard = {
|
2
|
+
"version": "0.1.0";
|
3
|
+
"name": "switchboard";
|
4
|
+
"instructions": [
|
5
|
+
{
|
6
|
+
"name": "initialize";
|
7
|
+
"accounts": [
|
8
|
+
{
|
9
|
+
"name": "aggregator";
|
10
|
+
"isMut": true;
|
11
|
+
"isSigner": false;
|
12
|
+
}
|
13
|
+
];
|
14
|
+
"args": [
|
15
|
+
{
|
16
|
+
"name": "price";
|
17
|
+
"type": "u64";
|
18
|
+
},
|
19
|
+
{
|
20
|
+
"name": "scale";
|
21
|
+
"type": "u16";
|
22
|
+
}
|
23
|
+
];
|
24
|
+
},
|
25
|
+
{
|
26
|
+
"name": "setPrice";
|
27
|
+
"accounts": [
|
28
|
+
{
|
29
|
+
"name": "aggregator";
|
30
|
+
"isMut": true;
|
31
|
+
"isSigner": false;
|
32
|
+
}
|
33
|
+
];
|
34
|
+
"args": [
|
35
|
+
{
|
36
|
+
"name": "price";
|
37
|
+
"type": "u64";
|
38
|
+
},
|
39
|
+
{
|
40
|
+
"name": "scale";
|
41
|
+
"type": "u16";
|
42
|
+
}
|
43
|
+
];
|
44
|
+
}
|
45
|
+
];
|
46
|
+
};
|
47
|
+
export declare const IDL: Switchboard;
|