flash-sdk 11.11.5-alpha.0 → 11.11.6
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/dist/CustodyAccount.d.ts +1 -1
- package/dist/MarketAccount.d.ts +2 -2
- package/dist/OraclePrice.d.ts +1 -0
- package/dist/OrderAccount.d.ts +1 -0
- package/dist/PerpetualsClient.d.ts +4387 -236
- package/dist/PerpetualsClient.js +411 -303
- package/dist/PoolAccount.d.ts +1 -0
- package/dist/PoolConfig.json +271 -23
- package/dist/PoolDataClient.d.ts +1 -0
- package/dist/PositionAccount.d.ts +1 -0
- package/dist/TokenStakeAccount.d.ts +1 -0
- package/dist/TokenVaultAccount.d.ts +1 -0
- package/dist/ViewHelper.js +5 -8
- package/dist/backupOracle.js +4 -4
- package/dist/constants/index.d.ts +1 -0
- package/dist/idl/perpetuals.d.ts +13170 -25947
- package/dist/idl/perpetuals.js +18163 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -5
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +157 -46
- package/dist/types/index.js +20 -35
- package/dist/utils/IdlCoder.d.ts +2 -3
- package/dist/utils/IdlCoder.js +9 -21
- package/dist/utils/alt.js +6 -5
- package/dist/utils/anchorCpiEvents.d.ts +2 -1
- package/dist/utils/anchorCpiEvents.js +10 -14
- package/dist/utils/index.js +6 -6
- package/dist/utils/rpc.js +9 -9
- package/package.json +2 -3
- package/dist/idl/perpetuals.json +0 -30940
- package/dist/types/generated.d.ts +0 -2272
- package/dist/types/generated.js +0 -2
package/dist/PerpetualsClient.js
CHANGED
|
@@ -20,8 +20,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
22
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g
|
|
24
|
-
return g
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
25
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
26
|
function step(op) {
|
|
27
27
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -68,7 +68,7 @@ var bs58_1 = require("bs58");
|
|
|
68
68
|
var PositionAccount_1 = require("./PositionAccount");
|
|
69
69
|
var types_1 = require("./types");
|
|
70
70
|
var OraclePrice_1 = require("./OraclePrice");
|
|
71
|
-
var
|
|
71
|
+
var perpetuals_1 = require("./idl/perpetuals");
|
|
72
72
|
var rpc_1 = require("./utils/rpc");
|
|
73
73
|
var utils_1 = require("./utils");
|
|
74
74
|
var constants_1 = require("./constants");
|
|
@@ -262,6 +262,11 @@ var PerpetualsClient = (function () {
|
|
|
262
262
|
tokenMint,
|
|
263
263
|
]).publicKey;
|
|
264
264
|
};
|
|
265
|
+
this.getTradingAccount = function (tradingAccount) { return __awaiter(_this, void 0, void 0, function () {
|
|
266
|
+
return __generator(this, function (_a) {
|
|
267
|
+
return [2, this.program.account.trading.fetch(tradingAccount)];
|
|
268
|
+
});
|
|
269
|
+
}); };
|
|
265
270
|
this.getPosition = function (postionKey) { return __awaiter(_this, void 0, void 0, function () {
|
|
266
271
|
return __generator(this, function (_a) {
|
|
267
272
|
return [2, this.program.account.position.fetch(postionKey)];
|
|
@@ -280,7 +285,7 @@ var PerpetualsClient = (function () {
|
|
|
280
285
|
_a.trys.push([1, 3, , 4]);
|
|
281
286
|
return [4, this.program.methods
|
|
282
287
|
.getPositionData({})
|
|
283
|
-
.
|
|
288
|
+
.accounts({
|
|
284
289
|
perpetuals: this.perpetuals.publicKey,
|
|
285
290
|
pool: poolConfig.poolAddress,
|
|
286
291
|
position: position.publicKey,
|
|
@@ -385,7 +390,7 @@ var PerpetualsClient = (function () {
|
|
|
385
390
|
return __generator(this, function (_a) {
|
|
386
391
|
switch (_a.label) {
|
|
387
392
|
case 0:
|
|
388
|
-
data = (0, bs58_1.encode)(
|
|
393
|
+
data = (0, bs58_1.encode)(Buffer.concat([marketKey.toBuffer()]));
|
|
389
394
|
return [4, this.program.account.position.all([
|
|
390
395
|
{
|
|
391
396
|
memcmp: { bytes: data, offset: 40 }
|
|
@@ -402,7 +407,7 @@ var PerpetualsClient = (function () {
|
|
|
402
407
|
return __generator(this, function (_a) {
|
|
403
408
|
switch (_a.label) {
|
|
404
409
|
case 0:
|
|
405
|
-
data = (0, bs58_1.encode)(
|
|
410
|
+
data = (0, bs58_1.encode)(Buffer.concat([marketKey.toBuffer()]));
|
|
406
411
|
return [4, this.program.account.position.all([
|
|
407
412
|
{
|
|
408
413
|
memcmp: { bytes: data, offset: 40 }
|
|
@@ -445,7 +450,7 @@ var PerpetualsClient = (function () {
|
|
|
445
450
|
collateralCustodyConfig = poolConfig.custodies.find(function (f) { return f.mintKey.equals(collateralMint); });
|
|
446
451
|
return [4, this.program.methods
|
|
447
452
|
.liquidate({})
|
|
448
|
-
.
|
|
453
|
+
.accounts({
|
|
449
454
|
signer: this.provider.wallet.publicKey,
|
|
450
455
|
perpetuals: this.perpetuals.publicKey,
|
|
451
456
|
pool: poolConfig.poolAddress,
|
|
@@ -455,6 +460,7 @@ var PerpetualsClient = (function () {
|
|
|
455
460
|
targetOracleAccount: this.useExtOracleAccount ? targetCustodyConfig.extOracleAccount : targetCustodyConfig.intOracleAccount,
|
|
456
461
|
collateralCustody: collateralCustodyConfig.custodyAccount,
|
|
457
462
|
collateralOracleAccount: this.useExtOracleAccount ? collateralCustodyConfig.extOracleAccount : collateralCustodyConfig.intOracleAccount,
|
|
463
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
458
464
|
program: this.program.programId,
|
|
459
465
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
|
|
460
466
|
})
|
|
@@ -1969,72 +1975,204 @@ var PerpetualsClient = (function () {
|
|
|
1969
1975
|
});
|
|
1970
1976
|
});
|
|
1971
1977
|
};
|
|
1972
|
-
this.
|
|
1973
|
-
var
|
|
1974
|
-
var
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
return [4, this.getOrLoadAddressLookupTable(POOL_CONFIG)];
|
|
2025
|
-
case 3:
|
|
2026
|
-
addressLookupTables = (_e.sent()).addressLookupTables;
|
|
2027
|
-
return [4, this.viewHelper.simulateTransaction(transaction, addressLookupTables)];
|
|
2028
|
-
case 4:
|
|
2029
|
-
result = _e.sent();
|
|
2030
|
-
index = perpetuals_json_1.default.instructions.findIndex(function (f) { return f.name === 'getLpTokenPrice'; });
|
|
2031
|
-
res = this.viewHelper.decodeLogs(result, index, 'getLpTokenPrice');
|
|
2032
|
-
return [2, res.toString()];
|
|
2033
|
-
}
|
|
1978
|
+
this.getLpTokenPriceView = function (poolConfig_1) {
|
|
1979
|
+
var args_1 = [];
|
|
1980
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1981
|
+
args_1[_i - 1] = arguments[_i];
|
|
1982
|
+
}
|
|
1983
|
+
return __awaiter(_this, __spreadArray([poolConfig_1], args_1, true), void 0, function (poolConfig, includeRemainingAccounts) {
|
|
1984
|
+
var custodyAccountMetas, custodyOracleAccountMetas, markets, _a, _b, custody, _c, _d, market;
|
|
1985
|
+
if (includeRemainingAccounts === void 0) { includeRemainingAccounts = true; }
|
|
1986
|
+
return __generator(this, function (_e) {
|
|
1987
|
+
switch (_e.label) {
|
|
1988
|
+
case 0:
|
|
1989
|
+
custodyAccountMetas = [];
|
|
1990
|
+
custodyOracleAccountMetas = [];
|
|
1991
|
+
markets = [];
|
|
1992
|
+
for (_a = 0, _b = poolConfig.custodies; _a < _b.length; _a++) {
|
|
1993
|
+
custody = _b[_a];
|
|
1994
|
+
custodyAccountMetas.push({
|
|
1995
|
+
pubkey: custody.custodyAccount,
|
|
1996
|
+
isSigner: false,
|
|
1997
|
+
isWritable: false,
|
|
1998
|
+
});
|
|
1999
|
+
custodyOracleAccountMetas.push({
|
|
2000
|
+
pubkey: this.useExtOracleAccount ? custody.extOracleAccount : custody.intOracleAccount,
|
|
2001
|
+
isSigner: false,
|
|
2002
|
+
isWritable: false,
|
|
2003
|
+
});
|
|
2004
|
+
}
|
|
2005
|
+
for (_c = 0, _d = poolConfig.markets; _c < _d.length; _c++) {
|
|
2006
|
+
market = _d[_c];
|
|
2007
|
+
markets.push({
|
|
2008
|
+
pubkey: market.marketAccount,
|
|
2009
|
+
isSigner: false,
|
|
2010
|
+
isWritable: false,
|
|
2011
|
+
});
|
|
2012
|
+
}
|
|
2013
|
+
return [4, this.program.methods
|
|
2014
|
+
.getLpTokenPrice({})
|
|
2015
|
+
.accounts({
|
|
2016
|
+
perpetuals: this.perpetuals.publicKey,
|
|
2017
|
+
pool: poolConfig.poolAddress,
|
|
2018
|
+
lpTokenMint: poolConfig.stakedLpTokenMint,
|
|
2019
|
+
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
|
|
2020
|
+
})
|
|
2021
|
+
.remainingAccounts(includeRemainingAccounts ? __spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true) : [])
|
|
2022
|
+
.view()
|
|
2023
|
+
.catch(function (err) {
|
|
2024
|
+
console.error(err);
|
|
2025
|
+
throw err;
|
|
2026
|
+
})];
|
|
2027
|
+
case 1: return [2, _e.sent()];
|
|
2028
|
+
}
|
|
2029
|
+
});
|
|
2034
2030
|
});
|
|
2035
|
-
}
|
|
2031
|
+
};
|
|
2032
|
+
this.getStakedLpTokenPrice = function (poolKey_1, POOL_CONFIG_1) {
|
|
2033
|
+
var args_1 = [];
|
|
2034
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
2035
|
+
args_1[_i - 2] = arguments[_i];
|
|
2036
|
+
}
|
|
2037
|
+
return __awaiter(_this, __spreadArray([poolKey_1, POOL_CONFIG_1], args_1, true), void 0, function (poolKey, POOL_CONFIG, includeRemainingAccounts) {
|
|
2038
|
+
var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _a, custodies_1, token, _b, custodies_2, custody, _c, _d, market, transaction, backUpOracleInstruction, setCULimitIx, addressLookupTables, result, index, res;
|
|
2039
|
+
var _e;
|
|
2040
|
+
if (includeRemainingAccounts === void 0) { includeRemainingAccounts = true; }
|
|
2041
|
+
return __generator(this, function (_f) {
|
|
2042
|
+
switch (_f.label) {
|
|
2043
|
+
case 0:
|
|
2044
|
+
backUpOracleInstructionPromise = (0, backupOracle_1.createBackupOracleInstruction)(POOL_CONFIG.poolAddress.toBase58(), true);
|
|
2045
|
+
custodies = POOL_CONFIG.custodies;
|
|
2046
|
+
custodyMetas = [];
|
|
2047
|
+
marketMetas = [];
|
|
2048
|
+
for (_a = 0, custodies_1 = custodies; _a < custodies_1.length; _a++) {
|
|
2049
|
+
token = custodies_1[_a];
|
|
2050
|
+
custodyMetas.push({
|
|
2051
|
+
isSigner: false,
|
|
2052
|
+
isWritable: false,
|
|
2053
|
+
pubkey: token.custodyAccount,
|
|
2054
|
+
});
|
|
2055
|
+
}
|
|
2056
|
+
for (_b = 0, custodies_2 = custodies; _b < custodies_2.length; _b++) {
|
|
2057
|
+
custody = custodies_2[_b];
|
|
2058
|
+
custodyMetas.push({
|
|
2059
|
+
isSigner: false,
|
|
2060
|
+
isWritable: false,
|
|
2061
|
+
pubkey: custody.intOracleAccount,
|
|
2062
|
+
});
|
|
2063
|
+
}
|
|
2064
|
+
for (_c = 0, _d = POOL_CONFIG.markets; _c < _d.length; _c++) {
|
|
2065
|
+
market = _d[_c];
|
|
2066
|
+
marketMetas.push({
|
|
2067
|
+
pubkey: market.marketAccount,
|
|
2068
|
+
isSigner: false,
|
|
2069
|
+
isWritable: false,
|
|
2070
|
+
});
|
|
2071
|
+
}
|
|
2072
|
+
return [4, this.program.methods
|
|
2073
|
+
.getLpTokenPrice({})
|
|
2074
|
+
.accounts({
|
|
2075
|
+
perpetuals: POOL_CONFIG.perpetuals,
|
|
2076
|
+
pool: poolKey,
|
|
2077
|
+
lpTokenMint: POOL_CONFIG.stakedLpTokenMint,
|
|
2078
|
+
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
2079
|
+
})
|
|
2080
|
+
.remainingAccounts(includeRemainingAccounts ? __spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true) : [])
|
|
2081
|
+
.transaction()];
|
|
2082
|
+
case 1:
|
|
2083
|
+
transaction = _f.sent();
|
|
2084
|
+
return [4, backUpOracleInstructionPromise];
|
|
2085
|
+
case 2:
|
|
2086
|
+
backUpOracleInstruction = _f.sent();
|
|
2087
|
+
setCULimitIx = web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: 450000 });
|
|
2088
|
+
transaction.instructions.unshift(setCULimitIx);
|
|
2089
|
+
(_e = transaction.instructions).unshift.apply(_e, backUpOracleInstruction);
|
|
2090
|
+
return [4, this.getOrLoadAddressLookupTable(POOL_CONFIG)];
|
|
2091
|
+
case 3:
|
|
2092
|
+
addressLookupTables = (_f.sent()).addressLookupTables;
|
|
2093
|
+
return [4, this.viewHelper.simulateTransaction(transaction, addressLookupTables)];
|
|
2094
|
+
case 4:
|
|
2095
|
+
result = _f.sent();
|
|
2096
|
+
index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getLpTokenPrice'; });
|
|
2097
|
+
res = this.viewHelper.decodeLogs(result, index, 'getLpTokenPrice');
|
|
2098
|
+
return [2, res.toString()];
|
|
2099
|
+
}
|
|
2100
|
+
});
|
|
2101
|
+
});
|
|
2102
|
+
};
|
|
2103
|
+
this.getCompoundingLPTokenPrice = function (poolKey_1, POOL_CONFIG_1) {
|
|
2104
|
+
var args_1 = [];
|
|
2105
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
2106
|
+
args_1[_i - 2] = arguments[_i];
|
|
2107
|
+
}
|
|
2108
|
+
return __awaiter(_this, __spreadArray([poolKey_1, POOL_CONFIG_1], args_1, true), void 0, function (poolKey, POOL_CONFIG, includeRemainingAccounts) {
|
|
2109
|
+
var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _a, custodies_3, token, _b, custodies_4, custody, _c, _d, market, backUpOracleInstruction, transaction, setCULimitIx, addressLookupTables, result, index, res;
|
|
2110
|
+
var _e;
|
|
2111
|
+
if (includeRemainingAccounts === void 0) { includeRemainingAccounts = true; }
|
|
2112
|
+
return __generator(this, function (_f) {
|
|
2113
|
+
switch (_f.label) {
|
|
2114
|
+
case 0:
|
|
2115
|
+
backUpOracleInstructionPromise = (0, backupOracle_1.createBackupOracleInstruction)(POOL_CONFIG.poolAddress.toBase58(), true);
|
|
2116
|
+
custodies = POOL_CONFIG.custodies;
|
|
2117
|
+
custodyMetas = [];
|
|
2118
|
+
marketMetas = [];
|
|
2119
|
+
for (_a = 0, custodies_3 = custodies; _a < custodies_3.length; _a++) {
|
|
2120
|
+
token = custodies_3[_a];
|
|
2121
|
+
custodyMetas.push({
|
|
2122
|
+
isSigner: false,
|
|
2123
|
+
isWritable: false,
|
|
2124
|
+
pubkey: token.custodyAccount,
|
|
2125
|
+
});
|
|
2126
|
+
}
|
|
2127
|
+
for (_b = 0, custodies_4 = custodies; _b < custodies_4.length; _b++) {
|
|
2128
|
+
custody = custodies_4[_b];
|
|
2129
|
+
custodyMetas.push({
|
|
2130
|
+
isSigner: false,
|
|
2131
|
+
isWritable: false,
|
|
2132
|
+
pubkey: custody.intOracleAccount,
|
|
2133
|
+
});
|
|
2134
|
+
}
|
|
2135
|
+
for (_c = 0, _d = POOL_CONFIG.markets; _c < _d.length; _c++) {
|
|
2136
|
+
market = _d[_c];
|
|
2137
|
+
marketMetas.push({
|
|
2138
|
+
pubkey: market.marketAccount,
|
|
2139
|
+
isSigner: false,
|
|
2140
|
+
isWritable: false,
|
|
2141
|
+
});
|
|
2142
|
+
}
|
|
2143
|
+
return [4, backUpOracleInstructionPromise];
|
|
2144
|
+
case 1:
|
|
2145
|
+
backUpOracleInstruction = _f.sent();
|
|
2146
|
+
return [4, this.program.methods
|
|
2147
|
+
.getCompoundingTokenPrice({})
|
|
2148
|
+
.accounts({
|
|
2149
|
+
perpetuals: POOL_CONFIG.perpetuals,
|
|
2150
|
+
pool: poolKey,
|
|
2151
|
+
lpTokenMint: POOL_CONFIG.stakedLpTokenMint,
|
|
2152
|
+
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
2153
|
+
})
|
|
2154
|
+
.remainingAccounts(includeRemainingAccounts ? __spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true) : [])
|
|
2155
|
+
.transaction()];
|
|
2156
|
+
case 2:
|
|
2157
|
+
transaction = _f.sent();
|
|
2158
|
+
setCULimitIx = web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: 450000 });
|
|
2159
|
+
transaction.instructions.unshift(setCULimitIx);
|
|
2160
|
+
(_e = transaction.instructions).unshift.apply(_e, backUpOracleInstruction);
|
|
2161
|
+
return [4, this.getOrLoadAddressLookupTable(POOL_CONFIG)];
|
|
2162
|
+
case 3:
|
|
2163
|
+
addressLookupTables = (_f.sent()).addressLookupTables;
|
|
2164
|
+
return [4, this.viewHelper.simulateTransaction(transaction, addressLookupTables)];
|
|
2165
|
+
case 4:
|
|
2166
|
+
result = _f.sent();
|
|
2167
|
+
index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getCompoundingTokenPrice'; });
|
|
2168
|
+
res = this.viewHelper.decodeLogs(result, index, 'getCompoundingTokenPrice');
|
|
2169
|
+
return [2, res.toString()];
|
|
2170
|
+
}
|
|
2171
|
+
});
|
|
2172
|
+
});
|
|
2173
|
+
};
|
|
2036
2174
|
this.getAssetsUnderManagement = function (poolKey, POOL_CONFIG) { return __awaiter(_this, void 0, void 0, function () {
|
|
2037
|
-
var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _i,
|
|
2175
|
+
var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _i, custodies_5, token, _a, custodies_6, custody, _b, _c, market;
|
|
2038
2176
|
return __generator(this, function (_d) {
|
|
2039
2177
|
switch (_d.label) {
|
|
2040
2178
|
case 0:
|
|
@@ -2042,16 +2180,16 @@ var PerpetualsClient = (function () {
|
|
|
2042
2180
|
custodies = POOL_CONFIG.custodies;
|
|
2043
2181
|
custodyMetas = [];
|
|
2044
2182
|
marketMetas = [];
|
|
2045
|
-
for (_i = 0,
|
|
2046
|
-
token =
|
|
2183
|
+
for (_i = 0, custodies_5 = custodies; _i < custodies_5.length; _i++) {
|
|
2184
|
+
token = custodies_5[_i];
|
|
2047
2185
|
custodyMetas.push({
|
|
2048
2186
|
isSigner: false,
|
|
2049
2187
|
isWritable: false,
|
|
2050
2188
|
pubkey: token.custodyAccount,
|
|
2051
2189
|
});
|
|
2052
2190
|
}
|
|
2053
|
-
for (_a = 0,
|
|
2054
|
-
custody =
|
|
2191
|
+
for (_a = 0, custodies_6 = custodies; _a < custodies_6.length; _a++) {
|
|
2192
|
+
custody = custodies_6[_a];
|
|
2055
2193
|
custodyMetas.push({
|
|
2056
2194
|
isSigner: false,
|
|
2057
2195
|
isWritable: false,
|
|
@@ -2068,7 +2206,7 @@ var PerpetualsClient = (function () {
|
|
|
2068
2206
|
}
|
|
2069
2207
|
return [4, this.program.methods
|
|
2070
2208
|
.getAssetsUnderManagement({})
|
|
2071
|
-
.
|
|
2209
|
+
.accounts({
|
|
2072
2210
|
perpetuals: POOL_CONFIG.perpetuals,
|
|
2073
2211
|
pool: poolKey,
|
|
2074
2212
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
@@ -2089,7 +2227,7 @@ var PerpetualsClient = (function () {
|
|
|
2089
2227
|
args_1[_i - 4] = arguments[_i];
|
|
2090
2228
|
}
|
|
2091
2229
|
return __awaiter(_this, __spreadArray([amount_1, poolKey_1, depositCustodyKey_1, POOL_CONFIG_1], args_1, true), void 0, function (amount, poolKey, depositCustodyKey, POOL_CONFIG, userPublicKey, enableBackupOracle, whitelist) {
|
|
2092
|
-
var custodies, custodyMetas, marketMetas, _a,
|
|
2230
|
+
var custodies, custodyMetas, marketMetas, _a, custodies_7, token, _b, custodies_8, custody, _c, _d, market, whitelistMeta, depositCustodyConfig, transaction, setCULimitIx, backUpOracleInstruction, addressLookupTables, result, index, res;
|
|
2093
2231
|
var _e;
|
|
2094
2232
|
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
|
2095
2233
|
if (enableBackupOracle === void 0) { enableBackupOracle = false; }
|
|
@@ -2100,16 +2238,16 @@ var PerpetualsClient = (function () {
|
|
|
2100
2238
|
custodies = POOL_CONFIG.custodies;
|
|
2101
2239
|
custodyMetas = [];
|
|
2102
2240
|
marketMetas = [];
|
|
2103
|
-
for (_a = 0,
|
|
2104
|
-
token =
|
|
2241
|
+
for (_a = 0, custodies_7 = custodies; _a < custodies_7.length; _a++) {
|
|
2242
|
+
token = custodies_7[_a];
|
|
2105
2243
|
custodyMetas.push({
|
|
2106
2244
|
isSigner: false,
|
|
2107
2245
|
isWritable: false,
|
|
2108
2246
|
pubkey: token.custodyAccount,
|
|
2109
2247
|
});
|
|
2110
2248
|
}
|
|
2111
|
-
for (_b = 0,
|
|
2112
|
-
custody =
|
|
2249
|
+
for (_b = 0, custodies_8 = custodies; _b < custodies_8.length; _b++) {
|
|
2250
|
+
custody = custodies_8[_b];
|
|
2113
2251
|
custodyMetas.push({
|
|
2114
2252
|
isSigner: false,
|
|
2115
2253
|
isWritable: false,
|
|
@@ -2134,7 +2272,7 @@ var PerpetualsClient = (function () {
|
|
|
2134
2272
|
.getAddLiquidityAmountAndFee({
|
|
2135
2273
|
amountIn: amount,
|
|
2136
2274
|
})
|
|
2137
|
-
.
|
|
2275
|
+
.accounts({
|
|
2138
2276
|
perpetuals: POOL_CONFIG.perpetuals,
|
|
2139
2277
|
pool: poolKey,
|
|
2140
2278
|
custody: depositCustodyKey,
|
|
@@ -2168,7 +2306,7 @@ var PerpetualsClient = (function () {
|
|
|
2168
2306
|
error: 'Simulation failed: ' + JSON.stringify(result.value.err),
|
|
2169
2307
|
}];
|
|
2170
2308
|
}
|
|
2171
|
-
index =
|
|
2309
|
+
index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getAddLiquidityAmountAndFee'; });
|
|
2172
2310
|
res = this.viewHelper.decodeLogs(result, index, 'getAddLiquidityAmountAndFee');
|
|
2173
2311
|
return [2, {
|
|
2174
2312
|
amount: res.amount,
|
|
@@ -2184,7 +2322,7 @@ var PerpetualsClient = (function () {
|
|
|
2184
2322
|
args_1[_i - 4] = arguments[_i];
|
|
2185
2323
|
}
|
|
2186
2324
|
return __awaiter(_this, __spreadArray([amount_1, poolKey_1, removeTokenCustodyKey_1, POOL_CONFIG_1], args_1, true), void 0, function (amount, poolKey, removeTokenCustodyKey, POOL_CONFIG, userPublicKey, enableBackupOracle, whitelist) {
|
|
2187
|
-
var custodies, custodyMetas, marketMetas, _a,
|
|
2325
|
+
var custodies, custodyMetas, marketMetas, _a, custodies_9, token, _b, custodies_10, custody, _c, _d, market, whitelistMeta, removeCustodyConfig, transaction, setCULimitIx, backUpOracleInstruction, addressLookupTables, result, index, res;
|
|
2188
2326
|
var _e;
|
|
2189
2327
|
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
|
2190
2328
|
if (enableBackupOracle === void 0) { enableBackupOracle = false; }
|
|
@@ -2195,16 +2333,16 @@ var PerpetualsClient = (function () {
|
|
|
2195
2333
|
custodies = POOL_CONFIG.custodies;
|
|
2196
2334
|
custodyMetas = [];
|
|
2197
2335
|
marketMetas = [];
|
|
2198
|
-
for (_a = 0,
|
|
2199
|
-
token =
|
|
2336
|
+
for (_a = 0, custodies_9 = custodies; _a < custodies_9.length; _a++) {
|
|
2337
|
+
token = custodies_9[_a];
|
|
2200
2338
|
custodyMetas.push({
|
|
2201
2339
|
isSigner: false,
|
|
2202
2340
|
isWritable: false,
|
|
2203
2341
|
pubkey: token.custodyAccount,
|
|
2204
2342
|
});
|
|
2205
2343
|
}
|
|
2206
|
-
for (_b = 0,
|
|
2207
|
-
custody =
|
|
2344
|
+
for (_b = 0, custodies_10 = custodies; _b < custodies_10.length; _b++) {
|
|
2345
|
+
custody = custodies_10[_b];
|
|
2208
2346
|
custodyMetas.push({
|
|
2209
2347
|
isSigner: false,
|
|
2210
2348
|
isWritable: false,
|
|
@@ -2229,7 +2367,7 @@ var PerpetualsClient = (function () {
|
|
|
2229
2367
|
.getRemoveLiquidityAmountAndFee({
|
|
2230
2368
|
lpAmountIn: amount,
|
|
2231
2369
|
})
|
|
2232
|
-
.
|
|
2370
|
+
.accounts({
|
|
2233
2371
|
perpetuals: POOL_CONFIG.perpetuals,
|
|
2234
2372
|
pool: poolKey,
|
|
2235
2373
|
custody: removeTokenCustodyKey,
|
|
@@ -2255,7 +2393,7 @@ var PerpetualsClient = (function () {
|
|
|
2255
2393
|
return [4, this.viewHelper.simulateTransaction(transaction, addressLookupTables, userPublicKey)];
|
|
2256
2394
|
case 5:
|
|
2257
2395
|
result = _f.sent();
|
|
2258
|
-
index =
|
|
2396
|
+
index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getRemoveLiquidityAmountAndFee'; });
|
|
2259
2397
|
if (result.value.err) {
|
|
2260
2398
|
console.error('error Simulation failed:', result);
|
|
2261
2399
|
return [2, {
|
|
@@ -2273,70 +2411,6 @@ var PerpetualsClient = (function () {
|
|
|
2273
2411
|
});
|
|
2274
2412
|
});
|
|
2275
2413
|
};
|
|
2276
|
-
this.getCompoundingLPTokenPrice = function (poolKey, POOL_CONFIG) { return __awaiter(_this, void 0, void 0, function () {
|
|
2277
|
-
var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _i, custodies_9, token, _a, custodies_10, custody, _b, _c, market, backUpOracleInstruction, transaction, setCULimitIx, addressLookupTables, result, index, res;
|
|
2278
|
-
var _d;
|
|
2279
|
-
return __generator(this, function (_e) {
|
|
2280
|
-
switch (_e.label) {
|
|
2281
|
-
case 0:
|
|
2282
|
-
backUpOracleInstructionPromise = (0, backupOracle_1.createBackupOracleInstruction)(POOL_CONFIG.poolAddress.toBase58(), true);
|
|
2283
|
-
custodies = POOL_CONFIG.custodies;
|
|
2284
|
-
custodyMetas = [];
|
|
2285
|
-
marketMetas = [];
|
|
2286
|
-
for (_i = 0, custodies_9 = custodies; _i < custodies_9.length; _i++) {
|
|
2287
|
-
token = custodies_9[_i];
|
|
2288
|
-
custodyMetas.push({
|
|
2289
|
-
isSigner: false,
|
|
2290
|
-
isWritable: false,
|
|
2291
|
-
pubkey: token.custodyAccount,
|
|
2292
|
-
});
|
|
2293
|
-
}
|
|
2294
|
-
for (_a = 0, custodies_10 = custodies; _a < custodies_10.length; _a++) {
|
|
2295
|
-
custody = custodies_10[_a];
|
|
2296
|
-
custodyMetas.push({
|
|
2297
|
-
isSigner: false,
|
|
2298
|
-
isWritable: false,
|
|
2299
|
-
pubkey: custody.intOracleAccount,
|
|
2300
|
-
});
|
|
2301
|
-
}
|
|
2302
|
-
for (_b = 0, _c = POOL_CONFIG.markets; _b < _c.length; _b++) {
|
|
2303
|
-
market = _c[_b];
|
|
2304
|
-
marketMetas.push({
|
|
2305
|
-
pubkey: market.marketAccount,
|
|
2306
|
-
isSigner: false,
|
|
2307
|
-
isWritable: false,
|
|
2308
|
-
});
|
|
2309
|
-
}
|
|
2310
|
-
return [4, backUpOracleInstructionPromise];
|
|
2311
|
-
case 1:
|
|
2312
|
-
backUpOracleInstruction = _e.sent();
|
|
2313
|
-
return [4, this.program.methods
|
|
2314
|
-
.getCompoundingTokenPrice({})
|
|
2315
|
-
.accountsPartial({
|
|
2316
|
-
perpetuals: POOL_CONFIG.perpetuals,
|
|
2317
|
-
pool: poolKey,
|
|
2318
|
-
lpTokenMint: POOL_CONFIG.stakedLpTokenMint,
|
|
2319
|
-
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
2320
|
-
})
|
|
2321
|
-
.remainingAccounts(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true))
|
|
2322
|
-
.transaction()];
|
|
2323
|
-
case 2:
|
|
2324
|
-
transaction = _e.sent();
|
|
2325
|
-
setCULimitIx = web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: 450000 });
|
|
2326
|
-
transaction.instructions.unshift(setCULimitIx);
|
|
2327
|
-
(_d = transaction.instructions).unshift.apply(_d, backUpOracleInstruction);
|
|
2328
|
-
return [4, this.getOrLoadAddressLookupTable(POOL_CONFIG)];
|
|
2329
|
-
case 3:
|
|
2330
|
-
addressLookupTables = (_e.sent()).addressLookupTables;
|
|
2331
|
-
return [4, this.viewHelper.simulateTransaction(transaction, addressLookupTables)];
|
|
2332
|
-
case 4:
|
|
2333
|
-
result = _e.sent();
|
|
2334
|
-
index = perpetuals_json_1.default.instructions.findIndex(function (f) { return f.name === 'getCompoundingTokenPrice'; });
|
|
2335
|
-
res = this.viewHelper.decodeLogs(result, index, 'getCompoundingTokenPrice');
|
|
2336
|
-
return [2, res.toString()];
|
|
2337
|
-
}
|
|
2338
|
-
});
|
|
2339
|
-
}); };
|
|
2340
2414
|
this.getAddCompoundingLiquidityAmountAndFeeView = function (amount_1, poolKey_1, depositCustodyKey_1, POOL_CONFIG_1) {
|
|
2341
2415
|
var args_1 = [];
|
|
2342
2416
|
for (var _i = 4; _i < arguments.length; _i++) {
|
|
@@ -2389,7 +2463,7 @@ var PerpetualsClient = (function () {
|
|
|
2389
2463
|
.getAddCompoundingLiquidityAmountAndFee({
|
|
2390
2464
|
amountIn: amount,
|
|
2391
2465
|
})
|
|
2392
|
-
.
|
|
2466
|
+
.accounts({
|
|
2393
2467
|
perpetuals: POOL_CONFIG.perpetuals,
|
|
2394
2468
|
pool: poolKey,
|
|
2395
2469
|
inCustody: depositCustodyKey,
|
|
@@ -2418,7 +2492,7 @@ var PerpetualsClient = (function () {
|
|
|
2418
2492
|
case 4: return [4, this.viewHelper.simulateTransaction(transaction, addressLookupTables, userPublicKey)];
|
|
2419
2493
|
case 5:
|
|
2420
2494
|
result = _f.sent();
|
|
2421
|
-
index =
|
|
2495
|
+
index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getAddCompoundingLiquidityAmountAndFee'; });
|
|
2422
2496
|
res = this.viewHelper.decodeLogs(result, index, 'getAddCompoundingLiquidityAmountAndFee');
|
|
2423
2497
|
return [2, {
|
|
2424
2498
|
amount: res.amount,
|
|
@@ -2480,7 +2554,7 @@ var PerpetualsClient = (function () {
|
|
|
2480
2554
|
.getRemoveCompoundingLiquidityAmountAndFee({
|
|
2481
2555
|
compoundingAmountIn: amount,
|
|
2482
2556
|
})
|
|
2483
|
-
.
|
|
2557
|
+
.accounts({
|
|
2484
2558
|
perpetuals: POOL_CONFIG.perpetuals,
|
|
2485
2559
|
pool: poolKey,
|
|
2486
2560
|
outCustody: removeTokenCustodyKey,
|
|
@@ -2509,7 +2583,7 @@ var PerpetualsClient = (function () {
|
|
|
2509
2583
|
return [4, this.viewHelper.simulateTransaction(transaction, addressLookupTables, userPublicKey)];
|
|
2510
2584
|
case 5:
|
|
2511
2585
|
result = _f.sent();
|
|
2512
|
-
index =
|
|
2586
|
+
index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getRemoveCompoundingLiquidityAmountAndFee'; });
|
|
2513
2587
|
if (result.value.err) {
|
|
2514
2588
|
return [2, {
|
|
2515
2589
|
amount: new anchor_1.BN(0),
|
|
@@ -2542,7 +2616,7 @@ var PerpetualsClient = (function () {
|
|
|
2542
2616
|
collateralCustodyConfig = poolConfig.custodies.find(function (f) { return f.custodyAccount.equals(marketConfig_1.collateralCustody); });
|
|
2543
2617
|
return [4, this.program.methods
|
|
2544
2618
|
.getLiquidationPrice({})
|
|
2545
|
-
.
|
|
2619
|
+
.accounts({
|
|
2546
2620
|
perpetuals: this.perpetuals.publicKey,
|
|
2547
2621
|
pool: poolConfig.poolAddress,
|
|
2548
2622
|
position: positionAccountKey,
|
|
@@ -2576,7 +2650,7 @@ var PerpetualsClient = (function () {
|
|
|
2576
2650
|
collateralCustodyConfig = poolConfig.custodies.find(function (f) { return f.mintKey.equals(collateralMint); });
|
|
2577
2651
|
return [4, this.program.methods
|
|
2578
2652
|
.getLiquidationState({})
|
|
2579
|
-
.
|
|
2653
|
+
.accounts({
|
|
2580
2654
|
perpetuals: this.perpetuals.publicKey,
|
|
2581
2655
|
pool: poolConfig.poolAddress,
|
|
2582
2656
|
position: positionAccount,
|
|
@@ -2626,54 +2700,7 @@ var PerpetualsClient = (function () {
|
|
|
2626
2700
|
}
|
|
2627
2701
|
return [4, this.program.methods
|
|
2628
2702
|
.getCompoundingTokenData({})
|
|
2629
|
-
.
|
|
2630
|
-
perpetuals: this.perpetuals.publicKey,
|
|
2631
|
-
pool: poolConfig.poolAddress,
|
|
2632
|
-
lpTokenMint: poolConfig.stakedLpTokenMint,
|
|
2633
|
-
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
|
|
2634
|
-
})
|
|
2635
|
-
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
|
|
2636
|
-
.view()
|
|
2637
|
-
.catch(function (err) {
|
|
2638
|
-
console.error(err);
|
|
2639
|
-
throw err;
|
|
2640
|
-
})];
|
|
2641
|
-
case 1: return [2, _d.sent()];
|
|
2642
|
-
}
|
|
2643
|
-
});
|
|
2644
|
-
}); };
|
|
2645
|
-
this.getLpTokenPriceView = function (poolConfig) { return __awaiter(_this, void 0, void 0, function () {
|
|
2646
|
-
var custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market;
|
|
2647
|
-
return __generator(this, function (_d) {
|
|
2648
|
-
switch (_d.label) {
|
|
2649
|
-
case 0:
|
|
2650
|
-
custodyAccountMetas = [];
|
|
2651
|
-
custodyOracleAccountMetas = [];
|
|
2652
|
-
markets = [];
|
|
2653
|
-
for (_i = 0, _a = poolConfig.custodies; _i < _a.length; _i++) {
|
|
2654
|
-
custody = _a[_i];
|
|
2655
|
-
custodyAccountMetas.push({
|
|
2656
|
-
pubkey: custody.custodyAccount,
|
|
2657
|
-
isSigner: false,
|
|
2658
|
-
isWritable: false,
|
|
2659
|
-
});
|
|
2660
|
-
custodyOracleAccountMetas.push({
|
|
2661
|
-
pubkey: this.useExtOracleAccount ? custody.extOracleAccount : custody.intOracleAccount,
|
|
2662
|
-
isSigner: false,
|
|
2663
|
-
isWritable: false,
|
|
2664
|
-
});
|
|
2665
|
-
}
|
|
2666
|
-
for (_b = 0, _c = poolConfig.markets; _b < _c.length; _b++) {
|
|
2667
|
-
market = _c[_b];
|
|
2668
|
-
markets.push({
|
|
2669
|
-
pubkey: market.marketAccount,
|
|
2670
|
-
isSigner: false,
|
|
2671
|
-
isWritable: false,
|
|
2672
|
-
});
|
|
2673
|
-
}
|
|
2674
|
-
return [4, this.program.methods
|
|
2675
|
-
.getLpTokenPrice({})
|
|
2676
|
-
.accountsPartial({
|
|
2703
|
+
.accounts({
|
|
2677
2704
|
perpetuals: this.perpetuals.publicKey,
|
|
2678
2705
|
pool: poolConfig.poolAddress,
|
|
2679
2706
|
lpTokenMint: poolConfig.stakedLpTokenMint,
|
|
@@ -2769,7 +2796,7 @@ var PerpetualsClient = (function () {
|
|
|
2769
2796
|
};
|
|
2770
2797
|
return [4, this.program.methods
|
|
2771
2798
|
.openPosition(params)
|
|
2772
|
-
.
|
|
2799
|
+
.accounts({
|
|
2773
2800
|
owner: publicKey,
|
|
2774
2801
|
feePayer: publicKey,
|
|
2775
2802
|
fundingAccount: collateralSymbol == 'SOL' ? (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey) : userCollateralTokenAccount,
|
|
@@ -2784,6 +2811,8 @@ var PerpetualsClient = (function () {
|
|
|
2784
2811
|
collateralCustodyTokenAccount: collateralCustodyConfig.tokenAccount,
|
|
2785
2812
|
systemProgram: web3_js_1.SystemProgram.programId,
|
|
2786
2813
|
fundingTokenProgram: poolConfig.getTokenFromSymbol(collateralSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
2814
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
2815
|
+
program: this.programId,
|
|
2787
2816
|
transferAuthority: this.authority.publicKey,
|
|
2788
2817
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
2789
2818
|
fundingMint: collateralCustodyConfig.mintKey
|
|
@@ -2868,7 +2897,7 @@ var PerpetualsClient = (function () {
|
|
|
2868
2897
|
priceWithSlippage: priceWithSlippage,
|
|
2869
2898
|
privilege: privilege
|
|
2870
2899
|
})
|
|
2871
|
-
.
|
|
2900
|
+
.accounts({
|
|
2872
2901
|
feePayer: publicKey,
|
|
2873
2902
|
owner: publicKey,
|
|
2874
2903
|
receivingAccount: collateralSymbol == 'SOL' ? (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey) : userReceivingTokenAccount,
|
|
@@ -2883,6 +2912,7 @@ var PerpetualsClient = (function () {
|
|
|
2883
2912
|
collateralOracleAccount: this.useExtOracleAccount ? collateralCustodyConfig.extOracleAccount : collateralCustodyConfig.intOracleAccount,
|
|
2884
2913
|
collateralCustodyTokenAccount: collateralCustodyConfig.tokenAccount,
|
|
2885
2914
|
eventAuthority: this.eventAuthority.publicKey,
|
|
2915
|
+
program: this.programId,
|
|
2886
2916
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
2887
2917
|
collateralMint: collateralCustodyConfig.mintKey,
|
|
2888
2918
|
collateralTokenProgram: poolConfig.getTokenFromSymbol(collateralSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID
|
|
@@ -3019,7 +3049,7 @@ var PerpetualsClient = (function () {
|
|
|
3019
3049
|
sizeAmount: sizeAmount,
|
|
3020
3050
|
privilege: privilege
|
|
3021
3051
|
})
|
|
3022
|
-
.
|
|
3052
|
+
.accounts({
|
|
3023
3053
|
owner: publicKey,
|
|
3024
3054
|
feePayer: publicKey,
|
|
3025
3055
|
fundingAccount: userInputTokenSymbol == 'SOL' ? (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey) : userInputTokenAccount,
|
|
@@ -3038,6 +3068,7 @@ var PerpetualsClient = (function () {
|
|
|
3038
3068
|
collateralCustodyTokenAccount: collateralCustodyConfig.tokenAccount,
|
|
3039
3069
|
systemProgram: web3_js_1.SystemProgram.programId,
|
|
3040
3070
|
eventAuthority: this.eventAuthority.publicKey,
|
|
3071
|
+
program: this.programId,
|
|
3041
3072
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
3042
3073
|
fundingMint: userInputCustodyConfig.mintKey,
|
|
3043
3074
|
fundingTokenProgram: poolConfig.getTokenFromSymbol(userInputTokenSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
@@ -3144,7 +3175,7 @@ var PerpetualsClient = (function () {
|
|
|
3144
3175
|
priceWithSlippage: priceWithSlippage,
|
|
3145
3176
|
privilege: privilege
|
|
3146
3177
|
})
|
|
3147
|
-
.
|
|
3178
|
+
.accounts({
|
|
3148
3179
|
owner: publicKey,
|
|
3149
3180
|
feePayer: publicKey,
|
|
3150
3181
|
receivingAccount: userOutputTokenSymbol == 'SOL' ? (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey) : userReceivingTokenAccount,
|
|
@@ -3162,6 +3193,8 @@ var PerpetualsClient = (function () {
|
|
|
3162
3193
|
dispensingCustody: userOutputCustodyConfig.custodyAccount,
|
|
3163
3194
|
dispensingOracleAccount: this.useExtOracleAccount ? userOutputCustodyConfig.extOracleAccount : userOutputCustodyConfig.intOracleAccount,
|
|
3164
3195
|
dispensingCustodyTokenAccount: userOutputCustodyConfig.tokenAccount,
|
|
3196
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
3197
|
+
program: this.programId,
|
|
3165
3198
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
3166
3199
|
receivingMint: userOutputCustodyConfig.mintKey,
|
|
3167
3200
|
receivingTokenProgram: userOutputToken.isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
@@ -3259,7 +3292,7 @@ var PerpetualsClient = (function () {
|
|
|
3259
3292
|
_c.label = 6;
|
|
3260
3293
|
case 6: return [4, this.program.methods.addCollateral({
|
|
3261
3294
|
collateralDelta: collateralWithFee
|
|
3262
|
-
}).
|
|
3295
|
+
}).accounts({
|
|
3263
3296
|
owner: publicKey,
|
|
3264
3297
|
position: positionPubKey,
|
|
3265
3298
|
market: marketAccount,
|
|
@@ -3271,7 +3304,9 @@ var PerpetualsClient = (function () {
|
|
|
3271
3304
|
collateralCustody: collateralCustodyConfig.custodyAccount,
|
|
3272
3305
|
collateralOracleAccount: this.useExtOracleAccount ? collateralCustodyConfig.extOracleAccount : collateralCustodyConfig.intOracleAccount,
|
|
3273
3306
|
collateralCustodyTokenAccount: collateralCustodyConfig.tokenAccount,
|
|
3307
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
3274
3308
|
fundingTokenProgram: poolConfig.getTokenFromSymbol(collateralSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
3309
|
+
program: this.programId,
|
|
3275
3310
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
3276
3311
|
fundingMint: collateralCustodyConfig.mintKey
|
|
3277
3312
|
})
|
|
@@ -3371,7 +3406,7 @@ var PerpetualsClient = (function () {
|
|
|
3371
3406
|
marketAccount = poolConfig.getMarketPk(targetCustodyConfig.custodyAccount, collateralCustodyConfig.custodyAccount, side);
|
|
3372
3407
|
return [4, this.program.methods.swapAndAddCollateral({
|
|
3373
3408
|
amountIn: amountIn,
|
|
3374
|
-
}).
|
|
3409
|
+
}).accounts({
|
|
3375
3410
|
owner: publicKey,
|
|
3376
3411
|
feePayer: publicKey,
|
|
3377
3412
|
fundingAccount: inputSymbol == 'SOL' ? (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey) : userInputTokenAccount,
|
|
@@ -3388,7 +3423,9 @@ var PerpetualsClient = (function () {
|
|
|
3388
3423
|
collateralCustody: collateralCustodyConfig.custodyAccount,
|
|
3389
3424
|
collateralOracleAccount: this.useExtOracleAccount ? collateralCustodyConfig.extOracleAccount : collateralCustodyConfig.intOracleAccount,
|
|
3390
3425
|
collateralCustodyTokenAccount: collateralCustodyConfig.tokenAccount,
|
|
3426
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
3391
3427
|
fundingTokenProgram: poolConfig.getTokenFromSymbol(inputSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
3428
|
+
program: this.programId,
|
|
3392
3429
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
3393
3430
|
fundingMint: poolConfig.getTokenFromSymbol(inputSymbol).mintKey,
|
|
3394
3431
|
})
|
|
@@ -3475,7 +3512,7 @@ var PerpetualsClient = (function () {
|
|
|
3475
3512
|
.removeCollateral({
|
|
3476
3513
|
collateralDeltaUsd: collateralDeltaUsd,
|
|
3477
3514
|
})
|
|
3478
|
-
.
|
|
3515
|
+
.accounts({
|
|
3479
3516
|
owner: publicKey,
|
|
3480
3517
|
receivingAccount: collateralSymbol == 'SOL' ? (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey) : userReceivingTokenAccount,
|
|
3481
3518
|
transferAuthority: poolConfig.transferAuthority,
|
|
@@ -3490,6 +3527,7 @@ var PerpetualsClient = (function () {
|
|
|
3490
3527
|
collateralCustodyTokenAccount: collateralCustodyConfig.tokenAccount,
|
|
3491
3528
|
eventAuthority: this.eventAuthority.publicKey,
|
|
3492
3529
|
receivingTokenProgram: poolConfig.getTokenFromSymbol(collateralSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
3530
|
+
program: this.programId,
|
|
3493
3531
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
3494
3532
|
receivingMint: collateralCustodyConfig.mintKey
|
|
3495
3533
|
})
|
|
@@ -3578,7 +3616,7 @@ var PerpetualsClient = (function () {
|
|
|
3578
3616
|
.removeCollateralAndSwap({
|
|
3579
3617
|
collateralDeltaUsd: collateralDeltaUsd,
|
|
3580
3618
|
})
|
|
3581
|
-
.
|
|
3619
|
+
.accounts({
|
|
3582
3620
|
owner: publicKey,
|
|
3583
3621
|
feePayer: publicKey,
|
|
3584
3622
|
receivingAccount: outputSymbol == 'SOL' ? (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey) : userReceivingTokenAccount,
|
|
@@ -3596,6 +3634,8 @@ var PerpetualsClient = (function () {
|
|
|
3596
3634
|
dispensingCustody: outputCustodyConfig.custodyAccount,
|
|
3597
3635
|
dispensingOracleAccount: this.useExtOracleAccount ? outputCustodyConfig.extOracleAccount : outputCustodyConfig.intOracleAccount,
|
|
3598
3636
|
dispensingCustodyTokenAccount: outputCustodyConfig.tokenAccount,
|
|
3637
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
3638
|
+
program: this.programId,
|
|
3599
3639
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
3600
3640
|
receivingMint: outputCustodyConfig.mintKey,
|
|
3601
3641
|
receivingTokenProgram: poolConfig.getTokenFromSymbol(outputSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
@@ -3647,7 +3687,7 @@ var PerpetualsClient = (function () {
|
|
|
3647
3687
|
sizeDelta: sizeDelta,
|
|
3648
3688
|
privilege: privilege
|
|
3649
3689
|
})
|
|
3650
|
-
.
|
|
3690
|
+
.accounts({
|
|
3651
3691
|
owner: publicKey,
|
|
3652
3692
|
transferAuthority: poolConfig.transferAuthority,
|
|
3653
3693
|
perpetuals: poolConfig.perpetuals,
|
|
@@ -3661,6 +3701,7 @@ var PerpetualsClient = (function () {
|
|
|
3661
3701
|
collateralCustodyTokenAccount: collateralCustodyConfig.tokenAccount,
|
|
3662
3702
|
collateralTokenProgram: poolConfig.getTokenFromSymbol(collateralSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
3663
3703
|
eventAuthority: this.eventAuthority.publicKey,
|
|
3704
|
+
program: this.programId,
|
|
3664
3705
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
3665
3706
|
collateralMint: collateralCustodyConfig.mintKey
|
|
3666
3707
|
})
|
|
@@ -3710,7 +3751,7 @@ var PerpetualsClient = (function () {
|
|
|
3710
3751
|
sizeDelta: sizeDelta,
|
|
3711
3752
|
privilege: privilege
|
|
3712
3753
|
})
|
|
3713
|
-
.
|
|
3754
|
+
.accounts({
|
|
3714
3755
|
owner: publicKey,
|
|
3715
3756
|
transferAuthority: poolConfig.transferAuthority,
|
|
3716
3757
|
perpetuals: poolConfig.perpetuals,
|
|
@@ -3724,6 +3765,7 @@ var PerpetualsClient = (function () {
|
|
|
3724
3765
|
collateralCustodyTokenAccount: collateralCustodyConfig.tokenAccount,
|
|
3725
3766
|
collateralTokenProgram: poolConfig.getTokenFromSymbol(collateralSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
3726
3767
|
eventAuthority: this.eventAuthority.publicKey,
|
|
3768
|
+
program: this.programId,
|
|
3727
3769
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
3728
3770
|
collateralMint: collateralCustodyConfig.mintKey
|
|
3729
3771
|
})
|
|
@@ -3745,11 +3787,12 @@ var PerpetualsClient = (function () {
|
|
|
3745
3787
|
for (var _i = 4; _i < arguments.length; _i++) {
|
|
3746
3788
|
args_1[_i - 4] = arguments[_i];
|
|
3747
3789
|
}
|
|
3748
|
-
return __awaiter(_this, __spreadArray([payTokenSymbol_1, tokenAmountIn_1, minLpAmountOut_1, poolConfig_1], args_1, true), void 0, function (payTokenSymbol, tokenAmountIn, minLpAmountOut, poolConfig, skipBalanceChecks, ephemeralSignerPubkey, isWhitelistedUser) {
|
|
3790
|
+
return __awaiter(_this, __spreadArray([payTokenSymbol_1, tokenAmountIn_1, minLpAmountOut_1, poolConfig_1], args_1, true), void 0, function (payTokenSymbol, tokenAmountIn, minLpAmountOut, poolConfig, skipBalanceChecks, ephemeralSignerPubkey, isWhitelistedUser, includeRemainingAccounts) {
|
|
3749
3791
|
var publicKey, payTokenCustodyConfig, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, payToken, userPayingTokenAccount, lpTokenAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _a, _b, custody, _c, _d, market, lamports, unWrappedSolBalance, _e, tokenAccountBalance, _f, whitelistPda, whitelistMeta, instruction, err_5;
|
|
3750
3792
|
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
|
3751
3793
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
3752
3794
|
if (isWhitelistedUser === void 0) { isWhitelistedUser = false; }
|
|
3795
|
+
if (includeRemainingAccounts === void 0) { includeRemainingAccounts = true; }
|
|
3753
3796
|
return __generator(this, function (_g) {
|
|
3754
3797
|
switch (_g.label) {
|
|
3755
3798
|
case 0:
|
|
@@ -3855,7 +3898,7 @@ var PerpetualsClient = (function () {
|
|
|
3855
3898
|
amountIn: tokenAmountIn,
|
|
3856
3899
|
minLpAmountOut: minLpAmountOut
|
|
3857
3900
|
})
|
|
3858
|
-
.
|
|
3901
|
+
.accounts({
|
|
3859
3902
|
owner: publicKey,
|
|
3860
3903
|
fundingAccount: payTokenSymbol == 'SOL' ? (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey) : userPayingTokenAccount,
|
|
3861
3904
|
lpTokenAccount: lpTokenAccount,
|
|
@@ -3868,11 +3911,12 @@ var PerpetualsClient = (function () {
|
|
|
3868
3911
|
lpTokenMint: poolConfig.stakedLpTokenMint,
|
|
3869
3912
|
eventAuthority: this.eventAuthority.publicKey,
|
|
3870
3913
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
3914
|
+
program: this.programId,
|
|
3871
3915
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
3872
3916
|
fundingMint: payTokenCustodyConfig.mintKey,
|
|
3873
3917
|
fundingTokenProgram: payToken.isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
3874
3918
|
})
|
|
3875
|
-
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), (isWhitelistedUser ? [whitelistMeta] : []), true))
|
|
3919
|
+
.remainingAccounts(includeRemainingAccounts ? __spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), (isWhitelistedUser ? [whitelistMeta] : []), true) : __spreadArray([], (isWhitelistedUser ? [whitelistMeta] : []), true))
|
|
3876
3920
|
.instruction()];
|
|
3877
3921
|
case 9:
|
|
3878
3922
|
instruction = _g.sent();
|
|
@@ -3895,12 +3939,13 @@ var PerpetualsClient = (function () {
|
|
|
3895
3939
|
for (var _i = 4; _i < arguments.length; _i++) {
|
|
3896
3940
|
args_1[_i - 4] = arguments[_i];
|
|
3897
3941
|
}
|
|
3898
|
-
return __awaiter(_this, __spreadArray([inputSymbol_1, amountIn_1, minLpAmountOut_1, poolConfig_1], args_1, true), void 0, function (inputSymbol, amountIn, minLpAmountOut, poolConfig, skipBalanceChecks, ephemeralSignerPubkey, userPublicKey, isWhitelistedUser) {
|
|
3942
|
+
return __awaiter(_this, __spreadArray([inputSymbol_1, amountIn_1, minLpAmountOut_1, poolConfig_1], args_1, true), void 0, function (inputSymbol, amountIn, minLpAmountOut, poolConfig, skipBalanceChecks, ephemeralSignerPubkey, userPublicKey, isWhitelistedUser, includeRemainingAccounts) {
|
|
3899
3943
|
var publicKey, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userInputTokenAccount, lpTokenMint, inputCustodyConfig, lpTokenAccount, inputToken, flpStakeAccount, poolStakedLpVault, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, custodyAccountMetas, custodyOracleAccountMetas, markets, _c, _d, custody, _e, _f, market, whitelistPda, whitelistMeta, instruction;
|
|
3900
3944
|
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
|
3901
3945
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
3902
3946
|
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
|
3903
3947
|
if (isWhitelistedUser === void 0) { isWhitelistedUser = false; }
|
|
3948
|
+
if (includeRemainingAccounts === void 0) { includeRemainingAccounts = true; }
|
|
3904
3949
|
return __generator(this, function (_g) {
|
|
3905
3950
|
switch (_g.label) {
|
|
3906
3951
|
case 0:
|
|
@@ -4001,7 +4046,7 @@ var PerpetualsClient = (function () {
|
|
|
4001
4046
|
return [4, this.program.methods.addLiquidityAndStake({
|
|
4002
4047
|
amountIn: amountIn,
|
|
4003
4048
|
minLpAmountOut: minLpAmountOut,
|
|
4004
|
-
}).
|
|
4049
|
+
}).accounts({
|
|
4005
4050
|
owner: publicKey,
|
|
4006
4051
|
feePayer: publicKey,
|
|
4007
4052
|
fundingAccount: inputSymbol == 'SOL' ? (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey) : userInputTokenAccount,
|
|
@@ -4016,11 +4061,13 @@ var PerpetualsClient = (function () {
|
|
|
4016
4061
|
poolStakedLpVault: poolStakedLpVault,
|
|
4017
4062
|
systemProgram: web3_js_1.SystemProgram.programId,
|
|
4018
4063
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
4064
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
4065
|
+
program: this.programId,
|
|
4019
4066
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
4020
4067
|
fundingMint: inputCustodyConfig.mintKey,
|
|
4021
4068
|
fundingTokenProgram: inputToken.isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
4022
4069
|
})
|
|
4023
|
-
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), (isWhitelistedUser ? [whitelistMeta] : []), true))
|
|
4070
|
+
.remainingAccounts(includeRemainingAccounts ? __spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), (isWhitelistedUser ? [whitelistMeta] : []), true) : __spreadArray([], (isWhitelistedUser ? [whitelistMeta] : []), true))
|
|
4024
4071
|
.instruction()];
|
|
4025
4072
|
case 8:
|
|
4026
4073
|
instruction = _g.sent();
|
|
@@ -4038,7 +4085,7 @@ var PerpetualsClient = (function () {
|
|
|
4038
4085
|
for (var _i = 4; _i < arguments.length; _i++) {
|
|
4039
4086
|
args_1[_i - 4] = arguments[_i];
|
|
4040
4087
|
}
|
|
4041
|
-
return __awaiter(_this, __spreadArray([recieveTokenSymbol_1, liquidityAmountIn_1, minTokenAmountOut_1, poolConfig_1], args_1, true), void 0, function (recieveTokenSymbol, liquidityAmountIn, minTokenAmountOut, poolConfig, closeLpATA, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey, userPublicKey, isWhitelistedUser) {
|
|
4088
|
+
return __awaiter(_this, __spreadArray([recieveTokenSymbol_1, liquidityAmountIn_1, minTokenAmountOut_1, poolConfig_1], args_1, true), void 0, function (recieveTokenSymbol, liquidityAmountIn, minTokenAmountOut, poolConfig, closeLpATA, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey, userPublicKey, isWhitelistedUser, includeRemainingAccounts) {
|
|
4042
4089
|
var recieveTokenCustodyConfig, publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, recieveToken, stakedLpTokenAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _a, _b, custody, _c, _d, market, lamports, _e, whitelistPda, whitelistMeta, removeLiquidityTx, closeInx, closeWsolATAIns, err_6;
|
|
4043
4090
|
if (closeLpATA === void 0) { closeLpATA = false; }
|
|
4044
4091
|
if (createUserATA === void 0) { createUserATA = true; }
|
|
@@ -4046,6 +4093,7 @@ var PerpetualsClient = (function () {
|
|
|
4046
4093
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
4047
4094
|
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
|
4048
4095
|
if (isWhitelistedUser === void 0) { isWhitelistedUser = false; }
|
|
4096
|
+
if (includeRemainingAccounts === void 0) { includeRemainingAccounts = true; }
|
|
4049
4097
|
return __generator(this, function (_f) {
|
|
4050
4098
|
switch (_f.label) {
|
|
4051
4099
|
case 0:
|
|
@@ -4132,7 +4180,7 @@ var PerpetualsClient = (function () {
|
|
|
4132
4180
|
lpAmountIn: liquidityAmountIn,
|
|
4133
4181
|
minAmountOut: minTokenAmountOut
|
|
4134
4182
|
})
|
|
4135
|
-
.
|
|
4183
|
+
.accounts({
|
|
4136
4184
|
owner: publicKey,
|
|
4137
4185
|
receivingAccount: recieveTokenSymbol == 'SOL' ? (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey) : userReceivingTokenAccount,
|
|
4138
4186
|
lpTokenAccount: stakedLpTokenAccount,
|
|
@@ -4145,11 +4193,12 @@ var PerpetualsClient = (function () {
|
|
|
4145
4193
|
lpTokenMint: poolConfig.stakedLpTokenMint,
|
|
4146
4194
|
eventAuthority: this.eventAuthority.publicKey,
|
|
4147
4195
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
4196
|
+
program: this.programId,
|
|
4148
4197
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
4149
4198
|
receivingMint: recieveTokenCustodyConfig.mintKey,
|
|
4150
4199
|
receivingTokenProgram: recieveToken.isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
4151
4200
|
})
|
|
4152
|
-
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), (isWhitelistedUser ? [whitelistMeta] : []), true))
|
|
4201
|
+
.remainingAccounts(includeRemainingAccounts ? __spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), (isWhitelistedUser ? [whitelistMeta] : []), true) : __spreadArray([], (isWhitelistedUser ? [whitelistMeta] : []), true))
|
|
4153
4202
|
.instruction()];
|
|
4154
4203
|
case 6:
|
|
4155
4204
|
removeLiquidityTx = _f.sent();
|
|
@@ -4190,7 +4239,7 @@ var PerpetualsClient = (function () {
|
|
|
4190
4239
|
_a.trys.push([1, 3, , 4]);
|
|
4191
4240
|
return [4, this.program.methods
|
|
4192
4241
|
.createReferral({})
|
|
4193
|
-
.
|
|
4242
|
+
.accounts({
|
|
4194
4243
|
owner: publicKey,
|
|
4195
4244
|
feePayer: publicKey,
|
|
4196
4245
|
referralAccount: nftReferralAccount,
|
|
@@ -4235,7 +4284,7 @@ var PerpetualsClient = (function () {
|
|
|
4235
4284
|
.depositStake({
|
|
4236
4285
|
depositAmount: depositAmount
|
|
4237
4286
|
})
|
|
4238
|
-
.
|
|
4287
|
+
.accounts({
|
|
4239
4288
|
owner: owner,
|
|
4240
4289
|
feePayer: feePayer,
|
|
4241
4290
|
fundingLpTokenAccount: userLpTokenAccount,
|
|
@@ -4246,6 +4295,8 @@ var PerpetualsClient = (function () {
|
|
|
4246
4295
|
poolStakedLpVault: poolStakedLpVault,
|
|
4247
4296
|
systemProgram: web3_js_1.SystemProgram.programId,
|
|
4248
4297
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
4298
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
4299
|
+
program: this.programId,
|
|
4249
4300
|
lpTokenMint: poolConfig.stakedLpTokenMint,
|
|
4250
4301
|
})
|
|
4251
4302
|
.instruction()];
|
|
@@ -4298,11 +4349,12 @@ var PerpetualsClient = (function () {
|
|
|
4298
4349
|
}
|
|
4299
4350
|
return [4, this.program.methods
|
|
4300
4351
|
.refreshStake({})
|
|
4301
|
-
.
|
|
4352
|
+
.accounts({
|
|
4302
4353
|
perpetuals: this.perpetuals.publicKey,
|
|
4303
4354
|
pool: pool,
|
|
4304
4355
|
rewardCustody: rewardCustodyConfig.custodyAccount,
|
|
4305
4356
|
feeDistributionTokenAccount: feeDistributionTokenAccount,
|
|
4357
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
4306
4358
|
program: this.program.programId,
|
|
4307
4359
|
})
|
|
4308
4360
|
.remainingAccounts(__spreadArray(__spreadArray([], custodyAccountMetas, true), flpStakeAccountMetas, true))
|
|
@@ -4358,11 +4410,12 @@ var PerpetualsClient = (function () {
|
|
|
4358
4410
|
});
|
|
4359
4411
|
return [4, this.program.methods
|
|
4360
4412
|
.refreshStake({})
|
|
4361
|
-
.
|
|
4413
|
+
.accounts({
|
|
4362
4414
|
perpetuals: this.perpetuals.publicKey,
|
|
4363
4415
|
pool: pool,
|
|
4364
4416
|
rewardCustody: rewardCustodyConfig.custodyAccount,
|
|
4365
4417
|
feeDistributionTokenAccount: feeDistributionTokenAccount,
|
|
4418
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
4366
4419
|
program: this.program.programId,
|
|
4367
4420
|
})
|
|
4368
4421
|
.remainingAccounts(__spreadArray(__spreadArray([], custodyAccountMetas, true), stakeAccountMetas, true))
|
|
@@ -4421,12 +4474,13 @@ var PerpetualsClient = (function () {
|
|
|
4421
4474
|
.unstakeInstant({
|
|
4422
4475
|
unstakeAmount: unstakeAmount
|
|
4423
4476
|
})
|
|
4424
|
-
.
|
|
4477
|
+
.accounts({
|
|
4425
4478
|
owner: publicKey,
|
|
4426
4479
|
perpetuals: this.perpetuals.publicKey,
|
|
4427
4480
|
pool: pool,
|
|
4428
4481
|
flpStakeAccount: flpStakeAccount,
|
|
4429
4482
|
rewardCustody: rewardCustodyConfig.custodyAccount,
|
|
4483
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
4430
4484
|
program: this.program.programId,
|
|
4431
4485
|
})
|
|
4432
4486
|
.remainingAccounts(__spreadArray([], tokenStakeAccounts, true))
|
|
@@ -4481,7 +4535,7 @@ var PerpetualsClient = (function () {
|
|
|
4481
4535
|
.setFeeShare({
|
|
4482
4536
|
feeShareBps: new anchor_1.BN(7000)
|
|
4483
4537
|
})
|
|
4484
|
-
.
|
|
4538
|
+
.accounts({
|
|
4485
4539
|
admin: publicKey,
|
|
4486
4540
|
multisig: this.multisig.publicKey,
|
|
4487
4541
|
pool: pool,
|
|
@@ -4518,13 +4572,14 @@ var PerpetualsClient = (function () {
|
|
|
4518
4572
|
.unstakeRequest({
|
|
4519
4573
|
unstakeAmount: unstakeAmount
|
|
4520
4574
|
})
|
|
4521
|
-
.
|
|
4575
|
+
.accounts({
|
|
4522
4576
|
owner: publicKey,
|
|
4523
4577
|
perpetuals: this.perpetuals.publicKey,
|
|
4524
4578
|
pool: pool,
|
|
4525
4579
|
flpStakeAccount: flpStakeAccount,
|
|
4526
4580
|
systemProgram: web3_js_1.SystemProgram.programId,
|
|
4527
4581
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
4582
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
4528
4583
|
program: this.programId
|
|
4529
4584
|
})
|
|
4530
4585
|
.instruction()];
|
|
@@ -4585,7 +4640,7 @@ var PerpetualsClient = (function () {
|
|
|
4585
4640
|
pendingActivation: pendingActivation,
|
|
4586
4641
|
deactivated: deactivated
|
|
4587
4642
|
})
|
|
4588
|
-
.
|
|
4643
|
+
.accounts({
|
|
4589
4644
|
owner: publicKey,
|
|
4590
4645
|
receivingLpTokenAccount: userLpTokenAccount,
|
|
4591
4646
|
transferAuthority: poolConfig.transferAuthority,
|
|
@@ -4595,6 +4650,7 @@ var PerpetualsClient = (function () {
|
|
|
4595
4650
|
poolStakedLpVault: poolStakedLpVault,
|
|
4596
4651
|
systemProgram: web3_js_1.SystemProgram.programId,
|
|
4597
4652
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
4653
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
4598
4654
|
program: this.program.programId,
|
|
4599
4655
|
lpMint: poolConfig.stakedLpTokenMint,
|
|
4600
4656
|
})
|
|
@@ -4659,7 +4715,7 @@ var PerpetualsClient = (function () {
|
|
|
4659
4715
|
}
|
|
4660
4716
|
return [4, this.program.methods
|
|
4661
4717
|
.collectStakeFees({})
|
|
4662
|
-
.
|
|
4718
|
+
.accounts({
|
|
4663
4719
|
owner: publicKey,
|
|
4664
4720
|
receivingTokenAccount: receivingTokenAccount,
|
|
4665
4721
|
transferAuthority: poolConfig.transferAuthority,
|
|
@@ -4671,6 +4727,7 @@ var PerpetualsClient = (function () {
|
|
|
4671
4727
|
program: this.program.programId,
|
|
4672
4728
|
systemProgram: web3_js_1.SystemProgram.programId,
|
|
4673
4729
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
4730
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
4674
4731
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
4675
4732
|
receivingMint: rewardCustodyMint,
|
|
4676
4733
|
})
|
|
@@ -4697,13 +4754,14 @@ var PerpetualsClient = (function () {
|
|
|
4697
4754
|
for (var _i = 5; _i < arguments.length; _i++) {
|
|
4698
4755
|
args_1[_i - 5] = arguments[_i];
|
|
4699
4756
|
}
|
|
4700
|
-
return __awaiter(_this, __spreadArray([amountIn_1, minCompoundingAmountOut_1, inTokenSymbol_1, rewardTokenMint_1, poolConfig_1], args_1, true), void 0, function (amountIn, minCompoundingAmountOut, inTokenSymbol, rewardTokenMint, poolConfig, skipBalanceChecks, ephemeralSignerPubkey, userPublicKey, enableHeapSizeIx, isWhitelistedUser) {
|
|
4757
|
+
return __awaiter(_this, __spreadArray([amountIn_1, minCompoundingAmountOut_1, inTokenSymbol_1, rewardTokenMint_1, poolConfig_1], args_1, true), void 0, function (amountIn, minCompoundingAmountOut, inTokenSymbol, rewardTokenMint, poolConfig, skipBalanceChecks, ephemeralSignerPubkey, userPublicKey, enableHeapSizeIx, isWhitelistedUser, includeRemainingAccounts) {
|
|
4701
4758
|
var publicKey, preInstructions, instructions, additionalSigners, postInstructions, rewardCustody, inCustodyConfig, lpTokenMint, compoundingTokenMint, wrappedSolAccount, lpTokenAccount, compoundingTokenAccount, fundingAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _a, _b, custody, _c, _d, market, lamports, unWrappedSolBalance, _e, heapSizeIx, whitelistPda, whitelistMeta, addCompoundingLiquidity, err_16;
|
|
4702
4759
|
if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
|
|
4703
4760
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
4704
4761
|
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
|
4705
4762
|
if (enableHeapSizeIx === void 0) { enableHeapSizeIx = true; }
|
|
4706
4763
|
if (isWhitelistedUser === void 0) { isWhitelistedUser = false; }
|
|
4764
|
+
if (includeRemainingAccounts === void 0) { includeRemainingAccounts = true; }
|
|
4707
4765
|
return __generator(this, function (_f) {
|
|
4708
4766
|
switch (_f.label) {
|
|
4709
4767
|
case 0:
|
|
@@ -4811,7 +4869,7 @@ var PerpetualsClient = (function () {
|
|
|
4811
4869
|
amountIn: amountIn,
|
|
4812
4870
|
minCompoundingAmountOut: minCompoundingAmountOut
|
|
4813
4871
|
})
|
|
4814
|
-
.
|
|
4872
|
+
.accounts({
|
|
4815
4873
|
owner: publicKey,
|
|
4816
4874
|
fundingAccount: inTokenSymbol == 'SOL' ? (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey) : fundingAccount,
|
|
4817
4875
|
compoundingTokenAccount: compoundingTokenAccount,
|
|
@@ -4827,12 +4885,13 @@ var PerpetualsClient = (function () {
|
|
|
4827
4885
|
lpTokenMint: lpTokenMint,
|
|
4828
4886
|
compoundingTokenMint: compoundingTokenMint,
|
|
4829
4887
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
4888
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
4830
4889
|
program: this.program.programId,
|
|
4831
4890
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
4832
4891
|
fundingMint: inCustodyConfig.mintKey,
|
|
4833
4892
|
fundingTokenProgram: poolConfig.getTokenFromSymbol(inTokenSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
4834
4893
|
})
|
|
4835
|
-
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), (isWhitelistedUser ? [whitelistMeta] : []), true))
|
|
4894
|
+
.remainingAccounts(includeRemainingAccounts ? __spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), (isWhitelistedUser ? [whitelistMeta] : []), true) : __spreadArray([], (isWhitelistedUser ? [whitelistMeta] : []), true))
|
|
4836
4895
|
.instruction()];
|
|
4837
4896
|
case 8:
|
|
4838
4897
|
addCompoundingLiquidity = _f.sent();
|
|
@@ -4855,13 +4914,14 @@ var PerpetualsClient = (function () {
|
|
|
4855
4914
|
for (var _i = 5; _i < arguments.length; _i++) {
|
|
4856
4915
|
args_1[_i - 5] = arguments[_i];
|
|
4857
4916
|
}
|
|
4858
|
-
return __awaiter(_this, __spreadArray([compoundingAmountIn_1, minAmountOut_1, outTokenSymbol_1, rewardTokenMint_1, poolConfig_1], args_1, true), void 0, function (compoundingAmountIn, minAmountOut, outTokenSymbol, rewardTokenMint, poolConfig, createUserATA, ephemeralSignerPubkey, userPublicKey, enableHeapSizeIx, isWhitelistedUser) {
|
|
4917
|
+
return __awaiter(_this, __spreadArray([compoundingAmountIn_1, minAmountOut_1, outTokenSymbol_1, rewardTokenMint_1, poolConfig_1], args_1, true), void 0, function (compoundingAmountIn, minAmountOut, outTokenSymbol, rewardTokenMint, poolConfig, createUserATA, ephemeralSignerPubkey, userPublicKey, enableHeapSizeIx, isWhitelistedUser, includeRemainingAccounts) {
|
|
4859
4918
|
var publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, outCustodyConfig, lpTokenMint, compoundingTokenMint, lamports, _a, custodyAccountMetas, custodyOracleAccountMetas, markets, _b, _c, custody, _d, _e, market, compoundingTokenAccount, heapSizeIx, whitelistPda, whitelistMeta, removeCompoundingLiquidity, err_17;
|
|
4860
4919
|
if (createUserATA === void 0) { createUserATA = true; }
|
|
4861
4920
|
if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
|
|
4862
4921
|
if (userPublicKey === void 0) { userPublicKey = undefined; }
|
|
4863
4922
|
if (enableHeapSizeIx === void 0) { enableHeapSizeIx = true; }
|
|
4864
4923
|
if (isWhitelistedUser === void 0) { isWhitelistedUser = false; }
|
|
4924
|
+
if (includeRemainingAccounts === void 0) { includeRemainingAccounts = true; }
|
|
4865
4925
|
return __generator(this, function (_f) {
|
|
4866
4926
|
switch (_f.label) {
|
|
4867
4927
|
case 0:
|
|
@@ -4953,7 +5013,7 @@ var PerpetualsClient = (function () {
|
|
|
4953
5013
|
compoundingAmountIn: compoundingAmountIn,
|
|
4954
5014
|
minAmountOut: minAmountOut
|
|
4955
5015
|
})
|
|
4956
|
-
.
|
|
5016
|
+
.accounts({
|
|
4957
5017
|
owner: publicKey,
|
|
4958
5018
|
receivingAccount: outCustodyConfig.symbol == 'SOL' ? (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey) : userReceivingTokenAccount,
|
|
4959
5019
|
compoundingTokenAccount: compoundingTokenAccount,
|
|
@@ -4969,12 +5029,13 @@ var PerpetualsClient = (function () {
|
|
|
4969
5029
|
lpTokenMint: lpTokenMint,
|
|
4970
5030
|
compoundingTokenMint: compoundingTokenMint,
|
|
4971
5031
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
5032
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
4972
5033
|
program: this.program.programId,
|
|
4973
5034
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
4974
5035
|
receivingMint: outCustodyConfig.mintKey,
|
|
4975
5036
|
receivingTokenProgram: poolConfig.getTokenFromSymbol(outTokenSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
4976
5037
|
})
|
|
4977
|
-
.remainingAccounts(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), (isWhitelistedUser ? [whitelistMeta] : []), true))
|
|
5038
|
+
.remainingAccounts(includeRemainingAccounts ? __spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), (isWhitelistedUser ? [whitelistMeta] : []), true) : __spreadArray([], (isWhitelistedUser ? [whitelistMeta] : []), true))
|
|
4978
5039
|
.instruction()];
|
|
4979
5040
|
case 6:
|
|
4980
5041
|
removeCompoundingLiquidity = _f.sent();
|
|
@@ -5071,7 +5132,7 @@ var PerpetualsClient = (function () {
|
|
|
5071
5132
|
.migrateStake({
|
|
5072
5133
|
amount: amount
|
|
5073
5134
|
})
|
|
5074
|
-
.
|
|
5135
|
+
.accounts({
|
|
5075
5136
|
owner: publicKey,
|
|
5076
5137
|
compoundingTokenAccount: compoudingTokenAccount,
|
|
5077
5138
|
transferAuthority: poolConfig.transferAuthority,
|
|
@@ -5085,6 +5146,7 @@ var PerpetualsClient = (function () {
|
|
|
5085
5146
|
lpTokenMint: lpTokenMint,
|
|
5086
5147
|
compoundingTokenMint: compoundingTokenMint,
|
|
5087
5148
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
5149
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
5088
5150
|
program: this.program.programId,
|
|
5089
5151
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
|
|
5090
5152
|
})
|
|
@@ -5153,7 +5215,7 @@ var PerpetualsClient = (function () {
|
|
|
5153
5215
|
.migrateFlp({
|
|
5154
5216
|
compoundingTokenAmount: amount
|
|
5155
5217
|
})
|
|
5156
|
-
.
|
|
5218
|
+
.accounts({
|
|
5157
5219
|
owner: publicKey,
|
|
5158
5220
|
compoundingTokenAccount: compoudingTokenAccount,
|
|
5159
5221
|
transferAuthority: poolConfig.transferAuthority,
|
|
@@ -5168,6 +5230,7 @@ var PerpetualsClient = (function () {
|
|
|
5168
5230
|
compoundingTokenMint: compoundingTokenMint,
|
|
5169
5231
|
systemProgram: web3_js_1.SystemProgram.programId,
|
|
5170
5232
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
5233
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
5171
5234
|
program: this.program.programId,
|
|
5172
5235
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
|
|
5173
5236
|
})
|
|
@@ -5232,7 +5295,7 @@ var PerpetualsClient = (function () {
|
|
|
5232
5295
|
_e.trys.push([1, 3, , 4]);
|
|
5233
5296
|
return [4, this.program.methods
|
|
5234
5297
|
.compoundFees({})
|
|
5235
|
-
.
|
|
5298
|
+
.accounts({
|
|
5236
5299
|
poolCompoundingLpVault: poolConfig.compoundingLpVault,
|
|
5237
5300
|
transferAuthority: poolConfig.transferAuthority,
|
|
5238
5301
|
perpetuals: poolConfig.perpetuals,
|
|
@@ -5241,6 +5304,7 @@ var PerpetualsClient = (function () {
|
|
|
5241
5304
|
rewardCustodyOracleAccount: this.useExtOracleAccount ? rewardCustody.extOracleAccount : rewardCustody.intOracleAccount,
|
|
5242
5305
|
lpTokenMint: lpTokenMint,
|
|
5243
5306
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
5307
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
5244
5308
|
program: this.program.programId,
|
|
5245
5309
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
|
|
5246
5310
|
})
|
|
@@ -5285,7 +5349,7 @@ var PerpetualsClient = (function () {
|
|
|
5285
5349
|
.depositTokenStake({
|
|
5286
5350
|
depositAmount: depositAmount
|
|
5287
5351
|
})
|
|
5288
|
-
.
|
|
5352
|
+
.accounts({
|
|
5289
5353
|
owner: owner,
|
|
5290
5354
|
feePayer: feePayer,
|
|
5291
5355
|
fundingTokenAccount: userTokenAccount,
|
|
@@ -5295,6 +5359,8 @@ var PerpetualsClient = (function () {
|
|
|
5295
5359
|
tokenStakeAccount: tokenStakeAccount,
|
|
5296
5360
|
systemProgram: web3_js_1.SystemProgram.programId,
|
|
5297
5361
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
5362
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
5363
|
+
program: this.programId,
|
|
5298
5364
|
tokenMint: poolConfig.tokenMint,
|
|
5299
5365
|
})
|
|
5300
5366
|
.instruction()];
|
|
@@ -5330,10 +5396,11 @@ var PerpetualsClient = (function () {
|
|
|
5330
5396
|
.unstakeTokenRequest({
|
|
5331
5397
|
unstakeAmount: unstakeAmount
|
|
5332
5398
|
})
|
|
5333
|
-
.
|
|
5399
|
+
.accounts({
|
|
5334
5400
|
owner: owner,
|
|
5335
5401
|
tokenVault: poolConfig.tokenVault,
|
|
5336
5402
|
tokenStakeAccount: tokenStakeAccount,
|
|
5403
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
5337
5404
|
program: this.programId
|
|
5338
5405
|
})
|
|
5339
5406
|
.instruction()];
|
|
@@ -5375,7 +5442,7 @@ var PerpetualsClient = (function () {
|
|
|
5375
5442
|
.unstakeTokenInstant({
|
|
5376
5443
|
unstakeAmount: unstakeAmount
|
|
5377
5444
|
})
|
|
5378
|
-
.
|
|
5445
|
+
.accounts({
|
|
5379
5446
|
owner: owner,
|
|
5380
5447
|
receivingTokenAccount: userTokenAccount,
|
|
5381
5448
|
perpetuals: poolConfig.perpetuals,
|
|
@@ -5384,6 +5451,8 @@ var PerpetualsClient = (function () {
|
|
|
5384
5451
|
tokenVaultTokenAccount: poolConfig.tokenVaultTokenAccount,
|
|
5385
5452
|
tokenStakeAccount: tokenStakeAccount,
|
|
5386
5453
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
5454
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
5455
|
+
program: this.programId,
|
|
5387
5456
|
tokenMint: poolConfig.tokenMint,
|
|
5388
5457
|
})
|
|
5389
5458
|
.instruction()];
|
|
@@ -5425,7 +5494,7 @@ var PerpetualsClient = (function () {
|
|
|
5425
5494
|
.withdrawToken({
|
|
5426
5495
|
withdrawRequestId: withdrawRequestId
|
|
5427
5496
|
})
|
|
5428
|
-
.
|
|
5497
|
+
.accounts({
|
|
5429
5498
|
owner: owner,
|
|
5430
5499
|
receivingTokenAccount: userTokenAccount,
|
|
5431
5500
|
perpetuals: this.perpetuals.publicKey,
|
|
@@ -5434,6 +5503,8 @@ var PerpetualsClient = (function () {
|
|
|
5434
5503
|
tokenVaultTokenAccount: poolConfig.tokenVaultTokenAccount,
|
|
5435
5504
|
tokenStakeAccount: tokenStakeAccount,
|
|
5436
5505
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
5506
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
5507
|
+
program: this.programId,
|
|
5437
5508
|
tokenMint: poolConfig.tokenMint,
|
|
5438
5509
|
})
|
|
5439
5510
|
.instruction()];
|
|
@@ -5469,10 +5540,11 @@ var PerpetualsClient = (function () {
|
|
|
5469
5540
|
.cancelUnstakeTokenRequest({
|
|
5470
5541
|
withdrawRequestId: withdrawRequestId
|
|
5471
5542
|
})
|
|
5472
|
-
.
|
|
5543
|
+
.accounts({
|
|
5473
5544
|
owner: owner,
|
|
5474
5545
|
tokenVault: poolConfig.tokenVault,
|
|
5475
5546
|
tokenStakeAccount: tokenStakeAccount,
|
|
5547
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
5476
5548
|
program: this.programId
|
|
5477
5549
|
})
|
|
5478
5550
|
.instruction()];
|
|
@@ -5524,7 +5596,7 @@ var PerpetualsClient = (function () {
|
|
|
5524
5596
|
}
|
|
5525
5597
|
return [4, this.program.methods
|
|
5526
5598
|
.collectTokenReward({})
|
|
5527
|
-
.
|
|
5599
|
+
.accounts({
|
|
5528
5600
|
owner: owner,
|
|
5529
5601
|
receivingTokenAccount: userTokenAccount,
|
|
5530
5602
|
perpetuals: this.perpetuals.publicKey,
|
|
@@ -5533,6 +5605,8 @@ var PerpetualsClient = (function () {
|
|
|
5533
5605
|
tokenVaultTokenAccount: poolConfig.tokenVaultTokenAccount,
|
|
5534
5606
|
tokenStakeAccount: tokenStakeAccount,
|
|
5535
5607
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
5608
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
5609
|
+
program: this.programId,
|
|
5536
5610
|
tokenMint: poolConfig.tokenMint,
|
|
5537
5611
|
})
|
|
5538
5612
|
.instruction()];
|
|
@@ -5586,7 +5660,7 @@ var PerpetualsClient = (function () {
|
|
|
5586
5660
|
}
|
|
5587
5661
|
return [4, this.program.methods
|
|
5588
5662
|
.collectRevenue({})
|
|
5589
|
-
.
|
|
5663
|
+
.accounts({
|
|
5590
5664
|
owner: owner,
|
|
5591
5665
|
receivingRevenueAccount: userTokenAccount,
|
|
5592
5666
|
perpetuals: this.perpetuals.publicKey,
|
|
@@ -5595,6 +5669,8 @@ var PerpetualsClient = (function () {
|
|
|
5595
5669
|
revenueTokenAccount: poolConfig.revenueTokenAccount,
|
|
5596
5670
|
tokenStakeAccount: tokenStakeAccount,
|
|
5597
5671
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
5672
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
5673
|
+
program: this.programId,
|
|
5598
5674
|
receivingTokenMint: rewardCustodyMint,
|
|
5599
5675
|
})
|
|
5600
5676
|
.instruction()];
|
|
@@ -5648,7 +5724,7 @@ var PerpetualsClient = (function () {
|
|
|
5648
5724
|
}
|
|
5649
5725
|
return [4, this.program.methods
|
|
5650
5726
|
.collectRebate()
|
|
5651
|
-
.
|
|
5727
|
+
.accounts({
|
|
5652
5728
|
owner: owner,
|
|
5653
5729
|
receivingTokenAccount: userTokenAccount,
|
|
5654
5730
|
perpetuals: this.perpetuals.publicKey,
|
|
@@ -5657,6 +5733,8 @@ var PerpetualsClient = (function () {
|
|
|
5657
5733
|
rebateTokenAccount: poolConfig.rebateTokenAccount,
|
|
5658
5734
|
tokenStakeAccount: tokenStakeAccount,
|
|
5659
5735
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
5736
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
5737
|
+
program: this.programId,
|
|
5660
5738
|
receivingTokenMint: rebateMint,
|
|
5661
5739
|
})
|
|
5662
5740
|
.instruction()];
|
|
@@ -5692,7 +5770,7 @@ var PerpetualsClient = (function () {
|
|
|
5692
5770
|
rebateMint = poolConfig.getTokenFromSymbol(rebateSymbol).mintKey;
|
|
5693
5771
|
return [4, this.program.methods
|
|
5694
5772
|
.settleRebates()
|
|
5695
|
-
.
|
|
5773
|
+
.accounts({
|
|
5696
5774
|
transferAuthority: poolConfig.transferAuthority,
|
|
5697
5775
|
perpetuals: this.perpetuals.publicKey,
|
|
5698
5776
|
pool: poolConfig.poolAddress,
|
|
@@ -5703,6 +5781,8 @@ var PerpetualsClient = (function () {
|
|
|
5703
5781
|
rebateTokenAccount: poolConfig.rebateTokenAccount,
|
|
5704
5782
|
tokenMint: rebateMint,
|
|
5705
5783
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
5784
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
5785
|
+
program: this.programId,
|
|
5706
5786
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
|
|
5707
5787
|
})
|
|
5708
5788
|
.instruction()];
|
|
@@ -5805,7 +5885,7 @@ var PerpetualsClient = (function () {
|
|
|
5805
5885
|
stopLossPrice: stopLossPrice,
|
|
5806
5886
|
takeProfitPrice: takeProfitPrice
|
|
5807
5887
|
})
|
|
5808
|
-
.
|
|
5888
|
+
.accounts({
|
|
5809
5889
|
owner: publicKey,
|
|
5810
5890
|
feePayer: publicKey,
|
|
5811
5891
|
fundingAccount: reserveSymbol == 'SOL' ? wrappedSolAccount.publicKey : userReserveTokenAccount,
|
|
@@ -5822,6 +5902,8 @@ var PerpetualsClient = (function () {
|
|
|
5822
5902
|
receiveCustody: receiveCustodyConfig.custodyAccount,
|
|
5823
5903
|
systemProgram: web3_js_1.SystemProgram.programId,
|
|
5824
5904
|
fundingTokenProgram: poolConfig.getTokenFromSymbol(reserveSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
5905
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
5906
|
+
program: this.programId,
|
|
5825
5907
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
5826
5908
|
fundingMint: reserveCustodyConfig.mintKey,
|
|
5827
5909
|
})
|
|
@@ -5911,7 +5993,7 @@ var PerpetualsClient = (function () {
|
|
|
5911
5993
|
stopLossPrice: stopLossPrice,
|
|
5912
5994
|
takeProfitPrice: takeProfitPrice
|
|
5913
5995
|
})
|
|
5914
|
-
.
|
|
5996
|
+
.accounts({
|
|
5915
5997
|
owner: publicKey,
|
|
5916
5998
|
feePayer: publicKey,
|
|
5917
5999
|
receivingAccount: reserveSymbol == 'SOL' ? (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey) : userReceivingTokenAccount,
|
|
@@ -5928,6 +6010,8 @@ var PerpetualsClient = (function () {
|
|
|
5928
6010
|
reserveCustodyTokenAccount: reserveCustodyConfig.tokenAccount,
|
|
5929
6011
|
receiveCustody: receiveCustodyConfig.custodyAccount,
|
|
5930
6012
|
receivingTokenProgram: poolConfig.getTokenFromSymbol(reserveSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
6013
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
6014
|
+
program: this.programId,
|
|
5931
6015
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
5932
6016
|
receivingMint: poolConfig.getTokenFromSymbol(reserveSymbol).mintKey
|
|
5933
6017
|
})
|
|
@@ -5978,7 +6062,7 @@ var PerpetualsClient = (function () {
|
|
|
5978
6062
|
orderId: orderId,
|
|
5979
6063
|
privilege: privilege
|
|
5980
6064
|
})
|
|
5981
|
-
.
|
|
6065
|
+
.accounts({
|
|
5982
6066
|
positionOwner: userPubkey,
|
|
5983
6067
|
feePayer: publicKey,
|
|
5984
6068
|
transferAuthority: poolConfig.transferAuthority,
|
|
@@ -5994,6 +6078,8 @@ var PerpetualsClient = (function () {
|
|
|
5994
6078
|
collateralCustodyTokenAccount: collateralCustodyConfig.tokenAccount,
|
|
5995
6079
|
systemProgram: web3_js_1.SystemProgram.programId,
|
|
5996
6080
|
collateralTokenProgram: poolConfig.getTokenFromSymbol(collateralSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
6081
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
6082
|
+
program: this.programId,
|
|
5997
6083
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
5998
6084
|
collateralMint: collateralCustodyConfig.mintKey,
|
|
5999
6085
|
})
|
|
@@ -6046,7 +6132,7 @@ var PerpetualsClient = (function () {
|
|
|
6046
6132
|
orderId: orderId,
|
|
6047
6133
|
privilege: privilege
|
|
6048
6134
|
})
|
|
6049
|
-
.
|
|
6135
|
+
.accounts({
|
|
6050
6136
|
positionOwner: userPubkey,
|
|
6051
6137
|
feePayer: publicKey,
|
|
6052
6138
|
transferAuthority: poolConfig.transferAuthority,
|
|
@@ -6064,6 +6150,8 @@ var PerpetualsClient = (function () {
|
|
|
6064
6150
|
collateralCustodyTokenAccount: collateralCustodyConfig.tokenAccount,
|
|
6065
6151
|
systemProgram: web3_js_1.SystemProgram.programId,
|
|
6066
6152
|
collateralTokenProgram: poolConfig.getTokenFromSymbol(collateralSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
6153
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
6154
|
+
program: this.programId,
|
|
6067
6155
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
6068
6156
|
collateralMint: collateralCustodyConfig.mintKey,
|
|
6069
6157
|
})
|
|
@@ -6110,7 +6198,7 @@ var PerpetualsClient = (function () {
|
|
|
6110
6198
|
deltaSizeAmount: deltaSizeAmount,
|
|
6111
6199
|
isStopLoss: isStopLoss
|
|
6112
6200
|
})
|
|
6113
|
-
.
|
|
6201
|
+
.accounts({
|
|
6114
6202
|
owner: publicKey,
|
|
6115
6203
|
feePayer: publicKey,
|
|
6116
6204
|
perpetuals: poolConfig.perpetuals,
|
|
@@ -6124,6 +6212,8 @@ var PerpetualsClient = (function () {
|
|
|
6124
6212
|
collateralOracleAccount: this.useExtOracleAccount ? collateralCustodyConfig.extOracleAccount : collateralCustodyConfig.intOracleAccount,
|
|
6125
6213
|
receiveCustody: receivingCustodyConfig.custodyAccount,
|
|
6126
6214
|
systemProgram: web3_js_1.SystemProgram.programId,
|
|
6215
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
6216
|
+
program: this.programId,
|
|
6127
6217
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
|
|
6128
6218
|
})
|
|
6129
6219
|
.instruction()];
|
|
@@ -6168,7 +6258,7 @@ var PerpetualsClient = (function () {
|
|
|
6168
6258
|
deltaSizeAmount: deltaSizeAmount,
|
|
6169
6259
|
isStopLoss: isStopLoss
|
|
6170
6260
|
})
|
|
6171
|
-
.
|
|
6261
|
+
.accounts({
|
|
6172
6262
|
owner: publicKey,
|
|
6173
6263
|
perpetuals: poolConfig.perpetuals,
|
|
6174
6264
|
pool: poolConfig.poolAddress,
|
|
@@ -6180,6 +6270,8 @@ var PerpetualsClient = (function () {
|
|
|
6180
6270
|
collateralCustody: collateralCustodyConfig.custodyAccount,
|
|
6181
6271
|
collateralOracleAccount: this.useExtOracleAccount ? collateralCustodyConfig.extOracleAccount : collateralCustodyConfig.intOracleAccount,
|
|
6182
6272
|
receiveCustody: receivingCustodyConfig.custodyAccount,
|
|
6273
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
6274
|
+
program: this.programId,
|
|
6183
6275
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
|
|
6184
6276
|
})
|
|
6185
6277
|
.instruction()];
|
|
@@ -6220,9 +6312,11 @@ var PerpetualsClient = (function () {
|
|
|
6220
6312
|
orderId: orderId,
|
|
6221
6313
|
isStopLoss: isStopLoss
|
|
6222
6314
|
})
|
|
6223
|
-
.
|
|
6315
|
+
.accounts({
|
|
6224
6316
|
owner: publicKey,
|
|
6225
6317
|
order: orderAccount,
|
|
6318
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
6319
|
+
program: this.programId,
|
|
6226
6320
|
})
|
|
6227
6321
|
.instruction()];
|
|
6228
6322
|
case 2:
|
|
@@ -6260,9 +6354,11 @@ var PerpetualsClient = (function () {
|
|
|
6260
6354
|
positionAccount = poolConfig.getPositionFromMarketPk(publicKey, marketAccount);
|
|
6261
6355
|
return [4, this.program.methods
|
|
6262
6356
|
.cancelAllTriggerOrders()
|
|
6263
|
-
.
|
|
6357
|
+
.accounts({
|
|
6264
6358
|
position: positionAccount,
|
|
6265
6359
|
order: orderAccount,
|
|
6360
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
6361
|
+
program: this.programId,
|
|
6266
6362
|
})
|
|
6267
6363
|
.instruction()];
|
|
6268
6364
|
case 2:
|
|
@@ -6358,7 +6454,7 @@ var PerpetualsClient = (function () {
|
|
|
6358
6454
|
orderId: orderId,
|
|
6359
6455
|
privilege: privilege
|
|
6360
6456
|
})
|
|
6361
|
-
.
|
|
6457
|
+
.accounts({
|
|
6362
6458
|
positionOwner: owner,
|
|
6363
6459
|
feePayer: payerPubkey,
|
|
6364
6460
|
receivingAccount: userReceivingTokenAccount,
|
|
@@ -6377,6 +6473,8 @@ var PerpetualsClient = (function () {
|
|
|
6377
6473
|
dispensingCustody: receivingCustodyConfig.custodyAccount,
|
|
6378
6474
|
dispensingOracleAccount: this.useExtOracleAccount ? receivingCustodyConfig.extOracleAccount : receivingCustodyConfig.intOracleAccount,
|
|
6379
6475
|
dispensingCustodyTokenAccount: receivingCustodyConfig.tokenAccount,
|
|
6476
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
6477
|
+
program: this.programId,
|
|
6380
6478
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
6381
6479
|
receivingMint: receivingCustodyConfig.mintKey,
|
|
6382
6480
|
receivingTokenProgram: receivingToken.isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
@@ -6450,7 +6548,7 @@ var PerpetualsClient = (function () {
|
|
|
6450
6548
|
orderId: orderId,
|
|
6451
6549
|
privilege: privilege
|
|
6452
6550
|
})
|
|
6453
|
-
.
|
|
6551
|
+
.accounts({
|
|
6454
6552
|
feePayer: payerPubkey,
|
|
6455
6553
|
positionOwner: owner,
|
|
6456
6554
|
receivingAccount: userReceivingTokenAccount,
|
|
@@ -6466,6 +6564,8 @@ var PerpetualsClient = (function () {
|
|
|
6466
6564
|
collateralOracleAccount: this.useExtOracleAccount ? collateralCustodyConfig.extOracleAccount : collateralCustodyConfig.intOracleAccount,
|
|
6467
6565
|
collateralCustodyTokenAccount: collateralCustodyConfig.tokenAccount,
|
|
6468
6566
|
receivingTokenProgram: poolConfig.getTokenFromSymbol(collateralSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
6567
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
6568
|
+
program: this.programId,
|
|
6469
6569
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
6470
6570
|
receivingMint: collateralCustodyConfig.mintKey
|
|
6471
6571
|
})
|
|
@@ -6673,7 +6773,7 @@ var PerpetualsClient = (function () {
|
|
|
6673
6773
|
};
|
|
6674
6774
|
return [4, this.program.methods
|
|
6675
6775
|
.swap(params)
|
|
6676
|
-
.
|
|
6776
|
+
.accounts({
|
|
6677
6777
|
owner: publicKey,
|
|
6678
6778
|
fundingAccount: userInputTokenSymbol == 'SOL' ? (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey) : userInputTokenAccount,
|
|
6679
6779
|
receivingAccount: userOutputTokenSymbol == 'SOL' ? (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey) : userOutputTokenAccount,
|
|
@@ -6687,6 +6787,7 @@ var PerpetualsClient = (function () {
|
|
|
6687
6787
|
dispensingCustodyOracleAccount: this.useExtOracleAccount ? userOutputCustodyConfig.extOracleAccount : userOutputCustodyConfig.intOracleAccount,
|
|
6688
6788
|
dispensingCustodyTokenAccount: userOutputCustodyConfig.tokenAccount,
|
|
6689
6789
|
eventAuthority: this.eventAuthority.publicKey,
|
|
6790
|
+
program: this.programId,
|
|
6690
6791
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
6691
6792
|
fundingMint: userInputCustodyConfig.mintKey,
|
|
6692
6793
|
fundingTokenProgram: poolConfig.getTokenFromSymbol(userInputTokenSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
|
|
@@ -6754,13 +6855,15 @@ var PerpetualsClient = (function () {
|
|
|
6754
6855
|
params = {};
|
|
6755
6856
|
return [4, this.program.methods
|
|
6756
6857
|
.swapFeeInternal(params)
|
|
6757
|
-
.
|
|
6858
|
+
.accounts({
|
|
6758
6859
|
owner: publicKey,
|
|
6759
6860
|
perpetuals: poolConfig.perpetuals,
|
|
6760
6861
|
pool: poolConfig.poolAddress,
|
|
6761
6862
|
rewardCustody: rewardCustody.custodyAccount,
|
|
6762
6863
|
rewardCustodyOracleAccount: this.useExtOracleAccount ? rewardCustody.extOracleAccount : rewardCustody.intOracleAccount,
|
|
6763
6864
|
rewardCustodyTokenAccount: rewardCustody.tokenAccount,
|
|
6865
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
6866
|
+
program: this.programId,
|
|
6764
6867
|
ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
|
|
6765
6868
|
})
|
|
6766
6869
|
.remainingAccounts(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true))
|
|
@@ -6816,7 +6919,7 @@ var PerpetualsClient = (function () {
|
|
|
6816
6919
|
}
|
|
6817
6920
|
return [4, this.program.methods
|
|
6818
6921
|
.setLpTokenPrice({})
|
|
6819
|
-
.
|
|
6922
|
+
.accounts({
|
|
6820
6923
|
perpetuals: poolConfig.perpetuals,
|
|
6821
6924
|
pool: poolConfig.poolAddress,
|
|
6822
6925
|
lpTokenMint: poolConfig.stakedLpTokenMint,
|
|
@@ -6856,7 +6959,7 @@ var PerpetualsClient = (function () {
|
|
|
6856
6959
|
}
|
|
6857
6960
|
return [4, this.program.methods
|
|
6858
6961
|
.init(config)
|
|
6859
|
-
.
|
|
6962
|
+
.accounts({
|
|
6860
6963
|
upgradeAuthority: this.provider.wallet.publicKey,
|
|
6861
6964
|
multisig: this.multisig.publicKey,
|
|
6862
6965
|
transferAuthority: this.authority.publicKey,
|
|
@@ -6899,7 +7002,7 @@ var PerpetualsClient = (function () {
|
|
|
6899
7002
|
.setAdminSigners({
|
|
6900
7003
|
minSignatures: minSignatures,
|
|
6901
7004
|
})
|
|
6902
|
-
.
|
|
7005
|
+
.accounts({
|
|
6903
7006
|
admin: this.admin,
|
|
6904
7007
|
multisig: this.multisig.publicKey,
|
|
6905
7008
|
})
|
|
@@ -6936,7 +7039,7 @@ var PerpetualsClient = (function () {
|
|
|
6936
7039
|
maxLpPriceUsd: maxLpPriceUsd,
|
|
6937
7040
|
thresholdUsd: thresholdUsd
|
|
6938
7041
|
})
|
|
6939
|
-
.
|
|
7042
|
+
.accounts({
|
|
6940
7043
|
admin: this.provider.wallet.publicKey,
|
|
6941
7044
|
multisig: this.multisig.publicKey,
|
|
6942
7045
|
transferAuthority: this.authority.publicKey,
|
|
@@ -6963,7 +7066,7 @@ var PerpetualsClient = (function () {
|
|
|
6963
7066
|
switch (_a.label) {
|
|
6964
7067
|
case 0: return [4, this.program.methods
|
|
6965
7068
|
.removePool({})
|
|
6966
|
-
.
|
|
7069
|
+
.accounts({
|
|
6967
7070
|
admin: this.admin,
|
|
6968
7071
|
multisig: this.multisig.publicKey,
|
|
6969
7072
|
transferAuthority: this.authority.publicKey,
|
|
@@ -6982,7 +7085,7 @@ var PerpetualsClient = (function () {
|
|
|
6982
7085
|
}
|
|
6983
7086
|
});
|
|
6984
7087
|
}); };
|
|
6985
|
-
this.addCustody = function (poolName, tokenMint, isToken222, isStable, isVirtual, oracle, pricing, permissions, fees, borrowRate, ratios, depegAdjustment, rewardThreshold, minReserveUsd, limitPriceBufferBps) { return __awaiter(_this, void 0, void 0, function () {
|
|
7088
|
+
this.addCustody = function (poolName, tokenMint, isToken222, isStable, isVirtual, oracle, pricing, permissions, fees, borrowRate, ratios, depegAdjustment, rewardThreshold, minReserveUsd, limitPriceBufferBps, inversePrice) { return __awaiter(_this, void 0, void 0, function () {
|
|
6986
7089
|
var trx_id, error_3;
|
|
6987
7090
|
return __generator(this, function (_a) {
|
|
6988
7091
|
switch (_a.label) {
|
|
@@ -6993,6 +7096,7 @@ var PerpetualsClient = (function () {
|
|
|
6993
7096
|
isStable: isStable,
|
|
6994
7097
|
depegAdjustment: depegAdjustment,
|
|
6995
7098
|
isVirtual: isVirtual,
|
|
7099
|
+
inversePrice: inversePrice,
|
|
6996
7100
|
token22: isToken222,
|
|
6997
7101
|
oracle: oracle,
|
|
6998
7102
|
pricing: pricing,
|
|
@@ -7004,7 +7108,7 @@ var PerpetualsClient = (function () {
|
|
|
7004
7108
|
minReserveUsd: minReserveUsd,
|
|
7005
7109
|
limitPriceBufferBps: limitPriceBufferBps
|
|
7006
7110
|
})
|
|
7007
|
-
.
|
|
7111
|
+
.accounts({
|
|
7008
7112
|
admin: this.admin,
|
|
7009
7113
|
multisig: this.multisig.publicKey,
|
|
7010
7114
|
transferAuthority: this.authority.publicKey,
|
|
@@ -7048,7 +7152,7 @@ var PerpetualsClient = (function () {
|
|
|
7048
7152
|
borrowRate: borrowRate,
|
|
7049
7153
|
ratios: ratios,
|
|
7050
7154
|
})
|
|
7051
|
-
.
|
|
7155
|
+
.accounts({
|
|
7052
7156
|
admin: this.admin,
|
|
7053
7157
|
multisig: this.multisig.publicKey,
|
|
7054
7158
|
transferAuthority: this.authority.publicKey,
|
|
@@ -7082,7 +7186,7 @@ var PerpetualsClient = (function () {
|
|
|
7082
7186
|
userReceivingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(tokenMint, this.admin, true);
|
|
7083
7187
|
return [4, this.program.methods
|
|
7084
7188
|
.removeCustody({ ratios: ratios })
|
|
7085
|
-
.
|
|
7189
|
+
.accounts({
|
|
7086
7190
|
admin: this.admin,
|
|
7087
7191
|
receivingAccount: userReceivingTokenAccount,
|
|
7088
7192
|
multisig: this.multisig.publicKey,
|
|
@@ -7125,7 +7229,7 @@ var PerpetualsClient = (function () {
|
|
|
7125
7229
|
_a.trys.push([2, 4, , 5]);
|
|
7126
7230
|
return [4, this.program.methods
|
|
7127
7231
|
.withdrawFees({})
|
|
7128
|
-
.
|
|
7232
|
+
.accounts({
|
|
7129
7233
|
admin: publicKey,
|
|
7130
7234
|
multisig: this.multisig.publicKey,
|
|
7131
7235
|
transferAuthority: this.authority.publicKey,
|
|
@@ -7166,7 +7270,7 @@ var PerpetualsClient = (function () {
|
|
|
7166
7270
|
_a.trys.push([1, 3, , 4]);
|
|
7167
7271
|
return [4, this.program.methods
|
|
7168
7272
|
.moveProtocolFees()
|
|
7169
|
-
.
|
|
7273
|
+
.accounts({
|
|
7170
7274
|
transferAuthority: this.authority.publicKey,
|
|
7171
7275
|
perpetuals: this.perpetuals.publicKey,
|
|
7172
7276
|
tokenVault: poolConfig.tokenVault,
|
|
@@ -7177,6 +7281,7 @@ var PerpetualsClient = (function () {
|
|
|
7177
7281
|
protocolVault: poolConfig.protocolVault,
|
|
7178
7282
|
protocolTokenAccount: poolConfig.protocolTokenAccount,
|
|
7179
7283
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
7284
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
7180
7285
|
program: this.program.programId,
|
|
7181
7286
|
tokenMint: rewardCustodyConfig.mintKey,
|
|
7182
7287
|
})
|
|
@@ -7207,7 +7312,7 @@ var PerpetualsClient = (function () {
|
|
|
7207
7312
|
.setProtocolFeeShare({
|
|
7208
7313
|
feeShareBps: feeShareBps
|
|
7209
7314
|
})
|
|
7210
|
-
.
|
|
7315
|
+
.accounts({
|
|
7211
7316
|
admin: publicKey,
|
|
7212
7317
|
multisig: this.multisig.publicKey,
|
|
7213
7318
|
protocolVault: poolConfig.protocolVault,
|
|
@@ -7241,7 +7346,7 @@ var PerpetualsClient = (function () {
|
|
|
7241
7346
|
.setPermissions({
|
|
7242
7347
|
permissions: permissions,
|
|
7243
7348
|
})
|
|
7244
|
-
.
|
|
7349
|
+
.accounts({
|
|
7245
7350
|
admin: publicKey,
|
|
7246
7351
|
multisig: this.multisig.publicKey,
|
|
7247
7352
|
perpetuals: this.perpetuals.publicKey
|
|
@@ -7300,7 +7405,7 @@ var PerpetualsClient = (function () {
|
|
|
7300
7405
|
_g.trys.push([1, 4, , 5]);
|
|
7301
7406
|
_e = (_d = this.program.methods
|
|
7302
7407
|
.reimburse({ amountIn: amountIn }))
|
|
7303
|
-
.
|
|
7408
|
+
.accounts;
|
|
7304
7409
|
_f = {
|
|
7305
7410
|
admin: this.provider.wallet.publicKey,
|
|
7306
7411
|
multisig: poolConfig.multisig
|
|
@@ -7354,7 +7459,7 @@ var PerpetualsClient = (function () {
|
|
|
7354
7459
|
ema: ema,
|
|
7355
7460
|
publishTime: publishTime,
|
|
7356
7461
|
})
|
|
7357
|
-
.
|
|
7462
|
+
.accounts({
|
|
7358
7463
|
authority: poolConfig.backupOracle,
|
|
7359
7464
|
perpetuals: poolConfig.perpetuals,
|
|
7360
7465
|
pool: poolConfig.poolAddress,
|
|
@@ -7416,7 +7521,7 @@ var PerpetualsClient = (function () {
|
|
|
7416
7521
|
useCurrentTime: useCurrentTime,
|
|
7417
7522
|
prices: tokenInternalPrices
|
|
7418
7523
|
})
|
|
7419
|
-
.
|
|
7524
|
+
.accounts({
|
|
7420
7525
|
authority: POOL_CONFIGS[0].backupOracle,
|
|
7421
7526
|
})
|
|
7422
7527
|
.remainingAccounts(__spreadArray([], accountMetas, true))
|
|
@@ -7467,7 +7572,7 @@ var PerpetualsClient = (function () {
|
|
|
7467
7572
|
.setInternalEmaPrice({
|
|
7468
7573
|
prices: tokenInternalEmaPrices
|
|
7469
7574
|
})
|
|
7470
|
-
.
|
|
7575
|
+
.accounts({
|
|
7471
7576
|
authority: POOL_CONFIGS[0].backupOracle,
|
|
7472
7577
|
})
|
|
7473
7578
|
.remainingAccounts(__spreadArray([], accountMetas, true))
|
|
@@ -7501,9 +7606,10 @@ var PerpetualsClient = (function () {
|
|
|
7501
7606
|
.setPositionPriceImpact({
|
|
7502
7607
|
priceImpactUsd: priceImpactUsd,
|
|
7503
7608
|
})
|
|
7504
|
-
.
|
|
7609
|
+
.accounts({
|
|
7505
7610
|
authority: penaltyAuthority,
|
|
7506
7611
|
position: positionPubkey,
|
|
7612
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
7507
7613
|
program: this.program.programId,
|
|
7508
7614
|
})
|
|
7509
7615
|
.instruction()];
|
|
@@ -7542,7 +7648,7 @@ var PerpetualsClient = (function () {
|
|
|
7542
7648
|
lpTokenSymbol: lpTokenSymbol,
|
|
7543
7649
|
lpTokenUri: lpTokenUri,
|
|
7544
7650
|
})
|
|
7545
|
-
.
|
|
7651
|
+
.accounts({
|
|
7546
7652
|
admin: publicKey,
|
|
7547
7653
|
multisig: this.multisig.publicKey,
|
|
7548
7654
|
transferAuthority: poolConfig.transferAuthority,
|
|
@@ -7591,7 +7697,7 @@ var PerpetualsClient = (function () {
|
|
|
7591
7697
|
.initStaking({
|
|
7592
7698
|
stakingFeeShareBps: stakingFeeShareBps
|
|
7593
7699
|
})
|
|
7594
|
-
.
|
|
7700
|
+
.accounts({
|
|
7595
7701
|
admin: publicKey,
|
|
7596
7702
|
multisig: this.multisig.publicKey,
|
|
7597
7703
|
transferAuthority: poolConfig.transferAuthority,
|
|
@@ -7644,7 +7750,7 @@ var PerpetualsClient = (function () {
|
|
|
7644
7750
|
metadataSymbol: metadataSymbol,
|
|
7645
7751
|
metadataUri: metadataUri
|
|
7646
7752
|
})
|
|
7647
|
-
.
|
|
7753
|
+
.accounts({
|
|
7648
7754
|
admin: publicKey,
|
|
7649
7755
|
multisig: this.multisig.publicKey,
|
|
7650
7756
|
transferAuthority: poolConfig.transferAuthority,
|
|
@@ -7698,7 +7804,7 @@ var PerpetualsClient = (function () {
|
|
|
7698
7804
|
withdrawInstantFee: withdrawInstantFee,
|
|
7699
7805
|
stakeLevel: stakeLevel,
|
|
7700
7806
|
})
|
|
7701
|
-
.
|
|
7807
|
+
.accounts({
|
|
7702
7808
|
admin: publicKey,
|
|
7703
7809
|
multisig: this.multisig.publicKey,
|
|
7704
7810
|
perpetuals: this.perpetuals.publicKey,
|
|
@@ -7747,7 +7853,7 @@ var PerpetualsClient = (function () {
|
|
|
7747
7853
|
withdrawInstantFee: withdrawInstantFee,
|
|
7748
7854
|
stakeLevel: stakeLevel,
|
|
7749
7855
|
})
|
|
7750
|
-
.
|
|
7856
|
+
.accounts({
|
|
7751
7857
|
admin: publicKey,
|
|
7752
7858
|
multisig: this.multisig.publicKey,
|
|
7753
7859
|
tokenVault: poolConfig.tokenVault,
|
|
@@ -7792,7 +7898,7 @@ var PerpetualsClient = (function () {
|
|
|
7792
7898
|
}
|
|
7793
7899
|
return [4, this.program.methods
|
|
7794
7900
|
.withdrawInstantFees({})
|
|
7795
|
-
.
|
|
7901
|
+
.accounts({
|
|
7796
7902
|
admin: publicKey,
|
|
7797
7903
|
multisig: this.multisig.publicKey,
|
|
7798
7904
|
perpetuals: this.perpetuals.publicKey,
|
|
@@ -7842,7 +7948,7 @@ var PerpetualsClient = (function () {
|
|
|
7842
7948
|
}
|
|
7843
7949
|
return [4, this.program.methods
|
|
7844
7950
|
.withdrawUnclaimedTokens({})
|
|
7845
|
-
.
|
|
7951
|
+
.accounts({
|
|
7846
7952
|
admin: publicKey,
|
|
7847
7953
|
multisig: this.multisig.publicKey,
|
|
7848
7954
|
perpetuals: this.perpetuals.publicKey,
|
|
@@ -7887,7 +7993,7 @@ var PerpetualsClient = (function () {
|
|
|
7887
7993
|
.initRevenueTokenAccount({
|
|
7888
7994
|
feeShareBps: feeShareBps
|
|
7889
7995
|
})
|
|
7890
|
-
.
|
|
7996
|
+
.accounts({
|
|
7891
7997
|
admin: publicKey,
|
|
7892
7998
|
multisig: this.multisig.publicKey,
|
|
7893
7999
|
perpetuals: this.perpetuals.publicKey,
|
|
@@ -7935,7 +8041,7 @@ var PerpetualsClient = (function () {
|
|
|
7935
8041
|
.initRebateVault({
|
|
7936
8042
|
allowRebatePayout: allowRebatePayout
|
|
7937
8043
|
})
|
|
7938
|
-
.
|
|
8044
|
+
.accounts({
|
|
7939
8045
|
admin: publicKey,
|
|
7940
8046
|
multisig: this.multisig.publicKey,
|
|
7941
8047
|
transferAuthority: poolConfig.transferAuthority,
|
|
@@ -7984,7 +8090,7 @@ var PerpetualsClient = (function () {
|
|
|
7984
8090
|
amount: amount,
|
|
7985
8091
|
epochCount: epochCount,
|
|
7986
8092
|
})
|
|
7987
|
-
.
|
|
8093
|
+
.accounts({
|
|
7988
8094
|
admin: publicKey,
|
|
7989
8095
|
multisig: this.multisig.publicKey,
|
|
7990
8096
|
perpetuals: this.perpetuals.publicKey,
|
|
@@ -7993,6 +8099,8 @@ var PerpetualsClient = (function () {
|
|
|
7993
8099
|
tokenVault: poolConfig.tokenVault,
|
|
7994
8100
|
tokenVaultTokenAccount: poolConfig.tokenVaultTokenAccount,
|
|
7995
8101
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
8102
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
8103
|
+
program: this.programId,
|
|
7996
8104
|
tokenMint: poolConfig.tokenMint,
|
|
7997
8105
|
})
|
|
7998
8106
|
.instruction()];
|
|
@@ -8011,7 +8119,7 @@ var PerpetualsClient = (function () {
|
|
|
8011
8119
|
}
|
|
8012
8120
|
});
|
|
8013
8121
|
}); };
|
|
8014
|
-
this.setTokenStakeLevel = function (owner, stakeLevel) { return __awaiter(_this, void 0, void 0, function () {
|
|
8122
|
+
this.setTokenStakeLevel = function (owner, stakeLevel, isInitialized) { return __awaiter(_this, void 0, void 0, function () {
|
|
8015
8123
|
var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenStakeLevelInstruction, err_63;
|
|
8016
8124
|
return __generator(this, function (_a) {
|
|
8017
8125
|
switch (_a.label) {
|
|
@@ -8028,8 +8136,9 @@ var PerpetualsClient = (function () {
|
|
|
8028
8136
|
return [4, this.program.methods
|
|
8029
8137
|
.setTokenStakeLevel({
|
|
8030
8138
|
level: stakeLevel,
|
|
8139
|
+
init: isInitialized,
|
|
8031
8140
|
})
|
|
8032
|
-
.
|
|
8141
|
+
.accounts({
|
|
8033
8142
|
admin: publicKey,
|
|
8034
8143
|
multisig: this.multisig.publicKey,
|
|
8035
8144
|
tokenStakeAccount: tokenStakeAccount,
|
|
@@ -8069,11 +8178,12 @@ var PerpetualsClient = (function () {
|
|
|
8069
8178
|
amount: amount,
|
|
8070
8179
|
epochCount: epochCount,
|
|
8071
8180
|
})
|
|
8072
|
-
.
|
|
8181
|
+
.accounts({
|
|
8073
8182
|
admin: publicKey,
|
|
8074
8183
|
multisig: this.multisig.publicKey,
|
|
8075
8184
|
tokenVault: poolConfig.tokenVault,
|
|
8076
8185
|
tokenStakeAccount: tokenStakeAccount,
|
|
8186
|
+
eventAuthority: this.eventAuthority.publicKey,
|
|
8077
8187
|
program: this.programId
|
|
8078
8188
|
})
|
|
8079
8189
|
.instruction()];
|
|
@@ -8109,7 +8219,7 @@ var PerpetualsClient = (function () {
|
|
|
8109
8219
|
.resizeInternalOracle({
|
|
8110
8220
|
extOracle: extOracle
|
|
8111
8221
|
})
|
|
8112
|
-
.
|
|
8222
|
+
.accounts({
|
|
8113
8223
|
admin: publicKey,
|
|
8114
8224
|
multisig: this.multisig.publicKey,
|
|
8115
8225
|
custodyTokenMint: tokenMint,
|
|
@@ -8153,7 +8263,7 @@ var PerpetualsClient = (function () {
|
|
|
8153
8263
|
isWithdrawalFeeExempt: isWithdrawalFeeExempt,
|
|
8154
8264
|
poolAddress: poolAddress,
|
|
8155
8265
|
})
|
|
8156
|
-
.
|
|
8266
|
+
.accounts({
|
|
8157
8267
|
admin: publicKey,
|
|
8158
8268
|
multisig: this.multisig.publicKey,
|
|
8159
8269
|
owner: owner,
|
|
@@ -8197,7 +8307,7 @@ var PerpetualsClient = (function () {
|
|
|
8197
8307
|
isWithdrawalFeeExempt: isWithdrawalFeeExempt,
|
|
8198
8308
|
poolAddress: poolAddress
|
|
8199
8309
|
})
|
|
8200
|
-
.
|
|
8310
|
+
.accounts({
|
|
8201
8311
|
admin: publicKey,
|
|
8202
8312
|
multisig: this.multisig.publicKey,
|
|
8203
8313
|
owner: owner,
|
|
@@ -8222,9 +8332,7 @@ var PerpetualsClient = (function () {
|
|
|
8222
8332
|
}); };
|
|
8223
8333
|
this.provider = provider;
|
|
8224
8334
|
(0, anchor_1.setProvider)(provider);
|
|
8225
|
-
this.program = new anchor_1.Program(
|
|
8226
|
-
connection: provider.connection,
|
|
8227
|
-
});
|
|
8335
|
+
this.program = new anchor_1.Program(perpetuals_1.IDL, programId);
|
|
8228
8336
|
this.programId = programId;
|
|
8229
8337
|
this.admin = this.provider.wallet.publicKey;
|
|
8230
8338
|
this.multisig = this.findProgramAddress("multisig");
|