hedge-web3 0.1.44 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- package/declarations/Constants.d.ts +2 -1
- package/declarations/idl/vault.d.ts +161 -35
- package/declarations/instructions/claimLiquidationPoolPosition.d.ts +1 -1
- package/declarations/instructions/claimStakingPoolPosition.d.ts +1 -1
- 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 +1 -1
- 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 +4 -3
- package/declarations/utils/getLinkedListAccounts.d.ts +1 -1
- package/lib/Constants.js +3 -2
- package/lib/idl/vault.js +161 -35
- package/lib/instructions/claimLiquidationPoolPosition.js +5 -1
- package/lib/instructions/claimStakingPoolPosition.js +5 -1
- package/lib/instructions/closeLiquidationPoolPosition.js +5 -1
- package/lib/instructions/createStakingPool.js +5 -2
- 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 +5 -1
- package/lib/instructions/initHedgeFoundation.js +5 -1
- package/lib/instructions/initHedgeFoundationTokens.js +5 -1
- package/lib/instructions/liquidateVault.js +5 -1
- package/lib/instructions/loanVault.js +5 -3
- package/lib/instructions/redeemVault.js +5 -1
- package/lib/instructions/refreshOraclePrice.js +6 -1
- package/lib/instructions/repayVault.js +5 -1
- 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 +5 -1
- package/lib/state/VaultAccount.js +11 -9
- package/lib/utils/getLinkedListAccounts.js +48 -48
- package/package.json +1 -1
- package/src/Constants.ts +2 -1
- package/src/idl/vault.ts +322 -70
- package/src/instructions/claimLiquidationPoolPosition.ts +3 -2
- package/src/instructions/claimStakingPoolPosition.ts +3 -2
- package/src/instructions/closeLiquidationPoolPosition.ts +3 -2
- package/src/instructions/createStakingPool.ts +3 -3
- 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 +3 -3
- package/src/instructions/initHedgeFoundation.ts +3 -2
- package/src/instructions/initHedgeFoundationTokens.ts +2 -1
- package/src/instructions/liquidateVault.ts +5 -3
- package/src/instructions/loanVault.ts +3 -4
- package/src/instructions/redeemVault.ts +3 -2
- package/src/instructions/refreshOraclePrice.ts +7 -4
- package/src/instructions/repayVault.ts +3 -2
- package/src/instructions/setHalted.ts +3 -2
- package/src/instructions/updateVaultType.ts +10 -2
- package/src/instructions/withdrawStakingPool.ts +3 -2
- package/src/instructions/withdrawVault.ts +3 -2
- package/src/state/VaultAccount.ts +17 -12
- package/src/state/VaultType.ts +62 -0
- package/src/utils/getLinkedListAccounts.ts +54 -49
- package/src/utils/sendAndConfirmWithDebug.ts +27 -0
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,58 @@ 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": []
|
1655
1712
|
}
|
1656
1713
|
],
|
1657
1714
|
"accounts": [
|
@@ -1780,10 +1837,6 @@ exports.IDL = {
|
|
1780
1837
|
"type": {
|
1781
1838
|
"kind": "struct",
|
1782
1839
|
"fields": [
|
1783
|
-
{
|
1784
|
-
"name": "state",
|
1785
|
-
"type": "u64"
|
1786
|
-
},
|
1787
1840
|
{
|
1788
1841
|
"name": "era",
|
1789
1842
|
"type": "publicKey"
|
@@ -1792,14 +1845,6 @@ exports.IDL = {
|
|
1792
1845
|
"name": "ownerAccount",
|
1793
1846
|
"type": "publicKey"
|
1794
1847
|
},
|
1795
|
-
{
|
1796
|
-
"name": "deposit",
|
1797
|
-
"type": "u64"
|
1798
|
-
},
|
1799
|
-
{
|
1800
|
-
"name": "closedUsh",
|
1801
|
-
"type": "u64"
|
1802
|
-
},
|
1803
1848
|
{
|
1804
1849
|
"name": "productSnapshotEntry",
|
1805
1850
|
"type": "u128"
|
@@ -1830,6 +1875,14 @@ exports.IDL = {
|
|
1830
1875
|
"name": "hedgeRewardsSnapshotAccum",
|
1831
1876
|
"type": "u128"
|
1832
1877
|
},
|
1878
|
+
{
|
1879
|
+
"name": "deposit",
|
1880
|
+
"type": "u64"
|
1881
|
+
},
|
1882
|
+
{
|
1883
|
+
"name": "closedUsh",
|
1884
|
+
"type": "u64"
|
1885
|
+
},
|
1833
1886
|
{
|
1834
1887
|
"name": "timestampOpened",
|
1835
1888
|
"type": "u64"
|
@@ -1837,6 +1890,12 @@ exports.IDL = {
|
|
1837
1890
|
{
|
1838
1891
|
"name": "timestampClosed",
|
1839
1892
|
"type": "u64"
|
1893
|
+
},
|
1894
|
+
{
|
1895
|
+
"name": "state",
|
1896
|
+
"type": {
|
1897
|
+
"defined": "PositionState"
|
1898
|
+
}
|
1840
1899
|
}
|
1841
1900
|
]
|
1842
1901
|
}
|
@@ -1847,8 +1906,8 @@ exports.IDL = {
|
|
1847
1906
|
"kind": "struct",
|
1848
1907
|
"fields": [
|
1849
1908
|
{
|
1850
|
-
"name": "
|
1851
|
-
"type": "
|
1909
|
+
"name": "vaultType",
|
1910
|
+
"type": "publicKey"
|
1852
1911
|
},
|
1853
1912
|
{
|
1854
1913
|
"name": "oraclePyth",
|
@@ -1863,8 +1922,20 @@ exports.IDL = {
|
|
1863
1922
|
"type": "publicKey"
|
1864
1923
|
},
|
1865
1924
|
{
|
1866
|
-
"name": "
|
1867
|
-
"type": "
|
1925
|
+
"name": "priorityPyth",
|
1926
|
+
"type": "i8"
|
1927
|
+
},
|
1928
|
+
{
|
1929
|
+
"name": "priorityChainlink",
|
1930
|
+
"type": "i8"
|
1931
|
+
},
|
1932
|
+
{
|
1933
|
+
"name": "prioritySwitchboard",
|
1934
|
+
"type": "i8"
|
1935
|
+
},
|
1936
|
+
{
|
1937
|
+
"name": "vaultTypeName",
|
1938
|
+
"type": "string"
|
1868
1939
|
}
|
1869
1940
|
]
|
1870
1941
|
}
|
@@ -2068,7 +2139,7 @@ exports.IDL = {
|
|
2068
2139
|
},
|
2069
2140
|
{
|
2070
2141
|
"name": "totalUshSupply",
|
2071
|
-
"type": "
|
2142
|
+
"type": "u128"
|
2072
2143
|
},
|
2073
2144
|
{
|
2074
2145
|
"name": "totalVaults",
|
@@ -2108,10 +2179,6 @@ exports.IDL = {
|
|
2108
2179
|
"type": {
|
2109
2180
|
"kind": "struct",
|
2110
2181
|
"fields": [
|
2111
|
-
{
|
2112
|
-
"name": "vaultTypeName",
|
2113
|
-
"type": "string"
|
2114
|
-
},
|
2115
2182
|
{
|
2116
2183
|
"name": "collateralMint",
|
2117
2184
|
"type": "publicKey"
|
@@ -2184,6 +2251,22 @@ exports.IDL = {
|
|
2184
2251
|
"name": "interestRatePerSecond",
|
2185
2252
|
"type": "u128"
|
2186
2253
|
},
|
2254
|
+
{
|
2255
|
+
"name": "deprecated",
|
2256
|
+
"type": "bool"
|
2257
|
+
},
|
2258
|
+
{
|
2259
|
+
"name": "totalFeesAccumulatedUsh",
|
2260
|
+
"type": "u128"
|
2261
|
+
},
|
2262
|
+
{
|
2263
|
+
"name": "totalFeesAccumulatedCollateral",
|
2264
|
+
"type": "u128"
|
2265
|
+
},
|
2266
|
+
{
|
2267
|
+
"name": "vaultTypeName",
|
2268
|
+
"type": "string"
|
2269
|
+
},
|
2187
2270
|
{
|
2188
2271
|
"name": "firstVaultToRedeem",
|
2189
2272
|
"type": {
|
@@ -2227,12 +2310,14 @@ exports.IDL = {
|
|
2227
2310
|
"type": "u64"
|
2228
2311
|
},
|
2229
2312
|
{
|
2230
|
-
"name": "
|
2231
|
-
"type":
|
2313
|
+
"name": "vaultStatus",
|
2314
|
+
"type": {
|
2315
|
+
"defined": "VaultStatus"
|
2316
|
+
}
|
2232
2317
|
},
|
2233
2318
|
{
|
2234
|
-
"name": "
|
2235
|
-
"type": "
|
2319
|
+
"name": "vaultType",
|
2320
|
+
"type": "publicKey"
|
2236
2321
|
},
|
2237
2322
|
{
|
2238
2323
|
"name": "bump",
|
@@ -2256,12 +2341,6 @@ exports.IDL = {
|
|
2256
2341
|
"defined": "CurrencyType"
|
2257
2342
|
}
|
2258
2343
|
},
|
2259
|
-
{
|
2260
|
-
"name": "vaultStatus",
|
2261
|
-
"type": {
|
2262
|
-
"defined": "VaultStatus"
|
2263
|
-
}
|
2264
|
-
},
|
2265
2344
|
{
|
2266
2345
|
"name": "timeCreated",
|
2267
2346
|
"type": "u64"
|
@@ -2270,15 +2349,19 @@ exports.IDL = {
|
|
2270
2349
|
"name": "timeLastInteraction",
|
2271
2350
|
"type": "u64"
|
2272
2351
|
},
|
2352
|
+
{
|
2353
|
+
"name": "vaultTypeName",
|
2354
|
+
"type": "string"
|
2355
|
+
},
|
2356
|
+
{
|
2357
|
+
"name": "pdaSalt",
|
2358
|
+
"type": "string"
|
2359
|
+
},
|
2273
2360
|
{
|
2274
2361
|
"name": "nextVaultToRedeem",
|
2275
2362
|
"type": {
|
2276
2363
|
"option": "publicKey"
|
2277
2364
|
}
|
2278
|
-
},
|
2279
|
-
{
|
2280
|
-
"name": "vaultType",
|
2281
|
-
"type": "publicKey"
|
2282
2365
|
}
|
2283
2366
|
]
|
2284
2367
|
}
|
@@ -2368,6 +2451,24 @@ exports.IDL = {
|
|
2368
2451
|
"option": "publicKey"
|
2369
2452
|
}
|
2370
2453
|
},
|
2454
|
+
{
|
2455
|
+
"name": "priorityChainlink",
|
2456
|
+
"type": {
|
2457
|
+
"option": "i8"
|
2458
|
+
}
|
2459
|
+
},
|
2460
|
+
{
|
2461
|
+
"name": "priorityPyth",
|
2462
|
+
"type": {
|
2463
|
+
"option": "i8"
|
2464
|
+
}
|
2465
|
+
},
|
2466
|
+
{
|
2467
|
+
"name": "prioritySwitchboard",
|
2468
|
+
"type": {
|
2469
|
+
"option": "i8"
|
2470
|
+
}
|
2471
|
+
},
|
2371
2472
|
{
|
2372
2473
|
"name": "deprecated",
|
2373
2474
|
"type": {
|
@@ -2712,8 +2813,33 @@ exports.IDL = {
|
|
2712
2813
|
},
|
2713
2814
|
{
|
2714
2815
|
"code": 6024,
|
2816
|
+
"name": "InvalidNameLength",
|
2817
|
+
"msg": "Name for new vault type must be length 16"
|
2818
|
+
},
|
2819
|
+
{
|
2820
|
+
"code": 6025,
|
2715
2821
|
"name": "UpdateVaultTypeBadMaxDebtExtended",
|
2716
2822
|
"msg": "New Max debt extended value is less than the current debt!"
|
2823
|
+
},
|
2824
|
+
{
|
2825
|
+
"code": 6025,
|
2826
|
+
"name": "UpdateVaultTypeNoEnabledOracles",
|
2827
|
+
"msg": "No Enabled Oracles!"
|
2828
|
+
},
|
2829
|
+
{
|
2830
|
+
"code": 6026,
|
2831
|
+
"name": "UpdateVaultTypeDuplicateOraclePriorities",
|
2832
|
+
"msg": "Duplicate Oracle Priorities"
|
2833
|
+
},
|
2834
|
+
{
|
2835
|
+
"code": 6027,
|
2836
|
+
"name": "UpdateVaultTypeInvalidOraclePriority",
|
2837
|
+
"msg": "Invalid Oracle Priority"
|
2838
|
+
},
|
2839
|
+
{
|
2840
|
+
"code": 6028,
|
2841
|
+
"name": "OracleUpdateFailed",
|
2842
|
+
"msg": "OracleUpdateFailed"
|
2717
2843
|
}
|
2718
2844
|
]
|
2719
2845
|
};
|
@@ -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
|
}
|
@@ -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
|
});
|
@@ -26,7 +30,6 @@ function createStakingPool(program, provider, payer, mintPublicKey, hedgeTokensT
|
|
26
30
|
exports.createStakingPool = createStakingPool;
|
27
31
|
function createStakingPoolInstruction(program, payerPublicKey, mintPublicKey, hedgeTokensToBeMinted, overrideStartTime) {
|
28
32
|
return __awaiter(this, void 0, void 0, function* () {
|
29
|
-
console.log("new createStakingPoolInstruction");
|
30
33
|
const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
|
31
34
|
const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
|
32
35
|
const [poolPublickey, poolBump] = yield (0, Constants_1.getPoolPublicKeyForMint)(mintPublicKey);
|
@@ -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
|
}
|
@@ -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.depositVaultInstruction = exports.depositVault = void 0;
|
13
16
|
const anchor_1 = require("@project-serum/anchor");
|
@@ -16,6 +19,7 @@ const spl_token_1 = require("@solana/spl-token");
|
|
16
19
|
const web3_js_1 = require("@solana/web3.js");
|
17
20
|
const getLinkedListAccounts_1 = require("../utils/getLinkedListAccounts");
|
18
21
|
const Constants_1 = require("../Constants");
|
22
|
+
const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
|
19
23
|
const token_instructions_1 = require("@project-serum/serum/lib/token-instructions");
|
20
24
|
function depositVault(program, provider, payer, vaultPublicKey, depositAmount, overrideTime) {
|
21
25
|
return __awaiter(this, void 0, void 0, function* () {
|
@@ -57,7 +61,7 @@ function depositVault(program, provider, payer, vaultPublicKey, depositAmount, o
|
|
57
61
|
owner: payer.publicKey,
|
58
62
|
}));
|
59
63
|
}
|
60
|
-
yield (0,
|
64
|
+
yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, signers);
|
61
65
|
return vaultPublicKey;
|
62
66
|
});
|
63
67
|
}
|
@@ -8,17 +8,21 @@ 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.initHedgeFoundationInstruction = exports.initHedgeFoundation = 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 initHedgeFoundation(program, provider, payer) {
|
18
22
|
return __awaiter(this, void 0, void 0, function* () {
|
19
23
|
const poolEra = web3_js_1.Keypair.generate();
|
20
24
|
const transaction = new web3_js_1.Transaction().add(yield initHedgeFoundationInstruction(program, poolEra.publicKey, payer.publicKey));
|
21
|
-
yield (0,
|
25
|
+
yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer, poolEra]).catch(Errors_1.parseAnchorErrors);
|
22
26
|
return payer.publicKey;
|
23
27
|
});
|
24
28
|
}
|
@@ -8,17 +8,21 @@ 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.initHedgeFoundationTokensInstruction = exports.initHedgeFoundationTokens = 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 initHedgeFoundationTokens(program, provider, payer) {
|
18
22
|
return __awaiter(this, void 0, void 0, function* () {
|
19
23
|
const poolEra = web3_js_1.Keypair.generate();
|
20
24
|
const transaction = new web3_js_1.Transaction().add(yield initHedgeFoundationTokensInstruction(program, payer.publicKey));
|
21
|
-
yield (0,
|
25
|
+
yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer]).catch(Errors_1.parseAnchorErrors);
|
22
26
|
return payer.publicKey;
|
23
27
|
});
|
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.liquidateVaultInstruction = exports.liquidateVault = 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 getLinkedListAccounts_1 = require("../utils/getLinkedListAccounts");
|
17
20
|
const Constants_1 = require("../Constants");
|
21
|
+
const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
|
18
22
|
function liquidateVault(program, provider, payer, vaultPublicKey, overrideTime) {
|
19
23
|
return __awaiter(this, void 0, void 0, function* () {
|
20
24
|
const vaultAccount = yield program.account.vault.fetch(vaultPublicKey);
|
@@ -36,7 +40,7 @@ function liquidateVault(program, provider, payer, vaultPublicKey, overrideTime)
|
|
36
40
|
const newEra = web3_js_1.Keypair.generate();
|
37
41
|
const transaction = new web3_js_1.Transaction();
|
38
42
|
transaction.add(yield liquidateVaultInstruction(program, payer.publicKey, payerAssociatedTokenAccount.address, vaultPublicKey, vaultAssociatedTokenAccount.address, liquidationPoolStatePublicKey, poolStateInfo.currentEra, poolAssociatedTokenAccount.address, history.publicKey, newEra.publicKey, hedgeStakingPoolPublicKey, feePoolAssociatedTokenAccount.address, hedgeStakingPoolAssociatedUshTokenAccount.address, collateralMint, vaultTypeAssociatedTokenAccount.address, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, vaultAccount.vaultType, overrideTime));
|
39
|
-
yield (0,
|
43
|
+
yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer, history, newEra]);
|
40
44
|
return vaultPublicKey;
|
41
45
|
});
|
42
46
|
}
|
@@ -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.loanVaultInstruction = exports.loanVault = void 0;
|
13
16
|
const anchor_1 = require("@project-serum/anchor");
|
@@ -15,8 +18,7 @@ const spl_token_1 = require("@solana/spl-token");
|
|
15
18
|
const web3_js_1 = require("@solana/web3.js");
|
16
19
|
const getLinkedListAccounts_1 = require("../utils/getLinkedListAccounts");
|
17
20
|
const Constants_1 = require("../Constants");
|
18
|
-
const
|
19
|
-
const fs = require('fs');
|
21
|
+
const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
|
20
22
|
function loanVault(program, provider, payer, vaultPublicKey, loanAmount, overrideTime) {
|
21
23
|
return __awaiter(this, void 0, void 0, function* () {
|
22
24
|
const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
|
@@ -28,7 +30,7 @@ function loanVault(program, provider, payer, vaultPublicKey, loanAmount, overrid
|
|
28
30
|
const [oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey] = yield (0, getLinkedListAccounts_1.getLinkedListAccounts)(program, provider, vaultAccount.vaultType, vaultPublicKey, 0, loanAmount, false, false);
|
29
31
|
const history = web3_js_1.Keypair.generate();
|
30
32
|
const transaction = new web3_js_1.Transaction().add(yield loanVaultInstruction(program, payer.publicKey, payerUshAccount.address, vaultPublicKey, vaultAssociatedTokenAccount.address, history.publicKey, vaultAccount.vaultType, vaultTypeAssociatedTokenAccount.address, oldSmallerPublicKey, newSmallerPublicKey, newLargerPublicKey, loanAmount, overrideTime));
|
31
|
-
yield (0,
|
33
|
+
yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer, history]);
|
32
34
|
return vaultPublicKey;
|
33
35
|
});
|
34
36
|
}
|