hedge-web3 0.1.46 → 0.2.1
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 +109 -47
- 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 +109 -47
- 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 +218 -94
- 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": [
|
@@ -1772,7 +1777,7 @@ exports.IDL = {
|
|
1772
1777
|
"type": {
|
1773
1778
|
"array": [
|
1774
1779
|
"u128",
|
1775
|
-
|
1780
|
+
128
|
1776
1781
|
]
|
1777
1782
|
}
|
1778
1783
|
},
|
@@ -1832,10 +1837,6 @@ exports.IDL = {
|
|
1832
1837
|
"type": {
|
1833
1838
|
"kind": "struct",
|
1834
1839
|
"fields": [
|
1835
|
-
{
|
1836
|
-
"name": "state",
|
1837
|
-
"type": "u64"
|
1838
|
-
},
|
1839
1840
|
{
|
1840
1841
|
"name": "era",
|
1841
1842
|
"type": "publicKey"
|
@@ -1844,14 +1845,6 @@ exports.IDL = {
|
|
1844
1845
|
"name": "ownerAccount",
|
1845
1846
|
"type": "publicKey"
|
1846
1847
|
},
|
1847
|
-
{
|
1848
|
-
"name": "deposit",
|
1849
|
-
"type": "u64"
|
1850
|
-
},
|
1851
|
-
{
|
1852
|
-
"name": "closedUsh",
|
1853
|
-
"type": "u64"
|
1854
|
-
},
|
1855
1848
|
{
|
1856
1849
|
"name": "productSnapshotEntry",
|
1857
1850
|
"type": "u128"
|
@@ -1865,7 +1858,7 @@ exports.IDL = {
|
|
1865
1858
|
"type": {
|
1866
1859
|
"array": [
|
1867
1860
|
"u128",
|
1868
|
-
|
1861
|
+
128
|
1869
1862
|
]
|
1870
1863
|
}
|
1871
1864
|
},
|
@@ -1874,7 +1867,7 @@ exports.IDL = {
|
|
1874
1867
|
"type": {
|
1875
1868
|
"array": [
|
1876
1869
|
"u128",
|
1877
|
-
|
1870
|
+
128
|
1878
1871
|
]
|
1879
1872
|
}
|
1880
1873
|
},
|
@@ -1882,6 +1875,14 @@ exports.IDL = {
|
|
1882
1875
|
"name": "hedgeRewardsSnapshotAccum",
|
1883
1876
|
"type": "u128"
|
1884
1877
|
},
|
1878
|
+
{
|
1879
|
+
"name": "deposit",
|
1880
|
+
"type": "u64"
|
1881
|
+
},
|
1882
|
+
{
|
1883
|
+
"name": "closedUsh",
|
1884
|
+
"type": "u64"
|
1885
|
+
},
|
1885
1886
|
{
|
1886
1887
|
"name": "timestampOpened",
|
1887
1888
|
"type": "u64"
|
@@ -1889,6 +1890,12 @@ exports.IDL = {
|
|
1889
1890
|
{
|
1890
1891
|
"name": "timestampClosed",
|
1891
1892
|
"type": "u64"
|
1893
|
+
},
|
1894
|
+
{
|
1895
|
+
"name": "state",
|
1896
|
+
"type": {
|
1897
|
+
"defined": "PositionState"
|
1898
|
+
}
|
1892
1899
|
}
|
1893
1900
|
]
|
1894
1901
|
}
|
@@ -1899,8 +1906,8 @@ exports.IDL = {
|
|
1899
1906
|
"kind": "struct",
|
1900
1907
|
"fields": [
|
1901
1908
|
{
|
1902
|
-
"name": "
|
1903
|
-
"type": "
|
1909
|
+
"name": "vaultType",
|
1910
|
+
"type": "publicKey"
|
1904
1911
|
},
|
1905
1912
|
{
|
1906
1913
|
"name": "oraclePyth",
|
@@ -1915,8 +1922,20 @@ exports.IDL = {
|
|
1915
1922
|
"type": "publicKey"
|
1916
1923
|
},
|
1917
1924
|
{
|
1918
|
-
"name": "
|
1919
|
-
"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"
|
1920
1939
|
}
|
1921
1940
|
]
|
1922
1941
|
}
|
@@ -1939,7 +1958,7 @@ exports.IDL = {
|
|
1939
1958
|
"type": {
|
1940
1959
|
"array": [
|
1941
1960
|
"u128",
|
1942
|
-
|
1961
|
+
128
|
1943
1962
|
]
|
1944
1963
|
}
|
1945
1964
|
},
|
@@ -1948,7 +1967,7 @@ exports.IDL = {
|
|
1948
1967
|
"type": {
|
1949
1968
|
"array": [
|
1950
1969
|
"u128",
|
1951
|
-
|
1970
|
+
128
|
1952
1971
|
]
|
1953
1972
|
}
|
1954
1973
|
},
|
@@ -2036,7 +2055,7 @@ exports.IDL = {
|
|
2036
2055
|
"type": {
|
2037
2056
|
"array": [
|
2038
2057
|
"u128",
|
2039
|
-
|
2058
|
+
128
|
2040
2059
|
]
|
2041
2060
|
}
|
2042
2061
|
},
|
@@ -2120,7 +2139,7 @@ exports.IDL = {
|
|
2120
2139
|
},
|
2121
2140
|
{
|
2122
2141
|
"name": "totalUshSupply",
|
2123
|
-
"type": "
|
2142
|
+
"type": "u128"
|
2124
2143
|
},
|
2125
2144
|
{
|
2126
2145
|
"name": "totalVaults",
|
@@ -2160,10 +2179,6 @@ exports.IDL = {
|
|
2160
2179
|
"type": {
|
2161
2180
|
"kind": "struct",
|
2162
2181
|
"fields": [
|
2163
|
-
{
|
2164
|
-
"name": "vaultTypeName",
|
2165
|
-
"type": "string"
|
2166
|
-
},
|
2167
2182
|
{
|
2168
2183
|
"name": "collateralMint",
|
2169
2184
|
"type": "publicKey"
|
@@ -2236,12 +2251,6 @@ exports.IDL = {
|
|
2236
2251
|
"name": "interestRatePerSecond",
|
2237
2252
|
"type": "u128"
|
2238
2253
|
},
|
2239
|
-
{
|
2240
|
-
"name": "firstVaultToRedeem",
|
2241
|
-
"type": {
|
2242
|
-
"option": "publicKey"
|
2243
|
-
}
|
2244
|
-
},
|
2245
2254
|
{
|
2246
2255
|
"name": "deprecated",
|
2247
2256
|
"type": "bool"
|
@@ -2253,6 +2262,16 @@ exports.IDL = {
|
|
2253
2262
|
{
|
2254
2263
|
"name": "totalFeesAccumulatedCollateral",
|
2255
2264
|
"type": "u128"
|
2265
|
+
},
|
2266
|
+
{
|
2267
|
+
"name": "vaultTypeName",
|
2268
|
+
"type": "string"
|
2269
|
+
},
|
2270
|
+
{
|
2271
|
+
"name": "firstVaultToRedeem",
|
2272
|
+
"type": {
|
2273
|
+
"option": "publicKey"
|
2274
|
+
}
|
2256
2275
|
}
|
2257
2276
|
]
|
2258
2277
|
}
|
@@ -2279,12 +2298,14 @@ exports.IDL = {
|
|
2279
2298
|
"type": "u64"
|
2280
2299
|
},
|
2281
2300
|
{
|
2282
|
-
"name": "
|
2283
|
-
"type":
|
2301
|
+
"name": "vaultStatus",
|
2302
|
+
"type": {
|
2303
|
+
"defined": "VaultStatus"
|
2304
|
+
}
|
2284
2305
|
},
|
2285
2306
|
{
|
2286
|
-
"name": "
|
2287
|
-
"type": "
|
2307
|
+
"name": "vaultType",
|
2308
|
+
"type": "publicKey"
|
2288
2309
|
},
|
2289
2310
|
{
|
2290
2311
|
"name": "bump",
|
@@ -2308,12 +2329,6 @@ exports.IDL = {
|
|
2308
2329
|
"defined": "CurrencyType"
|
2309
2330
|
}
|
2310
2331
|
},
|
2311
|
-
{
|
2312
|
-
"name": "vaultStatus",
|
2313
|
-
"type": {
|
2314
|
-
"defined": "VaultStatus"
|
2315
|
-
}
|
2316
|
-
},
|
2317
2332
|
{
|
2318
2333
|
"name": "timeCreated",
|
2319
2334
|
"type": "u64"
|
@@ -2322,15 +2337,19 @@ exports.IDL = {
|
|
2322
2337
|
"name": "timeLastInteraction",
|
2323
2338
|
"type": "u64"
|
2324
2339
|
},
|
2340
|
+
{
|
2341
|
+
"name": "vaultTypeName",
|
2342
|
+
"type": "string"
|
2343
|
+
},
|
2344
|
+
{
|
2345
|
+
"name": "pdaSalt",
|
2346
|
+
"type": "string"
|
2347
|
+
},
|
2325
2348
|
{
|
2326
2349
|
"name": "nextVaultToRedeem",
|
2327
2350
|
"type": {
|
2328
2351
|
"option": "publicKey"
|
2329
2352
|
}
|
2330
|
-
},
|
2331
|
-
{
|
2332
|
-
"name": "vaultType",
|
2333
|
-
"type": "publicKey"
|
2334
2353
|
}
|
2335
2354
|
]
|
2336
2355
|
}
|
@@ -2420,6 +2439,24 @@ exports.IDL = {
|
|
2420
2439
|
"option": "publicKey"
|
2421
2440
|
}
|
2422
2441
|
},
|
2442
|
+
{
|
2443
|
+
"name": "priorityChainlink",
|
2444
|
+
"type": {
|
2445
|
+
"option": "i8"
|
2446
|
+
}
|
2447
|
+
},
|
2448
|
+
{
|
2449
|
+
"name": "priorityPyth",
|
2450
|
+
"type": {
|
2451
|
+
"option": "i8"
|
2452
|
+
}
|
2453
|
+
},
|
2454
|
+
{
|
2455
|
+
"name": "prioritySwitchboard",
|
2456
|
+
"type": {
|
2457
|
+
"option": "i8"
|
2458
|
+
}
|
2459
|
+
},
|
2423
2460
|
{
|
2424
2461
|
"name": "deprecated",
|
2425
2462
|
"type": {
|
@@ -2764,8 +2801,33 @@ exports.IDL = {
|
|
2764
2801
|
},
|
2765
2802
|
{
|
2766
2803
|
"code": 6024,
|
2804
|
+
"name": "InvalidNameLength",
|
2805
|
+
"msg": "Name for new vault type must be length 16"
|
2806
|
+
},
|
2807
|
+
{
|
2808
|
+
"code": 6025,
|
2767
2809
|
"name": "UpdateVaultTypeBadMaxDebtExtended",
|
2768
2810
|
"msg": "New Max debt extended value is less than the current debt!"
|
2811
|
+
},
|
2812
|
+
{
|
2813
|
+
"code": 6026,
|
2814
|
+
"name": "UpdateVaultTypeNoEnabledOracles",
|
2815
|
+
"msg": "No Enabled Oracles!"
|
2816
|
+
},
|
2817
|
+
{
|
2818
|
+
"code": 6027,
|
2819
|
+
"name": "UpdateVaultTypeDuplicateOraclePriorities",
|
2820
|
+
"msg": "Duplicate Oracle Priorities"
|
2821
|
+
},
|
2822
|
+
{
|
2823
|
+
"code": 6028,
|
2824
|
+
"name": "UpdateVaultTypeInvalidOraclePriority",
|
2825
|
+
"msg": "Invalid Oracle Priority"
|
2826
|
+
},
|
2827
|
+
{
|
2828
|
+
"code": 6029,
|
2829
|
+
"name": "OracleUpdateFailed",
|
2830
|
+
"msg": "OracleUpdateFailed"
|
2769
2831
|
}
|
2770
2832
|
]
|
2771
2833
|
};
|
@@ -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
|
}
|