hedge-web3 0.1.41 → 0.1.42
Sign up to get free protection for your applications and to get access to all the features.
- package/declarations/idl/vault.d.ts +127 -2
- package/declarations/index.d.ts +1 -1
- package/declarations/instructions/updateVaultType.d.ts +15 -0
- package/lib/idl/vault.js +127 -2
- package/lib/index.js +1 -1
- package/lib/instructions/updateVaultType.js +47 -0
- package/lib/utils/Errors.js +1 -0
- package/package.json +2 -2
- package/src/idl/vault.ts +254 -4
- package/src/index.ts +1 -1
- package/src/instructions/{setVaultTypeStatus.ts → updateVaultType.ts} +39 -8
- package/src/utils/Errors.ts +1 -0
@@ -1560,7 +1560,7 @@ export declare type Vault = {
|
|
1560
1560
|
];
|
1561
1561
|
},
|
1562
1562
|
{
|
1563
|
-
"name": "
|
1563
|
+
"name": "updateVaultType";
|
1564
1564
|
"accounts": [
|
1565
1565
|
{
|
1566
1566
|
"name": "payer";
|
@@ -1576,12 +1576,77 @@ export declare type Vault = {
|
|
1576
1576
|
"name": "vaultType";
|
1577
1577
|
"isMut": true;
|
1578
1578
|
"isSigner": false;
|
1579
|
+
},
|
1580
|
+
{
|
1581
|
+
"name": "oracleInfoAccount";
|
1582
|
+
"isMut": true;
|
1583
|
+
"isSigner": false;
|
1584
|
+
}
|
1585
|
+
];
|
1586
|
+
"args": [
|
1587
|
+
{
|
1588
|
+
"name": "config";
|
1589
|
+
"type": {
|
1590
|
+
"defined": "VaultTypeConfig";
|
1591
|
+
};
|
1592
|
+
}
|
1593
|
+
];
|
1594
|
+
},
|
1595
|
+
{
|
1596
|
+
"name": "fixVaultRedeemPointer";
|
1597
|
+
"accounts": [
|
1598
|
+
{
|
1599
|
+
"name": "payer";
|
1600
|
+
"isMut": true;
|
1601
|
+
"isSigner": true;
|
1602
|
+
},
|
1603
|
+
{
|
1604
|
+
"name": "vaultSystemState";
|
1605
|
+
"isMut": true;
|
1606
|
+
"isSigner": false;
|
1607
|
+
},
|
1608
|
+
{
|
1609
|
+
"name": "vaultAccount";
|
1610
|
+
"isMut": true;
|
1611
|
+
"isSigner": false;
|
1612
|
+
}
|
1613
|
+
];
|
1614
|
+
"args": [];
|
1615
|
+
},
|
1616
|
+
{
|
1617
|
+
"name": "adminSetRedeemPointer";
|
1618
|
+
"accounts": [
|
1619
|
+
{
|
1620
|
+
"name": "payer";
|
1621
|
+
"isMut": true;
|
1622
|
+
"isSigner": true;
|
1623
|
+
},
|
1624
|
+
{
|
1625
|
+
"name": "vaultSystemState";
|
1626
|
+
"isMut": true;
|
1627
|
+
"isSigner": false;
|
1628
|
+
},
|
1629
|
+
{
|
1630
|
+
"name": "vaultAccount";
|
1631
|
+
"isMut": true;
|
1632
|
+
"isSigner": false;
|
1633
|
+
},
|
1634
|
+
{
|
1635
|
+
"name": "vaultTypeAccount";
|
1636
|
+
"isMut": true;
|
1637
|
+
"isSigner": false;
|
1579
1638
|
}
|
1580
1639
|
];
|
1581
1640
|
"args": [
|
1582
1641
|
{
|
1583
|
-
"name": "
|
1642
|
+
"name": "settingHead";
|
1584
1643
|
"type": "bool";
|
1644
|
+
},
|
1645
|
+
{
|
1646
|
+
"name": "pointerToSet";
|
1647
|
+
"type": {
|
1648
|
+
"option": "publicKey";
|
1649
|
+
};
|
1585
1650
|
}
|
1586
1651
|
];
|
1587
1652
|
}
|
@@ -2243,6 +2308,56 @@ export declare type Vault = {
|
|
2243
2308
|
];
|
2244
2309
|
};
|
2245
2310
|
},
|
2311
|
+
{
|
2312
|
+
"name": "VaultTypeConfig";
|
2313
|
+
"type": {
|
2314
|
+
"kind": "struct";
|
2315
|
+
"fields": [
|
2316
|
+
{
|
2317
|
+
"name": "maxDebtExtended";
|
2318
|
+
"type": {
|
2319
|
+
"option": "u64";
|
2320
|
+
};
|
2321
|
+
},
|
2322
|
+
{
|
2323
|
+
"name": "minDebtPerVault";
|
2324
|
+
"type": {
|
2325
|
+
"option": "u64";
|
2326
|
+
};
|
2327
|
+
},
|
2328
|
+
{
|
2329
|
+
"name": "loanInitFee";
|
2330
|
+
"type": {
|
2331
|
+
"option": "u64";
|
2332
|
+
};
|
2333
|
+
},
|
2334
|
+
{
|
2335
|
+
"name": "oracleChainlink";
|
2336
|
+
"type": {
|
2337
|
+
"option": "publicKey";
|
2338
|
+
};
|
2339
|
+
},
|
2340
|
+
{
|
2341
|
+
"name": "oraclePyth";
|
2342
|
+
"type": {
|
2343
|
+
"option": "publicKey";
|
2344
|
+
};
|
2345
|
+
},
|
2346
|
+
{
|
2347
|
+
"name": "oracleSwitchboard";
|
2348
|
+
"type": {
|
2349
|
+
"option": "publicKey";
|
2350
|
+
};
|
2351
|
+
},
|
2352
|
+
{
|
2353
|
+
"name": "deprecated";
|
2354
|
+
"type": {
|
2355
|
+
"option": "bool";
|
2356
|
+
};
|
2357
|
+
}
|
2358
|
+
];
|
2359
|
+
};
|
2360
|
+
},
|
2246
2361
|
{
|
2247
2362
|
"name": "PositionState";
|
2248
2363
|
"type": {
|
@@ -2565,6 +2680,16 @@ export declare type Vault = {
|
|
2565
2680
|
"code": 6021;
|
2566
2681
|
"name": "VaultTypeDeprecated";
|
2567
2682
|
"msg": "Vaults of this collateral type are deprecated. No new vaults can be created and no new debt will be issued for this collateral type.";
|
2683
|
+
},
|
2684
|
+
{
|
2685
|
+
"code": 6022;
|
2686
|
+
"name": "UpdateLinkedListFailed";
|
2687
|
+
"msg": "There was an error updating the list of vaults. Please make sure the transaction is fresh.";
|
2688
|
+
},
|
2689
|
+
{
|
2690
|
+
"code": 6023;
|
2691
|
+
"name": "UpdateVaultTypeBadMaxDebtExtended";
|
2692
|
+
"msg": "New Max debt extended value is less than the current debt!";
|
2568
2693
|
}
|
2569
2694
|
];
|
2570
2695
|
};
|
package/declarations/index.d.ts
CHANGED
@@ -16,7 +16,7 @@ export * from './instructions/refreshOraclePrice';
|
|
16
16
|
export * from './instructions/initHedgeFoundation';
|
17
17
|
export * from './instructions/initHedgeFoundationTokens';
|
18
18
|
export * from './instructions/setHalted';
|
19
|
-
export * from './instructions/
|
19
|
+
export * from './instructions/updateVaultType';
|
20
20
|
export * from './HedgeDecimal';
|
21
21
|
export * from './Constants';
|
22
22
|
export * from './state/VaultAccount';
|
@@ -0,0 +1,15 @@
|
|
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
|
+
oracleChainlink?: PublicKey;
|
10
|
+
oraclePyth?: PublicKey;
|
11
|
+
oracleSwitchboard?: PublicKey;
|
12
|
+
deprecated?: boolean;
|
13
|
+
}
|
14
|
+
export declare function updateVaultType(program: Program<Vault>, provider: Provider, payer: Signer, vaultTypeAccount: PublicKey, oracleInfoAccount: PublicKey, config: VaultTypeConfig): Promise<PublicKey>;
|
15
|
+
export declare function updateVaultTypeStatusInstruction(program: Program<Vault>, vaultSystemStatePublicKey: PublicKey, payerPublicKey: PublicKey, vaultTypeAccount: PublicKey, oracleInfoAccount: PublicKey, vaultTypeConfig: VaultTypeConfig): Promise<TransactionInstruction>;
|
package/lib/idl/vault.js
CHANGED
@@ -1563,7 +1563,7 @@ exports.IDL = {
|
|
1563
1563
|
]
|
1564
1564
|
},
|
1565
1565
|
{
|
1566
|
-
"name": "
|
1566
|
+
"name": "updateVaultType",
|
1567
1567
|
"accounts": [
|
1568
1568
|
{
|
1569
1569
|
"name": "payer",
|
@@ -1579,12 +1579,77 @@ exports.IDL = {
|
|
1579
1579
|
"name": "vaultType",
|
1580
1580
|
"isMut": true,
|
1581
1581
|
"isSigner": false
|
1582
|
+
},
|
1583
|
+
{
|
1584
|
+
"name": "oracleInfoAccount",
|
1585
|
+
"isMut": true,
|
1586
|
+
"isSigner": false
|
1587
|
+
}
|
1588
|
+
],
|
1589
|
+
"args": [
|
1590
|
+
{
|
1591
|
+
"name": "config",
|
1592
|
+
"type": {
|
1593
|
+
"defined": "VaultTypeConfig"
|
1594
|
+
}
|
1595
|
+
}
|
1596
|
+
]
|
1597
|
+
},
|
1598
|
+
{
|
1599
|
+
"name": "fixVaultRedeemPointer",
|
1600
|
+
"accounts": [
|
1601
|
+
{
|
1602
|
+
"name": "payer",
|
1603
|
+
"isMut": true,
|
1604
|
+
"isSigner": true
|
1605
|
+
},
|
1606
|
+
{
|
1607
|
+
"name": "vaultSystemState",
|
1608
|
+
"isMut": true,
|
1609
|
+
"isSigner": false
|
1610
|
+
},
|
1611
|
+
{
|
1612
|
+
"name": "vaultAccount",
|
1613
|
+
"isMut": true,
|
1614
|
+
"isSigner": false
|
1615
|
+
}
|
1616
|
+
],
|
1617
|
+
"args": []
|
1618
|
+
},
|
1619
|
+
{
|
1620
|
+
"name": "adminSetRedeemPointer",
|
1621
|
+
"accounts": [
|
1622
|
+
{
|
1623
|
+
"name": "payer",
|
1624
|
+
"isMut": true,
|
1625
|
+
"isSigner": true
|
1626
|
+
},
|
1627
|
+
{
|
1628
|
+
"name": "vaultSystemState",
|
1629
|
+
"isMut": true,
|
1630
|
+
"isSigner": false
|
1631
|
+
},
|
1632
|
+
{
|
1633
|
+
"name": "vaultAccount",
|
1634
|
+
"isMut": true,
|
1635
|
+
"isSigner": false
|
1636
|
+
},
|
1637
|
+
{
|
1638
|
+
"name": "vaultTypeAccount",
|
1639
|
+
"isMut": true,
|
1640
|
+
"isSigner": false
|
1582
1641
|
}
|
1583
1642
|
],
|
1584
1643
|
"args": [
|
1585
1644
|
{
|
1586
|
-
"name": "
|
1645
|
+
"name": "settingHead",
|
1587
1646
|
"type": "bool"
|
1647
|
+
},
|
1648
|
+
{
|
1649
|
+
"name": "pointerToSet",
|
1650
|
+
"type": {
|
1651
|
+
"option": "publicKey"
|
1652
|
+
}
|
1588
1653
|
}
|
1589
1654
|
]
|
1590
1655
|
}
|
@@ -2246,6 +2311,56 @@ exports.IDL = {
|
|
2246
2311
|
]
|
2247
2312
|
}
|
2248
2313
|
},
|
2314
|
+
{
|
2315
|
+
"name": "VaultTypeConfig",
|
2316
|
+
"type": {
|
2317
|
+
"kind": "struct",
|
2318
|
+
"fields": [
|
2319
|
+
{
|
2320
|
+
"name": "maxDebtExtended",
|
2321
|
+
"type": {
|
2322
|
+
"option": "u64"
|
2323
|
+
}
|
2324
|
+
},
|
2325
|
+
{
|
2326
|
+
"name": "minDebtPerVault",
|
2327
|
+
"type": {
|
2328
|
+
"option": "u64"
|
2329
|
+
}
|
2330
|
+
},
|
2331
|
+
{
|
2332
|
+
"name": "loanInitFee",
|
2333
|
+
"type": {
|
2334
|
+
"option": "u64"
|
2335
|
+
}
|
2336
|
+
},
|
2337
|
+
{
|
2338
|
+
"name": "oracleChainlink",
|
2339
|
+
"type": {
|
2340
|
+
"option": "publicKey"
|
2341
|
+
}
|
2342
|
+
},
|
2343
|
+
{
|
2344
|
+
"name": "oraclePyth",
|
2345
|
+
"type": {
|
2346
|
+
"option": "publicKey"
|
2347
|
+
}
|
2348
|
+
},
|
2349
|
+
{
|
2350
|
+
"name": "oracleSwitchboard",
|
2351
|
+
"type": {
|
2352
|
+
"option": "publicKey"
|
2353
|
+
}
|
2354
|
+
},
|
2355
|
+
{
|
2356
|
+
"name": "deprecated",
|
2357
|
+
"type": {
|
2358
|
+
"option": "bool"
|
2359
|
+
}
|
2360
|
+
}
|
2361
|
+
]
|
2362
|
+
}
|
2363
|
+
},
|
2249
2364
|
{
|
2250
2365
|
"name": "PositionState",
|
2251
2366
|
"type": {
|
@@ -2568,6 +2683,16 @@ exports.IDL = {
|
|
2568
2683
|
"code": 6021,
|
2569
2684
|
"name": "VaultTypeDeprecated",
|
2570
2685
|
"msg": "Vaults of this collateral type are deprecated. No new vaults can be created and no new debt will be issued for this collateral type."
|
2686
|
+
},
|
2687
|
+
{
|
2688
|
+
"code": 6022,
|
2689
|
+
"name": "UpdateLinkedListFailed",
|
2690
|
+
"msg": "There was an error updating the list of vaults. Please make sure the transaction is fresh."
|
2691
|
+
},
|
2692
|
+
{
|
2693
|
+
"code": 6023,
|
2694
|
+
"name": "UpdateVaultTypeBadMaxDebtExtended",
|
2695
|
+
"msg": "New Max debt extended value is less than the current debt!"
|
2571
2696
|
}
|
2572
2697
|
]
|
2573
2698
|
};
|
package/lib/index.js
CHANGED
@@ -28,7 +28,7 @@ __exportStar(require("./instructions/refreshOraclePrice"), exports);
|
|
28
28
|
__exportStar(require("./instructions/initHedgeFoundation"), exports);
|
29
29
|
__exportStar(require("./instructions/initHedgeFoundationTokens"), exports);
|
30
30
|
__exportStar(require("./instructions/setHalted"), exports);
|
31
|
-
__exportStar(require("./instructions/
|
31
|
+
__exportStar(require("./instructions/updateVaultType"), exports);
|
32
32
|
__exportStar(require("./HedgeDecimal"), exports);
|
33
33
|
__exportStar(require("./Constants"), exports);
|
34
34
|
__exportStar(require("./state/VaultAccount"), exports);
|
@@ -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;
|
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;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "hedge-web3",
|
3
|
-
"version": "0.1.
|
3
|
+
"version": "0.1.42",
|
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/idl/vault.ts
CHANGED
@@ -1560,7 +1560,7 @@ export type Vault = {
|
|
1560
1560
|
]
|
1561
1561
|
},
|
1562
1562
|
{
|
1563
|
-
"name": "
|
1563
|
+
"name": "updateVaultType",
|
1564
1564
|
"accounts": [
|
1565
1565
|
{
|
1566
1566
|
"name": "payer",
|
@@ -1576,12 +1576,77 @@ export type Vault = {
|
|
1576
1576
|
"name": "vaultType",
|
1577
1577
|
"isMut": true,
|
1578
1578
|
"isSigner": false
|
1579
|
+
},
|
1580
|
+
{
|
1581
|
+
"name": "oracleInfoAccount",
|
1582
|
+
"isMut": true,
|
1583
|
+
"isSigner": false
|
1584
|
+
}
|
1585
|
+
],
|
1586
|
+
"args": [
|
1587
|
+
{
|
1588
|
+
"name": "config",
|
1589
|
+
"type": {
|
1590
|
+
"defined": "VaultTypeConfig"
|
1591
|
+
}
|
1592
|
+
}
|
1593
|
+
]
|
1594
|
+
},
|
1595
|
+
{
|
1596
|
+
"name": "fixVaultRedeemPointer",
|
1597
|
+
"accounts": [
|
1598
|
+
{
|
1599
|
+
"name": "payer",
|
1600
|
+
"isMut": true,
|
1601
|
+
"isSigner": true
|
1602
|
+
},
|
1603
|
+
{
|
1604
|
+
"name": "vaultSystemState",
|
1605
|
+
"isMut": true,
|
1606
|
+
"isSigner": false
|
1607
|
+
},
|
1608
|
+
{
|
1609
|
+
"name": "vaultAccount",
|
1610
|
+
"isMut": true,
|
1611
|
+
"isSigner": false
|
1612
|
+
}
|
1613
|
+
],
|
1614
|
+
"args": []
|
1615
|
+
},
|
1616
|
+
{
|
1617
|
+
"name": "adminSetRedeemPointer",
|
1618
|
+
"accounts": [
|
1619
|
+
{
|
1620
|
+
"name": "payer",
|
1621
|
+
"isMut": true,
|
1622
|
+
"isSigner": true
|
1623
|
+
},
|
1624
|
+
{
|
1625
|
+
"name": "vaultSystemState",
|
1626
|
+
"isMut": true,
|
1627
|
+
"isSigner": false
|
1628
|
+
},
|
1629
|
+
{
|
1630
|
+
"name": "vaultAccount",
|
1631
|
+
"isMut": true,
|
1632
|
+
"isSigner": false
|
1633
|
+
},
|
1634
|
+
{
|
1635
|
+
"name": "vaultTypeAccount",
|
1636
|
+
"isMut": true,
|
1637
|
+
"isSigner": false
|
1579
1638
|
}
|
1580
1639
|
],
|
1581
1640
|
"args": [
|
1582
1641
|
{
|
1583
|
-
"name": "
|
1642
|
+
"name": "settingHead",
|
1584
1643
|
"type": "bool"
|
1644
|
+
},
|
1645
|
+
{
|
1646
|
+
"name": "pointerToSet",
|
1647
|
+
"type": {
|
1648
|
+
"option": "publicKey"
|
1649
|
+
}
|
1585
1650
|
}
|
1586
1651
|
]
|
1587
1652
|
}
|
@@ -2243,6 +2308,56 @@ export type Vault = {
|
|
2243
2308
|
]
|
2244
2309
|
}
|
2245
2310
|
},
|
2311
|
+
{
|
2312
|
+
"name": "VaultTypeConfig",
|
2313
|
+
"type": {
|
2314
|
+
"kind": "struct",
|
2315
|
+
"fields": [
|
2316
|
+
{
|
2317
|
+
"name": "maxDebtExtended",
|
2318
|
+
"type": {
|
2319
|
+
"option": "u64"
|
2320
|
+
}
|
2321
|
+
},
|
2322
|
+
{
|
2323
|
+
"name": "minDebtPerVault",
|
2324
|
+
"type": {
|
2325
|
+
"option": "u64"
|
2326
|
+
}
|
2327
|
+
},
|
2328
|
+
{
|
2329
|
+
"name": "loanInitFee",
|
2330
|
+
"type": {
|
2331
|
+
"option": "u64"
|
2332
|
+
}
|
2333
|
+
},
|
2334
|
+
{
|
2335
|
+
"name": "oracleChainlink",
|
2336
|
+
"type": {
|
2337
|
+
"option": "publicKey"
|
2338
|
+
}
|
2339
|
+
},
|
2340
|
+
{
|
2341
|
+
"name": "oraclePyth",
|
2342
|
+
"type": {
|
2343
|
+
"option": "publicKey"
|
2344
|
+
}
|
2345
|
+
},
|
2346
|
+
{
|
2347
|
+
"name": "oracleSwitchboard",
|
2348
|
+
"type": {
|
2349
|
+
"option": "publicKey"
|
2350
|
+
}
|
2351
|
+
},
|
2352
|
+
{
|
2353
|
+
"name": "deprecated",
|
2354
|
+
"type": {
|
2355
|
+
"option": "bool"
|
2356
|
+
}
|
2357
|
+
}
|
2358
|
+
]
|
2359
|
+
}
|
2360
|
+
},
|
2246
2361
|
{
|
2247
2362
|
"name": "PositionState",
|
2248
2363
|
"type": {
|
@@ -2565,6 +2680,16 @@ export type Vault = {
|
|
2565
2680
|
"code": 6021,
|
2566
2681
|
"name": "VaultTypeDeprecated",
|
2567
2682
|
"msg": "Vaults of this collateral type are deprecated. No new vaults can be created and no new debt will be issued for this collateral type."
|
2683
|
+
},
|
2684
|
+
{
|
2685
|
+
"code": 6022,
|
2686
|
+
"name": "UpdateLinkedListFailed",
|
2687
|
+
"msg": "There was an error updating the list of vaults. Please make sure the transaction is fresh."
|
2688
|
+
},
|
2689
|
+
{
|
2690
|
+
"code": 6023,
|
2691
|
+
"name": "UpdateVaultTypeBadMaxDebtExtended",
|
2692
|
+
"msg": "New Max debt extended value is less than the current debt!"
|
2568
2693
|
}
|
2569
2694
|
]
|
2570
2695
|
};
|
@@ -4131,7 +4256,7 @@ export const IDL: Vault = {
|
|
4131
4256
|
]
|
4132
4257
|
},
|
4133
4258
|
{
|
4134
|
-
"name": "
|
4259
|
+
"name": "updateVaultType",
|
4135
4260
|
"accounts": [
|
4136
4261
|
{
|
4137
4262
|
"name": "payer",
|
@@ -4147,12 +4272,77 @@ export const IDL: Vault = {
|
|
4147
4272
|
"name": "vaultType",
|
4148
4273
|
"isMut": true,
|
4149
4274
|
"isSigner": false
|
4275
|
+
},
|
4276
|
+
{
|
4277
|
+
"name": "oracleInfoAccount",
|
4278
|
+
"isMut": true,
|
4279
|
+
"isSigner": false
|
4280
|
+
}
|
4281
|
+
],
|
4282
|
+
"args": [
|
4283
|
+
{
|
4284
|
+
"name": "config",
|
4285
|
+
"type": {
|
4286
|
+
"defined": "VaultTypeConfig"
|
4287
|
+
}
|
4288
|
+
}
|
4289
|
+
]
|
4290
|
+
},
|
4291
|
+
{
|
4292
|
+
"name": "fixVaultRedeemPointer",
|
4293
|
+
"accounts": [
|
4294
|
+
{
|
4295
|
+
"name": "payer",
|
4296
|
+
"isMut": true,
|
4297
|
+
"isSigner": true
|
4298
|
+
},
|
4299
|
+
{
|
4300
|
+
"name": "vaultSystemState",
|
4301
|
+
"isMut": true,
|
4302
|
+
"isSigner": false
|
4303
|
+
},
|
4304
|
+
{
|
4305
|
+
"name": "vaultAccount",
|
4306
|
+
"isMut": true,
|
4307
|
+
"isSigner": false
|
4308
|
+
}
|
4309
|
+
],
|
4310
|
+
"args": []
|
4311
|
+
},
|
4312
|
+
{
|
4313
|
+
"name": "adminSetRedeemPointer",
|
4314
|
+
"accounts": [
|
4315
|
+
{
|
4316
|
+
"name": "payer",
|
4317
|
+
"isMut": true,
|
4318
|
+
"isSigner": true
|
4319
|
+
},
|
4320
|
+
{
|
4321
|
+
"name": "vaultSystemState",
|
4322
|
+
"isMut": true,
|
4323
|
+
"isSigner": false
|
4324
|
+
},
|
4325
|
+
{
|
4326
|
+
"name": "vaultAccount",
|
4327
|
+
"isMut": true,
|
4328
|
+
"isSigner": false
|
4329
|
+
},
|
4330
|
+
{
|
4331
|
+
"name": "vaultTypeAccount",
|
4332
|
+
"isMut": true,
|
4333
|
+
"isSigner": false
|
4150
4334
|
}
|
4151
4335
|
],
|
4152
4336
|
"args": [
|
4153
4337
|
{
|
4154
|
-
"name": "
|
4338
|
+
"name": "settingHead",
|
4155
4339
|
"type": "bool"
|
4340
|
+
},
|
4341
|
+
{
|
4342
|
+
"name": "pointerToSet",
|
4343
|
+
"type": {
|
4344
|
+
"option": "publicKey"
|
4345
|
+
}
|
4156
4346
|
}
|
4157
4347
|
]
|
4158
4348
|
}
|
@@ -4814,6 +5004,56 @@ export const IDL: Vault = {
|
|
4814
5004
|
]
|
4815
5005
|
}
|
4816
5006
|
},
|
5007
|
+
{
|
5008
|
+
"name": "VaultTypeConfig",
|
5009
|
+
"type": {
|
5010
|
+
"kind": "struct",
|
5011
|
+
"fields": [
|
5012
|
+
{
|
5013
|
+
"name": "maxDebtExtended",
|
5014
|
+
"type": {
|
5015
|
+
"option": "u64"
|
5016
|
+
}
|
5017
|
+
},
|
5018
|
+
{
|
5019
|
+
"name": "minDebtPerVault",
|
5020
|
+
"type": {
|
5021
|
+
"option": "u64"
|
5022
|
+
}
|
5023
|
+
},
|
5024
|
+
{
|
5025
|
+
"name": "loanInitFee",
|
5026
|
+
"type": {
|
5027
|
+
"option": "u64"
|
5028
|
+
}
|
5029
|
+
},
|
5030
|
+
{
|
5031
|
+
"name": "oracleChainlink",
|
5032
|
+
"type": {
|
5033
|
+
"option": "publicKey"
|
5034
|
+
}
|
5035
|
+
},
|
5036
|
+
{
|
5037
|
+
"name": "oraclePyth",
|
5038
|
+
"type": {
|
5039
|
+
"option": "publicKey"
|
5040
|
+
}
|
5041
|
+
},
|
5042
|
+
{
|
5043
|
+
"name": "oracleSwitchboard",
|
5044
|
+
"type": {
|
5045
|
+
"option": "publicKey"
|
5046
|
+
}
|
5047
|
+
},
|
5048
|
+
{
|
5049
|
+
"name": "deprecated",
|
5050
|
+
"type": {
|
5051
|
+
"option": "bool"
|
5052
|
+
}
|
5053
|
+
}
|
5054
|
+
]
|
5055
|
+
}
|
5056
|
+
},
|
4817
5057
|
{
|
4818
5058
|
"name": "PositionState",
|
4819
5059
|
"type": {
|
@@ -5136,6 +5376,16 @@ export const IDL: Vault = {
|
|
5136
5376
|
"code": 6021,
|
5137
5377
|
"name": "VaultTypeDeprecated",
|
5138
5378
|
"msg": "Vaults of this collateral type are deprecated. No new vaults can be created and no new debt will be issued for this collateral type."
|
5379
|
+
},
|
5380
|
+
{
|
5381
|
+
"code": 6022,
|
5382
|
+
"name": "UpdateLinkedListFailed",
|
5383
|
+
"msg": "There was an error updating the list of vaults. Please make sure the transaction is fresh."
|
5384
|
+
},
|
5385
|
+
{
|
5386
|
+
"code": 6023,
|
5387
|
+
"name": "UpdateVaultTypeBadMaxDebtExtended",
|
5388
|
+
"msg": "New Max debt extended value is less than the current debt!"
|
5139
5389
|
}
|
5140
5390
|
]
|
5141
5391
|
};
|
package/src/index.ts
CHANGED
@@ -17,7 +17,7 @@ export * from './instructions/refreshOraclePrice'
|
|
17
17
|
export * from './instructions/initHedgeFoundation'
|
18
18
|
export * from './instructions/initHedgeFoundationTokens'
|
19
19
|
export * from './instructions/setHalted'
|
20
|
-
export * from './instructions/
|
20
|
+
export * from './instructions/updateVaultType'
|
21
21
|
|
22
22
|
export * from './HedgeDecimal'
|
23
23
|
export * from './Constants'
|
@@ -23,36 +23,67 @@ import { v4 as uuidv4 } from 'uuid'
|
|
23
23
|
import { parseAnchorErrors } from '../utils/Errors'
|
24
24
|
import { Vault } from 'idl/vault'
|
25
25
|
|
26
|
-
export
|
26
|
+
export interface VaultTypeConfig {
|
27
|
+
maxDebtExtended?: BN
|
28
|
+
minDebtPerVault?: BN
|
29
|
+
loanInitFee?: BN
|
30
|
+
|
31
|
+
oracleChainlink?: PublicKey
|
32
|
+
oraclePyth?: PublicKey
|
33
|
+
oracleSwitchboard?: PublicKey
|
34
|
+
|
35
|
+
deprecated?: boolean
|
36
|
+
}
|
37
|
+
|
38
|
+
export async function updateVaultType(
|
27
39
|
program: Program<Vault>,
|
28
40
|
provider: Provider,
|
29
41
|
payer: Signer,
|
30
42
|
vaultTypeAccount: PublicKey,
|
31
|
-
|
43
|
+
oracleInfoAccount: PublicKey,
|
44
|
+
config: VaultTypeConfig
|
32
45
|
): Promise<PublicKey> {
|
33
46
|
const vaultSystemStatePublicKey = await getVaultSystemStatePublicKey()
|
34
|
-
|
35
47
|
const transaction = new Transaction().add(
|
36
|
-
await
|
48
|
+
await updateVaultTypeStatusInstruction(
|
49
|
+
program,
|
50
|
+
vaultSystemStatePublicKey,
|
51
|
+
payer.publicKey,
|
52
|
+
vaultTypeAccount,
|
53
|
+
oracleInfoAccount,
|
54
|
+
config
|
55
|
+
)
|
37
56
|
)
|
38
57
|
|
39
|
-
await sendAndConfirmTransaction(provider.connection, transaction, [payer])
|
58
|
+
await sendAndConfirmTransaction(provider.connection, transaction, [payer])
|
40
59
|
return vaultSystemStatePublicKey
|
41
60
|
}
|
42
61
|
|
43
|
-
export async function
|
62
|
+
export async function updateVaultTypeStatusInstruction(
|
44
63
|
program: Program<Vault>,
|
45
64
|
vaultSystemStatePublicKey: PublicKey,
|
46
65
|
payerPublicKey: PublicKey,
|
47
66
|
vaultTypeAccount: PublicKey,
|
48
|
-
|
67
|
+
oracleInfoAccount: PublicKey,
|
68
|
+
vaultTypeConfig: VaultTypeConfig
|
49
69
|
): Promise<TransactionInstruction> {
|
70
|
+
const config = {
|
71
|
+
maxDebtExtended: vaultTypeConfig.maxDebtExtended ?? null,
|
72
|
+
minDebtPerVault: vaultTypeConfig.minDebtPerVault ?? null,
|
73
|
+
loanInitFee: vaultTypeConfig.loanInitFee ?? null,
|
74
|
+
oracleChainlink: vaultTypeConfig.oracleChainlink ?? null,
|
75
|
+
oraclePyth: vaultTypeConfig.oraclePyth ?? null,
|
76
|
+
oracleSwitchboard: vaultTypeConfig.oracleSwitchboard ?? null,
|
77
|
+
deprecated: vaultTypeConfig.deprecated ?? null,
|
78
|
+
}
|
79
|
+
|
50
80
|
return await program.methods
|
51
|
-
.
|
81
|
+
.updateVaultType(config)
|
52
82
|
.accounts({
|
53
83
|
payer: payerPublicKey,
|
54
84
|
vaultSystemState: vaultSystemStatePublicKey,
|
55
85
|
vaultType: vaultTypeAccount,
|
86
|
+
oracleInfoAccount: oracleInfoAccount,
|
56
87
|
})
|
57
88
|
.instruction()
|
58
89
|
}
|
package/src/utils/Errors.ts
CHANGED