@kamino-finance/klend-sdk 7.3.9 → 7.3.10-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/classes/action.d.ts +21 -91
- package/dist/classes/action.d.ts.map +1 -1
- package/dist/classes/action.js +141 -119
- package/dist/classes/action.js.map +1 -1
- package/dist/classes/actionTypes.d.ts +310 -0
- package/dist/classes/actionTypes.d.ts.map +1 -0
- package/dist/classes/actionTypes.js +3 -0
- package/dist/classes/actionTypes.js.map +1 -0
- package/dist/classes/market.d.ts +15 -10
- package/dist/classes/market.d.ts.map +1 -1
- package/dist/classes/market.js +49 -26
- package/dist/classes/market.js.map +1 -1
- package/dist/classes/obligation.d.ts +9 -9
- package/dist/classes/obligation.d.ts.map +1 -1
- package/dist/classes/obligation.js +48 -50
- package/dist/classes/obligation.js.map +1 -1
- package/dist/classes/obligationOrder.d.ts.map +1 -1
- package/dist/classes/obligationOrder.js +6 -3
- package/dist/classes/obligationOrder.js.map +1 -1
- package/dist/classes/shared.d.ts +1 -0
- package/dist/classes/shared.d.ts.map +1 -1
- package/dist/client/commands/borrow.d.ts +1 -1
- package/dist/client/commands/borrow.d.ts.map +1 -1
- package/dist/client/commands/borrow.js +11 -2
- package/dist/client/commands/borrow.js.map +1 -1
- package/dist/client/commands/deposit.d.ts +1 -1
- package/dist/client/commands/deposit.d.ts.map +1 -1
- package/dist/client/commands/deposit.js +11 -2
- package/dist/client/commands/deposit.js.map +1 -1
- package/dist/client/commands/printReserve.d.ts +1 -1
- package/dist/client/commands/printReserve.d.ts.map +1 -1
- package/dist/client/commands/printReserve.js +2 -4
- package/dist/client/commands/printReserve.js.map +1 -1
- package/dist/client/commands/repay.d.ts +1 -1
- package/dist/client/commands/repay.d.ts.map +1 -1
- package/dist/client/commands/repay.js +12 -2
- package/dist/client/commands/repay.js.map +1 -1
- package/dist/client/commands/withdraw.d.ts +1 -1
- package/dist/client/commands/withdraw.d.ts.map +1 -1
- package/dist/client/commands/withdraw.js +11 -2
- package/dist/client/commands/withdraw.js.map +1 -1
- package/dist/lending_operations/repay_with_collateral_calcs.d.ts +1 -1
- package/dist/lending_operations/repay_with_collateral_calcs.d.ts.map +1 -1
- package/dist/lending_operations/repay_with_collateral_calcs.js +2 -2
- package/dist/lending_operations/repay_with_collateral_calcs.js.map +1 -1
- package/dist/lending_operations/repay_with_collateral_operations.d.ts +4 -4
- package/dist/lending_operations/repay_with_collateral_operations.d.ts.map +1 -1
- package/dist/lending_operations/repay_with_collateral_operations.js +43 -10
- package/dist/lending_operations/repay_with_collateral_operations.js.map +1 -1
- package/dist/lending_operations/swap_collateral_operations.d.ts +4 -4
- package/dist/lending_operations/swap_collateral_operations.d.ts.map +1 -1
- package/dist/lending_operations/swap_collateral_operations.js +40 -21
- package/dist/lending_operations/swap_collateral_operations.js.map +1 -1
- package/dist/leverage/operations.d.ts +6 -6
- package/dist/leverage/operations.d.ts.map +1 -1
- package/dist/leverage/operations.js +167 -52
- package/dist/leverage/operations.js.map +1 -1
- package/dist/leverage/types.d.ts +2 -2
- package/dist/leverage/types.d.ts.map +1 -1
- package/dist/manager/client_kamino_manager.js +0 -2
- package/dist/manager/client_kamino_manager.js.map +1 -1
- package/dist/obligation_orders/price_based.js +5 -3
- package/dist/obligation_orders/price_based.js.map +1 -1
- package/dist/utils/Logger.d.ts +14 -0
- package/dist/utils/Logger.d.ts.map +1 -0
- package/dist/utils/Logger.js +12 -0
- package/dist/utils/Logger.js.map +1 -0
- package/dist/utils/ObligationType.d.ts +33 -1
- package/dist/utils/ObligationType.d.ts.map +1 -1
- package/dist/utils/ObligationType.js +81 -2
- package/dist/utils/ObligationType.js.map +1 -1
- package/dist/utils/api.d.ts +13 -4
- package/dist/utils/api.d.ts.map +1 -1
- package/dist/utils/api.js +33 -31
- package/dist/utils/api.js.map +1 -1
- package/dist/utils/userMetadata.d.ts +2 -2
- package/dist/utils/userMetadata.d.ts.map +1 -1
- package/dist/utils/userMetadata.js +49 -25
- package/dist/utils/userMetadata.js.map +1 -1
- package/dist/utils/validations.d.ts +1 -0
- package/dist/utils/validations.d.ts.map +1 -1
- package/dist/utils/validations.js +5 -0
- package/dist/utils/validations.js.map +1 -1
- package/package.json +1 -1
- package/src/classes/action.ts +321 -347
- package/src/classes/actionTypes.ts +295 -0
- package/src/classes/market.ts +74 -31
- package/src/classes/obligation.ts +54 -53
- package/src/classes/obligationOrder.ts +6 -3
- package/src/classes/shared.ts +2 -0
- package/src/client/client.ts +17 -18
- package/src/client/commands/borrow.ts +10 -9
- package/src/client/commands/deposit.ts +10 -9
- package/src/client/commands/printReserve.ts +2 -4
- package/src/client/commands/repay.ts +11 -10
- package/src/client/commands/withdraw.ts +15 -9
- package/src/lending_operations/repay_with_collateral_calcs.ts +3 -4
- package/src/lending_operations/repay_with_collateral_operations.ts +40 -38
- package/src/lending_operations/swap_collateral_operations.ts +47 -41
- package/src/leverage/operations.ts +168 -129
- package/src/leverage/types.ts +2 -2
- package/src/manager/client_kamino_manager.ts +0 -2
- package/src/obligation_orders/price_based.ts +7 -5
- package/src/utils/Logger.ts +14 -0
- package/src/utils/ObligationType.ts +92 -1
- package/src/utils/api.ts +56 -33
- package/src/utils/userMetadata.ts +64 -30
- package/src/utils/validations.ts +5 -0
package/src/classes/action.ts
CHANGED
|
@@ -83,6 +83,24 @@ import {
|
|
|
83
83
|
} from '@solana-program/token-2022';
|
|
84
84
|
import { getTransferSolInstruction, SYSTEM_PROGRAM_ADDRESS } from '@solana-program/system';
|
|
85
85
|
import { noopSigner } from '../utils/signer';
|
|
86
|
+
import {
|
|
87
|
+
BuildDepositTxnsProps,
|
|
88
|
+
BuildBorrowTxnsProps,
|
|
89
|
+
BuildDepositReserveLiquidityTxnsProps,
|
|
90
|
+
BuildRedeemReserveCollateralTxnsProps,
|
|
91
|
+
BuildWithdrawTxnsProps,
|
|
92
|
+
BuildRepayTxnsProps,
|
|
93
|
+
BuildDepositAndBorrowTxnsProps,
|
|
94
|
+
BuildRefreshObligationTxnsProps,
|
|
95
|
+
BuildRequestElevationGroupTxnsProps,
|
|
96
|
+
BuildDepositAndWithdrawV2TxnsProps,
|
|
97
|
+
BuildRepayAndWithdrawTxnsProps,
|
|
98
|
+
BuildRepayAndWithdrawV2TxnsProps,
|
|
99
|
+
BuildLiquidateTxnsProps,
|
|
100
|
+
BuildWithdrawReferrerFeeTxnsProps,
|
|
101
|
+
BuildDepositObligationCollateralTxnsProps,
|
|
102
|
+
InitializeActionProps,
|
|
103
|
+
} from './actionTypes';
|
|
86
104
|
|
|
87
105
|
export type ActionType =
|
|
88
106
|
| 'deposit'
|
|
@@ -203,20 +221,22 @@ export class KaminoAction {
|
|
|
203
221
|
this.currentSlot = currentSlot;
|
|
204
222
|
}
|
|
205
223
|
|
|
206
|
-
static async initialize(
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
224
|
+
static async initialize(props: InitializeActionProps) {
|
|
225
|
+
const {
|
|
226
|
+
kaminoMarket,
|
|
227
|
+
action,
|
|
228
|
+
amount,
|
|
229
|
+
reserveAddress,
|
|
230
|
+
owner,
|
|
231
|
+
obligation,
|
|
232
|
+
referrer = none(),
|
|
233
|
+
currentSlot = 0n,
|
|
234
|
+
payer = owner,
|
|
235
|
+
} = props;
|
|
236
|
+
|
|
237
|
+
const reserve = kaminoMarket.getReserveByAddress(reserveAddress);
|
|
218
238
|
if (reserve === undefined) {
|
|
219
|
-
throw new Error(`Reserve ${
|
|
239
|
+
throw new Error(`Reserve ${reserveAddress} not found in market ${kaminoMarket.getAddress()}`);
|
|
220
240
|
}
|
|
221
241
|
|
|
222
242
|
const { kaminoObligation, depositReserves, borrowReserves, distinctReserveCount } =
|
|
@@ -228,7 +248,7 @@ export class KaminoAction {
|
|
|
228
248
|
kaminoMarket,
|
|
229
249
|
owner,
|
|
230
250
|
kaminoObligation || obligation,
|
|
231
|
-
|
|
251
|
+
reserve.getLiquidityMint(),
|
|
232
252
|
distinctReserveCount,
|
|
233
253
|
amount,
|
|
234
254
|
depositReserves,
|
|
@@ -309,29 +329,23 @@ export class KaminoAction {
|
|
|
309
329
|
};
|
|
310
330
|
}
|
|
311
331
|
|
|
312
|
-
static async buildRefreshObligationTxns(
|
|
313
|
-
kaminoMarket
|
|
314
|
-
payer: TransactionSigner,
|
|
315
|
-
obligation: KaminoObligation,
|
|
316
|
-
extraComputeBudget: number = 1_000_000, // if > 0 then adds the ix
|
|
317
|
-
currentSlot: Slot = 0n
|
|
318
|
-
) {
|
|
332
|
+
static async buildRefreshObligationTxns(props: BuildRefreshObligationTxnsProps) {
|
|
333
|
+
const { kaminoMarket, payer, obligation, extraComputeBudget = 1_000_000, currentSlot = 0n } = props;
|
|
319
334
|
// placeholder for action initialization
|
|
320
335
|
const firstReserve = obligation.getDeposits()[0].reserveAddress;
|
|
321
336
|
const firstKaminoReserve = kaminoMarket.getReserveByAddress(firstReserve);
|
|
322
337
|
if (!firstKaminoReserve) {
|
|
323
338
|
throw new Error(`Reserve ${firstReserve} not found`);
|
|
324
339
|
}
|
|
325
|
-
const axn = await KaminoAction.initialize(
|
|
326
|
-
'refreshObligation',
|
|
327
|
-
'0',
|
|
328
|
-
firstKaminoReserve?.getLiquidityMint(),
|
|
329
|
-
noopSigner(obligation.state.owner), // owner does not need to sign for refresh
|
|
340
|
+
const axn = await KaminoAction.initialize({
|
|
330
341
|
kaminoMarket,
|
|
342
|
+
action: 'refreshObligation',
|
|
343
|
+
amount: '0',
|
|
344
|
+
reserveAddress: firstKaminoReserve.address,
|
|
345
|
+
owner: noopSigner(obligation.state.owner), // owner does not need to sign for refresh
|
|
331
346
|
obligation,
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
);
|
|
347
|
+
currentSlot,
|
|
348
|
+
});
|
|
335
349
|
|
|
336
350
|
if (extraComputeBudget > 0) {
|
|
337
351
|
axn.addComputeBudgetIx(extraComputeBudget);
|
|
@@ -342,29 +356,22 @@ export class KaminoAction {
|
|
|
342
356
|
return axn;
|
|
343
357
|
}
|
|
344
358
|
|
|
345
|
-
static async buildRequestElevationGroupTxns(
|
|
346
|
-
kaminoMarket
|
|
347
|
-
owner: TransactionSigner,
|
|
348
|
-
obligation: KaminoObligation,
|
|
349
|
-
elevationGroup: number,
|
|
350
|
-
extraComputeBudget: number = 1_000_000, // if > 0 then adds the ix
|
|
351
|
-
currentSlot: Slot = 0n
|
|
352
|
-
) {
|
|
359
|
+
static async buildRequestElevationGroupTxns(props: BuildRequestElevationGroupTxnsProps) {
|
|
360
|
+
const { kaminoMarket, owner, obligation, elevationGroup, extraComputeBudget = 1_000_000, currentSlot = 0n } = props;
|
|
353
361
|
const firstReserve = obligation.state.deposits.find((x) => x.depositReserve !== DEFAULT_PUBLIC_KEY)!.depositReserve;
|
|
354
362
|
const firstKaminoReserve = kaminoMarket.getReserveByAddress(firstReserve);
|
|
355
363
|
if (!firstKaminoReserve) {
|
|
356
364
|
throw new Error(`Reserve ${firstReserve} not found`);
|
|
357
365
|
}
|
|
358
|
-
const axn = await KaminoAction.initialize(
|
|
359
|
-
'requestElevationGroup',
|
|
360
|
-
'0',
|
|
361
|
-
firstKaminoReserve?.getLiquidityMint(),
|
|
362
|
-
owner,
|
|
366
|
+
const axn = await KaminoAction.initialize({
|
|
363
367
|
kaminoMarket,
|
|
368
|
+
action: 'requestElevationGroup',
|
|
369
|
+
amount: '0',
|
|
370
|
+
reserveAddress: firstKaminoReserve.address,
|
|
371
|
+
owner,
|
|
364
372
|
obligation,
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
);
|
|
373
|
+
currentSlot,
|
|
374
|
+
});
|
|
368
375
|
|
|
369
376
|
if (extraComputeBudget > 0) {
|
|
370
377
|
axn.addComputeBudgetIx(extraComputeBudget);
|
|
@@ -376,35 +383,34 @@ export class KaminoAction {
|
|
|
376
383
|
return axn;
|
|
377
384
|
}
|
|
378
385
|
|
|
379
|
-
static async buildDepositTxns(
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
mint: Address,
|
|
383
|
-
owner: TransactionSigner,
|
|
384
|
-
obligation: KaminoObligation | ObligationType,
|
|
385
|
-
useV2Ixs: boolean,
|
|
386
|
-
scopeRefreshConfig: ScopePriceRefreshConfig | undefined,
|
|
387
|
-
extraComputeBudget: number = 1_000_000, // if > 0 then adds the ix
|
|
388
|
-
includeAtaIxs: boolean = true, // if true it includes create and close wsol and token atas,
|
|
389
|
-
requestElevationGroup: boolean = false, // to be requested *before* the deposit
|
|
390
|
-
initUserMetadata: { skipInitialization: boolean; skipLutCreation: boolean } = {
|
|
391
|
-
skipInitialization: false,
|
|
392
|
-
skipLutCreation: false,
|
|
393
|
-
},
|
|
394
|
-
referrer: Option<Address> = none(),
|
|
395
|
-
currentSlot: Slot = 0n,
|
|
396
|
-
overrideElevationGroupRequest: number | undefined = undefined // if set, when an elevationgroup request is made, it will use this value
|
|
397
|
-
) {
|
|
398
|
-
const axn = await KaminoAction.initialize(
|
|
399
|
-
'deposit',
|
|
386
|
+
static async buildDepositTxns(props: BuildDepositTxnsProps) {
|
|
387
|
+
const {
|
|
388
|
+
kaminoMarket,
|
|
400
389
|
amount,
|
|
401
|
-
|
|
390
|
+
reserveAddress,
|
|
402
391
|
owner,
|
|
392
|
+
obligation,
|
|
393
|
+
useV2Ixs,
|
|
394
|
+
scopeRefreshConfig,
|
|
395
|
+
extraComputeBudget = 1_000_000,
|
|
396
|
+
includeAtaIxs = true,
|
|
397
|
+
requestElevationGroup = false,
|
|
398
|
+
initUserMetadata = { skipInitialization: false, skipLutCreation: false },
|
|
399
|
+
referrer = none(),
|
|
400
|
+
currentSlot = 0n,
|
|
401
|
+
overrideElevationGroupRequest,
|
|
402
|
+
} = props;
|
|
403
|
+
|
|
404
|
+
const axn = await KaminoAction.initialize({
|
|
403
405
|
kaminoMarket,
|
|
406
|
+
action: 'deposit',
|
|
407
|
+
amount,
|
|
408
|
+
reserveAddress,
|
|
409
|
+
owner,
|
|
404
410
|
obligation,
|
|
405
411
|
referrer,
|
|
406
|
-
currentSlot
|
|
407
|
-
);
|
|
412
|
+
currentSlot,
|
|
413
|
+
});
|
|
408
414
|
const addInitObligationForFarm = true;
|
|
409
415
|
|
|
410
416
|
if (extraComputeBudget > 0) {
|
|
@@ -440,35 +446,34 @@ export class KaminoAction {
|
|
|
440
446
|
}
|
|
441
447
|
}
|
|
442
448
|
|
|
443
|
-
static async buildBorrowTxns(
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
mint: Address,
|
|
447
|
-
owner: TransactionSigner,
|
|
448
|
-
obligation: KaminoObligation | ObligationType,
|
|
449
|
-
useV2Ixs: boolean,
|
|
450
|
-
scopeRefreshConfig: ScopePriceRefreshConfig | undefined,
|
|
451
|
-
extraComputeBudget: number = 1_000_000, // if > 0 then adds the ix
|
|
452
|
-
includeAtaIxs: boolean = true, // if true it includes create and close wsol and token atas,
|
|
453
|
-
requestElevationGroup: boolean = false,
|
|
454
|
-
initUserMetadata: { skipInitialization: boolean; skipLutCreation: boolean } = {
|
|
455
|
-
skipInitialization: false,
|
|
456
|
-
skipLutCreation: false,
|
|
457
|
-
},
|
|
458
|
-
referrer: Option<Address> = none(),
|
|
459
|
-
currentSlot: Slot = 0n,
|
|
460
|
-
overrideElevationGroupRequest: number | undefined = undefined // if set, when an elevationgroup request is made, it will use this value
|
|
461
|
-
) {
|
|
462
|
-
const axn = await KaminoAction.initialize(
|
|
463
|
-
'borrow',
|
|
449
|
+
static async buildBorrowTxns(props: BuildBorrowTxnsProps) {
|
|
450
|
+
const {
|
|
451
|
+
kaminoMarket,
|
|
464
452
|
amount,
|
|
465
|
-
|
|
453
|
+
reserveAddress,
|
|
466
454
|
owner,
|
|
455
|
+
obligation,
|
|
456
|
+
useV2Ixs,
|
|
457
|
+
scopeRefreshConfig,
|
|
458
|
+
extraComputeBudget = 1_000_000,
|
|
459
|
+
includeAtaIxs = true,
|
|
460
|
+
requestElevationGroup = false,
|
|
461
|
+
initUserMetadata = { skipInitialization: false, skipLutCreation: false },
|
|
462
|
+
referrer = none(),
|
|
463
|
+
currentSlot = 0n,
|
|
464
|
+
overrideElevationGroupRequest,
|
|
465
|
+
} = props;
|
|
466
|
+
|
|
467
|
+
const axn = await KaminoAction.initialize({
|
|
467
468
|
kaminoMarket,
|
|
469
|
+
action: 'borrow',
|
|
470
|
+
amount,
|
|
471
|
+
reserveAddress,
|
|
472
|
+
owner,
|
|
468
473
|
obligation,
|
|
469
474
|
referrer,
|
|
470
|
-
currentSlot
|
|
471
|
-
);
|
|
475
|
+
currentSlot,
|
|
476
|
+
});
|
|
472
477
|
const addInitObligationForFarm = true;
|
|
473
478
|
if (extraComputeBudget > 0) {
|
|
474
479
|
axn.addComputeBudgetIx(extraComputeBudget);
|
|
@@ -507,29 +512,31 @@ export class KaminoAction {
|
|
|
507
512
|
return axn;
|
|
508
513
|
}
|
|
509
514
|
|
|
510
|
-
static async buildDepositReserveLiquidityTxns(
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
mint: Address,
|
|
514
|
-
owner: TransactionSigner,
|
|
515
|
-
obligation: KaminoObligation | ObligationType,
|
|
516
|
-
scopeRefreshConfig: ScopePriceRefreshConfig | undefined,
|
|
517
|
-
extraComputeBudget: number = 1_000_000, // if > 0 then adds the ix
|
|
518
|
-
includeAtaIxs: boolean = true, // if true it includes create and close wsol and token atas
|
|
519
|
-
requestElevationGroup: boolean = false,
|
|
520
|
-
referrer: Option<Address> = none(),
|
|
521
|
-
currentSlot: Slot = 0n
|
|
522
|
-
) {
|
|
523
|
-
const axn = await KaminoAction.initialize(
|
|
524
|
-
'mint',
|
|
515
|
+
static async buildDepositReserveLiquidityTxns(props: BuildDepositReserveLiquidityTxnsProps) {
|
|
516
|
+
const {
|
|
517
|
+
kaminoMarket,
|
|
525
518
|
amount,
|
|
526
|
-
|
|
519
|
+
reserveAddress,
|
|
527
520
|
owner,
|
|
521
|
+
obligation,
|
|
522
|
+
scopeRefreshConfig,
|
|
523
|
+
extraComputeBudget = 1_000_000,
|
|
524
|
+
includeAtaIxs = true,
|
|
525
|
+
requestElevationGroup = false,
|
|
526
|
+
referrer = none(),
|
|
527
|
+
currentSlot = 0n,
|
|
528
|
+
} = props;
|
|
529
|
+
|
|
530
|
+
const axn = await KaminoAction.initialize({
|
|
528
531
|
kaminoMarket,
|
|
532
|
+
action: 'mint',
|
|
533
|
+
amount,
|
|
534
|
+
reserveAddress,
|
|
535
|
+
owner,
|
|
529
536
|
obligation,
|
|
530
537
|
referrer,
|
|
531
|
-
currentSlot
|
|
532
|
-
);
|
|
538
|
+
currentSlot,
|
|
539
|
+
});
|
|
533
540
|
const addInitObligationForFarm = true;
|
|
534
541
|
|
|
535
542
|
if (extraComputeBudget > 0) {
|
|
@@ -550,29 +557,31 @@ export class KaminoAction {
|
|
|
550
557
|
return axn;
|
|
551
558
|
}
|
|
552
559
|
|
|
553
|
-
static async buildRedeemReserveCollateralTxns(
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
mint: Address,
|
|
557
|
-
owner: TransactionSigner,
|
|
558
|
-
obligation: KaminoObligation | ObligationType,
|
|
559
|
-
scopeRefreshConfig: ScopePriceRefreshConfig | undefined,
|
|
560
|
-
extraComputeBudget: number = 1_000_000, // if > 0 then adds the ix
|
|
561
|
-
includeAtaIxs: boolean = true, // if true it includes create and close wsol and token atas
|
|
562
|
-
requestElevationGroup: boolean = false,
|
|
563
|
-
referrer: Option<Address> = none(),
|
|
564
|
-
currentSlot: Slot = 0n
|
|
565
|
-
) {
|
|
566
|
-
const axn = await KaminoAction.initialize(
|
|
567
|
-
'redeem',
|
|
560
|
+
static async buildRedeemReserveCollateralTxns(props: BuildRedeemReserveCollateralTxnsProps) {
|
|
561
|
+
const {
|
|
562
|
+
kaminoMarket,
|
|
568
563
|
amount,
|
|
569
|
-
|
|
564
|
+
reserveAddress,
|
|
570
565
|
owner,
|
|
566
|
+
obligation,
|
|
567
|
+
scopeRefreshConfig,
|
|
568
|
+
extraComputeBudget = 1_000_000,
|
|
569
|
+
includeAtaIxs = true,
|
|
570
|
+
requestElevationGroup = false,
|
|
571
|
+
referrer = none(),
|
|
572
|
+
currentSlot = 0n,
|
|
573
|
+
} = props;
|
|
574
|
+
|
|
575
|
+
const axn = await KaminoAction.initialize({
|
|
571
576
|
kaminoMarket,
|
|
577
|
+
action: 'redeem',
|
|
578
|
+
amount,
|
|
579
|
+
reserveAddress,
|
|
580
|
+
owner,
|
|
572
581
|
obligation,
|
|
573
582
|
referrer,
|
|
574
|
-
currentSlot
|
|
575
|
-
);
|
|
583
|
+
currentSlot,
|
|
584
|
+
});
|
|
576
585
|
const addInitObligationForFarm = true;
|
|
577
586
|
|
|
578
587
|
if (extraComputeBudget > 0) {
|
|
@@ -593,34 +602,32 @@ export class KaminoAction {
|
|
|
593
602
|
return axn;
|
|
594
603
|
}
|
|
595
604
|
|
|
596
|
-
static async buildDepositObligationCollateralTxns(
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
mint: Address,
|
|
600
|
-
owner: TransactionSigner,
|
|
601
|
-
obligation: KaminoObligation | ObligationType,
|
|
602
|
-
useV2Ixs: boolean,
|
|
603
|
-
scopeRefreshConfig: ScopePriceRefreshConfig | undefined,
|
|
604
|
-
extraComputeBudget: number = 1_000_000, // if > 0 then adds the ix
|
|
605
|
-
includeAtaIxs: boolean = true, // if true it includes create and close wsol and token atas
|
|
606
|
-
requestElevationGroup: boolean = false,
|
|
607
|
-
initUserMetadata: { skipInitialization: boolean; skipLutCreation: boolean } = {
|
|
608
|
-
skipInitialization: false,
|
|
609
|
-
skipLutCreation: false,
|
|
610
|
-
},
|
|
611
|
-
referrer: Option<Address> = none(),
|
|
612
|
-
currentSlot: Slot = 0n
|
|
613
|
-
) {
|
|
614
|
-
const axn = await KaminoAction.initialize(
|
|
615
|
-
'depositCollateral',
|
|
605
|
+
static async buildDepositObligationCollateralTxns(props: BuildDepositObligationCollateralTxnsProps) {
|
|
606
|
+
const {
|
|
607
|
+
kaminoMarket,
|
|
616
608
|
amount,
|
|
617
|
-
|
|
609
|
+
reserveAddress,
|
|
618
610
|
owner,
|
|
611
|
+
obligation,
|
|
612
|
+
useV2Ixs,
|
|
613
|
+
scopeRefreshConfig,
|
|
614
|
+
extraComputeBudget = 1_000_000,
|
|
615
|
+
includeAtaIxs = true,
|
|
616
|
+
requestElevationGroup = false,
|
|
617
|
+
initUserMetadata = { skipInitialization: false, skipLutCreation: false },
|
|
618
|
+
referrer = none(),
|
|
619
|
+
currentSlot = 0n,
|
|
620
|
+
} = props;
|
|
621
|
+
const axn = await KaminoAction.initialize({
|
|
619
622
|
kaminoMarket,
|
|
623
|
+
action: 'depositCollateral',
|
|
624
|
+
amount,
|
|
625
|
+
reserveAddress,
|
|
626
|
+
owner,
|
|
620
627
|
obligation,
|
|
621
628
|
referrer,
|
|
622
|
-
currentSlot
|
|
623
|
-
);
|
|
629
|
+
currentSlot,
|
|
630
|
+
});
|
|
624
631
|
const addInitObligationForFarm = true;
|
|
625
632
|
|
|
626
633
|
if (extraComputeBudget > 0) {
|
|
@@ -645,32 +652,30 @@ export class KaminoAction {
|
|
|
645
652
|
return axn;
|
|
646
653
|
}
|
|
647
654
|
|
|
648
|
-
static async buildDepositAndBorrowTxns(
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
skipInitialization: false,
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
currentSlot: Slot = 0n
|
|
667
|
-
) {
|
|
655
|
+
static async buildDepositAndBorrowTxns(props: BuildDepositAndBorrowTxnsProps) {
|
|
656
|
+
const {
|
|
657
|
+
kaminoMarket,
|
|
658
|
+
depositAmount,
|
|
659
|
+
depositReserveAddress,
|
|
660
|
+
borrowAmount,
|
|
661
|
+
borrowReserveAddress,
|
|
662
|
+
owner,
|
|
663
|
+
obligation,
|
|
664
|
+
useV2Ixs,
|
|
665
|
+
scopeRefreshConfig,
|
|
666
|
+
extraComputeBudget = 1_000_000,
|
|
667
|
+
includeAtaIxs = true,
|
|
668
|
+
requestElevationGroup = false,
|
|
669
|
+
initUserMetadata = { skipInitialization: false, skipLutCreation: false },
|
|
670
|
+
referrer = none(),
|
|
671
|
+
currentSlot = 0n,
|
|
672
|
+
} = props;
|
|
668
673
|
const axn = await KaminoAction.initializeMultiTokenAction(
|
|
669
674
|
kaminoMarket,
|
|
670
675
|
'depositAndBorrow',
|
|
671
676
|
depositAmount,
|
|
672
|
-
|
|
673
|
-
|
|
677
|
+
depositReserveAddress,
|
|
678
|
+
borrowReserveAddress,
|
|
674
679
|
owner,
|
|
675
680
|
owner.address,
|
|
676
681
|
obligation,
|
|
@@ -745,31 +750,29 @@ export class KaminoAction {
|
|
|
745
750
|
return axn;
|
|
746
751
|
}
|
|
747
752
|
|
|
748
|
-
static async buildDepositAndWithdrawV2Txns(
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
skipInitialization: false,
|
|
763
|
-
|
|
764
|
-
}
|
|
765
|
-
referrer: Option<Address> = none()
|
|
766
|
-
) {
|
|
753
|
+
static async buildDepositAndWithdrawV2Txns(props: BuildDepositAndWithdrawV2TxnsProps) {
|
|
754
|
+
const {
|
|
755
|
+
kaminoMarket,
|
|
756
|
+
depositAmount,
|
|
757
|
+
depositReserveAddress,
|
|
758
|
+
withdrawAmount,
|
|
759
|
+
withdrawReserveAddress,
|
|
760
|
+
owner,
|
|
761
|
+
currentSlot,
|
|
762
|
+
obligation,
|
|
763
|
+
scopeRefreshConfig,
|
|
764
|
+
extraComputeBudget = 1_000_000,
|
|
765
|
+
includeAtaIxs = true,
|
|
766
|
+
requestElevationGroup = false,
|
|
767
|
+
initUserMetadata = { skipInitialization: false, skipLutCreation: false },
|
|
768
|
+
referrer = none(),
|
|
769
|
+
} = props;
|
|
767
770
|
const axn = await KaminoAction.initializeMultiTokenAction(
|
|
768
771
|
kaminoMarket,
|
|
769
772
|
'depositAndWithdraw',
|
|
770
773
|
depositAmount,
|
|
771
|
-
|
|
772
|
-
|
|
774
|
+
depositReserveAddress,
|
|
775
|
+
withdrawReserveAddress,
|
|
773
776
|
owner,
|
|
774
777
|
owner.address,
|
|
775
778
|
obligation,
|
|
@@ -799,31 +802,29 @@ export class KaminoAction {
|
|
|
799
802
|
return axn;
|
|
800
803
|
}
|
|
801
804
|
|
|
802
|
-
static async buildRepayAndWithdrawV2Txns(
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
skipInitialization: false,
|
|
817
|
-
|
|
818
|
-
}
|
|
819
|
-
referrer: Option<Address> = none()
|
|
820
|
-
) {
|
|
805
|
+
static async buildRepayAndWithdrawV2Txns(props: BuildRepayAndWithdrawV2TxnsProps) {
|
|
806
|
+
const {
|
|
807
|
+
kaminoMarket,
|
|
808
|
+
repayAmount,
|
|
809
|
+
repayReserveAddress,
|
|
810
|
+
withdrawAmount,
|
|
811
|
+
withdrawReserveAddress,
|
|
812
|
+
payer,
|
|
813
|
+
currentSlot,
|
|
814
|
+
obligation,
|
|
815
|
+
scopeRefreshConfig,
|
|
816
|
+
extraComputeBudget = 1_000_000,
|
|
817
|
+
includeAtaIxs = true,
|
|
818
|
+
requestElevationGroup = false,
|
|
819
|
+
initUserMetadata = { skipInitialization: false, skipLutCreation: false },
|
|
820
|
+
referrer = none(),
|
|
821
|
+
} = props;
|
|
821
822
|
const axn = await KaminoAction.initializeMultiTokenAction(
|
|
822
823
|
kaminoMarket,
|
|
823
824
|
'repayAndWithdrawV2',
|
|
824
825
|
repayAmount,
|
|
825
|
-
|
|
826
|
-
|
|
826
|
+
repayReserveAddress,
|
|
827
|
+
withdrawReserveAddress,
|
|
827
828
|
payer,
|
|
828
829
|
payer.address,
|
|
829
830
|
obligation,
|
|
@@ -853,32 +854,30 @@ export class KaminoAction {
|
|
|
853
854
|
return axn;
|
|
854
855
|
}
|
|
855
856
|
|
|
856
|
-
static async buildRepayAndWithdrawTxns(
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
skipInitialization: false,
|
|
872
|
-
|
|
873
|
-
}
|
|
874
|
-
referrer: Option<Address> = none()
|
|
875
|
-
) {
|
|
857
|
+
static async buildRepayAndWithdrawTxns(props: BuildRepayAndWithdrawTxnsProps) {
|
|
858
|
+
const {
|
|
859
|
+
kaminoMarket,
|
|
860
|
+
repayAmount,
|
|
861
|
+
repayReserveAddress,
|
|
862
|
+
withdrawAmount,
|
|
863
|
+
withdrawReserveAddress,
|
|
864
|
+
payer,
|
|
865
|
+
currentSlot,
|
|
866
|
+
obligation,
|
|
867
|
+
useV2Ixs,
|
|
868
|
+
scopeRefreshConfig,
|
|
869
|
+
extraComputeBudget = 1_000_000,
|
|
870
|
+
includeAtaIxs = true,
|
|
871
|
+
requestElevationGroup = false,
|
|
872
|
+
initUserMetadata = { skipInitialization: false, skipLutCreation: false },
|
|
873
|
+
referrer = none(),
|
|
874
|
+
} = props;
|
|
876
875
|
const axn = await KaminoAction.initializeMultiTokenAction(
|
|
877
876
|
kaminoMarket,
|
|
878
877
|
'repayAndWithdraw',
|
|
879
878
|
repayAmount,
|
|
880
|
-
|
|
881
|
-
|
|
879
|
+
repayReserveAddress,
|
|
880
|
+
withdrawReserveAddress,
|
|
882
881
|
payer,
|
|
883
882
|
payer.address,
|
|
884
883
|
obligation,
|
|
@@ -942,40 +941,35 @@ export class KaminoAction {
|
|
|
942
941
|
return axn;
|
|
943
942
|
}
|
|
944
943
|
|
|
945
|
-
static async buildWithdrawTxns(
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
mint: Address,
|
|
949
|
-
owner: TransactionSigner,
|
|
950
|
-
obligation: KaminoObligation | ObligationType,
|
|
951
|
-
useV2Ixs: boolean,
|
|
952
|
-
scopeRefreshConfig: ScopePriceRefreshConfig | undefined,
|
|
953
|
-
extraComputeBudget: number = 1_000_000, // if > 0 then adds the ix
|
|
954
|
-
includeAtaIxs: boolean = true, // if true it includes create and close wsol and token atas,
|
|
955
|
-
requestElevationGroup: boolean = false, // to be requested *after* the withdraw
|
|
956
|
-
initUserMetadata: { skipInitialization: boolean; skipLutCreation: boolean } = {
|
|
957
|
-
skipInitialization: false,
|
|
958
|
-
skipLutCreation: false,
|
|
959
|
-
},
|
|
960
|
-
referrer: Option<Address> = none(),
|
|
961
|
-
currentSlot: Slot = 0n,
|
|
962
|
-
overrideElevationGroupRequest?: number,
|
|
963
|
-
// Optional customizations which may be needed if the obligation was mutated by some previous ix.
|
|
964
|
-
obligationCustomizations?: {
|
|
965
|
-
// Any newly-added deposit reserves.
|
|
966
|
-
addedDepositReserves?: Address[];
|
|
967
|
-
}
|
|
968
|
-
) {
|
|
969
|
-
const axn = await KaminoAction.initialize(
|
|
970
|
-
'withdraw',
|
|
944
|
+
static async buildWithdrawTxns(props: BuildWithdrawTxnsProps) {
|
|
945
|
+
const {
|
|
946
|
+
kaminoMarket,
|
|
971
947
|
amount,
|
|
972
|
-
|
|
948
|
+
reserveAddress,
|
|
973
949
|
owner,
|
|
950
|
+
obligation,
|
|
951
|
+
useV2Ixs,
|
|
952
|
+
scopeRefreshConfig,
|
|
953
|
+
extraComputeBudget = 1_000_000,
|
|
954
|
+
includeAtaIxs = true,
|
|
955
|
+
requestElevationGroup = false,
|
|
956
|
+
initUserMetadata = { skipInitialization: false, skipLutCreation: false },
|
|
957
|
+
referrer = none(),
|
|
958
|
+
currentSlot = 0n,
|
|
959
|
+
overrideElevationGroupRequest,
|
|
960
|
+
obligationCustomizations,
|
|
961
|
+
} = props;
|
|
962
|
+
|
|
963
|
+
const axn = await KaminoAction.initialize({
|
|
974
964
|
kaminoMarket,
|
|
965
|
+
action: 'withdraw',
|
|
966
|
+
amount,
|
|
967
|
+
reserveAddress,
|
|
968
|
+
owner,
|
|
975
969
|
obligation,
|
|
976
970
|
referrer,
|
|
977
|
-
currentSlot
|
|
978
|
-
);
|
|
971
|
+
currentSlot,
|
|
972
|
+
});
|
|
979
973
|
const addInitObligationForFarm = true;
|
|
980
974
|
|
|
981
975
|
if (extraComputeBudget > 0) {
|
|
@@ -1009,52 +1003,38 @@ export class KaminoAction {
|
|
|
1009
1003
|
}
|
|
1010
1004
|
|
|
1011
1005
|
/**
|
|
1012
|
-
*
|
|
1013
|
-
* @param
|
|
1014
|
-
* @param amount
|
|
1015
|
-
* @param mint
|
|
1016
|
-
* @param owner
|
|
1017
|
-
* @param obligation - obligation to repay or the PDA seeds
|
|
1018
|
-
* @param useV2Ixs
|
|
1019
|
-
* @param scopeRefreshConfig
|
|
1020
|
-
* @param currentSlot
|
|
1021
|
-
* @param payer - if not set then owner is used
|
|
1022
|
-
* @param extraComputeBudget - if > 0 then adds the ix
|
|
1023
|
-
* @param includeAtaIxs - if true it includes create and close wsol and token atas
|
|
1024
|
-
* @param requestElevationGroup
|
|
1025
|
-
* @param initUserMetadata
|
|
1026
|
-
* @param referrer
|
|
1006
|
+
* Build repay transactions
|
|
1007
|
+
* @param props - BuildRepayTxnsProps containing all required and optional parameters
|
|
1027
1008
|
*/
|
|
1028
|
-
static async buildRepayTxns(
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
mint: Address,
|
|
1032
|
-
owner: TransactionSigner,
|
|
1033
|
-
obligation: KaminoObligation | ObligationType,
|
|
1034
|
-
useV2Ixs: boolean,
|
|
1035
|
-
scopeRefreshConfig: ScopePriceRefreshConfig | undefined,
|
|
1036
|
-
currentSlot: Slot,
|
|
1037
|
-
payer: TransactionSigner = owner,
|
|
1038
|
-
extraComputeBudget: number = 1_000_000,
|
|
1039
|
-
includeAtaIxs: boolean = true,
|
|
1040
|
-
requestElevationGroup: boolean = false,
|
|
1041
|
-
initUserMetadata: { skipInitialization: boolean; skipLutCreation: boolean } = {
|
|
1042
|
-
skipInitialization: false,
|
|
1043
|
-
skipLutCreation: false,
|
|
1044
|
-
},
|
|
1045
|
-
referrer: Option<Address> = none()
|
|
1046
|
-
) {
|
|
1047
|
-
const axn = await KaminoAction.initialize(
|
|
1048
|
-
'repay',
|
|
1009
|
+
static async buildRepayTxns(props: BuildRepayTxnsProps) {
|
|
1010
|
+
const {
|
|
1011
|
+
kaminoMarket,
|
|
1049
1012
|
amount,
|
|
1050
|
-
|
|
1013
|
+
reserveAddress,
|
|
1051
1014
|
owner,
|
|
1015
|
+
obligation,
|
|
1016
|
+
useV2Ixs,
|
|
1017
|
+
scopeRefreshConfig,
|
|
1018
|
+
currentSlot,
|
|
1019
|
+
payer = owner,
|
|
1020
|
+
extraComputeBudget = 1_000_000,
|
|
1021
|
+
includeAtaIxs = true,
|
|
1022
|
+
requestElevationGroup = false,
|
|
1023
|
+
initUserMetadata = { skipInitialization: false, skipLutCreation: false },
|
|
1024
|
+
referrer = none(),
|
|
1025
|
+
} = props;
|
|
1026
|
+
|
|
1027
|
+
const axn = await KaminoAction.initialize({
|
|
1052
1028
|
kaminoMarket,
|
|
1029
|
+
action: 'repay',
|
|
1030
|
+
amount,
|
|
1031
|
+
reserveAddress,
|
|
1032
|
+
owner,
|
|
1053
1033
|
obligation,
|
|
1054
1034
|
referrer,
|
|
1055
1035
|
currentSlot,
|
|
1056
|
-
payer
|
|
1057
|
-
);
|
|
1036
|
+
payer,
|
|
1037
|
+
});
|
|
1058
1038
|
const addInitObligationForFarm = true;
|
|
1059
1039
|
|
|
1060
1040
|
if (extraComputeBudget > 0) {
|
|
@@ -1080,34 +1060,32 @@ export class KaminoAction {
|
|
|
1080
1060
|
return axn;
|
|
1081
1061
|
}
|
|
1082
1062
|
|
|
1083
|
-
static async buildLiquidateTxns(
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
skipInitialization: false,
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
currentSlot: Slot = 0n
|
|
1104
|
-
): Promise<KaminoAction> {
|
|
1063
|
+
static async buildLiquidateTxns(props: BuildLiquidateTxnsProps): Promise<KaminoAction> {
|
|
1064
|
+
const {
|
|
1065
|
+
kaminoMarket,
|
|
1066
|
+
amount,
|
|
1067
|
+
minCollateralReceiveAmount,
|
|
1068
|
+
repayReserveAddress,
|
|
1069
|
+
withdrawReserveAddress,
|
|
1070
|
+
liquidator,
|
|
1071
|
+
obligationOwner,
|
|
1072
|
+
obligation,
|
|
1073
|
+
useV2Ixs,
|
|
1074
|
+
scopeRefreshConfig,
|
|
1075
|
+
extraComputeBudget = 1_000_000,
|
|
1076
|
+
includeAtaIxs = true,
|
|
1077
|
+
requestElevationGroup = false,
|
|
1078
|
+
initUserMetadata = { skipInitialization: false, skipLutCreation: false },
|
|
1079
|
+
referrer = none(),
|
|
1080
|
+
maxAllowedLtvOverridePercent = 0,
|
|
1081
|
+
currentSlot = 0n,
|
|
1082
|
+
} = props;
|
|
1105
1083
|
const axn = await KaminoAction.initializeMultiTokenAction(
|
|
1106
1084
|
kaminoMarket,
|
|
1107
1085
|
'liquidate',
|
|
1108
1086
|
amount,
|
|
1109
|
-
|
|
1110
|
-
|
|
1087
|
+
repayReserveAddress,
|
|
1088
|
+
withdrawReserveAddress,
|
|
1111
1089
|
liquidator,
|
|
1112
1090
|
obligationOwner,
|
|
1113
1091
|
obligation,
|
|
@@ -1140,14 +1118,10 @@ export class KaminoAction {
|
|
|
1140
1118
|
return axn;
|
|
1141
1119
|
}
|
|
1142
1120
|
|
|
1143
|
-
static async buildWithdrawReferrerFeeTxns(
|
|
1144
|
-
owner
|
|
1145
|
-
tokenMint: Address,
|
|
1146
|
-
kaminoMarket: KaminoMarket,
|
|
1147
|
-
currentSlot: Slot = 0n
|
|
1148
|
-
) {
|
|
1121
|
+
static async buildWithdrawReferrerFeeTxns(props: BuildWithdrawReferrerFeeTxnsProps) {
|
|
1122
|
+
const { owner, reserveAddress, kaminoMarket, currentSlot = 0n } = props;
|
|
1149
1123
|
const { axn, createAtaIxs } = await KaminoAction.initializeWithdrawReferrerFees(
|
|
1150
|
-
|
|
1124
|
+
reserveAddress,
|
|
1151
1125
|
owner,
|
|
1152
1126
|
kaminoMarket,
|
|
1153
1127
|
currentSlot
|
|
@@ -3346,8 +3320,8 @@ export class KaminoAction {
|
|
|
3346
3320
|
kaminoMarket: KaminoMarket,
|
|
3347
3321
|
action: ActionType,
|
|
3348
3322
|
inflowAmount: string | BN,
|
|
3349
|
-
|
|
3350
|
-
|
|
3323
|
+
inflowReserveAddress: Address,
|
|
3324
|
+
outflowReserveAddress: Address,
|
|
3351
3325
|
signer: TransactionSigner,
|
|
3352
3326
|
obligationOwner: Address,
|
|
3353
3327
|
obligation: KaminoObligation | ObligationType,
|
|
@@ -3355,8 +3329,8 @@ export class KaminoAction {
|
|
|
3355
3329
|
referrer: Option<Address> = none(),
|
|
3356
3330
|
currentSlot: Slot = 0n
|
|
3357
3331
|
) {
|
|
3358
|
-
const inflowReserve = kaminoMarket.
|
|
3359
|
-
const outflowReserve = kaminoMarket.
|
|
3332
|
+
const inflowReserve = kaminoMarket.getExistingReserveByAddress(inflowReserveAddress);
|
|
3333
|
+
const outflowReserve = kaminoMarket.getExistingReserveByAddress(outflowReserveAddress);
|
|
3360
3334
|
|
|
3361
3335
|
const { kaminoObligation, depositReserves, borrowReserves, distinctReserveCount } =
|
|
3362
3336
|
await KaminoAction.loadObligation(
|
|
@@ -3378,8 +3352,8 @@ export class KaminoAction {
|
|
|
3378
3352
|
action === 'repayAndWithdraw' ||
|
|
3379
3353
|
action === 'repayAndWithdrawV2'
|
|
3380
3354
|
) {
|
|
3381
|
-
primaryMint =
|
|
3382
|
-
secondaryMint =
|
|
3355
|
+
primaryMint = inflowReserve.getLiquidityMint();
|
|
3356
|
+
secondaryMint = outflowReserve.getLiquidityMint();
|
|
3383
3357
|
} else {
|
|
3384
3358
|
throw new Error('Invalid action');
|
|
3385
3359
|
}
|
|
@@ -3403,14 +3377,14 @@ export class KaminoAction {
|
|
|
3403
3377
|
}
|
|
3404
3378
|
|
|
3405
3379
|
static async initializeWithdrawReferrerFees(
|
|
3406
|
-
|
|
3380
|
+
reserveAddress: Address,
|
|
3407
3381
|
owner: TransactionSigner,
|
|
3408
3382
|
kaminoMarket: KaminoMarket,
|
|
3409
3383
|
currentSlot: Slot = 0n
|
|
3410
3384
|
) {
|
|
3411
|
-
const reserve = kaminoMarket.
|
|
3385
|
+
const reserve = kaminoMarket.getReserveByAddress(reserveAddress);
|
|
3412
3386
|
if (reserve === undefined) {
|
|
3413
|
-
throw new Error(`Reserve ${
|
|
3387
|
+
throw new Error(`Reserve ${reserveAddress} not found in market ${kaminoMarket.getAddress()}`);
|
|
3414
3388
|
}
|
|
3415
3389
|
|
|
3416
3390
|
const [{ createAtaIx }] = await createAtasIdempotent(owner, [
|
|
@@ -3425,7 +3399,7 @@ export class KaminoAction {
|
|
|
3425
3399
|
kaminoMarket,
|
|
3426
3400
|
owner,
|
|
3427
3401
|
new VanillaObligation(kaminoMarket.programId),
|
|
3428
|
-
|
|
3402
|
+
reserve.getLiquidityMint(),
|
|
3429
3403
|
0,
|
|
3430
3404
|
new BN(0),
|
|
3431
3405
|
[],
|