hedge-web3 0.2.24 → 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 +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/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 +15 -15
- 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/utils/getLinkedListAccounts.js +2 -3
- 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 -26
- 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/utils/getLinkedListAccounts.ts +4 -7
@@ -1,78 +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>;
|
26
24
|
/**
|
27
25
|
*
|
28
26
|
* @returns The Referral State public key
|
29
27
|
*/
|
30
|
-
export declare function getReferralStatePublicKey(): Promise<PublicKey>;
|
28
|
+
export declare function getReferralStatePublicKey(hedgeProgramId: PublicKey): Promise<PublicKey>;
|
31
29
|
/**
|
32
30
|
*
|
33
31
|
* @returns The Referral State public key based off the owner's public key
|
34
32
|
*/
|
35
|
-
export declare function getReferralAccountPublicKey(ownerPublicKey: PublicKey): Promise<PublicKey>;
|
33
|
+
export declare function getReferralAccountPublicKey(hedgeProgramId: PublicKey, ownerPublicKey: PublicKey): Promise<PublicKey>;
|
36
34
|
/**
|
37
35
|
*
|
38
36
|
* @returns The user referral account public key based off the user's public key
|
39
37
|
*/
|
40
|
-
export declare function getUserReferralAccountPublicKey(ownerPublicKey: PublicKey): Promise<PublicKey>;
|
38
|
+
export declare function getUserReferralAccountPublicKey(hedgeProgramId: PublicKey, ownerPublicKey: PublicKey): Promise<PublicKey>;
|
41
39
|
/**
|
42
40
|
*
|
43
41
|
* @returns The HDG mint public key
|
44
42
|
*/
|
45
|
-
export declare function getHedgeMintPublicKey(): Promise<PublicKey>;
|
43
|
+
export declare function getHedgeMintPublicKey(hedgeProgramId: PublicKey): Promise<PublicKey>;
|
46
44
|
/**
|
47
45
|
* Get the public key for any staking pool
|
48
46
|
*
|
49
47
|
* @param mintPublicKey Staked collateral mint public key
|
50
48
|
* @returns the public key for that staking pool
|
51
49
|
*/
|
52
|
-
export declare function getPoolPublicKeyForMint(mintPublicKey: PublicKey): Promise<[PublicKey, number, string]>;
|
50
|
+
export declare function getPoolPublicKeyForMint(hedgeProgramId: PublicKey, mintPublicKey: PublicKey): Promise<[PublicKey, number, string]>;
|
53
51
|
/**
|
54
52
|
*
|
55
53
|
* @param collateralType String name of the collateral type (must be 16 chars)
|
56
54
|
* @returns The public key for that Vault Type account
|
57
55
|
*/
|
58
|
-
export declare function getVaultTypeAccountPublicKey(collateralType: string): Promise<PublicKey>;
|
56
|
+
export declare function getVaultTypeAccountPublicKey(hedgeProgramId: PublicKey, collateralType: string): Promise<PublicKey>;
|
59
57
|
/**
|
60
58
|
*
|
61
59
|
* @param collateralType String name of the collateral type (must be 16 chars)
|
62
60
|
* @returns The public key for that Vault Type oracle info
|
63
61
|
*/
|
64
|
-
export declare function getVaultTypeOracleAccountPublicKey(collateralType: string): Promise<PublicKey>;
|
62
|
+
export declare function getVaultTypeOracleAccountPublicKey(hedgeProgramId: PublicKey, collateralType: string): Promise<PublicKey>;
|
65
63
|
/**
|
66
64
|
* Vaults are stored in PDA accounts. Use this to get the address from a salt
|
67
65
|
*
|
68
66
|
* @param vaultSalt String salt for the vault (must be 8 chars)
|
69
67
|
* @returns The public key for that Vault Type oracle info
|
70
68
|
*/
|
71
|
-
export declare function findVaultAddress(vaultSalt: string): Promise<PublicKey>;
|
69
|
+
export declare function findVaultAddress(hedgeProgramId: PublicKey, vaultSalt: string): Promise<PublicKey>;
|
72
70
|
/**
|
73
71
|
*
|
74
72
|
* @param walletAddress Owner public key
|
75
73
|
* @param tokenMintAddress Token mint
|
76
74
|
* @returns The associated token account public key
|
77
75
|
*/
|
78
|
-
export declare function findAssociatedTokenAddress(walletAddress: PublicKey, tokenMintAddress: PublicKey): Promise<PublicKey>;
|
76
|
+
export declare function findAssociatedTokenAddress(hedgeProgramId: PublicKey, walletAddress: PublicKey, tokenMintAddress: PublicKey): Promise<PublicKey>;
|
@@ -2413,33 +2413,54 @@ export declare 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 declare 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 declare 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
|
];
|
@@ -12,6 +12,6 @@ import { Vault } from '../idl/vault';
|
|
12
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
13
|
* - referrer: PublicKey
|
14
14
|
* - overrideTime?: number
|
15
|
-
*/
|
15
|
+
*/
|
16
16
|
export declare function createReferralAccount(program: Program<Vault>, provider: Provider, payer: Signer, poolPosition: PublicKey, overrideTime?: number): Promise<PublicKey>;
|
17
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>;
|
@@ -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:
|
5
|
+
export declare function depositLiquidationPool(program: Program<Vault>, provider: Provider, payer: Signer, depositAmount: number, overrideStartTime?: number, referrer?: PublicKey): Promise<PublicKey>;
|
6
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>;
|
@@ -11,6 +11,6 @@ import { Vault } from '../idl/vault';
|
|
11
11
|
* - payer: Signer : who we are creating the referral account for
|
12
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
13
|
* - referrer: PublicKey
|
14
|
-
*/
|
14
|
+
*/
|
15
15
|
export declare function referralClaimFees(program: Program<Vault>, provider: Provider, payer: Signer, poolPosition: PublicKey): Promise<PublicKey>;
|
16
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,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.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 =
|
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,9 +52,9 @@ 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
|
}
|
@@ -65,9 +63,9 @@ exports.getVaultSystemStatePublicKey = getVaultSystemStatePublicKey;
|
|
65
63
|
*
|
66
64
|
* @returns The Referral State public key
|
67
65
|
*/
|
68
|
-
function getReferralStatePublicKey() {
|
66
|
+
function getReferralStatePublicKey(hedgeProgramId) {
|
69
67
|
return __awaiter(this, void 0, void 0, function* () {
|
70
|
-
const [publicKey] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode('ReferralStateV1')],
|
68
|
+
const [publicKey] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode('ReferralStateV1')], hedgeProgramId);
|
71
69
|
return publicKey;
|
72
70
|
});
|
73
71
|
}
|
@@ -76,10 +74,10 @@ exports.getReferralStatePublicKey = getReferralStatePublicKey;
|
|
76
74
|
*
|
77
75
|
* @returns The Referral State public key based off the owner's public key
|
78
76
|
*/
|
79
|
-
function getReferralAccountPublicKey(ownerPublicKey) {
|
77
|
+
function getReferralAccountPublicKey(hedgeProgramId, ownerPublicKey) {
|
80
78
|
return __awaiter(this, void 0, void 0, function* () {
|
81
79
|
const strToEncode = ownerPublicKey.toBuffer(); //.substring(0, 28)
|
82
|
-
const [publicKey] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode('refer_acct'), strToEncode],
|
80
|
+
const [publicKey] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode('refer_acct'), strToEncode], hedgeProgramId);
|
83
81
|
return publicKey;
|
84
82
|
});
|
85
83
|
}
|
@@ -88,10 +86,10 @@ exports.getReferralAccountPublicKey = getReferralAccountPublicKey;
|
|
88
86
|
*
|
89
87
|
* @returns The user referral account public key based off the user's public key
|
90
88
|
*/
|
91
|
-
function getUserReferralAccountPublicKey(ownerPublicKey) {
|
89
|
+
function getUserReferralAccountPublicKey(hedgeProgramId, ownerPublicKey) {
|
92
90
|
return __awaiter(this, void 0, void 0, function* () {
|
93
91
|
const strToEncode = ownerPublicKey.toBuffer(); //.substring(0, 28)
|
94
|
-
const [publicKey] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode('user_ref'), strToEncode],
|
92
|
+
const [publicKey] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode('user_ref'), strToEncode], hedgeProgramId);
|
95
93
|
return publicKey;
|
96
94
|
});
|
97
95
|
}
|
@@ -100,9 +98,9 @@ exports.getUserReferralAccountPublicKey = getUserReferralAccountPublicKey;
|
|
100
98
|
*
|
101
99
|
* @returns The HDG mint public key
|
102
100
|
*/
|
103
|
-
function getHedgeMintPublicKey() {
|
101
|
+
function getHedgeMintPublicKey(hedgeProgramId) {
|
104
102
|
return __awaiter(this, void 0, void 0, function* () {
|
105
|
-
const [publicKey] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode('HEDGEMintV1')],
|
103
|
+
const [publicKey] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode('HEDGEMintV1')], hedgeProgramId);
|
106
104
|
return publicKey;
|
107
105
|
});
|
108
106
|
}
|
@@ -113,10 +111,10 @@ exports.getHedgeMintPublicKey = getHedgeMintPublicKey;
|
|
113
111
|
* @param mintPublicKey Staked collateral mint public key
|
114
112
|
* @returns the public key for that staking pool
|
115
113
|
*/
|
116
|
-
function getPoolPublicKeyForMint(mintPublicKey) {
|
114
|
+
function getPoolPublicKeyForMint(hedgeProgramId, mintPublicKey) {
|
117
115
|
return __awaiter(this, void 0, void 0, function* () {
|
118
116
|
const strToEncode = mintPublicKey.toString().substring(0, 12);
|
119
|
-
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);
|
120
118
|
return [publicKey, bump, strToEncode];
|
121
119
|
});
|
122
120
|
}
|
@@ -126,9 +124,9 @@ exports.getPoolPublicKeyForMint = getPoolPublicKeyForMint;
|
|
126
124
|
* @param collateralType String name of the collateral type (must be 16 chars)
|
127
125
|
* @returns The public key for that Vault Type account
|
128
126
|
*/
|
129
|
-
function getVaultTypeAccountPublicKey(collateralType) {
|
127
|
+
function getVaultTypeAccountPublicKey(hedgeProgramId, collateralType) {
|
130
128
|
return __awaiter(this, void 0, void 0, function* () {
|
131
|
-
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);
|
132
130
|
return vaultTypeAccount;
|
133
131
|
});
|
134
132
|
}
|
@@ -138,9 +136,9 @@ exports.getVaultTypeAccountPublicKey = getVaultTypeAccountPublicKey;
|
|
138
136
|
* @param collateralType String name of the collateral type (must be 16 chars)
|
139
137
|
* @returns The public key for that Vault Type oracle info
|
140
138
|
*/
|
141
|
-
function getVaultTypeOracleAccountPublicKey(collateralType) {
|
139
|
+
function getVaultTypeOracleAccountPublicKey(hedgeProgramId, collateralType) {
|
142
140
|
return __awaiter(this, void 0, void 0, function* () {
|
143
|
-
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);
|
144
142
|
return vaultTypeOracleAccount;
|
145
143
|
});
|
146
144
|
}
|
@@ -151,9 +149,9 @@ exports.getVaultTypeOracleAccountPublicKey = getVaultTypeOracleAccountPublicKey;
|
|
151
149
|
* @param vaultSalt String salt for the vault (must be 8 chars)
|
152
150
|
* @returns The public key for that Vault Type oracle info
|
153
151
|
*/
|
154
|
-
function findVaultAddress(vaultSalt) {
|
152
|
+
function findVaultAddress(hedgeProgramId, vaultSalt) {
|
155
153
|
return __awaiter(this, void 0, void 0, function* () {
|
156
|
-
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);
|
157
155
|
return vaultAddress;
|
158
156
|
});
|
159
157
|
}
|
@@ -164,13 +162,9 @@ exports.findVaultAddress = findVaultAddress;
|
|
164
162
|
* @param tokenMintAddress Token mint
|
165
163
|
* @returns The associated token account public key
|
166
164
|
*/
|
167
|
-
function findAssociatedTokenAddress(walletAddress, tokenMintAddress) {
|
165
|
+
function findAssociatedTokenAddress(hedgeProgramId, walletAddress, tokenMintAddress) {
|
168
166
|
return __awaiter(this, void 0, void 0, function* () {
|
169
|
-
return (yield web3_js_1.PublicKey.findProgramAddress([
|
170
|
-
walletAddress.toBuffer(),
|
171
|
-
spl_token_1.TOKEN_PROGRAM_ID.toBuffer(),
|
172
|
-
tokenMintAddress.toBuffer(),
|
173
|
-
], 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];
|
174
168
|
});
|
175
169
|
}
|
176
170
|
exports.findAssociatedTokenAddress = findAssociatedTokenAddress;
|
package/lib/idl/vault.js
CHANGED
@@ -2416,33 +2416,54 @@ exports.IDL = {
|
|
2416
2416
|
"accounts": [
|
2417
2417
|
{
|
2418
2418
|
"name": "aggregator",
|
2419
|
+
"docs": [
|
2420
|
+
"Define the type of state stored in accounts"
|
2421
|
+
],
|
2419
2422
|
"type": {
|
2420
2423
|
"kind": "struct",
|
2421
2424
|
"fields": [
|
2422
2425
|
{
|
2423
2426
|
"name": "isInitialized",
|
2427
|
+
"docs": [
|
2428
|
+
"Set to true after initialization."
|
2429
|
+
],
|
2424
2430
|
"type": "bool"
|
2425
2431
|
},
|
2426
2432
|
{
|
2427
2433
|
"name": "version",
|
2434
|
+
"docs": [
|
2435
|
+
"Version of the state"
|
2436
|
+
],
|
2428
2437
|
"type": "u32"
|
2429
2438
|
},
|
2430
2439
|
{
|
2431
2440
|
"name": "config",
|
2441
|
+
"docs": [
|
2442
|
+
"The configuration for this aggregator"
|
2443
|
+
],
|
2432
2444
|
"type": {
|
2433
2445
|
"defined": "Config"
|
2434
2446
|
}
|
2435
2447
|
},
|
2436
2448
|
{
|
2437
2449
|
"name": "updatedAt",
|
2450
|
+
"docs": [
|
2451
|
+
"When the config was last updated."
|
2452
|
+
],
|
2438
2453
|
"type": "i64"
|
2439
2454
|
},
|
2440
2455
|
{
|
2441
2456
|
"name": "owner",
|
2457
|
+
"docs": [
|
2458
|
+
"The aggregator owner is allowed to modify it's config."
|
2459
|
+
],
|
2442
2460
|
"type": "publicKey"
|
2443
2461
|
},
|
2444
2462
|
{
|
2445
2463
|
"name": "submissions",
|
2464
|
+
"docs": [
|
2465
|
+
"A set of current submissions, one per oracle. Array index corresponds to oracle index."
|
2466
|
+
],
|
2446
2467
|
"type": {
|
2447
2468
|
"array": [
|
2448
2469
|
{
|
@@ -2454,6 +2475,9 @@ exports.IDL = {
|
|
2454
2475
|
},
|
2455
2476
|
{
|
2456
2477
|
"name": "answer",
|
2478
|
+
"docs": [
|
2479
|
+
"The current median answer."
|
2480
|
+
],
|
2457
2481
|
"type": {
|
2458
2482
|
"option": "u128"
|
2459
2483
|
}
|
@@ -3299,20 +3323,32 @@ exports.IDL = {
|
|
3299
3323
|
"fields": [
|
3300
3324
|
{
|
3301
3325
|
"name": "oracles",
|
3326
|
+
"docs": [
|
3327
|
+
"A list of oracles allowed to submit answers."
|
3328
|
+
],
|
3302
3329
|
"type": {
|
3303
3330
|
"vec": "publicKey"
|
3304
3331
|
}
|
3305
3332
|
},
|
3306
3333
|
{
|
3307
3334
|
"name": "minAnswerThreshold",
|
3335
|
+
"docs": [
|
3336
|
+
"Number of submissions required to produce an answer. Must be larger than 0."
|
3337
|
+
],
|
3308
3338
|
"type": "u8"
|
3309
3339
|
},
|
3310
3340
|
{
|
3311
3341
|
"name": "stalenessThreshold",
|
3342
|
+
"docs": [
|
3343
|
+
"Offset in number of seconds before a submission is considered stale."
|
3344
|
+
],
|
3312
3345
|
"type": "u8"
|
3313
3346
|
},
|
3314
3347
|
{
|
3315
3348
|
"name": "decimals",
|
3349
|
+
"docs": [
|
3350
|
+
"Decimal places for value representations"
|
3351
|
+
],
|
3316
3352
|
"type": "u8"
|
3317
3353
|
}
|
3318
3354
|
]
|
@@ -15,12 +15,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.claimLiquidationPoolPositionInstruction = exports.claimLiquidationPoolPosition = void 0;
|
16
16
|
const spl_token_1 = require("@solana/spl-token");
|
17
17
|
const web3_js_1 = require("@solana/web3.js");
|
18
|
-
const Errors_1 = require("../utils/Errors");
|
19
18
|
const Constants_1 = require("../Constants");
|
19
|
+
const Errors_1 = require("../utils/Errors");
|
20
20
|
const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
|
21
21
|
function claimLiquidationPoolPosition(program, provider, poolPosition, payer, collateralType, overrideStartTime) {
|
22
22
|
return __awaiter(this, void 0, void 0, function* () {
|
23
|
-
const vaultTypeAccountPublicKey = yield (0, Constants_1.getVaultTypeAccountPublicKey)(collateralType);
|
23
|
+
const vaultTypeAccountPublicKey = yield (0, Constants_1.getVaultTypeAccountPublicKey)(program.programId, collateralType);
|
24
24
|
const vaultTypeAccountInfo = yield program.account.vaultType.fetch(vaultTypeAccountPublicKey);
|
25
25
|
const collateralMintPublicKey = vaultTypeAccountInfo.collateralMint;
|
26
26
|
const payerAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMintPublicKey, payer.publicKey);
|
@@ -32,10 +32,12 @@ function claimLiquidationPoolPosition(program, provider, poolPosition, payer, co
|
|
32
32
|
exports.claimLiquidationPoolPosition = claimLiquidationPoolPosition;
|
33
33
|
function claimLiquidationPoolPositionInstruction(program, vaultTypeAccount, collateralMint, poolPosition, payer, payerAssociatedTokenAccount, overrideStartTime) {
|
34
34
|
return __awaiter(this, void 0, void 0, function* () {
|
35
|
-
const vaultSystemState = yield (0, Constants_1.getVaultSystemStatePublicKey)();
|
36
|
-
const poolStatePublicKey = yield (0, Constants_1.getLiquidationPoolStatePublicKey)();
|
37
|
-
const poolAssociatedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(poolStatePublicKey, collateralMint);
|
38
|
-
return yield program.methods
|
35
|
+
const vaultSystemState = yield (0, Constants_1.getVaultSystemStatePublicKey)(program.programId);
|
36
|
+
const poolStatePublicKey = yield (0, Constants_1.getLiquidationPoolStatePublicKey)(program.programId);
|
37
|
+
const poolAssociatedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(program.programId, poolStatePublicKey, collateralMint);
|
38
|
+
return yield program.methods
|
39
|
+
.claimLiquidationPoolPosition()
|
40
|
+
.accounts({
|
39
41
|
vaultSystemState: vaultSystemState,
|
40
42
|
poolState: poolStatePublicKey,
|
41
43
|
poolAssociatedTokenAccount: poolAssociatedTokenAccount,
|
@@ -48,7 +50,8 @@ function claimLiquidationPoolPositionInstruction(program, vaultTypeAccount, coll
|
|
48
50
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
49
51
|
systemProgram: web3_js_1.SystemProgram.programId,
|
50
52
|
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
51
|
-
})
|
53
|
+
})
|
54
|
+
.instruction();
|
52
55
|
});
|
53
56
|
}
|
54
57
|
exports.claimLiquidationPoolPositionInstruction = claimLiquidationPoolPositionInstruction;
|
@@ -15,16 +15,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.claimStakingPoolPositionInstruction = exports.claimStakingPoolPosition = void 0;
|
16
16
|
const spl_token_1 = require("@solana/spl-token");
|
17
17
|
const web3_js_1 = require("@solana/web3.js");
|
18
|
-
const Errors_1 = require("../utils/Errors");
|
19
18
|
const Constants_1 = require("../Constants");
|
19
|
+
const Errors_1 = require("../utils/Errors");
|
20
20
|
const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
|
21
21
|
function claimStakingPoolPosition(program, provider, poolPosition, payer, collateralType) {
|
22
22
|
return __awaiter(this, void 0, void 0, function* () {
|
23
|
-
const vaultTypeAccount = yield (0, Constants_1.getVaultTypeAccountPublicKey)(collateralType);
|
23
|
+
const vaultTypeAccount = yield (0, Constants_1.getVaultTypeAccountPublicKey)(program.programId, collateralType);
|
24
24
|
const vaultTypeAccountInfo = yield program.account.vaultType.fetch(vaultTypeAccount);
|
25
25
|
const collateralMint = vaultTypeAccountInfo.collateralMint;
|
26
|
-
const stakedTokenMint = yield (0, Constants_1.getHedgeMintPublicKey)();
|
27
|
-
const [feePool] = yield (0, Constants_1.getPoolPublicKeyForMint)(stakedTokenMint);
|
26
|
+
const stakedTokenMint = yield (0, Constants_1.getHedgeMintPublicKey)(program.programId);
|
27
|
+
const [feePool] = yield (0, Constants_1.getPoolPublicKeyForMint)(program.programId, stakedTokenMint);
|
28
28
|
const feePoolAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMint, feePool, true);
|
29
29
|
const payerAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMint, payer.publicKey);
|
30
30
|
const transaction = new web3_js_1.Transaction().add(yield claimStakingPoolPositionInstruction(program, feePool, feePoolAssociatedTokenAccount.address, stakedTokenMint, vaultTypeAccount, collateralMint, poolPosition, payer.publicKey, payerAssociatedTokenAccount.address));
|
@@ -35,7 +35,7 @@ function claimStakingPoolPosition(program, provider, poolPosition, payer, collat
|
|
35
35
|
exports.claimStakingPoolPosition = claimStakingPoolPosition;
|
36
36
|
function claimStakingPoolPositionInstruction(program, feePool, feePoolAssociatedTokenAccount, stakedTokenMint, vaultTypeAccount, collateralMint, poolPosition, payer, payerAssociatedTokenAccount) {
|
37
37
|
return __awaiter(this, void 0, void 0, function* () {
|
38
|
-
const vaultSystemState = yield (0, Constants_1.getVaultSystemStatePublicKey)();
|
38
|
+
const vaultSystemState = yield (0, Constants_1.getVaultSystemStatePublicKey)(program.programId);
|
39
39
|
return yield program.methods
|
40
40
|
.claimStakingPoolPosition()
|
41
41
|
.accounts({
|
@@ -16,29 +16,29 @@ exports.closeLiquidationPoolPositionInstruction = exports.closeLiquidationPoolPo
|
|
16
16
|
const anchor_1 = require("@project-serum/anchor");
|
17
17
|
const spl_token_1 = require("@solana/spl-token");
|
18
18
|
const web3_js_1 = require("@solana/web3.js");
|
19
|
-
const Errors_1 = require("../utils/Errors");
|
20
19
|
const Constants_1 = require("../Constants");
|
20
|
+
const Errors_1 = require("../utils/Errors");
|
21
21
|
const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
|
22
22
|
function closeLiquidationPoolPosition(program, provider, poolPosition, payer, overrideStartTime, referrer) {
|
23
23
|
return __awaiter(this, void 0, void 0, function* () {
|
24
|
-
const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
|
24
|
+
const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)(program.programId);
|
25
25
|
const payerUshAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, ushMintPublickey, payer.publicKey);
|
26
|
-
const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
|
27
|
-
const referralStatePublicKey = yield (0, Constants_1.getReferralStatePublicKey)();
|
26
|
+
const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)(program.programId);
|
27
|
+
const referralStatePublicKey = yield (0, Constants_1.getReferralStatePublicKey)(program.programId);
|
28
28
|
const liquidationPositionAccount = yield program.account.liquidationPosition.fetch(poolPosition);
|
29
29
|
const poolEra = liquidationPositionAccount.era;
|
30
|
-
const hedgeMint = yield (0, Constants_1.getHedgeMintPublicKey)();
|
30
|
+
const hedgeMint = yield (0, Constants_1.getHedgeMintPublicKey)(program.programId);
|
31
31
|
const payerAssociatedHedgeAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, hedgeMint, payer.publicKey);
|
32
32
|
const communityAssociatedHedgeTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, hedgeMint, vaultSystemStatePublicKey, true);
|
33
33
|
let referralAccountPublicKey = null;
|
34
34
|
if (typeof referrer === 'undefined') {
|
35
|
-
referralAccountPublicKey = yield (0, Constants_1.getReferralAccountPublicKey)(vaultSystemStatePublicKey);
|
35
|
+
referralAccountPublicKey = yield (0, Constants_1.getReferralAccountPublicKey)(program.programId, vaultSystemStatePublicKey);
|
36
36
|
}
|
37
37
|
else {
|
38
|
-
referralAccountPublicKey = yield (0, Constants_1.getReferralAccountPublicKey)(referrer);
|
38
|
+
referralAccountPublicKey = yield (0, Constants_1.getReferralAccountPublicKey)(program.programId, referrer);
|
39
39
|
}
|
40
40
|
// Derive the user referral account public key
|
41
|
-
const userReferralAccountPublicKey = yield (0, Constants_1.getUserReferralAccountPublicKey)(payer.publicKey);
|
41
|
+
const userReferralAccountPublicKey = yield (0, Constants_1.getUserReferralAccountPublicKey)(program.programId, payer.publicKey);
|
42
42
|
const transaction = new web3_js_1.Transaction().add(yield closeLiquidationPoolPositionInstruction(program, poolEra, poolPosition, payer.publicKey, payerUshAccount.address, payerAssociatedHedgeAccount.address, communityAssociatedHedgeTokenAccount.address, userReferralAccountPublicKey, referralAccountPublicKey, referralStatePublicKey, overrideStartTime));
|
43
43
|
yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer]).catch(Errors_1.parseAnchorErrors);
|
44
44
|
return poolPosition;
|
@@ -47,11 +47,11 @@ function closeLiquidationPoolPosition(program, provider, poolPosition, payer, ov
|
|
47
47
|
exports.closeLiquidationPoolPosition = closeLiquidationPoolPosition;
|
48
48
|
function closeLiquidationPoolPositionInstruction(program, poolEra, poolPosition, payerPublicKey, payerUshAccount, payerAssociatedHedgeAccount, communityAssociatedHedgeTokenAccount, userReferralAccountPublicKey, referralAccountPublicKey, referralStatePublicKey, overrideStartTime) {
|
49
49
|
return __awaiter(this, void 0, void 0, function* () {
|
50
|
-
const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
|
51
|
-
const ushMint = yield (0, Constants_1.getUshMintPublicKey)();
|
52
|
-
const hedgeMint = yield (0, Constants_1.getHedgeMintPublicKey)();
|
53
|
-
const poolUshAccount = yield (0, Constants_1.getLiquidationPoolUshAccountPublicKey)();
|
54
|
-
const poolState = yield (0, Constants_1.getLiquidationPoolStatePublicKey)();
|
50
|
+
const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)(program.programId);
|
51
|
+
const ushMint = yield (0, Constants_1.getUshMintPublicKey)(program.programId);
|
52
|
+
const hedgeMint = yield (0, Constants_1.getHedgeMintPublicKey)(program.programId);
|
53
|
+
const poolUshAccount = yield (0, Constants_1.getLiquidationPoolUshAccountPublicKey)(program.programId);
|
54
|
+
const poolState = yield (0, Constants_1.getLiquidationPoolStatePublicKey)(program.programId);
|
55
55
|
return yield program.methods
|
56
56
|
.closeLiquidationPoolPosition(new anchor_1.BN(overrideStartTime !== null && overrideStartTime !== void 0 ? overrideStartTime : Math.floor(Date.now() / 1000)) // override current time
|
57
57
|
)
|