hedge-web3 0.2.0 → 0.2.3
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 +68 -22
- package/declarations/index.d.ts +1 -0
- package/declarations/instructions/closeClaimedLiquidationPoolPosition.d.ts +5 -0
- package/lib/Constants.js +1 -1
- package/lib/idl/vault.js +68 -22
- package/lib/index.js +1 -0
- package/lib/instructions/closeClaimedLiquidationPoolPosition.js +38 -0
- package/package.json +1 -1
- package/src/Constants.ts +1 -1
- package/src/idl/vault.ts +136 -44
- package/src/index.ts +1 -0
- package/src/instructions/closeClaimedLiquidationPoolPosition.ts +31 -0
- package/src/instructions/liquidateVault.ts +1 -0
- package/src/instructions/withdrawStakingPool.ts +2 -1
@@ -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 = "HedgeEohwU6RqokrvPU4Hb6XKPub8NuKbnPmY7FoMMtN";
|
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;
|
@@ -1706,6 +1706,54 @@ export declare type Vault = {
|
|
1706
1706
|
}
|
1707
1707
|
];
|
1708
1708
|
"args": [];
|
1709
|
+
},
|
1710
|
+
{
|
1711
|
+
"name": "closeClaimedLiquidationPoolPosition";
|
1712
|
+
"accounts": [
|
1713
|
+
{
|
1714
|
+
"name": "payer";
|
1715
|
+
"isMut": true;
|
1716
|
+
"isSigner": true;
|
1717
|
+
},
|
1718
|
+
{
|
1719
|
+
"name": "poolPosition";
|
1720
|
+
"isMut": true;
|
1721
|
+
"isSigner": false;
|
1722
|
+
}
|
1723
|
+
];
|
1724
|
+
"args": [];
|
1725
|
+
},
|
1726
|
+
{
|
1727
|
+
"name": "closeClaimedStakingPoolPosition";
|
1728
|
+
"accounts": [
|
1729
|
+
{
|
1730
|
+
"name": "payer";
|
1731
|
+
"isMut": true;
|
1732
|
+
"isSigner": true;
|
1733
|
+
},
|
1734
|
+
{
|
1735
|
+
"name": "poolPosition";
|
1736
|
+
"isMut": true;
|
1737
|
+
"isSigner": false;
|
1738
|
+
}
|
1739
|
+
];
|
1740
|
+
"args": [];
|
1741
|
+
},
|
1742
|
+
{
|
1743
|
+
"name": "closeUnusedPoolEra";
|
1744
|
+
"accounts": [
|
1745
|
+
{
|
1746
|
+
"name": "payer";
|
1747
|
+
"isMut": true;
|
1748
|
+
"isSigner": true;
|
1749
|
+
},
|
1750
|
+
{
|
1751
|
+
"name": "poolEra";
|
1752
|
+
"isMut": true;
|
1753
|
+
"isSigner": false;
|
1754
|
+
}
|
1755
|
+
];
|
1756
|
+
"args": [];
|
1709
1757
|
}
|
1710
1758
|
];
|
1711
1759
|
"accounts": [
|
@@ -1774,7 +1822,7 @@ export declare type Vault = {
|
|
1774
1822
|
"type": {
|
1775
1823
|
"array": [
|
1776
1824
|
"u128",
|
1777
|
-
|
1825
|
+
128
|
1778
1826
|
];
|
1779
1827
|
};
|
1780
1828
|
},
|
@@ -1855,7 +1903,7 @@ export declare type Vault = {
|
|
1855
1903
|
"type": {
|
1856
1904
|
"array": [
|
1857
1905
|
"u128",
|
1858
|
-
|
1906
|
+
128
|
1859
1907
|
];
|
1860
1908
|
};
|
1861
1909
|
},
|
@@ -1864,7 +1912,7 @@ export declare type Vault = {
|
|
1864
1912
|
"type": {
|
1865
1913
|
"array": [
|
1866
1914
|
"u128",
|
1867
|
-
|
1915
|
+
128
|
1868
1916
|
];
|
1869
1917
|
};
|
1870
1918
|
},
|
@@ -1955,7 +2003,7 @@ export declare type Vault = {
|
|
1955
2003
|
"type": {
|
1956
2004
|
"array": [
|
1957
2005
|
"u128",
|
1958
|
-
|
2006
|
+
128
|
1959
2007
|
];
|
1960
2008
|
};
|
1961
2009
|
},
|
@@ -1964,7 +2012,7 @@ export declare type Vault = {
|
|
1964
2012
|
"type": {
|
1965
2013
|
"array": [
|
1966
2014
|
"u128",
|
1967
|
-
|
2015
|
+
128
|
1968
2016
|
];
|
1969
2017
|
};
|
1970
2018
|
},
|
@@ -2052,7 +2100,7 @@ export declare type Vault = {
|
|
2052
2100
|
"type": {
|
2053
2101
|
"array": [
|
2054
2102
|
"u128",
|
2055
|
-
|
2103
|
+
128
|
2056
2104
|
];
|
2057
2105
|
};
|
2058
2106
|
},
|
@@ -2269,18 +2317,6 @@ export declare type Vault = {
|
|
2269
2317
|
"type": {
|
2270
2318
|
"option": "publicKey";
|
2271
2319
|
};
|
2272
|
-
},
|
2273
|
-
{
|
2274
|
-
"name": "deprecated";
|
2275
|
-
"type": "bool";
|
2276
|
-
},
|
2277
|
-
{
|
2278
|
-
"name": "totalFeesAccumulatedUsh";
|
2279
|
-
"type": "u128";
|
2280
|
-
},
|
2281
|
-
{
|
2282
|
-
"name": "totalFeesAccumulatedCollateral";
|
2283
|
-
"type": "u128";
|
2284
2320
|
}
|
2285
2321
|
];
|
2286
2322
|
};
|
@@ -2815,26 +2851,36 @@ export declare type Vault = {
|
|
2815
2851
|
},
|
2816
2852
|
{
|
2817
2853
|
"code": 6025;
|
2854
|
+
"name": "PositionNotClaimed";
|
2855
|
+
"msg": "Not all positions claimed. Claim all before closing account to recover SOL rent.";
|
2856
|
+
},
|
2857
|
+
{
|
2858
|
+
"code": 6026;
|
2859
|
+
"name": "PoolWasUsed";
|
2860
|
+
"msg": "Era was not unused. Cannot reclaim the SOL rent.";
|
2861
|
+
},
|
2862
|
+
{
|
2863
|
+
"code": 6027;
|
2818
2864
|
"name": "UpdateVaultTypeBadMaxDebtExtended";
|
2819
2865
|
"msg": "New Max debt extended value is less than the current debt!";
|
2820
2866
|
},
|
2821
2867
|
{
|
2822
|
-
"code":
|
2868
|
+
"code": 6028;
|
2823
2869
|
"name": "UpdateVaultTypeNoEnabledOracles";
|
2824
2870
|
"msg": "No Enabled Oracles!";
|
2825
2871
|
},
|
2826
2872
|
{
|
2827
|
-
"code":
|
2873
|
+
"code": 6029;
|
2828
2874
|
"name": "UpdateVaultTypeDuplicateOraclePriorities";
|
2829
2875
|
"msg": "Duplicate Oracle Priorities";
|
2830
2876
|
},
|
2831
2877
|
{
|
2832
|
-
"code":
|
2878
|
+
"code": 6030;
|
2833
2879
|
"name": "UpdateVaultTypeInvalidOraclePriority";
|
2834
2880
|
"msg": "Invalid Oracle Priority";
|
2835
2881
|
},
|
2836
2882
|
{
|
2837
|
-
"code":
|
2883
|
+
"code": 6031;
|
2838
2884
|
"name": "OracleUpdateFailed";
|
2839
2885
|
"msg": "OracleUpdateFailed";
|
2840
2886
|
}
|
package/declarations/index.d.ts
CHANGED
@@ -5,6 +5,7 @@ export * from './instructions/claimStakingPoolPosition';
|
|
5
5
|
export * from './instructions/depositLiquidationPool';
|
6
6
|
export * from './instructions/closeLiquidationPoolPosition';
|
7
7
|
export * from './instructions/claimLiquidationPoolPosition';
|
8
|
+
export * from './instructions/closeClaimedLiquidationPoolPosition';
|
8
9
|
export * from './instructions/createVault';
|
9
10
|
export * from './instructions/depositVault';
|
10
11
|
export * from './instructions/withdrawVault';
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import { Program, Provider } from '@project-serum/anchor';
|
2
|
+
import { PublicKey, Signer, TransactionInstruction } from '@solana/web3.js';
|
3
|
+
import { Vault } from '../idl/vault';
|
4
|
+
export declare function closeClaimedLiquidationPoolPosition(program: Program<Vault>, provider: Provider, poolPosition: PublicKey, payer: Signer): Promise<PublicKey>;
|
5
|
+
export declare function closeClaimedLiquidationPoolPositionInstruction(program: Program<Vault>, poolPosition: PublicKey, payer: PublicKey): Promise<TransactionInstruction>;
|
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_PROGRAM_ID = 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 = 'HedgeEohwU6RqokrvPU4Hb6XKPub8NuKbnPmY7FoMMtN';
|
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
@@ -1709,6 +1709,54 @@ exports.IDL = {
|
|
1709
1709
|
}
|
1710
1710
|
],
|
1711
1711
|
"args": []
|
1712
|
+
},
|
1713
|
+
{
|
1714
|
+
"name": "closeClaimedLiquidationPoolPosition",
|
1715
|
+
"accounts": [
|
1716
|
+
{
|
1717
|
+
"name": "payer",
|
1718
|
+
"isMut": true,
|
1719
|
+
"isSigner": true
|
1720
|
+
},
|
1721
|
+
{
|
1722
|
+
"name": "poolPosition",
|
1723
|
+
"isMut": true,
|
1724
|
+
"isSigner": false
|
1725
|
+
}
|
1726
|
+
],
|
1727
|
+
"args": []
|
1728
|
+
},
|
1729
|
+
{
|
1730
|
+
"name": "closeClaimedStakingPoolPosition",
|
1731
|
+
"accounts": [
|
1732
|
+
{
|
1733
|
+
"name": "payer",
|
1734
|
+
"isMut": true,
|
1735
|
+
"isSigner": true
|
1736
|
+
},
|
1737
|
+
{
|
1738
|
+
"name": "poolPosition",
|
1739
|
+
"isMut": true,
|
1740
|
+
"isSigner": false
|
1741
|
+
}
|
1742
|
+
],
|
1743
|
+
"args": []
|
1744
|
+
},
|
1745
|
+
{
|
1746
|
+
"name": "closeUnusedPoolEra",
|
1747
|
+
"accounts": [
|
1748
|
+
{
|
1749
|
+
"name": "payer",
|
1750
|
+
"isMut": true,
|
1751
|
+
"isSigner": true
|
1752
|
+
},
|
1753
|
+
{
|
1754
|
+
"name": "poolEra",
|
1755
|
+
"isMut": true,
|
1756
|
+
"isSigner": false
|
1757
|
+
}
|
1758
|
+
],
|
1759
|
+
"args": []
|
1712
1760
|
}
|
1713
1761
|
],
|
1714
1762
|
"accounts": [
|
@@ -1777,7 +1825,7 @@ exports.IDL = {
|
|
1777
1825
|
"type": {
|
1778
1826
|
"array": [
|
1779
1827
|
"u128",
|
1780
|
-
|
1828
|
+
128
|
1781
1829
|
]
|
1782
1830
|
}
|
1783
1831
|
},
|
@@ -1858,7 +1906,7 @@ exports.IDL = {
|
|
1858
1906
|
"type": {
|
1859
1907
|
"array": [
|
1860
1908
|
"u128",
|
1861
|
-
|
1909
|
+
128
|
1862
1910
|
]
|
1863
1911
|
}
|
1864
1912
|
},
|
@@ -1867,7 +1915,7 @@ exports.IDL = {
|
|
1867
1915
|
"type": {
|
1868
1916
|
"array": [
|
1869
1917
|
"u128",
|
1870
|
-
|
1918
|
+
128
|
1871
1919
|
]
|
1872
1920
|
}
|
1873
1921
|
},
|
@@ -1958,7 +2006,7 @@ exports.IDL = {
|
|
1958
2006
|
"type": {
|
1959
2007
|
"array": [
|
1960
2008
|
"u128",
|
1961
|
-
|
2009
|
+
128
|
1962
2010
|
]
|
1963
2011
|
}
|
1964
2012
|
},
|
@@ -1967,7 +2015,7 @@ exports.IDL = {
|
|
1967
2015
|
"type": {
|
1968
2016
|
"array": [
|
1969
2017
|
"u128",
|
1970
|
-
|
2018
|
+
128
|
1971
2019
|
]
|
1972
2020
|
}
|
1973
2021
|
},
|
@@ -2055,7 +2103,7 @@ exports.IDL = {
|
|
2055
2103
|
"type": {
|
2056
2104
|
"array": [
|
2057
2105
|
"u128",
|
2058
|
-
|
2106
|
+
128
|
2059
2107
|
]
|
2060
2108
|
}
|
2061
2109
|
},
|
@@ -2272,18 +2320,6 @@ exports.IDL = {
|
|
2272
2320
|
"type": {
|
2273
2321
|
"option": "publicKey"
|
2274
2322
|
}
|
2275
|
-
},
|
2276
|
-
{
|
2277
|
-
"name": "deprecated",
|
2278
|
-
"type": "bool"
|
2279
|
-
},
|
2280
|
-
{
|
2281
|
-
"name": "totalFeesAccumulatedUsh",
|
2282
|
-
"type": "u128"
|
2283
|
-
},
|
2284
|
-
{
|
2285
|
-
"name": "totalFeesAccumulatedCollateral",
|
2286
|
-
"type": "u128"
|
2287
2323
|
}
|
2288
2324
|
]
|
2289
2325
|
}
|
@@ -2818,26 +2854,36 @@ exports.IDL = {
|
|
2818
2854
|
},
|
2819
2855
|
{
|
2820
2856
|
"code": 6025,
|
2857
|
+
"name": "PositionNotClaimed",
|
2858
|
+
"msg": "Not all positions claimed. Claim all before closing account to recover SOL rent."
|
2859
|
+
},
|
2860
|
+
{
|
2861
|
+
"code": 6026,
|
2862
|
+
"name": "PoolWasUsed",
|
2863
|
+
"msg": "Era was not unused. Cannot reclaim the SOL rent."
|
2864
|
+
},
|
2865
|
+
{
|
2866
|
+
"code": 6027,
|
2821
2867
|
"name": "UpdateVaultTypeBadMaxDebtExtended",
|
2822
2868
|
"msg": "New Max debt extended value is less than the current debt!"
|
2823
2869
|
},
|
2824
2870
|
{
|
2825
|
-
"code":
|
2871
|
+
"code": 6028,
|
2826
2872
|
"name": "UpdateVaultTypeNoEnabledOracles",
|
2827
2873
|
"msg": "No Enabled Oracles!"
|
2828
2874
|
},
|
2829
2875
|
{
|
2830
|
-
"code":
|
2876
|
+
"code": 6029,
|
2831
2877
|
"name": "UpdateVaultTypeDuplicateOraclePriorities",
|
2832
2878
|
"msg": "Duplicate Oracle Priorities"
|
2833
2879
|
},
|
2834
2880
|
{
|
2835
|
-
"code":
|
2881
|
+
"code": 6030,
|
2836
2882
|
"name": "UpdateVaultTypeInvalidOraclePriority",
|
2837
2883
|
"msg": "Invalid Oracle Priority"
|
2838
2884
|
},
|
2839
2885
|
{
|
2840
|
-
"code":
|
2886
|
+
"code": 6031,
|
2841
2887
|
"name": "OracleUpdateFailed",
|
2842
2888
|
"msg": "OracleUpdateFailed"
|
2843
2889
|
}
|
package/lib/index.js
CHANGED
@@ -17,6 +17,7 @@ __exportStar(require("./instructions/claimStakingPoolPosition"), exports);
|
|
17
17
|
__exportStar(require("./instructions/depositLiquidationPool"), exports);
|
18
18
|
__exportStar(require("./instructions/closeLiquidationPoolPosition"), exports);
|
19
19
|
__exportStar(require("./instructions/claimLiquidationPoolPosition"), exports);
|
20
|
+
__exportStar(require("./instructions/closeClaimedLiquidationPoolPosition"), exports);
|
20
21
|
__exportStar(require("./instructions/createVault"), exports);
|
21
22
|
__exportStar(require("./instructions/depositVault"), exports);
|
22
23
|
__exportStar(require("./instructions/withdrawVault"), exports);
|
@@ -0,0 +1,38 @@
|
|
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.closeClaimedLiquidationPoolPositionInstruction = exports.closeClaimedLiquidationPoolPosition = void 0;
|
16
|
+
const web3_js_1 = require("@solana/web3.js");
|
17
|
+
const Errors_1 = require("../utils/Errors");
|
18
|
+
const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
|
19
|
+
function closeClaimedLiquidationPoolPosition(program, provider, poolPosition, payer) {
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
21
|
+
const transaction = new web3_js_1.Transaction().add(yield closeClaimedLiquidationPoolPositionInstruction(program, poolPosition, payer.publicKey));
|
22
|
+
yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer]).catch(Errors_1.parseAnchorErrors);
|
23
|
+
return poolPosition;
|
24
|
+
});
|
25
|
+
}
|
26
|
+
exports.closeClaimedLiquidationPoolPosition = closeClaimedLiquidationPoolPosition;
|
27
|
+
function closeClaimedLiquidationPoolPositionInstruction(program, poolPosition, payer) {
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
29
|
+
return program.methods
|
30
|
+
.closeClaimedLiquidationPoolPosition()
|
31
|
+
.accounts({
|
32
|
+
poolPosition: poolPosition,
|
33
|
+
payer: payer
|
34
|
+
})
|
35
|
+
.instruction();
|
36
|
+
});
|
37
|
+
}
|
38
|
+
exports.closeClaimedLiquidationPoolPositionInstruction = closeClaimedLiquidationPoolPositionInstruction;
|
package/package.json
CHANGED
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 = 'HedgeEohwU6RqokrvPU4Hb6XKPub8NuKbnPmY7FoMMtN'
|
8
8
|
export const HEDGE_PROGRAM_PUBLICKEY = new PublicKey(HEDGE_PROGRAM_ID)
|
9
9
|
|
10
10
|
export const CHAINLINK_SOL_USD_ID =
|
package/src/idl/vault.ts
CHANGED
@@ -1706,6 +1706,54 @@ export type Vault = {
|
|
1706
1706
|
}
|
1707
1707
|
],
|
1708
1708
|
"args": []
|
1709
|
+
},
|
1710
|
+
{
|
1711
|
+
"name": "closeClaimedLiquidationPoolPosition",
|
1712
|
+
"accounts": [
|
1713
|
+
{
|
1714
|
+
"name": "payer",
|
1715
|
+
"isMut": true,
|
1716
|
+
"isSigner": true
|
1717
|
+
},
|
1718
|
+
{
|
1719
|
+
"name": "poolPosition",
|
1720
|
+
"isMut": true,
|
1721
|
+
"isSigner": false
|
1722
|
+
}
|
1723
|
+
],
|
1724
|
+
"args": []
|
1725
|
+
},
|
1726
|
+
{
|
1727
|
+
"name": "closeClaimedStakingPoolPosition",
|
1728
|
+
"accounts": [
|
1729
|
+
{
|
1730
|
+
"name": "payer",
|
1731
|
+
"isMut": true,
|
1732
|
+
"isSigner": true
|
1733
|
+
},
|
1734
|
+
{
|
1735
|
+
"name": "poolPosition",
|
1736
|
+
"isMut": true,
|
1737
|
+
"isSigner": false
|
1738
|
+
}
|
1739
|
+
],
|
1740
|
+
"args": []
|
1741
|
+
},
|
1742
|
+
{
|
1743
|
+
"name": "closeUnusedPoolEra",
|
1744
|
+
"accounts": [
|
1745
|
+
{
|
1746
|
+
"name": "payer",
|
1747
|
+
"isMut": true,
|
1748
|
+
"isSigner": true
|
1749
|
+
},
|
1750
|
+
{
|
1751
|
+
"name": "poolEra",
|
1752
|
+
"isMut": true,
|
1753
|
+
"isSigner": false
|
1754
|
+
}
|
1755
|
+
],
|
1756
|
+
"args": []
|
1709
1757
|
}
|
1710
1758
|
],
|
1711
1759
|
"accounts": [
|
@@ -1774,7 +1822,7 @@ export type Vault = {
|
|
1774
1822
|
"type": {
|
1775
1823
|
"array": [
|
1776
1824
|
"u128",
|
1777
|
-
|
1825
|
+
128
|
1778
1826
|
]
|
1779
1827
|
}
|
1780
1828
|
},
|
@@ -1855,7 +1903,7 @@ export type Vault = {
|
|
1855
1903
|
"type": {
|
1856
1904
|
"array": [
|
1857
1905
|
"u128",
|
1858
|
-
|
1906
|
+
128
|
1859
1907
|
]
|
1860
1908
|
}
|
1861
1909
|
},
|
@@ -1864,7 +1912,7 @@ export type Vault = {
|
|
1864
1912
|
"type": {
|
1865
1913
|
"array": [
|
1866
1914
|
"u128",
|
1867
|
-
|
1915
|
+
128
|
1868
1916
|
]
|
1869
1917
|
}
|
1870
1918
|
},
|
@@ -1955,7 +2003,7 @@ export type Vault = {
|
|
1955
2003
|
"type": {
|
1956
2004
|
"array": [
|
1957
2005
|
"u128",
|
1958
|
-
|
2006
|
+
128
|
1959
2007
|
]
|
1960
2008
|
}
|
1961
2009
|
},
|
@@ -1964,7 +2012,7 @@ export type Vault = {
|
|
1964
2012
|
"type": {
|
1965
2013
|
"array": [
|
1966
2014
|
"u128",
|
1967
|
-
|
2015
|
+
128
|
1968
2016
|
]
|
1969
2017
|
}
|
1970
2018
|
},
|
@@ -2052,7 +2100,7 @@ export type Vault = {
|
|
2052
2100
|
"type": {
|
2053
2101
|
"array": [
|
2054
2102
|
"u128",
|
2055
|
-
|
2103
|
+
128
|
2056
2104
|
]
|
2057
2105
|
}
|
2058
2106
|
},
|
@@ -2269,18 +2317,6 @@ export type Vault = {
|
|
2269
2317
|
"type": {
|
2270
2318
|
"option": "publicKey"
|
2271
2319
|
}
|
2272
|
-
},
|
2273
|
-
{
|
2274
|
-
"name": "deprecated",
|
2275
|
-
"type": "bool"
|
2276
|
-
},
|
2277
|
-
{
|
2278
|
-
"name": "totalFeesAccumulatedUsh",
|
2279
|
-
"type": "u128"
|
2280
|
-
},
|
2281
|
-
{
|
2282
|
-
"name": "totalFeesAccumulatedCollateral",
|
2283
|
-
"type": "u128"
|
2284
2320
|
}
|
2285
2321
|
]
|
2286
2322
|
}
|
@@ -2815,26 +2851,36 @@ export type Vault = {
|
|
2815
2851
|
},
|
2816
2852
|
{
|
2817
2853
|
"code": 6025,
|
2854
|
+
"name": "PositionNotClaimed",
|
2855
|
+
"msg": "Not all positions claimed. Claim all before closing account to recover SOL rent."
|
2856
|
+
},
|
2857
|
+
{
|
2858
|
+
"code": 6026,
|
2859
|
+
"name": "PoolWasUsed",
|
2860
|
+
"msg": "Era was not unused. Cannot reclaim the SOL rent."
|
2861
|
+
},
|
2862
|
+
{
|
2863
|
+
"code": 6027,
|
2818
2864
|
"name": "UpdateVaultTypeBadMaxDebtExtended",
|
2819
2865
|
"msg": "New Max debt extended value is less than the current debt!"
|
2820
2866
|
},
|
2821
2867
|
{
|
2822
|
-
"code":
|
2868
|
+
"code": 6028,
|
2823
2869
|
"name": "UpdateVaultTypeNoEnabledOracles",
|
2824
2870
|
"msg": "No Enabled Oracles!"
|
2825
2871
|
},
|
2826
2872
|
{
|
2827
|
-
"code":
|
2873
|
+
"code": 6029,
|
2828
2874
|
"name": "UpdateVaultTypeDuplicateOraclePriorities",
|
2829
2875
|
"msg": "Duplicate Oracle Priorities"
|
2830
2876
|
},
|
2831
2877
|
{
|
2832
|
-
"code":
|
2878
|
+
"code": 6030,
|
2833
2879
|
"name": "UpdateVaultTypeInvalidOraclePriority",
|
2834
2880
|
"msg": "Invalid Oracle Priority"
|
2835
2881
|
},
|
2836
2882
|
{
|
2837
|
-
"code":
|
2883
|
+
"code": 6031,
|
2838
2884
|
"name": "OracleUpdateFailed",
|
2839
2885
|
"msg": "OracleUpdateFailed"
|
2840
2886
|
}
|
@@ -4549,6 +4595,54 @@ export const IDL: Vault = {
|
|
4549
4595
|
}
|
4550
4596
|
],
|
4551
4597
|
"args": []
|
4598
|
+
},
|
4599
|
+
{
|
4600
|
+
"name": "closeClaimedLiquidationPoolPosition",
|
4601
|
+
"accounts": [
|
4602
|
+
{
|
4603
|
+
"name": "payer",
|
4604
|
+
"isMut": true,
|
4605
|
+
"isSigner": true
|
4606
|
+
},
|
4607
|
+
{
|
4608
|
+
"name": "poolPosition",
|
4609
|
+
"isMut": true,
|
4610
|
+
"isSigner": false
|
4611
|
+
}
|
4612
|
+
],
|
4613
|
+
"args": []
|
4614
|
+
},
|
4615
|
+
{
|
4616
|
+
"name": "closeClaimedStakingPoolPosition",
|
4617
|
+
"accounts": [
|
4618
|
+
{
|
4619
|
+
"name": "payer",
|
4620
|
+
"isMut": true,
|
4621
|
+
"isSigner": true
|
4622
|
+
},
|
4623
|
+
{
|
4624
|
+
"name": "poolPosition",
|
4625
|
+
"isMut": true,
|
4626
|
+
"isSigner": false
|
4627
|
+
}
|
4628
|
+
],
|
4629
|
+
"args": []
|
4630
|
+
},
|
4631
|
+
{
|
4632
|
+
"name": "closeUnusedPoolEra",
|
4633
|
+
"accounts": [
|
4634
|
+
{
|
4635
|
+
"name": "payer",
|
4636
|
+
"isMut": true,
|
4637
|
+
"isSigner": true
|
4638
|
+
},
|
4639
|
+
{
|
4640
|
+
"name": "poolEra",
|
4641
|
+
"isMut": true,
|
4642
|
+
"isSigner": false
|
4643
|
+
}
|
4644
|
+
],
|
4645
|
+
"args": []
|
4552
4646
|
}
|
4553
4647
|
],
|
4554
4648
|
"accounts": [
|
@@ -4617,7 +4711,7 @@ export const IDL: Vault = {
|
|
4617
4711
|
"type": {
|
4618
4712
|
"array": [
|
4619
4713
|
"u128",
|
4620
|
-
|
4714
|
+
128
|
4621
4715
|
]
|
4622
4716
|
}
|
4623
4717
|
},
|
@@ -4698,7 +4792,7 @@ export const IDL: Vault = {
|
|
4698
4792
|
"type": {
|
4699
4793
|
"array": [
|
4700
4794
|
"u128",
|
4701
|
-
|
4795
|
+
128
|
4702
4796
|
]
|
4703
4797
|
}
|
4704
4798
|
},
|
@@ -4707,7 +4801,7 @@ export const IDL: Vault = {
|
|
4707
4801
|
"type": {
|
4708
4802
|
"array": [
|
4709
4803
|
"u128",
|
4710
|
-
|
4804
|
+
128
|
4711
4805
|
]
|
4712
4806
|
}
|
4713
4807
|
},
|
@@ -4798,7 +4892,7 @@ export const IDL: Vault = {
|
|
4798
4892
|
"type": {
|
4799
4893
|
"array": [
|
4800
4894
|
"u128",
|
4801
|
-
|
4895
|
+
128
|
4802
4896
|
]
|
4803
4897
|
}
|
4804
4898
|
},
|
@@ -4807,7 +4901,7 @@ export const IDL: Vault = {
|
|
4807
4901
|
"type": {
|
4808
4902
|
"array": [
|
4809
4903
|
"u128",
|
4810
|
-
|
4904
|
+
128
|
4811
4905
|
]
|
4812
4906
|
}
|
4813
4907
|
},
|
@@ -4895,7 +4989,7 @@ export const IDL: Vault = {
|
|
4895
4989
|
"type": {
|
4896
4990
|
"array": [
|
4897
4991
|
"u128",
|
4898
|
-
|
4992
|
+
128
|
4899
4993
|
]
|
4900
4994
|
}
|
4901
4995
|
},
|
@@ -5112,18 +5206,6 @@ export const IDL: Vault = {
|
|
5112
5206
|
"type": {
|
5113
5207
|
"option": "publicKey"
|
5114
5208
|
}
|
5115
|
-
},
|
5116
|
-
{
|
5117
|
-
"name": "deprecated",
|
5118
|
-
"type": "bool"
|
5119
|
-
},
|
5120
|
-
{
|
5121
|
-
"name": "totalFeesAccumulatedUsh",
|
5122
|
-
"type": "u128"
|
5123
|
-
},
|
5124
|
-
{
|
5125
|
-
"name": "totalFeesAccumulatedCollateral",
|
5126
|
-
"type": "u128"
|
5127
5209
|
}
|
5128
5210
|
]
|
5129
5211
|
}
|
@@ -5658,26 +5740,36 @@ export const IDL: Vault = {
|
|
5658
5740
|
},
|
5659
5741
|
{
|
5660
5742
|
"code": 6025,
|
5743
|
+
"name": "PositionNotClaimed",
|
5744
|
+
"msg": "Not all positions claimed. Claim all before closing account to recover SOL rent."
|
5745
|
+
},
|
5746
|
+
{
|
5747
|
+
"code": 6026,
|
5748
|
+
"name": "PoolWasUsed",
|
5749
|
+
"msg": "Era was not unused. Cannot reclaim the SOL rent."
|
5750
|
+
},
|
5751
|
+
{
|
5752
|
+
"code": 6027,
|
5661
5753
|
"name": "UpdateVaultTypeBadMaxDebtExtended",
|
5662
5754
|
"msg": "New Max debt extended value is less than the current debt!"
|
5663
5755
|
},
|
5664
5756
|
{
|
5665
|
-
"code":
|
5757
|
+
"code": 6028,
|
5666
5758
|
"name": "UpdateVaultTypeNoEnabledOracles",
|
5667
5759
|
"msg": "No Enabled Oracles!"
|
5668
5760
|
},
|
5669
5761
|
{
|
5670
|
-
"code":
|
5762
|
+
"code": 6029,
|
5671
5763
|
"name": "UpdateVaultTypeDuplicateOraclePriorities",
|
5672
5764
|
"msg": "Duplicate Oracle Priorities"
|
5673
5765
|
},
|
5674
5766
|
{
|
5675
|
-
"code":
|
5767
|
+
"code": 6030,
|
5676
5768
|
"name": "UpdateVaultTypeInvalidOraclePriority",
|
5677
5769
|
"msg": "Invalid Oracle Priority"
|
5678
5770
|
},
|
5679
5771
|
{
|
5680
|
-
"code":
|
5772
|
+
"code": 6031,
|
5681
5773
|
"name": "OracleUpdateFailed",
|
5682
5774
|
"msg": "OracleUpdateFailed"
|
5683
5775
|
}
|
package/src/index.ts
CHANGED
@@ -6,6 +6,7 @@ export * from './instructions/claimStakingPoolPosition'
|
|
6
6
|
export * from './instructions/depositLiquidationPool'
|
7
7
|
export * from './instructions/closeLiquidationPoolPosition'
|
8
8
|
export * from './instructions/claimLiquidationPoolPosition'
|
9
|
+
export * from './instructions/closeClaimedLiquidationPoolPosition'
|
9
10
|
export * from './instructions/createVault'
|
10
11
|
export * from './instructions/depositVault'
|
11
12
|
export * from './instructions/withdrawVault'
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import { Program, Provider } from '@project-serum/anchor'
|
2
|
+
import { PublicKey, Signer, Transaction, TransactionInstruction } from '@solana/web3.js'
|
3
|
+
import { parseAnchorErrors } from '../utils/Errors'
|
4
|
+
import sendAndConfirmWithDebug from '../utils/sendAndConfirmWithDebug'
|
5
|
+
import { Vault } from '../idl/vault'
|
6
|
+
|
7
|
+
export async function closeClaimedLiquidationPoolPosition(
|
8
|
+
program: Program<Vault>,
|
9
|
+
provider: Provider,
|
10
|
+
poolPosition: PublicKey,
|
11
|
+
payer: Signer
|
12
|
+
): Promise<PublicKey> {
|
13
|
+
const transaction = new Transaction().add(await closeClaimedLiquidationPoolPositionInstruction(program, poolPosition, payer.publicKey))
|
14
|
+
|
15
|
+
await sendAndConfirmWithDebug(provider.connection, transaction, [payer]).catch(parseAnchorErrors)
|
16
|
+
return poolPosition
|
17
|
+
}
|
18
|
+
|
19
|
+
export async function closeClaimedLiquidationPoolPositionInstruction(
|
20
|
+
program: Program<Vault>,
|
21
|
+
poolPosition: PublicKey,
|
22
|
+
payer: PublicKey
|
23
|
+
): Promise<TransactionInstruction> {
|
24
|
+
return program.methods
|
25
|
+
.closeClaimedLiquidationPoolPosition()
|
26
|
+
.accounts({
|
27
|
+
poolPosition: poolPosition,
|
28
|
+
payer: payer
|
29
|
+
})
|
30
|
+
.instruction()
|
31
|
+
}
|
@@ -27,7 +27,7 @@ export async function withdrawStakingPool(
|
|
27
27
|
payer: Signer,
|
28
28
|
poolPositionPublicKey: PublicKey,
|
29
29
|
stakedTokenMintPublicKey: PublicKey,
|
30
|
-
overrideStartTime?: number
|
30
|
+
overrideStartTime?: number,
|
31
31
|
): Promise<PublicKey> {
|
32
32
|
const poolPosition = Keypair.generate()
|
33
33
|
const transaction = new Transaction().add(
|
@@ -39,6 +39,7 @@ export async function withdrawStakingPool(
|
|
39
39
|
overrideStartTime
|
40
40
|
)
|
41
41
|
)
|
42
|
+
|
42
43
|
await sendAndConfirmWithDebug(provider.connection, transaction, [payer]).catch(parseAnchorErrors)
|
43
44
|
return poolPosition.publicKey
|
44
45
|
}
|