flash-sdk 2.46.6 → 2.46.7

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.
@@ -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 = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
24
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), 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.");
@@ -2149,146 +2149,160 @@ var PerpetualsClient = (function () {
2149
2149
  }
2150
2150
  });
2151
2151
  }); };
2152
- this.getAddLiquidityAmountAndFeeView = function (amount, poolKey, depositCustodyKey, POOL_CONFIG) { return __awaiter(_this, void 0, void 0, function () {
2153
- var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _i, custodies_5, token, _a, custodies_6, custody, _b, _c, market, depositCustodyConfig, transaction, backUpOracleInstruction, result, index, res;
2154
- var _d;
2155
- return __generator(this, function (_e) {
2156
- switch (_e.label) {
2157
- case 0:
2158
- backUpOracleInstructionPromise = (0, backupOracle_1.createBackupOracleInstruction)(POOL_CONFIG.poolAddress.toBase58(), true);
2159
- custodies = POOL_CONFIG.custodies;
2160
- custodyMetas = [];
2161
- marketMetas = [];
2162
- for (_i = 0, custodies_5 = custodies; _i < custodies_5.length; _i++) {
2163
- token = custodies_5[_i];
2164
- custodyMetas.push({
2165
- isSigner: false,
2166
- isWritable: false,
2167
- pubkey: token.custodyAccount,
2168
- });
2169
- }
2170
- for (_a = 0, custodies_6 = custodies; _a < custodies_6.length; _a++) {
2171
- custody = custodies_6[_a];
2172
- custodyMetas.push({
2173
- isSigner: false,
2174
- isWritable: false,
2175
- pubkey: custody.intOracleAccount,
2176
- });
2177
- }
2178
- for (_b = 0, _c = POOL_CONFIG.markets; _b < _c.length; _b++) {
2179
- market = _c[_b];
2180
- marketMetas.push({
2181
- pubkey: market.marketAccount,
2182
- isSigner: false,
2183
- isWritable: false,
2184
- });
2185
- }
2186
- depositCustodyConfig = custodies.find(function (i) { return i.custodyAccount.equals(depositCustodyKey); });
2187
- return [4, this.program.methods
2188
- .getAddLiquidityAmountAndFee({
2189
- amountIn: amount,
2190
- })
2191
- .accounts({
2192
- perpetuals: POOL_CONFIG.perpetuals,
2193
- pool: poolKey,
2194
- custody: depositCustodyKey,
2195
- custodyOracleAccount: depositCustodyConfig.intOracleAccount,
2196
- lpTokenMint: POOL_CONFIG.stakedLpTokenMint,
2197
- ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
2198
- })
2199
- .remainingAccounts(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true))
2200
- .transaction()];
2201
- case 1:
2202
- transaction = _e.sent();
2203
- return [4, backUpOracleInstructionPromise];
2204
- case 2:
2205
- backUpOracleInstruction = _e.sent();
2206
- (_d = transaction.instructions).unshift.apply(_d, backUpOracleInstruction);
2207
- return [4, this.viewHelper.simulateTransaction(transaction)];
2208
- case 3:
2209
- result = _e.sent();
2210
- index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getAddLiquidityAmountAndFee'; });
2211
- res = this.viewHelper.decodeLogs(result, index, 'getAddLiquidityAmountAndFee');
2212
- return [2, {
2213
- amount: res.amount,
2214
- fee: res.fee,
2215
- }];
2216
- }
2152
+ this.getAddLiquidityAmountAndFeeView = function (amount_1, poolKey_1, depositCustodyKey_1, POOL_CONFIG_1) {
2153
+ var args_1 = [];
2154
+ for (var _i = 4; _i < arguments.length; _i++) {
2155
+ args_1[_i - 4] = arguments[_i];
2156
+ }
2157
+ 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) {
2158
+ var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _a, custodies_5, token, _b, custodies_6, custody, _c, _d, market, depositCustodyConfig, transaction, backUpOracleInstruction, result, index, res;
2159
+ var _e;
2160
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
2161
+ return __generator(this, function (_f) {
2162
+ switch (_f.label) {
2163
+ case 0:
2164
+ backUpOracleInstructionPromise = (0, backupOracle_1.createBackupOracleInstruction)(POOL_CONFIG.poolAddress.toBase58(), true);
2165
+ custodies = POOL_CONFIG.custodies;
2166
+ custodyMetas = [];
2167
+ marketMetas = [];
2168
+ for (_a = 0, custodies_5 = custodies; _a < custodies_5.length; _a++) {
2169
+ token = custodies_5[_a];
2170
+ custodyMetas.push({
2171
+ isSigner: false,
2172
+ isWritable: false,
2173
+ pubkey: token.custodyAccount,
2174
+ });
2175
+ }
2176
+ for (_b = 0, custodies_6 = custodies; _b < custodies_6.length; _b++) {
2177
+ custody = custodies_6[_b];
2178
+ custodyMetas.push({
2179
+ isSigner: false,
2180
+ isWritable: false,
2181
+ pubkey: custody.intOracleAccount,
2182
+ });
2183
+ }
2184
+ for (_c = 0, _d = POOL_CONFIG.markets; _c < _d.length; _c++) {
2185
+ market = _d[_c];
2186
+ marketMetas.push({
2187
+ pubkey: market.marketAccount,
2188
+ isSigner: false,
2189
+ isWritable: false,
2190
+ });
2191
+ }
2192
+ depositCustodyConfig = custodies.find(function (i) { return i.custodyAccount.equals(depositCustodyKey); });
2193
+ return [4, this.program.methods
2194
+ .getAddLiquidityAmountAndFee({
2195
+ amountIn: amount,
2196
+ })
2197
+ .accounts({
2198
+ perpetuals: POOL_CONFIG.perpetuals,
2199
+ pool: poolKey,
2200
+ custody: depositCustodyKey,
2201
+ custodyOracleAccount: depositCustodyConfig.intOracleAccount,
2202
+ lpTokenMint: POOL_CONFIG.stakedLpTokenMint,
2203
+ ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
2204
+ })
2205
+ .remainingAccounts(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true))
2206
+ .transaction()];
2207
+ case 1:
2208
+ transaction = _f.sent();
2209
+ return [4, backUpOracleInstructionPromise];
2210
+ case 2:
2211
+ backUpOracleInstruction = _f.sent();
2212
+ (_e = transaction.instructions).unshift.apply(_e, backUpOracleInstruction);
2213
+ return [4, this.viewHelper.simulateTransaction(transaction, userPublicKey)];
2214
+ case 3:
2215
+ result = _f.sent();
2216
+ index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getAddLiquidityAmountAndFee'; });
2217
+ res = this.viewHelper.decodeLogs(result, index, 'getAddLiquidityAmountAndFee');
2218
+ return [2, {
2219
+ amount: res.amount,
2220
+ fee: res.fee,
2221
+ }];
2222
+ }
2223
+ });
2217
2224
  });
2218
- }); };
2219
- this.getRemoveLiquidityAmountAndFeeView = function (amount, poolKey, removeTokenCustodyKey, POOL_CONFIG) { return __awaiter(_this, void 0, void 0, function () {
2220
- var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _i, custodies_7, token, _a, custodies_8, custody, _b, _c, market, removeCustodyConfig, transaction, backUpOracleInstruction, result, index, res;
2221
- var _d;
2222
- return __generator(this, function (_e) {
2223
- switch (_e.label) {
2224
- case 0:
2225
- backUpOracleInstructionPromise = (0, backupOracle_1.createBackupOracleInstruction)(POOL_CONFIG.poolAddress.toBase58(), true);
2226
- custodies = POOL_CONFIG.custodies;
2227
- custodyMetas = [];
2228
- marketMetas = [];
2229
- for (_i = 0, custodies_7 = custodies; _i < custodies_7.length; _i++) {
2230
- token = custodies_7[_i];
2231
- custodyMetas.push({
2232
- isSigner: false,
2233
- isWritable: false,
2234
- pubkey: token.custodyAccount,
2235
- });
2236
- }
2237
- for (_a = 0, custodies_8 = custodies; _a < custodies_8.length; _a++) {
2238
- custody = custodies_8[_a];
2239
- custodyMetas.push({
2240
- isSigner: false,
2241
- isWritable: false,
2242
- pubkey: custody.intOracleAccount,
2243
- });
2244
- }
2245
- for (_b = 0, _c = POOL_CONFIG.markets; _b < _c.length; _b++) {
2246
- market = _c[_b];
2247
- marketMetas.push({
2248
- pubkey: market.marketAccount,
2249
- isSigner: false,
2250
- isWritable: false,
2251
- });
2252
- }
2253
- removeCustodyConfig = custodies.find(function (i) { return i.custodyAccount.equals(removeTokenCustodyKey); });
2254
- return [4, this.program.methods
2255
- .getRemoveLiquidityAmountAndFee({
2256
- lpAmountIn: amount,
2257
- })
2258
- .accounts({
2259
- perpetuals: POOL_CONFIG.perpetuals,
2260
- pool: poolKey,
2261
- custody: removeTokenCustodyKey,
2262
- custodyOracleAccount: removeCustodyConfig.intOracleAccount,
2263
- lpTokenMint: POOL_CONFIG.stakedLpTokenMint,
2264
- ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
2265
- })
2266
- .remainingAccounts(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true))
2267
- .transaction()];
2268
- case 1:
2269
- transaction = _e.sent();
2270
- return [4, backUpOracleInstructionPromise];
2271
- case 2:
2272
- backUpOracleInstruction = _e.sent();
2273
- (_d = transaction.instructions).unshift.apply(_d, backUpOracleInstruction);
2274
- return [4, this.viewHelper.simulateTransaction(transaction)];
2275
- case 3:
2276
- result = _e.sent();
2277
- index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getRemoveLiquidityAmountAndFee'; });
2278
- if (result.value.err) {
2225
+ };
2226
+ this.getRemoveLiquidityAmountAndFeeView = function (amount_1, poolKey_1, removeTokenCustodyKey_1, POOL_CONFIG_1) {
2227
+ var args_1 = [];
2228
+ for (var _i = 4; _i < arguments.length; _i++) {
2229
+ args_1[_i - 4] = arguments[_i];
2230
+ }
2231
+ 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) {
2232
+ var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _a, custodies_7, token, _b, custodies_8, custody, _c, _d, market, removeCustodyConfig, transaction, backUpOracleInstruction, result, index, res;
2233
+ var _e;
2234
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
2235
+ return __generator(this, function (_f) {
2236
+ switch (_f.label) {
2237
+ case 0:
2238
+ backUpOracleInstructionPromise = (0, backupOracle_1.createBackupOracleInstruction)(POOL_CONFIG.poolAddress.toBase58(), true);
2239
+ custodies = POOL_CONFIG.custodies;
2240
+ custodyMetas = [];
2241
+ marketMetas = [];
2242
+ for (_a = 0, custodies_7 = custodies; _a < custodies_7.length; _a++) {
2243
+ token = custodies_7[_a];
2244
+ custodyMetas.push({
2245
+ isSigner: false,
2246
+ isWritable: false,
2247
+ pubkey: token.custodyAccount,
2248
+ });
2249
+ }
2250
+ for (_b = 0, custodies_8 = custodies; _b < custodies_8.length; _b++) {
2251
+ custody = custodies_8[_b];
2252
+ custodyMetas.push({
2253
+ isSigner: false,
2254
+ isWritable: false,
2255
+ pubkey: custody.intOracleAccount,
2256
+ });
2257
+ }
2258
+ for (_c = 0, _d = POOL_CONFIG.markets; _c < _d.length; _c++) {
2259
+ market = _d[_c];
2260
+ marketMetas.push({
2261
+ pubkey: market.marketAccount,
2262
+ isSigner: false,
2263
+ isWritable: false,
2264
+ });
2265
+ }
2266
+ removeCustodyConfig = custodies.find(function (i) { return i.custodyAccount.equals(removeTokenCustodyKey); });
2267
+ return [4, this.program.methods
2268
+ .getRemoveLiquidityAmountAndFee({
2269
+ lpAmountIn: amount,
2270
+ })
2271
+ .accounts({
2272
+ perpetuals: POOL_CONFIG.perpetuals,
2273
+ pool: poolKey,
2274
+ custody: removeTokenCustodyKey,
2275
+ custodyOracleAccount: removeCustodyConfig.intOracleAccount,
2276
+ lpTokenMint: POOL_CONFIG.stakedLpTokenMint,
2277
+ ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
2278
+ })
2279
+ .remainingAccounts(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true))
2280
+ .transaction()];
2281
+ case 1:
2282
+ transaction = _f.sent();
2283
+ return [4, backUpOracleInstructionPromise];
2284
+ case 2:
2285
+ backUpOracleInstruction = _f.sent();
2286
+ (_e = transaction.instructions).unshift.apply(_e, backUpOracleInstruction);
2287
+ return [4, this.viewHelper.simulateTransaction(transaction, userPublicKey)];
2288
+ case 3:
2289
+ result = _f.sent();
2290
+ index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getRemoveLiquidityAmountAndFee'; });
2291
+ if (result.value.err) {
2292
+ return [2, {
2293
+ amount: new anchor_1.BN(0),
2294
+ fee: new anchor_1.BN(0),
2295
+ }];
2296
+ }
2297
+ res = this.viewHelper.decodeLogs(result, index, 'getRemoveLiquidityAmountAndFee');
2279
2298
  return [2, {
2280
- amount: new anchor_1.BN(0),
2281
- fee: new anchor_1.BN(0),
2299
+ amount: res.amount,
2300
+ fee: res.fee,
2282
2301
  }];
2283
- }
2284
- res = this.viewHelper.decodeLogs(result, index, 'getRemoveLiquidityAmountAndFee');
2285
- return [2, {
2286
- amount: res.amount,
2287
- fee: res.fee,
2288
- }];
2289
- }
2302
+ }
2303
+ });
2290
2304
  });
2291
- }); };
2305
+ };
2292
2306
  this.getCompoundingLPTokenPrice = function (poolKey, POOL_CONFIG) { return __awaiter(_this, void 0, void 0, function () {
2293
2307
  var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _i, custodies_9, token, _a, custodies_10, custody, _b, _c, market, backUpOracleInstruction, transaction, result, index, res;
2294
2308
  var _d;
@@ -2348,154 +2362,168 @@ var PerpetualsClient = (function () {
2348
2362
  }
2349
2363
  });
2350
2364
  }); };
