hedge-web3 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- 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/withdrawVault.d.ts +3 -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 +2 -2
- package/lib/instructions/loanVault.js +2 -2
- package/lib/instructions/redeemVault.js +2 -2
- package/lib/instructions/repayVault.js +2 -2
- package/lib/instructions/withdrawVault.js +2 -2
- 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 +3 -3
- package/src/instructions/loanVault.ts +3 -3
- package/src/instructions/redeemVault.ts +3 -3
- package/src/instructions/repayVault.ts +3 -3
- package/src/instructions/withdrawVault.ts +3 -3
@@ -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,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>;
|
@@ -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,
|
@@ -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,
|
@@ -29,7 +29,7 @@ function loanVault(program, provider, payer, vaultPublicKey, loanAmount, overrid
|
|
29
29
|
const vaultAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccount.collateralMint, vaultPublicKey, true);
|
30
30
|
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, provider, vaultAccount.vaultType, vaultPublicKey, 0, loanAmount, 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,
|
@@ -32,7 +32,7 @@ function redeemVault(program, provider, payer, vaultPublicKey, redeemAmount, tra
|
|
32
32
|
const payerTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccountInfo.collateralMint, payer.publicKey);
|
33
33
|
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, provider, vaultAccount.vaultType, vaultPublicKey, 0, 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,
|
@@ -30,7 +30,7 @@ function repayVault(program, provider, payer, vaultPublicKey, repayAmount, overr
|
|
30
30
|
const vaultAssociatedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(vaultPublicKey, vaultTypeAccount.collateralMint);
|
31
31
|
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, provider, vaultAccount.vaultType, vaultPublicKey, 0, repayAmount * -1, 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,
|
@@ -35,7 +35,7 @@ function withdrawVault(program, provider, payer, vaultPublicKey, withdrawAmount,
|
|
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
37
|
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, provider, vaultAccount.vaultType, vaultPublicKey, withdrawAmount * -1, 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, withdrawAmount, overrideTime));
|
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,
|
package/package.json
CHANGED
@@ -93,7 +93,7 @@ export async function createVault(
|
|
93
93
|
vaultTypeAccountInfo.collateralMint,
|
94
94
|
history.publicKey,
|
95
95
|
ushMintPublickey,
|
96
|
-
depositAmount,
|
96
|
+
new BN(depositAmount),
|
97
97
|
overrideTime
|
98
98
|
)
|
99
99
|
)
|
@@ -187,7 +187,7 @@ export async function buildCreateVaultTransaction(
|
|
187
187
|
vaultTypeAccountInfo.collateralMint,
|
188
188
|
history.publicKey,
|
189
189
|
ushMintPublickey,
|
190
|
-
depositAmount,
|
190
|
+
new BN(depositAmount),
|
191
191
|
overrideTime
|
192
192
|
)
|
193
193
|
)
|
@@ -221,7 +221,7 @@ export async function createVaultInstruction(
|
|
221
221
|
collateralMint: PublicKey,
|
222
222
|
historyPublicKey: PublicKey,
|
223
223
|
ushMintPublickey: PublicKey,
|
224
|
-
depositAmount:
|
224
|
+
depositAmount: BN,
|
225
225
|
overrideTime?: number
|
226
226
|
): Promise<TransactionInstruction> {
|
227
227
|
const vaultSystemStatePublicKey = await getVaultSystemStatePublicKey()
|
@@ -24,7 +24,7 @@ export async function depositLiquidationPool(
|
|
24
24
|
program: Program<Vault>,
|
25
25
|
provider: Provider,
|
26
26
|
payer: Signer,
|
27
|
-
depositAmount:
|
27
|
+
depositAmount: BN,
|
28
28
|
overrideStartTime?: number
|
29
29
|
): Promise<PublicKey> {
|
30
30
|
const ushMintPublickey = await getUshMintPublicKey()
|
@@ -42,7 +42,7 @@ export async function depositLiquidationPool(
|
|
42
42
|
payer.publicKey,
|
43
43
|
payerUshAccount.address,
|
44
44
|
poolPosition.publicKey,
|
45
|
-
depositAmount,
|
45
|
+
new BN(depositAmount),
|
46
46
|
overrideStartTime
|
47
47
|
)
|
48
48
|
)
|
@@ -55,7 +55,7 @@ export async function depositLiquidationPoolInstruction(
|
|
55
55
|
payerPublicKey: PublicKey,
|
56
56
|
payerUshAccount: PublicKey,
|
57
57
|
poolPositionPublicKey: PublicKey,
|
58
|
-
depositAmount:
|
58
|
+
depositAmount: BN,
|
59
59
|
overrideStartTime?: number
|
60
60
|
): Promise<TransactionInstruction> {
|
61
61
|
const liquidationPoolStatePublicKey = await getLiquidationPoolStatePublicKey()
|
@@ -68,7 +68,7 @@ export async function depositLiquidationPoolInstruction(
|
|
68
68
|
|
69
69
|
return await program.methods
|
70
70
|
.depositLiquidationPool(
|
71
|
-
|
71
|
+
depositAmount,
|
72
72
|
new BN(overrideStartTime ?? Math.floor(Date.now() / 1000)) // override current time
|
73
73
|
)
|
74
74
|
.accounts({
|
@@ -30,7 +30,7 @@ export async function depositStakingPool(
|
|
30
30
|
payer.publicKey,
|
31
31
|
poolPosition.publicKey,
|
32
32
|
mintPublicKey,
|
33
|
-
depositAmount,
|
33
|
+
new BN(depositAmount),
|
34
34
|
overrideStartTime
|
35
35
|
)
|
36
36
|
)
|
@@ -43,7 +43,7 @@ export async function depositStakingPoolInstruction(
|
|
43
43
|
payerPublicKey: PublicKey,
|
44
44
|
poolPositionPublicKey: PublicKey,
|
45
45
|
stakedTokenMintPublicKey: PublicKey,
|
46
|
-
depositAmount:
|
46
|
+
depositAmount: BN,
|
47
47
|
overrideStartTime?: number
|
48
48
|
): Promise<TransactionInstruction> {
|
49
49
|
const [poolPublickey] = await getPoolPublicKeyForMint(stakedTokenMintPublicKey)
|
@@ -53,7 +53,7 @@ export async function depositStakingPoolInstruction(
|
|
53
53
|
|
54
54
|
return await program.methods
|
55
55
|
.depositStakingPool(
|
56
|
-
|
56
|
+
depositAmount,
|
57
57
|
new BN(overrideStartTime ?? Math.floor(Date.now() / 1000)) // override current time
|
58
58
|
)
|
59
59
|
.accounts({
|
@@ -111,7 +111,7 @@ export async function depositVault(
|
|
111
111
|
oldSmallerPublicKey,
|
112
112
|
newSmallerPublicKey,
|
113
113
|
newLargerPublicKey,
|
114
|
-
depositAmount,
|
114
|
+
new BN(depositAmount),
|
115
115
|
overrideTime
|
116
116
|
)
|
117
117
|
)
|
@@ -146,12 +146,12 @@ export async function depositVaultInstruction(
|
|
146
146
|
oldSmallerPublicKey: PublicKey,
|
147
147
|
newSmallerPublicKey: PublicKey,
|
148
148
|
newLargerPublicKey: PublicKey,
|
149
|
-
depositAmount:
|
149
|
+
depositAmount: BN,
|
150
150
|
overrideTime?: number
|
151
151
|
): Promise<TransactionInstruction> {
|
152
152
|
return await program.methods
|
153
153
|
.depositVault(
|
154
|
-
|
154
|
+
depositAmount,
|
155
155
|
new BN(overrideTime ?? Math.floor(Date.now() / 1000)) // override override time
|
156
156
|
)
|
157
157
|
.accounts({
|
@@ -82,7 +82,7 @@ export async function loanVault(
|
|
82
82
|
oldSmallerPublicKey,
|
83
83
|
newSmallerPublicKey,
|
84
84
|
newLargerPublicKey,
|
85
|
-
loanAmount,
|
85
|
+
new BN(loanAmount),
|
86
86
|
overrideTime
|
87
87
|
)
|
88
88
|
)
|
@@ -102,7 +102,7 @@ export async function loanVaultInstruction(
|
|
102
102
|
oldSmallerPublicKey: PublicKey,
|
103
103
|
newSmallerPublicKey: PublicKey,
|
104
104
|
newLargerPublicKey: PublicKey,
|
105
|
-
loanAmount:
|
105
|
+
loanAmount: BN,
|
106
106
|
overrideTime?: number
|
107
107
|
): Promise<TransactionInstruction> {
|
108
108
|
const vaultSystemStatePublicKey = await getVaultSystemStatePublicKey()
|
@@ -116,7 +116,7 @@ export async function loanVaultInstruction(
|
|
116
116
|
|
117
117
|
return await program.methods
|
118
118
|
.loanVault(
|
119
|
-
|
119
|
+
loanAmount,
|
120
120
|
new BN(overrideTime ?? Math.floor(Date.now() / 1000)) // override override time
|
121
121
|
)
|
122
122
|
.accounts({
|
@@ -91,7 +91,7 @@ export async function redeemVault(
|
|
91
91
|
oldSmallerPublicKey,
|
92
92
|
newSmallerPublicKey,
|
93
93
|
newLargerPublicKey,
|
94
|
-
redeemAmount,
|
94
|
+
new BN(redeemAmount),
|
95
95
|
transactionOverrideTime
|
96
96
|
)
|
97
97
|
)
|
@@ -112,7 +112,7 @@ export async function redeemVaultInstruction(
|
|
112
112
|
oldSmallerPublicKey: PublicKey,
|
113
113
|
newSmallerPublicKey: PublicKey,
|
114
114
|
newLargerPublicKey: PublicKey,
|
115
|
-
redeemAmount:
|
115
|
+
redeemAmount: BN,
|
116
116
|
transactionOverrideTime?: number
|
117
117
|
): Promise<TransactionInstruction> {
|
118
118
|
const vaultSystemStatePublicKey = await getVaultSystemStatePublicKey()
|
@@ -125,7 +125,7 @@ export async function redeemVaultInstruction(
|
|
125
125
|
)
|
126
126
|
return await program.methods
|
127
127
|
.redeemVault(
|
128
|
-
|
128
|
+
redeemAmount,
|
129
129
|
new BN(transactionOverrideTime ?? Date.now() / 1000) // override start time
|
130
130
|
)
|
131
131
|
.accounts({
|
@@ -72,7 +72,7 @@ export async function repayVault(
|
|
72
72
|
oldSmallerPublicKey,
|
73
73
|
newSmallerPublicKey,
|
74
74
|
newLargerPublicKey,
|
75
|
-
repayAmount,
|
75
|
+
new BN(repayAmount),
|
76
76
|
overrideTime
|
77
77
|
)
|
78
78
|
)
|
@@ -92,7 +92,7 @@ export async function repayVaultInstruction(
|
|
92
92
|
oldSmallerPublicKey: PublicKey,
|
93
93
|
newSmallerPublicKey: PublicKey,
|
94
94
|
newLargerPublicKey: PublicKey,
|
95
|
-
repayAmount:
|
95
|
+
repayAmount: BN,
|
96
96
|
overrideTime?: number
|
97
97
|
): Promise<TransactionInstruction> {
|
98
98
|
const vaultSystemStatePublicKey = await getVaultSystemStatePublicKey()
|
@@ -106,7 +106,7 @@ export async function repayVaultInstruction(
|
|
106
106
|
|
107
107
|
return await program.methods
|
108
108
|
.repayVault(
|
109
|
-
|
109
|
+
repayAmount,
|
110
110
|
new BN(overrideTime ?? Math.floor(Date.now() / 1000)) // override override time
|
111
111
|
)
|
112
112
|
.accounts({
|
@@ -95,7 +95,7 @@ export async function withdrawVault(
|
|
95
95
|
oldSmallerPublicKey,
|
96
96
|
newSmallerPublicKey,
|
97
97
|
newLargerPublicKey,
|
98
|
-
withdrawAmount,
|
98
|
+
new BN(withdrawAmount),
|
99
99
|
overrideTime
|
100
100
|
)
|
101
101
|
)
|
@@ -119,12 +119,12 @@ export async function withdrawVaultInstruction(
|
|
119
119
|
oldSmallerPublicKey: PublicKey,
|
120
120
|
newSmallerPublicKey: PublicKey,
|
121
121
|
newLargerPublicKey: PublicKey,
|
122
|
-
withdrawAmount:
|
122
|
+
withdrawAmount: BN,
|
123
123
|
overrideTime?: number
|
124
124
|
): Promise<TransactionInstruction> {
|
125
125
|
return await program.methods
|
126
126
|
.withdrawVault(
|
127
|
-
|
127
|
+
withdrawAmount,
|
128
128
|
new BN(overrideTime ?? Math.floor(Date.now() / 1000)) // override override time
|
129
129
|
)
|
130
130
|
.accounts({
|