hedge-web3 0.1.44 → 0.1.50
Sign up to get free protection for your applications and to get access to all the features.
- package/declarations/Constants.d.ts +1 -1
- package/declarations/idl/vault.d.ts +5 -26
- package/declarations/instructions/liquidateVault.d.ts +1 -1
- package/declarations/state/VaultAccount.d.ts +5 -7
- package/lib/Constants.js +1 -1
- package/lib/idl/vault.js +5 -26
- package/lib/instructions/createStakingPool.js +0 -1
- package/lib/instructions/depositVault.js +7 -7
- package/lib/instructions/liquidateVault.js +7 -5
- package/lib/instructions/loanVault.js +6 -7
- package/lib/instructions/redeemVault.js +5 -4
- package/lib/instructions/refreshOraclePrice.js +2 -2
- package/lib/instructions/repayVault.js +5 -4
- package/lib/instructions/withdrawVault.js +5 -4
- package/lib/state/VaultAccount.js +26 -20
- package/lib/utils/getLinkedListAccounts.js +22 -19
- package/package.json +1 -1
- package/src/Constants.ts +1 -1
- package/src/idl/vault.ts +10 -52
- package/src/instructions/createStakingPool.ts +0 -1
- package/src/instructions/depositVault.ts +8 -8
- package/src/instructions/liquidateVault.ts +7 -5
- package/src/instructions/loanVault.ts +8 -11
- package/src/instructions/redeemVault.ts +5 -4
- package/src/instructions/refreshOraclePrice.ts +2 -2
- package/src/instructions/repayVault.ts +5 -4
- package/src/instructions/withdrawVault.ts +5 -4
- package/src/state/VaultAccount.ts +25 -25
- package/src/utils/getLinkedListAccounts.ts +24 -20
@@ -1,5 +1,5 @@
|
|
1
1
|
import { PublicKey } from '@solana/web3.js';
|
2
|
-
export declare const HEDGE_PROGRAM_ID = "
|
2
|
+
export declare const HEDGE_PROGRAM_ID = "HDG4FDos8fyrB79qMCe98gaFjNEy5kpxGNjMc5V8M6TJ";
|
3
3
|
export declare const HEDGE_PROGRAM_PUBLICKEY: PublicKey;
|
4
4
|
export declare const CHAINLINK_SOL_USD_ID = "FmAmfoyPXiA8Vhhe6MZTr3U6rZfEZ1ctEHay1ysqCqcf";
|
5
5
|
export declare const CHAINLINK_SOL_USD_PUBLICKEY: PublicKey;
|
@@ -1844,7 +1844,7 @@ export declare type Vault = {
|
|
1844
1844
|
"kind": "struct";
|
1845
1845
|
"fields": [
|
1846
1846
|
{
|
1847
|
-
"name": "
|
1847
|
+
"name": "collateralType";
|
1848
1848
|
"type": "string";
|
1849
1849
|
},
|
1850
1850
|
{
|
@@ -1858,10 +1858,6 @@ export declare type Vault = {
|
|
1858
1858
|
{
|
1859
1859
|
"name": "oracleSwitchboard";
|
1860
1860
|
"type": "publicKey";
|
1861
|
-
},
|
1862
|
-
{
|
1863
|
-
"name": "vaultType";
|
1864
|
-
"type": "publicKey";
|
1865
1861
|
}
|
1866
1862
|
];
|
1867
1863
|
};
|
@@ -2106,7 +2102,7 @@ export declare type Vault = {
|
|
2106
2102
|
"kind": "struct";
|
2107
2103
|
"fields": [
|
2108
2104
|
{
|
2109
|
-
"name": "
|
2105
|
+
"name": "collateralType";
|
2110
2106
|
"type": "string";
|
2111
2107
|
},
|
2112
2108
|
{
|
@@ -2190,14 +2186,6 @@ export declare type Vault = {
|
|
2190
2186
|
{
|
2191
2187
|
"name": "deprecated";
|
2192
2188
|
"type": "bool";
|
2193
|
-
},
|
2194
|
-
{
|
2195
|
-
"name": "totalFeesAccumulatedUsh";
|
2196
|
-
"type": "u128";
|
2197
|
-
},
|
2198
|
-
{
|
2199
|
-
"name": "totalFeesAccumulatedCollateral";
|
2200
|
-
"type": "u128";
|
2201
2189
|
}
|
2202
2190
|
];
|
2203
2191
|
};
|
@@ -2224,7 +2212,7 @@ export declare type Vault = {
|
|
2224
2212
|
"type": "u64";
|
2225
2213
|
},
|
2226
2214
|
{
|
2227
|
-
"name": "
|
2215
|
+
"name": "collateralType";
|
2228
2216
|
"type": "string";
|
2229
2217
|
},
|
2230
2218
|
{
|
@@ -2272,10 +2260,6 @@ export declare type Vault = {
|
|
2272
2260
|
"type": {
|
2273
2261
|
"option": "publicKey";
|
2274
2262
|
};
|
2275
|
-
},
|
2276
|
-
{
|
2277
|
-
"name": "vaultType";
|
2278
|
-
"type": "publicKey";
|
2279
2263
|
}
|
2280
2264
|
];
|
2281
2265
|
};
|
@@ -2689,8 +2673,8 @@ export declare type Vault = {
|
|
2689
2673
|
},
|
2690
2674
|
{
|
2691
2675
|
"code": 6020;
|
2692
|
-
"name": "
|
2693
|
-
"msg": "Can only redeem
|
2676
|
+
"name": "RedeemingNonHighestCollateralRatioVault";
|
2677
|
+
"msg": "Can only redeem highest collateral ratio vault in system.";
|
2694
2678
|
},
|
2695
2679
|
{
|
2696
2680
|
"code": 6021;
|
@@ -2704,11 +2688,6 @@ export declare type Vault = {
|
|
2704
2688
|
},
|
2705
2689
|
{
|
2706
2690
|
"code": 6023;
|
2707
|
-
"name": "InvalidSaltLength";
|
2708
|
-
"msg": "Salt for new vaults must be of length 8";
|
2709
|
-
},
|
2710
|
-
{
|
2711
|
-
"code": 6024;
|
2712
2691
|
"name": "UpdateVaultTypeBadMaxDebtExtended";
|
2713
2692
|
"msg": "New Max debt extended value is less than the current debt!";
|
2714
2693
|
}
|
@@ -2,4 +2,4 @@ import { Program, Provider } from '@project-serum/anchor';
|
|
2
2
|
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
3
|
import { Vault } from 'idl/vault';
|
4
4
|
export declare function liquidateVault(program: Program<Vault>, provider: Provider, payer: Signer, vaultPublicKey: PublicKey, overrideTime?: number): Promise<PublicKey>;
|
5
|
-
export declare function liquidateVaultInstruction(program: Program<Vault>, payerPublicKey: PublicKey, payerAssociatedTokenAccount: PublicKey, vaultPublickey: PublicKey, vaultAssociatedTokenAccount: PublicKey, poolState: PublicKey, poolEra: PublicKey, poolAssociatedTokenAccount: PublicKey, historyPublicKey: PublicKey, newEraPublicKey: PublicKey, feePool: PublicKey, feePoolAssociatedTokenAccount: PublicKey, hedgeStakingPoolAssociatedUshTokenAccount: PublicKey, collateralMint: PublicKey, vaultTypeAssociatedTokenAccount: PublicKey, oldSmallerPublicKey: PublicKey, newSmallerPublicKey: PublicKey, newLargerPublicKey: PublicKey,
|
5
|
+
export declare function liquidateVaultInstruction(program: Program<Vault>, payerPublicKey: PublicKey, payerAssociatedTokenAccount: PublicKey, vaultPublickey: PublicKey, vaultAssociatedTokenAccount: PublicKey, poolState: PublicKey, poolEra: PublicKey, poolAssociatedTokenAccount: PublicKey, historyPublicKey: PublicKey, newEraPublicKey: PublicKey, feePool: PublicKey, feePoolAssociatedTokenAccount: PublicKey, hedgeStakingPoolAssociatedUshTokenAccount: PublicKey, collateralMint: PublicKey, vaultTypeAssociatedTokenAccount: PublicKey, oldSmallerPublicKey: PublicKey, newSmallerPublicKey: PublicKey, newLargerPublicKey: PublicKey, collateralType: string, overrideTime?: number): Promise<TransactionInstruction>;
|
@@ -12,23 +12,21 @@ export declare class VaultAccount {
|
|
12
12
|
/** The public key of the vault owner. */
|
13
13
|
pdaSalt: string;
|
14
14
|
/** The deposited collateral of the vault (in SOL Lamports). */
|
15
|
-
deposited:
|
15
|
+
deposited: Decimal;
|
16
16
|
/** The outstanding debt of the vault (in USH Lamports). Denormalized to time 0. */
|
17
|
-
denormalizedDebt:
|
17
|
+
denormalizedDebt: Decimal;
|
18
18
|
/** The ordered number of when this vault was created. */
|
19
19
|
vaultNumber: number;
|
20
20
|
/** Debt redistribution snapshot */
|
21
21
|
debtProductSnapshotBytes: Decimal;
|
22
22
|
/** Collateral redistribution snapshot' */
|
23
23
|
collateralAccumulatorSnapshotBytes: Decimal;
|
24
|
-
/** The vault type eg '
|
25
|
-
|
24
|
+
/** The vault type eg 'SOL-150' */
|
25
|
+
collateralType: string;
|
26
26
|
/** Current State of the vault ("Open", "Closed", "Liquidated") */
|
27
27
|
vaultStatus: string;
|
28
28
|
/** The public key of the next vault to redeem. */
|
29
29
|
nextVaultToRedeem: PublicKey;
|
30
|
-
/** The public key of the vault type. */
|
31
|
-
vaultType: PublicKey;
|
32
30
|
constructor(vault: any, publicKey: PublicKey);
|
33
31
|
/**
|
34
32
|
* Check if some `PublicKey` is the owner
|
@@ -59,7 +57,7 @@ export declare class VaultAccount {
|
|
59
57
|
addDeposit(depositAmount: number): void;
|
60
58
|
redeem(): void;
|
61
59
|
liquidate(): void;
|
62
|
-
updateDebtAndCollateral(
|
60
|
+
updateDebtAndCollateral(vaultTypeAccuntData: any): void;
|
63
61
|
toString(highlight: PublicKey): string;
|
64
62
|
/**
|
65
63
|
* Creates a VaultAccount from a slice of data
|
package/lib/Constants.js
CHANGED
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.findAssociatedTokenAddress = exports.findVaultAddress = exports.getVaultTypeOracleAccountPublicKey = exports.getVaultTypeAccountPublicKey = exports.getPoolPublicKeyForMint = exports.getHedgeMintPublicKey = exports.getVaultSystemStatePublicKey = exports.getUshMintPublicKey = exports.getLiquidationPoolUshAccountPublicKey = exports.getLiquidationPoolStatePublicKey = exports.CHAINLINK_SOL_USD_PUBLICKEY = exports.CHAINLINK_SOL_USD_ID = exports.HEDGE_PROGRAM_PUBLICKEY = exports.HEDGE_PROGRAM_ID = void 0;
|
13
13
|
const spl_token_1 = require("@solana/spl-token");
|
14
14
|
const web3_js_1 = require("@solana/web3.js");
|
15
|
-
exports.HEDGE_PROGRAM_ID = '
|
15
|
+
exports.HEDGE_PROGRAM_ID = 'HDG4FDos8fyrB79qMCe98gaFjNEy5kpxGNjMc5V8M6TJ';
|
16
16
|
exports.HEDGE_PROGRAM_PUBLICKEY = new web3_js_1.PublicKey(exports.HEDGE_PROGRAM_ID);
|
17
17
|
exports.CHAINLINK_SOL_USD_ID = 'FmAmfoyPXiA8Vhhe6MZTr3U6rZfEZ1ctEHay1ysqCqcf';
|
18
18
|
exports.CHAINLINK_SOL_USD_PUBLICKEY = new web3_js_1.PublicKey(exports.CHAINLINK_SOL_USD_ID);
|
package/lib/idl/vault.js
CHANGED
@@ -1847,7 +1847,7 @@ exports.IDL = {
|
|
1847
1847
|
"kind": "struct",
|
1848
1848
|
"fields": [
|
1849
1849
|
{
|
1850
|
-
"name": "
|
1850
|
+
"name": "collateralType",
|
1851
1851
|
"type": "string"
|
1852
1852
|
},
|
1853
1853
|
{
|
@@ -1861,10 +1861,6 @@ exports.IDL = {
|
|
1861
1861
|
{
|
1862
1862
|
"name": "oracleSwitchboard",
|
1863
1863
|
"type": "publicKey"
|
1864
|
-
},
|
1865
|
-
{
|
1866
|
-
"name": "vaultType",
|
1867
|
-
"type": "publicKey"
|
1868
1864
|
}
|
1869
1865
|
]
|
1870
1866
|
}
|
@@ -2109,7 +2105,7 @@ exports.IDL = {
|
|
2109
2105
|
"kind": "struct",
|
2110
2106
|
"fields": [
|
2111
2107
|
{
|
2112
|
-
"name": "
|
2108
|
+
"name": "collateralType",
|
2113
2109
|
"type": "string"
|
2114
2110
|
},
|
2115
2111
|
{
|
@@ -2193,14 +2189,6 @@ exports.IDL = {
|
|
2193
2189
|
{
|
2194
2190
|
"name": "deprecated",
|
2195
2191
|
"type": "bool"
|
2196
|
-
},
|
2197
|
-
{
|
2198
|
-
"name": "totalFeesAccumulatedUsh",
|
2199
|
-
"type": "u128"
|
2200
|
-
},
|
2201
|
-
{
|
2202
|
-
"name": "totalFeesAccumulatedCollateral",
|
2203
|
-
"type": "u128"
|
2204
2192
|
}
|
2205
2193
|
]
|
2206
2194
|
}
|
@@ -2227,7 +2215,7 @@ exports.IDL = {
|
|
2227
2215
|
"type": "u64"
|
2228
2216
|
},
|
2229
2217
|
{
|
2230
|
-
"name": "
|
2218
|
+
"name": "collateralType",
|
2231
2219
|
"type": "string"
|
2232
2220
|
},
|
2233
2221
|
{
|
@@ -2275,10 +2263,6 @@ exports.IDL = {
|
|
2275
2263
|
"type": {
|
2276
2264
|
"option": "publicKey"
|
2277
2265
|
}
|
2278
|
-
},
|
2279
|
-
{
|
2280
|
-
"name": "vaultType",
|
2281
|
-
"type": "publicKey"
|
2282
2266
|
}
|
2283
2267
|
]
|
2284
2268
|
}
|
@@ -2692,8 +2676,8 @@ exports.IDL = {
|
|
2692
2676
|
},
|
2693
2677
|
{
|
2694
2678
|
"code": 6020,
|
2695
|
-
"name": "
|
2696
|
-
"msg": "Can only redeem
|
2679
|
+
"name": "RedeemingNonHighestCollateralRatioVault",
|
2680
|
+
"msg": "Can only redeem highest collateral ratio vault in system."
|
2697
2681
|
},
|
2698
2682
|
{
|
2699
2683
|
"code": 6021,
|
@@ -2707,11 +2691,6 @@ exports.IDL = {
|
|
2707
2691
|
},
|
2708
2692
|
{
|
2709
2693
|
"code": 6023,
|
2710
|
-
"name": "InvalidSaltLength",
|
2711
|
-
"msg": "Salt for new vaults must be of length 8"
|
2712
|
-
},
|
2713
|
-
{
|
2714
|
-
"code": 6024,
|
2715
2694
|
"name": "UpdateVaultTypeBadMaxDebtExtended",
|
2716
2695
|
"msg": "New Max debt extended value is less than the current debt!"
|
2717
2696
|
}
|
@@ -26,7 +26,6 @@ function createStakingPool(program, provider, payer, mintPublicKey, hedgeTokensT
|
|
26
26
|
exports.createStakingPool = createStakingPool;
|
27
27
|
function createStakingPoolInstruction(program, payerPublicKey, mintPublicKey, hedgeTokensToBeMinted, overrideStartTime) {
|
28
28
|
return __awaiter(this, void 0, void 0, function* () {
|
29
|
-
console.log("new createStakingPoolInstruction");
|
30
29
|
const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
|
31
30
|
const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
|
32
31
|
const [poolPublickey, poolBump] = yield (0, Constants_1.getPoolPublicKeyForMint)(mintPublicKey);
|
@@ -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");
|
20
19
|
function depositVault(program, provider, payer, vaultPublicKey, depositAmount, overrideTime) {
|
21
20
|
return __awaiter(this, void 0, void 0, function* () {
|
22
21
|
const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
|
23
22
|
// Prep the user to get USH back out at some point
|
24
23
|
yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, ushMintPublickey, payer.publicKey);
|
25
24
|
const vaultAccount = yield program.account.vault.fetch(vaultPublicKey);
|
26
|
-
const
|
27
|
-
const
|
25
|
+
const vaultTypeAccountPublicKey = yield (0, Constants_1.getVaultTypeAccountPublicKey)(vaultAccount.collateralType);
|
26
|
+
const vaultTypeAccountInfo = yield program.account.vaultType.fetch(vaultTypeAccountPublicKey);
|
27
|
+
const vaultTypeAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccountInfo.collateralMint, vaultTypeAccountPublicKey, 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, vaultTypeAccountPublicKey, vaultPublicKey, depositAmount, 0, false, false);
|
38
|
+
if (vaultAccount.collateralType === 'SOL') {
|
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, vaultAccount.collateralType === 'SOL' ? wrappedSolAccount.publicKey : payerTokenAccount, vaultPublicKey, vaultAssociatedCollateralAccountPublicKey, history.publicKey, vaultTypeAccountPublicKey, vaultTypeAssociatedTokenAccount.address, hedgeStakingPoolPublicKey, hedgeStakingPoolAssociatedUshTokenAccount, vaultTypeAccountInfo.collateralMint, ushMintPublickey, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, depositAmount, overrideTime));
|
53
|
+
if (vaultAccount.collateralType === 'SOL') {
|
54
54
|
transaction.add(serum_1.TokenInstructions.closeAccount({
|
55
55
|
source: wrappedSolAccount.publicKey,
|
56
56
|
destination: payer.publicKey,
|
@@ -18,7 +18,8 @@ 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
|
21
|
+
const vaultTypeAccountPublicKey = yield (0, Constants_1.getVaultTypeAccountPublicKey)(vaultAccount.collateralType);
|
22
|
+
const vaultTypeAccountInfo = yield program.account.vaultType.fetch(vaultTypeAccountPublicKey);
|
22
23
|
const collateralMint = vaultTypeAccountInfo.collateralMint;
|
23
24
|
const hedgeMintPublickey = yield (0, Constants_1.getHedgeMintPublicKey)();
|
24
25
|
const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
|
@@ -29,23 +30,24 @@ function liquidateVault(program, provider, payer, vaultPublicKey, overrideTime)
|
|
29
30
|
const feePoolAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMint, hedgeStakingPoolPublicKey, true);
|
30
31
|
const vaultAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMint, vaultPublicKey, true);
|
31
32
|
const poolAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMint, liquidationPoolStatePublicKey, true);
|
32
|
-
const vaultTypeAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMint,
|
33
|
+
const vaultTypeAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMint, vaultTypeAccountPublicKey, true);
|
33
34
|
const hedgeStakingPoolAssociatedUshTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, ushMintPublickey, hedgeStakingPoolPublicKey, true);
|
34
|
-
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, provider,
|
35
|
+
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, provider, vaultTypeAccountPublicKey, vaultPublicKey, 0, 0, false, true);
|
35
36
|
const history = web3_js_1.Keypair.generate();
|
36
37
|
const newEra = web3_js_1.Keypair.generate();
|
37
38
|
const transaction = new web3_js_1.Transaction();
|
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.
|
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.collateralType, overrideTime));
|
39
40
|
yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer, history, newEra]);
|
40
41
|
return vaultPublicKey;
|
41
42
|
});
|
42
43
|
}
|
43
44
|
exports.liquidateVault = liquidateVault;
|
44
|
-
function liquidateVaultInstruction(program, payerPublicKey, payerAssociatedTokenAccount, vaultPublickey, vaultAssociatedTokenAccount, poolState, poolEra, poolAssociatedTokenAccount, historyPublicKey, newEraPublicKey, feePool, feePoolAssociatedTokenAccount, hedgeStakingPoolAssociatedUshTokenAccount, collateralMint, vaultTypeAssociatedTokenAccount, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey,
|
45
|
+
function liquidateVaultInstruction(program, payerPublicKey, payerAssociatedTokenAccount, vaultPublickey, vaultAssociatedTokenAccount, poolState, poolEra, poolAssociatedTokenAccount, historyPublicKey, newEraPublicKey, feePool, feePoolAssociatedTokenAccount, hedgeStakingPoolAssociatedUshTokenAccount, collateralMint, vaultTypeAssociatedTokenAccount, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, collateralType, overrideTime) {
|
45
46
|
return __awaiter(this, void 0, void 0, function* () {
|
46
47
|
const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
|
47
48
|
const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
|
48
49
|
const liquidationPoolUshAccountPublickey = yield (0, Constants_1.getLiquidationPoolUshAccountPublicKey)();
|
50
|
+
const vaultTypeAccount = yield (0, Constants_1.getVaultTypeAccountPublicKey)(collateralType);
|
49
51
|
return yield program.methods
|
50
52
|
.liquidateVault(new anchor_1.BN(overrideTime !== null && overrideTime !== void 0 ? overrideTime : Math.floor(Date.now() / 1000)) // override override time
|
51
53
|
)
|
@@ -15,20 +15,19 @@ 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');
|
20
18
|
function loanVault(program, provider, payer, vaultPublicKey, loanAmount, overrideTime) {
|
21
19
|
return __awaiter(this, void 0, void 0, function* () {
|
22
20
|
const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
|
23
21
|
const payerUshAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, ushMintPublickey, payer.publicKey);
|
24
22
|
const vaultAccount = yield program.account.vault.fetch(vaultPublicKey);
|
25
|
-
const
|
26
|
-
const
|
23
|
+
const vaultTypeAccountPublicKey = yield (0, Constants_1.getVaultTypeAccountPublicKey)(vaultAccount.collateralType);
|
24
|
+
const vaultTypeAccount = yield program.account.vaultType.fetch(vaultTypeAccountPublicKey);
|
25
|
+
const vaultTypeAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccount.collateralMint, vaultTypeAccountPublicKey, true);
|
27
26
|
const vaultAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccount.collateralMint, vaultPublicKey, true);
|
28
|
-
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, provider,
|
27
|
+
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, provider, vaultTypeAccountPublicKey, vaultPublicKey, 0, loanAmount, false, false);
|
29
28
|
const history = web3_js_1.Keypair.generate();
|
30
|
-
const transaction = new web3_js_1.Transaction().add(yield loanVaultInstruction(program, payer.publicKey, payerUshAccount.address, vaultPublicKey, vaultAssociatedTokenAccount.address, history.publicKey,
|
31
|
-
yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer, history])
|
29
|
+
const transaction = new web3_js_1.Transaction().add(yield loanVaultInstruction(program, payer.publicKey, payerUshAccount.address, vaultPublicKey, vaultAssociatedTokenAccount.address, history.publicKey, vaultTypeAccountPublicKey, vaultTypeAssociatedTokenAccount.address, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, loanAmount, overrideTime));
|
30
|
+
yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer, history]);
|
32
31
|
return vaultPublicKey;
|
33
32
|
});
|
34
33
|
}
|
@@ -22,13 +22,14 @@ 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
|
25
|
+
const vaultTypeAccountPublicKey = yield (0, Constants_1.getVaultTypeAccountPublicKey)(vaultAccount.collateralType);
|
26
|
+
const vaultTypeAccountInfo = yield program.account.vaultType.fetch(vaultTypeAccountPublicKey);
|
27
|
+
const vaultTypeAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccountInfo.collateralMint, vaultTypeAccountPublicKey, true);
|
27
28
|
const vaultAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccountInfo.collateralMint, vaultPublicKey, true);
|
28
29
|
const payerTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccountInfo.collateralMint, payer.publicKey);
|
29
|
-
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, provider,
|
30
|
+
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, provider, vaultTypeAccountPublicKey, vaultPublicKey, 0, 0, true, false);
|
30
31
|
const history = web3_js_1.Keypair.generate();
|
31
|
-
const transaction = new web3_js_1.Transaction().add(yield redeemVaultInstruction(program, payer.publicKey, payerUshAccount.address, payerTokenAccount.address, vaultPublicKey, vaultAssociatedTokenAccount.address, history.publicKey,
|
32
|
+
const transaction = new web3_js_1.Transaction().add(yield redeemVaultInstruction(program, payer.publicKey, payerUshAccount.address, payerTokenAccount.address, vaultPublicKey, vaultAssociatedTokenAccount.address, history.publicKey, vaultTypeAccountPublicKey, vaultTypeAssociatedTokenAccount.address, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, redeemAmount, transactionOverrideTime));
|
32
33
|
yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer, history]);
|
33
34
|
return vaultPublicKey;
|
34
35
|
});
|
@@ -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: chainlinkAccunts[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 chainlinkAccunts = {
|
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,12 +21,13 @@ 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
|
24
|
+
const vaultTypeAccountPublicKey = yield (0, Constants_1.getVaultTypeAccountPublicKey)(vaultAccount.collateralType);
|
25
|
+
const vaultTypeAccount = yield program.account.vaultType.fetch(vaultTypeAccountPublicKey);
|
26
|
+
const vaultTypeAssociatedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(vaultTypeAccountPublicKey, vaultTypeAccount.collateralMint);
|
26
27
|
const vaultAssociatedTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(vaultPublicKey, vaultTypeAccount.collateralMint);
|
27
|
-
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, provider,
|
28
|
+
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, provider, vaultTypeAccountPublicKey, vaultPublicKey, 0, repayAmount * -1, false, false);
|
28
29
|
const history = web3_js_1.Keypair.generate();
|
29
|
-
const transaction = new web3_js_1.Transaction().add(yield repayVaultInstruction(program, payer.publicKey, payerUshAccount.address, vaultPublicKey, vaultAssociatedTokenAccount, history.publicKey,
|
30
|
+
const transaction = new web3_js_1.Transaction().add(yield repayVaultInstruction(program, payer.publicKey, payerUshAccount.address, vaultPublicKey, vaultAssociatedTokenAccount, history.publicKey, vaultTypeAccountPublicKey, vaultTypeAssociatedTokenAccount, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, repayAmount, overrideTime));
|
30
31
|
yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer, history]);
|
31
32
|
return vaultPublicKey;
|
32
33
|
});
|
@@ -24,14 +24,15 @@ 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);
|
27
28
|
const vaultAssociatedCollateralAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, serum_1.TokenInstructions.WRAPPED_SOL_MINT, vaultPublicKey, true);
|
28
|
-
const vaultTypeAccountInfo = yield program.account.vaultType.fetch(
|
29
|
-
const vaultTypeAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccountInfo.collateralMint,
|
29
|
+
const vaultTypeAccountInfo = yield program.account.vaultType.fetch(vaultTypeAccountPublicKey);
|
30
|
+
const vaultTypeAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccountInfo.collateralMint, vaultTypeAccountPublicKey, true);
|
30
31
|
const destinationTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, vaultTypeAccountInfo.collateralMint, payer.publicKey);
|
31
32
|
const [hedgeStakingPoolPublicKey] = yield (0, Constants_1.getPoolPublicKeyForMint)(yield (0, Constants_1.getHedgeMintPublicKey)());
|
32
33
|
const hedgeStakingPoolAssociatedUshTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(hedgeStakingPoolPublicKey, ushMintPublickey);
|
33
|
-
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, provider,
|
34
|
-
const transaction = new web3_js_1.Transaction().add(yield withdrawVaultInstruction(program, vaultSystemStatePublicKey, payer.publicKey, destinationTokenAccount.address, vaultPublicKey, vaultAssociatedCollateralAccount.address,
|
34
|
+
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, provider, vaultTypeAccountPublicKey, vaultPublicKey, withdrawAmount * -1, 0, false, false);
|
35
|
+
const transaction = new web3_js_1.Transaction().add(yield withdrawVaultInstruction(program, vaultSystemStatePublicKey, payer.publicKey, destinationTokenAccount.address, vaultPublicKey, vaultAssociatedCollateralAccount.address, vaultTypeAccountPublicKey, vaultTypeAssociatedTokenAccount.address, hedgeStakingPoolPublicKey, hedgeStakingPoolAssociatedUshTokenAccount, ushMintPublickey, history.publicKey, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, withdrawAmount, overrideTime));
|
35
36
|
yield (0, web3_js_1.sendAndConfirmTransaction)(provider.connection, transaction, [payer, history]);
|
36
37
|
return vaultPublicKey;
|
37
38
|
});
|
@@ -32,7 +32,11 @@ const borsh = __importStar(require("@project-serum/borsh"));
|
|
32
32
|
*/
|
33
33
|
class VaultAccount {
|
34
34
|
constructor(vault, publicKey) {
|
35
|
-
var _a
|
35
|
+
var _a;
|
36
|
+
/** The deposited collateral of the vault (in SOL Lamports). */
|
37
|
+
this.deposited = new decimal_js_1.default(0);
|
38
|
+
/** The outstanding debt of the vault (in USH Lamports). Denormalized to time 0. */
|
39
|
+
this.denormalizedDebt = new decimal_js_1.default(0);
|
36
40
|
/** Debt redistribution snapshot */
|
37
41
|
this.debtProductSnapshotBytes = new decimal_js_1.default(0);
|
38
42
|
/** Collateral redistribution snapshot' */
|
@@ -43,20 +47,23 @@ class VaultAccount {
|
|
43
47
|
this.vaultOwner = vault.vaultOwner;
|
44
48
|
this.vaultNumber = (_a = vault.vaultNumber) === null || _a === void 0 ? void 0 : _a.toNumber();
|
45
49
|
this.pdaSalt = vault.pdaSalt;
|
46
|
-
|
47
|
-
|
50
|
+
if (vault.deposited) {
|
51
|
+
this.deposited = new decimal_js_1.default(vault.deposited.toString());
|
52
|
+
}
|
53
|
+
if (vault.denormalizedDebt) {
|
54
|
+
this.denormalizedDebt = new decimal_js_1.default(vault.denormalizedDebt.toString());
|
55
|
+
}
|
48
56
|
if (vault.debtProductSnapshotBytes) {
|
49
57
|
this.debtProductSnapshotBytes = (0, HedgeDecimal_1.DecimalFromU128)(vault.debtProductSnapshotBytes.toString());
|
50
58
|
}
|
51
59
|
if (vault.collateralAccumulatorSnapshotBytes) {
|
52
60
|
this.collateralAccumulatorSnapshotBytes = (0, HedgeDecimal_1.DecimalFromU128)(vault.collateralAccumulatorSnapshotBytes.toString());
|
53
61
|
}
|
54
|
-
this.
|
62
|
+
this.collateralType = vault.collateralType;
|
55
63
|
this.nextVaultToRedeem = vault.nextVaultToRedeem;
|
56
64
|
if (vault.vaultStatus) {
|
57
65
|
this.vaultStatus = Object.keys(vault.vaultStatus)[0];
|
58
66
|
}
|
59
|
-
this.vaultType = vault.vaultType;
|
60
67
|
}
|
61
68
|
/**
|
62
69
|
* Check if some `PublicKey` is the owner
|
@@ -73,7 +80,7 @@ class VaultAccount {
|
|
73
80
|
* @returns collateral value in SOL
|
74
81
|
*/
|
75
82
|
inSol() {
|
76
|
-
return this.deposited
|
83
|
+
return this.deposited.div(web3_js_1.LAMPORTS_PER_SOL).toNumber();
|
77
84
|
}
|
78
85
|
/**
|
79
86
|
* Get the debt value in USH
|
@@ -81,7 +88,7 @@ class VaultAccount {
|
|
81
88
|
* @returns debt value in USH
|
82
89
|
*/
|
83
90
|
inUsd() {
|
84
|
-
return this.denormalizedDebt
|
91
|
+
return this.denormalizedDebt.div(web3_js_1.LAMPORTS_PER_SOL).toNumber();
|
85
92
|
}
|
86
93
|
/**
|
87
94
|
* Pretty print the vault publickey for easy display
|
@@ -95,31 +102,30 @@ class VaultAccount {
|
|
95
102
|
}
|
96
103
|
addDebt(newNormalizedDebt, vaultTypeCompoundedInterest) {
|
97
104
|
const denormalizedNewDebt = newNormalizedDebt.div(vaultTypeCompoundedInterest);
|
98
|
-
this.denormalizedDebt = denormalizedNewDebt.add(new decimal_js_1.default(this.denormalizedDebt)).floor()
|
105
|
+
this.denormalizedDebt = denormalizedNewDebt.add(new decimal_js_1.default(this.denormalizedDebt)).floor();
|
99
106
|
// this.denormalizedDebt = parseFloat(this.denormalizedDebt.toFixed(0))
|
100
107
|
}
|
101
108
|
addDeposit(depositAmount) {
|
102
|
-
this.deposited
|
109
|
+
this.deposited = this.deposited.add(depositAmount);
|
103
110
|
}
|
104
111
|
redeem() {
|
105
112
|
// TODO - Calculate actual redeem amount and adust correctly
|
106
|
-
this.denormalizedDebt = 0;
|
113
|
+
this.denormalizedDebt = new decimal_js_1.default(0);
|
107
114
|
this.vaultStatus = 'initialized';
|
108
115
|
}
|
109
116
|
liquidate() {
|
110
117
|
// TODO - Calculate actual liquidate amount and adust correctly
|
111
|
-
this.denormalizedDebt = 0;
|
118
|
+
this.denormalizedDebt = new decimal_js_1.default(0);
|
112
119
|
this.vaultStatus = 'liquidated';
|
113
120
|
}
|
114
|
-
updateDebtAndCollateral(
|
115
|
-
const debtProductCurrent = (0, HedgeDecimal_1.DecimalFromU128)(
|
116
|
-
const collateralAccumulatorCurrent = (0, HedgeDecimal_1.DecimalFromU128)(
|
121
|
+
updateDebtAndCollateral(vaultTypeAccuntData) {
|
122
|
+
const debtProductCurrent = (0, HedgeDecimal_1.DecimalFromU128)(vaultTypeAccuntData.debtRedistributionProduct);
|
123
|
+
const collateralAccumulatorCurrent = (0, HedgeDecimal_1.DecimalFromU128)(vaultTypeAccuntData.collateralRedistributionAccumulator);
|
117
124
|
this.denormalizedDebt = debtProductCurrent
|
118
125
|
.div(this.debtProductSnapshotBytes)
|
119
|
-
.mul(new decimal_js_1.default(this.denormalizedDebt))
|
120
|
-
|
121
|
-
|
122
|
-
this.deposited += extraCollateralDeposited;
|
126
|
+
.mul(new decimal_js_1.default(this.denormalizedDebt));
|
127
|
+
const extraCollateralDeposited = this.denormalizedDebt.mul(collateralAccumulatorCurrent.sub(this.collateralAccumulatorSnapshotBytes));
|
128
|
+
this.deposited = this.deposited.add(extraCollateralDeposited);
|
123
129
|
this.collateralAccumulatorSnapshotBytes = collateralAccumulatorCurrent;
|
124
130
|
this.debtProductSnapshotBytes = debtProductCurrent;
|
125
131
|
}
|
@@ -129,14 +135,14 @@ class VaultAccount {
|
|
129
135
|
arrow = ' <----!!';
|
130
136
|
}
|
131
137
|
let collateralRatio = 'Infinite';
|
132
|
-
if (this.denormalizedDebt
|
138
|
+
if (this.denormalizedDebt.greaterThan(0)) {
|
133
139
|
collateralRatio = new decimal_js_1.default(this.deposited).div(new decimal_js_1.default(this.denormalizedDebt)).toString();
|
134
140
|
}
|
135
141
|
let nextVault = 'None';
|
136
142
|
if (this.nextVaultToRedeem) {
|
137
143
|
nextVault = this.nextVaultToRedeem.toString().substring(0, 6);
|
138
144
|
}
|
139
|
-
return `Vault(${this.vaultNumber}): ${this.publicKey.toString().substring(0, 6)}. Debt: ${this.denormalizedDebt} Collat: ${this.deposited} Ratio: ${collateralRatio} ${arrow} `;
|
145
|
+
return `Vault(${this.vaultNumber}): ${this.publicKey.toString().substring(0, 6)}. Debt: ${this.denormalizedDebt} Collat: ${this.deposited} Ratio: ${collateralRatio} NextVault: ${nextVault} ${arrow} `;
|
140
146
|
}
|
141
147
|
/**
|
142
148
|
* Creates a VaultAccount from a slice of data
|