2351
- this.getAddCompoundingLiquidityAmountAndFeeView = function (amount, poolKey, depositCustodyKey, POOL_CONFIG) { return __awaiter(_this, void 0, void 0, function () {
2352
- var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _i, custodies_11, token, _a, custodies_12, custody, _b, _c, market, depositCustodyConfig, rewardCustody, backUpOracleInstruction, transaction, result, index, res;
2353
- var _d;
2354
- return __generator(this, function (_e) {
2355
- switch (_e.label) {
2356
- case 0:
2357
- backUpOracleInstructionPromise = (0, backupOracle_1.createBackupOracleInstruction)(POOL_CONFIG.poolAddress.toBase58(), true);
2358
- custodies = POOL_CONFIG.custodies;
2359
- custodyMetas = [];
2360
- marketMetas = [];
2361
- for (_i = 0, custodies_11 = custodies; _i < custodies_11.length; _i++) {
2362
- token = custodies_11[_i];
2363
- custodyMetas.push({
2364
- isSigner: false,
2365
- isWritable: false,
2366
- pubkey: token.custodyAccount,
2367
- });
2368
- }
2369
- for (_a = 0, custodies_12 = custodies; _a < custodies_12.length; _a++) {
2370
- custody = custodies_12[_a];
2371
- custodyMetas.push({
2372
- isSigner: false,
2373
- isWritable: false,
2374
- pubkey: custody.intOracleAccount,
2375
- });
2376
- }
2377
- for (_b = 0, _c = POOL_CONFIG.markets; _b < _c.length; _b++) {
2378
- market = _c[_b];
2379
- marketMetas.push({
2380
- pubkey: market.marketAccount,
2381
- isSigner: false,
2382
- isWritable: false,
2383
- });
2384
- }
2385
- depositCustodyConfig = custodies.find(function (i) { return i.custodyAccount.equals(depositCustodyKey); });
2386
- rewardCustody = POOL_CONFIG.custodies.find(function (f) { return f.symbol == 'USDC'; });
2387
- return [4, backUpOracleInstructionPromise];
2388
- case 1:
2389
- backUpOracleInstruction = _e.sent();
2390
- return [4, this.program.methods
2391
- .getAddCompoundingLiquidityAmountAndFee({
2392
- amountIn: amount,
2393
- })
2394
- .accounts({
2395
- perpetuals: POOL_CONFIG.perpetuals,
2396
- pool: poolKey,
2397
- inCustody: depositCustodyKey,
2398
- inCustodyOracleAccount: depositCustodyConfig.intOracleAccount,
2399
- rewardCustody: rewardCustody.custodyAccount,
2400
- rewardCustodyOracleAccount: rewardCustody.intOracleAccount,
2401
- lpTokenMint: POOL_CONFIG.stakedLpTokenMint,
2402
- compoundingTokenMint: POOL_CONFIG.compoundingTokenMint,
2403
- ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
2404
- })
2405
- .remainingAccounts(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true))
2406
- .transaction()];
2407
- case 2:
2408
- transaction = _e.sent();
2409
- (_d = transaction.instructions).unshift.apply(_d, backUpOracleInstruction);
2410
- return [4, this.viewHelper.simulateTransaction(transaction)];
2411
- case 3:
2412
- result = _e.sent();
2413
- index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getAddCompoundingLiquidityAmountAndFee'; });
2414
- res = this.viewHelper.decodeLogs(result, index, 'getAddCompoundingLiquidityAmountAndFee');
2415
- return [2, {
2416
- amount: res.amount,
2417
- fee: res.fee,
2418
- }];
2419
- }
2365
+ this.getAddCompoundingLiquidityAmountAndFeeView = function (amount_1, poolKey_1, depositCustodyKey_1, POOL_CONFIG_1) {
2366
+ var args_1 = [];
2367
+ for (var _i = 4; _i < arguments.length; _i++) {
2368
+ args_1[_i - 4] = arguments[_i];
2369
+ }
2370
+ 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) {
2371
+ var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _a, custodies_11, token, _b, custodies_12, custody, _c, _d, market, depositCustodyConfig, rewardCustody, backUpOracleInstruction, transaction, result, index, res;
2372
+ var _e;
2373
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
2374
+ return __generator(this, function (_f) {
2375
+ switch (_f.label) {
2376
+ case 0:
2377
+ backUpOracleInstructionPromise = (0, backupOracle_1.createBackupOracleInstruction)(POOL_CONFIG.poolAddress.toBase58(), true);
2378
+ custodies = POOL_CONFIG.custodies;
2379
+ custodyMetas = [];
2380
+ marketMetas = [];
2381
+ for (_a = 0, custodies_11 = custodies; _a < custodies_11.length; _a++) {
2382
+ token = custodies_11[_a];
2383
+ custodyMetas.push({
2384
+ isSigner: false,
2385
+ isWritable: false,
2386
+ pubkey: token.custodyAccount,
2387
+ });
2388
+ }
2389
+ for (_b = 0, custodies_12 = custodies; _b < custodies_12.length; _b++) {
2390
+ custody = custodies_12[_b];
2391
+ custodyMetas.push({
2392
+ isSigner: false,
2393
+ isWritable: false,
2394
+ pubkey: custody.intOracleAccount,
2395
+ });
2396
+ }
2397
+ for (_c = 0, _d = POOL_CONFIG.markets; _c < _d.length; _c++) {
2398
+ market = _d[_c];
2399
+ marketMetas.push({
2400
+ pubkey: market.marketAccount,
2401
+ isSigner: false,
2402
+ isWritable: false,
2403
+ });
2404
+ }
2405
+ depositCustodyConfig = custodies.find(function (i) { return i.custodyAccount.equals(depositCustodyKey); });
2406
+ rewardCustody = POOL_CONFIG.custodies.find(function (f) { return f.symbol == 'USDC'; });
2407
+ return [4, backUpOracleInstructionPromise];
2408
+ case 1:
2409
+ backUpOracleInstruction = _f.sent();
2410
+ return [4, this.program.methods
2411
+ .getAddCompoundingLiquidityAmountAndFee({
2412
+ amountIn: amount,
2413
+ })
2414
+ .accounts({
2415
+ perpetuals: POOL_CONFIG.perpetuals,
2416
+ pool: poolKey,
2417
+ inCustody: depositCustodyKey,
2418
+ inCustodyOracleAccount: depositCustodyConfig.intOracleAccount,
2419
+ rewardCustody: rewardCustody.custodyAccount,
2420
+ rewardCustodyOracleAccount: rewardCustody.intOracleAccount,
2421
+ lpTokenMint: POOL_CONFIG.stakedLpTokenMint,
2422
+ compoundingTokenMint: POOL_CONFIG.compoundingTokenMint,
2423
+ ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
2424
+ })
2425
+ .remainingAccounts(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true))
2426
+ .transaction()];
2427
+ case 2:
2428
+ transaction = _f.sent();
2429
+ (_e = transaction.instructions).unshift.apply(_e, backUpOracleInstruction);
2430
+ return [4, this.viewHelper.simulateTransaction(transaction, userPublicKey)];
2431
+ case 3:
2432
+ result = _f.sent();
2433
+ index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getAddCompoundingLiquidityAmountAndFee'; });
2434
+ res = this.viewHelper.decodeLogs(result, index, 'getAddCompoundingLiquidityAmountAndFee');
2435
+ return [2, {
2436
+ amount: res.amount,
2437
+ fee: res.fee,
2438
+ }];
2439
+ }
2440
+ });
2420
2441
  });
2421
- }); };
2422
- this.getRemoveCompoundingLiquidityAmountAndFeeView = function (amount, poolKey, removeTokenCustodyKey, POOL_CONFIG) { return __awaiter(_this, void 0, void 0, function () {
2423
- var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _i, custodies_13, token, _a, custodies_14, custody, _b, _c, market, removeCustodyConfig, rewardCustody, backUpOracleInstruction, transaction, result, index, res;
2424
- var _d;
2425
- return __generator(this, function (_e) {
2426
- switch (_e.label) {
2427
- case 0:
2428
- backUpOracleInstructionPromise = (0, backupOracle_1.createBackupOracleInstruction)(POOL_CONFIG.poolAddress.toBase58(), true);
2429
- custodies = POOL_CONFIG.custodies;
2430
- custodyMetas = [];
2431
- marketMetas = [];
2432
- for (_i = 0, custodies_13 = custodies; _i < custodies_13.length; _i++) {
2433
- token = custodies_13[_i];
2434
- custodyMetas.push({
2435
- isSigner: false,
2436
- isWritable: false,
2437
- pubkey: token.custodyAccount,
2438
- });
2439
- }
2440
- for (_a = 0, custodies_14 = custodies; _a < custodies_14.length; _a++) {
2441
- custody = custodies_14[_a];
2442
- custodyMetas.push({
2443
- isSigner: false,
2444
- isWritable: false,
2445
- pubkey: custody.intOracleAccount,
2446
- });
2447
- }
2448
- for (_b = 0, _c = POOL_CONFIG.markets; _b < _c.length; _b++) {
2449
- market = _c[_b];
2450
- marketMetas.push({
2451
- pubkey: market.marketAccount,
2452
- isSigner: false,
2453
- isWritable: false,
2454
- });
2455
- }
2456
- removeCustodyConfig = custodies.find(function (i) { return i.custodyAccount.equals(removeTokenCustodyKey); });
2457
- rewardCustody = POOL_CONFIG.custodies.find(function (f) { return f.symbol == 'USDC'; });
2458
- return [4, backUpOracleInstructionPromise];
2459
- case 1:
2460
- backUpOracleInstruction = _e.sent();
2461
- return [4, this.program.methods
2462
- .getRemoveCompoundingLiquidityAmountAndFee({
2463
- compoundingAmountIn: amount,
2464
- })
2465
- .accounts({
2466
- perpetuals: POOL_CONFIG.perpetuals,
2467
- pool: poolKey,
2468
- outCustody: removeTokenCustodyKey,
2469
- outCustodyOracleAccount: removeCustodyConfig.intOracleAccount,
2470
- rewardCustody: rewardCustody.custodyAccount,
2471
- rewardCustodyOracleAccount: rewardCustody.intOracleAccount,
2472
- compoundingTokenMint: POOL_CONFIG.compoundingTokenMint,
2473
- lpTokenMint: POOL_CONFIG.stakedLpTokenMint,
2474
- ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
2475
- })
2476
- .remainingAccounts(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true))
2477
- .transaction()];
2478
- case 2:
2479
- transaction = _e.sent();
2480
- (_d = transaction.instructions).unshift.apply(_d, backUpOracleInstruction);
2481
- return [4, this.viewHelper.simulateTransaction(transaction)];
2482
- case 3:
2483
- result = _e.sent();
2484
- index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getRemoveCompoundingLiquidityAmountAndFee'; });
2485
- if (result.value.err) {
2442
+ };
2443
+ this.getRemoveCompoundingLiquidityAmountAndFeeView = function (amount_1, poolKey_1, removeTokenCustodyKey_1, POOL_CONFIG_1) {
2444
+ var args_1 = [];
2445
+ for (var _i = 4; _i < arguments.length; _i++) {
2446
+ args_1[_i - 4] = arguments[_i];
2447
+ }
2448
+ 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) {
2449
+ var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _a, custodies_13, token, _b, custodies_14, custody, _c, _d, market, removeCustodyConfig, rewardCustody, backUpOracleInstruction, transaction, result, index, res;
2450
+ var _e;
2451
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
2452
+ return __generator(this, function (_f) {
2453
+ switch (_f.label) {
2454
+ case 0:
2455
+ backUpOracleInstructionPromise = (0, backupOracle_1.createBackupOracleInstruction)(POOL_CONFIG.poolAddress.toBase58(), true);
2456
+ custodies = POOL_CONFIG.custodies;
2457
+ custodyMetas = [];
2458
+ marketMetas = [];
2459
+ for (_a = 0, custodies_13 = custodies; _a < custodies_13.length; _a++) {
2460
+ token = custodies_13[_a];
2461
+ custodyMetas.push({
2462
+ isSigner: false,
2463
+ isWritable: false,
2464
+ pubkey: token.custodyAccount,
2465
+ });
2466
+ }
2467
+ for (_b = 0, custodies_14 = custodies; _b < custodies_14.length; _b++) {
2468
+ custody = custodies_14[_b];
2469
+ custodyMetas.push({
2470
+ isSigner: false,
2471
+ isWritable: false,
2472
+ pubkey: custody.intOracleAccount,
2473
+ });
2474
+ }
2475
+ for (_c = 0, _d = POOL_CONFIG.markets; _c < _d.length; _c++) {
2476
+ market = _d[_c];
2477
+ marketMetas.push({
2478
+ pubkey: market.marketAccount,
2479
+ isSigner: false,
2480
+ isWritable: false,
2481
+ });
2482
+ }
2483
+ removeCustodyConfig = custodies.find(function (i) { return i.custodyAccount.equals(removeTokenCustodyKey); });
2484
+ rewardCustody = POOL_CONFIG.custodies.find(function (f) { return f.symbol == 'USDC'; });
2485
+ return [4, backUpOracleInstructionPromise];
2486
+ case 1:
2487
+ backUpOracleInstruction = _f.sent();
2488
+ return [4, this.program.methods
2489
+ .getRemoveCompoundingLiquidityAmountAndFee({
2490
+ compoundingAmountIn: amount,
2491
+ })
2492
+ .accounts({
2493
+ perpetuals: POOL_CONFIG.perpetuals,
2494
+ pool: poolKey,
2495
+ outCustody: removeTokenCustodyKey,
2496
+ outCustodyOracleAccount: removeCustodyConfig.intOracleAccount,
2497
+ rewardCustody: rewardCustody.custodyAccount,
2498
+ rewardCustodyOracleAccount: rewardCustody.intOracleAccount,
2499
+ compoundingTokenMint: POOL_CONFIG.compoundingTokenMint,
2500
+ lpTokenMint: POOL_CONFIG.stakedLpTokenMint,
2501
+ ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
2502
+ })
2503
+ .remainingAccounts(__spreadArray(__spreadArray([], custodyMetas, true), marketMetas, true))
2504
+ .transaction()];
2505
+ case 2:
2506
+ transaction = _f.sent();
2507
+ (_e = transaction.instructions).unshift.apply(_e, backUpOracleInstruction);
2508
+ return [4, this.viewHelper.simulateTransaction(transaction, userPublicKey)];
2509
+ case 3:
2510
+ result = _f.sent();
2511
+ index = perpetuals_1.IDL.instructions.findIndex(function (f) { return f.name === 'getRemoveCompoundingLiquidityAmountAndFee'; });
2512
+ if (result.value.err) {
2513
+ return [2, {
2514
+ amount: new anchor_1.BN(0),
2515
+ fee: new anchor_1.BN(0),
2516
+ }];
2517
+ }
2518
+ res = this.viewHelper.decodeLogs(result, index, 'getRemoveCompoundingLiquidityAmountAndFee');
2486
2519
  return [2, {
2487
- amount: new anchor_1.BN(0),
2488
- fee: new anchor_1.BN(0),
2520
+ amount: res.amount,
2521
+ fee: res.fee,
2489
2522
  }];
2490
- }
2491
- res = this.viewHelper.decodeLogs(result, index, 'getRemoveCompoundingLiquidityAmountAndFee');
2492
- return [2, {
2493
- amount: res.amount,
2494
- fee: res.fee,
2495
- }];
2496
- }
2523
+ }
2524
+ });
2497
2525
  });
2498
- }); };
2526
+ };
2499
2527
  this.getLiquidationStateView = function (positionAccount, poolName, tokenMint, collateralMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
2500
2528
  var targetCustodyConfig, collateralCustodyConfig;
2501
2529
  return __generator(this, function (_a) {
@@ -4111,14 +4139,15 @@ var PerpetualsClient = (function () {
4111
4139
  for (var _i = 4; _i < arguments.length; _i++) {
4112
4140
  args_1[_i - 4] = arguments[_i];
4113
4141
  }
4114
- return __awaiter(_this, __spreadArray([inputSymbol_1, amountIn_1, minLpAmountOut_1, poolConfig_1], args_1, true), void 0, function (inputSymbol, amountIn, minLpAmountOut, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
4142
+ 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) {
4115
4143
  var publicKey, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userInputTokenAccount, lpTokenMint, inputCustodyConfig, lpTokenAccount, flpStakeAccount, poolStakedLpVault, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, custodyAccountMetas, custodyOracleAccountMetas, markets, _c, _d, custody, _e, _f, market, instruction;
4116
4144
  if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
4117
4145
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
4146
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
4118
4147
  return __generator(this, function (_g) {
4119
4148
  switch (_g.label) {
4120
4149
  case 0:
4121
- publicKey = this.provider.wallet.publicKey;
4150
+ publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
4122
4151
  preInstructions = [];
4123
4152
  instructions = [];
4124
4153
  postInstructions = [];
@@ -4245,12 +4274,13 @@ var PerpetualsClient = (function () {
4245
4274
  for (var _i = 4; _i < arguments.length; _i++) {
4246
4275
  args_1[_i - 4] = arguments[_i];
4247
4276
  }
4248
- 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) {
4277
+ 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) {
4249
4278
  var recieveTokenCustodyConfig, publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, stakedLpTokenAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _a, _b, custody, _c, _d, market, lamports, _e, removeLiquidityTx, closeInx, closeWsolATAIns, err_7;
4250
4279
  if (closeLpATA === void 0) { closeLpATA = false; }
4251
4280
  if (createUserATA === void 0) { createUserATA = true; }
4252
4281
  if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
4253
4282
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
4283
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
4254
4284
  return __generator(this, function (_f) {
4255
4285
  switch (_f.label) {
4256
4286
  case 0:
@@ -4258,7 +4288,7 @@ var PerpetualsClient = (function () {
4258
4288
  if (!recieveTokenCustodyConfig) {
4259
4289
  throw "recieveTokenCustody not found";
4260
4290
  }
4261
- publicKey = this.provider.wallet.publicKey;
4291
+ publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
4262
4292
  preInstructions = [];
4263
4293
  instructions = [];
4264
4294
  postInstructions = [];
@@ -4778,61 +4808,68 @@ var PerpetualsClient = (function () {
4778
4808
  }
4779
4809
  });
4780
4810
  }); };
4781
- this.refreshStakeWithTokenStake = function (rewardSymbol, poolConfig, flpStakeAccountPk) { return __awaiter(_this, void 0, void 0, function () {
4782
- var publicKey, rewardCustodyMint, rewardCustodyConfig, pool, feeDistributionTokenAccount, custodyAccountMetas, _i, _a, custody, stakeAccountMetas, tokenStakeAccount, refreshStakeInstruction, err_16;
4783
- return __generator(this, function (_b) {
4784
- switch (_b.label) {
4785
- case 0:
4786
- _b.trys.push([0, 2, , 3]);
4787
- publicKey = this.provider.wallet.publicKey;
4788
- rewardCustodyMint = poolConfig.getTokenFromSymbol(rewardSymbol).mintKey;
4789
- rewardCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(rewardSymbol).mintKey); });
4790
- pool = poolConfig.poolAddress;
4791
- feeDistributionTokenAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("custody_token_account"), pool.toBuffer(), rewardCustodyMint.toBuffer()], this.programId)[0];
4792
- custodyAccountMetas = [];
4793
- for (_i = 0, _a = poolConfig.custodies; _i < _a.length; _i++) {
4794
- custody = _a[_i];
4795
- custodyAccountMetas.push({
4796
- pubkey: custody.custodyAccount,
4811
+ this.refreshStakeWithTokenStake = function (rewardSymbol_1, poolConfig_1, flpStakeAccountPk_1) {
4812
+ var args_1 = [];
4813
+ for (var _i = 3; _i < arguments.length; _i++) {
4814
+ args_1[_i - 3] = arguments[_i];
4815
+ }
4816
+ return __awaiter(_this, __spreadArray([rewardSymbol_1, poolConfig_1, flpStakeAccountPk_1], args_1, true), void 0, function (rewardSymbol, poolConfig, flpStakeAccountPk, userPublicKey) {
4817
+ var publicKey, rewardCustodyMint, rewardCustodyConfig, pool, feeDistributionTokenAccount, custodyAccountMetas, _a, _b, custody, stakeAccountMetas, tokenStakeAccount, refreshStakeInstruction, err_16;
4818
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
4819
+ return __generator(this, function (_c) {
4820
+ switch (_c.label) {
4821
+ case 0:
4822
+ _c.trys.push([0, 2, , 3]);
4823
+ publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
4824
+ rewardCustodyMint = poolConfig.getTokenFromSymbol(rewardSymbol).mintKey;
4825
+ rewardCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(rewardSymbol).mintKey); });
4826
+ pool = poolConfig.poolAddress;
4827
+ feeDistributionTokenAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("custody_token_account"), pool.toBuffer(), rewardCustodyMint.toBuffer()], this.programId)[0];
4828
+ custodyAccountMetas = [];
4829
+ for (_a = 0, _b = poolConfig.custodies; _a < _b.length; _a++) {
4830
+ custody = _b[_a];
4831
+ custodyAccountMetas.push({
4832
+ pubkey: custody.custodyAccount,
4833
+ isSigner: false,
4834
+ isWritable: false,
4835
+ });
4836
+ }
4837
+ stakeAccountMetas = [];
4838
+ stakeAccountMetas.push({
4839
+ pubkey: flpStakeAccountPk,
4840
+ isSigner: false,
4841
+ isWritable: true,
4842
+ });
4843
+ tokenStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("token_stake"), publicKey.toBuffer()], this.programId)[0];
4844
+ stakeAccountMetas.push({
4845
+ pubkey: tokenStakeAccount,
4797
4846
  isSigner: false,
4798
4847
  isWritable: false,
4799
4848
  });
4800
- }
4801
- stakeAccountMetas = [];
4802
- stakeAccountMetas.push({
4803
- pubkey: flpStakeAccountPk,
4804
- isSigner: false,
4805
- isWritable: true,
4806
- });
4807
- tokenStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("token_stake"), publicKey.toBuffer()], this.programId)[0];
4808
- stakeAccountMetas.push({
4809
- pubkey: tokenStakeAccount,
4810
- isSigner: false,
4811
- isWritable: false,
4812
- });
4813
- return [4, this.program.methods
4814
- .refreshStake({})
4815
- .accounts({
4816
- perpetuals: this.perpetuals.publicKey,
4817
- pool: pool,
4818
- rewardCustody: rewardCustodyConfig.custodyAccount,
4819
- feeDistributionTokenAccount: feeDistributionTokenAccount,
4820
- eventAuthority: this.eventAuthority.publicKey,
4821
- program: this.program.programId,
4822
- })
4823
- .remainingAccounts(__spreadArray(__spreadArray([], custodyAccountMetas, true), stakeAccountMetas, true))
4824
- .instruction()];
4825
- case 1:
4826
- refreshStakeInstruction = _b.sent();
4827
- return [2, refreshStakeInstruction];
4828
- case 2:
4829
- err_16 = _b.sent();
4830
- console.log("perpClient refreshStaking error:: ", err_16);
4831
- throw err_16;
4832
- case 3: return [2];
4833
- }
4849
+ return [4, this.program.methods
4850
+ .refreshStake({})
4851
+ .accounts({
4852
+ perpetuals: this.perpetuals.publicKey,
4853
+ pool: pool,
4854
+ rewardCustody: rewardCustodyConfig.custodyAccount,
4855
+ feeDistributionTokenAccount: feeDistributionTokenAccount,
4856
+ eventAuthority: this.eventAuthority.publicKey,
4857
+ program: this.program.programId,
4858
+ })
4859
+ .remainingAccounts(__spreadArray(__spreadArray([], custodyAccountMetas, true), stakeAccountMetas, true))
4860
+ .instruction()];
4861
+ case 1:
4862
+ refreshStakeInstruction = _c.sent();
4863
+ return [2, refreshStakeInstruction];
4864
+ case 2:
4865
+ err_16 = _c.sent();
4866
+ console.log("perpClient refreshStaking error:: ", err_16);
4867
+ throw err_16;
4868
+ case 3: return [2];
4869
+ }
4870
+ });
4834
4871
  });
4835
- }); };
4872
+ };
4836
4873
  this.unstakeInstant = function (rewardSymbol, unstakeAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
4837
4874
  var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyConfig, pool, flpStakeAccount, tokenStakeAccount, tokenStakeAccounts, _a, unstakeInstantInstruction, err_17;
4838
4875
  return __generator(this, function (_b) {
@@ -7276,14 +7313,15 @@ var PerpetualsClient = (function () {
7276
7313
  for (var _i = 5; _i < arguments.length; _i++) {
7277
7314
  args_1[_i - 5] = arguments[_i];
7278
7315
  }
7279
- 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) {
7316
+ 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) {
7280
7317
  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, addCompoundingLiquidity, err_58;
7281
7318
  if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
7282
7319
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
7320
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
7283
7321
  return __generator(this, function (_f) {
7284
7322
  switch (_f.label) {
7285
7323
  case 0:
7286
- publicKey = this.provider.wallet.publicKey;
7324
+ publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
7287
7325
  preInstructions = [];
7288
7326
  instructions = [];
7289
7327
  additionalSigners = [];
@@ -7418,14 +7456,15 @@ var PerpetualsClient = (function () {
7418
7456
  for (var _i = 5; _i < arguments.length; _i++) {
7419
7457
  args_1[_i - 5] = arguments[_i];
7420
7458
  }
7421
- 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) {
7459
+ 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) {
7422
7460
  var publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, outCustodyConfig, lpTokenMint, compoundingTokenMint, lamports, _a, custodyAccountMetas, custodyOracleAccountMetas, markets, _b, _c, custody, _d, _e, market, compoundingTokenAccount, removeCompoundingLiquidity, err_59;
7423
7461
  if (createUserATA === void 0) { createUserATA = true; }
7424
7462
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
7463
+ if (userPublicKey === void 0) { userPublicKey = undefined; }
7425
7464
  return __generator(this, function (_f) {
7426
7465
  switch (_f.label) {
7427
7466
  case 0:
7428
- publicKey = this.provider.wallet.publicKey;
7467
+ publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
7429
7468
  preInstructions = [];
7430
7469
  instructions = [];
7431
7470
  postInstructions = [];