hedge-web3 0.1.41 → 0.1.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/declarations/Constants.d.ts +1 -1
- package/declarations/idl/vault.d.ts +154 -8
- package/declarations/index.d.ts +1 -1
- package/declarations/instructions/liquidateVault.d.ts +1 -1
- package/declarations/instructions/updateVaultType.d.ts +15 -0
- package/declarations/state/VaultAccount.d.ts +8 -6
- package/declarations/state/VaultType.d.ts +24 -0
- package/declarations/utils/Sender.d.ts +2 -0
- package/declarations/utils/sendAndConfirmWithDebug.d.ts +2 -0
- package/lib/Constants.js +1 -1
- package/lib/idl/vault.js +154 -8
- package/lib/index.js +1 -1
- package/lib/instructions/createStakingPool.js +1 -0
- package/lib/instructions/depositVault.js +7 -7
- package/lib/instructions/liquidateVault.js +5 -7
- package/lib/instructions/loanVault.js +7 -6
- package/lib/instructions/redeemVault.js +4 -5
- package/lib/instructions/refreshOraclePrice.js +2 -2
- package/lib/instructions/repayVault.js +4 -5
- package/lib/instructions/updateVaultType.js +47 -0
- package/lib/instructions/withdrawVault.js +4 -5
- package/lib/state/VaultAccount.js +9 -8
- package/lib/state/VaultType.js +32 -0
- package/lib/utils/Errors.js +1 -0
- package/lib/utils/Sender.js +32 -0
- package/lib/utils/getLinkedListAccounts.js +15 -15
- package/lib/utils/sendAndConfirmWithDebug.js +35 -0
- package/package.json +2 -2
- package/src/Constants.ts +1 -1
- package/src/idl/vault.ts +308 -16
- package/src/index.ts +1 -1
- package/src/instructions/createStakingPool.ts +1 -0
- package/src/instructions/depositVault.ts +8 -8
- package/src/instructions/liquidateVault.ts +5 -7
- package/src/instructions/loanVault.ts +11 -8
- package/src/instructions/redeemVault.ts +4 -5
- package/src/instructions/refreshOraclePrice.ts +2 -2
- package/src/instructions/repayVault.ts +4 -5
- package/src/instructions/{setVaultTypeStatus.ts → updateVaultType.ts} +39 -8
- package/src/instructions/withdrawVault.ts +4 -5
- package/src/state/VaultAccount.ts +14 -10
- package/src/utils/Errors.ts +1 -0
- package/src/utils/getLinkedListAccounts.ts +16 -16
@@ -16,15 +16,15 @@ const spl_token_1 = require("@solana/spl-token");
|
|
16
16
|
const web3_js_1 = require("@solana/web3.js");
|
17
17
|
const getLinkedListAccounts_1 = require("../utils/getLinkedListAccounts");
|
18
18
|
const Constants_1 = require("../Constants");
|
19
|
+
const token_instructions_1 = require("@project-serum/serum/lib/token-instructions");
|
19
20
|
function depositVault(program, provider, payer, vaultPublicKey, depositAmount, overrideTime) {
|
20
21
|
return __awaiter(this, void 0, void 0, function* () {
|
21
22
|
const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
|
22
23
|
// Prep the user to get USH back out at some point
|
23
24
|
yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, ushMintPublickey, payer.publicKey);
|
24
25
|
const vaultAccount = yield program.account.vault.fetch(vaultPublicKey);
|
25
|
-
const
|
26
|
-
const
|
27
|
-
const vaultTypeAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccountInfo.collateralMint, vaultTypeAccountPublicKey, true);
|
26
|
+
const vaultTypeAccountInfo = yield program.account.vaultType.fetch(vaultAccount.vaultType);
|
27
|
+
const vaultTypeAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccountInfo.collateralMint, vaultAccount.vaultType, true);
|
28
28
|
const payerTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(payer.publicKey, vaultTypeAccountInfo.collateralMint);
|
29
29
|
const vaultAssociatedCollateralAccountPublicKey = yield (0, Constants_1.findAssociatedTokenAddress)(vaultPublicKey, vaultTypeAccountInfo.collateralMint);
|
30
30
|
const history = web3_js_1.Keypair.generate();
|
@@ -34,8 +34,8 @@ function depositVault(program, provider, payer, vaultPublicKey, depositAmount, o
|
|
34
34
|
const hedgeStakingPoolAssociatedUshTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(hedgeStakingPoolPublicKey, ushMintPublickey);
|
35
35
|
const transaction = new web3_js_1.Transaction();
|
36
36
|
const signers = [payer, history];
|
37
|
-
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, provider,
|
38
|
-
if (
|
37
|
+
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, provider, vaultAccount.vaultType, vaultPublicKey, depositAmount, 0, false, false);
|
38
|
+
if (vaultTypeAccountInfo.collateralMint.toString() === token_instructions_1.WRAPPED_SOL_MINT.toString()) {
|
39
39
|
transaction.add(web3_js_1.SystemProgram.createAccount({
|
40
40
|
fromPubkey: payer.publicKey,
|
41
41
|
lamports: depositAmount + 2.04e6,
|
@@ -49,8 +49,8 @@ function depositVault(program, provider, payer, vaultPublicKey, depositAmount, o
|
|
49
49
|
}));
|
50
50
|
signers.push(wrappedSolAccount);
|
51
51
|
}
|
52
|
-
transaction.add(yield depositVaultInstruction(program, vaultSystemStatePublicKey, payer.publicKey,
|
53
|
-
if (
|
52
|
+
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));
|
53
|
+
if (vaultTypeAccountInfo.collateralMint.toString() === token_instructions_1.WRAPPED_SOL_MINT.toString()) {
|
54
54
|
transaction.add(serum_1.TokenInstructions.closeAccount({
|
55
55
|
source: wrappedSolAccount.publicKey,
|
56
56
|
destination: payer.publicKey,
|
@@ -18,8 +18,7 @@ const Constants_1 = require("../Constants");
|
|
18
18
|
function liquidateVault(program, provider, payer, vaultPublicKey, overrideTime) {
|
19
19
|
return __awaiter(this, void 0, void 0, function* () {
|
20
20
|
const vaultAccount = yield program.account.vault.fetch(vaultPublicKey);
|
21
|
-
const
|
22
|
-
const vaultTypeAccountInfo = yield program.account.vaultType.fetch(vaultTypeAccountPublicKey);
|
21
|
+
const vaultTypeAccountInfo = yield program.account.vaultType.fetch(vaultAccount.vaultType);
|
23
22
|
const collateralMint = vaultTypeAccountInfo.collateralMint;
|
24
23
|
const hedgeMintPublickey = yield (0, Constants_1.getHedgeMintPublicKey)();
|
25
24
|
const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
|
@@ -30,24 +29,23 @@ function liquidateVault(program, provider, payer, vaultPublicKey, overrideTime)
|
|
30
29
|
const feePoolAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMint, hedgeStakingPoolPublicKey, true);
|
31
30
|
const vaultAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMint, vaultPublicKey, true);
|
32
31
|
const poolAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMint, liquidationPoolStatePublicKey, true);
|
33
|
-
const vaultTypeAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMint,
|
32
|
+
const vaultTypeAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMint, vaultAccount.vaultType, true);
|
34
33
|
const hedgeStakingPoolAssociatedUshTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, ushMintPublickey, hedgeStakingPoolPublicKey, true);
|
35
|
-
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, provider,
|
34
|
+
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, provider, vaultAccount.vaultType, vaultPublicKey, 0, 0, false, true);
|
36
35
|
const history = web3_js_1.Keypair.generate();
|
37
36
|
const newEra = web3_js_1.Keypair.generate();
|
38
37
|
const transaction = new web3_js_1.Transaction();
|
39
|
-
transaction.add(yield liquidateVaultInstruction(program, payer.publicKey, payerAssociatedTokenAccount.address, vaultPublicKey, vaultAssociatedTokenAccount.address, liquidationPoolStatePublicKey, poolStateInfo.currentEra, poolAssociatedTokenAccount.address, history.publicKey, newEra.publicKey, hedgeStakingPoolPublicKey, feePoolAssociatedTokenAccount.address, hedgeStakingPoolAssociatedUshTokenAccount.address, collateralMint, vaultTypeAssociatedTokenAccount.address, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, vaultAccount.
|
38
|
+
transaction.add(yield liquidateVaultInstruction(program, payer.publicKey, payerAssociatedTokenAccount.address, vaultPublicKey, vaultAssociatedTokenAccount.address, liquidationPoolStatePublicKey, poolStateInfo.currentEra, poolAssociatedTokenAccount.address, history.publicKey, newEra.publicKey, hedgeStakingPoolPublicKey, feePoolAssociatedTokenAccount.address, hedgeStakingPoolAssociatedUshTokenAccount.address, collateralMint, vaultTypeAssociatedTokenAccount.address, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, vaultAccount.vaultType, overrideTime));
|
40
39
|
yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer, history, newEra]);
|
41
40
|
return vaultPublicKey;
|
42
41
|
});
|
43
42
|
}
|
44
43
|
exports.liquidateVault = liquidateVault;
|
45
|
-
function liquidateVaultInstruction(program, payerPublicKey, payerAssociatedTokenAccount, vaultPublickey, vaultAssociatedTokenAccount, poolState, poolEra, poolAssociatedTokenAccount, historyPublicKey, newEraPublicKey, feePool, feePoolAssociatedTokenAccount, hedgeStakingPoolAssociatedUshTokenAccount, collateralMint, vaultTypeAssociatedTokenAccount, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey,
|
44
|
+
function liquidateVaultInstruction(program, payerPublicKey, payerAssociatedTokenAccount, vaultPublickey, vaultAssociatedTokenAccount, poolState, poolEra, poolAssociatedTokenAccount, historyPublicKey, newEraPublicKey, feePool, feePoolAssociatedTokenAccount, hedgeStakingPoolAssociatedUshTokenAccount, collateralMint, vaultTypeAssociatedTokenAccount, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, vaultTypeAccount, overrideTime) {
|
46
45
|
return __awaiter(this, void 0, void 0, function* () {
|
47
46
|
const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
|
48
47
|
const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
|
49
48
|
const liquidationPoolUshAccountPublickey = yield (0, Constants_1.getLiquidationPoolUshAccountPublicKey)();
|
50
|
-
const vaultTypeAccount = yield (0, Constants_1.getVaultTypeAccountPublicKey)(collateralType);
|
51
49
|
return yield program.methods
|
52
50
|
.liquidateVault(new anchor_1.BN(overrideTime !== null && overrideTime !== void 0 ? overrideTime : Math.floor(Date.now() / 1000)) // override override time
|
53
51
|
)
|
@@ -15,19 +15,20 @@ const spl_token_1 = require("@solana/spl-token");
|
|
15
15
|
const web3_js_1 = require("@solana/web3.js");
|
16
16
|
const getLinkedListAccounts_1 = require("../utils/getLinkedListAccounts");
|
17
17
|
const Constants_1 = require("../Constants");
|
18
|
+
const Errors_1 = require("../utils/Errors");
|
19
|
+
const fs = require('fs');
|
18
20
|
function loanVault(program, provider, payer, vaultPublicKey, loanAmount, overrideTime) {
|
19
21
|
return __awaiter(this, void 0, void 0, function* () {
|
20
22
|
const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
|
21
23
|
const payerUshAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, ushMintPublickey, payer.publicKey);
|
22
24
|
const vaultAccount = yield program.account.vault.fetch(vaultPublicKey);
|
23
|
-
const
|
24
|
-
const
|
25
|
-
const vaultTypeAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccount.collateralMint, vaultTypeAccountPublicKey, true);
|
25
|
+
const vaultTypeAccount = yield program.account.vaultType.fetch(vaultAccount.vaultType);
|
26
|
+
const vaultTypeAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccount.collateralMint, vaultAccount.vaultType, true);
|
26
27
|
const vaultAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccount.collateralMint, vaultPublicKey, true);
|
27
|
-
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, provider,
|
28
|
+
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, provider, vaultAccount.vaultType, vaultPublicKey, 0, loanAmount, false, false);
|
28
29
|
const history = web3_js_1.Keypair.generate();
|
29
|
-
const transaction = new web3_js_1.Transaction().add(yield loanVaultInstruction(program, payer.publicKey, payerUshAccount.address, vaultPublicKey, vaultAssociatedTokenAccount.address, history.publicKey,
|
30
|
-
yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer, history]);
|
30
|
+
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));
|
31
|
+
yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer, history]).catch(Errors_1.parseAnchorErrors);
|
31
32
|
return vaultPublicKey;
|
32
33
|
});
|
33
34
|
}
|
@@ -22,14 +22,13 @@ function redeemVault(program, provider, payer, vaultPublicKey, redeemAmount, tra
|
|
22
22
|
// Prep the user to get USH back out at some point
|
23
23
|
const payerUshAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, ushMintPublickey, payer.publicKey);
|
24
24
|
const vaultAccount = yield program.account.vault.fetch(vaultPublicKey);
|
25
|
-
const
|
26
|
-
const
|
27
|
-
const vaultTypeAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccountInfo.collateralMint, vaultTypeAccountPublicKey, true);
|
25
|
+
const vaultTypeAccountInfo = yield program.account.vaultType.fetch(vaultAccount.vaultType);
|
26
|
+
const vaultTypeAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccountInfo.collateralMint, vaultAccount.vaultType, true);
|
28
27
|
const vaultAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccountInfo.collateralMint, vaultPublicKey, true);
|
29
28
|
const payerTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccountInfo.collateralMint, payer.publicKey);
|
30
|
-
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, provider,
|
29
|
+
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, provider, vaultAccount.vaultType, vaultPublicKey, 0, 0, true, false);
|
31
30
|
const history = web3_js_1.Keypair.generate();
|
32
|
-
const transaction = new web3_js_1.Transaction().add(yield redeemVaultInstruction(program, payer.publicKey, payerUshAccount.address, payerTokenAccount.address, vaultPublicKey, vaultAssociatedTokenAccount.address, history.publicKey,
|
31
|
+
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));
|
33
32
|
yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer, history]);
|
34
33
|
return vaultPublicKey;
|
35
34
|
});
|
@@ -32,7 +32,7 @@ function refreshOraclePriceInstruction(program, collateralType, network, overrid
|
|
32
32
|
.accounts({
|
33
33
|
oracleInfoAccount: oracleInfoAccount,
|
34
34
|
vaultTypeAccount: vaultTypeAccount,
|
35
|
-
oracleChainlink:
|
35
|
+
oracleChainlink: chainlinkAccounts[network],
|
36
36
|
oraclePyth: pythAccounts[network],
|
37
37
|
oracleSwitchboard: switchboardAccounts[network],
|
38
38
|
systemProgram: web3_js_1.SystemProgram.programId,
|
@@ -52,7 +52,7 @@ const pythAccounts = {
|
|
52
52
|
Devnet: new web3_js_1.PublicKey('J83w4HKfqxwcq3BEMMkPFSppX3gqekLyLJBexebFVkix'),
|
53
53
|
MainnetBeta: new web3_js_1.PublicKey('H6ARHf6YXhGYeQfUzQNGk6rDNnLBQKrenN712K4AQJEG'),
|
54
54
|
};
|
55
|
-
const
|
55
|
+
const chainlinkAccounts = {
|
56
56
|
Testing: web3_js_1.SystemProgram.programId,
|
57
57
|
Devnet: new web3_js_1.PublicKey('FmAmfoyPXiA8Vhhe6MZTr3U6rZfEZ1ctEHay1ysqCqcf'),
|
58
58
|
MainnetBeta: web3_js_1.SystemProgram.programId, // CHAINLINK NOT ON MAINNET YET
|
@@ -21,13 +21,12 @@ function repayVault(program, provider, payer, vaultPublicKey, repayAmount, overr
|
|
21
21
|
// Prep the user to get USH back out at some point
|
22
22
|
const payerUshAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, ushMintPublickey, payer.publicKey);
|
23
23
|
const vaultAccount = yield program.account.vault.fetch(vaultPublicKey);
|
24
|
-
const
|
25
|
-
const
|
26
|
-
const vaultTypeAssociatedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(vaultTypeAccountPublicKey, vaultTypeAccount.collateralMint);
|
24
|
+
const vaultTypeAccount = yield program.account.vaultType.fetch(vaultAccount.vaultType);
|
25
|
+
const vaultTypeAssociatedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(vaultAccount.vaultType, vaultTypeAccount.collateralMint);
|
27
26
|
const vaultAssociatedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(vaultPublicKey, vaultTypeAccount.collateralMint);
|
28
|
-
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, provider,
|
27
|
+
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, provider, vaultAccount.vaultType, vaultPublicKey, 0, repayAmount * -1, false, false);
|
29
28
|
const history = web3_js_1.Keypair.generate();
|
30
|
-
const transaction = new web3_js_1.Transaction().add(yield repayVaultInstruction(program, payer.publicKey, payerUshAccount.address, vaultPublicKey, vaultAssociatedTokenAccount, history.publicKey,
|
29
|
+
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));
|
31
30
|
yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer, history]);
|
32
31
|
return vaultPublicKey;
|
33
32
|
});
|
@@ -0,0 +1,47 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
exports.updateVaultTypeStatusInstruction = exports.updateVaultType = void 0;
|
13
|
+
const web3_js_1 = require("@solana/web3.js");
|
14
|
+
const Constants_1 = require("../Constants");
|
15
|
+
function updateVaultType(program, provider, payer, vaultTypeAccount, oracleInfoAccount, config) {
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
17
|
+
const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
|
18
|
+
const transaction = new web3_js_1.Transaction().add(yield updateVaultTypeStatusInstruction(program, vaultSystemStatePublicKey, payer.publicKey, vaultTypeAccount, oracleInfoAccount, config));
|
19
|
+
yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer]);
|
20
|
+
return vaultSystemStatePublicKey;
|
21
|
+
});
|
22
|
+
}
|
23
|
+
exports.updateVaultType = updateVaultType;
|
24
|
+
function updateVaultTypeStatusInstruction(program, vaultSystemStatePublicKey, payerPublicKey, vaultTypeAccount, oracleInfoAccount, vaultTypeConfig) {
|
25
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
27
|
+
const config = {
|
28
|
+
maxDebtExtended: (_a = vaultTypeConfig.maxDebtExtended) !== null && _a !== void 0 ? _a : null,
|
29
|
+
minDebtPerVault: (_b = vaultTypeConfig.minDebtPerVault) !== null && _b !== void 0 ? _b : null,
|
30
|
+
loanInitFee: (_c = vaultTypeConfig.loanInitFee) !== null && _c !== void 0 ? _c : null,
|
31
|
+
oracleChainlink: (_d = vaultTypeConfig.oracleChainlink) !== null && _d !== void 0 ? _d : null,
|
32
|
+
oraclePyth: (_e = vaultTypeConfig.oraclePyth) !== null && _e !== void 0 ? _e : null,
|
33
|
+
oracleSwitchboard: (_f = vaultTypeConfig.oracleSwitchboard) !== null && _f !== void 0 ? _f : null,
|
34
|
+
deprecated: (_g = vaultTypeConfig.deprecated) !== null && _g !== void 0 ? _g : null,
|
35
|
+
};
|
36
|
+
return yield program.methods
|
37
|
+
.updateVaultType(config)
|
38
|
+
.accounts({
|
39
|
+
payer: payerPublicKey,
|
40
|
+
vaultSystemState: vaultSystemStatePublicKey,
|
41
|
+
vaultType: vaultTypeAccount,
|
42
|
+
oracleInfoAccount: oracleInfoAccount,
|
43
|
+
})
|
44
|
+
.instruction();
|
45
|
+
});
|
46
|
+
}
|
47
|
+
exports.updateVaultTypeStatusInstruction = updateVaultTypeStatusInstruction;
|
@@ -24,15 +24,14 @@ function withdrawVault(program, provider, payer, vaultPublicKey, withdrawAmount,
|
|
24
24
|
const history = web3_js_1.Keypair.generate();
|
25
25
|
const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
|
26
26
|
const vaultAccount = yield program.account.vault.fetch(vaultPublicKey);
|
27
|
-
const vaultTypeAccountPublicKey = yield (0, Constants_1.getVaultTypeAccountPublicKey)(vaultAccount.collateralType);
|
28
27
|
const vaultAssociatedCollateralAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, serum_1.TokenInstructions.WRAPPED_SOL_MINT, vaultPublicKey, true);
|
29
|
-
const vaultTypeAccountInfo = yield program.account.vaultType.fetch(
|
30
|
-
const vaultTypeAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccountInfo.collateralMint,
|
28
|
+
const vaultTypeAccountInfo = yield program.account.vaultType.fetch(vaultAccount.vaultType);
|
29
|
+
const vaultTypeAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccountInfo.collateralMint, vaultAccount.vaultType, true);
|
31
30
|
const destinationTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccountInfo.collateralMint, payer.publicKey);
|
32
31
|
const [hedgeStakingPoolPublicKey] = yield (0, Constants_1.getPoolPublicKeyForMint)(yield (0, Constants_1.getHedgeMintPublicKey)());
|
33
32
|
const hedgeStakingPoolAssociatedUshTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(hedgeStakingPoolPublicKey, ushMintPublickey);
|
34
|
-
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, provider,
|
35
|
-
const transaction = new web3_js_1.Transaction().add(yield withdrawVaultInstruction(program, vaultSystemStatePublicKey, payer.publicKey, destinationTokenAccount.address, vaultPublicKey, vaultAssociatedCollateralAccount.address,
|
33
|
+
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, provider, vaultAccount.vaultType, vaultPublicKey, withdrawAmount * -1, 0, false, false);
|
34
|
+
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));
|
36
35
|
yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer, history]);
|
37
36
|
return vaultPublicKey;
|
38
37
|
});
|
@@ -33,11 +33,11 @@ const borsh = __importStar(require("@project-serum/borsh"));
|
|
33
33
|
class VaultAccount {
|
34
34
|
constructor(vault, publicKey) {
|
35
35
|
var _a, _b, _c;
|
36
|
-
/** Debt redistribution
|
36
|
+
/** Debt redistribution snapshot */
|
37
37
|
this.debtProductSnapshotBytes = new decimal_js_1.default(0);
|
38
|
-
/** Collateral redistribution
|
38
|
+
/** Collateral redistribution snapshot' */
|
39
39
|
this.collateralAccumulatorSnapshotBytes = new decimal_js_1.default(0);
|
40
|
-
/** Current State of the
|
40
|
+
/** Current State of the vault ("Open", "Closed", "Liquidated") */
|
41
41
|
this.vaultStatus = '';
|
42
42
|
this.publicKey = publicKey;
|
43
43
|
this.vaultOwner = vault.vaultOwner;
|
@@ -51,11 +51,12 @@ class VaultAccount {
|
|
51
51
|
if (vault.collateralAccumulatorSnapshotBytes) {
|
52
52
|
this.collateralAccumulatorSnapshotBytes = (0, HedgeDecimal_1.DecimalFromU128)(vault.collateralAccumulatorSnapshotBytes.toString());
|
53
53
|
}
|
54
|
-
this.
|
54
|
+
this.vaultTypeName = vault.vaultTypeName;
|
55
55
|
this.nextVaultToRedeem = vault.nextVaultToRedeem;
|
56
56
|
if (vault.vaultStatus) {
|
57
57
|
this.vaultStatus = Object.keys(vault.vaultStatus)[0];
|
58
58
|
}
|
59
|
+
this.vaultType = vault.vaultType;
|
59
60
|
}
|
60
61
|
/**
|
61
62
|
* Check if some `PublicKey` is the owner
|
@@ -110,9 +111,9 @@ class VaultAccount {
|
|
110
111
|
this.denormalizedDebt = 0;
|
111
112
|
this.vaultStatus = 'liquidated';
|
112
113
|
}
|
113
|
-
updateDebtAndCollateral(
|
114
|
-
const debtProductCurrent = (0, HedgeDecimal_1.DecimalFromU128)(
|
115
|
-
const collateralAccumulatorCurrent = (0, HedgeDecimal_1.DecimalFromU128)(
|
114
|
+
updateDebtAndCollateral(vaultTypeAccountData) {
|
115
|
+
const debtProductCurrent = (0, HedgeDecimal_1.DecimalFromU128)(vaultTypeAccountData.debtRedistributionProduct);
|
116
|
+
const collateralAccumulatorCurrent = (0, HedgeDecimal_1.DecimalFromU128)(vaultTypeAccountData.collateralRedistributionAccumulator);
|
116
117
|
this.denormalizedDebt = debtProductCurrent
|
117
118
|
.div(this.debtProductSnapshotBytes)
|
118
119
|
.mul(new decimal_js_1.default(this.denormalizedDebt))
|
@@ -135,7 +136,7 @@ class VaultAccount {
|
|
135
136
|
if (this.nextVaultToRedeem) {
|
136
137
|
nextVault = this.nextVaultToRedeem.toString().substring(0, 6);
|
137
138
|
}
|
138
|
-
return `Vault(${this.vaultNumber}): ${this.publicKey.toString().substring(0, 6)}. Debt: ${this.denormalizedDebt} Collat: ${this.deposited} Ratio: ${collateralRatio}
|
139
|
+
return `Vault(${this.vaultNumber}): ${this.publicKey.toString().substring(0, 6)}. Debt: ${this.denormalizedDebt} Collat: ${this.deposited} Ratio: ${collateralRatio} ${arrow} `;
|
139
140
|
}
|
140
141
|
/**
|
141
142
|
* Creates a VaultAccount from a slice of data
|
@@ -0,0 +1,32 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
const decimal_js_1 = __importDefault(require("decimal.js"));
|
7
|
+
const HedgeDecimal_1 = require("../HedgeDecimal");
|
8
|
+
class VaultType {
|
9
|
+
constructor(config, publicKey) {
|
10
|
+
var _a;
|
11
|
+
this.publicKey = publicKey;
|
12
|
+
this.name = config.collateralType;
|
13
|
+
this.loanInitFee = (0, HedgeDecimal_1.DecimalFromU128)(config.loanInitFee);
|
14
|
+
this.minCollateralRatio = (0, HedgeDecimal_1.DecimalFromU128)(config.minCollateralRatio);
|
15
|
+
this.interestRatePerSecond = (0, HedgeDecimal_1.DecimalFromU128)(config.interestRatePerSecond);
|
16
|
+
this.minDebtPerVault = (0, HedgeDecimal_1.DecimalFromU128)(config.minDebtPerVault);
|
17
|
+
this.maxDebtExtended = (0, HedgeDecimal_1.DecimalFromU128)(config.maxDebtExtended);
|
18
|
+
this.canBeRedeemed = config.canBeRedeemed;
|
19
|
+
this.collateralMint = config.collateralMint;
|
20
|
+
this.firstVaultToRedeem = config.firstVaultToRedeem;
|
21
|
+
this.recentPrice = (0, HedgeDecimal_1.DecimalFromU128)((_a = config.recentPrice) === null || _a === void 0 ? void 0 : _a.toString());
|
22
|
+
this.priceLastUpdatedTimestamp = new decimal_js_1.default(config.priceLastUpdatedTimestamp.toString());
|
23
|
+
this.collateralHeld = new decimal_js_1.default(config.collateralHeld.toString());
|
24
|
+
this.denormalizedDebtExtended = new decimal_js_1.default(config.denormalizedDebtExtended.toString());
|
25
|
+
this.debtRedistributionProduct = (0, HedgeDecimal_1.DecimalFromU128)(config.debtRedistributionProduct.toString());
|
26
|
+
this.collateralRedistributionAccumulator = (0, HedgeDecimal_1.DecimalFromU128)(config.collateralRedistributionAccumulator.toString());
|
27
|
+
this.cumulativeRate = (0, HedgeDecimal_1.DecimalFromU128)(config.cumulativeRate.toString());
|
28
|
+
this.cumulativeRateLastUpdated = new decimal_js_1.default(config.cumulativeRateLastUpdated.toString());
|
29
|
+
this.collateralIndex = config.collateralIndex.toNumber();
|
30
|
+
}
|
31
|
+
}
|
32
|
+
exports.default = VaultType;
|
package/lib/utils/Errors.js
CHANGED
@@ -5,6 +5,7 @@ const anchor_1 = require("@project-serum/anchor");
|
|
5
5
|
const vault_1 = require("../idl/vault");
|
6
6
|
function parseAnchorErrors(error) {
|
7
7
|
const idlErrors = (0, anchor_1.parseIdlErrors)(vault_1.IDL);
|
8
|
+
console.log(error);
|
8
9
|
const parsedError = anchor_1.ProgramError.parse(error, idlErrors);
|
9
10
|
if (parsedError !== null) {
|
10
11
|
throw parsedError;
|
@@ -0,0 +1,32 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
exports.sendAndConfirmWithDebug = void 0;
|
13
|
+
function sendAndConfirmWithDebug(connection, transaction, signers) {
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
15
|
+
return connection
|
16
|
+
.sendTransaction(transaction, signers)
|
17
|
+
.then((signature) => {
|
18
|
+
return connection
|
19
|
+
.confirmTransaction(signature)
|
20
|
+
.then((signatureContext) => {
|
21
|
+
return signature;
|
22
|
+
})
|
23
|
+
.catch((error) => {
|
24
|
+
console.log('There was an error confirming the transaction', error);
|
25
|
+
});
|
26
|
+
})
|
27
|
+
.catch((error) => {
|
28
|
+
console.log('There was an error sending the transaction', error);
|
29
|
+
});
|
30
|
+
});
|
31
|
+
}
|
32
|
+
exports.sendAndConfirmWithDebug = sendAndConfirmWithDebug;
|
@@ -21,13 +21,14 @@ const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
21
21
|
const bs58_1 = __importDefault(require("bs58"));
|
22
22
|
function getLinkedListAccounts(program, provider, vaultTypeAccountPublicKey, vaultPublicKey, depositAmount, loanAmount, redeem, liquidate, cachedVaults) {
|
23
23
|
return __awaiter(this, void 0, void 0, function* () {
|
24
|
-
console.log('Getting getLinkedListAccounts')
|
24
|
+
// console.log('Getting getLinkedListAccounts')
|
25
25
|
const vaultTypeAccount = yield program.account.vaultType.fetch(vaultTypeAccountPublicKey);
|
26
26
|
// Default for null is the vault itself, so set them all to this vault
|
27
27
|
let oldSmallerPublicKey = vaultPublicKey;
|
28
28
|
let newSmallerPublicKey = vaultPublicKey;
|
29
29
|
let newLargerPublicKey = vaultPublicKey;
|
30
30
|
const thisVaultData = yield program.account.vault.fetch(vaultPublicKey);
|
31
|
+
const accountInfo = yield program.provider.connection.getAccountInfo(vaultPublicKey);
|
31
32
|
const thisVault = new VaultAccount_1.VaultAccount(thisVaultData, vaultPublicKey);
|
32
33
|
// Load all the vaults
|
33
34
|
let vaults;
|
@@ -50,10 +51,10 @@ function getLinkedListAccounts(program, provider, vaultTypeAccountPublicKey, vau
|
|
50
51
|
// vaults = allVaults.map((vault) => {
|
51
52
|
// return new VaultAccount(vault.account, vault.publicKey)
|
52
53
|
// })
|
53
|
-
vaults = yield getMiniVaults(program, vaultTypeAccount.
|
54
|
+
vaults = yield getMiniVaults(program, vaultTypeAccount.vaultTypeName);
|
54
55
|
}
|
55
|
-
console.log('Vault count found:', vaults.length)
|
56
|
-
console.log('First Vault', vaults[0])
|
56
|
+
// console.log('Vault count found:', vaults.length)
|
57
|
+
// console.log('First Vault', vaults[0])
|
57
58
|
// Filter out the accounts that are not open
|
58
59
|
// TODO filter on vault status. Or we enable people to "close out" empty vaults
|
59
60
|
// vaults = _.filter(vaults, (vault) => {
|
@@ -76,6 +77,11 @@ function getLinkedListAccounts(program, provider, vaultTypeAccountPublicKey, vau
|
|
76
77
|
if (indexBefore > 0) {
|
77
78
|
oldSmallerPublicKey = vaults[indexBefore - 1].publicKey;
|
78
79
|
}
|
80
|
+
// Pretty print the list again
|
81
|
+
// console.log('Sorted open vaults. Index Before: ', indexBefore)
|
82
|
+
// console.log(vaults.map((vault) => {
|
83
|
+
// return vault.toString(vaultPublicKey)
|
84
|
+
// }))
|
79
85
|
// Pretty print all the vaults before the operation
|
80
86
|
// console.log('Sorted open vaults BEFORE at index:', indexBefore)
|
81
87
|
// let correctOrderBefore = true
|
@@ -89,7 +95,7 @@ function getLinkedListAccounts(program, provider, vaultTypeAccountPublicKey, vau
|
|
89
95
|
// }
|
90
96
|
// }
|
91
97
|
// if (correctOrderBefore) {
|
92
|
-
// console.log(`
|
98
|
+
// console.log(`Verified the on-chain order of vault type:`, vaultTypeAccount.collateralType)
|
93
99
|
// } else {
|
94
100
|
// throw new Error('On-Chian vaults not in order!')
|
95
101
|
// }
|
@@ -104,7 +110,7 @@ function getLinkedListAccounts(program, provider, vaultTypeAccountPublicKey, vau
|
|
104
110
|
vaults[indexBefore] = thisVault;
|
105
111
|
}
|
106
112
|
// Now that we know it's def in the list, iterate the list and update
|
107
|
-
// this vault with the
|
113
|
+
// this vault with the operation we're going to apply
|
108
114
|
const newNormalizedDebt = new decimal_js_1.default(loanAmount);
|
109
115
|
const vaultTypeCompoundedInterest = (0, HedgeDecimal_1.DecimalFromU128)(vaultTypeAccount.cumulativeRate.toString());
|
110
116
|
vaults[indexBefore].updateDebtAndCollateral(vaultTypeAccount);
|
@@ -121,11 +127,6 @@ function getLinkedListAccounts(program, provider, vaultTypeAccountPublicKey, vau
|
|
121
127
|
}
|
122
128
|
// Sort it again since we've changed one vault
|
123
129
|
vaults = vaults.sort(sortVaults);
|
124
|
-
// Pretty print the list again
|
125
|
-
// console.log('Sorted open vaults with new debt added at index: ', indexAfter)
|
126
|
-
// console.log(vaults.map((vault) => {
|
127
|
-
// return vault.toString(vaultPublicKey)
|
128
|
-
// }))
|
129
130
|
// Search for the vaults new position
|
130
131
|
let indexAfter = -1;
|
131
132
|
vaults.forEach((vault, index) => {
|
@@ -141,8 +142,7 @@ function getLinkedListAccounts(program, provider, vaultTypeAccountPublicKey, vau
|
|
141
142
|
// })
|
142
143
|
// )
|
143
144
|
// Print where it moved from / to
|
144
|
-
console.log('Index
|
145
|
-
console.log('Index After', indexAfter);
|
145
|
+
// console.log('Index After', indexAfter)
|
146
146
|
// Save references to the new left and right
|
147
147
|
if (indexAfter > 0) {
|
148
148
|
newSmallerPublicKey = vaults[indexAfter - 1].publicKey;
|
@@ -168,7 +168,7 @@ function sortVaults(a, b) {
|
|
168
168
|
}
|
169
169
|
return aRatio - bRatio;
|
170
170
|
}
|
171
|
-
function getMiniVaults(program,
|
171
|
+
function getMiniVaults(program, vaultTypeName) {
|
172
172
|
return __awaiter(this, void 0, void 0, function* () {
|
173
173
|
const filters = [
|
174
174
|
// Filter for Vault Accounts
|
@@ -179,7 +179,7 @@ function getMiniVaults(program, collateralType) {
|
|
179
179
|
// Filter for Vaults with this collateral type
|
180
180
|
{
|
181
181
|
memcmp: {
|
182
|
-
bytes: bs58_1.default.encode(VaultAccount_1.VaultAccount.getBufferForString(
|
182
|
+
bytes: bs58_1.default.encode(VaultAccount_1.VaultAccount.getBufferForString(vaultTypeName)),
|
183
183
|
offset: 8 + 32 + 24,
|
184
184
|
},
|
185
185
|
},
|
@@ -0,0 +1,35 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
function sendAndConfirmWithDebug(connection, transaction, signers) {
|
13
|
+
return __awaiter(this, void 0, void 0, function* () {
|
14
|
+
return connection
|
15
|
+
.sendTransaction(transaction, signers)
|
16
|
+
.then((signature) => {
|
17
|
+
return connection
|
18
|
+
.confirmTransaction(signature)
|
19
|
+
.then((signatureContext) => {
|
20
|
+
return signature;
|
21
|
+
})
|
22
|
+
.catch((error) => {
|
23
|
+
console.log('There was an error confirming the transaction', error);
|
24
|
+
console.trace();
|
25
|
+
throw error;
|
26
|
+
});
|
27
|
+
})
|
28
|
+
.catch((error) => {
|
29
|
+
console.log('There was an error sending the transaction', error);
|
30
|
+
console.trace();
|
31
|
+
throw error;
|
32
|
+
});
|
33
|
+
});
|
34
|
+
}
|
35
|
+
exports.default = sendAndConfirmWithDebug;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "hedge-web3",
|
3
|
-
"version": "0.1.
|
3
|
+
"version": "0.1.44",
|
4
4
|
"description": "Hedge Javascript Web3 API",
|
5
5
|
"main": "lib/index.js",
|
6
6
|
"types": "declarations/index.d.ts",
|
@@ -14,7 +14,7 @@
|
|
14
14
|
"author": "Chris Coudron <coudron@hedge.so>",
|
15
15
|
"license": "ISC",
|
16
16
|
"dependencies": {
|
17
|
-
"@project-serum/anchor": "
|
17
|
+
"@project-serum/anchor": "0.24.2",
|
18
18
|
"@project-serum/serum": "^0.13.61",
|
19
19
|
"@rollup/plugin-typescript": "^8.3.0",
|
20
20
|
"@solana/buffer-layout": "^4.0.0",
|
package/src/Constants.ts
CHANGED
@@ -4,7 +4,7 @@ import {
|
|
4
4
|
} from '@solana/spl-token'
|
5
5
|
import { PublicKey } from '@solana/web3.js'
|
6
6
|
|
7
|
-
export const HEDGE_PROGRAM_ID = '
|
7
|
+
export const HEDGE_PROGRAM_ID = 'zooJaircVAoQ4e7EXRDocnsbB7UPYQ6J7bKyZEMh784'
|
8
8
|
export const HEDGE_PROGRAM_PUBLICKEY = new PublicKey(HEDGE_PROGRAM_ID)
|
9
9
|
|
10
10
|
export const CHAINLINK_SOL_USD_ID =
|