@kamino-finance/klend-sdk 5.10.33 → 5.10.35-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 +33 -26
- package/dist/classes/action.d.ts.map +1 -1
- package/dist/classes/action.js +614 -202
- package/dist/classes/action.js.map +1 -1
- package/dist/classes/manager.d.ts +4 -4
- package/dist/classes/manager.d.ts.map +1 -1
- package/dist/classes/manager.js +13 -4
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/reserve.d.ts +1 -1
- package/dist/classes/reserve.d.ts.map +1 -1
- package/dist/classes/reserve.js +2 -1
- package/dist/classes/reserve.js.map +1 -1
- package/dist/classes/types.d.ts +4 -0
- package/dist/classes/types.d.ts.map +1 -1
- package/dist/classes/utils.d.ts.map +1 -1
- package/dist/classes/utils.js +1 -2
- package/dist/classes/utils.js.map +1 -1
- package/dist/classes/vault.d.ts +4 -4
- package/dist/classes/vault.d.ts.map +1 -1
- package/dist/classes/vault.js +39 -26
- package/dist/classes/vault.js.map +1 -1
- package/dist/client_kamino_manager.d.ts.map +1 -1
- package/dist/client_kamino_manager.js +8 -3
- package/dist/client_kamino_manager.js.map +1 -1
- package/dist/idl.json +269 -156
- package/dist/idl_codegen/accounts/LendingMarket.d.ts +15 -0
- package/dist/idl_codegen/accounts/LendingMarket.d.ts.map +1 -1
- package/dist/idl_codegen/accounts/LendingMarket.js +11 -1
- package/dist/idl_codegen/accounts/LendingMarket.js.map +1 -1
- package/dist/idl_codegen/accounts/Obligation.d.ts +6 -0
- package/dist/idl_codegen/accounts/Obligation.d.ts.map +1 -1
- package/dist/idl_codegen/accounts/Obligation.js +8 -1
- package/dist/idl_codegen/accounts/Obligation.js.map +1 -1
- package/dist/idl_codegen/errors/custom.d.ts +51 -3
- package/dist/idl_codegen/errors/custom.d.ts.map +1 -1
- package/dist/idl_codegen/errors/custom.js +89 -5
- package/dist/idl_codegen/errors/custom.js.map +1 -1
- package/dist/idl_codegen/instructions/borrowObligationLiquidity.js +1 -1
- package/dist/idl_codegen/instructions/borrowObligationLiquidity.js.map +1 -1
- package/dist/idl_codegen/instructions/borrowObligationLiquidityV2.js +1 -1
- package/dist/idl_codegen/instructions/borrowObligationLiquidityV2.js.map +1 -1
- package/dist/idl_codegen/instructions/depositAndWithdraw.d.ts +52 -0
- package/dist/idl_codegen/instructions/depositAndWithdraw.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/depositAndWithdraw.js +219 -0
- package/dist/idl_codegen/instructions/depositAndWithdraw.js.map +1 -0
- package/dist/idl_codegen/instructions/depositReserveLiquidity.js +1 -1
- package/dist/idl_codegen/instructions/depositReserveLiquidity.js.map +1 -1
- package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateral.js +1 -1
- package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateral.js.map +1 -1
- package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateralV2.js +1 -1
- package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateralV2.js.map +1 -1
- package/dist/idl_codegen/instructions/index.d.ts +2 -2
- package/dist/idl_codegen/instructions/index.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/index.js +3 -3
- package/dist/idl_codegen/instructions/index.js.map +1 -1
- package/dist/idl_codegen/instructions/initFarmsForReserve.js +1 -1
- package/dist/idl_codegen/instructions/initFarmsForReserve.js.map +1 -1
- package/dist/idl_codegen/instructions/initObligationFarmsForReserve.js +1 -1
- package/dist/idl_codegen/instructions/initObligationFarmsForReserve.js.map +1 -1
- package/dist/idl_codegen/instructions/initReserve.d.ts +1 -0
- package/dist/idl_codegen/instructions/initReserve.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/initReserve.js +5 -0
- package/dist/idl_codegen/instructions/initReserve.js.map +1 -1
- package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.js +2 -2
- package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.js.map +1 -1
- package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateralV2.js +2 -2
- package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateralV2.js.map +1 -1
- package/dist/idl_codegen/instructions/redeemFees.js +1 -1
- package/dist/idl_codegen/instructions/redeemFees.js.map +1 -1
- package/dist/idl_codegen/instructions/redeemReserveCollateral.js +1 -1
- package/dist/idl_codegen/instructions/redeemReserveCollateral.js.map +1 -1
- package/dist/idl_codegen/instructions/refreshObligationFarmsForReserve.js +1 -1
- package/dist/idl_codegen/instructions/refreshObligationFarmsForReserve.js.map +1 -1
- package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeem.d.ts +9 -0
- package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeem.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeem.js +24 -3
- package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeem.js.map +1 -1
- package/dist/idl_codegen/instructions/repayObligationLiquidity.js +1 -1
- package/dist/idl_codegen/instructions/repayObligationLiquidity.js.map +1 -1
- package/dist/idl_codegen/instructions/repayObligationLiquidityV2.js +1 -1
- package/dist/idl_codegen/instructions/repayObligationLiquidityV2.js.map +1 -1
- package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.js +2 -2
- package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.js.map +1 -1
- package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.js +2 -2
- package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.js.map +1 -1
- package/dist/idl_codegen/instructions/withdrawProtocolFee.js +1 -1
- package/dist/idl_codegen/instructions/withdrawProtocolFee.js.map +1 -1
- package/dist/idl_codegen/instructions/withdrawReferrerFees.js +1 -1
- package/dist/idl_codegen/instructions/withdrawReferrerFees.js.map +1 -1
- package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts +13 -0
- package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts.map +1 -1
- package/dist/idl_codegen/types/UpdateLendingMarketMode.js +25 -1
- package/dist/idl_codegen/types/UpdateLendingMarketMode.js.map +1 -1
- package/dist/idl_codegen/types/index.d.ts +2 -2
- package/dist/idl_codegen/types/index.d.ts.map +1 -1
- package/dist/idl_codegen/types/index.js.map +1 -1
- package/dist/idl_codegen/zero_padding/ObligationZP.d.ts +12 -4
- package/dist/idl_codegen/zero_padding/ObligationZP.d.ts.map +1 -1
- package/dist/idl_codegen/zero_padding/ObligationZP.js +15 -8
- package/dist/idl_codegen/zero_padding/ObligationZP.js.map +1 -1
- package/dist/lending_operations/repay_with_collateral_operations.d.ts +3 -2
- package/dist/lending_operations/repay_with_collateral_operations.d.ts.map +1 -1
- package/dist/lending_operations/repay_with_collateral_operations.js +7 -6
- package/dist/lending_operations/repay_with_collateral_operations.js.map +1 -1
- package/dist/lending_operations/swap_collateral_operations.d.ts +5 -0
- package/dist/lending_operations/swap_collateral_operations.d.ts.map +1 -1
- package/dist/lending_operations/swap_collateral_operations.js +9 -5
- package/dist/lending_operations/swap_collateral_operations.js.map +1 -1
- package/dist/leverage/instructions.d.ts +1 -2
- package/dist/leverage/instructions.d.ts.map +1 -1
- package/dist/leverage/instructions.js +2 -6
- package/dist/leverage/instructions.js.map +1 -1
- package/dist/leverage/operations.d.ts +8 -8
- package/dist/leverage/operations.d.ts.map +1 -1
- package/dist/leverage/operations.js +46 -37
- package/dist/leverage/operations.js.map +1 -1
- package/dist/leverage/types.d.ts +4 -1
- package/dist/leverage/types.d.ts.map +1 -1
- package/dist/utils/ata.d.ts +1 -1
- package/dist/utils/ata.d.ts.map +1 -1
- package/dist/utils/ata.js +2 -2
- package/dist/utils/ata.js.map +1 -1
- package/dist/utils/constants.d.ts +4 -9
- package/dist/utils/constants.d.ts.map +1 -1
- package/dist/utils/constants.js +5 -10
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/instruction.d.ts.map +1 -1
- package/dist/utils/instruction.js +1 -3
- package/dist/utils/instruction.js.map +1 -1
- package/dist/utils/managerTypes.d.ts +1 -0
- package/dist/utils/managerTypes.d.ts.map +1 -1
- package/dist/utils/managerTypes.js.map +1 -1
- package/dist/utils/seeds.d.ts +5 -0
- package/dist/utils/seeds.d.ts.map +1 -1
- package/dist/utils/seeds.js +10 -1
- package/dist/utils/seeds.js.map +1 -1
- package/dist/utils/userMetadata.d.ts.map +1 -1
- package/dist/utils/userMetadata.js +8 -10
- package/dist/utils/userMetadata.js.map +1 -1
- package/package.json +6 -3
- package/src/classes/action.ts +789 -214
- package/src/classes/manager.ts +18 -4
- package/src/classes/reserve.ts +2 -0
- package/src/classes/types.ts +5 -0
- package/src/classes/utils.ts +3 -3
- package/src/classes/vault.ts +49 -37
- package/src/client.ts +7 -3
- package/src/client_kamino_manager.ts +10 -3
- package/src/idl.json +269 -156
- package/src/idl_codegen/accounts/LendingMarket.ts +21 -1
- package/src/idl_codegen/accounts/Obligation.ts +12 -1
- package/src/idl_codegen/errors/custom.ts +103 -4
- package/src/idl_codegen/instructions/borrowObligationLiquidity.ts +1 -1
- package/src/idl_codegen/instructions/borrowObligationLiquidityV2.ts +1 -1
- package/src/idl_codegen/instructions/depositAndWithdraw.ts +241 -0
- package/src/idl_codegen/instructions/depositReserveLiquidity.ts +1 -1
- package/src/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateral.ts +1 -1
- package/src/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateralV2.ts +1 -1
- package/src/idl_codegen/instructions/index.ts +4 -4
- package/src/idl_codegen/instructions/initFarmsForReserve.ts +1 -1
- package/src/idl_codegen/instructions/initObligationFarmsForReserve.ts +1 -1
- package/src/idl_codegen/instructions/initReserve.ts +6 -0
- package/src/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.ts +2 -2
- package/src/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateralV2.ts +2 -2
- package/src/idl_codegen/instructions/redeemFees.ts +1 -1
- package/src/idl_codegen/instructions/redeemReserveCollateral.ts +1 -1
- package/src/idl_codegen/instructions/refreshObligationFarmsForReserve.ts +1 -1
- package/src/idl_codegen/instructions/repayAndWithdrawAndRedeem.ts +33 -3
- package/src/idl_codegen/instructions/repayObligationLiquidity.ts +1 -1
- package/src/idl_codegen/instructions/repayObligationLiquidityV2.ts +1 -1
- package/src/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.ts +2 -2
- package/src/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.ts +2 -2
- package/src/idl_codegen/instructions/withdrawProtocolFee.ts +1 -1
- package/src/idl_codegen/instructions/withdrawReferrerFees.ts +1 -1
- package/src/idl_codegen/types/UpdateLendingMarketMode.ts +30 -0
- package/src/idl_codegen/types/index.ts +2 -0
- package/src/idl_codegen/zero_padding/ObligationZP.ts +18 -7
- package/src/lending_operations/repay_with_collateral_operations.ts +12 -3
- package/src/lending_operations/swap_collateral_operations.ts +17 -5
- package/src/leverage/instructions.ts +1 -6
- package/src/leverage/operations.ts +66 -29
- package/src/leverage/types.ts +4 -1
- package/src/utils/ata.ts +1 -1
- package/src/utils/constants.ts +5 -11
- package/src/utils/instruction.ts +1 -3
- package/src/utils/managerTypes.ts +1 -0
- package/src/utils/seeds.ts +13 -0
- package/src/utils/userMetadata.ts +21 -26
|
@@ -37,6 +37,15 @@ export interface RepayAndWithdrawAndRedeemAccounts {
|
|
|
37
37
|
liquidityTokenProgram: PublicKey
|
|
38
38
|
instructionSysvarAccount: PublicKey
|
|
39
39
|
}
|
|
40
|
+
collateralFarmsAccounts: {
|
|
41
|
+
obligationFarmUserState: PublicKey
|
|
42
|
+
reserveFarmState: PublicKey
|
|
43
|
+
}
|
|
44
|
+
debtFarmsAccounts: {
|
|
45
|
+
obligationFarmUserState: PublicKey
|
|
46
|
+
reserveFarmState: PublicKey
|
|
47
|
+
}
|
|
48
|
+
farmsProgram: PublicKey
|
|
40
49
|
}
|
|
41
50
|
|
|
42
51
|
export const layout = borsh.struct([
|
|
@@ -69,7 +78,7 @@ export function repayAndWithdrawAndRedeem(
|
|
|
69
78
|
{
|
|
70
79
|
pubkey: accounts.repayAccounts.reserveLiquidityMint,
|
|
71
80
|
isSigner: false,
|
|
72
|
-
isWritable:
|
|
81
|
+
isWritable: false,
|
|
73
82
|
},
|
|
74
83
|
{
|
|
75
84
|
pubkey: accounts.repayAccounts.reserveDestinationLiquidity,
|
|
@@ -94,7 +103,7 @@ export function repayAndWithdrawAndRedeem(
|
|
|
94
103
|
{
|
|
95
104
|
pubkey: accounts.withdrawAccounts.owner,
|
|
96
105
|
isSigner: true,
|
|
97
|
-
isWritable:
|
|
106
|
+
isWritable: true,
|
|
98
107
|
},
|
|
99
108
|
{
|
|
100
109
|
pubkey: accounts.withdrawAccounts.obligation,
|
|
@@ -119,7 +128,7 @@ export function repayAndWithdrawAndRedeem(
|
|
|
119
128
|
{
|
|
120
129
|
pubkey: accounts.withdrawAccounts.reserveLiquidityMint,
|
|
121
130
|
isSigner: false,
|
|
122
|
-
isWritable:
|
|
131
|
+
isWritable: false,
|
|
123
132
|
},
|
|
124
133
|
{
|
|
125
134
|
pubkey: accounts.withdrawAccounts.reserveSourceCollateral,
|
|
@@ -161,6 +170,27 @@ export function repayAndWithdrawAndRedeem(
|
|
|
161
170
|
isSigner: false,
|
|
162
171
|
isWritable: false,
|
|
163
172
|
},
|
|
173
|
+
{
|
|
174
|
+
pubkey: accounts.collateralFarmsAccounts.obligationFarmUserState,
|
|
175
|
+
isSigner: false,
|
|
176
|
+
isWritable: true,
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
pubkey: accounts.collateralFarmsAccounts.reserveFarmState,
|
|
180
|
+
isSigner: false,
|
|
181
|
+
isWritable: true,
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
pubkey: accounts.debtFarmsAccounts.obligationFarmUserState,
|
|
185
|
+
isSigner: false,
|
|
186
|
+
isWritable: true,
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
pubkey: accounts.debtFarmsAccounts.reserveFarmState,
|
|
190
|
+
isSigner: false,
|
|
191
|
+
isWritable: true,
|
|
192
|
+
},
|
|
193
|
+
{ pubkey: accounts.farmsProgram, isSigner: false, isWritable: false },
|
|
164
194
|
]
|
|
165
195
|
const identifier = Buffer.from([2, 54, 152, 3, 148, 96, 109, 218])
|
|
166
196
|
const buffer = Buffer.alloc(1000)
|
package/src/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.ts
CHANGED
|
@@ -33,7 +33,7 @@ export function withdrawObligationCollateralAndRedeemReserveCollateral(
|
|
|
33
33
|
programId: PublicKey = PROGRAM_ID
|
|
34
34
|
) {
|
|
35
35
|
const keys: Array<AccountMeta> = [
|
|
36
|
-
{ pubkey: accounts.owner, isSigner: true, isWritable:
|
|
36
|
+
{ pubkey: accounts.owner, isSigner: true, isWritable: true },
|
|
37
37
|
{ pubkey: accounts.obligation, isSigner: false, isWritable: true },
|
|
38
38
|
{ pubkey: accounts.lendingMarket, isSigner: false, isWritable: false },
|
|
39
39
|
{
|
|
@@ -45,7 +45,7 @@ export function withdrawObligationCollateralAndRedeemReserveCollateral(
|
|
|
45
45
|
{
|
|
46
46
|
pubkey: accounts.reserveLiquidityMint,
|
|
47
47
|
isSigner: false,
|
|
48
|
-
isWritable:
|
|
48
|
+
isWritable: false,
|
|
49
49
|
},
|
|
50
50
|
{
|
|
51
51
|
pubkey: accounts.reserveSourceCollateral,
|
package/src/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.ts
CHANGED
|
@@ -43,7 +43,7 @@ export function withdrawObligationCollateralAndRedeemReserveCollateralV2(
|
|
|
43
43
|
{
|
|
44
44
|
pubkey: accounts.withdrawAccounts.owner,
|
|
45
45
|
isSigner: true,
|
|
46
|
-
isWritable:
|
|
46
|
+
isWritable: true,
|
|
47
47
|
},
|
|
48
48
|
{
|
|
49
49
|
pubkey: accounts.withdrawAccounts.obligation,
|
|
@@ -68,7 +68,7 @@ export function withdrawObligationCollateralAndRedeemReserveCollateralV2(
|
|
|
68
68
|
{
|
|
69
69
|
pubkey: accounts.withdrawAccounts.reserveLiquidityMint,
|
|
70
70
|
isSigner: false,
|
|
71
|
-
isWritable:
|
|
71
|
+
isWritable: false,
|
|
72
72
|
},
|
|
73
73
|
{
|
|
74
74
|
pubkey: accounts.withdrawAccounts.reserveSourceCollateral,
|
|
@@ -486,6 +486,29 @@ export class UpdateIndividualAutodeleverageMarginCallPeriodSecs {
|
|
|
486
486
|
}
|
|
487
487
|
}
|
|
488
488
|
|
|
489
|
+
export interface UpdateInitialDepositAmountJSON {
|
|
490
|
+
kind: "UpdateInitialDepositAmount"
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
export class UpdateInitialDepositAmount {
|
|
494
|
+
static readonly discriminator = 21
|
|
495
|
+
static readonly kind = "UpdateInitialDepositAmount"
|
|
496
|
+
readonly discriminator = 21
|
|
497
|
+
readonly kind = "UpdateInitialDepositAmount"
|
|
498
|
+
|
|
499
|
+
toJSON(): UpdateInitialDepositAmountJSON {
|
|
500
|
+
return {
|
|
501
|
+
kind: "UpdateInitialDepositAmount",
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
toEncodable() {
|
|
506
|
+
return {
|
|
507
|
+
UpdateInitialDepositAmount: {},
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
|
|
489
512
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
490
513
|
export function fromDecoded(obj: any): types.UpdateLendingMarketModeKind {
|
|
491
514
|
if (typeof obj !== "object") {
|
|
@@ -555,6 +578,9 @@ export function fromDecoded(obj: any): types.UpdateLendingMarketModeKind {
|
|
|
555
578
|
if ("UpdateIndividualAutodeleverageMarginCallPeriodSecs" in obj) {
|
|
556
579
|
return new UpdateIndividualAutodeleverageMarginCallPeriodSecs()
|
|
557
580
|
}
|
|
581
|
+
if ("UpdateInitialDepositAmount" in obj) {
|
|
582
|
+
return new UpdateInitialDepositAmount()
|
|
583
|
+
}
|
|
558
584
|
|
|
559
585
|
throw new Error("Invalid enum object")
|
|
560
586
|
}
|
|
@@ -626,6 +652,9 @@ export function fromJSON(
|
|
|
626
652
|
case "UpdateIndividualAutodeleverageMarginCallPeriodSecs": {
|
|
627
653
|
return new UpdateIndividualAutodeleverageMarginCallPeriodSecs()
|
|
628
654
|
}
|
|
655
|
+
case "UpdateInitialDepositAmount": {
|
|
656
|
+
return new UpdateInitialDepositAmount()
|
|
657
|
+
}
|
|
629
658
|
}
|
|
630
659
|
}
|
|
631
660
|
|
|
@@ -652,6 +681,7 @@ export function layout(property?: string) {
|
|
|
652
681
|
borsh.struct([], "UpdatePaddingFields"),
|
|
653
682
|
borsh.struct([], "UpdateName"),
|
|
654
683
|
borsh.struct([], "UpdateIndividualAutodeleverageMarginCallPeriodSecs"),
|
|
684
|
+
borsh.struct([], "UpdateInitialDepositAmount"),
|
|
655
685
|
])
|
|
656
686
|
if (property !== undefined) {
|
|
657
687
|
return ret.replicate(property)
|
|
@@ -156,6 +156,7 @@ export type UpdateLendingMarketModeKind =
|
|
|
156
156
|
| UpdateLendingMarketMode.UpdatePaddingFields
|
|
157
157
|
| UpdateLendingMarketMode.UpdateName
|
|
158
158
|
| UpdateLendingMarketMode.UpdateIndividualAutodeleverageMarginCallPeriodSecs
|
|
159
|
+
| UpdateLendingMarketMode.UpdateInitialDepositAmount
|
|
159
160
|
export type UpdateLendingMarketModeJSON =
|
|
160
161
|
| UpdateLendingMarketMode.UpdateOwnerJSON
|
|
161
162
|
| UpdateLendingMarketMode.UpdateEmergencyModeJSON
|
|
@@ -178,6 +179,7 @@ export type UpdateLendingMarketModeJSON =
|
|
|
178
179
|
| UpdateLendingMarketMode.UpdatePaddingFieldsJSON
|
|
179
180
|
| UpdateLendingMarketMode.UpdateNameJSON
|
|
180
181
|
| UpdateLendingMarketMode.UpdateIndividualAutodeleverageMarginCallPeriodSecsJSON
|
|
182
|
+
| UpdateLendingMarketMode.UpdateInitialDepositAmountJSON
|
|
181
183
|
|
|
182
184
|
export { LastUpdate } from "./LastUpdate"
|
|
183
185
|
export type { LastUpdateFields, LastUpdateJSON } from "./LastUpdate"
|
|
@@ -48,13 +48,21 @@ export class ObligationZP {
|
|
|
48
48
|
readonly referrer: PublicKey
|
|
49
49
|
/** Marked = 1 if borrowing disabled, 0 = borrowing enabled */
|
|
50
50
|
readonly borrowingDisabled: number
|
|
51
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* A target LTV set by the risk council when marking this obligation for deleveraging.
|
|
53
|
+
* Only effective when `deleveraging_margin_call_started_slot != 0`.
|
|
54
|
+
* */
|
|
52
55
|
readonly autodeleverageTargetLtvPct: number
|
|
53
|
-
|
|
56
|
+
/** The lowest max LTV found amongst the collateral deposits */
|
|
57
|
+
readonly lowestReserveDepositMaxLtvPct: number
|
|
58
|
+
readonly reserved: Array<number>
|
|
54
59
|
readonly highestBorrowFactorPct: BN
|
|
55
|
-
/**
|
|
60
|
+
/**
|
|
61
|
+
* A timestamp at which the risk council most-recently marked this obligation for deleveraging.
|
|
62
|
+
* Zero if not currently subject to deleveraging.
|
|
63
|
+
* */
|
|
56
64
|
readonly autodeleverageMarginCallStartedTimestamp: BN
|
|
57
|
-
padding3: Array<BN> = new Array(0)
|
|
65
|
+
readonly padding3: Array<BN> = new Array(0)
|
|
58
66
|
|
|
59
67
|
static readonly layout = borsh.struct([
|
|
60
68
|
borsh.u64("tag"),
|
|
@@ -77,7 +85,8 @@ export class ObligationZP {
|
|
|
77
85
|
borsh.publicKey("referrer"),
|
|
78
86
|
borsh.u8("borrowingDisabled"),
|
|
79
87
|
borsh.u8("autodeleverageTargetLtvPct"),
|
|
80
|
-
borsh.
|
|
88
|
+
borsh.u8("lowestReserveDepositMaxLtvPct"),
|
|
89
|
+
borsh.array(borsh.u8(), 5, "reserved"),
|
|
81
90
|
borsh.u64("highestBorrowFactorPct"),
|
|
82
91
|
borsh.u64("autodeleverageMarginCallStartedTimestamp"),
|
|
83
92
|
])
|
|
@@ -109,7 +118,8 @@ export class ObligationZP {
|
|
|
109
118
|
this.referrer = fields.referrer
|
|
110
119
|
this.borrowingDisabled = fields.borrowingDisabled
|
|
111
120
|
this.autodeleverageTargetLtvPct = fields.autodeleverageTargetLtvPct
|
|
112
|
-
this.
|
|
121
|
+
this.lowestReserveDepositMaxLtvPct = fields.lowestReserveDepositMaxLtvPct
|
|
122
|
+
this.reserved = new Array<number>(0)
|
|
113
123
|
this.highestBorrowFactorPct = fields.highestBorrowFactorPct
|
|
114
124
|
this.autodeleverageMarginCallStartedTimestamp = fields.autodeleverageMarginCallStartedTimestamp
|
|
115
125
|
this.padding3 = new Array<BN>(0);
|
|
@@ -187,10 +197,11 @@ export class ObligationZP {
|
|
|
187
197
|
referrer: dec.referrer,
|
|
188
198
|
borrowingDisabled: dec.borrowingDisabled,
|
|
189
199
|
autodeleverageTargetLtvPct: dec.autodeleverageTargetLtvPct,
|
|
200
|
+
lowestReserveDepositMaxLtvPct: dec.lowestReserveDepositMaxLtvPct,
|
|
190
201
|
reserved: dec.reserved,
|
|
191
202
|
highestBorrowFactorPct: dec.highestBorrowFactorPct,
|
|
192
203
|
autodeleverageMarginCallStartedTimestamp: dec.autodeleverageMarginCallStartedTimestamp,
|
|
193
204
|
padding3: [],
|
|
194
205
|
})
|
|
195
206
|
}
|
|
196
|
-
}
|
|
207
|
+
}
|
|
@@ -52,6 +52,7 @@ interface RepayWithCollSwapInputsProps<QuoteResponse> {
|
|
|
52
52
|
isClosingPosition: boolean;
|
|
53
53
|
budgetAndPriorityFeeIxs?: TransactionInstruction[];
|
|
54
54
|
scopeRefresh?: ScopeRefresh;
|
|
55
|
+
useV2Ixs: boolean;
|
|
55
56
|
quoter: SwapQuoteProvider<QuoteResponse>;
|
|
56
57
|
}
|
|
57
58
|
|
|
@@ -67,6 +68,7 @@ export async function getRepayWithCollSwapInputs<QuoteResponse>({
|
|
|
67
68
|
isClosingPosition,
|
|
68
69
|
budgetAndPriorityFeeIxs,
|
|
69
70
|
scopeRefresh,
|
|
71
|
+
useV2Ixs,
|
|
70
72
|
}: RepayWithCollSwapInputsProps<QuoteResponse>): Promise<{
|
|
71
73
|
swapInputs: SwapInputs;
|
|
72
74
|
initialInputs: RepayWithCollInitialInputs<QuoteResponse>;
|
|
@@ -132,7 +134,8 @@ export async function getRepayWithCollSwapInputs<QuoteResponse>({
|
|
|
132
134
|
},
|
|
133
135
|
isClosingPosition,
|
|
134
136
|
repayAmountLamports,
|
|
135
|
-
inputAmountLamports
|
|
137
|
+
inputAmountLamports,
|
|
138
|
+
useV2Ixs
|
|
136
139
|
);
|
|
137
140
|
const uniqueKlendAccounts = uniqueAccounts(klendIxs);
|
|
138
141
|
|
|
@@ -189,6 +192,7 @@ export async function getRepayWithCollIxs<QuoteResponse>({
|
|
|
189
192
|
swapper,
|
|
190
193
|
referrer,
|
|
191
194
|
scopeRefresh,
|
|
195
|
+
useV2Ixs,
|
|
192
196
|
logger = console.log,
|
|
193
197
|
}: RepayWithCollIxsProps<QuoteResponse>): Promise<RepayWithCollIxsResponse<QuoteResponse>> {
|
|
194
198
|
const { swapInputs, initialInputs } = await getRepayWithCollSwapInputs({
|
|
@@ -203,6 +207,7 @@ export async function getRepayWithCollIxs<QuoteResponse>({
|
|
|
203
207
|
isClosingPosition,
|
|
204
208
|
budgetAndPriorityFeeIxs,
|
|
205
209
|
scopeRefresh,
|
|
210
|
+
useV2Ixs,
|
|
206
211
|
});
|
|
207
212
|
const { debtRepayAmountLamports, flashRepayAmountLamports, maxCollateralWithdrawLamports, swapQuote } = initialInputs;
|
|
208
213
|
const { inputAmountLamports: collSwapInLamports } = swapInputs;
|
|
@@ -243,7 +248,8 @@ export async function getRepayWithCollIxs<QuoteResponse>({
|
|
|
243
248
|
swapResponse,
|
|
244
249
|
isClosingPosition,
|
|
245
250
|
debtRepayAmountLamports,
|
|
246
|
-
swapInputs.inputAmountLamports
|
|
251
|
+
swapInputs.inputAmountLamports,
|
|
252
|
+
useV2Ixs
|
|
247
253
|
);
|
|
248
254
|
|
|
249
255
|
return {
|
|
@@ -266,7 +272,8 @@ async function buildRepayWithCollateralIxs(
|
|
|
266
272
|
swapQuoteIxs: SwapIxs,
|
|
267
273
|
isClosingPosition: boolean,
|
|
268
274
|
debtRepayAmountLamports: Decimal,
|
|
269
|
-
collWithdrawLamports: Decimal
|
|
275
|
+
collWithdrawLamports: Decimal,
|
|
276
|
+
useV2Ixs: boolean
|
|
270
277
|
): Promise<TransactionInstruction[]> {
|
|
271
278
|
// 1. Create atas & budget txns
|
|
272
279
|
const budgetIxns = budgetAndPriorityFeeIxs || getComputeBudgetAndPriorityFeeIxns(1_400_000);
|
|
@@ -306,10 +313,12 @@ async function buildRepayWithCollateralIxs(
|
|
|
306
313
|
obligation.state.owner,
|
|
307
314
|
currentSlot,
|
|
308
315
|
obligation,
|
|
316
|
+
useV2Ixs,
|
|
309
317
|
0,
|
|
310
318
|
false,
|
|
311
319
|
requestElevationGroup,
|
|
312
320
|
undefined,
|
|
321
|
+
undefined,
|
|
313
322
|
referrer,
|
|
314
323
|
scopeRefresh
|
|
315
324
|
);
|
|
@@ -16,11 +16,10 @@ import {
|
|
|
16
16
|
ScopeRefresh,
|
|
17
17
|
U64_MAX,
|
|
18
18
|
uniqueAccounts,
|
|
19
|
-
WRAPPED_SOL_MINT,
|
|
20
19
|
} from '../utils';
|
|
21
20
|
import { AddressLookupTableAccount, PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
22
21
|
import Decimal from 'decimal.js';
|
|
23
|
-
import { createCloseAccountInstruction, TOKEN_PROGRAM_ID } from '@solana/spl-token';
|
|
22
|
+
import { createCloseAccountInstruction, NATIVE_MINT, TOKEN_PROGRAM_ID } from '@solana/spl-token';
|
|
24
23
|
|
|
25
24
|
/**
|
|
26
25
|
* Inputs to the `getSwapCollIxns()` operation.
|
|
@@ -63,6 +62,7 @@ export interface SwapCollIxnsInputs<QuoteResponse> {
|
|
|
63
62
|
currentSlot: number;
|
|
64
63
|
budgetAndPriorityFeeIxns?: TransactionInstruction[];
|
|
65
64
|
scopeRefresh?: ScopeRefresh;
|
|
65
|
+
useV2Ixs: boolean;
|
|
66
66
|
quoter: SwapQuoteProvider<QuoteResponse>;
|
|
67
67
|
swapper: SwapIxsProvider<QuoteResponse>;
|
|
68
68
|
logger?: (msg: string, ...extra: any[]) => void;
|
|
@@ -82,6 +82,11 @@ export interface SwapCollIxnsOutputs<QuoteResponse> {
|
|
|
82
82
|
*/
|
|
83
83
|
lookupTables: AddressLookupTableAccount[];
|
|
84
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Whether the swap is using V2 instructions.
|
|
87
|
+
*/
|
|
88
|
+
useV2Ixs: boolean;
|
|
89
|
+
|
|
85
90
|
/**
|
|
86
91
|
* Informational-only details of the token amounts/fees/rates that were used during construction of `ixs`.
|
|
87
92
|
*/
|
|
@@ -168,6 +173,7 @@ export async function getSwapCollIxns<QuoteResponse>(
|
|
|
168
173
|
return {
|
|
169
174
|
ixs: listIxns(klendIxns, externalSwapIxns.ixns),
|
|
170
175
|
lookupTables: externalSwapIxns.luts,
|
|
176
|
+
useV2Ixs: context.useV2Ixs,
|
|
171
177
|
simulationDetails: {
|
|
172
178
|
flashLoan: {
|
|
173
179
|
targetCollFlashBorrowedAmount: klendIxns.simulationDetails.targetCollFlashBorrowedAmount,
|
|
@@ -198,6 +204,7 @@ type SwapCollContext<QuoteResponse> = {
|
|
|
198
204
|
swapper: SwapIxsProvider<QuoteResponse>;
|
|
199
205
|
referrer: PublicKey;
|
|
200
206
|
currentSlot: number;
|
|
207
|
+
useV2Ixs: boolean;
|
|
201
208
|
scopeRefresh: ScopeRefresh | undefined;
|
|
202
209
|
logger: (msg: string, ...extra: any[]) => void;
|
|
203
210
|
};
|
|
@@ -230,6 +237,7 @@ function extractArgsAndContext<QuoteResponse>(
|
|
|
230
237
|
referrer: inputs.referrer,
|
|
231
238
|
scopeRefresh: inputs.scopeRefresh,
|
|
232
239
|
currentSlot: inputs.currentSlot,
|
|
240
|
+
useV2Ixs: inputs.useV2Ixs,
|
|
233
241
|
},
|
|
234
242
|
];
|
|
235
243
|
}
|
|
@@ -321,11 +329,11 @@ function getAtaCreationIxns(context: SwapCollContext<any>) {
|
|
|
321
329
|
function getAtaCloseIxns(context: SwapCollContext<any>) {
|
|
322
330
|
const ataCloseIxns: TransactionInstruction[] = [];
|
|
323
331
|
if (
|
|
324
|
-
context.sourceCollReserve.getLiquidityMint().equals(
|
|
325
|
-
context.targetCollReserve.getLiquidityMint().equals(
|
|
332
|
+
context.sourceCollReserve.getLiquidityMint().equals(NATIVE_MINT) ||
|
|
333
|
+
context.targetCollReserve.getLiquidityMint().equals(NATIVE_MINT)
|
|
326
334
|
) {
|
|
327
335
|
const owner = context.obligation.state.owner;
|
|
328
|
-
const wsolAta = getAssociatedTokenAddress(
|
|
336
|
+
const wsolAta = getAssociatedTokenAddress(NATIVE_MINT, owner, false);
|
|
329
337
|
ataCloseIxns.push(createCloseAccountInstruction(wsolAta, owner, owner, [], TOKEN_PROGRAM_ID));
|
|
330
338
|
}
|
|
331
339
|
return ataCloseIxns;
|
|
@@ -371,10 +379,12 @@ async function getDepositTargetCollIxns(
|
|
|
371
379
|
context.targetCollReserve.getLiquidityMint(),
|
|
372
380
|
context.obligation.state.owner,
|
|
373
381
|
context.obligation,
|
|
382
|
+
context.useV2Ixs,
|
|
374
383
|
0, // no extra compute budget
|
|
375
384
|
false, // we do not need ATA ixns here (we construct and close them ourselves)
|
|
376
385
|
removesElevationGroup, // we may need to (temporarily) remove the elevation group; the same or a different one will be set on withdraw, if requested
|
|
377
386
|
false, // we are dealing with an existing obligation, no need to create user metadata
|
|
387
|
+
false, // we do not need to create a lookup table, dealing with an existing obligation
|
|
378
388
|
context.referrer,
|
|
379
389
|
context.currentSlot,
|
|
380
390
|
context.scopeRefresh,
|
|
@@ -419,10 +429,12 @@ async function getWithdrawSourceCollIxns(
|
|
|
419
429
|
context.sourceCollReserve.getLiquidityMint(),
|
|
420
430
|
context.obligation.state.owner,
|
|
421
431
|
context.obligation,
|
|
432
|
+
context.useV2Ixs,
|
|
422
433
|
0, // no extra compute budget
|
|
423
434
|
false, // we do not need ATA ixns here (we construct and close them ourselves)
|
|
424
435
|
requestedElevationGroup !== undefined, // the `elevationGroupIdToRequestAfterWithdraw()` has already decided on this
|
|
425
436
|
false, // we are dealing with an existing obligation, no need to create user metadata
|
|
437
|
+
false, // we do not need to create a lookup table, dealing with an existing obligation
|
|
426
438
|
context.referrer,
|
|
427
439
|
context.currentSlot,
|
|
428
440
|
undefined, // we have refreshed scope already, during depositing
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PublicKey, SYSVAR_INSTRUCTIONS_PUBKEY } from '@solana/web3.js';
|
|
2
|
+
import * as anchor from '@coral-xyz/anchor';
|
|
2
3
|
import { KaminoReserve } from '../classes';
|
|
3
4
|
import {
|
|
4
5
|
FlashBorrowReserveLiquidityArgs,
|
|
@@ -9,12 +10,6 @@ import {
|
|
|
9
10
|
flashRepayReserveLiquidity,
|
|
10
11
|
} from '../lib';
|
|
11
12
|
import Decimal from 'decimal.js';
|
|
12
|
-
import * as anchor from '@coral-xyz/anchor';
|
|
13
|
-
|
|
14
|
-
export const SOL_MINTS: Array<PublicKey> = [
|
|
15
|
-
new PublicKey('So11111111111111111111111111111111111111111'),
|
|
16
|
-
new PublicKey('So11111111111111111111111111111111111111112'),
|
|
17
|
-
];
|
|
18
13
|
|
|
19
14
|
export const getFlashLoanInstructions = (args: {
|
|
20
15
|
borrowIxnIndex: number;
|