hedge-web3 0.2.3 → 0.2.9
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/instructions/createVault.d.ts +3 -2
- package/declarations/instructions/depositLiquidationPool.d.ts +4 -3
- package/declarations/instructions/depositStakingPool.d.ts +3 -2
- package/declarations/instructions/depositVault.d.ts +3 -2
- package/declarations/instructions/loanVault.d.ts +3 -2
- package/declarations/instructions/redeemVault.d.ts +3 -2
- package/declarations/instructions/repayVault.d.ts +3 -2
- package/declarations/instructions/setVaultTypeStatus.d.ts +2 -3
- package/declarations/instructions/withdrawVault.d.ts +3 -2
- package/declarations/state/VaultAccount.d.ts +33 -10
- package/declarations/utils/getLinkedListAccounts.d.ts +17 -2
- package/lib/instructions/createVault.js +2 -2
- package/lib/instructions/depositLiquidationPool.js +2 -2
- package/lib/instructions/depositStakingPool.js +2 -2
- package/lib/instructions/depositVault.js +3 -3
- package/lib/instructions/liquidateVault.js +1 -1
- package/lib/instructions/loanVault.js +3 -3
- package/lib/instructions/redeemVault.js +3 -3
- package/lib/instructions/refreshOraclePrice.js +2 -2
- package/lib/instructions/repayVault.js +3 -3
- package/lib/instructions/setVaultTypeStatus.js +10 -9
- package/lib/instructions/withdrawVault.js +3 -3
- package/lib/state/VaultAccount.js +76 -33
- package/lib/utils/getLinkedListAccounts.js +29 -13
- package/package.json +1 -1
- package/src/instructions/createVault.ts +3 -3
- package/src/instructions/depositLiquidationPool.ts +4 -4
- package/src/instructions/depositStakingPool.ts +3 -3
- package/src/instructions/depositVault.ts +7 -6
- package/src/instructions/liquidateVault.ts +4 -3
- package/src/instructions/loanVault.ts +7 -6
- package/src/instructions/redeemVault.ts +7 -6
- package/src/instructions/refreshOraclePrice.ts +2 -2
- package/src/instructions/repayVault.ts +7 -6
- package/src/instructions/withdrawVault.ts +7 -6
- package/src/state/VaultAccount.ts +84 -39
- package/src/utils/getLinkedListAccounts.ts +34 -16
@@ -1,6 +1,7 @@
|
|
1
|
-
|
1
|
+
/// <reference types="bn.js" />
|
2
|
+
import { BN, Program, Provider } from '@project-serum/anchor';
|
2
3
|
import { PublicKey, Signer, Transaction, TransactionInstruction } from '@solana/web3.js';
|
3
4
|
import { Vault } from '../idl/vault';
|
4
5
|
export declare function createVault(program: Program<Vault>, provider: Provider, payer: Signer, collateralType: string, depositAmount: number, overrideTime?: number): Promise<PublicKey>;
|
5
6
|
export declare function buildCreateVaultTransaction(program: Program<Vault>, payerPublicKey: PublicKey, collateralType: string, depositAmount: number, overrideTime?: number): Promise<[Transaction, Signer[], PublicKey]>;
|
6
|
-
export declare function createVaultInstruction(program: Program<Vault>, salt: string, payerPublicKey: PublicKey, payerTokenAccountPublicKey: PublicKey, vaultPublicKey: PublicKey, vaultAssociatedTokenAccount: PublicKey, feePool: PublicKey, feePoolAssociatedUshTokenAccount: PublicKey, vaultTypeAccount: PublicKey, collateralMint: PublicKey, historyPublicKey: PublicKey, ushMintPublickey: PublicKey, depositAmount:
|
7
|
+
export declare function createVaultInstruction(program: Program<Vault>, salt: string, payerPublicKey: PublicKey, payerTokenAccountPublicKey: PublicKey, vaultPublicKey: PublicKey, vaultAssociatedTokenAccount: PublicKey, feePool: PublicKey, feePoolAssociatedUshTokenAccount: PublicKey, vaultTypeAccount: PublicKey, collateralMint: PublicKey, historyPublicKey: PublicKey, ushMintPublickey: PublicKey, depositAmount: BN, overrideTime?: number): Promise<TransactionInstruction>;
|
@@ -1,5 +1,6 @@
|
|
1
|
-
|
1
|
+
/// <reference types="bn.js" />
|
2
|
+
import { BN, Program, Provider } from '@project-serum/anchor';
|
2
3
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
4
|
import { Vault } from '../idl/vault';
|
4
|
-
export declare function depositLiquidationPool(program: Program<Vault>, provider: Provider, payer: Signer, depositAmount:
|
5
|
-
export declare function depositLiquidationPoolInstruction(program: Program<Vault>, payerPublicKey: PublicKey, payerUshAccount: PublicKey, poolPositionPublicKey: PublicKey, depositAmount:
|
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>;
|
@@ -1,5 +1,6 @@
|
|
1
|
-
|
1
|
+
/// <reference types="bn.js" />
|
2
|
+
import { BN, Program, Provider } from '@project-serum/anchor';
|
2
3
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
4
|
import { Vault } from '../idl/vault';
|
4
5
|
export declare function depositStakingPool(program: Program<Vault>, provider: Provider, payer: Signer, mintPublicKey: PublicKey, depositAmount: number, overrideStartTime?: number): Promise<PublicKey>;
|
5
|
-
export declare function depositStakingPoolInstruction(program: Program<Vault>, payerPublicKey: PublicKey, poolPositionPublicKey: PublicKey, stakedTokenMintPublicKey: PublicKey, depositAmount:
|
6
|
+
export declare function depositStakingPoolInstruction(program: Program<Vault>, payerPublicKey: PublicKey, poolPositionPublicKey: PublicKey, stakedTokenMintPublicKey: PublicKey, depositAmount: BN, overrideStartTime?: number): Promise<TransactionInstruction>;
|
@@ -1,5 +1,6 @@
|
|
1
|
-
|
1
|
+
/// <reference types="bn.js" />
|
2
|
+
import { BN, Program, Provider } from '@project-serum/anchor';
|
2
3
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
4
|
import { Vault } from '../idl/vault';
|
4
5
|
export declare function depositVault(program: Program<Vault>, provider: Provider, payer: Signer, vaultPublicKey: PublicKey, depositAmount: number, overrideTime?: number): Promise<PublicKey>;
|
5
|
-
export declare function depositVaultInstruction(program: Program<Vault>, vaultSystemStatePublicKey: PublicKey, vaultOwner: PublicKey, vaultOwnerTokenAccount: PublicKey, vaultPublicKey: PublicKey, vaultAssociatedTokenAccount: PublicKey, historyPublicKey: PublicKey, vaultTypeAccountPublicKey: PublicKey, vaultTypeAssociatedTokenAccount: PublicKey, hedgeStakingPoolPublicKey: PublicKey, hedgeStakingPoolAssociatedUshTokenAccount: PublicKey, collateralMint: PublicKey, ushMintPublickey: PublicKey, oldSmallerPublicKey: PublicKey, newSmallerPublicKey: PublicKey, newLargerPublicKey: PublicKey, depositAmount:
|
6
|
+
export declare function depositVaultInstruction(program: Program<Vault>, vaultSystemStatePublicKey: PublicKey, vaultOwner: PublicKey, vaultOwnerTokenAccount: PublicKey, vaultPublicKey: PublicKey, vaultAssociatedTokenAccount: PublicKey, historyPublicKey: PublicKey, vaultTypeAccountPublicKey: PublicKey, vaultTypeAssociatedTokenAccount: PublicKey, hedgeStakingPoolPublicKey: PublicKey, hedgeStakingPoolAssociatedUshTokenAccount: PublicKey, collateralMint: PublicKey, ushMintPublickey: PublicKey, oldSmallerPublicKey: PublicKey, newSmallerPublicKey: PublicKey, newLargerPublicKey: PublicKey, depositAmount: BN, overrideTime?: number): Promise<TransactionInstruction>;
|
@@ -1,5 +1,6 @@
|
|
1
|
-
|
1
|
+
/// <reference types="bn.js" />
|
2
|
+
import { BN, Program, Provider } from '@project-serum/anchor';
|
2
3
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
4
|
import { Vault } from '../idl/vault';
|
4
5
|
export declare function loanVault(program: Program<Vault>, provider: Provider, payer: Signer, vaultPublicKey: PublicKey, loanAmount: number, overrideTime?: number): Promise<PublicKey>;
|
5
|
-
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:
|
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>;
|
@@ -1,5 +1,6 @@
|
|
1
|
-
|
1
|
+
/// <reference types="bn.js" />
|
2
|
+
import { BN, Program, Provider } from '@project-serum/anchor';
|
2
3
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
4
|
import { Vault } from '../idl/vault';
|
4
5
|
export declare function redeemVault(program: Program<Vault>, provider: Provider, payer: Signer, vaultPublicKey: PublicKey, redeemAmount: number, transactionOverrideTime?: number): Promise<PublicKey>;
|
5
|
-
export declare function redeemVaultInstruction(program: Program<Vault>, payerPublicKey: PublicKey, payerUshAccount: PublicKey, destinationTokenAccount: PublicKey, vaultPublickey: PublicKey, vaultAssociatedTokenAccount: PublicKey, historyPublicKey: PublicKey, vaultTypeAccount: PublicKey, vaultTypeAssociatedTokenAccount: PublicKey, oldSmallerPublicKey: PublicKey, newSmallerPublicKey: PublicKey, newLargerPublicKey: PublicKey, redeemAmount:
|
6
|
+
export declare function redeemVaultInstruction(program: Program<Vault>, payerPublicKey: PublicKey, payerUshAccount: PublicKey, destinationTokenAccount: PublicKey, vaultPublickey: PublicKey, vaultAssociatedTokenAccount: PublicKey, historyPublicKey: PublicKey, vaultTypeAccount: PublicKey, vaultTypeAssociatedTokenAccount: PublicKey, oldSmallerPublicKey: PublicKey, newSmallerPublicKey: PublicKey, newLargerPublicKey: PublicKey, redeemAmount: BN, transactionOverrideTime?: number): Promise<TransactionInstruction>;
|
@@ -1,5 +1,6 @@
|
|
1
|
-
|
1
|
+
/// <reference types="bn.js" />
|
2
|
+
import { BN, Program, Provider } from '@project-serum/anchor';
|
2
3
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
4
|
import { Vault } from '../idl/vault';
|
4
5
|
export declare function repayVault(program: Program<Vault>, provider: Provider, payer: Signer, vaultPublicKey: PublicKey, repayAmount: number, overrideTime?: number): Promise<PublicKey>;
|
5
|
-
export declare function repayVaultInstruction(program: Program<Vault>, payerPublicKey: PublicKey, ownerUshAccount: PublicKey, vaultPublickey: PublicKey, vaultAssociatedTokenAccount: PublicKey, historyPublicKey: PublicKey, vaultTypeAccount: PublicKey, vaultTypeAssociatedTokenAccount: PublicKey, oldSmallerPublicKey: PublicKey, newSmallerPublicKey: PublicKey, newLargerPublicKey: PublicKey, repayAmount:
|
6
|
+
export declare function repayVaultInstruction(program: Program<Vault>, payerPublicKey: PublicKey, ownerUshAccount: PublicKey, vaultPublickey: PublicKey, vaultAssociatedTokenAccount: PublicKey, historyPublicKey: PublicKey, vaultTypeAccount: PublicKey, vaultTypeAssociatedTokenAccount: PublicKey, oldSmallerPublicKey: PublicKey, newSmallerPublicKey: PublicKey, newLargerPublicKey: PublicKey, repayAmount: BN, overrideTime?: number): Promise<TransactionInstruction>;
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import { Program, Provider } from '@project-serum/anchor';
|
2
2
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
|
-
|
4
|
-
export declare function
|
5
|
-
export declare function setVaultTypeStatusInstruction(program: Program<Vault>, vaultSystemStatePublicKey: PublicKey, payerPublicKey: PublicKey, vaultTypeAccount: PublicKey, deprecated: boolean): Promise<TransactionInstruction>;
|
3
|
+
export declare function setVaultTypeStatus(program: Program, provider: Provider, payer: Signer, vaultTypeAccount: PublicKey, deprecated: boolean): Promise<PublicKey>;
|
4
|
+
export declare function setVaultTypeStatusInstruction(program: Program, vaultSystemStatePublicKey: PublicKey, payerPublicKey: PublicKey, vaultTypeAccount: PublicKey, deprecated: boolean): Promise<TransactionInstruction>;
|
@@ -1,5 +1,6 @@
|
|
1
|
-
|
1
|
+
/// <reference types="bn.js" />
|
2
|
+
import { BN, Program, Provider } from '@project-serum/anchor';
|
2
3
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
4
|
import { Vault } from '../idl/vault';
|
4
5
|
export declare function withdrawVault(program: Program<Vault>, provider: Provider, payer: Signer, vaultPublicKey: PublicKey, withdrawAmount: number, overrideTime?: number): Promise<PublicKey>;
|
5
|
-
export declare function withdrawVaultInstruction(program: Program<Vault>, vaultSystemStatePublicKey: PublicKey, payerPublicKey: PublicKey, destinationTokenAccount: PublicKey, vaultPublickey: PublicKey, vaultAssociatedCollateralPublicKey: PublicKey, vaultTypeAccount: PublicKey, vaultTypeAssociatedTokenAccount: PublicKey, hedgeStakingPoolPublicKey: PublicKey, hedgeStakingPoolAssociatedUshTokenAccount: PublicKey, ushMint: PublicKey, historyPublicKey: PublicKey, oldSmallerPublicKey: PublicKey, newSmallerPublicKey: PublicKey, newLargerPublicKey: PublicKey, withdrawAmount:
|
6
|
+
export declare function withdrawVaultInstruction(program: Program<Vault>, vaultSystemStatePublicKey: PublicKey, payerPublicKey: PublicKey, destinationTokenAccount: PublicKey, vaultPublickey: PublicKey, vaultAssociatedCollateralPublicKey: PublicKey, vaultTypeAccount: PublicKey, vaultTypeAssociatedTokenAccount: PublicKey, hedgeStakingPoolPublicKey: PublicKey, hedgeStakingPoolAssociatedUshTokenAccount: PublicKey, ushMint: PublicKey, historyPublicKey: PublicKey, oldSmallerPublicKey: PublicKey, newSmallerPublicKey: PublicKey, newLargerPublicKey: PublicKey, withdrawAmount: BN, overrideTime?: number): Promise<TransactionInstruction>;
|
@@ -1,6 +1,7 @@
|
|
1
1
|
/// <reference types="node" />
|
2
2
|
import { PublicKey } from '@solana/web3.js';
|
3
3
|
import Decimal from 'decimal.js';
|
4
|
+
import BN from 'bn.js';
|
4
5
|
import VaultType from './VaultType';
|
5
6
|
/**
|
6
7
|
* A class that represents an on-chian vault.
|
@@ -13,9 +14,9 @@ export declare class VaultAccount {
|
|
13
14
|
/** The public key of the vault owner. */
|
14
15
|
pdaSalt: string;
|
15
16
|
/** The deposited collateral of the vault (in SOL Lamports). */
|
16
|
-
deposited:
|
17
|
+
deposited: BN;
|
17
18
|
/** The outstanding debt of the vault (in USH Lamports). Denormalized to time 0. */
|
18
|
-
denormalizedDebt:
|
19
|
+
denormalizedDebt: BN;
|
19
20
|
/** The ordered number of when this vault was created. */
|
20
21
|
vaultNumber: number;
|
21
22
|
/** Debt redistribution snapshot */
|
@@ -38,12 +39,6 @@ export declare class VaultAccount {
|
|
38
39
|
* @returns true if publicKey matches the owner publicKey
|
39
40
|
*/
|
40
41
|
isOwnedBy(publicKey: PublicKey): boolean;
|
41
|
-
/**
|
42
|
-
* Get the collateral value in SOL
|
43
|
-
*
|
44
|
-
* @returns collateral value in SOL
|
45
|
-
*/
|
46
|
-
inSol(): number;
|
47
42
|
/**
|
48
43
|
* Get the debt value in USH
|
49
44
|
*
|
@@ -56,8 +51,36 @@ export declare class VaultAccount {
|
|
56
51
|
* @returns example: `1b6ca...azy71s`
|
57
52
|
*/
|
58
53
|
toDisplayString(): string;
|
59
|
-
|
60
|
-
|
54
|
+
/**
|
55
|
+
* Add additional debt to the vault.
|
56
|
+
*
|
57
|
+
* @param {BN} additionalDebt - Additional normalized debt to add in (USH) lamports.
|
58
|
+
* @param {VaultType} vaultTypeAccount - Vault's vaultType
|
59
|
+
*
|
60
|
+
*/
|
61
|
+
addDebt(additionalDebt: BN, vaultTypeAccount: VaultType): void;
|
62
|
+
/**
|
63
|
+
* Repay debt on a vault
|
64
|
+
*
|
65
|
+
* @param {BN} repayAmount - Normalized debt to repay in (USH) lamports.
|
66
|
+
* @param {VaultType} vaultTypeAccount - Vault's vaultType
|
67
|
+
*
|
68
|
+
*/
|
69
|
+
repayDebt(repayAmount: BN, vaultTypeAccount: VaultType): void;
|
70
|
+
/**
|
71
|
+
* Deposit Collateral
|
72
|
+
*
|
73
|
+
* @param {BN} depositAmount - Amount to deposit in (CollateralMint) lamports
|
74
|
+
*
|
75
|
+
*/
|
76
|
+
depositCollateral(depositAmount: BN): void;
|
77
|
+
/**
|
78
|
+
* Withdraw Collateral
|
79
|
+
*
|
80
|
+
* @param {BN} withdrawAmount - Amount to withdraw in (CollateralMint) lamports
|
81
|
+
*
|
82
|
+
*/
|
83
|
+
withdrawCollateral(withdrawAmount: BN): void;
|
61
84
|
redeem(): void;
|
62
85
|
liquidate(): void;
|
63
86
|
updateDebtAndCollateral(vaultTypeAccountData: VaultType): void;
|
@@ -1,5 +1,20 @@
|
|
1
|
-
|
1
|
+
/// <reference types="bn.js" />
|
2
|
+
import { Program, BN } from '@project-serum/anchor';
|
2
3
|
import { PublicKey } from '@solana/web3.js';
|
3
4
|
import { VaultAccount } from '../state/VaultAccount';
|
4
5
|
import { Vault } from '../idl/vault';
|
5
|
-
|
6
|
+
/**
|
7
|
+
* Get the accounts the left and right for re-inserting in the linked list
|
8
|
+
*
|
9
|
+
* @param {Program<Vault>} program - Anchor program <Vault ILD>
|
10
|
+
* @param {PublicKey} vaultTypeAccountPublicKey - Vault Type Account PublicKey
|
11
|
+
* @param {PublicKey} vaultPublicKey - Vault Account PublicKey
|
12
|
+
* @param {BN} depositAmount - Amount that will be deposited into vault with instruction
|
13
|
+
* @param {BN} withdrawAmount - Amount that will be withdrawn from vault with instruction
|
14
|
+
* @param {BN} loanAmount - Amount that will be deposited into vault with transaction (sans fees)
|
15
|
+
* @param {BN} repayAmount - Amount that will be repaid into vault with transaction
|
16
|
+
* @param {boolean} redeem - True if vault is going to be redeemed fully
|
17
|
+
* @param {boolean} liquidate - True if vault is going to be liquidated fully
|
18
|
+
* @param {VaultAccount[]} cachedVaults - Optional list of cached vaults. Saves a request to the on-chain data.
|
19
|
+
*/
|
20
|
+
export declare function getLinkedListAccounts(program: Program<Vault>, vaultTypeAccountPublicKey: PublicKey, vaultPublicKey: PublicKey, depositAmount: BN, withdrawAmount: BN, loanAmount: BN, repayAmount: BN, redeem: boolean, liquidate: boolean, cachedVaults?: VaultAccount[]): Promise<[PublicKey, PublicKey, PublicKey, VaultAccount[]]>;
|
@@ -53,7 +53,7 @@ function createVault(program, provider, payer, collateralType, depositAmount, ov
|
|
53
53
|
}));
|
54
54
|
signers.push(wrappedSolAccount);
|
55
55
|
}
|
56
|
-
transaction.add(yield createVaultInstruction(program, salt, payer.publicKey, isWrappedSol ? wrappedSolAccount.publicKey : payerTokenAccount, newVaultPublicKey, vaultAssociatedTokenAccount, hedgeStakingPoolPublicKey, feePoolAssociatedUshTokenAccount, vaultTypeAccountPublicKey, vaultTypeAccountInfo.collateralMint, history.publicKey, ushMintPublickey, depositAmount, overrideTime));
|
56
|
+
transaction.add(yield createVaultInstruction(program, salt, payer.publicKey, isWrappedSol ? wrappedSolAccount.publicKey : payerTokenAccount, newVaultPublicKey, vaultAssociatedTokenAccount, hedgeStakingPoolPublicKey, feePoolAssociatedUshTokenAccount, vaultTypeAccountPublicKey, vaultTypeAccountInfo.collateralMint, history.publicKey, ushMintPublickey, new anchor_1.BN(depositAmount), overrideTime));
|
57
57
|
if (isWrappedSol) {
|
58
58
|
transaction.add(serum_1.TokenInstructions.closeAccount({
|
59
59
|
source: wrappedSolAccount.publicKey,
|
@@ -108,7 +108,7 @@ function buildCreateVaultTransaction(program, payerPublicKey, collateralType, de
|
|
108
108
|
signers.push(wrappedSolAccount);
|
109
109
|
}
|
110
110
|
console.log('hedgeStakingPoolPublicKey', hedgeStakingPoolPublicKey.toString());
|
111
|
-
transaction.add(yield createVaultInstruction(program, salt, payerPublicKey, isWrappedSol ? wrappedSolAccount.publicKey : payerTokenAccount, newVaultPublicKey, vaultAssociatedTokenAccount, hedgeStakingPoolPublicKey, feePoolAssociatedUshTokenAccount, vaultTypeAccountPublicKey, vaultTypeAccountInfo.collateralMint, history.publicKey, ushMintPublickey, depositAmount, overrideTime));
|
111
|
+
transaction.add(yield createVaultInstruction(program, salt, payerPublicKey, isWrappedSol ? wrappedSolAccount.publicKey : payerTokenAccount, newVaultPublicKey, vaultAssociatedTokenAccount, hedgeStakingPoolPublicKey, feePoolAssociatedUshTokenAccount, vaultTypeAccountPublicKey, vaultTypeAccountInfo.collateralMint, history.publicKey, ushMintPublickey, new anchor_1.BN(depositAmount), overrideTime));
|
112
112
|
if (isWrappedSol) {
|
113
113
|
transaction.add(serum_1.TokenInstructions.closeAccount({
|
114
114
|
source: wrappedSolAccount.publicKey,
|
@@ -24,7 +24,7 @@ function depositLiquidationPool(program, provider, payer, depositAmount, overrid
|
|
24
24
|
const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
|
25
25
|
const payerUshAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, ushMintPublickey, payer.publicKey);
|
26
26
|
const poolPosition = web3_js_1.Keypair.generate();
|
27
|
-
const transaction = new web3_js_1.Transaction().add(yield depositLiquidationPoolInstruction(program, payer.publicKey, payerUshAccount.address, poolPosition.publicKey, depositAmount, overrideStartTime));
|
27
|
+
const transaction = new web3_js_1.Transaction().add(yield depositLiquidationPoolInstruction(program, payer.publicKey, payerUshAccount.address, poolPosition.publicKey, new anchor_1.BN(depositAmount), overrideStartTime));
|
28
28
|
yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer, poolPosition]).catch(Errors_1.parseAnchorErrors);
|
29
29
|
return poolPosition.publicKey;
|
30
30
|
});
|
@@ -38,7 +38,7 @@ function depositLiquidationPoolInstruction(program, payerPublicKey, payerUshAcco
|
|
38
38
|
const ushMint = yield (0, Constants_1.getUshMintPublicKey)();
|
39
39
|
const vaultSystemState = yield (0, Constants_1.getVaultSystemStatePublicKey)();
|
40
40
|
return yield program.methods
|
41
|
-
.depositLiquidationPool(
|
41
|
+
.depositLiquidationPool(depositAmount, new anchor_1.BN(overrideStartTime !== null && overrideStartTime !== void 0 ? overrideStartTime : Math.floor(Date.now() / 1000)) // override current time
|
42
42
|
)
|
43
43
|
.accounts({
|
44
44
|
vaultSystemState: vaultSystemState,
|
@@ -22,7 +22,7 @@ const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfi
|
|
22
22
|
function depositStakingPool(program, provider, payer, mintPublicKey, depositAmount, overrideStartTime) {
|
23
23
|
return __awaiter(this, void 0, void 0, function* () {
|
24
24
|
const poolPosition = web3_js_1.Keypair.generate();
|
25
|
-
const transaction = new web3_js_1.Transaction().add(yield depositStakingPoolInstruction(program, payer.publicKey, poolPosition.publicKey, mintPublicKey, depositAmount, overrideStartTime));
|
25
|
+
const transaction = new web3_js_1.Transaction().add(yield depositStakingPoolInstruction(program, payer.publicKey, poolPosition.publicKey, mintPublicKey, new anchor_1.BN(depositAmount), overrideStartTime));
|
26
26
|
yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer, poolPosition]).catch(Errors_1.parseAnchorErrors);
|
27
27
|
return poolPosition.publicKey;
|
28
28
|
});
|
@@ -35,7 +35,7 @@ function depositStakingPoolInstruction(program, payerPublicKey, poolPositionPubl
|
|
35
35
|
const payersArbitraryTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(payerPublicKey, stakedTokenMintPublicKey);
|
36
36
|
const vaultSystemState = yield (0, Constants_1.getVaultSystemStatePublicKey)();
|
37
37
|
return yield program.methods
|
38
|
-
.depositStakingPool(
|
38
|
+
.depositStakingPool(depositAmount, new anchor_1.BN(overrideStartTime !== null && overrideStartTime !== void 0 ? overrideStartTime : Math.floor(Date.now() / 1000)) // override current time
|
39
39
|
)
|
40
40
|
.accounts({
|
41
41
|
payer: payerPublicKey,
|
@@ -38,7 +38,7 @@ function depositVault(program, provider, payer, vaultPublicKey, depositAmount, o
|
|
38
38
|
const hedgeStakingPoolAssociatedUshTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(hedgeStakingPoolPublicKey, ushMintPublickey);
|
39
39
|
const transaction = new web3_js_1.Transaction();
|
40
40
|
const signers = [payer, history];
|
41
|
-
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program,
|
41
|
+
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, vaultAccount.vaultType, vaultPublicKey, new anchor_1.BN(depositAmount), new anchor_1.BN(0), new anchor_1.BN(0), new anchor_1.BN(0), false, false);
|
42
42
|
if (vaultTypeAccountInfo.collateralMint.toString() === token_instructions_1.WRAPPED_SOL_MINT.toString()) {
|
43
43
|
transaction.add(web3_js_1.SystemProgram.createAccount({
|
44
44
|
fromPubkey: payer.publicKey,
|
@@ -53,7 +53,7 @@ function depositVault(program, provider, payer, vaultPublicKey, depositAmount, o
|
|
53
53
|
}));
|
54
54
|
signers.push(wrappedSolAccount);
|
55
55
|
}
|
56
|
-
transaction.add(yield depositVaultInstruction(program, vaultSystemStatePublicKey, payer.publicKey, vaultTypeAccountInfo.collateralMint.toString() === token_instructions_1.WRAPPED_SOL_MINT.toString() ? wrappedSolAccount.publicKey : payerTokenAccount, vaultPublicKey, vaultAssociatedCollateralAccountPublicKey, history.publicKey, vaultAccount.vaultType, vaultTypeAssociatedTokenAccount.address, hedgeStakingPoolPublicKey, hedgeStakingPoolAssociatedUshTokenAccount, vaultTypeAccountInfo.collateralMint, ushMintPublickey, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, depositAmount, overrideTime));
|
56
|
+
transaction.add(yield depositVaultInstruction(program, vaultSystemStatePublicKey, payer.publicKey, vaultTypeAccountInfo.collateralMint.toString() === token_instructions_1.WRAPPED_SOL_MINT.toString() ? wrappedSolAccount.publicKey : payerTokenAccount, vaultPublicKey, vaultAssociatedCollateralAccountPublicKey, history.publicKey, vaultAccount.vaultType, vaultTypeAssociatedTokenAccount.address, hedgeStakingPoolPublicKey, hedgeStakingPoolAssociatedUshTokenAccount, vaultTypeAccountInfo.collateralMint, ushMintPublickey, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, new anchor_1.BN(depositAmount), overrideTime));
|
57
57
|
if (vaultTypeAccountInfo.collateralMint.toString() === token_instructions_1.WRAPPED_SOL_MINT.toString()) {
|
58
58
|
transaction.add(serum_1.TokenInstructions.closeAccount({
|
59
59
|
source: wrappedSolAccount.publicKey,
|
@@ -69,7 +69,7 @@ exports.depositVault = depositVault;
|
|
69
69
|
function depositVaultInstruction(program, vaultSystemStatePublicKey, vaultOwner, vaultOwnerTokenAccount, vaultPublicKey, vaultAssociatedTokenAccount, historyPublicKey, vaultTypeAccountPublicKey, vaultTypeAssociatedTokenAccount, hedgeStakingPoolPublicKey, hedgeStakingPoolAssociatedUshTokenAccount, collateralMint, ushMintPublickey, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, depositAmount, overrideTime) {
|
70
70
|
return __awaiter(this, void 0, void 0, function* () {
|
71
71
|
return yield program.methods
|
72
|
-
.depositVault(
|
72
|
+
.depositVault(depositAmount, new anchor_1.BN(overrideTime !== null && overrideTime !== void 0 ? overrideTime : Math.floor(Date.now() / 1000)) // override override time
|
73
73
|
)
|
74
74
|
.accounts({
|
75
75
|
vaultSystemState: vaultSystemStatePublicKey,
|
@@ -35,7 +35,7 @@ function liquidateVault(program, provider, payer, vaultPublicKey, overrideTime)
|
|
35
35
|
const poolAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMint, liquidationPoolStatePublicKey, true);
|
36
36
|
const vaultTypeAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMint, vaultAccount.vaultType, true);
|
37
37
|
const hedgeStakingPoolAssociatedUshTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, ushMintPublickey, hedgeStakingPoolPublicKey, true);
|
38
|
-
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program,
|
38
|
+
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, vaultAccount.vaultType, vaultPublicKey, new anchor_1.BN(0), new anchor_1.BN(0), new anchor_1.BN(0), new anchor_1.BN(0), false, true);
|
39
39
|
const history = web3_js_1.Keypair.generate();
|
40
40
|
const newEra = web3_js_1.Keypair.generate();
|
41
41
|
const transaction = new web3_js_1.Transaction();
|
@@ -27,9 +27,9 @@ function loanVault(program, provider, payer, vaultPublicKey, loanAmount, overrid
|
|
27
27
|
const vaultTypeAccount = yield program.account.vaultType.fetch(vaultAccount.vaultType);
|
28
28
|
const vaultTypeAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccount.collateralMint, vaultAccount.vaultType, true);
|
29
29
|
const vaultAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccount.collateralMint, vaultPublicKey, true);
|
30
|
-
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program,
|
30
|
+
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, vaultAccount.vaultType, vaultPublicKey, new anchor_1.BN(0), new anchor_1.BN(0), new anchor_1.BN(loanAmount), new anchor_1.BN(0), false, false);
|
31
31
|
const history = web3_js_1.Keypair.generate();
|
32
|
-
const transaction = new web3_js_1.Transaction().add(yield loanVaultInstruction(program, payer.publicKey, payerUshAccount.address, vaultPublicKey, vaultAssociatedTokenAccount.address, history.publicKey, vaultAccount.vaultType, vaultTypeAssociatedTokenAccount.address, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, loanAmount, overrideTime));
|
32
|
+
const transaction = new web3_js_1.Transaction().add(yield loanVaultInstruction(program, payer.publicKey, payerUshAccount.address, vaultPublicKey, vaultAssociatedTokenAccount.address, history.publicKey, vaultAccount.vaultType, vaultTypeAssociatedTokenAccount.address, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, new anchor_1.BN(loanAmount), overrideTime));
|
33
33
|
yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer, history]);
|
34
34
|
return vaultPublicKey;
|
35
35
|
});
|
@@ -43,7 +43,7 @@ function loanVaultInstruction(program, payerPublicKey, ownerUshAccount, vaultPub
|
|
43
43
|
const [hedgeStakingPoolPublicKey] = yield (0, Constants_1.getPoolPublicKeyForMint)(hedgeMintPublickey);
|
44
44
|
const hedgeStakingPoolAssociatedUshTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(hedgeStakingPoolPublicKey, ushMintPublickey);
|
45
45
|
return yield program.methods
|
46
|
-
.loanVault(
|
46
|
+
.loanVault(loanAmount, new anchor_1.BN(overrideTime !== null && overrideTime !== void 0 ? overrideTime : Math.floor(Date.now() / 1000)) // override override time
|
47
47
|
)
|
48
48
|
.accounts({
|
49
49
|
vaultSystemState: vaultSystemStatePublicKey,
|
@@ -30,9 +30,9 @@ function redeemVault(program, provider, payer, vaultPublicKey, redeemAmount, tra
|
|
30
30
|
const vaultTypeAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccountInfo.collateralMint, vaultAccount.vaultType, true);
|
31
31
|
const vaultAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccountInfo.collateralMint, vaultPublicKey, true);
|
32
32
|
const payerTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccountInfo.collateralMint, payer.publicKey);
|
33
|
-
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program,
|
33
|
+
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, vaultAccount.vaultType, vaultPublicKey, new anchor_1.BN(0), new anchor_1.BN(0), new anchor_1.BN(0), new anchor_1.BN(0), true, false);
|
34
34
|
const history = web3_js_1.Keypair.generate();
|
35
|
-
const transaction = new web3_js_1.Transaction().add(yield redeemVaultInstruction(program, payer.publicKey, payerUshAccount.address, payerTokenAccount.address, vaultPublicKey, vaultAssociatedTokenAccount.address, history.publicKey, vaultAccount.vaultType, vaultTypeAssociatedTokenAccount.address, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, redeemAmount, transactionOverrideTime));
|
35
|
+
const transaction = new web3_js_1.Transaction().add(yield redeemVaultInstruction(program, payer.publicKey, payerUshAccount.address, payerTokenAccount.address, vaultPublicKey, vaultAssociatedTokenAccount.address, history.publicKey, vaultAccount.vaultType, vaultTypeAssociatedTokenAccount.address, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, new anchor_1.BN(redeemAmount), transactionOverrideTime));
|
36
36
|
yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer, history]);
|
37
37
|
return vaultPublicKey;
|
38
38
|
});
|
@@ -46,7 +46,7 @@ function redeemVaultInstruction(program, payerPublicKey, payerUshAccount, destin
|
|
46
46
|
const [hedgeStakingPoolPublicKey] = yield (0, Constants_1.getPoolPublicKeyForMint)(hedgeMintPublickey);
|
47
47
|
const hedgeStakingPoolAssociatedUshTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(hedgeStakingPoolPublicKey, ushMintPublickey);
|
48
48
|
return yield program.methods
|
49
|
-
.redeemVault(
|
49
|
+
.redeemVault(redeemAmount, new anchor_1.BN(transactionOverrideTime !== null && transactionOverrideTime !== void 0 ? transactionOverrideTime : Date.now() / 1000) // override start time
|
50
50
|
)
|
51
51
|
.accounts({
|
52
52
|
vaultSystemState: vaultSystemStatePublicKey,
|
@@ -59,12 +59,12 @@ const pythAccounts = {
|
|
59
59
|
};
|
60
60
|
const chainlinkAccounts = {
|
61
61
|
Testing: web3_js_1.SystemProgram.programId,
|
62
|
-
Devnet: new web3_js_1.PublicKey('
|
62
|
+
Devnet: new web3_js_1.PublicKey('HgTtcbcmp5BeThax5AU8vg4VwK79qAvAKKFMs8txMLW6'),
|
63
63
|
MainnetBeta: web3_js_1.SystemProgram.programId, // CHAINLINK NOT ON MAINNET YET
|
64
64
|
};
|
65
65
|
const switchboardAccounts = {
|
66
66
|
Testing: web3_js_1.SystemProgram.programId,
|
67
67
|
// Devnet: new PublicKey('GvDMxPzN1sCj7L26YDK2HnMRXEQmQ2aemov8YBtPS7vR'),
|
68
|
-
Devnet: new web3_js_1.PublicKey('
|
68
|
+
Devnet: new web3_js_1.PublicKey('GvDMxPzN1sCj7L26YDK2HnMRXEQmQ2aemov8YBtPS7vR'),
|
69
69
|
MainnetBeta: web3_js_1.SystemProgram.programId, // Switchboard V2 NOT ON MAINNET YET
|
70
70
|
};
|
@@ -28,9 +28,9 @@ function repayVault(program, provider, payer, vaultPublicKey, repayAmount, overr
|
|
28
28
|
const vaultTypeAccount = yield program.account.vaultType.fetch(vaultAccount.vaultType);
|
29
29
|
const vaultTypeAssociatedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(vaultAccount.vaultType, vaultTypeAccount.collateralMint);
|
30
30
|
const vaultAssociatedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(vaultPublicKey, vaultTypeAccount.collateralMint);
|
31
|
-
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program,
|
31
|
+
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, vaultAccount.vaultType, vaultPublicKey, new anchor_1.BN(0), new anchor_1.BN(0), new anchor_1.BN(0), new anchor_1.BN(Math.abs(repayAmount)), false, false);
|
32
32
|
const history = web3_js_1.Keypair.generate();
|
33
|
-
const transaction = new web3_js_1.Transaction().add(yield repayVaultInstruction(program, payer.publicKey, payerUshAccount.address, vaultPublicKey, vaultAssociatedTokenAccount, history.publicKey, vaultAccount.vaultType, vaultTypeAssociatedTokenAccount, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, repayAmount, overrideTime));
|
33
|
+
const transaction = new web3_js_1.Transaction().add(yield repayVaultInstruction(program, payer.publicKey, payerUshAccount.address, vaultPublicKey, vaultAssociatedTokenAccount, history.publicKey, vaultAccount.vaultType, vaultTypeAssociatedTokenAccount, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, new anchor_1.BN(repayAmount), overrideTime));
|
34
34
|
yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer, history]);
|
35
35
|
return vaultPublicKey;
|
36
36
|
});
|
@@ -44,7 +44,7 @@ function repayVaultInstruction(program, payerPublicKey, ownerUshAccount, vaultPu
|
|
44
44
|
const [hedgeStakingPoolPublicKey] = yield (0, Constants_1.getPoolPublicKeyForMint)(hedgeMintPublickey);
|
45
45
|
const hedgeStakingPoolAssociatedUshTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(hedgeStakingPoolPublicKey, ushMintPublickey);
|
46
46
|
return yield program.methods
|
47
|
-
.repayVault(
|
47
|
+
.repayVault(repayAmount, new anchor_1.BN(overrideTime !== null && overrideTime !== void 0 ? overrideTime : Math.floor(Date.now() / 1000)) // override override time
|
48
48
|
)
|
49
49
|
.accounts({
|
50
50
|
vaultSystemState: vaultSystemStatePublicKey,
|
@@ -17,21 +17,22 @@ function setVaultTypeStatus(program, provider, payer, vaultTypeAccount, deprecat
|
|
17
17
|
return __awaiter(this, void 0, void 0, function* () {
|
18
18
|
const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
|
19
19
|
const transaction = new web3_js_1.Transaction().add(yield setVaultTypeStatusInstruction(program, vaultSystemStatePublicKey, payer.publicKey, vaultTypeAccount, deprecated));
|
20
|
-
yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer]).catch(Errors_1.parseAnchorErrors);
|
20
|
+
yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer], provider === null || provider === void 0 ? void 0 : provider.opts).catch(Errors_1.parseAnchorErrors);
|
21
21
|
return vaultSystemStatePublicKey;
|
22
22
|
});
|
23
23
|
}
|
24
24
|
exports.setVaultTypeStatus = setVaultTypeStatus;
|
25
25
|
function setVaultTypeStatusInstruction(program, vaultSystemStatePublicKey, payerPublicKey, vaultTypeAccount, deprecated) {
|
26
26
|
return __awaiter(this, void 0, void 0, function* () {
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
27
|
+
const ix = program.instruction.setVaultTypeStatus(deprecated, {
|
28
|
+
accounts: {
|
29
|
+
payer: payerPublicKey,
|
30
|
+
vaultSystemState: vaultSystemStatePublicKey,
|
31
|
+
vaultType: vaultTypeAccount,
|
32
|
+
},
|
33
|
+
signers: []
|
34
|
+
});
|
35
|
+
return ix;
|
35
36
|
});
|
36
37
|
}
|
37
38
|
exports.setVaultTypeStatusInstruction = setVaultTypeStatusInstruction;
|
@@ -34,8 +34,8 @@ function withdrawVault(program, provider, payer, vaultPublicKey, withdrawAmount,
|
|
34
34
|
const destinationTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccountInfo.collateralMint, payer.publicKey);
|
35
35
|
const [hedgeStakingPoolPublicKey] = yield (0, Constants_1.getPoolPublicKeyForMint)(yield (0, Constants_1.getHedgeMintPublicKey)());
|
36
36
|
const hedgeStakingPoolAssociatedUshTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(hedgeStakingPoolPublicKey, ushMintPublickey);
|
37
|
-
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program,
|
38
|
-
const transaction = new web3_js_1.Transaction().add(yield withdrawVaultInstruction(program, vaultSystemStatePublicKey, payer.publicKey, destinationTokenAccount.address, vaultPublicKey, vaultAssociatedCollateralAccount.address, vaultAccount.vaultType, vaultTypeAssociatedTokenAccount.address, hedgeStakingPoolPublicKey, hedgeStakingPoolAssociatedUshTokenAccount, ushMintPublickey, history.publicKey, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, withdrawAmount, overrideTime));
|
37
|
+
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, vaultAccount.vaultType, vaultPublicKey, new anchor_1.BN(0), new anchor_1.BN(Math.abs(withdrawAmount)), new anchor_1.BN(0), new anchor_1.BN(0), false, false);
|
38
|
+
const transaction = new web3_js_1.Transaction().add(yield withdrawVaultInstruction(program, vaultSystemStatePublicKey, payer.publicKey, destinationTokenAccount.address, vaultPublicKey, vaultAssociatedCollateralAccount.address, vaultAccount.vaultType, vaultTypeAssociatedTokenAccount.address, hedgeStakingPoolPublicKey, hedgeStakingPoolAssociatedUshTokenAccount, ushMintPublickey, history.publicKey, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, new anchor_1.BN(withdrawAmount), overrideTime));
|
39
39
|
yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer, history]);
|
40
40
|
return vaultPublicKey;
|
41
41
|
});
|
@@ -44,7 +44,7 @@ exports.withdrawVault = withdrawVault;
|
|
44
44
|
function withdrawVaultInstruction(program, vaultSystemStatePublicKey, payerPublicKey, destinationTokenAccount, vaultPublickey, vaultAssociatedCollateralPublicKey, vaultTypeAccount, vaultTypeAssociatedTokenAccount, hedgeStakingPoolPublicKey, hedgeStakingPoolAssociatedUshTokenAccount, ushMint, historyPublicKey, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, withdrawAmount, overrideTime) {
|
45
45
|
return __awaiter(this, void 0, void 0, function* () {
|
46
46
|
return yield program.methods
|
47
|
-
.withdrawVault(
|
47
|
+
.withdrawVault(withdrawAmount, new anchor_1.BN(overrideTime !== null && overrideTime !== void 0 ? overrideTime : Math.floor(Date.now() / 1000)) // override override time
|
48
48
|
)
|
49
49
|
.accounts({
|
50
50
|
vaultSystemState: vaultSystemStatePublicKey,
|