@kamino-finance/klend-sdk 2.12.0-SNAPSHOT.3 → 2.12.0
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/classes/action.js +80 -79
- package/dist/classes/action.js.map +1 -1
- package/dist/classes/fraction.js.map +1 -1
- package/dist/classes/jupiterPerps.js.map +1 -1
- package/dist/classes/market.js +9 -10
- package/dist/classes/market.js.map +1 -1
- package/dist/classes/obligation.js.map +1 -1
- package/dist/classes/reserve.js.map +1 -1
- package/dist/classes/shared.js +1 -1
- package/dist/classes/shared.js.map +1 -1
- package/dist/classes/utils.js.map +1 -1
- package/dist/idl_codegen/accounts/LendingMarket.js +4 -4
- package/dist/idl_codegen/accounts/LendingMarket.js.map +1 -1
- package/dist/idl_codegen/accounts/Obligation.js +4 -4
- package/dist/idl_codegen/accounts/Obligation.js.map +1 -1
- package/dist/idl_codegen/accounts/ReferrerState.js +4 -4
- package/dist/idl_codegen/accounts/ReferrerState.js.map +1 -1
- package/dist/idl_codegen/accounts/ReferrerTokenState.js +4 -4
- package/dist/idl_codegen/accounts/ReferrerTokenState.js.map +1 -1
- package/dist/idl_codegen/accounts/Reserve.js +4 -4
- package/dist/idl_codegen/accounts/Reserve.js.map +1 -1
- package/dist/idl_codegen/accounts/ShortUrl.js +4 -4
- package/dist/idl_codegen/accounts/ShortUrl.js.map +1 -1
- package/dist/idl_codegen/accounts/UserMetadata.js +4 -4
- package/dist/idl_codegen/accounts/UserMetadata.js.map +1 -1
- package/dist/idl_codegen/accounts/UserState.js +4 -4
- package/dist/idl_codegen/accounts/UserState.js.map +1 -1
- package/dist/idl_codegen/errors/anchor.js.map +1 -1
- package/dist/idl_codegen/errors/custom.js.map +1 -1
- package/dist/idl_codegen/errors/index.js.map +1 -1
- package/dist/idl_codegen/types/AssetTier.js.map +1 -1
- package/dist/idl_codegen/types/FeeCalculation.js.map +1 -1
- package/dist/idl_codegen/types/ReserveFarmKind.js.map +1 -1
- package/dist/idl_codegen/types/ReserveStatus.js.map +1 -1
- package/dist/idl_codegen/types/UpdateConfigMode.js.map +1 -1
- package/dist/idl_codegen/types/UpdateLendingMarketConfigValue.js.map +1 -1
- package/dist/idl_codegen/types/UpdateLendingMarketMode.js.map +1 -1
- package/dist/idl_codegen/zero_padding/ObligationZP.js +4 -4
- package/dist/idl_codegen/zero_padding/ObligationZP.js.map +1 -1
- package/dist/idl_codegen_jupiter_perps/accounts/Pool.js +4 -4
- package/dist/idl_codegen_jupiter_perps/accounts/Pool.js.map +1 -1
- package/dist/lending_operations/repay_with_collateral_calcs.js.map +1 -1
- package/dist/lending_operations/repay_with_collateral_operations.js.map +1 -1
- package/dist/leverage/calcs.js +3 -3
- package/dist/leverage/calcs.js.map +1 -1
- package/dist/leverage/operations.js +6 -5
- package/dist/leverage/operations.js.map +1 -1
- package/dist/leverage/utils.js +3 -3
- package/dist/leverage/utils.js.map +1 -1
- package/dist/referrals/instructions.js +2 -2
- package/dist/referrals/instructions.js.map +1 -1
- package/dist/referrals/operations.d.ts +2 -2
- package/dist/referrals/operations.js +15 -15
- package/dist/referrals/operations.js.map +1 -1
- package/dist/utils/ObligationType.js +1 -1
- package/dist/utils/ObligationType.js.map +1 -1
- package/dist/utils/api.js +2 -2
- package/dist/utils/api.js.map +1 -1
- package/dist/utils/ata.js +19 -3
- package/dist/utils/ata.js.map +1 -1
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/instruction.d.ts +1 -0
- package/dist/utils/instruction.js +13 -13
- package/dist/utils/instruction.js.map +1 -1
- package/dist/utils/kamino.js +24 -2
- package/dist/utils/kamino.js.map +1 -1
- package/dist/utils/layout.js.map +1 -1
- package/dist/utils/lookupTable.js.map +1 -1
- package/dist/utils/oracle.js.map +1 -1
- package/dist/utils/pubkey.js.map +1 -1
- package/dist/utils/rpc.js.map +1 -1
- package/dist/utils/seeds.js.map +1 -1
- package/dist/utils/token.d.ts +2 -0
- package/dist/utils/token.js +20 -0
- package/dist/utils/token.js.map +1 -0
- package/dist/utils/userMetadata.js +3 -3
- package/dist/utils/userMetadata.js.map +1 -1
- package/package.json +5 -5
package/dist/classes/action.js
CHANGED
|
@@ -24,6 +24,7 @@ const types_1 = require("../idl_codegen/types");
|
|
|
24
24
|
const farms_sdk_1 = require("@hubbleprotocol/farms-sdk");
|
|
25
25
|
const ObligationType_1 = require("../utils/ObligationType");
|
|
26
26
|
const lib_1 = require("../lib");
|
|
27
|
+
const token_1 = require("../utils/token");
|
|
27
28
|
exports.POSITION_LIMIT = 10;
|
|
28
29
|
exports.BORROWS_LIMIT = 5;
|
|
29
30
|
exports.DEPOSITS_LIMIT = 8;
|
|
@@ -76,8 +77,8 @@ class KaminoAction {
|
|
|
76
77
|
this.referrer = referrer ? referrer : web3_js_1.PublicKey.default;
|
|
77
78
|
this.currentSlot = currentSlot;
|
|
78
79
|
}
|
|
79
|
-
static initialize(
|
|
80
|
-
return __awaiter(this,
|
|
80
|
+
static initialize(action, amount, mint, owner, kaminoMarket, obligation, referrer = web3_js_1.PublicKey.default, currentSlot = 0, hostAta, payer) {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
81
82
|
const reserve = kaminoMarket.getReserveByMint(mint);
|
|
82
83
|
if (reserve === undefined) {
|
|
83
84
|
throw new Error(`Reserve ${mint} not found in market ${kaminoMarket.getAddress().toBase58()}`);
|
|
@@ -142,9 +143,9 @@ class KaminoAction {
|
|
|
142
143
|
};
|
|
143
144
|
});
|
|
144
145
|
}
|
|
145
|
-
static buildRefreshObligationTxns(
|
|
146
|
-
|
|
147
|
-
|
|
146
|
+
static buildRefreshObligationTxns(kaminoMarket, payer, obligation, extraComputeBudget = 1000000, // if > 0 then adds the ixn
|
|
147
|
+
currentSlot = 0) {
|
|
148
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
148
149
|
// placeholder for action initialization
|
|
149
150
|
const firstReserve = obligation.state.deposits[0].depositReserve;
|
|
150
151
|
const firstKaminoReserve = kaminoMarket.getReserveByAddress(firstReserve);
|
|
@@ -159,9 +160,9 @@ class KaminoAction {
|
|
|
159
160
|
return axn;
|
|
160
161
|
});
|
|
161
162
|
}
|
|
162
|
-
static buildRequestElevationGroupTxns(
|
|
163
|
-
|
|
164
|
-
|
|
163
|
+
static buildRequestElevationGroupTxns(kaminoMarket, payer, obligation, elevationGroup, extraComputeBudget = 1000000, // if > 0 then adds the ixn
|
|
164
|
+
currentSlot = 0) {
|
|
165
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
165
166
|
const firstReserve = obligation.state.deposits[0].depositReserve;
|
|
166
167
|
const firstKaminoReserve = kaminoMarket.getReserveByAddress(firstReserve);
|
|
167
168
|
if (!firstKaminoReserve) {
|
|
@@ -176,11 +177,11 @@ class KaminoAction {
|
|
|
176
177
|
return axn;
|
|
177
178
|
});
|
|
178
179
|
}
|
|
179
|
-
static buildDepositTxns(
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
180
|
+
static buildDepositTxns(kaminoMarket, amount, mint, owner, obligation, extraComputeBudget = 1000000, // if > 0 then adds the ixn
|
|
181
|
+
includeAtaIxns = true, // if true it includes create and close wsol and token atas,
|
|
182
|
+
requestElevationGroup = false, includeUserMetadata = true, // if true it includes user metadata
|
|
183
|
+
referrer = web3_js_1.PublicKey.default, currentSlot = 0) {
|
|
184
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
184
185
|
const axn = yield KaminoAction.initialize('deposit', amount, mint, owner, kaminoMarket, obligation, referrer, currentSlot);
|
|
185
186
|
const addInitObligationForFarm = true;
|
|
186
187
|
if (extraComputeBudget > 0) {
|
|
@@ -192,11 +193,11 @@ class KaminoAction {
|
|
|
192
193
|
return axn;
|
|
193
194
|
});
|
|
194
195
|
}
|
|
195
|
-
static buildBorrowTxns(
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
196
|
+
static buildBorrowTxns(kaminoMarket, amount, mint, owner, obligation, extraComputeBudget = 1000000, // if > 0 then adds the ixn
|
|
197
|
+
includeAtaIxns = true, // if true it includes create and close wsol and token atas,
|
|
198
|
+
requestElevationGroup = false, includeUserMetadata = true, // if true it includes user metadata
|
|
199
|
+
referrer = web3_js_1.PublicKey.default, currentSlot = 0, hostAta) {
|
|
200
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
200
201
|
const axn = yield KaminoAction.initialize('borrow', amount, mint, owner, kaminoMarket, obligation, referrer, currentSlot, hostAta);
|
|
201
202
|
const addInitObligationForFarm = true;
|
|
202
203
|
if (extraComputeBudget > 0) {
|
|
@@ -208,11 +209,11 @@ class KaminoAction {
|
|
|
208
209
|
return axn;
|
|
209
210
|
});
|
|
210
211
|
}
|
|
211
|
-
static buildDepositReserveLiquidityTxns(
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
212
|
+
static buildDepositReserveLiquidityTxns(kaminoMarket, amount, mint, owner, obligation, extraComputeBudget = 1000000, // if > 0 then adds the ixn
|
|
213
|
+
includeAtaIxns = true, // if true it includes create and close wsol and token atas
|
|
214
|
+
requestElevationGroup = false, includeUserMetadata = true, // if true it includes user metadata
|
|
215
|
+
referrer = web3_js_1.PublicKey.default, currentSlot = 0) {
|
|
216
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
216
217
|
const axn = yield KaminoAction.initialize('mint', amount, mint, owner, kaminoMarket, obligation, referrer, currentSlot);
|
|
217
218
|
const addInitObligationForFarm = true;
|
|
218
219
|
if (extraComputeBudget > 0) {
|
|
@@ -224,11 +225,11 @@ class KaminoAction {
|
|
|
224
225
|
return axn;
|
|
225
226
|
});
|
|
226
227
|
}
|
|
227
|
-
static buildRedeemReserveCollateralTxns(
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
228
|
+
static buildRedeemReserveCollateralTxns(kaminoMarket, amount, mint, owner, obligation, extraComputeBudget = 1000000, // if > 0 then adds the ixn
|
|
229
|
+
includeAtaIxns = true, // if true it includes create and close wsol and token atas
|
|
230
|
+
requestElevationGroup = false, includeUserMetadata = true, // if true it includes user metadata,
|
|
231
|
+
referrer = web3_js_1.PublicKey.default, currentSlot = 0) {
|
|
232
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
232
233
|
const axn = yield KaminoAction.initialize('redeem', amount, mint, owner, kaminoMarket, obligation, referrer, currentSlot);
|
|
233
234
|
const addInitObligationForFarm = true;
|
|
234
235
|
if (extraComputeBudget > 0) {
|
|
@@ -240,11 +241,11 @@ class KaminoAction {
|
|
|
240
241
|
return axn;
|
|
241
242
|
});
|
|
242
243
|
}
|
|
243
|
-
static buildDepositObligationCollateralTxns(
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
244
|
+
static buildDepositObligationCollateralTxns(kaminoMarket, amount, mint, owner, obligation, extraComputeBudget = 1000000, // if > 0 then adds the ixn
|
|
245
|
+
includeAtaIxns = true, // if true it includes create and close wsol and token atas
|
|
246
|
+
requestElevationGroup = false, includeUserMetadata = true, // if true it includes user metadata
|
|
247
|
+
referrer = web3_js_1.PublicKey.default, currentSlot = 0) {
|
|
248
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
248
249
|
const axn = yield KaminoAction.initialize('depositCollateral', amount, mint, owner, kaminoMarket, obligation, referrer, currentSlot);
|
|
249
250
|
const addInitObligationForFarm = true;
|
|
250
251
|
if (extraComputeBudget > 0) {
|
|
@@ -256,11 +257,11 @@ class KaminoAction {
|
|
|
256
257
|
return axn;
|
|
257
258
|
});
|
|
258
259
|
}
|
|
259
|
-
static buildDepositAndBorrowTxns(
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
260
|
+
static buildDepositAndBorrowTxns(kaminoMarket, depositAmount, depositMint, borrowAmount, borrowMint, payer, obligation, extraComputeBudget = 1000000, // if > 0 then adds the ixn
|
|
261
|
+
includeAtaIxns = true, // if true it includes create and close wsol and token atas,
|
|
262
|
+
requestElevationGroup = false, includeUserMetadata = true, // if true it includes user metadata,
|
|
263
|
+
referrer = web3_js_1.PublicKey.default, currentSlot = 0) {
|
|
264
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
264
265
|
const axn = yield KaminoAction.initializeMultiTokenAction(kaminoMarket, 'depositAndBorrow', depositAmount, depositMint, borrowMint, payer, payer, obligation, borrowAmount, referrer, currentSlot);
|
|
265
266
|
const addInitObligationForFarmForDeposit = true;
|
|
266
267
|
const addInitObligationForFarmForBorrow = false;
|
|
@@ -275,11 +276,11 @@ class KaminoAction {
|
|
|
275
276
|
return axn;
|
|
276
277
|
});
|
|
277
278
|
}
|
|
278
|
-
static buildRepayAndWithdrawTxns(
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
279
|
+
static buildRepayAndWithdrawTxns(kaminoMarket, repayAmount, repayMint, withdrawAmount, withdrawMint, payer, currentSlot, obligation, extraComputeBudget = 1000000, // if > 0 then adds the ixn
|
|
280
|
+
includeAtaIxns = true, // if true it includes create and close wsol and token atas,
|
|
281
|
+
requestElevationGroup = false, includeUserMetadata = true, // if true it includes user metadata,
|
|
282
|
+
isClosingPosition = false, referrer = web3_js_1.PublicKey.default) {
|
|
283
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
283
284
|
const axn = yield KaminoAction.initializeMultiTokenAction(kaminoMarket, 'repayAndWithdraw', repayAmount, repayMint, withdrawMint, payer, payer, obligation, withdrawAmount, referrer, currentSlot);
|
|
284
285
|
const addInitObligationForFarmForRepay = true;
|
|
285
286
|
const addInitObligationForFarmForWithdraw = false;
|
|
@@ -294,11 +295,11 @@ class KaminoAction {
|
|
|
294
295
|
return axn;
|
|
295
296
|
});
|
|
296
297
|
}
|
|
297
|
-
static buildWithdrawTxns(
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
298
|
+
static buildWithdrawTxns(kaminoMarket, amount, mint, owner, obligation, extraComputeBudget = 1000000, // if > 0 then adds the ixn
|
|
299
|
+
includeAtaIxns = true, // if true it includes create and close wsol and token atas,
|
|
300
|
+
requestElevationGroup = false, includeUserMetadata = true, // if true it includes user metadata
|
|
301
|
+
referrer = web3_js_1.PublicKey.default, currentSlot = 0) {
|
|
302
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
302
303
|
const axn = yield KaminoAction.initialize('withdraw', amount, mint, owner, kaminoMarket, obligation, referrer, currentSlot);
|
|
303
304
|
const addInitObligationForFarm = true;
|
|
304
305
|
if (extraComputeBudget > 0) {
|
|
@@ -325,8 +326,8 @@ class KaminoAction {
|
|
|
325
326
|
* @param includeUserMetadata - if true it includes user metadata
|
|
326
327
|
* @param referrer
|
|
327
328
|
*/
|
|
328
|
-
static buildRepayTxns(
|
|
329
|
-
return __awaiter(this,
|
|
329
|
+
static buildRepayTxns(kaminoMarket, amount, mint, owner, obligation, currentSlot, payer = undefined, extraComputeBudget = 1000000, includeAtaIxns = true, requestElevationGroup = false, includeUserMetadata = true, referrer = web3_js_1.PublicKey.default) {
|
|
330
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
330
331
|
const axn = yield KaminoAction.initialize('repay', amount, mint, owner, kaminoMarket, obligation, referrer, currentSlot, undefined, payer);
|
|
331
332
|
const addInitObligationForFarm = true;
|
|
332
333
|
if (extraComputeBudget > 0) {
|
|
@@ -338,11 +339,11 @@ class KaminoAction {
|
|
|
338
339
|
return axn;
|
|
339
340
|
});
|
|
340
341
|
}
|
|
341
|
-
static buildLiquidateTxns(
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
342
|
+
static buildLiquidateTxns(kaminoMarket, amount, minCollateralReceiveAmount, repayTokenMint, withdrawTokenMint, liquidator, obligationOwner, obligation, extraComputeBudget = 1000000, // if > 0 then adds the ixn
|
|
343
|
+
includeAtaIxns = true, // if true it includes create and close wsol and token atas, and creates all other token atas if they don't exist
|
|
344
|
+
requestElevationGroup = false, includeUserMetadata = true, // if true it includes user metadata
|
|
345
|
+
referrer = web3_js_1.PublicKey.default, maxAllowedLtvOverridePercent = 0, currentSlot = 0) {
|
|
346
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
346
347
|
const axn = yield KaminoAction.initializeMultiTokenAction(kaminoMarket, 'liquidate', amount, repayTokenMint, withdrawTokenMint, liquidator, obligationOwner, obligation, minCollateralReceiveAmount, referrer, currentSlot);
|
|
347
348
|
const addInitObligationForFarm = true;
|
|
348
349
|
if (extraComputeBudget > 0) {
|
|
@@ -354,8 +355,8 @@ class KaminoAction {
|
|
|
354
355
|
return axn;
|
|
355
356
|
});
|
|
356
357
|
}
|
|
357
|
-
static buildWithdrawReferrerFeeTxns(
|
|
358
|
-
return __awaiter(this,
|
|
358
|
+
static buildWithdrawReferrerFeeTxns(owner, tokenMint, kaminoMarket, currentSlot = 0) {
|
|
359
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
359
360
|
const { axn, createAtasIxns } = yield KaminoAction.initializeWithdrawReferrerFees(tokenMint, owner, kaminoMarket, currentSlot);
|
|
360
361
|
axn.preTxnIxs.push(...createAtasIxns);
|
|
361
362
|
axn.preTxnIxsLabels.push(`createAtasIxs[${axn.userTokenAccountAddress.toString()}]`);
|
|
@@ -445,7 +446,7 @@ class KaminoAction {
|
|
|
445
446
|
reserveLiquidityMint: this.reserve.getLiquidityMint(),
|
|
446
447
|
reserveLiquiditySupply: this.reserve.state.liquidity.supplyVault,
|
|
447
448
|
reserveCollateralMint: this.reserve.getCTokenMint(),
|
|
448
|
-
reserveDestinationDepositCollateral: this.reserve.state.collateral.supplyVault,
|
|
449
|
+
reserveDestinationDepositCollateral: this.reserve.state.collateral.supplyVault,
|
|
449
450
|
userSourceLiquidity: this.userTokenAccountAddress,
|
|
450
451
|
placeholderUserDestinationCollateral: this.kaminoMarket.programId,
|
|
451
452
|
collateralTokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
@@ -546,7 +547,7 @@ class KaminoAction {
|
|
|
546
547
|
reserveLiquidityMint: this.reserve.getLiquidityMint(),
|
|
547
548
|
reserveLiquiditySupply: this.reserve.state.liquidity.supplyVault,
|
|
548
549
|
reserveCollateralMint: this.reserve.getCTokenMint(),
|
|
549
|
-
reserveDestinationDepositCollateral: this.reserve.state.collateral.supplyVault,
|
|
550
|
+
reserveDestinationDepositCollateral: this.reserve.state.collateral.supplyVault,
|
|
550
551
|
userSourceLiquidity: this.userTokenAccountAddress,
|
|
551
552
|
placeholderUserDestinationCollateral: this.kaminoMarket.programId,
|
|
552
553
|
collateralTokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
@@ -689,8 +690,8 @@ class KaminoAction {
|
|
|
689
690
|
this.lendingIxs.push(repayIx);
|
|
690
691
|
});
|
|
691
692
|
}
|
|
692
|
-
addLiquidateIx() {
|
|
693
|
-
return __awaiter(this,
|
|
693
|
+
addLiquidateIx(maxAllowedLtvOverridePercent = 0) {
|
|
694
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
694
695
|
this.lendingIxsLabels.push(`liquidateObligationAndRedeemReserveCollateral`);
|
|
695
696
|
if (!this.outflowReserve) {
|
|
696
697
|
throw Error(`Withdraw reserve during liquidation is not defined`);
|
|
@@ -733,8 +734,8 @@ class KaminoAction {
|
|
|
733
734
|
this.lendingIxs.push(liquidateIx);
|
|
734
735
|
});
|
|
735
736
|
}
|
|
736
|
-
addInBetweenIxs(
|
|
737
|
-
return __awaiter(this,
|
|
737
|
+
addInBetweenIxs(action, includeAtaIxns, requestElevationGroup, addInitObligationForFarm, isClosingPosition = false) {
|
|
738
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
738
739
|
yield this.addSupportIxsWithoutInitObligation(action, includeAtaIxns, false, requestElevationGroup, addInitObligationForFarm, isClosingPosition);
|
|
739
740
|
});
|
|
740
741
|
}
|
|
@@ -748,9 +749,9 @@ class KaminoAction {
|
|
|
748
749
|
this.addRefreshFarmsForReserve(this.borrowReserves.map((r) => this.kaminoMarket.getReserveByAddress(r)), addAllToSetupIxns, types_1.ReserveFarmKind.Debt, crank);
|
|
749
750
|
this.addRefreshObligationIx(addAllToSetupIxns, false);
|
|
750
751
|
}
|
|
751
|
-
addSupportIxsWithoutInitObligation(
|
|
752
|
-
|
|
753
|
-
|
|
752
|
+
addSupportIxsWithoutInitObligation(action, includeAtaIxns, addToSetupIxs = true, requestElevationGroup = false, addInitObligationForFarm = false, isClosingPosition = false, twoTokenAction = false) {
|
|
753
|
+
var _a;
|
|
754
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
754
755
|
// TODO: why are we not doing this first?
|
|
755
756
|
if (includeAtaIxns) {
|
|
756
757
|
yield this.addAtaIxs(action);
|
|
@@ -931,8 +932,8 @@ class KaminoAction {
|
|
|
931
932
|
}
|
|
932
933
|
});
|
|
933
934
|
}
|
|
934
|
-
addSupportIxs(
|
|
935
|
-
return __awaiter(this,
|
|
935
|
+
addSupportIxs(action, includeAtaIxns, requestElevationGroup, includeUserMetadata, addInitObligationForFarm, twoTokenAction = false) {
|
|
936
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
936
937
|
if (!['mint', 'redeem'].includes(action)) {
|
|
937
938
|
const [, ownerUserMetadata] = yield this.kaminoMarket.getUserMetadata(this.owner);
|
|
938
939
|
if (!ownerUserMetadata && includeUserMetadata) {
|
|
@@ -1138,8 +1139,8 @@ class KaminoAction {
|
|
|
1138
1139
|
this.cleanupIxs.splice(this.cleanupIxs.length - 1, 0, ...this.refreshFarmsCleanupTxnIxs);
|
|
1139
1140
|
this.cleanupIxsLabels.splice(this.cleanupIxsLabels.length - 1, 0, ...this.refreshFarmsCleanupTxnIxsLabels);
|
|
1140
1141
|
}
|
|
1141
|
-
addInitObligationForFarm(
|
|
1142
|
-
return __awaiter(this,
|
|
1142
|
+
addInitObligationForFarm(reserve, mode, addToSetupIxs = true) {
|
|
1143
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1143
1144
|
const BASE_SEED_USER_STATE = Buffer.from('user');
|
|
1144
1145
|
const getPda = (farm) => web3_js_1.PublicKey.findProgramAddressSync([BASE_SEED_USER_STATE, farm.toBytes(), this.getObligationPda().toBytes()], farms_sdk_1.farmsId)[0];
|
|
1145
1146
|
const farms = [];
|
|
@@ -1233,8 +1234,8 @@ class KaminoAction {
|
|
|
1233
1234
|
this.setupIxsLabels.push(`initUserMetadata[${userMetadataAddress.toString()}]`);
|
|
1234
1235
|
});
|
|
1235
1236
|
}
|
|
1236
|
-
addInitReferrerTokenStateIxs() {
|
|
1237
|
-
return __awaiter(this,
|
|
1237
|
+
addInitReferrerTokenStateIxs(reservesArr = []) {
|
|
1238
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1238
1239
|
if (this.referrer.equals(web3_js_1.PublicKey.default)) {
|
|
1239
1240
|
return;
|
|
1240
1241
|
}
|
|
@@ -1286,8 +1287,8 @@ class KaminoAction {
|
|
|
1286
1287
|
this.setupIxsLabels.push(`AddComputeBudget[${units}]`);
|
|
1287
1288
|
}
|
|
1288
1289
|
addAtaIxs(action) {
|
|
1290
|
+
var _a, _b;
|
|
1289
1291
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1290
|
-
var _a, _b;
|
|
1291
1292
|
if (this.mint.equals(utils_1.WRAPPED_SOL_MINT) || ((_a = this.secondaryMint) === null || _a === void 0 ? void 0 : _a.equals(utils_1.WRAPPED_SOL_MINT))) {
|
|
1292
1293
|
yield this.updateWSOLAccount(action);
|
|
1293
1294
|
}
|
|
@@ -1385,8 +1386,8 @@ class KaminoAction {
|
|
|
1385
1386
|
});
|
|
1386
1387
|
}
|
|
1387
1388
|
updateWSOLAccount(action) {
|
|
1389
|
+
var _a, _b;
|
|
1388
1390
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1389
|
-
var _a, _b;
|
|
1390
1391
|
const preIxs = [];
|
|
1391
1392
|
const postIxs = [];
|
|
1392
1393
|
const preIxsLabels = [];
|
|
@@ -1430,7 +1431,7 @@ class KaminoAction {
|
|
|
1430
1431
|
});
|
|
1431
1432
|
preIxs.push(transferLamportsIx);
|
|
1432
1433
|
preIxsLabels.push(`TransferLamportsToUserAtaSOL[${userTokenAccountAddress}]`);
|
|
1433
|
-
const closeWSOLAccountIx = (0,
|
|
1434
|
+
const closeWSOLAccountIx = (0, token_1.createCloseAccountInstruction)(userTokenAccountAddress, this.owner, this.owner, spl_token_1.TOKEN_PROGRAM_ID);
|
|
1434
1435
|
const syncIx = (0, utils_1.syncNative)(userTokenAccountAddress);
|
|
1435
1436
|
if (userWSOLAccountInfo) {
|
|
1436
1437
|
if (sendAction) {
|
|
@@ -1465,8 +1466,8 @@ class KaminoAction {
|
|
|
1465
1466
|
this.cleanupIxsLabels.push(...postIxsLabels);
|
|
1466
1467
|
});
|
|
1467
1468
|
}
|
|
1468
|
-
static initializeMultiTokenAction(
|
|
1469
|
-
return __awaiter(this,
|
|
1469
|
+
static initializeMultiTokenAction(kaminoMarket, action, inflowAmount, inflowTokenMint, outflowTokenMint, payer, obligationOwner, obligation, outflowAmount, referrer = web3_js_1.PublicKey.default, currentSlot = 0) {
|
|
1470
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1470
1471
|
const inflowReserve = kaminoMarket.getReserveByMint(inflowTokenMint);
|
|
1471
1472
|
const outflowReserve = kaminoMarket.getReserveByMint(outflowTokenMint);
|
|
1472
1473
|
if (!outflowReserve || !inflowReserve) {
|
|
@@ -1512,8 +1513,8 @@ class KaminoAction {
|
|
|
1512
1513
|
return new KaminoAction(kaminoMarket, payer, kaminoObligation || obligation, userTokenAccountAddress, userCollateralAccountAddress, primaryMint, distinctReserveCount, inflowAmount, depositReserves, borrowReserves, inflowReserve, currentSlot, undefined, secondaryMint, additionalUserTokenAccountAddress, outflowReserve, outflowAmount, referrerKey);
|
|
1513
1514
|
});
|
|
1514
1515
|
}
|
|
1515
|
-
static initializeWithdrawReferrerFees(
|
|
1516
|
-
return __awaiter(this,
|
|
1516
|
+
static initializeWithdrawReferrerFees(mint, owner, kaminoMarket, currentSlot = 0, hostAta) {
|
|
1517
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1517
1518
|
const reserve = kaminoMarket.getReserveByMint(mint);
|
|
1518
1519
|
if (reserve === undefined) {
|
|
1519
1520
|
throw new Error(`Reserve ${mint} not found in market ${kaminoMarket.getAddress().toBase58()}`);
|