hedge-web3 0.2.24 → 0.2.26
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 +13 -15
- package/declarations/idl/vault.d.ts +36 -0
- package/declarations/instructions/createReferralAccount.d.ts +1 -1
- package/declarations/instructions/depositLiquidationPool.d.ts +1 -1
- package/declarations/instructions/referralClaimFees.d.ts +1 -1
- package/declarations/state/VaultAccount.d.ts +15 -2
- package/declarations/utils/getLinkedListAccounts.d.ts +2 -2
- package/lib/Constants.js +28 -34
- package/lib/idl/vault.js +36 -0
- 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 +13 -13
- package/lib/instructions/createReferralAccount.js +8 -8
- package/lib/instructions/createStakingPool.js +7 -7
- package/lib/instructions/createUserReferralAccount.js +6 -6
- package/lib/instructions/createVault.js +16 -16
- package/lib/instructions/depositLiquidationPool.js +9 -9
- 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 +12 -12
- package/lib/instructions/psmEditAccount.js +5 -5
- package/lib/instructions/psmMintUsh.js +14 -14
- package/lib/instructions/psmRedeemUsh.js +14 -14
- package/lib/instructions/redeemVault.js +7 -7
- package/lib/instructions/referralClaimFees.js +8 -8
- package/lib/instructions/refreshOraclePrice.js +3 -3
- package/lib/instructions/repayVault.js +9 -9
- package/lib/instructions/setHalted.js +1 -1
- package/lib/instructions/updateReferralAccount.js +2 -2
- package/lib/instructions/updateReferralState.js +2 -2
- 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 +16 -16
- package/lib/utils/getLinkedListAccounts.js +20 -4
- package/package.json +1 -1
- package/src/Constants.ts +44 -85
- package/src/idl/vault.ts +72 -0
- 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 +18 -24
- package/src/instructions/createReferralAccount.ts +17 -29
- package/src/instructions/createStakingPool.ts +11 -13
- package/src/instructions/createUserReferralAccount.ts +13 -24
- package/src/instructions/createVault.ts +44 -21
- package/src/instructions/depositLiquidationPool.ts +16 -23
- 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 +18 -27
- package/src/instructions/psmEditAccount.ts +10 -18
- package/src/instructions/psmMintUsh.ts +19 -41
- package/src/instructions/psmRedeemUsh.ts +21 -45
- package/src/instructions/redeemVault.ts +12 -15
- package/src/instructions/referralClaimFees.ts +17 -31
- 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 +4 -9
- package/src/instructions/updateReferralAccount.ts +7 -14
- package/src/instructions/updateReferralState.ts +7 -14
- 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 +31 -17
- package/src/utils/getLinkedListAccounts.ts +20 -7
package/src/Constants.ts
CHANGED
@@ -1,194 +1,153 @@
|
|
1
|
-
import {
|
2
|
-
ASSOCIATED_TOKEN_PROGRAM_ID,
|
3
|
-
TOKEN_PROGRAM_ID,
|
4
|
-
} from '@solana/spl-token'
|
1
|
+
import { ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID } from '@solana/spl-token'
|
5
2
|
import { PublicKey } from '@solana/web3.js'
|
6
3
|
|
7
|
-
export const
|
8
|
-
export const HEDGE_PROGRAM_PUBLICKEY = new PublicKey(HEDGE_PROGRAM_ID)
|
9
|
-
|
10
|
-
export const CHAINLINK_SOL_USD_ID =
|
11
|
-
'FmAmfoyPXiA8Vhhe6MZTr3U6rZfEZ1ctEHay1ysqCqcf'
|
4
|
+
export const CHAINLINK_SOL_USD_ID = 'FmAmfoyPXiA8Vhhe6MZTr3U6rZfEZ1ctEHay1ysqCqcf'
|
12
5
|
export const CHAINLINK_SOL_USD_PUBLICKEY = new PublicKey(CHAINLINK_SOL_USD_ID)
|
13
|
-
export const CHAINLINK_PROGRAM_ID =
|
6
|
+
export const CHAINLINK_PROGRAM_ID = 'HEvSKofvBgfaexv23kMabbYqxasxU3mQ4ibBMEmJWHny'
|
14
7
|
|
15
8
|
const enc = new TextEncoder()
|
16
9
|
|
17
10
|
/**
|
18
11
|
* @returns The Liquidation pool public key
|
19
12
|
*/
|
20
|
-
export async function getLiquidationPoolStatePublicKey(): Promise<PublicKey> {
|
21
|
-
const [poolPublicKey] = await PublicKey.findProgramAddress(
|
22
|
-
[enc.encode('LiquidationPoolStateV1')],
|
23
|
-
HEDGE_PROGRAM_PUBLICKEY
|
24
|
-
)
|
13
|
+
export async function getLiquidationPoolStatePublicKey(hedgeProgramId: PublicKey): Promise<PublicKey> {
|
14
|
+
const [poolPublicKey] = await PublicKey.findProgramAddress([enc.encode('LiquidationPoolStateV1')], hedgeProgramId)
|
25
15
|
return poolPublicKey
|
26
16
|
}
|
27
17
|
/**
|
28
|
-
*
|
18
|
+
*
|
29
19
|
* @returns The liquidation pool ush account public key
|
30
20
|
*/
|
31
|
-
export async function getLiquidationPoolUshAccountPublicKey(): Promise<PublicKey> {
|
32
|
-
const [poolPublicKey] = await PublicKey.findProgramAddress(
|
33
|
-
[enc.encode('LiquidationPoolUSHAccountV1')],
|
34
|
-
HEDGE_PROGRAM_PUBLICKEY
|
35
|
-
)
|
21
|
+
export async function getLiquidationPoolUshAccountPublicKey(hedgeProgramId: PublicKey): Promise<PublicKey> {
|
22
|
+
const [poolPublicKey] = await PublicKey.findProgramAddress([enc.encode('LiquidationPoolUSHAccountV1')], hedgeProgramId)
|
36
23
|
return poolPublicKey
|
37
24
|
}
|
38
25
|
/**
|
39
|
-
*
|
26
|
+
*
|
40
27
|
* @returns The USH mint public key
|
41
28
|
*/
|
42
|
-
export async function getUshMintPublicKey(): Promise<PublicKey> {
|
43
|
-
const [findMintPublicKey] = await PublicKey.findProgramAddress(
|
44
|
-
[enc.encode('UshMintV1')],
|
45
|
-
HEDGE_PROGRAM_PUBLICKEY
|
46
|
-
)
|
29
|
+
export async function getUshMintPublicKey(hedgeProgramId: PublicKey): Promise<PublicKey> {
|
30
|
+
const [findMintPublicKey] = await PublicKey.findProgramAddress([enc.encode('UshMintV1')], hedgeProgramId)
|
47
31
|
return findMintPublicKey
|
48
32
|
}
|
49
33
|
/**
|
50
|
-
*
|
34
|
+
*
|
51
35
|
* @returns The Vault System State public key
|
52
36
|
*/
|
53
|
-
export async function getVaultSystemStatePublicKey(): Promise<PublicKey> {
|
54
|
-
const [publicKey] = await PublicKey.findProgramAddress(
|
55
|
-
[enc.encode('VaultSystemStateV1')],
|
56
|
-
HEDGE_PROGRAM_PUBLICKEY
|
57
|
-
)
|
37
|
+
export async function getVaultSystemStatePublicKey(hedgeProgramId: PublicKey): Promise<PublicKey> {
|
38
|
+
const [publicKey] = await PublicKey.findProgramAddress([enc.encode('VaultSystemStateV1')], hedgeProgramId)
|
58
39
|
return publicKey
|
59
40
|
}
|
60
41
|
|
61
42
|
/**
|
62
|
-
*
|
43
|
+
*
|
63
44
|
* @returns The Referral State public key
|
64
45
|
*/
|
65
|
-
export async function getReferralStatePublicKey(): Promise<PublicKey> {
|
66
|
-
const [publicKey] = await PublicKey.findProgramAddress(
|
67
|
-
[enc.encode('ReferralStateV1')],
|
68
|
-
HEDGE_PROGRAM_PUBLICKEY
|
69
|
-
)
|
46
|
+
export async function getReferralStatePublicKey(hedgeProgramId: PublicKey): Promise<PublicKey> {
|
47
|
+
const [publicKey] = await PublicKey.findProgramAddress([enc.encode('ReferralStateV1')], hedgeProgramId)
|
70
48
|
return publicKey
|
71
49
|
}
|
72
50
|
|
73
51
|
/**
|
74
|
-
*
|
52
|
+
*
|
75
53
|
* @returns The Referral State public key based off the owner's public key
|
76
54
|
*/
|
77
|
-
export async function getReferralAccountPublicKey(
|
78
|
-
ownerPublicKey
|
79
|
-
|
80
|
-
const strToEncode = ownerPublicKey.toBuffer()//.substring(0, 28)
|
81
|
-
const [publicKey] = await PublicKey.findProgramAddress(
|
82
|
-
[enc.encode('refer_acct'), strToEncode],
|
83
|
-
HEDGE_PROGRAM_PUBLICKEY
|
84
|
-
)
|
55
|
+
export async function getReferralAccountPublicKey(hedgeProgramId: PublicKey, ownerPublicKey: PublicKey): Promise<PublicKey> {
|
56
|
+
const strToEncode = ownerPublicKey.toBuffer() //.substring(0, 28)
|
57
|
+
const [publicKey] = await PublicKey.findProgramAddress([enc.encode('refer_acct'), strToEncode], hedgeProgramId)
|
85
58
|
return publicKey
|
86
59
|
}
|
87
60
|
|
88
61
|
/**
|
89
|
-
*
|
62
|
+
*
|
90
63
|
* @returns The user referral account public key based off the user's public key
|
91
64
|
*/
|
92
|
-
|
65
|
+
export async function getUserReferralAccountPublicKey(
|
66
|
+
hedgeProgramId: PublicKey,
|
93
67
|
ownerPublicKey: PublicKey
|
94
68
|
): Promise<PublicKey> {
|
95
|
-
const strToEncode = ownerPublicKey.toBuffer()//.substring(0, 28)
|
96
|
-
const [publicKey] = await PublicKey.findProgramAddress(
|
97
|
-
[enc.encode('user_ref'), strToEncode],
|
98
|
-
HEDGE_PROGRAM_PUBLICKEY
|
99
|
-
)
|
69
|
+
const strToEncode = ownerPublicKey.toBuffer() //.substring(0, 28)
|
70
|
+
const [publicKey] = await PublicKey.findProgramAddress([enc.encode('user_ref'), strToEncode], hedgeProgramId)
|
100
71
|
return publicKey
|
101
72
|
}
|
102
73
|
|
103
74
|
/**
|
104
|
-
*
|
75
|
+
*
|
105
76
|
* @returns The HDG mint public key
|
106
77
|
*/
|
107
|
-
export async function getHedgeMintPublicKey(): Promise<PublicKey> {
|
108
|
-
const [publicKey] = await PublicKey.findProgramAddress(
|
109
|
-
[enc.encode('HEDGEMintV1')],
|
110
|
-
HEDGE_PROGRAM_PUBLICKEY
|
111
|
-
)
|
78
|
+
export async function getHedgeMintPublicKey(hedgeProgramId: PublicKey): Promise<PublicKey> {
|
79
|
+
const [publicKey] = await PublicKey.findProgramAddress([enc.encode('HEDGEMintV1')], hedgeProgramId)
|
112
80
|
return publicKey
|
113
81
|
}
|
114
82
|
/**
|
115
83
|
* Get the public key for any staking pool
|
116
|
-
*
|
84
|
+
*
|
117
85
|
* @param mintPublicKey Staked collateral mint public key
|
118
86
|
* @returns the public key for that staking pool
|
119
87
|
*/
|
120
88
|
export async function getPoolPublicKeyForMint(
|
89
|
+
hedgeProgramId: PublicKey,
|
121
90
|
mintPublicKey: PublicKey
|
122
91
|
): Promise<[PublicKey, number, string]> {
|
123
92
|
const strToEncode = mintPublicKey.toString().substring(0, 12)
|
124
|
-
const [publicKey, bump] = await PublicKey.findProgramAddress(
|
125
|
-
[enc.encode(strToEncode)],
|
126
|
-
HEDGE_PROGRAM_PUBLICKEY
|
127
|
-
)
|
93
|
+
const [publicKey, bump] = await PublicKey.findProgramAddress([enc.encode(strToEncode)], hedgeProgramId)
|
128
94
|
return [publicKey, bump, strToEncode]
|
129
95
|
}
|
130
96
|
|
131
97
|
/**
|
132
|
-
*
|
98
|
+
*
|
133
99
|
* @param collateralType String name of the collateral type (must be 16 chars)
|
134
100
|
* @returns The public key for that Vault Type account
|
135
101
|
*/
|
136
|
-
export async function getVaultTypeAccountPublicKey(
|
137
|
-
collateralType: string
|
138
|
-
): Promise<PublicKey> {
|
102
|
+
export async function getVaultTypeAccountPublicKey(hedgeProgramId: PublicKey, collateralType: string): Promise<PublicKey> {
|
139
103
|
const [vaultTypeAccount] = await PublicKey.findProgramAddress(
|
140
104
|
[enc.encode(collateralType), enc.encode('State')],
|
141
|
-
|
105
|
+
hedgeProgramId
|
142
106
|
)
|
143
107
|
return vaultTypeAccount
|
144
108
|
}
|
145
109
|
|
146
110
|
/**
|
147
|
-
*
|
111
|
+
*
|
148
112
|
* @param collateralType String name of the collateral type (must be 16 chars)
|
149
113
|
* @returns The public key for that Vault Type oracle info
|
150
114
|
*/
|
151
115
|
export async function getVaultTypeOracleAccountPublicKey(
|
116
|
+
hedgeProgramId: PublicKey,
|
152
117
|
collateralType: string
|
153
118
|
): Promise<PublicKey> {
|
154
119
|
const [vaultTypeOracleAccount] = await PublicKey.findProgramAddress(
|
155
120
|
[enc.encode(collateralType), enc.encode('Oracle')],
|
156
|
-
|
121
|
+
hedgeProgramId
|
157
122
|
)
|
158
123
|
return vaultTypeOracleAccount
|
159
124
|
}
|
160
125
|
|
161
126
|
/**
|
162
127
|
* Vaults are stored in PDA accounts. Use this to get the address from a salt
|
163
|
-
*
|
128
|
+
*
|
164
129
|
* @param vaultSalt String salt for the vault (must be 8 chars)
|
165
130
|
* @returns The public key for that Vault Type oracle info
|
166
131
|
*/
|
167
|
-
export async function findVaultAddress(vaultSalt: string): Promise<PublicKey> {
|
168
|
-
const [vaultAddress] = await PublicKey.findProgramAddress(
|
169
|
-
[enc.encode('Vault'), enc.encode(vaultSalt)],
|
170
|
-
HEDGE_PROGRAM_PUBLICKEY
|
171
|
-
)
|
132
|
+
export async function findVaultAddress(hedgeProgramId: PublicKey, vaultSalt: string): Promise<PublicKey> {
|
133
|
+
const [vaultAddress] = await PublicKey.findProgramAddress([enc.encode('Vault'), enc.encode(vaultSalt)], hedgeProgramId)
|
172
134
|
return vaultAddress
|
173
135
|
}
|
174
136
|
|
175
137
|
/**
|
176
|
-
*
|
138
|
+
*
|
177
139
|
* @param walletAddress Owner public key
|
178
140
|
* @param tokenMintAddress Token mint
|
179
141
|
* @returns The associated token account public key
|
180
142
|
*/
|
181
143
|
export async function findAssociatedTokenAddress(
|
144
|
+
hedgeProgramId: PublicKey,
|
182
145
|
walletAddress: PublicKey,
|
183
146
|
tokenMintAddress: PublicKey
|
184
147
|
): Promise<PublicKey> {
|
185
148
|
return (
|
186
149
|
await PublicKey.findProgramAddress(
|
187
|
-
[
|
188
|
-
walletAddress.toBuffer(),
|
189
|
-
TOKEN_PROGRAM_ID.toBuffer(),
|
190
|
-
tokenMintAddress.toBuffer(),
|
191
|
-
],
|
150
|
+
[walletAddress.toBuffer(), TOKEN_PROGRAM_ID.toBuffer(), tokenMintAddress.toBuffer()],
|
192
151
|
ASSOCIATED_TOKEN_PROGRAM_ID
|
193
152
|
)
|
194
153
|
)[0]
|
package/src/idl/vault.ts
CHANGED
@@ -2413,33 +2413,54 @@ export type Vault = {
|
|
2413
2413
|
"accounts": [
|
2414
2414
|
{
|
2415
2415
|
"name": "aggregator",
|
2416
|
+
"docs": [
|
2417
|
+
"Define the type of state stored in accounts"
|
2418
|
+
],
|
2416
2419
|
"type": {
|
2417
2420
|
"kind": "struct",
|
2418
2421
|
"fields": [
|
2419
2422
|
{
|
2420
2423
|
"name": "isInitialized",
|
2424
|
+
"docs": [
|
2425
|
+
"Set to true after initialization."
|
2426
|
+
],
|
2421
2427
|
"type": "bool"
|
2422
2428
|
},
|
2423
2429
|
{
|
2424
2430
|
"name": "version",
|
2431
|
+
"docs": [
|
2432
|
+
"Version of the state"
|
2433
|
+
],
|
2425
2434
|
"type": "u32"
|
2426
2435
|
},
|
2427
2436
|
{
|
2428
2437
|
"name": "config",
|
2438
|
+
"docs": [
|
2439
|
+
"The configuration for this aggregator"
|
2440
|
+
],
|
2429
2441
|
"type": {
|
2430
2442
|
"defined": "Config"
|
2431
2443
|
}
|
2432
2444
|
},
|
2433
2445
|
{
|
2434
2446
|
"name": "updatedAt",
|
2447
|
+
"docs": [
|
2448
|
+
"When the config was last updated."
|
2449
|
+
],
|
2435
2450
|
"type": "i64"
|
2436
2451
|
},
|
2437
2452
|
{
|
2438
2453
|
"name": "owner",
|
2454
|
+
"docs": [
|
2455
|
+
"The aggregator owner is allowed to modify it's config."
|
2456
|
+
],
|
2439
2457
|
"type": "publicKey"
|
2440
2458
|
},
|
2441
2459
|
{
|
2442
2460
|
"name": "submissions",
|
2461
|
+
"docs": [
|
2462
|
+
"A set of current submissions, one per oracle. Array index corresponds to oracle index."
|
2463
|
+
],
|
2443
2464
|
"type": {
|
2444
2465
|
"array": [
|
2445
2466
|
{
|
@@ -2451,6 +2472,9 @@ export type Vault = {
|
|
2451
2472
|
},
|
2452
2473
|
{
|
2453
2474
|
"name": "answer",
|
2475
|
+
"docs": [
|
2476
|
+
"The current median answer."
|
2477
|
+
],
|
2454
2478
|
"type": {
|
2455
2479
|
"option": "u128"
|
2456
2480
|
}
|
@@ -3296,20 +3320,32 @@ export type Vault = {
|
|
3296
3320
|
"fields": [
|
3297
3321
|
{
|
3298
3322
|
"name": "oracles",
|
3323
|
+
"docs": [
|
3324
|
+
"A list of oracles allowed to submit answers."
|
3325
|
+
],
|
3299
3326
|
"type": {
|
3300
3327
|
"vec": "publicKey"
|
3301
3328
|
}
|
3302
3329
|
},
|
3303
3330
|
{
|
3304
3331
|
"name": "minAnswerThreshold",
|
3332
|
+
"docs": [
|
3333
|
+
"Number of submissions required to produce an answer. Must be larger than 0."
|
3334
|
+
],
|
3305
3335
|
"type": "u8"
|
3306
3336
|
},
|
3307
3337
|
{
|
3308
3338
|
"name": "stalenessThreshold",
|
3339
|
+
"docs": [
|
3340
|
+
"Offset in number of seconds before a submission is considered stale."
|
3341
|
+
],
|
3309
3342
|
"type": "u8"
|
3310
3343
|
},
|
3311
3344
|
{
|
3312
3345
|
"name": "decimals",
|
3346
|
+
"docs": [
|
3347
|
+
"Decimal places for value representations"
|
3348
|
+
],
|
3313
3349
|
"type": "u8"
|
3314
3350
|
}
|
3315
3351
|
]
|
@@ -6392,33 +6428,54 @@ export const IDL: Vault = {
|
|
6392
6428
|
"accounts": [
|
6393
6429
|
{
|
6394
6430
|
"name": "aggregator",
|
6431
|
+
"docs": [
|
6432
|
+
"Define the type of state stored in accounts"
|
6433
|
+
],
|
6395
6434
|
"type": {
|
6396
6435
|
"kind": "struct",
|
6397
6436
|
"fields": [
|
6398
6437
|
{
|
6399
6438
|
"name": "isInitialized",
|
6439
|
+
"docs": [
|
6440
|
+
"Set to true after initialization."
|
6441
|
+
],
|
6400
6442
|
"type": "bool"
|
6401
6443
|
},
|
6402
6444
|
{
|
6403
6445
|
"name": "version",
|
6446
|
+
"docs": [
|
6447
|
+
"Version of the state"
|
6448
|
+
],
|
6404
6449
|
"type": "u32"
|
6405
6450
|
},
|
6406
6451
|
{
|
6407
6452
|
"name": "config",
|
6453
|
+
"docs": [
|
6454
|
+
"The configuration for this aggregator"
|
6455
|
+
],
|
6408
6456
|
"type": {
|
6409
6457
|
"defined": "Config"
|
6410
6458
|
}
|
6411
6459
|
},
|
6412
6460
|
{
|
6413
6461
|
"name": "updatedAt",
|
6462
|
+
"docs": [
|
6463
|
+
"When the config was last updated."
|
6464
|
+
],
|
6414
6465
|
"type": "i64"
|
6415
6466
|
},
|
6416
6467
|
{
|
6417
6468
|
"name": "owner",
|
6469
|
+
"docs": [
|
6470
|
+
"The aggregator owner is allowed to modify it's config."
|
6471
|
+
],
|
6418
6472
|
"type": "publicKey"
|
6419
6473
|
},
|
6420
6474
|
{
|
6421
6475
|
"name": "submissions",
|
6476
|
+
"docs": [
|
6477
|
+
"A set of current submissions, one per oracle. Array index corresponds to oracle index."
|
6478
|
+
],
|
6422
6479
|
"type": {
|
6423
6480
|
"array": [
|
6424
6481
|
{
|
@@ -6430,6 +6487,9 @@ export const IDL: Vault = {
|
|
6430
6487
|
},
|
6431
6488
|
{
|
6432
6489
|
"name": "answer",
|
6490
|
+
"docs": [
|
6491
|
+
"The current median answer."
|
6492
|
+
],
|
6433
6493
|
"type": {
|
6434
6494
|
"option": "u128"
|
6435
6495
|
}
|
@@ -7275,20 +7335,32 @@ export const IDL: Vault = {
|
|
7275
7335
|
"fields": [
|
7276
7336
|
{
|
7277
7337
|
"name": "oracles",
|
7338
|
+
"docs": [
|
7339
|
+
"A list of oracles allowed to submit answers."
|
7340
|
+
],
|
7278
7341
|
"type": {
|
7279
7342
|
"vec": "publicKey"
|
7280
7343
|
}
|
7281
7344
|
},
|
7282
7345
|
{
|
7283
7346
|
"name": "minAnswerThreshold",
|
7347
|
+
"docs": [
|
7348
|
+
"Number of submissions required to produce an answer. Must be larger than 0."
|
7349
|
+
],
|
7284
7350
|
"type": "u8"
|
7285
7351
|
},
|
7286
7352
|
{
|
7287
7353
|
"name": "stalenessThreshold",
|
7354
|
+
"docs": [
|
7355
|
+
"Offset in number of seconds before a submission is considered stale."
|
7356
|
+
],
|
7288
7357
|
"type": "u8"
|
7289
7358
|
},
|
7290
7359
|
{
|
7291
7360
|
"name": "decimals",
|
7361
|
+
"docs": [
|
7362
|
+
"Decimal places for value representations"
|
7363
|
+
],
|
7292
7364
|
"type": "u8"
|
7293
7365
|
}
|
7294
7366
|
]
|
@@ -1,23 +1,19 @@
|
|
1
1
|
import { Program, Provider } from '@project-serum/anchor'
|
2
2
|
import { ASSOCIATED_TOKEN_PROGRAM_ID, getOrCreateAssociatedTokenAccount, TOKEN_PROGRAM_ID } from '@solana/spl-token'
|
3
3
|
import {
|
4
|
-
PublicKey,
|
5
|
-
sendAndConfirmTransaction,
|
6
|
-
Signer,
|
4
|
+
PublicKey, Signer,
|
7
5
|
SystemProgram,
|
8
6
|
SYSVAR_RENT_PUBKEY,
|
9
7
|
Transaction,
|
10
|
-
TransactionInstruction
|
8
|
+
TransactionInstruction
|
11
9
|
} from '@solana/web3.js'
|
12
|
-
import { parseAnchorErrors } from '../utils/Errors'
|
13
10
|
import {
|
14
|
-
findAssociatedTokenAddress,
|
15
|
-
getVaultTypeAccountPublicKey
|
16
|
-
getLiquidationPoolStatePublicKey,
|
17
|
-
getVaultSystemStatePublicKey,
|
11
|
+
findAssociatedTokenAddress, getLiquidationPoolStatePublicKey,
|
12
|
+
getVaultSystemStatePublicKey, getVaultTypeAccountPublicKey
|
18
13
|
} from '../Constants'
|
19
|
-
import sendAndConfirmWithDebug from '../utils/sendAndConfirmWithDebug'
|
20
14
|
import { Vault } from '../idl/vault'
|
15
|
+
import { parseAnchorErrors } from '../utils/Errors'
|
16
|
+
import sendAndConfirmWithDebug from '../utils/sendAndConfirmWithDebug'
|
21
17
|
|
22
18
|
export async function claimLiquidationPoolPosition(
|
23
19
|
program: Program<Vault>,
|
@@ -27,7 +23,7 @@ export async function claimLiquidationPoolPosition(
|
|
27
23
|
collateralType: string,
|
28
24
|
overrideStartTime?: number
|
29
25
|
): Promise<PublicKey> {
|
30
|
-
const vaultTypeAccountPublicKey = await getVaultTypeAccountPublicKey(collateralType)
|
26
|
+
const vaultTypeAccountPublicKey = await getVaultTypeAccountPublicKey(program.programId, collateralType)
|
31
27
|
const vaultTypeAccountInfo = await program.account.vaultType.fetch(vaultTypeAccountPublicKey)
|
32
28
|
const collateralMintPublicKey = vaultTypeAccountInfo.collateralMint
|
33
29
|
|
@@ -62,23 +58,29 @@ export async function claimLiquidationPoolPositionInstruction(
|
|
62
58
|
payerAssociatedTokenAccount: PublicKey,
|
63
59
|
overrideStartTime?: number
|
64
60
|
): Promise<TransactionInstruction> {
|
61
|
+
const vaultSystemState = await getVaultSystemStatePublicKey(program.programId)
|
62
|
+
const poolStatePublicKey = await getLiquidationPoolStatePublicKey(program.programId)
|
63
|
+
const poolAssociatedTokenAccount = await findAssociatedTokenAddress(
|
64
|
+
program.programId,
|
65
|
+
poolStatePublicKey,
|
66
|
+
collateralMint
|
67
|
+
)
|
65
68
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
}).instruction()
|
69
|
+
return await program.methods
|
70
|
+
.claimLiquidationPoolPosition()
|
71
|
+
.accounts({
|
72
|
+
vaultSystemState: vaultSystemState,
|
73
|
+
poolState: poolStatePublicKey,
|
74
|
+
poolAssociatedTokenAccount: poolAssociatedTokenAccount,
|
75
|
+
vaultTypeAccount: vaultTypeAccount,
|
76
|
+
collateralMint: collateralMint,
|
77
|
+
poolPosition: poolPosition,
|
78
|
+
payer: payer,
|
79
|
+
payerAssociatedTokenAccount: payerAssociatedTokenAccount,
|
80
|
+
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
|
81
|
+
tokenProgram: TOKEN_PROGRAM_ID,
|
82
|
+
systemProgram: SystemProgram.programId,
|
83
|
+
rent: SYSVAR_RENT_PUBKEY,
|
84
|
+
})
|
85
|
+
.instruction()
|
84
86
|
}
|
@@ -1,24 +1,19 @@
|
|
1
1
|
import { Program, Provider } from '@project-serum/anchor'
|
2
2
|
import { ASSOCIATED_TOKEN_PROGRAM_ID, getOrCreateAssociatedTokenAccount, TOKEN_PROGRAM_ID } from '@solana/spl-token'
|
3
3
|
import {
|
4
|
-
PublicKey,
|
5
|
-
sendAndConfirmTransaction,
|
6
|
-
Signer,
|
4
|
+
PublicKey, Signer,
|
7
5
|
SystemProgram,
|
8
6
|
SYSVAR_RENT_PUBKEY,
|
9
7
|
Transaction,
|
10
|
-
TransactionInstruction
|
8
|
+
TransactionInstruction
|
11
9
|
} from '@solana/web3.js'
|
12
|
-
import { parseAnchorErrors } from '../utils/Errors'
|
13
10
|
import {
|
14
|
-
getHedgeMintPublicKey,
|
15
|
-
|
16
|
-
getVaultTypeAccountPublicKey,
|
17
|
-
getPoolPublicKeyForMint,
|
18
|
-
getVaultSystemStatePublicKey,
|
11
|
+
getHedgeMintPublicKey, getPoolPublicKeyForMint,
|
12
|
+
getVaultSystemStatePublicKey, getVaultTypeAccountPublicKey
|
19
13
|
} from '../Constants'
|
20
|
-
import sendAndConfirmWithDebug from '../utils/sendAndConfirmWithDebug'
|
21
14
|
import { Vault } from '../idl/vault'
|
15
|
+
import { parseAnchorErrors } from '../utils/Errors'
|
16
|
+
import sendAndConfirmWithDebug from '../utils/sendAndConfirmWithDebug'
|
22
17
|
|
23
18
|
export async function claimStakingPoolPosition(
|
24
19
|
program: Program<Vault>,
|
@@ -27,11 +22,11 @@ export async function claimStakingPoolPosition(
|
|
27
22
|
payer: Signer,
|
28
23
|
collateralType: string
|
29
24
|
): Promise<PublicKey> {
|
30
|
-
const vaultTypeAccount = await getVaultTypeAccountPublicKey(collateralType)
|
25
|
+
const vaultTypeAccount = await getVaultTypeAccountPublicKey(program.programId, collateralType)
|
31
26
|
const vaultTypeAccountInfo = await program.account.vaultType.fetch(vaultTypeAccount)
|
32
27
|
const collateralMint = vaultTypeAccountInfo.collateralMint
|
33
|
-
const stakedTokenMint = await getHedgeMintPublicKey()
|
34
|
-
const [feePool] = await getPoolPublicKeyForMint(stakedTokenMint)
|
28
|
+
const stakedTokenMint = await getHedgeMintPublicKey(program.programId)
|
29
|
+
const [feePool] = await getPoolPublicKeyForMint(program.programId, stakedTokenMint)
|
35
30
|
const feePoolAssociatedTokenAccount = await getOrCreateAssociatedTokenAccount(
|
36
31
|
provider.connection,
|
37
32
|
payer,
|
@@ -74,7 +69,7 @@ export async function claimStakingPoolPositionInstruction(
|
|
74
69
|
payer: PublicKey,
|
75
70
|
payerAssociatedTokenAccount: PublicKey
|
76
71
|
): Promise<TransactionInstruction> {
|
77
|
-
const vaultSystemState = await getVaultSystemStatePublicKey()
|
72
|
+
const vaultSystemState = await getVaultSystemStatePublicKey(program.programId)
|
78
73
|
|
79
74
|
return await program.methods
|
80
75
|
.claimStakingPoolPosition()
|
@@ -10,7 +10,9 @@ export async function closeClaimedLiquidationPoolPosition(
|
|
10
10
|
poolPosition: PublicKey,
|
11
11
|
payer: Signer
|
12
12
|
): Promise<PublicKey> {
|
13
|
-
const transaction = new Transaction().add(
|
13
|
+
const transaction = new Transaction().add(
|
14
|
+
await closeClaimedLiquidationPoolPositionInstruction(program, poolPosition, payer.publicKey)
|
15
|
+
)
|
14
16
|
|
15
17
|
await sendAndConfirmWithDebug(provider.connection, transaction, [payer]).catch(parseAnchorErrors)
|
16
18
|
return poolPosition
|
@@ -25,7 +27,7 @@ export async function closeClaimedLiquidationPoolPositionInstruction(
|
|
25
27
|
.closeClaimedLiquidationPoolPosition()
|
26
28
|
.accounts({
|
27
29
|
poolPosition: poolPosition,
|
28
|
-
payer: payer
|
30
|
+
payer: payer,
|
29
31
|
})
|
30
32
|
.instruction()
|
31
33
|
}
|