hedge-web3 0.2.14 → 0.2.17
Sign up to get free protection for your applications and to get access to all the features.
- package/declarations/idl/vault.d.ts +266 -11
- package/declarations/index.d.ts +2 -0
- package/declarations/instructions/psmMintUsh.d.ts +6 -0
- package/declarations/instructions/psmRedeemUsh.d.ts +6 -0
- package/lib/idl/vault.js +266 -11
- package/lib/index.js +2 -0
- package/lib/instructions/psmMintUsh.js +65 -0
- package/lib/instructions/psmRedeemUsh.js +65 -0
- package/package.json +1 -1
- package/src/idl/vault.ts +532 -22
- package/src/index.ts +2 -0
- package/src/instructions/psmMintUsh.ts +129 -0
- package/src/instructions/psmRedeemUsh.ts +129 -0
package/lib/idl/vault.js
CHANGED
@@ -1759,7 +1759,7 @@ exports.IDL = {
|
|
1759
1759
|
"args": []
|
1760
1760
|
},
|
1761
1761
|
{
|
1762
|
-
"name": "
|
1762
|
+
"name": "psmCreate",
|
1763
1763
|
"accounts": [
|
1764
1764
|
{
|
1765
1765
|
"name": "payer",
|
@@ -1772,30 +1772,106 @@ exports.IDL = {
|
|
1772
1772
|
"isSigner": false
|
1773
1773
|
},
|
1774
1774
|
{
|
1775
|
-
"name": "
|
1775
|
+
"name": "psmAccount",
|
1776
1776
|
"isMut": true,
|
1777
1777
|
"isSigner": false
|
1778
1778
|
},
|
1779
1779
|
{
|
1780
|
-
"name": "
|
1780
|
+
"name": "collateralMint",
|
1781
|
+
"isMut": false,
|
1782
|
+
"isSigner": false
|
1783
|
+
},
|
1784
|
+
{
|
1785
|
+
"name": "systemProgram",
|
1786
|
+
"isMut": false,
|
1787
|
+
"isSigner": false
|
1788
|
+
}
|
1789
|
+
],
|
1790
|
+
"args": [
|
1791
|
+
{
|
1792
|
+
"name": "mintFee",
|
1793
|
+
"type": "u64"
|
1794
|
+
},
|
1795
|
+
{
|
1796
|
+
"name": "redeemFee",
|
1797
|
+
"type": "u64"
|
1798
|
+
},
|
1799
|
+
{
|
1800
|
+
"name": "debtLimit",
|
1801
|
+
"type": "u64"
|
1802
|
+
},
|
1803
|
+
{
|
1804
|
+
"name": "minSwap",
|
1805
|
+
"type": "u64"
|
1806
|
+
},
|
1807
|
+
{
|
1808
|
+
"name": "collateralDecimals",
|
1809
|
+
"type": "u8"
|
1810
|
+
},
|
1811
|
+
{
|
1812
|
+
"name": "overrideCurrentTime",
|
1813
|
+
"type": "i64"
|
1814
|
+
}
|
1815
|
+
]
|
1816
|
+
},
|
1817
|
+
{
|
1818
|
+
"name": "psmMintUsh",
|
1819
|
+
"accounts": [
|
1820
|
+
{
|
1821
|
+
"name": "payer",
|
1822
|
+
"isMut": true,
|
1823
|
+
"isSigner": true
|
1824
|
+
},
|
1825
|
+
{
|
1826
|
+
"name": "vaultSystemState",
|
1781
1827
|
"isMut": true,
|
1782
1828
|
"isSigner": false
|
1783
1829
|
},
|
1784
1830
|
{
|
1785
|
-
"name": "
|
1831
|
+
"name": "feePool",
|
1786
1832
|
"isMut": true,
|
1787
1833
|
"isSigner": false
|
1788
1834
|
},
|
1789
1835
|
{
|
1790
|
-
"name": "
|
1836
|
+
"name": "feePoolAssociatedUshTokenAccount",
|
1837
|
+
"isMut": true,
|
1838
|
+
"isSigner": false
|
1839
|
+
},
|
1840
|
+
{
|
1841
|
+
"name": "psmAccount",
|
1842
|
+
"isMut": true,
|
1843
|
+
"isSigner": false
|
1844
|
+
},
|
1845
|
+
{
|
1846
|
+
"name": "psmAccountAta",
|
1847
|
+
"isMut": true,
|
1848
|
+
"isSigner": false
|
1849
|
+
},
|
1850
|
+
{
|
1851
|
+
"name": "ownerUshAccount",
|
1852
|
+
"isMut": true,
|
1853
|
+
"isSigner": false
|
1854
|
+
},
|
1855
|
+
{
|
1856
|
+
"name": "ownerCollateralAccount",
|
1791
1857
|
"isMut": true,
|
1792
1858
|
"isSigner": false
|
1793
1859
|
},
|
1794
1860
|
{
|
1795
1861
|
"name": "collateralMint",
|
1862
|
+
"isMut": false,
|
1863
|
+
"isSigner": false
|
1864
|
+
},
|
1865
|
+
{
|
1866
|
+
"name": "ushMint",
|
1796
1867
|
"isMut": true,
|
1797
1868
|
"isSigner": false
|
1798
1869
|
},
|
1870
|
+
{
|
1871
|
+
"name": "systemProgram",
|
1872
|
+
"isMut": false,
|
1873
|
+
"isSigner": false
|
1874
|
+
},
|
1799
1875
|
{
|
1800
1876
|
"name": "tokenProgram",
|
1801
1877
|
"isMut": false,
|
@@ -1804,12 +1880,87 @@ exports.IDL = {
|
|
1804
1880
|
],
|
1805
1881
|
"args": [
|
1806
1882
|
{
|
1807
|
-
"name": "
|
1883
|
+
"name": "collateralAmount",
|
1808
1884
|
"type": "u64"
|
1809
1885
|
},
|
1810
1886
|
{
|
1811
|
-
"name": "
|
1887
|
+
"name": "overrideCurrentTime",
|
1888
|
+
"type": "i64"
|
1889
|
+
}
|
1890
|
+
]
|
1891
|
+
},
|
1892
|
+
{
|
1893
|
+
"name": "psmRedeemUsh",
|
1894
|
+
"accounts": [
|
1895
|
+
{
|
1896
|
+
"name": "payer",
|
1897
|
+
"isMut": true,
|
1898
|
+
"isSigner": true
|
1899
|
+
},
|
1900
|
+
{
|
1901
|
+
"name": "vaultSystemState",
|
1902
|
+
"isMut": true,
|
1903
|
+
"isSigner": false
|
1904
|
+
},
|
1905
|
+
{
|
1906
|
+
"name": "feePool",
|
1907
|
+
"isMut": true,
|
1908
|
+
"isSigner": false
|
1909
|
+
},
|
1910
|
+
{
|
1911
|
+
"name": "feePoolAssociatedUshTokenAccount",
|
1912
|
+
"isMut": true,
|
1913
|
+
"isSigner": false
|
1914
|
+
},
|
1915
|
+
{
|
1916
|
+
"name": "psmAccount",
|
1917
|
+
"isMut": true,
|
1918
|
+
"isSigner": false
|
1919
|
+
},
|
1920
|
+
{
|
1921
|
+
"name": "psmAccountAta",
|
1922
|
+
"isMut": true,
|
1923
|
+
"isSigner": false
|
1924
|
+
},
|
1925
|
+
{
|
1926
|
+
"name": "ownerUshAccount",
|
1927
|
+
"isMut": true,
|
1928
|
+
"isSigner": false
|
1929
|
+
},
|
1930
|
+
{
|
1931
|
+
"name": "ownerCollateralAccount",
|
1932
|
+
"isMut": true,
|
1933
|
+
"isSigner": false
|
1934
|
+
},
|
1935
|
+
{
|
1936
|
+
"name": "collateralMint",
|
1937
|
+
"isMut": false,
|
1938
|
+
"isSigner": false
|
1939
|
+
},
|
1940
|
+
{
|
1941
|
+
"name": "ushMint",
|
1942
|
+
"isMut": true,
|
1943
|
+
"isSigner": false
|
1944
|
+
},
|
1945
|
+
{
|
1946
|
+
"name": "systemProgram",
|
1947
|
+
"isMut": false,
|
1948
|
+
"isSigner": false
|
1949
|
+
},
|
1950
|
+
{
|
1951
|
+
"name": "tokenProgram",
|
1952
|
+
"isMut": false,
|
1953
|
+
"isSigner": false
|
1954
|
+
}
|
1955
|
+
],
|
1956
|
+
"args": [
|
1957
|
+
{
|
1958
|
+
"name": "ushAmount",
|
1812
1959
|
"type": "u64"
|
1960
|
+
},
|
1961
|
+
{
|
1962
|
+
"name": "overrideCurrentTime",
|
1963
|
+
"type": "i64"
|
1813
1964
|
}
|
1814
1965
|
]
|
1815
1966
|
}
|
@@ -2043,6 +2194,80 @@ exports.IDL = {
|
|
2043
2194
|
]
|
2044
2195
|
}
|
2045
2196
|
},
|
2197
|
+
{
|
2198
|
+
"name": "psmAccount",
|
2199
|
+
"type": {
|
2200
|
+
"kind": "struct",
|
2201
|
+
"fields": [
|
2202
|
+
{
|
2203
|
+
"name": "collateralMint",
|
2204
|
+
"type": "publicKey"
|
2205
|
+
},
|
2206
|
+
{
|
2207
|
+
"name": "minCollateralRatio",
|
2208
|
+
"type": "u128"
|
2209
|
+
},
|
2210
|
+
{
|
2211
|
+
"name": "mintFee",
|
2212
|
+
"type": "u128"
|
2213
|
+
},
|
2214
|
+
{
|
2215
|
+
"name": "redeemFee",
|
2216
|
+
"type": "u128"
|
2217
|
+
},
|
2218
|
+
{
|
2219
|
+
"name": "totalFeesAccumulatedUsh",
|
2220
|
+
"type": "u128"
|
2221
|
+
},
|
2222
|
+
{
|
2223
|
+
"name": "totalFeesAccumulatedCollateral",
|
2224
|
+
"type": "u128"
|
2225
|
+
},
|
2226
|
+
{
|
2227
|
+
"name": "recentPrice",
|
2228
|
+
"type": "u128"
|
2229
|
+
},
|
2230
|
+
{
|
2231
|
+
"name": "debtLimit",
|
2232
|
+
"type": "u64"
|
2233
|
+
},
|
2234
|
+
{
|
2235
|
+
"name": "deposited",
|
2236
|
+
"type": "u64"
|
2237
|
+
},
|
2238
|
+
{
|
2239
|
+
"name": "amountMinted",
|
2240
|
+
"type": "u64"
|
2241
|
+
},
|
2242
|
+
{
|
2243
|
+
"name": "minSwap",
|
2244
|
+
"type": "u64"
|
2245
|
+
},
|
2246
|
+
{
|
2247
|
+
"name": "timeCreated",
|
2248
|
+
"type": "u64"
|
2249
|
+
},
|
2250
|
+
{
|
2251
|
+
"name": "timeLastInteraction",
|
2252
|
+
"type": "u64"
|
2253
|
+
},
|
2254
|
+
{
|
2255
|
+
"name": "priceLastUpdatedTimestamp",
|
2256
|
+
"type": "u64"
|
2257
|
+
},
|
2258
|
+
{
|
2259
|
+
"name": "psmStatus",
|
2260
|
+
"type": {
|
2261
|
+
"defined": "PsmStatus"
|
2262
|
+
}
|
2263
|
+
},
|
2264
|
+
{
|
2265
|
+
"name": "collateralDecimals",
|
2266
|
+
"type": "u8"
|
2267
|
+
}
|
2268
|
+
]
|
2269
|
+
}
|
2270
|
+
},
|
2046
2271
|
{
|
2047
2272
|
"name": "stakingPoolPosition",
|
2048
2273
|
"type": {
|
@@ -2620,6 +2845,26 @@ exports.IDL = {
|
|
2620
2845
|
]
|
2621
2846
|
}
|
2622
2847
|
},
|
2848
|
+
{
|
2849
|
+
"name": "PsmStatus",
|
2850
|
+
"type": {
|
2851
|
+
"kind": "enum",
|
2852
|
+
"variants": [
|
2853
|
+
{
|
2854
|
+
"name": "PsmEnabled"
|
2855
|
+
},
|
2856
|
+
{
|
2857
|
+
"name": "PsmDisabled"
|
2858
|
+
},
|
2859
|
+
{
|
2860
|
+
"name": "MintOnly"
|
2861
|
+
},
|
2862
|
+
{
|
2863
|
+
"name": "RedeemOnly"
|
2864
|
+
}
|
2865
|
+
]
|
2866
|
+
}
|
2867
|
+
},
|
2623
2868
|
{
|
2624
2869
|
"name": "SystemStatus",
|
2625
2870
|
"type": {
|
@@ -2916,26 +3161,36 @@ exports.IDL = {
|
|
2916
3161
|
},
|
2917
3162
|
{
|
2918
3163
|
"code": 6027,
|
3164
|
+
"name": "PsmDisabled",
|
3165
|
+
"msg": "PSM is currently disabled."
|
3166
|
+
},
|
3167
|
+
{
|
3168
|
+
"code": 6028,
|
3169
|
+
"name": "PsmError",
|
3170
|
+
"msg": "PSM error."
|
3171
|
+
},
|
3172
|
+
{
|
3173
|
+
"code": 6029,
|
2919
3174
|
"name": "UpdateVaultTypeBadMaxDebtExtended",
|
2920
3175
|
"msg": "New Max debt extended value is less than the current debt!"
|
2921
3176
|
},
|
2922
3177
|
{
|
2923
|
-
"code":
|
3178
|
+
"code": 6030,
|
2924
3179
|
"name": "UpdateVaultTypeNoEnabledOracles",
|
2925
3180
|
"msg": "No Enabled Oracles!"
|
2926
3181
|
},
|
2927
3182
|
{
|
2928
|
-
"code":
|
3183
|
+
"code": 6031,
|
2929
3184
|
"name": "UpdateVaultTypeDuplicateOraclePriorities",
|
2930
3185
|
"msg": "Duplicate Oracle Priorities"
|
2931
3186
|
},
|
2932
3187
|
{
|
2933
|
-
"code":
|
3188
|
+
"code": 6032,
|
2934
3189
|
"name": "UpdateVaultTypeInvalidOraclePriority",
|
2935
3190
|
"msg": "Invalid Oracle Priority"
|
2936
3191
|
},
|
2937
3192
|
{
|
2938
|
-
"code":
|
3193
|
+
"code": 6033,
|
2939
3194
|
"name": "OracleUpdateFailed",
|
2940
3195
|
"msg": "OracleUpdateFailed"
|
2941
3196
|
}
|
package/lib/index.js
CHANGED
@@ -19,6 +19,8 @@ __exportStar(require("./instructions/closeLiquidationPoolPosition"), exports);
|
|
19
19
|
__exportStar(require("./instructions/claimLiquidationPoolPosition"), exports);
|
20
20
|
__exportStar(require("./instructions/closeClaimedLiquidationPoolPosition"), exports);
|
21
21
|
__exportStar(require("./instructions/createVault"), exports);
|
22
|
+
__exportStar(require("./instructions/psmMintUsh"), exports);
|
23
|
+
__exportStar(require("./instructions/psmRedeemUsh"), exports);
|
22
24
|
__exportStar(require("./instructions/depositVault"), exports);
|
23
25
|
__exportStar(require("./instructions/withdrawVault"), exports);
|
24
26
|
__exportStar(require("./instructions/loanVault"), exports);
|
@@ -0,0 +1,65 @@
|
|
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.psmMintUshInstruction = exports.psmMintUsh = void 0;
|
16
|
+
const anchor_1 = require("@project-serum/anchor");
|
17
|
+
const spl_token_1 = require("@solana/spl-token");
|
18
|
+
const web3_js_1 = require("@solana/web3.js");
|
19
|
+
const Constants_1 = require("../Constants");
|
20
|
+
const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
|
21
|
+
function psmMintUsh(program, provider, payer, collateralMint, collateralAmount, overrideTime) {
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
23
|
+
const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
|
24
|
+
const payerUshAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, ushMintPublickey, payer.publicKey);
|
25
|
+
const payerCollateralAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMint, payer.publicKey);
|
26
|
+
const enc = new TextEncoder();
|
27
|
+
const [psmAccount] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode(collateralMint.toString().slice(0, 12)), enc.encode('PSM')], Constants_1.HEDGE_PROGRAM_PUBLICKEY);
|
28
|
+
const psmAccountAta = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMint, psmAccount, true);
|
29
|
+
const transaction = new web3_js_1.Transaction().add(yield psmMintUshInstruction(program, payer.publicKey, psmAccount, collateralMint, new anchor_1.BN(collateralAmount), overrideTime));
|
30
|
+
yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer]);
|
31
|
+
return payer.publicKey;
|
32
|
+
});
|
33
|
+
}
|
34
|
+
exports.psmMintUsh = psmMintUsh;
|
35
|
+
function psmMintUshInstruction(program, payerPublicKey, psmAccount, collateralMint, collateralAmount, overrideTime) {
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
37
|
+
const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
|
38
|
+
const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
|
39
|
+
const hedgeMintPublickey = yield (0, Constants_1.getHedgeMintPublicKey)();
|
40
|
+
const [hedgeStakingPoolPublicKey] = yield (0, Constants_1.getPoolPublicKeyForMint)(hedgeMintPublickey);
|
41
|
+
const hedgeStakingPoolAssociatedUshTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(hedgeStakingPoolPublicKey, ushMintPublickey);
|
42
|
+
const psmAccountAta = yield (0, Constants_1.findAssociatedTokenAddress)(psmAccount, collateralMint);
|
43
|
+
const ownerCollateralAccount = yield (0, Constants_1.findAssociatedTokenAddress)(payerPublicKey, collateralMint);
|
44
|
+
const ownerUshAccount = yield (0, Constants_1.findAssociatedTokenAddress)(payerPublicKey, ushMintPublickey);
|
45
|
+
return yield program.methods
|
46
|
+
.psmMintUsh(collateralAmount, new anchor_1.BN(overrideTime !== null && overrideTime !== void 0 ? overrideTime : Math.floor(Date.now() / 1000)) // override override time
|
47
|
+
)
|
48
|
+
.accounts({
|
49
|
+
payer: payerPublicKey,
|
50
|
+
vaultSystemState: vaultSystemStatePublicKey,
|
51
|
+
feePool: hedgeStakingPoolPublicKey,
|
52
|
+
feePoolAssociatedUshTokenAccount: hedgeStakingPoolAssociatedUshTokenAccount,
|
53
|
+
psmAccount: psmAccount,
|
54
|
+
psmAccountAta: psmAccountAta,
|
55
|
+
ownerUshAccount: ownerUshAccount,
|
56
|
+
ownerCollateralAccount: ownerCollateralAccount,
|
57
|
+
collateralMint: collateralMint,
|
58
|
+
ushMint: ushMintPublickey,
|
59
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
60
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
61
|
+
})
|
62
|
+
.instruction();
|
63
|
+
});
|
64
|
+
}
|
65
|
+
exports.psmMintUshInstruction = psmMintUshInstruction;
|
@@ -0,0 +1,65 @@
|
|
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.psmRedeemUshInstruction = exports.psmRedeemUsh = void 0;
|
16
|
+
const anchor_1 = require("@project-serum/anchor");
|
17
|
+
const spl_token_1 = require("@solana/spl-token");
|
18
|
+
const web3_js_1 = require("@solana/web3.js");
|
19
|
+
const Constants_1 = require("../Constants");
|
20
|
+
const sendAndConfirmWithDebug_1 = __importDefault(require("../utils/sendAndConfirmWithDebug"));
|
21
|
+
function psmRedeemUsh(program, provider, payer, collateralMint, ushAmount, overrideTime) {
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
23
|
+
const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
|
24
|
+
const payerUshAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, ushMintPublickey, payer.publicKey);
|
25
|
+
const payerCollateralAccount = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMint, payer.publicKey);
|
26
|
+
const enc = new TextEncoder();
|
27
|
+
const [psmAccount] = yield web3_js_1.PublicKey.findProgramAddress([enc.encode(collateralMint.toString().slice(0, 12)), enc.encode('PSM')], Constants_1.HEDGE_PROGRAM_PUBLICKEY);
|
28
|
+
const psmAccountAta = yield (0, spl_token_1.getOrCreateAssociatedTokenAccount)(provider.connection, payer, collateralMint, psmAccount, true);
|
29
|
+
const transaction = new web3_js_1.Transaction().add(yield psmRedeemUshInstruction(program, payer.publicKey, psmAccount, collateralMint, new anchor_1.BN(ushAmount), overrideTime));
|
30
|
+
yield (0, sendAndConfirmWithDebug_1.default)(provider.connection, transaction, [payer]);
|
31
|
+
return payer.publicKey;
|
32
|
+
});
|
33
|
+
}
|
34
|
+
exports.psmRedeemUsh = psmRedeemUsh;
|
35
|
+
function psmRedeemUshInstruction(program, payerPublicKey, psmAccount, collateralMint, ushAmount, overrideTime) {
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
37
|
+
const vaultSystemStatePublicKey = yield (0, Constants_1.getVaultSystemStatePublicKey)();
|
38
|
+
const ushMintPublickey = yield (0, Constants_1.getUshMintPublicKey)();
|
39
|
+
const hedgeMintPublickey = yield (0, Constants_1.getHedgeMintPublicKey)();
|
40
|
+
const [hedgeStakingPoolPublicKey] = yield (0, Constants_1.getPoolPublicKeyForMint)(hedgeMintPublickey);
|
41
|
+
const hedgeStakingPoolAssociatedUshTokenAccount = yield (0, Constants_1.findAssociatedTokenAddress)(hedgeStakingPoolPublicKey, ushMintPublickey);
|
42
|
+
const psmAccountAta = yield (0, Constants_1.findAssociatedTokenAddress)(psmAccount, collateralMint);
|
43
|
+
const ownerCollateralAccount = yield (0, Constants_1.findAssociatedTokenAddress)(payerPublicKey, collateralMint);
|
44
|
+
const ownerUshAccount = yield (0, Constants_1.findAssociatedTokenAddress)(payerPublicKey, ushMintPublickey);
|
45
|
+
return yield program.methods
|
46
|
+
.psmRedeemUsh(ushAmount, new anchor_1.BN(overrideTime !== null && overrideTime !== void 0 ? overrideTime : Math.floor(Date.now() / 1000)) // override override time
|
47
|
+
)
|
48
|
+
.accounts({
|
49
|
+
payer: payerPublicKey,
|
50
|
+
vaultSystemState: vaultSystemStatePublicKey,
|
51
|
+
feePool: hedgeStakingPoolPublicKey,
|
52
|
+
feePoolAssociatedUshTokenAccount: hedgeStakingPoolAssociatedUshTokenAccount,
|
53
|
+
psmAccount: psmAccount,
|
54
|
+
psmAccountAta: psmAccountAta,
|
55
|
+
ownerUshAccount: ownerUshAccount,
|
56
|
+
ownerCollateralAccount: ownerCollateralAccount,
|
57
|
+
collateralMint: collateralMint,
|
58
|
+
ushMint: ushMintPublickey,
|
59
|
+
systemProgram: web3_js_1.SystemProgram.programId,
|
60
|
+
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
61
|
+
})
|
62
|
+
.instruction();
|
63
|
+
});
|
64
|
+
}
|
65
|
+
exports.psmRedeemUshInstruction = psmRedeemUshInstruction;
|