hedge-web3 0.1.50 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/declarations/Constants.d.ts +2 -1
- package/declarations/idl/vault.d.ts +192 -41
- package/declarations/index.d.ts +1 -0
- package/declarations/instructions/claimLiquidationPoolPosition.d.ts +1 -1
- package/declarations/instructions/claimStakingPoolPosition.d.ts +1 -1
- package/declarations/instructions/closeClaimedLiquidationPoolPosition.d.ts +5 -0
- package/declarations/instructions/closeLiquidationPoolPosition.d.ts +1 -1
- package/declarations/instructions/createStakingPool.d.ts +1 -1
- package/declarations/instructions/createVault.d.ts +1 -1
- package/declarations/instructions/depositLiquidationPool.d.ts +1 -1
- package/declarations/instructions/depositStakingPool.d.ts +1 -1
- package/declarations/instructions/depositVault.d.ts +1 -1
- package/declarations/instructions/initHedgeFoundation.d.ts +1 -1
- package/declarations/instructions/liquidateVault.d.ts +2 -2
- package/declarations/instructions/loanVault.d.ts +1 -1
- package/declarations/instructions/redeemVault.d.ts +1 -1
- package/declarations/instructions/refreshOraclePrice.d.ts +3 -3
- package/declarations/instructions/repayVault.d.ts +1 -1
- package/declarations/instructions/setHalted.d.ts +1 -1
- package/declarations/instructions/updateVaultType.d.ts +4 -1
- package/declarations/instructions/withdrawStakingPool.d.ts +1 -1
- package/declarations/instructions/withdrawVault.d.ts +1 -1
- package/declarations/state/VaultAccount.d.ts +9 -6
- package/declarations/utils/getLinkedListAccounts.d.ts +1 -1
- package/lib/Constants.js +3 -2
- package/lib/idl/vault.js +192 -41
- package/lib/index.js +1 -0
- package/lib/instructions/claimLiquidationPoolPosition.js +5 -1
- package/lib/instructions/claimStakingPoolPosition.js +5 -1
- package/lib/instructions/closeClaimedLiquidationPoolPosition.js +38 -0
- package/lib/instructions/closeLiquidationPoolPosition.js +5 -1
- package/lib/instructions/createStakingPool.js +5 -1
- package/lib/instructions/createVault.js +5 -1
- package/lib/instructions/depositLiquidationPool.js +5 -1
- package/lib/instructions/depositStakingPool.js +5 -1
- package/lib/instructions/depositVault.js +12 -8
- package/lib/instructions/initHedgeFoundation.js +5 -1
- package/lib/instructions/initHedgeFoundationTokens.js +5 -1
- package/lib/instructions/liquidateVault.js +10 -8
- package/lib/instructions/loanVault.js +9 -6
- package/lib/instructions/redeemVault.js +9 -6
- package/lib/instructions/refreshOraclePrice.js +8 -3
- package/lib/instructions/repayVault.js +9 -6
- package/lib/instructions/setHalted.js +5 -1
- package/lib/instructions/updateVaultType.js +9 -2
- package/lib/instructions/withdrawStakingPool.js +5 -1
- package/lib/instructions/withdrawVault.js +9 -6
- package/lib/state/VaultAccount.js +28 -32
- package/lib/utils/getLinkedListAccounts.js +54 -57
- package/package.json +1 -1
- package/src/Constants.ts +2 -1
- package/src/idl/vault.ts +384 -82
- package/src/index.ts +1 -0
- package/src/instructions/claimLiquidationPoolPosition.ts +3 -2
- package/src/instructions/claimStakingPoolPosition.ts +3 -2
- package/src/instructions/closeClaimedLiquidationPoolPosition.ts +31 -0
- package/src/instructions/closeLiquidationPoolPosition.ts +3 -2
- package/src/instructions/createStakingPool.ts +3 -2
- package/src/instructions/createVault.ts +3 -2
- package/src/instructions/depositLiquidationPool.ts +3 -2
- package/src/instructions/depositStakingPool.ts +3 -2
- package/src/instructions/depositVault.ts +11 -11
- package/src/instructions/initHedgeFoundation.ts +3 -2
- package/src/instructions/initHedgeFoundationTokens.ts +2 -1
- package/src/instructions/liquidateVault.ts +11 -10
- package/src/instructions/loanVault.ts +11 -9
- package/src/instructions/redeemVault.ts +7 -7
- package/src/instructions/refreshOraclePrice.ts +9 -6
- package/src/instructions/repayVault.ts +7 -7
- package/src/instructions/setHalted.ts +3 -2
- package/src/instructions/updateVaultType.ts +10 -2
- package/src/instructions/withdrawStakingPool.ts +5 -3
- package/src/instructions/withdrawVault.ts +7 -7
- package/src/state/VaultAccount.ts +37 -32
- package/src/state/VaultType.ts +62 -0
- package/src/utils/getLinkedListAccounts.ts +61 -60
- package/src/utils/sendAndConfirmWithDebug.ts +27 -0
@@ -1,5 +1,5 @@
|
|
1
1
|
import { Program, Provider } from '@project-serum/anchor';
|
2
2
|
import { PublicKey } from '@solana/web3.js';
|
3
3
|
import { VaultAccount } from '../state/VaultAccount';
|
4
|
-
import { Vault } from 'idl/vault';
|
4
|
+
import { Vault } from '../idl/vault';
|
5
5
|
export declare function getLinkedListAccounts(program: Program<Vault>, provider: Provider, vaultTypeAccountPublicKey: PublicKey, vaultPublicKey: PublicKey, depositAmount: number, loanAmount: number, redeem: boolean, liquidate: boolean, cachedVaults?: VaultAccount[]): Promise<[PublicKey, PublicKey, PublicKey, VaultAccount[]]>;
|
package/lib/Constants.js
CHANGED
@@ -9,13 +9,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
9
9
|
});
|
10
10
|
};
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
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;
|
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);
|
19
|
+
exports.CHAINLINK_PROGRAM_ID = "HEvSKofvBgfaexv23kMabbYqxasxU3mQ4ibBMEmJWHny";
|
19
20
|
const enc = new TextEncoder();
|
20
21
|
function getLiquidationPoolStatePublicKey() {
|
21
22
|
return __awaiter(this, void 0, void 0, function* () {
|
package/lib/idl/vault.js
CHANGED
@@ -1180,6 +1180,11 @@ exports.IDL = {
|
|
1180
1180
|
"name": "systemProgram",
|
1181
1181
|
"isMut": false,
|
1182
1182
|
"isSigner": false
|
1183
|
+
},
|
1184
|
+
{
|
1185
|
+
"name": "chainlinkProgram",
|
1186
|
+
"isMut": false,
|
1187
|
+
"isSigner": false
|
1183
1188
|
}
|
1184
1189
|
],
|
1185
1190
|
"args": [
|
@@ -1652,6 +1657,74 @@ exports.IDL = {
|
|
1652
1657
|
}
|
1653
1658
|
}
|
1654
1659
|
]
|
1660
|
+
},
|
1661
|
+
{
|
1662
|
+
"name": "adminMigrateVault",
|
1663
|
+
"accounts": [
|
1664
|
+
{
|
1665
|
+
"name": "payer",
|
1666
|
+
"isMut": true,
|
1667
|
+
"isSigner": true
|
1668
|
+
},
|
1669
|
+
{
|
1670
|
+
"name": "vaultSystemState",
|
1671
|
+
"isMut": true,
|
1672
|
+
"isSigner": false
|
1673
|
+
},
|
1674
|
+
{
|
1675
|
+
"name": "vaultAccount",
|
1676
|
+
"isMut": true,
|
1677
|
+
"isSigner": false
|
1678
|
+
},
|
1679
|
+
{
|
1680
|
+
"name": "vaultTypeAccount",
|
1681
|
+
"isMut": true,
|
1682
|
+
"isSigner": false
|
1683
|
+
}
|
1684
|
+
],
|
1685
|
+
"args": []
|
1686
|
+
},
|
1687
|
+
{
|
1688
|
+
"name": "adminMigrateOracle",
|
1689
|
+
"accounts": [
|
1690
|
+
{
|
1691
|
+
"name": "payer",
|
1692
|
+
"isMut": true,
|
1693
|
+
"isSigner": true
|
1694
|
+
},
|
1695
|
+
{
|
1696
|
+
"name": "vaultSystemState",
|
1697
|
+
"isMut": true,
|
1698
|
+
"isSigner": false
|
1699
|
+
},
|
1700
|
+
{
|
1701
|
+
"name": "oracleInfoAccount",
|
1702
|
+
"isMut": true,
|
1703
|
+
"isSigner": false
|
1704
|
+
},
|
1705
|
+
{
|
1706
|
+
"name": "vaultTypeAccount",
|
1707
|
+
"isMut": true,
|
1708
|
+
"isSigner": false
|
1709
|
+
}
|
1710
|
+
],
|
1711
|
+
"args": []
|
1712
|
+
},
|
1713
|
+
{
|
1714
|
+
"name": "closeClaimedLiquidationPool",
|
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": []
|
1655
1728
|
}
|
1656
1729
|
],
|
1657
1730
|
"accounts": [
|
@@ -1720,7 +1793,7 @@ exports.IDL = {
|
|
1720
1793
|
"type": {
|
1721
1794
|
"array": [
|
1722
1795
|
"u128",
|
1723
|
-
|
1796
|
+
128
|
1724
1797
|
]
|
1725
1798
|
}
|
1726
1799
|
},
|
@@ -1780,10 +1853,6 @@ exports.IDL = {
|
|
1780
1853
|
"type": {
|
1781
1854
|
"kind": "struct",
|
1782
1855
|
"fields": [
|
1783
|
-
{
|
1784
|
-
"name": "state",
|
1785
|
-
"type": "u64"
|
1786
|
-
},
|
1787
1856
|
{
|
1788
1857
|
"name": "era",
|
1789
1858
|
"type": "publicKey"
|
@@ -1792,14 +1861,6 @@ exports.IDL = {
|
|
1792
1861
|
"name": "ownerAccount",
|
1793
1862
|
"type": "publicKey"
|
1794
1863
|
},
|
1795
|
-
{
|
1796
|
-
"name": "deposit",
|
1797
|
-
"type": "u64"
|
1798
|
-
},
|
1799
|
-
{
|
1800
|
-
"name": "closedUsh",
|
1801
|
-
"type": "u64"
|
1802
|
-
},
|
1803
1864
|
{
|
1804
1865
|
"name": "productSnapshotEntry",
|
1805
1866
|
"type": "u128"
|
@@ -1813,7 +1874,7 @@ exports.IDL = {
|
|
1813
1874
|
"type": {
|
1814
1875
|
"array": [
|
1815
1876
|
"u128",
|
1816
|
-
|
1877
|
+
128
|
1817
1878
|
]
|
1818
1879
|
}
|
1819
1880
|
},
|
@@ -1822,7 +1883,7 @@ exports.IDL = {
|
|
1822
1883
|
"type": {
|
1823
1884
|
"array": [
|
1824
1885
|
"u128",
|
1825
|
-
|
1886
|
+
128
|
1826
1887
|
]
|
1827
1888
|
}
|
1828
1889
|
},
|
@@ -1830,6 +1891,14 @@ exports.IDL = {
|
|
1830
1891
|
"name": "hedgeRewardsSnapshotAccum",
|
1831
1892
|
"type": "u128"
|
1832
1893
|
},
|
1894
|
+
{
|
1895
|
+
"name": "deposit",
|
1896
|
+
"type": "u64"
|
1897
|
+
},
|
1898
|
+
{
|
1899
|
+
"name": "closedUsh",
|
1900
|
+
"type": "u64"
|
1901
|
+
},
|
1833
1902
|
{
|
1834
1903
|
"name": "timestampOpened",
|
1835
1904
|
"type": "u64"
|
@@ -1837,6 +1906,12 @@ exports.IDL = {
|
|
1837
1906
|
{
|
1838
1907
|
"name": "timestampClosed",
|
1839
1908
|
"type": "u64"
|
1909
|
+
},
|
1910
|
+
{
|
1911
|
+
"name": "state",
|
1912
|
+
"type": {
|
1913
|
+
"defined": "PositionState"
|
1914
|
+
}
|
1840
1915
|
}
|
1841
1916
|
]
|
1842
1917
|
}
|
@@ -1847,8 +1922,8 @@ exports.IDL = {
|
|
1847
1922
|
"kind": "struct",
|
1848
1923
|
"fields": [
|
1849
1924
|
{
|
1850
|
-
"name": "
|
1851
|
-
"type": "
|
1925
|
+
"name": "vaultType",
|
1926
|
+
"type": "publicKey"
|
1852
1927
|
},
|
1853
1928
|
{
|
1854
1929
|
"name": "oraclePyth",
|
@@ -1861,6 +1936,22 @@ exports.IDL = {
|
|
1861
1936
|
{
|
1862
1937
|
"name": "oracleSwitchboard",
|
1863
1938
|
"type": "publicKey"
|
1939
|
+
},
|
1940
|
+
{
|
1941
|
+
"name": "priorityPyth",
|
1942
|
+
"type": "i8"
|
1943
|
+
},
|
1944
|
+
{
|
1945
|
+
"name": "priorityChainlink",
|
1946
|
+
"type": "i8"
|
1947
|
+
},
|
1948
|
+
{
|
1949
|
+
"name": "prioritySwitchboard",
|
1950
|
+
"type": "i8"
|
1951
|
+
},
|
1952
|
+
{
|
1953
|
+
"name": "vaultTypeName",
|
1954
|
+
"type": "string"
|
1864
1955
|
}
|
1865
1956
|
]
|
1866
1957
|
}
|
@@ -1883,7 +1974,7 @@ exports.IDL = {
|
|
1883
1974
|
"type": {
|
1884
1975
|
"array": [
|
1885
1976
|
"u128",
|
1886
|
-
|
1977
|
+
128
|
1887
1978
|
]
|
1888
1979
|
}
|
1889
1980
|
},
|
@@ -1892,7 +1983,7 @@ exports.IDL = {
|
|
1892
1983
|
"type": {
|
1893
1984
|
"array": [
|
1894
1985
|
"u128",
|
1895
|
-
|
1986
|
+
128
|
1896
1987
|
]
|
1897
1988
|
}
|
1898
1989
|
},
|
@@ -1980,7 +2071,7 @@ exports.IDL = {
|
|
1980
2071
|
"type": {
|
1981
2072
|
"array": [
|
1982
2073
|
"u128",
|
1983
|
-
|
2074
|
+
128
|
1984
2075
|
]
|
1985
2076
|
}
|
1986
2077
|
},
|
@@ -2064,7 +2155,7 @@ exports.IDL = {
|
|
2064
2155
|
},
|
2065
2156
|
{
|
2066
2157
|
"name": "totalUshSupply",
|
2067
|
-
"type": "
|
2158
|
+
"type": "u128"
|
2068
2159
|
},
|
2069
2160
|
{
|
2070
2161
|
"name": "totalVaults",
|
@@ -2104,10 +2195,6 @@ exports.IDL = {
|
|
2104
2195
|
"type": {
|
2105
2196
|
"kind": "struct",
|
2106
2197
|
"fields": [
|
2107
|
-
{
|
2108
|
-
"name": "collateralType",
|
2109
|
-
"type": "string"
|
2110
|
-
},
|
2111
2198
|
{
|
2112
2199
|
"name": "collateralMint",
|
2113
2200
|
"type": "publicKey"
|
@@ -2180,15 +2267,27 @@ exports.IDL = {
|
|
2180
2267
|
"name": "interestRatePerSecond",
|
2181
2268
|
"type": "u128"
|
2182
2269
|
},
|
2270
|
+
{
|
2271
|
+
"name": "deprecated",
|
2272
|
+
"type": "bool"
|
2273
|
+
},
|
2274
|
+
{
|
2275
|
+
"name": "totalFeesAccumulatedUsh",
|
2276
|
+
"type": "u128"
|
2277
|
+
},
|
2278
|
+
{
|
2279
|
+
"name": "totalFeesAccumulatedCollateral",
|
2280
|
+
"type": "u128"
|
2281
|
+
},
|
2282
|
+
{
|
2283
|
+
"name": "vaultTypeName",
|
2284
|
+
"type": "string"
|
2285
|
+
},
|
2183
2286
|
{
|
2184
2287
|
"name": "firstVaultToRedeem",
|
2185
2288
|
"type": {
|
2186
2289
|
"option": "publicKey"
|
2187
2290
|
}
|
2188
|
-
},
|
2189
|
-
{
|
2190
|
-
"name": "deprecated",
|
2191
|
-
"type": "bool"
|
2192
2291
|
}
|
2193
2292
|
]
|
2194
2293
|
}
|
@@ -2215,12 +2314,14 @@ exports.IDL = {
|
|
2215
2314
|
"type": "u64"
|
2216
2315
|
},
|
2217
2316
|
{
|
2218
|
-
"name": "
|
2219
|
-
"type":
|
2317
|
+
"name": "vaultStatus",
|
2318
|
+
"type": {
|
2319
|
+
"defined": "VaultStatus"
|
2320
|
+
}
|
2220
2321
|
},
|
2221
2322
|
{
|
2222
|
-
"name": "
|
2223
|
-
"type": "
|
2323
|
+
"name": "vaultType",
|
2324
|
+
"type": "publicKey"
|
2224
2325
|
},
|
2225
2326
|
{
|
2226
2327
|
"name": "bump",
|
@@ -2244,12 +2345,6 @@ exports.IDL = {
|
|
2244
2345
|
"defined": "CurrencyType"
|
2245
2346
|
}
|
2246
2347
|
},
|
2247
|
-
{
|
2248
|
-
"name": "vaultStatus",
|
2249
|
-
"type": {
|
2250
|
-
"defined": "VaultStatus"
|
2251
|
-
}
|
2252
|
-
},
|
2253
2348
|
{
|
2254
2349
|
"name": "timeCreated",
|
2255
2350
|
"type": "u64"
|
@@ -2258,6 +2353,14 @@ exports.IDL = {
|
|
2258
2353
|
"name": "timeLastInteraction",
|
2259
2354
|
"type": "u64"
|
2260
2355
|
},
|
2356
|
+
{
|
2357
|
+
"name": "vaultTypeName",
|
2358
|
+
"type": "string"
|
2359
|
+
},
|
2360
|
+
{
|
2361
|
+
"name": "pdaSalt",
|
2362
|
+
"type": "string"
|
2363
|
+
},
|
2261
2364
|
{
|
2262
2365
|
"name": "nextVaultToRedeem",
|
2263
2366
|
"type": {
|
@@ -2352,6 +2455,24 @@ exports.IDL = {
|
|
2352
2455
|
"option": "publicKey"
|
2353
2456
|
}
|
2354
2457
|
},
|
2458
|
+
{
|
2459
|
+
"name": "priorityChainlink",
|
2460
|
+
"type": {
|
2461
|
+
"option": "i8"
|
2462
|
+
}
|
2463
|
+
},
|
2464
|
+
{
|
2465
|
+
"name": "priorityPyth",
|
2466
|
+
"type": {
|
2467
|
+
"option": "i8"
|
2468
|
+
}
|
2469
|
+
},
|
2470
|
+
{
|
2471
|
+
"name": "prioritySwitchboard",
|
2472
|
+
"type": {
|
2473
|
+
"option": "i8"
|
2474
|
+
}
|
2475
|
+
},
|
2355
2476
|
{
|
2356
2477
|
"name": "deprecated",
|
2357
2478
|
"type": {
|
@@ -2676,8 +2797,8 @@ exports.IDL = {
|
|
2676
2797
|
},
|
2677
2798
|
{
|
2678
2799
|
"code": 6020,
|
2679
|
-
"name": "
|
2680
|
-
"msg": "Can only redeem
|
2800
|
+
"name": "NotRedeemingLowestCollateralRatioVault",
|
2801
|
+
"msg": "Can only redeem lowest collateral ratio vault in system."
|
2681
2802
|
},
|
2682
2803
|
{
|
2683
2804
|
"code": 6021,
|
@@ -2691,8 +2812,38 @@ exports.IDL = {
|
|
2691
2812
|
},
|
2692
2813
|
{
|
2693
2814
|
"code": 6023,
|
2815
|
+
"name": "InvalidSaltLength",
|
2816
|
+
"msg": "Salt for new vaults must be of length 8"
|
2817
|
+
},
|
2818
|
+
{
|
2819
|
+
"code": 6024,
|
2820
|
+
"name": "InvalidNameLength",
|
2821
|
+
"msg": "Name for new vault type must be length 16"
|
2822
|
+
},
|
2823
|
+
{
|
2824
|
+
"code": 6025,
|
2694
2825
|
"name": "UpdateVaultTypeBadMaxDebtExtended",
|
2695
2826
|
"msg": "New Max debt extended value is less than the current debt!"
|
2827
|
+
},
|
2828
|
+
{
|
2829
|
+
"code": 6026,
|
2830
|
+
"name": "UpdateVaultTypeNoEnabledOracles",
|
2831
|
+
"msg": "No Enabled Oracles!"
|
2832
|
+
},
|
2833
|
+
{
|
2834
|
+
"code": 6027,
|
2835
|
+
"name": "UpdateVaultTypeDuplicateOraclePriorities",
|
2836
|
+
"msg": "Duplicate Oracle Priorities"
|
2837
|
+
},
|
2838
|
+
{
|
2839
|
+
"code": 6028,
|
2840
|
+
"name": "UpdateVaultTypeInvalidOraclePriority",
|
2841
|
+
"msg": "Invalid Oracle Priority"
|
2842
|
+
},
|
2843
|
+
{
|
2844
|
+
"code": 6029,
|
2845
|
+
"name": "OracleUpdateFailed",
|
2846
|
+
"msg": "OracleUpdateFailed"
|
2696
2847
|
}
|
2697
2848
|
]
|
2698
2849
|
};
|
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);
|
@@ -8,12 +8,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
9
|
});
|
10
10
|
};
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
15
|
exports.claimLiquidationPoolPositionInstruction = exports.claimLiquidationPoolPosition = void 0;
|
13
16
|
const spl_token_1 = require("@solana/spl-token");
|
14
17
|
const web3_js_1 = require("@solana/web3.js");
|
15
18
|
const Errors_1 = require("../utils/Errors");
|
16
19
|
const Constants_1 = require("../Constants");
|
20
|
+
const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
|
17
21
|
function claimLiquidationPoolPosition(program, provider, poolPosition, payer, collateralType, overrideStartTime) {
|
18
22
|
return __awaiter(this, void 0, void 0, function* () {
|
19
23
|
const vaultTypeAccountPublicKey = yield (0, Constants_1.getVaultTypeAccountPublicKey)(collateralType);
|
@@ -21,7 +25,7 @@ function claimLiquidationPoolPosition(program, provider, poolPosition, payer, co
|
|
21
25
|
const collateralMintPublicKey = vaultTypeAccountInfo.collateralMint;
|
22
26
|
const payerAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMintPublicKey, payer.publicKey);
|
23
27
|
const transaction = new web3_js_1.Transaction().add(yield claimLiquidationPoolPositionInstruction(program, vaultTypeAccountPublicKey, collateralMintPublicKey, poolPosition, payer.publicKey, payerAssociatedTokenAccount.address, overrideStartTime));
|
24
|
-
yield (0,
|
28
|
+
yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer]).catch(Errors_1.parseAnchorErrors);
|
25
29
|
return payerAssociatedTokenAccount.address;
|
26
30
|
});
|
27
31
|
}
|
@@ -8,12 +8,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
9
|
});
|
10
10
|
};
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
15
|
exports.claimStakingPoolPositionInstruction = exports.claimStakingPoolPosition = void 0;
|
13
16
|
const spl_token_1 = require("@solana/spl-token");
|
14
17
|
const web3_js_1 = require("@solana/web3.js");
|
15
18
|
const Errors_1 = require("../utils/Errors");
|
16
19
|
const Constants_1 = require("../Constants");
|
20
|
+
const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
|
17
21
|
function claimStakingPoolPosition(program, provider, poolPosition, payer, collateralType) {
|
18
22
|
return __awaiter(this, void 0, void 0, function* () {
|
19
23
|
const vaultTypeAccount = yield (0, Constants_1.getVaultTypeAccountPublicKey)(collateralType);
|
@@ -24,7 +28,7 @@ function claimStakingPoolPosition(program, provider, poolPosition, payer, collat
|
|
24
28
|
const feePoolAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMint, feePool, true);
|
25
29
|
const payerAssociatedTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMint, payer.publicKey);
|
26
30
|
const transaction = new web3_js_1.Transaction().add(yield claimStakingPoolPositionInstruction(program, feePool, feePoolAssociatedTokenAccount.address, stakedTokenMint, vaultTypeAccount, collateralMint, poolPosition, payer.publicKey, payerAssociatedTokenAccount.address));
|
27
|
-
yield (0,
|
31
|
+
yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer]).catch(Errors_1.parseAnchorErrors);
|
28
32
|
return payerAssociatedTokenAccount.address;
|
29
33
|
});
|
30
34
|
}
|
@@ -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
|
+
.closeClaimedLiquidationPool()
|
31
|
+
.accounts({
|
32
|
+
poolPosition: poolPosition,
|
33
|
+
payer: payer
|
34
|
+
})
|
35
|
+
.instruction();
|
36
|
+
});
|
37
|
+
}
|
38
|
+
exports.closeClaimedLiquidationPoolPositionInstruction = closeClaimedLiquidationPoolPositionInstruction;
|
@@ -8,6 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
9
|
});
|
10
10
|
};
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
15
|
exports.closeLiquidationPoolPositionInstruction = exports.closeLiquidationPoolPosition = void 0;
|
13
16
|
const anchor_1 = require("@project-serum/anchor");
|
@@ -15,6 +18,7 @@ const spl_token_1 = require("@solana/spl-token");
|
|
15
18
|
const web3_js_1 = require("@solana/web3.js");
|
16
19
|
const Errors_1 = require("../utils/Errors");
|
17
20
|
const Constants_1 = require("../Constants");
|
21
|
+
const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
|
18
22
|
function closeLiquidationPoolPosition(program, provider, poolPosition, payer, overrideStartTime) {
|
19
23
|
return __awaiter(this, void 0, void 0, function* () {
|
20
24
|
const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
|
@@ -26,7 +30,7 @@ function closeLiquidationPoolPosition(program, provider, poolPosition, payer, ov
|
|
26
30
|
const payerAssociatedHedgeAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, hedgeMint, payer.publicKey);
|
27
31
|
const communityAssociatedHedgeTokenAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, hedgeMint, vaultSystemStatePublicKey, true);
|
28
32
|
const transaction = new web3_js_1.Transaction().add(yield closeLiquidationPoolPositionInstruction(program, poolEra, poolPosition, payer.publicKey, payerUshAccount.address, payerAssociatedHedgeAccount.address, communityAssociatedHedgeTokenAccount.address, overrideStartTime));
|
29
|
-
yield (0,
|
33
|
+
yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer]).catch(Errors_1.parseAnchorErrors);
|
30
34
|
return poolPosition;
|
31
35
|
});
|
32
36
|
}
|
@@ -8,6 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
9
|
});
|
10
10
|
};
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
15
|
exports.createStakingPoolInstruction = exports.createStakingPool = void 0;
|
13
16
|
const anchor_1 = require("@project-serum/anchor");
|
@@ -15,10 +18,11 @@ const spl_token_1 = require("@solana/spl-token");
|
|
15
18
|
const web3_js_1 = require("@solana/web3.js");
|
16
19
|
const Errors_1 = require("../utils/Errors");
|
17
20
|
const Constants_1 = require("../Constants");
|
21
|
+
const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
|
18
22
|
function createStakingPool(program, provider, payer, mintPublicKey, hedgeTokensToBeMinted, overrideStartTime) {
|
19
23
|
return __awaiter(this, void 0, void 0, function* () {
|
20
24
|
const transaction = new web3_js_1.Transaction().add(yield createStakingPoolInstruction(program, payer.publicKey, mintPublicKey, hedgeTokensToBeMinted, overrideStartTime));
|
21
|
-
yield (0,
|
25
|
+
yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer]).catch(Errors_1.parseAnchorErrors);
|
22
26
|
const [poolPublickey] = yield (0, Constants_1.getPoolPublicKeyForMint)(mintPublicKey);
|
23
27
|
return poolPublickey;
|
24
28
|
});
|
@@ -8,6 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
9
|
});
|
10
10
|
};
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
15
|
exports.createVaultInstruction = exports.buildCreateVaultTransaction = exports.createVault = void 0;
|
13
16
|
const anchor_1 = require("@project-serum/anchor");
|
@@ -17,6 +20,7 @@ const web3_js_1 = require("@solana/web3.js");
|
|
17
20
|
const Constants_1 = require("../Constants");
|
18
21
|
const uuid_1 = require("uuid");
|
19
22
|
const Errors_1 = require("../utils/Errors");
|
23
|
+
const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
|
20
24
|
function createVault(program, provider, payer, collateralType, depositAmount, overrideTime) {
|
21
25
|
return __awaiter(this, void 0, void 0, function* () {
|
22
26
|
const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
|
@@ -57,7 +61,7 @@ function createVault(program, provider, payer, collateralType, depositAmount, ov
|
|
57
61
|
owner: payer.publicKey,
|
58
62
|
}));
|
59
63
|
}
|
60
|
-
yield (0,
|
64
|
+
yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, signers).catch(Errors_1.parseAnchorErrors);
|
61
65
|
return newVaultPublicKey;
|
62
66
|
});
|
63
67
|
}
|
@@ -8,6 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
9
|
});
|
10
10
|
};
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
15
|
exports.depositLiquidationPoolInstruction = exports.depositLiquidationPool = void 0;
|
13
16
|
const anchor_1 = require("@project-serum/anchor");
|
@@ -15,13 +18,14 @@ const spl_token_1 = require("@solana/spl-token");
|
|
15
18
|
const web3_js_1 = require("@solana/web3.js");
|
16
19
|
const Errors_1 = require("../utils/Errors");
|
17
20
|
const Constants_1 = require("../Constants");
|
21
|
+
const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
|
18
22
|
function depositLiquidationPool(program, provider, payer, depositAmount, overrideStartTime) {
|
19
23
|
return __awaiter(this, void 0, void 0, function* () {
|
20
24
|
const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
|
21
25
|
const payerUshAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, ushMintPublickey, payer.publicKey);
|
22
26
|
const poolPosition = web3_js_1.Keypair.generate();
|
23
27
|
const transaction = new web3_js_1.Transaction().add(yield depositLiquidationPoolInstruction(program, payer.publicKey, payerUshAccount.address, poolPosition.publicKey, depositAmount, overrideStartTime));
|
24
|
-
yield (0,
|
28
|
+
yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer, poolPosition]).catch(Errors_1.parseAnchorErrors);
|
25
29
|
return poolPosition.publicKey;
|
26
30
|
});
|
27
31
|
}
|
@@ -8,6 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
9
|
});
|
10
10
|
};
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
15
|
exports.depositStakingPoolInstruction = exports.depositStakingPool = void 0;
|
13
16
|
const anchor_1 = require("@project-serum/anchor");
|
@@ -15,11 +18,12 @@ const spl_token_1 = require("@solana/spl-token");
|
|
15
18
|
const web3_js_1 = require("@solana/web3.js");
|
16
19
|
const Errors_1 = require("../utils/Errors");
|
17
20
|
const Constants_1 = require("../Constants");
|
21
|
+
const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
|
18
22
|
function depositStakingPool(program, provider, payer, mintPublicKey, depositAmount, overrideStartTime) {
|
19
23
|
return __awaiter(this, void 0, void 0, function* () {
|
20
24
|
const poolPosition = web3_js_1.Keypair.generate();
|
21
25
|
const transaction = new web3_js_1.Transaction().add(yield depositStakingPoolInstruction(program, payer.publicKey, poolPosition.publicKey, mintPublicKey, depositAmount, overrideStartTime));
|
22
|
-
yield (0,
|
26
|
+
yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer, poolPosition]).catch(Errors_1.parseAnchorErrors);
|
23
27
|
return poolPosition.publicKey;
|
24
28
|
});
|
25
29
|
}
|