@kamino-finance/klend-sdk 5.11.5 → 5.11.6-beta.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.d.ts +23 -23
- package/dist/classes/action.d.ts.map +1 -1
- package/dist/classes/action.js +195 -122
- package/dist/classes/action.js.map +1 -1
- package/dist/classes/index.d.ts +0 -1
- package/dist/classes/index.d.ts.map +1 -1
- package/dist/classes/index.js +0 -1
- package/dist/classes/index.js.map +1 -1
- package/dist/classes/manager.d.ts +1 -6
- package/dist/classes/manager.d.ts.map +1 -1
- package/dist/classes/manager.js +1 -16
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/market.d.ts +3 -3
- package/dist/classes/market.d.ts.map +1 -1
- package/dist/classes/market.js +16 -30
- package/dist/classes/market.js.map +1 -1
- package/dist/classes/obligation.d.ts +0 -2
- package/dist/classes/obligation.d.ts.map +1 -1
- package/dist/classes/obligation.js +0 -5
- package/dist/classes/obligation.js.map +1 -1
- package/dist/classes/types.d.ts.map +1 -1
- package/dist/classes/vault.d.ts +0 -1
- package/dist/classes/vault.d.ts.map +1 -1
- package/dist/classes/vault.js +18 -21
- package/dist/classes/vault.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.d.ts +3 -6
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.js +7 -13
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/errors/custom.d.ts +1 -25
- package/dist/idl_codegen_kamino_vault/errors/custom.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/errors/custom.js +1 -43
- package/dist/idl_codegen_kamino_vault/errors/custom.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/giveUpPendingFees.d.ts +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/giveUpPendingFees.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/giveUpPendingFees.js +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/giveUpPendingFees.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/initVault.d.ts +0 -1
- package/dist/idl_codegen_kamino_vault/instructions/initVault.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/initVault.js +0 -1
- package/dist/idl_codegen_kamino_vault/instructions/initVault.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.d.ts +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.js +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.d.ts +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.js +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateSharesMetadata.d.ts +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateSharesMetadata.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateSharesMetadata.js +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateSharesMetadata.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateVaultConfig.d.ts +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateVaultConfig.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateVaultConfig.js +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateVaultConfig.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.d.ts +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.js +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/VaultConfigField.d.ts +0 -13
- package/dist/idl_codegen_kamino_vault/types/VaultConfigField.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/VaultConfigField.js +1 -25
- package/dist/idl_codegen_kamino_vault/types/VaultConfigField.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/index.d.ts +2 -2
- package/dist/idl_codegen_kamino_vault/types/index.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/index.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 +8 -10
- package/dist/lending_operations/repay_with_collateral_operations.js.map +1 -1
- package/dist/lending_operations/swap_collateral_operations.d.ts +2 -2
- package/dist/lending_operations/swap_collateral_operations.d.ts.map +1 -1
- package/dist/lending_operations/swap_collateral_operations.js +6 -11
- package/dist/lending_operations/swap_collateral_operations.js.map +1 -1
- package/dist/leverage/operations.d.ts +7 -9
- package/dist/leverage/operations.d.ts.map +1 -1
- package/dist/leverage/operations.js +66 -78
- package/dist/leverage/operations.js.map +1 -1
- package/dist/leverage/types.d.ts +4 -4
- package/dist/leverage/types.d.ts.map +1 -1
- package/dist/utils/ObligationType.d.ts +1 -1
- package/dist/utils/ObligationType.d.ts.map +1 -1
- package/dist/utils/constants.d.ts +0 -1
- package/dist/utils/constants.d.ts.map +1 -1
- package/dist/utils/constants.js +1 -2
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/managerTypes.d.ts.map +1 -1
- package/dist/utils/managerTypes.js +52 -7
- package/dist/utils/managerTypes.js.map +1 -1
- package/dist/utils/oracle.d.ts +3 -3
- package/dist/utils/oracle.d.ts.map +1 -1
- package/dist/utils/oracle.js +3 -4
- package/dist/utils/oracle.js.map +1 -1
- package/package.json +2 -2
- package/src/classes/action.ts +211 -143
- package/src/classes/index.ts +0 -1
- package/src/classes/manager.ts +1 -27
- package/src/classes/market.ts +25 -34
- package/src/classes/obligation.ts +0 -6
- package/src/classes/types.ts +1 -1
- package/src/classes/vault.ts +22 -23
- package/src/client.ts +3 -8
- package/src/idl_codegen_kamino_vault/accounts/VaultState.ts +9 -17
- package/src/idl_codegen_kamino_vault/errors/custom.ts +0 -42
- package/src/idl_codegen_kamino_vault/instructions/giveUpPendingFees.ts +2 -2
- package/src/idl_codegen_kamino_vault/instructions/initVault.ts +0 -2
- package/src/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.ts +2 -2
- package/src/idl_codegen_kamino_vault/instructions/updateReserveAllocation.ts +2 -2
- package/src/idl_codegen_kamino_vault/instructions/updateSharesMetadata.ts +2 -2
- package/src/idl_codegen_kamino_vault/instructions/updateVaultConfig.ts +2 -2
- package/src/idl_codegen_kamino_vault/instructions/withdrawPendingFees.ts +2 -2
- package/src/idl_codegen_kamino_vault/types/VaultConfigField.ts +0 -30
- package/src/idl_codegen_kamino_vault/types/index.ts +0 -2
- package/src/idl_kamino_vault.json +8 -35
- package/src/lending_operations/repay_with_collateral_operations.ts +11 -15
- package/src/lending_operations/swap_collateral_operations.ts +7 -19
- package/src/leverage/operations.ts +66 -114
- package/src/leverage/types.ts +4 -4
- package/src/utils/ObligationType.ts +1 -1
- package/src/utils/constants.ts +0 -1
- package/src/utils/managerTypes.ts +52 -10
- package/src/utils/oracle.ts +6 -7
package/src/classes/action.ts
CHANGED
|
@@ -61,11 +61,11 @@ import {
|
|
|
61
61
|
isNotNullPubkey,
|
|
62
62
|
PublicKeySet,
|
|
63
63
|
getAssociatedTokenAddress,
|
|
64
|
-
|
|
64
|
+
ScopeRefresh,
|
|
65
65
|
createAtasIdempotent,
|
|
66
66
|
obligationFarmStatePda,
|
|
67
67
|
} from '../utils';
|
|
68
|
-
import {
|
|
68
|
+
import { KaminoMarket } from './market';
|
|
69
69
|
import { KaminoObligation } from './obligation';
|
|
70
70
|
import { KaminoReserve } from './reserve';
|
|
71
71
|
import { ReserveFarmKind } from '../idl_codegen/types';
|
|
@@ -73,7 +73,7 @@ import { farmsId } from '@kamino-finance/farms-sdk';
|
|
|
73
73
|
import { Reserve } from '../idl_codegen/accounts';
|
|
74
74
|
import { VanillaObligation } from '../utils/ObligationType';
|
|
75
75
|
import { PROGRAM_ID } from '../lib';
|
|
76
|
-
import {
|
|
76
|
+
import { U16_MAX } from '@kamino-finance/scope-sdk';
|
|
77
77
|
|
|
78
78
|
const SOL_PADDING_FOR_INTEREST = new BN('1000000');
|
|
79
79
|
|
|
@@ -411,7 +411,6 @@ export class KaminoAction {
|
|
|
411
411
|
owner: PublicKey,
|
|
412
412
|
obligation: KaminoObligation | ObligationType,
|
|
413
413
|
useV2Ixs: boolean,
|
|
414
|
-
scopeRefreshConfig: ScopePriceRefreshConfig | undefined,
|
|
415
414
|
extraComputeBudget: number = 1_000_000, // if > 0 then adds the ixn
|
|
416
415
|
includeAtaIxns: boolean = true, // if true it includes create and close wsol and token atas,
|
|
417
416
|
requestElevationGroup: boolean = false, // to be requested *before* the deposit
|
|
@@ -419,6 +418,7 @@ export class KaminoAction {
|
|
|
419
418
|
createLookupTable: boolean = true,
|
|
420
419
|
referrer: PublicKey = PublicKey.default,
|
|
421
420
|
currentSlot: number = 0,
|
|
421
|
+
scopeRefresh: ScopeRefresh = { includeScopeRefresh: false, scopeFeed: 'hubble' },
|
|
422
422
|
overrideElevationGroupRequest: number | undefined = undefined // if set, when an elevationgroup request is made, it will use this value
|
|
423
423
|
) {
|
|
424
424
|
const axn = await KaminoAction.initialize(
|
|
@@ -437,6 +437,16 @@ export class KaminoAction {
|
|
|
437
437
|
axn.addComputeBudgetIxn(extraComputeBudget);
|
|
438
438
|
}
|
|
439
439
|
|
|
440
|
+
const allReserves = new PublicKeySet<PublicKey>([
|
|
441
|
+
...axn.depositReserves,
|
|
442
|
+
...axn.borrowReserves,
|
|
443
|
+
axn.reserve.address,
|
|
444
|
+
]).toArray();
|
|
445
|
+
const tokenIds = axn.getTokenIdsForScopeRefresh(kaminoMarket, allReserves);
|
|
446
|
+
|
|
447
|
+
if (tokenIds.length > 0 && scopeRefresh.includeScopeRefresh) {
|
|
448
|
+
await axn.addScopeRefreshIxs(tokenIds, scopeRefresh.scopeFeed);
|
|
449
|
+
}
|
|
440
450
|
await axn.addSupportIxs(
|
|
441
451
|
'deposit',
|
|
442
452
|
includeAtaIxns,
|
|
@@ -444,7 +454,6 @@ export class KaminoAction {
|
|
|
444
454
|
includeUserMetadata,
|
|
445
455
|
addInitObligationForFarm,
|
|
446
456
|
useV2Ixs,
|
|
447
|
-
scopeRefreshConfig,
|
|
448
457
|
createLookupTable,
|
|
449
458
|
undefined,
|
|
450
459
|
overrideElevationGroupRequest
|
|
@@ -459,10 +468,36 @@ export class KaminoAction {
|
|
|
459
468
|
return axn;
|
|
460
469
|
}
|
|
461
470
|
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
471
|
+
getTokenIdsForScopeRefresh(kaminoMarket: KaminoMarket, reserves: PublicKey[]): number[] {
|
|
472
|
+
const tokenIds: number[] = [];
|
|
473
|
+
|
|
474
|
+
for (const reserveAddress of reserves) {
|
|
475
|
+
const reserve = kaminoMarket.getReserveByAddress(reserveAddress);
|
|
476
|
+
if (!reserve) {
|
|
477
|
+
throw new Error(`Reserve not found for reserve ${reserveAddress.toBase58()}`);
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
if (!reserve.state.config.tokenInfo.scopeConfiguration.priceFeed.equals(PublicKey.default)) {
|
|
481
|
+
reserve.state.config.tokenInfo.scopeConfiguration.priceChain.map((x) => {
|
|
482
|
+
if (x !== U16_MAX) {
|
|
483
|
+
tokenIds.push(x);
|
|
484
|
+
}
|
|
485
|
+
});
|
|
486
|
+
reserve.state.config.tokenInfo.scopeConfiguration.twapChain.map((x) => {
|
|
487
|
+
if (x !== U16_MAX) {
|
|
488
|
+
tokenIds.push(x);
|
|
489
|
+
}
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
return tokenIds;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
async addScopeRefreshIxs(tokens: number[], feed: string = 'hubble') {
|
|
498
|
+
this.preTxnIxsLabels.unshift(`refreshScopePrices`);
|
|
499
|
+
this.preTxnIxs.unshift(
|
|
500
|
+
await this.kaminoMarket.scope.refreshPriceListIx(
|
|
466
501
|
{
|
|
467
502
|
feed: feed,
|
|
468
503
|
},
|
|
@@ -478,7 +513,6 @@ export class KaminoAction {
|
|
|
478
513
|
owner: PublicKey,
|
|
479
514
|
obligation: KaminoObligation | ObligationType,
|
|
480
515
|
useV2Ixs: boolean,
|
|
481
|
-
scopeRefreshConfig: ScopePriceRefreshConfig | undefined,
|
|
482
516
|
extraComputeBudget: number = 1_000_000, // if > 0 then adds the ixn
|
|
483
517
|
includeAtaIxns: boolean = true, // if true it includes create and close wsol and token atas,
|
|
484
518
|
requestElevationGroup: boolean = false,
|
|
@@ -486,6 +520,7 @@ export class KaminoAction {
|
|
|
486
520
|
createLookupTable: boolean = true,
|
|
487
521
|
referrer: PublicKey = PublicKey.default,
|
|
488
522
|
currentSlot: number = 0,
|
|
523
|
+
scopeRefresh: ScopeRefresh = { includeScopeRefresh: false, scopeFeed: 'hubble' },
|
|
489
524
|
overrideElevationGroupRequest: number | undefined = undefined // if set, when an elevationgroup request is made, it will use this value
|
|
490
525
|
) {
|
|
491
526
|
const axn = await KaminoAction.initialize(
|
|
@@ -503,16 +538,15 @@ export class KaminoAction {
|
|
|
503
538
|
axn.addComputeBudgetIxn(extraComputeBudget);
|
|
504
539
|
}
|
|
505
540
|
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
}
|
|
541
|
+
const allReserves = new PublicKeySet<PublicKey>([
|
|
542
|
+
...axn.depositReserves,
|
|
543
|
+
...axn.borrowReserves,
|
|
544
|
+
axn.reserve.address,
|
|
545
|
+
]).toArray();
|
|
546
|
+
const tokenIds = axn.getTokenIdsForScopeRefresh(kaminoMarket, allReserves);
|
|
547
|
+
|
|
548
|
+
if (tokenIds.length > 0 && scopeRefresh.includeScopeRefresh) {
|
|
549
|
+
await axn.addScopeRefreshIxs(tokenIds, scopeRefresh.scopeFeed);
|
|
516
550
|
}
|
|
517
551
|
|
|
518
552
|
await axn.addSupportIxs(
|
|
@@ -522,7 +556,6 @@ export class KaminoAction {
|
|
|
522
556
|
includeUserMetadata,
|
|
523
557
|
addInitObligationForFarm,
|
|
524
558
|
useV2Ixs,
|
|
525
|
-
scopeRefreshConfig,
|
|
526
559
|
createLookupTable,
|
|
527
560
|
undefined,
|
|
528
561
|
overrideElevationGroupRequest
|
|
@@ -543,12 +576,12 @@ export class KaminoAction {
|
|
|
543
576
|
mint: PublicKey,
|
|
544
577
|
owner: PublicKey,
|
|
545
578
|
obligation: KaminoObligation | ObligationType,
|
|
546
|
-
scopeRefreshConfig: ScopePriceRefreshConfig | undefined,
|
|
547
579
|
extraComputeBudget: number = 1_000_000, // if > 0 then adds the ixn
|
|
548
580
|
includeAtaIxns: boolean = true, // if true it includes create and close wsol and token atas
|
|
549
581
|
requestElevationGroup: boolean = false,
|
|
550
582
|
referrer: PublicKey = PublicKey.default,
|
|
551
|
-
currentSlot: number = 0
|
|
583
|
+
currentSlot: number = 0,
|
|
584
|
+
scopeRefresh: ScopeRefresh = { includeScopeRefresh: false, scopeFeed: 'hubble' }
|
|
552
585
|
) {
|
|
553
586
|
const axn = await KaminoAction.initialize(
|
|
554
587
|
'mint',
|
|
@@ -566,6 +599,17 @@ export class KaminoAction {
|
|
|
566
599
|
axn.addComputeBudgetIxn(extraComputeBudget);
|
|
567
600
|
}
|
|
568
601
|
|
|
602
|
+
const allReserves = new PublicKeySet<PublicKey>([
|
|
603
|
+
...axn.depositReserves,
|
|
604
|
+
...axn.borrowReserves,
|
|
605
|
+
axn.reserve.address,
|
|
606
|
+
]).toArray();
|
|
607
|
+
const tokenIds = axn.getTokenIdsForScopeRefresh(kaminoMarket, allReserves);
|
|
608
|
+
|
|
609
|
+
if (tokenIds.length > 0 && scopeRefresh.includeScopeRefresh) {
|
|
610
|
+
await axn.addScopeRefreshIxs(tokenIds, scopeRefresh.scopeFeed);
|
|
611
|
+
}
|
|
612
|
+
|
|
569
613
|
await axn.addSupportIxs(
|
|
570
614
|
'mint',
|
|
571
615
|
includeAtaIxns,
|
|
@@ -573,7 +617,6 @@ export class KaminoAction {
|
|
|
573
617
|
false,
|
|
574
618
|
addInitObligationForFarm,
|
|
575
619
|
false,
|
|
576
|
-
scopeRefreshConfig,
|
|
577
620
|
false
|
|
578
621
|
);
|
|
579
622
|
axn.addDepositReserveLiquidityIx();
|
|
@@ -587,12 +630,12 @@ export class KaminoAction {
|
|
|
587
630
|
mint: PublicKey,
|
|
588
631
|
owner: PublicKey,
|
|
589
632
|
obligation: KaminoObligation | ObligationType,
|
|
590
|
-
scopeRefreshConfig: ScopePriceRefreshConfig | undefined,
|
|
591
633
|
extraComputeBudget: number = 1_000_000, // if > 0 then adds the ixn
|
|
592
634
|
includeAtaIxns: boolean = true, // if true it includes create and close wsol and token atas
|
|
593
635
|
requestElevationGroup: boolean = false,
|
|
594
636
|
referrer: PublicKey = PublicKey.default,
|
|
595
|
-
currentSlot: number = 0
|
|
637
|
+
currentSlot: number = 0,
|
|
638
|
+
scopeRefresh: ScopeRefresh = { includeScopeRefresh: false, scopeFeed: 'hubble' }
|
|
596
639
|
) {
|
|
597
640
|
const axn = await KaminoAction.initialize(
|
|
598
641
|
'redeem',
|
|
@@ -610,6 +653,17 @@ export class KaminoAction {
|
|
|
610
653
|
axn.addComputeBudgetIxn(extraComputeBudget);
|
|
611
654
|
}
|
|
612
655
|
|
|
656
|
+
const allReserves = new PublicKeySet<PublicKey>([
|
|
657
|
+
...axn.depositReserves,
|
|
658
|
+
...axn.borrowReserves,
|
|
659
|
+
axn.reserve.address,
|
|
660
|
+
]).toArray();
|
|
661
|
+
const tokenIds = axn.getTokenIdsForScopeRefresh(kaminoMarket, allReserves);
|
|
662
|
+
|
|
663
|
+
if (tokenIds.length > 0 && scopeRefresh.includeScopeRefresh) {
|
|
664
|
+
await axn.addScopeRefreshIxs(tokenIds, scopeRefresh.scopeFeed);
|
|
665
|
+
}
|
|
666
|
+
|
|
613
667
|
await axn.addSupportIxs(
|
|
614
668
|
'redeem',
|
|
615
669
|
includeAtaIxns,
|
|
@@ -617,7 +671,6 @@ export class KaminoAction {
|
|
|
617
671
|
false,
|
|
618
672
|
addInitObligationForFarm,
|
|
619
673
|
false,
|
|
620
|
-
scopeRefreshConfig,
|
|
621
674
|
false
|
|
622
675
|
);
|
|
623
676
|
axn.addRedeemReserveCollateralIx();
|
|
@@ -632,14 +685,14 @@ export class KaminoAction {
|
|
|
632
685
|
owner: PublicKey,
|
|
633
686
|
obligation: KaminoObligation | ObligationType,
|
|
634
687
|
useV2Ixs: boolean,
|
|
635
|
-
scopeRefreshConfig: ScopePriceRefreshConfig | undefined,
|
|
636
688
|
extraComputeBudget: number = 1_000_000, // if > 0 then adds the ixn
|
|
637
689
|
includeAtaIxns: boolean = true, // if true it includes create and close wsol and token atas
|
|
638
690
|
requestElevationGroup: boolean = false,
|
|
639
691
|
includeUserMetadata: boolean = true, // if true it includes user metadata
|
|
640
692
|
createLookupTable: boolean = true,
|
|
641
693
|
referrer: PublicKey = PublicKey.default,
|
|
642
|
-
currentSlot: number = 0
|
|
694
|
+
currentSlot: number = 0,
|
|
695
|
+
scopeRefresh: ScopeRefresh = { includeScopeRefresh: false, scopeFeed: 'hubble' }
|
|
643
696
|
) {
|
|
644
697
|
const axn = await KaminoAction.initialize(
|
|
645
698
|
'depositCollateral',
|
|
@@ -657,6 +710,17 @@ export class KaminoAction {
|
|
|
657
710
|
axn.addComputeBudgetIxn(extraComputeBudget);
|
|
658
711
|
}
|
|
659
712
|
|
|
713
|
+
const allReserves = new PublicKeySet<PublicKey>([
|
|
714
|
+
...axn.depositReserves,
|
|
715
|
+
...axn.borrowReserves,
|
|
716
|
+
axn.reserve.address,
|
|
717
|
+
]).toArray();
|
|
718
|
+
const tokenIds = axn.getTokenIdsForScopeRefresh(kaminoMarket, allReserves);
|
|
719
|
+
|
|
720
|
+
if (tokenIds.length > 0 && scopeRefresh.includeScopeRefresh) {
|
|
721
|
+
await axn.addScopeRefreshIxs(tokenIds, scopeRefresh.scopeFeed);
|
|
722
|
+
}
|
|
723
|
+
|
|
660
724
|
await axn.addSupportIxs(
|
|
661
725
|
'depositCollateral',
|
|
662
726
|
includeAtaIxns,
|
|
@@ -664,7 +728,6 @@ export class KaminoAction {
|
|
|
664
728
|
includeUserMetadata,
|
|
665
729
|
addInitObligationForFarm,
|
|
666
730
|
useV2Ixs,
|
|
667
|
-
scopeRefreshConfig,
|
|
668
731
|
createLookupTable
|
|
669
732
|
);
|
|
670
733
|
if (useV2Ixs) {
|
|
@@ -685,14 +748,14 @@ export class KaminoAction {
|
|
|
685
748
|
payer: PublicKey,
|
|
686
749
|
obligation: KaminoObligation | ObligationType,
|
|
687
750
|
useV2Ixs: boolean,
|
|
688
|
-
scopeRefreshConfig: ScopePriceRefreshConfig | undefined,
|
|
689
751
|
extraComputeBudget: number = 1_000_000, // if > 0 then adds the ixn
|
|
690
752
|
includeAtaIxns: boolean = true, // if true it includes create and close wsol and token atas,
|
|
691
753
|
requestElevationGroup: boolean = false,
|
|
692
754
|
includeUserMetadata: boolean = true, // if true it includes user metadata,
|
|
693
755
|
createLookupTable: boolean = true,
|
|
694
756
|
referrer: PublicKey = PublicKey.default,
|
|
695
|
-
currentSlot: number = 0
|
|
757
|
+
currentSlot: number = 0,
|
|
758
|
+
scopeRefresh: ScopeRefresh = { includeScopeRefresh: false, scopeFeed: 'hubble' }
|
|
696
759
|
) {
|
|
697
760
|
const axn = await KaminoAction.initializeMultiTokenAction(
|
|
698
761
|
kaminoMarket,
|
|
@@ -715,17 +778,18 @@ export class KaminoAction {
|
|
|
715
778
|
axn.addComputeBudgetIxn(extraComputeBudget);
|
|
716
779
|
}
|
|
717
780
|
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
781
|
+
const allReserves = new PublicKeySet<PublicKey>([
|
|
782
|
+
...axn.depositReserves,
|
|
783
|
+
...axn.borrowReserves,
|
|
784
|
+
axn.reserve.address,
|
|
785
|
+
axn.outflowReserve!.address,
|
|
786
|
+
]).toArray();
|
|
787
|
+
const tokenIds = axn.getTokenIdsForScopeRefresh(kaminoMarket, allReserves);
|
|
788
|
+
|
|
789
|
+
if (tokenIds.length > 0 && scopeRefresh.includeScopeRefresh) {
|
|
790
|
+
await axn.addScopeRefreshIxs(tokenIds, scopeRefresh.scopeFeed);
|
|
728
791
|
}
|
|
792
|
+
|
|
729
793
|
await axn.addSupportIxs(
|
|
730
794
|
'deposit',
|
|
731
795
|
includeAtaIxns,
|
|
@@ -733,7 +797,6 @@ export class KaminoAction {
|
|
|
733
797
|
includeUserMetadata,
|
|
734
798
|
addInitObligationForFarmForDeposit,
|
|
735
799
|
useV2Ixs,
|
|
736
|
-
undefined,
|
|
737
800
|
createLookupTable,
|
|
738
801
|
twoTokenAction
|
|
739
802
|
);
|
|
@@ -751,20 +814,6 @@ export class KaminoAction {
|
|
|
751
814
|
useV2Ixs
|
|
752
815
|
);
|
|
753
816
|
axn.addRefreshFarmsCleanupTxnIxsToCleanupIxs();
|
|
754
|
-
|
|
755
|
-
// Create the scope refresh ixn in here to ensure it's the first ixn in the txn
|
|
756
|
-
const allReserves = new PublicKeySet<PublicKey>([
|
|
757
|
-
...axn.depositReserves,
|
|
758
|
-
...axn.borrowReserves,
|
|
759
|
-
axn.reserve.address,
|
|
760
|
-
...(axn.outflowReserve ? [axn.outflowReserve.address] : []),
|
|
761
|
-
...(axn.preLoadedDepositReservesSameTx ? axn.preLoadedDepositReservesSameTx : []),
|
|
762
|
-
]).toArray();
|
|
763
|
-
const tokenIds = getTokenIdsForScopeRefresh(axn.kaminoMarket, allReserves);
|
|
764
|
-
|
|
765
|
-
if (tokenIds.length > 0 && scopeRefreshConfig) {
|
|
766
|
-
await axn.addScopeRefreshIxs(scopeRefreshConfig.scope, tokenIds, scopeRefreshConfig.scopeFeed);
|
|
767
|
-
}
|
|
768
817
|
return axn;
|
|
769
818
|
}
|
|
770
819
|
|
|
@@ -778,13 +827,13 @@ export class KaminoAction {
|
|
|
778
827
|
currentSlot: number,
|
|
779
828
|
obligation: KaminoObligation | ObligationType,
|
|
780
829
|
useV2Ixs: boolean,
|
|
781
|
-
scopeRefreshConfig: ScopePriceRefreshConfig | undefined,
|
|
782
830
|
extraComputeBudget: number = 1_000_000, // if > 0 then adds the ixn
|
|
783
831
|
includeAtaIxns: boolean = true, // if true it includes create and close wsol and token atas,
|
|
784
832
|
requestElevationGroup: boolean = false,
|
|
785
833
|
includeUserMetadata: boolean = true, // if true it includes user metadata,
|
|
786
834
|
createLookupTable: boolean = true,
|
|
787
|
-
referrer: PublicKey = PublicKey.default
|
|
835
|
+
referrer: PublicKey = PublicKey.default,
|
|
836
|
+
scopeRefresh: ScopeRefresh = { includeScopeRefresh: false, scopeFeed: 'hubble' }
|
|
788
837
|
) {
|
|
789
838
|
const axn = await KaminoAction.initializeMultiTokenAction(
|
|
790
839
|
kaminoMarket,
|
|
@@ -806,6 +855,18 @@ export class KaminoAction {
|
|
|
806
855
|
axn.addComputeBudgetIxn(extraComputeBudget);
|
|
807
856
|
}
|
|
808
857
|
|
|
858
|
+
const allReserves = new PublicKeySet<PublicKey>([
|
|
859
|
+
...axn.depositReserves,
|
|
860
|
+
...axn.borrowReserves,
|
|
861
|
+
axn.reserve.address,
|
|
862
|
+
axn.outflowReserve!.address,
|
|
863
|
+
]).toArray();
|
|
864
|
+
const tokenIds = axn.getTokenIdsForScopeRefresh(kaminoMarket, allReserves);
|
|
865
|
+
|
|
866
|
+
if (tokenIds.length > 0 && scopeRefresh.includeScopeRefresh) {
|
|
867
|
+
await axn.addScopeRefreshIxs(tokenIds, scopeRefresh.scopeFeed);
|
|
868
|
+
}
|
|
869
|
+
|
|
809
870
|
await axn.addSupportIxs(
|
|
810
871
|
'repay',
|
|
811
872
|
includeAtaIxns,
|
|
@@ -813,7 +874,6 @@ export class KaminoAction {
|
|
|
813
874
|
includeUserMetadata,
|
|
814
875
|
addInitObligationForFarmForRepay,
|
|
815
876
|
useV2Ixs,
|
|
816
|
-
undefined,
|
|
817
877
|
createLookupTable,
|
|
818
878
|
twoTokenAction
|
|
819
879
|
);
|
|
@@ -833,19 +893,6 @@ export class KaminoAction {
|
|
|
833
893
|
useV2Ixs
|
|
834
894
|
);
|
|
835
895
|
axn.addRefreshFarmsCleanupTxnIxsToCleanupIxs();
|
|
836
|
-
// Create the scope refresh ixn in here to ensure it's the first ixn in the txn
|
|
837
|
-
const allReserves = new PublicKeySet<PublicKey>([
|
|
838
|
-
...axn.depositReserves,
|
|
839
|
-
...axn.borrowReserves,
|
|
840
|
-
axn.reserve.address,
|
|
841
|
-
...(axn.outflowReserve ? [axn.outflowReserve.address] : []),
|
|
842
|
-
...(axn.preLoadedDepositReservesSameTx ? axn.preLoadedDepositReservesSameTx : []),
|
|
843
|
-
]).toArray();
|
|
844
|
-
const tokenIds = getTokenIdsForScopeRefresh(axn.kaminoMarket, allReserves);
|
|
845
|
-
|
|
846
|
-
if (tokenIds.length > 0 && scopeRefreshConfig) {
|
|
847
|
-
await axn.addScopeRefreshIxs(scopeRefreshConfig.scope, tokenIds, scopeRefreshConfig.scopeFeed);
|
|
848
|
-
}
|
|
849
896
|
return axn;
|
|
850
897
|
}
|
|
851
898
|
|
|
@@ -856,7 +903,6 @@ export class KaminoAction {
|
|
|
856
903
|
owner: PublicKey,
|
|
857
904
|
obligation: KaminoObligation | ObligationType,
|
|
858
905
|
useV2Ixs: boolean,
|
|
859
|
-
scopeRefreshConfig: ScopePriceRefreshConfig | undefined,
|
|
860
906
|
extraComputeBudget: number = 1_000_000, // if > 0 then adds the ixn
|
|
861
907
|
includeAtaIxns: boolean = true, // if true it includes create and close wsol and token atas,
|
|
862
908
|
requestElevationGroup: boolean = false, // to be requested *after* the withdraw
|
|
@@ -864,6 +910,7 @@ export class KaminoAction {
|
|
|
864
910
|
createLookupTable: boolean = true,
|
|
865
911
|
referrer: PublicKey = PublicKey.default,
|
|
866
912
|
currentSlot: number = 0,
|
|
913
|
+
scopeRefresh: ScopeRefresh | undefined = undefined,
|
|
867
914
|
overrideElevationGroupRequest?: number,
|
|
868
915
|
// Optional customizations which may be needed if the obligation was mutated by some previous ixn.
|
|
869
916
|
obligationCustomizations?: {
|
|
@@ -889,6 +936,17 @@ export class KaminoAction {
|
|
|
889
936
|
|
|
890
937
|
axn.depositReserves.push(...(obligationCustomizations?.addedDepositReserves || []));
|
|
891
938
|
|
|
939
|
+
const allReserves = new PublicKeySet<PublicKey>([
|
|
940
|
+
...axn.depositReserves,
|
|
941
|
+
...axn.borrowReserves,
|
|
942
|
+
axn.reserve.address,
|
|
943
|
+
]).toArray();
|
|
944
|
+
const tokenIds = axn.getTokenIdsForScopeRefresh(kaminoMarket, allReserves);
|
|
945
|
+
|
|
946
|
+
if (tokenIds.length > 0 && scopeRefresh && scopeRefresh.includeScopeRefresh) {
|
|
947
|
+
await axn.addScopeRefreshIxs(tokenIds, scopeRefresh.scopeFeed);
|
|
948
|
+
}
|
|
949
|
+
|
|
892
950
|
await axn.addSupportIxs(
|
|
893
951
|
'withdraw',
|
|
894
952
|
includeAtaIxns,
|
|
@@ -896,7 +954,6 @@ export class KaminoAction {
|
|
|
896
954
|
includeUserMetadata,
|
|
897
955
|
addInitObligationForFarm,
|
|
898
956
|
useV2Ixs,
|
|
899
|
-
scopeRefreshConfig,
|
|
900
957
|
createLookupTable,
|
|
901
958
|
false,
|
|
902
959
|
overrideElevationGroupRequest
|
|
@@ -936,7 +993,6 @@ export class KaminoAction {
|
|
|
936
993
|
owner: PublicKey,
|
|
937
994
|
obligation: KaminoObligation | ObligationType,
|
|
938
995
|
useV2Ixs: boolean,
|
|
939
|
-
scopeRefreshConfig: ScopePriceRefreshConfig | undefined,
|
|
940
996
|
currentSlot: number,
|
|
941
997
|
payer: PublicKey | undefined = undefined,
|
|
942
998
|
extraComputeBudget: number = 1_000_000,
|
|
@@ -944,7 +1000,8 @@ export class KaminoAction {
|
|
|
944
1000
|
requestElevationGroup: boolean = false,
|
|
945
1001
|
includeUserMetadata: boolean = true,
|
|
946
1002
|
createLookupTable: boolean = true,
|
|
947
|
-
referrer: PublicKey = PublicKey.default
|
|
1003
|
+
referrer: PublicKey = PublicKey.default,
|
|
1004
|
+
scopeRefresh: ScopeRefresh = { includeScopeRefresh: false, scopeFeed: 'hubble' }
|
|
948
1005
|
) {
|
|
949
1006
|
const axn = await KaminoAction.initialize(
|
|
950
1007
|
'repay',
|
|
@@ -963,6 +1020,17 @@ export class KaminoAction {
|
|
|
963
1020
|
axn.addComputeBudgetIxn(extraComputeBudget);
|
|
964
1021
|
}
|
|
965
1022
|
|
|
1023
|
+
const allReserves = new PublicKeySet<PublicKey>([
|
|
1024
|
+
...axn.depositReserves,
|
|
1025
|
+
...axn.borrowReserves,
|
|
1026
|
+
axn.reserve.address,
|
|
1027
|
+
]).toArray();
|
|
1028
|
+
const tokenIds = axn.getTokenIdsForScopeRefresh(kaminoMarket, allReserves);
|
|
1029
|
+
|
|
1030
|
+
if (tokenIds.length > 0 && scopeRefresh.includeScopeRefresh) {
|
|
1031
|
+
await axn.addScopeRefreshIxs(tokenIds, scopeRefresh.scopeFeed);
|
|
1032
|
+
}
|
|
1033
|
+
|
|
966
1034
|
await axn.addSupportIxs(
|
|
967
1035
|
'repay',
|
|
968
1036
|
includeAtaIxns,
|
|
@@ -970,7 +1038,6 @@ export class KaminoAction {
|
|
|
970
1038
|
includeUserMetadata,
|
|
971
1039
|
addInitObligationForFarm,
|
|
972
1040
|
useV2Ixs,
|
|
973
|
-
scopeRefreshConfig,
|
|
974
1041
|
createLookupTable
|
|
975
1042
|
);
|
|
976
1043
|
if (useV2Ixs) {
|
|
@@ -993,7 +1060,6 @@ export class KaminoAction {
|
|
|
993
1060
|
obligationOwner: PublicKey,
|
|
994
1061
|
obligation: KaminoObligation | ObligationType,
|
|
995
1062
|
useV2Ixs: boolean,
|
|
996
|
-
scopeRefreshConfig: ScopePriceRefreshConfig | undefined,
|
|
997
1063
|
extraComputeBudget: number = 1_000_000, // if > 0 then adds the ixn
|
|
998
1064
|
includeAtaIxns: boolean = true, // if true it includes create and close wsol and token atas, and creates all other token atas if they don't exist
|
|
999
1065
|
requestElevationGroup: boolean = false,
|
|
@@ -1001,7 +1067,8 @@ export class KaminoAction {
|
|
|
1001
1067
|
createLookupTable: boolean = true,
|
|
1002
1068
|
referrer: PublicKey = PublicKey.default,
|
|
1003
1069
|
maxAllowedLtvOverridePercent: number = 0,
|
|
1004
|
-
currentSlot: number = 0
|
|
1070
|
+
currentSlot: number = 0,
|
|
1071
|
+
scopeRefresh: ScopeRefresh = { includeScopeRefresh: false, scopeFeed: 'hubble' }
|
|
1005
1072
|
) {
|
|
1006
1073
|
const axn = await KaminoAction.initializeMultiTokenAction(
|
|
1007
1074
|
kaminoMarket,
|
|
@@ -1022,6 +1089,18 @@ export class KaminoAction {
|
|
|
1022
1089
|
axn.addComputeBudgetIxn(extraComputeBudget);
|
|
1023
1090
|
}
|
|
1024
1091
|
|
|
1092
|
+
const allReserves = new PublicKeySet<PublicKey>([
|
|
1093
|
+
...axn.depositReserves,
|
|
1094
|
+
...axn.borrowReserves,
|
|
1095
|
+
axn.reserve.address,
|
|
1096
|
+
axn.outflowReserve!.address,
|
|
1097
|
+
]).toArray();
|
|
1098
|
+
const tokenIds = axn.getTokenIdsForScopeRefresh(kaminoMarket, allReserves);
|
|
1099
|
+
|
|
1100
|
+
if (tokenIds.length > 0 && scopeRefresh.includeScopeRefresh) {
|
|
1101
|
+
await axn.addScopeRefreshIxs(tokenIds, scopeRefresh.scopeFeed);
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1025
1104
|
await axn.addSupportIxs(
|
|
1026
1105
|
'liquidate',
|
|
1027
1106
|
includeAtaIxns,
|
|
@@ -1029,7 +1108,6 @@ export class KaminoAction {
|
|
|
1029
1108
|
includeUserMetadata,
|
|
1030
1109
|
addInitObligationForFarm,
|
|
1031
1110
|
useV2Ixs,
|
|
1032
|
-
scopeRefreshConfig,
|
|
1033
1111
|
createLookupTable
|
|
1034
1112
|
);
|
|
1035
1113
|
if (useV2Ixs) {
|
|
@@ -1058,17 +1136,6 @@ export class KaminoAction {
|
|
|
1058
1136
|
axn.preTxnIxs.push(...createAtaIxs);
|
|
1059
1137
|
axn.preTxnIxsLabels.push(`createAtasIxs[${axn.userTokenAccountAddress.toString()}]`);
|
|
1060
1138
|
|
|
1061
|
-
if (!axn.referrer.equals(PublicKey.default)) {
|
|
1062
|
-
const referrerTokenState = referrerTokenStatePda(
|
|
1063
|
-
axn.referrer,
|
|
1064
|
-
axn.reserve.address,
|
|
1065
|
-
axn.kaminoMarket.programId
|
|
1066
|
-
)[0];
|
|
1067
|
-
const account = await axn.kaminoMarket.getConnection().getAccountInfo(referrerTokenState);
|
|
1068
|
-
if (!account) {
|
|
1069
|
-
axn.addInitReferrerTokenStateIx(axn.reserve, referrerTokenState);
|
|
1070
|
-
}
|
|
1071
|
-
}
|
|
1072
1139
|
axn.addRefreshReserveIxs([axn.reserve.address]);
|
|
1073
1140
|
axn.addWithdrawReferrerFeesIxs();
|
|
1074
1141
|
|
|
@@ -1257,8 +1324,8 @@ export class KaminoAction {
|
|
|
1257
1324
|
addDepositIxV2() {
|
|
1258
1325
|
const farmsAccounts = this.reserve.state.farmCollateral.equals(PublicKey.default)
|
|
1259
1326
|
? {
|
|
1260
|
-
obligationFarmUserState:
|
|
1261
|
-
reserveFarmState:
|
|
1327
|
+
obligationFarmUserState: PROGRAM_ID,
|
|
1328
|
+
reserveFarmState: PROGRAM_ID,
|
|
1262
1329
|
}
|
|
1263
1330
|
: {
|
|
1264
1331
|
obligationFarmUserState: obligationFarmStatePda(
|
|
@@ -1325,8 +1392,8 @@ export class KaminoAction {
|
|
|
1325
1392
|
addDepositObligationCollateralIxV2() {
|
|
1326
1393
|
const farmsAccounts = this.reserve.state.farmCollateral.equals(PublicKey.default)
|
|
1327
1394
|
? {
|
|
1328
|
-
obligationFarmUserState:
|
|
1329
|
-
reserveFarmState:
|
|
1395
|
+
obligationFarmUserState: PROGRAM_ID,
|
|
1396
|
+
reserveFarmState: PROGRAM_ID,
|
|
1330
1397
|
}
|
|
1331
1398
|
: {
|
|
1332
1399
|
obligationFarmUserState: obligationFarmStatePda(
|
|
@@ -1410,8 +1477,8 @@ export class KaminoAction {
|
|
|
1410
1477
|
|
|
1411
1478
|
const farmsAccounts = this.reserve.state.farmDebt.equals(PublicKey.default)
|
|
1412
1479
|
? {
|
|
1413
|
-
obligationFarmUserState:
|
|
1414
|
-
reserveFarmState:
|
|
1480
|
+
obligationFarmUserState: PROGRAM_ID,
|
|
1481
|
+
reserveFarmState: PROGRAM_ID,
|
|
1415
1482
|
}
|
|
1416
1483
|
: {
|
|
1417
1484
|
obligationFarmUserState: obligationFarmStatePda(this.getObligationPda(), this.reserve.state.farmDebt)[0],
|
|
@@ -1485,8 +1552,8 @@ export class KaminoAction {
|
|
|
1485
1552
|
async addWithdrawIxV2(collateralAmount: BN) {
|
|
1486
1553
|
const farmsAccounts = this.reserve.state.farmCollateral.equals(PublicKey.default)
|
|
1487
1554
|
? {
|
|
1488
|
-
obligationFarmUserState:
|
|
1489
|
-
reserveFarmState:
|
|
1555
|
+
obligationFarmUserState: PROGRAM_ID,
|
|
1556
|
+
reserveFarmState: PROGRAM_ID,
|
|
1490
1557
|
}
|
|
1491
1558
|
: {
|
|
1492
1559
|
obligationFarmUserState: obligationFarmStatePda(
|
|
@@ -1572,8 +1639,8 @@ export class KaminoAction {
|
|
|
1572
1639
|
|
|
1573
1640
|
const farmsAccounts = this.reserve.state.farmDebt.equals(PublicKey.default)
|
|
1574
1641
|
? {
|
|
1575
|
-
obligationFarmUserState:
|
|
1576
|
-
reserveFarmState:
|
|
1642
|
+
obligationFarmUserState: PROGRAM_ID,
|
|
1643
|
+
reserveFarmState: PROGRAM_ID,
|
|
1577
1644
|
}
|
|
1578
1645
|
: {
|
|
1579
1646
|
obligationFarmUserState: obligationFarmStatePda(this.getObligationPda(), this.reserve.state.farmDebt)[0],
|
|
@@ -1693,8 +1760,8 @@ export class KaminoAction {
|
|
|
1693
1760
|
async addDepositAndBorrowIxV2() {
|
|
1694
1761
|
const collateralFarmsAccounts = this.reserve.state.farmCollateral.equals(PublicKey.default)
|
|
1695
1762
|
? {
|
|
1696
|
-
obligationFarmUserState:
|
|
1697
|
-
reserveFarmState:
|
|
1763
|
+
obligationFarmUserState: PROGRAM_ID,
|
|
1764
|
+
reserveFarmState: PROGRAM_ID,
|
|
1698
1765
|
}
|
|
1699
1766
|
: {
|
|
1700
1767
|
obligationFarmUserState: obligationFarmStatePda(
|
|
@@ -1757,8 +1824,8 @@ export class KaminoAction {
|
|
|
1757
1824
|
|
|
1758
1825
|
const debtFarmsAccounts = this.outflowReserve.state.farmDebt.equals(PublicKey.default)
|
|
1759
1826
|
? {
|
|
1760
|
-
obligationFarmUserState:
|
|
1761
|
-
reserveFarmState:
|
|
1827
|
+
obligationFarmUserState: PROGRAM_ID,
|
|
1828
|
+
reserveFarmState: PROGRAM_ID,
|
|
1762
1829
|
}
|
|
1763
1830
|
: {
|
|
1764
1831
|
obligationFarmUserState: obligationFarmStatePda(
|
|
@@ -1886,8 +1953,8 @@ export class KaminoAction {
|
|
|
1886
1953
|
|
|
1887
1954
|
const debtFarmsAccounts = this.reserve.state.farmDebt.equals(PublicKey.default)
|
|
1888
1955
|
? {
|
|
1889
|
-
obligationFarmUserState:
|
|
1890
|
-
reserveFarmState:
|
|
1956
|
+
obligationFarmUserState: PROGRAM_ID,
|
|
1957
|
+
reserveFarmState: PROGRAM_ID,
|
|
1891
1958
|
}
|
|
1892
1959
|
: {
|
|
1893
1960
|
obligationFarmUserState: obligationFarmStatePda(this.getObligationPda(), this.reserve.state.farmDebt)[0],
|
|
@@ -1934,8 +2001,8 @@ export class KaminoAction {
|
|
|
1934
2001
|
|
|
1935
2002
|
const collateralFarmsAccounts = this.outflowReserve.state.farmCollateral.equals(PublicKey.default)
|
|
1936
2003
|
? {
|
|
1937
|
-
obligationFarmUserState:
|
|
1938
|
-
reserveFarmState:
|
|
2004
|
+
obligationFarmUserState: PROGRAM_ID,
|
|
2005
|
+
reserveFarmState: PROGRAM_ID,
|
|
1939
2006
|
}
|
|
1940
2007
|
: {
|
|
1941
2008
|
obligationFarmUserState: obligationFarmStatePda(
|
|
@@ -2043,8 +2110,8 @@ export class KaminoAction {
|
|
|
2043
2110
|
|
|
2044
2111
|
const collateralFarmsAccounts = this.outflowReserve.state.farmCollateral.equals(PublicKey.default)
|
|
2045
2112
|
? {
|
|
2046
|
-
obligationFarmUserState:
|
|
2047
|
-
reserveFarmState:
|
|
2113
|
+
obligationFarmUserState: PROGRAM_ID,
|
|
2114
|
+
reserveFarmState: PROGRAM_ID,
|
|
2048
2115
|
}
|
|
2049
2116
|
: {
|
|
2050
2117
|
obligationFarmUserState: obligationFarmStatePda(
|
|
@@ -2056,8 +2123,8 @@ export class KaminoAction {
|
|
|
2056
2123
|
|
|
2057
2124
|
const debtFarmsAccounts = this.reserve.state.farmDebt.equals(PublicKey.default)
|
|
2058
2125
|
? {
|
|
2059
|
-
obligationFarmUserState:
|
|
2060
|
-
reserveFarmState:
|
|
2126
|
+
obligationFarmUserState: PROGRAM_ID,
|
|
2127
|
+
reserveFarmState: PROGRAM_ID,
|
|
2061
2128
|
}
|
|
2062
2129
|
: {
|
|
2063
2130
|
obligationFarmUserState: obligationFarmStatePda(this.getObligationPda(), this.reserve.state.farmDebt)[0],
|
|
@@ -2433,7 +2500,6 @@ export class KaminoAction {
|
|
|
2433
2500
|
includeUserMetadata: boolean,
|
|
2434
2501
|
addInitObligationForFarm: boolean,
|
|
2435
2502
|
useV2Ixs: boolean,
|
|
2436
|
-
scopeRefreshConfig: ScopePriceRefreshConfig | undefined,
|
|
2437
2503
|
createLookupTable: boolean,
|
|
2438
2504
|
twoTokenAction: boolean = false,
|
|
2439
2505
|
overrideElevationGroupRequest?: number
|
|
@@ -2454,6 +2520,13 @@ export class KaminoAction {
|
|
|
2454
2520
|
this.addInitUserMetadataIxs(lookupTable);
|
|
2455
2521
|
}
|
|
2456
2522
|
|
|
2523
|
+
if (['borrow', 'withdrawReferrerFees'].includes(action)) {
|
|
2524
|
+
await this.addInitReferrerTokenStateIx(this.reserve);
|
|
2525
|
+
}
|
|
2526
|
+
// depositAndBorrow
|
|
2527
|
+
if (action === 'deposit' && this.outflowReserve) {
|
|
2528
|
+
await this.addInitReferrerTokenStateIx(this.outflowReserve);
|
|
2529
|
+
}
|
|
2457
2530
|
await this.addInitObligationIxs();
|
|
2458
2531
|
}
|
|
2459
2532
|
|
|
@@ -2467,19 +2540,6 @@ export class KaminoAction {
|
|
|
2467
2540
|
twoTokenAction,
|
|
2468
2541
|
overrideElevationGroupRequest
|
|
2469
2542
|
);
|
|
2470
|
-
|
|
2471
|
-
const allReserves = new PublicKeySet<PublicKey>([
|
|
2472
|
-
...this.depositReserves,
|
|
2473
|
-
...this.borrowReserves,
|
|
2474
|
-
this.reserve.address,
|
|
2475
|
-
...(this.outflowReserve ? [this.outflowReserve.address] : []),
|
|
2476
|
-
...(this.preLoadedDepositReservesSameTx ? this.preLoadedDepositReservesSameTx : []),
|
|
2477
|
-
]).toArray();
|
|
2478
|
-
const tokenIds = getTokenIdsForScopeRefresh(this.kaminoMarket, allReserves);
|
|
2479
|
-
|
|
2480
|
-
if (tokenIds.length > 0 && scopeRefreshConfig) {
|
|
2481
|
-
await this.addScopeRefreshIxs(scopeRefreshConfig.scope, tokenIds, scopeRefreshConfig.scopeFeed);
|
|
2482
|
-
}
|
|
2483
2543
|
}
|
|
2484
2544
|
|
|
2485
2545
|
private static optionalAccount(pubkey: PublicKey, programId: PublicKey = PROGRAM_ID): PublicKey {
|
|
@@ -2888,21 +2948,29 @@ export class KaminoAction {
|
|
|
2888
2948
|
this.setupIxsLabels.push(`initUserMetadata[${userMetadataAddress.toString()}]`);
|
|
2889
2949
|
}
|
|
2890
2950
|
|
|
2891
|
-
private addInitReferrerTokenStateIx(reserve: KaminoReserve
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2951
|
+
private async addInitReferrerTokenStateIx(reserve: KaminoReserve) {
|
|
2952
|
+
if (this.referrer.equals(PublicKey.default)) {
|
|
2953
|
+
return;
|
|
2954
|
+
}
|
|
2955
|
+
|
|
2956
|
+
const referrerTokenState = referrerTokenStatePda(this.referrer, reserve.address, this.kaminoMarket.programId)[0];
|
|
2957
|
+
const account = await this.kaminoMarket.getConnection().getAccountInfo(referrerTokenState);
|
|
2958
|
+
if (!account) {
|
|
2959
|
+
const initReferrerTokenStateIx = initReferrerTokenState(
|
|
2960
|
+
{
|
|
2961
|
+
lendingMarket: this.kaminoMarket.getAddress(),
|
|
2962
|
+
payer: this.owner,
|
|
2963
|
+
reserve: reserve.address,
|
|
2964
|
+
referrer: this.referrer,
|
|
2965
|
+
referrerTokenState,
|
|
2966
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
2967
|
+
systemProgram: SystemProgram.programId,
|
|
2968
|
+
},
|
|
2969
|
+
this.kaminoMarket.programId
|
|
2970
|
+
);
|
|
2971
|
+
this.setupIxs.unshift(initReferrerTokenStateIx);
|
|
2972
|
+
this.setupIxsLabels.unshift(`InitReferrerTokenState[${referrerTokenState.toString()} res=${reserve.address}]`);
|
|
2973
|
+
}
|
|
2906
2974
|
}
|
|
2907
2975
|
|
|
2908
2976
|
private addWithdrawReferrerFeesIxs() {
|