hedge-web3 0.2.18 → 0.2.21
Sign up to get free protection for your applications and to get access to all the features.
- package/declarations/idl/vault.d.ts +16 -0
- package/declarations/instructions/transferVault.d.ts +19 -0
- package/declarations/instructions/updateVaultType.d.ts +2 -0
- package/lib/idl/vault.js +16 -0
- package/lib/instructions/transferVault.js +55 -0
- package/lib/instructions/updateVaultType.js +10 -8
- package/package.json +1 -1
- package/src/idl/vault.ts +32 -0
- package/src/instructions/updateVaultType.ts +5 -0
@@ -76,6 +76,10 @@ export declare type Vault = {
|
|
76
76
|
"name": "maxDebtExtended";
|
77
77
|
"type": "u64";
|
78
78
|
},
|
79
|
+
{
|
80
|
+
"name": "emergencyModeThreshold";
|
81
|
+
"type": "u64";
|
82
|
+
},
|
79
83
|
{
|
80
84
|
"name": "canBeRedeemed";
|
81
85
|
"type": "bool";
|
@@ -2794,6 +2798,18 @@ export declare type Vault = {
|
|
2794
2798
|
"option": "u64";
|
2795
2799
|
};
|
2796
2800
|
},
|
2801
|
+
{
|
2802
|
+
"name": "interestRatePerSecond";
|
2803
|
+
"type": {
|
2804
|
+
"option": "u128";
|
2805
|
+
};
|
2806
|
+
},
|
2807
|
+
{
|
2808
|
+
"name": "emergencyModeThreshold";
|
2809
|
+
"type": {
|
2810
|
+
"option": "u64";
|
2811
|
+
};
|
2812
|
+
},
|
2797
2813
|
{
|
2798
2814
|
"name": "oracleChainlink";
|
2799
2815
|
"type": {
|
@@ -0,0 +1,19 @@
|
|
1
|
+
/// <reference types="bn.js" />
|
2
|
+
import { BN, Program, Provider } from '@project-serum/anchor';
|
3
|
+
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
4
|
+
import { Vault } from '../idl/vault';
|
5
|
+
export interface VaultTypeConfig {
|
6
|
+
maxDebtExtended?: BN;
|
7
|
+
minDebtPerVault?: BN;
|
8
|
+
loanInitFee?: BN;
|
9
|
+
emergencyModeThreshold?: BN;
|
10
|
+
oracleChainlink?: PublicKey;
|
11
|
+
oraclePyth?: PublicKey;
|
12
|
+
oracleSwitchboard?: PublicKey;
|
13
|
+
priorityPyth?: number;
|
14
|
+
priorityChainlink?: number;
|
15
|
+
prioritySwitchboard?: number;
|
16
|
+
deprecated?: boolean;
|
17
|
+
}
|
18
|
+
export declare function transferVault(program: Program<Vault>, provider: Provider, payer: Signer, vaultTypeAccount: PublicKey, oracleInfoAccount: PublicKey, config: VaultTypeConfig): Promise<PublicKey>;
|
19
|
+
export declare function transferVaultInstruction(program: Program<Vault>, vaultSystemStatePublicKey: PublicKey, payerPublicKey: PublicKey, vaultTypeAccount: PublicKey, oracleInfoAccount: PublicKey, vaultTypeConfig: VaultTypeConfig): Promise<TransactionInstruction>;
|
package/lib/idl/vault.js
CHANGED
@@ -79,6 +79,10 @@ exports.IDL = {
|
|
79
79
|
"name": "maxDebtExtended",
|
80
80
|
"type": "u64"
|
81
81
|
},
|
82
|
+
{
|
83
|
+
"name": "emergencyModeThreshold",
|
84
|
+
"type": "u64"
|
85
|
+
},
|
82
86
|
{
|
83
87
|
"name": "canBeRedeemed",
|
84
88
|
"type": "bool"
|
@@ -2797,6 +2801,18 @@ exports.IDL = {
|
|
2797
2801
|
"option": "u64"
|
2798
2802
|
}
|
2799
2803
|
},
|
2804
|
+
{
|
2805
|
+
"name": "interestRatePerSecond",
|
2806
|
+
"type": {
|
2807
|
+
"option": "u128"
|
2808
|
+
}
|
2809
|
+
},
|
2810
|
+
{
|
2811
|
+
"name": "emergencyModeThreshold",
|
2812
|
+
"type": {
|
2813
|
+
"option": "u64"
|
2814
|
+
}
|
2815
|
+
},
|
2800
2816
|
{
|
2801
2817
|
"name": "oracleChainlink",
|
2802
2818
|
"type": {
|
@@ -0,0 +1,55 @@
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
+
exports.transferVaultInstruction = exports.transferVault = void 0;
|
16
|
+
const web3_js_1 = require("@solana/web3.js");
|
17
|
+
const Constants_1 = require("../Constants");
|
18
|
+
const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
|
19
|
+
function transferVault(program, provider, payer, vaultTypeAccount, oracleInfoAccount, config) {
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
21
|
+
const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
|
22
|
+
const transaction = new web3_js_1.Transaction().add(yield transferVaultInstruction(program, vaultSystemStatePublicKey, payer.publicKey, vaultTypeAccount, oracleInfoAccount, config));
|
23
|
+
yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer]);
|
24
|
+
return vaultSystemStatePublicKey;
|
25
|
+
});
|
26
|
+
}
|
27
|
+
exports.transferVault = transferVault;
|
28
|
+
function transferVaultInstruction(program, vaultSystemStatePublicKey, payerPublicKey, vaultTypeAccount, oracleInfoAccount, vaultTypeConfig) {
|
29
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
31
|
+
const config = {
|
32
|
+
maxDebtExtended: (_a = vaultTypeConfig.maxDebtExtended) !== null && _a !== void 0 ? _a : null,
|
33
|
+
minDebtPerVault: (_b = vaultTypeConfig.minDebtPerVault) !== null && _b !== void 0 ? _b : null,
|
34
|
+
loanInitFee: (_c = vaultTypeConfig.loanInitFee) !== null && _c !== void 0 ? _c : null,
|
35
|
+
emergencyModeThreshold: (_d = vaultTypeConfig.emergencyModeThreshold) !== null && _d !== void 0 ? _d : null,
|
36
|
+
oracleChainlink: (_e = vaultTypeConfig.oracleChainlink) !== null && _e !== void 0 ? _e : null,
|
37
|
+
oraclePyth: (_f = vaultTypeConfig.oraclePyth) !== null && _f !== void 0 ? _f : null,
|
38
|
+
oracleSwitchboard: (_g = vaultTypeConfig.oracleSwitchboard) !== null && _g !== void 0 ? _g : null,
|
39
|
+
deprecated: (_h = vaultTypeConfig.deprecated) !== null && _h !== void 0 ? _h : null,
|
40
|
+
priorityPyth: (_j = vaultTypeConfig.priorityPyth) !== null && _j !== void 0 ? _j : null,
|
41
|
+
priorityChainlink: (_k = vaultTypeConfig.priorityChainlink) !== null && _k !== void 0 ? _k : null,
|
42
|
+
prioritySwitchboard: (_l = vaultTypeConfig.prioritySwitchboard) !== null && _l !== void 0 ? _l : null,
|
43
|
+
};
|
44
|
+
return yield program.methods
|
45
|
+
.updateVaultType(config)
|
46
|
+
.accounts({
|
47
|
+
payer: payerPublicKey,
|
48
|
+
vaultSystemState: vaultSystemStatePublicKey,
|
49
|
+
vaultType: vaultTypeAccount,
|
50
|
+
oracleInfoAccount: oracleInfoAccount,
|
51
|
+
})
|
52
|
+
.instruction();
|
53
|
+
});
|
54
|
+
}
|
55
|
+
exports.transferVaultInstruction = transferVaultInstruction;
|
@@ -26,19 +26,21 @@ function updateVaultType(program, provider, payer, vaultTypeAccount, oracleInfoA
|
|
26
26
|
}
|
27
27
|
exports.updateVaultType = updateVaultType;
|
28
28
|
function updateVaultTypeStatusInstruction(program, vaultSystemStatePublicKey, payerPublicKey, vaultTypeAccount, oracleInfoAccount, vaultTypeConfig) {
|
29
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
29
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
30
30
|
return __awaiter(this, void 0, void 0, function* () {
|
31
31
|
const config = {
|
32
32
|
maxDebtExtended: (_a = vaultTypeConfig.maxDebtExtended) !== null && _a !== void 0 ? _a : null,
|
33
33
|
minDebtPerVault: (_b = vaultTypeConfig.minDebtPerVault) !== null && _b !== void 0 ? _b : null,
|
34
34
|
loanInitFee: (_c = vaultTypeConfig.loanInitFee) !== null && _c !== void 0 ? _c : null,
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
35
|
+
interestRatePerSecond: (_d = vaultTypeConfig.interestRatePerSecond) !== null && _d !== void 0 ? _d : null,
|
36
|
+
emergencyModeThreshold: (_e = vaultTypeConfig.emergencyModeThreshold) !== null && _e !== void 0 ? _e : null,
|
37
|
+
oracleChainlink: (_f = vaultTypeConfig.oracleChainlink) !== null && _f !== void 0 ? _f : null,
|
38
|
+
oraclePyth: (_g = vaultTypeConfig.oraclePyth) !== null && _g !== void 0 ? _g : null,
|
39
|
+
oracleSwitchboard: (_h = vaultTypeConfig.oracleSwitchboard) !== null && _h !== void 0 ? _h : null,
|
40
|
+
deprecated: (_j = vaultTypeConfig.deprecated) !== null && _j !== void 0 ? _j : null,
|
41
|
+
priorityPyth: (_k = vaultTypeConfig.priorityPyth) !== null && _k !== void 0 ? _k : null,
|
42
|
+
priorityChainlink: (_l = vaultTypeConfig.priorityChainlink) !== null && _l !== void 0 ? _l : null,
|
43
|
+
prioritySwitchboard: (_m = vaultTypeConfig.prioritySwitchboard) !== null && _m !== void 0 ? _m : null,
|
42
44
|
};
|
43
45
|
return yield program.methods
|
44
46
|
.updateVaultType(config)
|
package/package.json
CHANGED
package/src/idl/vault.ts
CHANGED
@@ -76,6 +76,10 @@ export type Vault = {
|
|
76
76
|
"name": "maxDebtExtended",
|
77
77
|
"type": "u64"
|
78
78
|
},
|
79
|
+
{
|
80
|
+
"name": "emergencyModeThreshold",
|
81
|
+
"type": "u64"
|
82
|
+
},
|
79
83
|
{
|
80
84
|
"name": "canBeRedeemed",
|
81
85
|
"type": "bool"
|
@@ -2794,6 +2798,18 @@ export type Vault = {
|
|
2794
2798
|
"option": "u64"
|
2795
2799
|
}
|
2796
2800
|
},
|
2801
|
+
{
|
2802
|
+
"name": "interestRatePerSecond",
|
2803
|
+
"type": {
|
2804
|
+
"option": "u128"
|
2805
|
+
}
|
2806
|
+
},
|
2807
|
+
{
|
2808
|
+
"name": "emergencyModeThreshold",
|
2809
|
+
"type": {
|
2810
|
+
"option": "u64"
|
2811
|
+
}
|
2812
|
+
},
|
2797
2813
|
{
|
2798
2814
|
"name": "oracleChainlink",
|
2799
2815
|
"type": {
|
@@ -3325,6 +3341,10 @@ export const IDL: Vault = {
|
|
3325
3341
|
"name": "maxDebtExtended",
|
3326
3342
|
"type": "u64"
|
3327
3343
|
},
|
3344
|
+
{
|
3345
|
+
"name": "emergencyModeThreshold",
|
3346
|
+
"type": "u64"
|
3347
|
+
},
|
3328
3348
|
{
|
3329
3349
|
"name": "canBeRedeemed",
|
3330
3350
|
"type": "bool"
|
@@ -6043,6 +6063,18 @@ export const IDL: Vault = {
|
|
6043
6063
|
"option": "u64"
|
6044
6064
|
}
|
6045
6065
|
},
|
6066
|
+
{
|
6067
|
+
"name": "interestRatePerSecond",
|
6068
|
+
"type": {
|
6069
|
+
"option": "u128"
|
6070
|
+
}
|
6071
|
+
},
|
6072
|
+
{
|
6073
|
+
"name": "emergencyModeThreshold",
|
6074
|
+
"type": {
|
6075
|
+
"option": "u64"
|
6076
|
+
}
|
6077
|
+
},
|
6046
6078
|
{
|
6047
6079
|
"name": "oracleChainlink",
|
6048
6080
|
"type": {
|
@@ -28,6 +28,9 @@ export interface VaultTypeConfig {
|
|
28
28
|
maxDebtExtended?: BN
|
29
29
|
minDebtPerVault?: BN
|
30
30
|
loanInitFee?: BN
|
31
|
+
interestRatePerSecond?: BN
|
32
|
+
|
33
|
+
emergencyModeThreshold?: BN
|
31
34
|
|
32
35
|
oracleChainlink?: PublicKey
|
33
36
|
oraclePyth?: PublicKey
|
@@ -76,6 +79,8 @@ export async function updateVaultTypeStatusInstruction(
|
|
76
79
|
maxDebtExtended: vaultTypeConfig.maxDebtExtended ?? null,
|
77
80
|
minDebtPerVault: vaultTypeConfig.minDebtPerVault ?? null,
|
78
81
|
loanInitFee: vaultTypeConfig.loanInitFee ?? null,
|
82
|
+
interestRatePerSecond: vaultTypeConfig.interestRatePerSecond ?? null,
|
83
|
+
emergencyModeThreshold: vaultTypeConfig.emergencyModeThreshold ?? null,
|
79
84
|
oracleChainlink: vaultTypeConfig.oracleChainlink ?? null,
|
80
85
|
oraclePyth: vaultTypeConfig.oraclePyth ?? null,
|
81
86
|
oracleSwitchboard: vaultTypeConfig.oracleSwitchboard ?? null,
|