@kamino-finance/klend-sdk 5.2.13 → 5.3.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.map +1 -1
- package/dist/classes/action.js +1 -2
- package/dist/classes/action.js.map +1 -1
- package/dist/classes/manager.js +22 -5
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/obligation.d.ts +2 -0
- package/dist/classes/obligation.d.ts.map +1 -1
- package/dist/classes/obligation.js +12 -6
- package/dist/classes/obligation.js.map +1 -1
- package/dist/classes/reserve.js +14 -14
- package/dist/classes/reserve.js.map +1 -1
- package/dist/classes/shared.d.ts +2 -2
- package/dist/classes/shared.d.ts.map +1 -1
- package/dist/classes/types.d.ts +1 -1
- package/dist/classes/types.d.ts.map +1 -1
- package/dist/classes/vault.d.ts +1 -1
- package/dist/classes/vault.d.ts.map +1 -1
- package/dist/classes/vault.js +16 -3
- package/dist/classes/vault.js.map +1 -1
- package/dist/client_kamino_manager.d.ts.map +1 -1
- package/dist/client_kamino_manager.js +44 -6
- package/dist/client_kamino_manager.js.map +1 -1
- package/dist/idl.json +310 -48
- package/dist/idl_codegen/accounts/LendingMarket.d.ts +48 -3
- package/dist/idl_codegen/accounts/LendingMarket.d.ts.map +1 -1
- package/dist/idl_codegen/accounts/LendingMarket.js +35 -8
- package/dist/idl_codegen/accounts/LendingMarket.js.map +1 -1
- package/dist/idl_codegen/accounts/Obligation.d.ts +30 -0
- package/dist/idl_codegen/accounts/Obligation.d.ts.map +1 -1
- package/dist/idl_codegen/accounts/Obligation.js +23 -2
- package/dist/idl_codegen/accounts/Obligation.js.map +1 -1
- package/dist/idl_codegen/accounts/Reserve.js +1 -1
- package/dist/idl_codegen/errors/custom.d.ts +33 -1
- package/dist/idl_codegen/errors/custom.d.ts.map +1 -1
- package/dist/idl_codegen/errors/custom.js +57 -1
- package/dist/idl_codegen/errors/custom.js.map +1 -1
- package/dist/idl_codegen/instructions/index.d.ts +7 -3
- package/dist/idl_codegen/instructions/index.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/index.js +7 -3
- package/dist/idl_codegen/instructions/index.js.map +1 -1
- package/dist/idl_codegen/instructions/initReferrerTokenState.d.ts +2 -5
- package/dist/idl_codegen/instructions/initReferrerTokenState.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/initReferrerTokenState.js +3 -32
- package/dist/idl_codegen/instructions/initReferrerTokenState.js.map +1 -1
- package/dist/idl_codegen/instructions/markObligationForDeleveraging.d.ts +12 -0
- package/dist/idl_codegen/instructions/markObligationForDeleveraging.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/markObligationForDeleveraging.js +47 -0
- package/dist/idl_codegen/instructions/markObligationForDeleveraging.js.map +1 -0
- package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeem.d.ts +38 -0
- package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeem.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeem.js +159 -0
- package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeem.js.map +1 -0
- package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.js +1 -1
- package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.js.map +1 -1
- package/dist/idl_codegen/types/ReserveConfig.d.ts +78 -20
- package/dist/idl_codegen/types/ReserveConfig.d.ts.map +1 -1
- package/dist/idl_codegen/types/ReserveConfig.js +45 -14
- package/dist/idl_codegen/types/ReserveConfig.js.map +1 -1
- package/dist/idl_codegen/types/ReserveLiquidity.d.ts +16 -16
- package/dist/idl_codegen/types/ReserveLiquidity.d.ts.map +1 -1
- package/dist/idl_codegen/types/ReserveLiquidity.js +16 -16
- package/dist/idl_codegen/types/ReserveLiquidity.js.map +1 -1
- package/dist/idl_codegen/types/UpdateConfigMode.d.ts +40 -14
- package/dist/idl_codegen/types/UpdateConfigMode.d.ts.map +1 -1
- package/dist/idl_codegen/types/UpdateConfigMode.js +71 -23
- package/dist/idl_codegen/types/UpdateConfigMode.js.map +1 -1
- package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts +37 -11
- package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts.map +1 -1
- package/dist/idl_codegen/types/UpdateLendingMarketMode.js +64 -16
- package/dist/idl_codegen/types/UpdateLendingMarketMode.js.map +1 -1
- package/dist/idl_codegen/types/index.d.ts +4 -4
- 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 +4 -0
- package/dist/idl_codegen/zero_padding/ObligationZP.d.ts.map +1 -1
- package/dist/idl_codegen/zero_padding/ObligationZP.js +10 -0
- package/dist/idl_codegen/zero_padding/ObligationZP.js.map +1 -1
- package/dist/lending_operations/repay_with_collateral_calcs.d.ts +4 -2
- package/dist/lending_operations/repay_with_collateral_calcs.d.ts.map +1 -1
- package/dist/lending_operations/repay_with_collateral_calcs.js +45 -52
- package/dist/lending_operations/repay_with_collateral_calcs.js.map +1 -1
- package/dist/lending_operations/repay_with_collateral_operations.d.ts +7 -0
- package/dist/lending_operations/repay_with_collateral_operations.d.ts.map +1 -1
- package/dist/lending_operations/repay_with_collateral_operations.js +13 -3
- package/dist/lending_operations/repay_with_collateral_operations.js.map +1 -1
- package/dist/pyth/accounts/PriceUpdateV2.d.ts +30 -0
- package/dist/pyth/accounts/PriceUpdateV2.d.ts.map +1 -0
- package/dist/pyth/accounts/PriceUpdateV2.js +104 -0
- package/dist/pyth/accounts/PriceUpdateV2.js.map +1 -0
- package/dist/pyth/accounts/index.d.ts +3 -0
- package/dist/pyth/accounts/index.d.ts.map +1 -0
- package/dist/pyth/accounts/index.js +6 -0
- package/dist/pyth/accounts/index.js.map +1 -0
- package/dist/pyth/types/PriceFeedMessage.d.ts +58 -0
- package/dist/pyth/types/PriceFeedMessage.d.ts.map +1 -0
- package/dist/pyth/types/PriceFeedMessage.js +118 -0
- package/dist/pyth/types/PriceFeedMessage.js.map +1 -0
- package/dist/pyth/types/VerificationLevel.d.ts +45 -0
- package/dist/pyth/types/VerificationLevel.d.ts.map +1 -0
- package/dist/pyth/types/VerificationLevel.js +105 -0
- package/dist/pyth/types/VerificationLevel.js.map +1 -0
- package/dist/pyth/types/index.d.ts +7 -0
- package/dist/pyth/types/index.d.ts.map +1 -0
- package/dist/pyth/types/index.js +31 -0
- package/dist/pyth/types/index.js.map +1 -0
- package/dist/referrals/instructions.d.ts.map +1 -1
- package/dist/referrals/instructions.js +1 -2
- package/dist/referrals/instructions.js.map +1 -1
- package/dist/utils/managerTypes.d.ts.map +1 -1
- package/dist/utils/managerTypes.js +5 -4
- package/dist/utils/managerTypes.js.map +1 -1
- package/dist/utils/oracle.d.ts.map +1 -1
- package/dist/utils/oracle.js +9 -14
- package/dist/utils/oracle.js.map +1 -1
- package/package.json +3 -4
- package/src/classes/action.ts +1 -3
- package/src/classes/manager.ts +29 -6
- package/src/classes/obligation.ts +15 -6
- package/src/classes/reserve.ts +16 -16
- package/src/classes/shared.ts +2 -2
- package/src/classes/types.ts +16 -17
- package/src/classes/vault.ts +18 -4
- package/src/client_kamino_manager.ts +61 -6
- package/src/idl_codegen/accounts/LendingMarket.ts +76 -13
- package/src/idl_codegen/accounts/Obligation.ts +47 -2
- package/src/idl_codegen/accounts/Reserve.ts +1 -1
- package/src/idl_codegen/errors/custom.ts +56 -0
- package/src/idl_codegen/instructions/index.ts +13 -6
- package/src/idl_codegen/instructions/initReferrerTokenState.ts +3 -15
- package/src/idl_codegen/instructions/markObligationForDeleveraging.ts +40 -0
- package/src/idl_codegen/instructions/repayAndWithdrawAndRedeem.ts +177 -0
- package/src/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.ts +1 -1
- package/src/idl_codegen/programId.ts +1 -1
- package/src/idl_codegen/types/ReserveConfig.ts +100 -28
- package/src/idl_codegen/types/ReserveLiquidity.ts +25 -24
- package/src/idl_codegen/types/UpdateConfigMode.ts +86 -26
- package/src/idl_codegen/types/UpdateLendingMarketMode.ts +77 -17
- package/src/idl_codegen/types/index.ts +14 -6
- package/src/idl_codegen/zero_padding/ObligationZP.ts +10 -0
- package/src/lending_operations/repay_with_collateral_calcs.ts +55 -61
- package/src/lending_operations/repay_with_collateral_operations.ts +24 -4
- package/src/leverage/operations.ts +1 -1
- package/src/pyth/accounts/PriceUpdateV2.ts +110 -0
- package/src/pyth/accounts/index.ts +2 -0
- package/src/pyth/types/PriceFeedMessage.ts +120 -0
- package/src/pyth/types/VerificationLevel.ts +98 -0
- package/src/pyth/types/index.ts +9 -0
- package/src/referrals/instructions.ts +1 -3
- package/src/utils/managerTypes.ts +5 -5
- package/src/utils/oracle.ts +9 -15
|
@@ -716,25 +716,25 @@ export class UpdateMinLiquidationBonusBps {
|
|
|
716
716
|
}
|
|
717
717
|
}
|
|
718
718
|
|
|
719
|
-
export interface
|
|
720
|
-
kind: "
|
|
719
|
+
export interface UpdateDeleveragingMarginCallPeriodJSON {
|
|
720
|
+
kind: "UpdateDeleveragingMarginCallPeriod"
|
|
721
721
|
}
|
|
722
722
|
|
|
723
|
-
export class
|
|
723
|
+
export class UpdateDeleveragingMarginCallPeriod {
|
|
724
724
|
static readonly discriminator = 31
|
|
725
|
-
static readonly kind = "
|
|
725
|
+
static readonly kind = "UpdateDeleveragingMarginCallPeriod"
|
|
726
726
|
readonly discriminator = 31
|
|
727
|
-
readonly kind = "
|
|
727
|
+
readonly kind = "UpdateDeleveragingMarginCallPeriod"
|
|
728
728
|
|
|
729
|
-
toJSON():
|
|
729
|
+
toJSON(): UpdateDeleveragingMarginCallPeriodJSON {
|
|
730
730
|
return {
|
|
731
|
-
kind: "
|
|
731
|
+
kind: "UpdateDeleveragingMarginCallPeriod",
|
|
732
732
|
}
|
|
733
733
|
}
|
|
734
734
|
|
|
735
735
|
toEncodable() {
|
|
736
736
|
return {
|
|
737
|
-
|
|
737
|
+
UpdateDeleveragingMarginCallPeriod: {},
|
|
738
738
|
}
|
|
739
739
|
}
|
|
740
740
|
}
|
|
@@ -808,25 +808,25 @@ export class UpdateElevationGroup {
|
|
|
808
808
|
}
|
|
809
809
|
}
|
|
810
810
|
|
|
811
|
-
export interface
|
|
812
|
-
kind: "
|
|
811
|
+
export interface UpdateDeleveragingThresholdSecsPerBpsJSON {
|
|
812
|
+
kind: "UpdateDeleveragingThresholdSecsPerBps"
|
|
813
813
|
}
|
|
814
814
|
|
|
815
|
-
export class
|
|
815
|
+
export class UpdateDeleveragingThresholdSecsPerBps {
|
|
816
816
|
static readonly discriminator = 35
|
|
817
|
-
static readonly kind = "
|
|
817
|
+
static readonly kind = "UpdateDeleveragingThresholdSecsPerBps"
|
|
818
818
|
readonly discriminator = 35
|
|
819
|
-
readonly kind = "
|
|
819
|
+
readonly kind = "UpdateDeleveragingThresholdSecsPerBps"
|
|
820
820
|
|
|
821
|
-
toJSON():
|
|
821
|
+
toJSON(): UpdateDeleveragingThresholdSecsPerBpsJSON {
|
|
822
822
|
return {
|
|
823
|
-
kind: "
|
|
823
|
+
kind: "UpdateDeleveragingThresholdSecsPerBps",
|
|
824
824
|
}
|
|
825
825
|
}
|
|
826
826
|
|
|
827
827
|
toEncodable() {
|
|
828
828
|
return {
|
|
829
|
-
|
|
829
|
+
UpdateDeleveragingThresholdSecsPerBps: {},
|
|
830
830
|
}
|
|
831
831
|
}
|
|
832
832
|
}
|
|
@@ -1084,6 +1084,52 @@ export class UpdateHostFixedInterestRateBps {
|
|
|
1084
1084
|
}
|
|
1085
1085
|
}
|
|
1086
1086
|
|
|
1087
|
+
export interface UpdateAutodeleverageEnabledJSON {
|
|
1088
|
+
kind: "UpdateAutodeleverageEnabled"
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
export class UpdateAutodeleverageEnabled {
|
|
1092
|
+
static readonly discriminator = 47
|
|
1093
|
+
static readonly kind = "UpdateAutodeleverageEnabled"
|
|
1094
|
+
readonly discriminator = 47
|
|
1095
|
+
readonly kind = "UpdateAutodeleverageEnabled"
|
|
1096
|
+
|
|
1097
|
+
toJSON(): UpdateAutodeleverageEnabledJSON {
|
|
1098
|
+
return {
|
|
1099
|
+
kind: "UpdateAutodeleverageEnabled",
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
toEncodable() {
|
|
1104
|
+
return {
|
|
1105
|
+
UpdateAutodeleverageEnabled: {},
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
export interface UpdateDeleveragingBonusIncreaseBpsPerDayJSON {
|
|
1111
|
+
kind: "UpdateDeleveragingBonusIncreaseBpsPerDay"
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
export class UpdateDeleveragingBonusIncreaseBpsPerDay {
|
|
1115
|
+
static readonly discriminator = 48
|
|
1116
|
+
static readonly kind = "UpdateDeleveragingBonusIncreaseBpsPerDay"
|
|
1117
|
+
readonly discriminator = 48
|
|
1118
|
+
readonly kind = "UpdateDeleveragingBonusIncreaseBpsPerDay"
|
|
1119
|
+
|
|
1120
|
+
toJSON(): UpdateDeleveragingBonusIncreaseBpsPerDayJSON {
|
|
1121
|
+
return {
|
|
1122
|
+
kind: "UpdateDeleveragingBonusIncreaseBpsPerDay",
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
toEncodable() {
|
|
1127
|
+
return {
|
|
1128
|
+
UpdateDeleveragingBonusIncreaseBpsPerDay: {},
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1087
1133
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1088
1134
|
export function fromDecoded(obj: any): types.UpdateConfigModeKind {
|
|
1089
1135
|
if (typeof obj !== "object") {
|
|
@@ -1183,8 +1229,8 @@ export function fromDecoded(obj: any): types.UpdateConfigModeKind {
|
|
|
1183
1229
|
if ("UpdateMinLiquidationBonusBps" in obj) {
|
|
1184
1230
|
return new UpdateMinLiquidationBonusBps()
|
|
1185
1231
|
}
|
|
1186
|
-
if ("
|
|
1187
|
-
return new
|
|
1232
|
+
if ("UpdateDeleveragingMarginCallPeriod" in obj) {
|
|
1233
|
+
return new UpdateDeleveragingMarginCallPeriod()
|
|
1188
1234
|
}
|
|
1189
1235
|
if ("UpdateBorrowFactor" in obj) {
|
|
1190
1236
|
return new UpdateBorrowFactor()
|
|
@@ -1195,8 +1241,8 @@ export function fromDecoded(obj: any): types.UpdateConfigModeKind {
|
|
|
1195
1241
|
if ("UpdateElevationGroup" in obj) {
|
|
1196
1242
|
return new UpdateElevationGroup()
|
|
1197
1243
|
}
|
|
1198
|
-
if ("
|
|
1199
|
-
return new
|
|
1244
|
+
if ("UpdateDeleveragingThresholdSecsPerBps" in obj) {
|
|
1245
|
+
return new UpdateDeleveragingThresholdSecsPerBps()
|
|
1200
1246
|
}
|
|
1201
1247
|
if ("DeprecatedUpdateMultiplierSideBoost" in obj) {
|
|
1202
1248
|
return new DeprecatedUpdateMultiplierSideBoost()
|
|
@@ -1231,6 +1277,12 @@ export function fromDecoded(obj: any): types.UpdateConfigModeKind {
|
|
|
1231
1277
|
if ("UpdateHostFixedInterestRateBps" in obj) {
|
|
1232
1278
|
return new UpdateHostFixedInterestRateBps()
|
|
1233
1279
|
}
|
|
1280
|
+
if ("UpdateAutodeleverageEnabled" in obj) {
|
|
1281
|
+
return new UpdateAutodeleverageEnabled()
|
|
1282
|
+
}
|
|
1283
|
+
if ("UpdateDeleveragingBonusIncreaseBpsPerDay" in obj) {
|
|
1284
|
+
return new UpdateDeleveragingBonusIncreaseBpsPerDay()
|
|
1285
|
+
}
|
|
1234
1286
|
|
|
1235
1287
|
throw new Error("Invalid enum object")
|
|
1236
1288
|
}
|
|
@@ -1332,8 +1384,8 @@ export function fromJSON(
|
|
|
1332
1384
|
case "UpdateMinLiquidationBonusBps": {
|
|
1333
1385
|
return new UpdateMinLiquidationBonusBps()
|
|
1334
1386
|
}
|
|
1335
|
-
case "
|
|
1336
|
-
return new
|
|
1387
|
+
case "UpdateDeleveragingMarginCallPeriod": {
|
|
1388
|
+
return new UpdateDeleveragingMarginCallPeriod()
|
|
1337
1389
|
}
|
|
1338
1390
|
case "UpdateBorrowFactor": {
|
|
1339
1391
|
return new UpdateBorrowFactor()
|
|
@@ -1344,8 +1396,8 @@ export function fromJSON(
|
|
|
1344
1396
|
case "UpdateElevationGroup": {
|
|
1345
1397
|
return new UpdateElevationGroup()
|
|
1346
1398
|
}
|
|
1347
|
-
case "
|
|
1348
|
-
return new
|
|
1399
|
+
case "UpdateDeleveragingThresholdSecsPerBps": {
|
|
1400
|
+
return new UpdateDeleveragingThresholdSecsPerBps()
|
|
1349
1401
|
}
|
|
1350
1402
|
case "DeprecatedUpdateMultiplierSideBoost": {
|
|
1351
1403
|
return new DeprecatedUpdateMultiplierSideBoost()
|
|
@@ -1380,6 +1432,12 @@ export function fromJSON(
|
|
|
1380
1432
|
case "UpdateHostFixedInterestRateBps": {
|
|
1381
1433
|
return new UpdateHostFixedInterestRateBps()
|
|
1382
1434
|
}
|
|
1435
|
+
case "UpdateAutodeleverageEnabled": {
|
|
1436
|
+
return new UpdateAutodeleverageEnabled()
|
|
1437
|
+
}
|
|
1438
|
+
case "UpdateDeleveragingBonusIncreaseBpsPerDay": {
|
|
1439
|
+
return new UpdateDeleveragingBonusIncreaseBpsPerDay()
|
|
1440
|
+
}
|
|
1383
1441
|
}
|
|
1384
1442
|
}
|
|
1385
1443
|
|
|
@@ -1416,11 +1474,11 @@ export function layout(property?: string) {
|
|
|
1416
1474
|
borsh.struct([], "UpdateDepositWithdrawalCapCurrentTotal"),
|
|
1417
1475
|
borsh.struct([], "UpdateBadDebtLiquidationBonusBps"),
|
|
1418
1476
|
borsh.struct([], "UpdateMinLiquidationBonusBps"),
|
|
1419
|
-
borsh.struct([], "
|
|
1477
|
+
borsh.struct([], "UpdateDeleveragingMarginCallPeriod"),
|
|
1420
1478
|
borsh.struct([], "UpdateBorrowFactor"),
|
|
1421
1479
|
borsh.struct([], "UpdateAssetTier"),
|
|
1422
1480
|
borsh.struct([], "UpdateElevationGroup"),
|
|
1423
|
-
borsh.struct([], "
|
|
1481
|
+
borsh.struct([], "UpdateDeleveragingThresholdSecsPerBps"),
|
|
1424
1482
|
borsh.struct([], "DeprecatedUpdateMultiplierSideBoost"),
|
|
1425
1483
|
borsh.struct([], "DeprecatedUpdateMultiplierTagBoost"),
|
|
1426
1484
|
borsh.struct([], "UpdateReserveStatus"),
|
|
@@ -1432,6 +1490,8 @@ export function layout(property?: string) {
|
|
|
1432
1490
|
borsh.struct([], "UpdateBorrowLimitOutsideElevationGroup"),
|
|
1433
1491
|
borsh.struct([], "UpdateBorrowLimitsInElevationGroupAgainstThisReserve"),
|
|
1434
1492
|
borsh.struct([], "UpdateHostFixedInterestRateBps"),
|
|
1493
|
+
borsh.struct([], "UpdateAutodeleverageEnabled"),
|
|
1494
|
+
borsh.struct([], "UpdateDeleveragingBonusIncreaseBpsPerDay"),
|
|
1435
1495
|
])
|
|
1436
1496
|
if (property !== undefined) {
|
|
1437
1497
|
return ret.replicate(property)
|
|
@@ -371,25 +371,48 @@ export class UpdateMinNetValueObligationPostAction {
|
|
|
371
371
|
}
|
|
372
372
|
}
|
|
373
373
|
|
|
374
|
-
export interface
|
|
375
|
-
kind: "
|
|
374
|
+
export interface UpdateMinValueLtvSkipPriorityLiqCheckJSON {
|
|
375
|
+
kind: "UpdateMinValueLtvSkipPriorityLiqCheck"
|
|
376
376
|
}
|
|
377
377
|
|
|
378
|
-
export class
|
|
378
|
+
export class UpdateMinValueLtvSkipPriorityLiqCheck {
|
|
379
379
|
static readonly discriminator = 16
|
|
380
|
-
static readonly kind = "
|
|
380
|
+
static readonly kind = "UpdateMinValueLtvSkipPriorityLiqCheck"
|
|
381
381
|
readonly discriminator = 16
|
|
382
|
-
readonly kind = "
|
|
382
|
+
readonly kind = "UpdateMinValueLtvSkipPriorityLiqCheck"
|
|
383
383
|
|
|
384
|
-
toJSON():
|
|
384
|
+
toJSON(): UpdateMinValueLtvSkipPriorityLiqCheckJSON {
|
|
385
385
|
return {
|
|
386
|
-
kind: "
|
|
386
|
+
kind: "UpdateMinValueLtvSkipPriorityLiqCheck",
|
|
387
387
|
}
|
|
388
388
|
}
|
|
389
389
|
|
|
390
390
|
toEncodable() {
|
|
391
391
|
return {
|
|
392
|
-
|
|
392
|
+
UpdateMinValueLtvSkipPriorityLiqCheck: {},
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
export interface UpdateMinValueBfSkipPriorityLiqCheckJSON {
|
|
398
|
+
kind: "UpdateMinValueBfSkipPriorityLiqCheck"
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
export class UpdateMinValueBfSkipPriorityLiqCheck {
|
|
402
|
+
static readonly discriminator = 17
|
|
403
|
+
static readonly kind = "UpdateMinValueBfSkipPriorityLiqCheck"
|
|
404
|
+
readonly discriminator = 17
|
|
405
|
+
readonly kind = "UpdateMinValueBfSkipPriorityLiqCheck"
|
|
406
|
+
|
|
407
|
+
toJSON(): UpdateMinValueBfSkipPriorityLiqCheckJSON {
|
|
408
|
+
return {
|
|
409
|
+
kind: "UpdateMinValueBfSkipPriorityLiqCheck",
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
toEncodable() {
|
|
414
|
+
return {
|
|
415
|
+
UpdateMinValueBfSkipPriorityLiqCheck: {},
|
|
393
416
|
}
|
|
394
417
|
}
|
|
395
418
|
}
|
|
@@ -399,9 +422,9 @@ export interface UpdatePaddingFieldsJSON {
|
|
|
399
422
|
}
|
|
400
423
|
|
|
401
424
|
export class UpdatePaddingFields {
|
|
402
|
-
static readonly discriminator =
|
|
425
|
+
static readonly discriminator = 18
|
|
403
426
|
static readonly kind = "UpdatePaddingFields"
|
|
404
|
-
readonly discriminator =
|
|
427
|
+
readonly discriminator = 18
|
|
405
428
|
readonly kind = "UpdatePaddingFields"
|
|
406
429
|
|
|
407
430
|
toJSON(): UpdatePaddingFieldsJSON {
|
|
@@ -422,9 +445,9 @@ export interface UpdateNameJSON {
|
|
|
422
445
|
}
|
|
423
446
|
|
|
424
447
|
export class UpdateName {
|
|
425
|
-
static readonly discriminator =
|
|
448
|
+
static readonly discriminator = 19
|
|
426
449
|
static readonly kind = "UpdateName"
|
|
427
|
-
readonly discriminator =
|
|
450
|
+
readonly discriminator = 19
|
|
428
451
|
readonly kind = "UpdateName"
|
|
429
452
|
|
|
430
453
|
toJSON(): UpdateNameJSON {
|
|
@@ -440,6 +463,29 @@ export class UpdateName {
|
|
|
440
463
|
}
|
|
441
464
|
}
|
|
442
465
|
|
|
466
|
+
export interface UpdateIndividualAutodeleverageMarginCallPeriodSecsJSON {
|
|
467
|
+
kind: "UpdateIndividualAutodeleverageMarginCallPeriodSecs"
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
export class UpdateIndividualAutodeleverageMarginCallPeriodSecs {
|
|
471
|
+
static readonly discriminator = 20
|
|
472
|
+
static readonly kind = "UpdateIndividualAutodeleverageMarginCallPeriodSecs"
|
|
473
|
+
readonly discriminator = 20
|
|
474
|
+
readonly kind = "UpdateIndividualAutodeleverageMarginCallPeriodSecs"
|
|
475
|
+
|
|
476
|
+
toJSON(): UpdateIndividualAutodeleverageMarginCallPeriodSecsJSON {
|
|
477
|
+
return {
|
|
478
|
+
kind: "UpdateIndividualAutodeleverageMarginCallPeriodSecs",
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
toEncodable() {
|
|
483
|
+
return {
|
|
484
|
+
UpdateIndividualAutodeleverageMarginCallPeriodSecs: {},
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
443
489
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
444
490
|
export function fromDecoded(obj: any): types.UpdateLendingMarketModeKind {
|
|
445
491
|
if (typeof obj !== "object") {
|
|
@@ -494,8 +540,11 @@ export function fromDecoded(obj: any): types.UpdateLendingMarketModeKind {
|
|
|
494
540
|
if ("UpdateMinNetValueObligationPostAction" in obj) {
|
|
495
541
|
return new UpdateMinNetValueObligationPostAction()
|
|
496
542
|
}
|
|
497
|
-
if ("
|
|
498
|
-
return new
|
|
543
|
+
if ("UpdateMinValueLtvSkipPriorityLiqCheck" in obj) {
|
|
544
|
+
return new UpdateMinValueLtvSkipPriorityLiqCheck()
|
|
545
|
+
}
|
|
546
|
+
if ("UpdateMinValueBfSkipPriorityLiqCheck" in obj) {
|
|
547
|
+
return new UpdateMinValueBfSkipPriorityLiqCheck()
|
|
499
548
|
}
|
|
500
549
|
if ("UpdatePaddingFields" in obj) {
|
|
501
550
|
return new UpdatePaddingFields()
|
|
@@ -503,6 +552,9 @@ export function fromDecoded(obj: any): types.UpdateLendingMarketModeKind {
|
|
|
503
552
|
if ("UpdateName" in obj) {
|
|
504
553
|
return new UpdateName()
|
|
505
554
|
}
|
|
555
|
+
if ("UpdateIndividualAutodeleverageMarginCallPeriodSecs" in obj) {
|
|
556
|
+
return new UpdateIndividualAutodeleverageMarginCallPeriodSecs()
|
|
557
|
+
}
|
|
506
558
|
|
|
507
559
|
throw new Error("Invalid enum object")
|
|
508
560
|
}
|
|
@@ -559,8 +611,11 @@ export function fromJSON(
|
|
|
559
611
|
case "UpdateMinNetValueObligationPostAction": {
|
|
560
612
|
return new UpdateMinNetValueObligationPostAction()
|
|
561
613
|
}
|
|
562
|
-
case "
|
|
563
|
-
return new
|
|
614
|
+
case "UpdateMinValueLtvSkipPriorityLiqCheck": {
|
|
615
|
+
return new UpdateMinValueLtvSkipPriorityLiqCheck()
|
|
616
|
+
}
|
|
617
|
+
case "UpdateMinValueBfSkipPriorityLiqCheck": {
|
|
618
|
+
return new UpdateMinValueBfSkipPriorityLiqCheck()
|
|
564
619
|
}
|
|
565
620
|
case "UpdatePaddingFields": {
|
|
566
621
|
return new UpdatePaddingFields()
|
|
@@ -568,6 +623,9 @@ export function fromJSON(
|
|
|
568
623
|
case "UpdateName": {
|
|
569
624
|
return new UpdateName()
|
|
570
625
|
}
|
|
626
|
+
case "UpdateIndividualAutodeleverageMarginCallPeriodSecs": {
|
|
627
|
+
return new UpdateIndividualAutodeleverageMarginCallPeriodSecs()
|
|
628
|
+
}
|
|
571
629
|
}
|
|
572
630
|
}
|
|
573
631
|
|
|
@@ -589,9 +647,11 @@ export function layout(property?: string) {
|
|
|
589
647
|
borsh.struct([], "UpdateAutodeleverageEnabled"),
|
|
590
648
|
borsh.struct([], "UpdateBorrowingDisabled"),
|
|
591
649
|
borsh.struct([], "UpdateMinNetValueObligationPostAction"),
|
|
592
|
-
borsh.struct([], "
|
|
650
|
+
borsh.struct([], "UpdateMinValueLtvSkipPriorityLiqCheck"),
|
|
651
|
+
borsh.struct([], "UpdateMinValueBfSkipPriorityLiqCheck"),
|
|
593
652
|
borsh.struct([], "UpdatePaddingFields"),
|
|
594
653
|
borsh.struct([], "UpdateName"),
|
|
654
|
+
borsh.struct([], "UpdateIndividualAutodeleverageMarginCallPeriodSecs"),
|
|
595
655
|
])
|
|
596
656
|
if (property !== undefined) {
|
|
597
657
|
return ret.replicate(property)
|
|
@@ -40,11 +40,11 @@ export type UpdateConfigModeKind =
|
|
|
40
40
|
| UpdateConfigMode.UpdateDepositWithdrawalCapCurrentTotal
|
|
41
41
|
| UpdateConfigMode.UpdateBadDebtLiquidationBonusBps
|
|
42
42
|
| UpdateConfigMode.UpdateMinLiquidationBonusBps
|
|
43
|
-
| UpdateConfigMode.
|
|
43
|
+
| UpdateConfigMode.UpdateDeleveragingMarginCallPeriod
|
|
44
44
|
| UpdateConfigMode.UpdateBorrowFactor
|
|
45
45
|
| UpdateConfigMode.UpdateAssetTier
|
|
46
46
|
| UpdateConfigMode.UpdateElevationGroup
|
|
47
|
-
| UpdateConfigMode.
|
|
47
|
+
| UpdateConfigMode.UpdateDeleveragingThresholdSecsPerBps
|
|
48
48
|
| UpdateConfigMode.DeprecatedUpdateMultiplierSideBoost
|
|
49
49
|
| UpdateConfigMode.DeprecatedUpdateMultiplierTagBoost
|
|
50
50
|
| UpdateConfigMode.UpdateReserveStatus
|
|
@@ -56,6 +56,8 @@ export type UpdateConfigModeKind =
|
|
|
56
56
|
| UpdateConfigMode.UpdateBorrowLimitOutsideElevationGroup
|
|
57
57
|
| UpdateConfigMode.UpdateBorrowLimitsInElevationGroupAgainstThisReserve
|
|
58
58
|
| UpdateConfigMode.UpdateHostFixedInterestRateBps
|
|
59
|
+
| UpdateConfigMode.UpdateAutodeleverageEnabled
|
|
60
|
+
| UpdateConfigMode.UpdateDeleveragingBonusIncreaseBpsPerDay
|
|
59
61
|
export type UpdateConfigModeJSON =
|
|
60
62
|
| UpdateConfigMode.UpdateLoanToValuePctJSON
|
|
61
63
|
| UpdateConfigMode.UpdateMaxLiquidationBonusBpsJSON
|
|
@@ -88,11 +90,11 @@ export type UpdateConfigModeJSON =
|
|
|
88
90
|
| UpdateConfigMode.UpdateDepositWithdrawalCapCurrentTotalJSON
|
|
89
91
|
| UpdateConfigMode.UpdateBadDebtLiquidationBonusBpsJSON
|
|
90
92
|
| UpdateConfigMode.UpdateMinLiquidationBonusBpsJSON
|
|
91
|
-
| UpdateConfigMode.
|
|
93
|
+
| UpdateConfigMode.UpdateDeleveragingMarginCallPeriodJSON
|
|
92
94
|
| UpdateConfigMode.UpdateBorrowFactorJSON
|
|
93
95
|
| UpdateConfigMode.UpdateAssetTierJSON
|
|
94
96
|
| UpdateConfigMode.UpdateElevationGroupJSON
|
|
95
|
-
| UpdateConfigMode.
|
|
97
|
+
| UpdateConfigMode.UpdateDeleveragingThresholdSecsPerBpsJSON
|
|
96
98
|
| UpdateConfigMode.DeprecatedUpdateMultiplierSideBoostJSON
|
|
97
99
|
| UpdateConfigMode.DeprecatedUpdateMultiplierTagBoostJSON
|
|
98
100
|
| UpdateConfigMode.UpdateReserveStatusJSON
|
|
@@ -104,6 +106,8 @@ export type UpdateConfigModeJSON =
|
|
|
104
106
|
| UpdateConfigMode.UpdateBorrowLimitOutsideElevationGroupJSON
|
|
105
107
|
| UpdateConfigMode.UpdateBorrowLimitsInElevationGroupAgainstThisReserveJSON
|
|
106
108
|
| UpdateConfigMode.UpdateHostFixedInterestRateBpsJSON
|
|
109
|
+
| UpdateConfigMode.UpdateAutodeleverageEnabledJSON
|
|
110
|
+
| UpdateConfigMode.UpdateDeleveragingBonusIncreaseBpsPerDayJSON
|
|
107
111
|
|
|
108
112
|
export { UpdateLendingMarketConfigValue }
|
|
109
113
|
|
|
@@ -147,9 +151,11 @@ export type UpdateLendingMarketModeKind =
|
|
|
147
151
|
| UpdateLendingMarketMode.UpdateAutodeleverageEnabled
|
|
148
152
|
| UpdateLendingMarketMode.UpdateBorrowingDisabled
|
|
149
153
|
| UpdateLendingMarketMode.UpdateMinNetValueObligationPostAction
|
|
150
|
-
| UpdateLendingMarketMode.
|
|
154
|
+
| UpdateLendingMarketMode.UpdateMinValueLtvSkipPriorityLiqCheck
|
|
155
|
+
| UpdateLendingMarketMode.UpdateMinValueBfSkipPriorityLiqCheck
|
|
151
156
|
| UpdateLendingMarketMode.UpdatePaddingFields
|
|
152
157
|
| UpdateLendingMarketMode.UpdateName
|
|
158
|
+
| UpdateLendingMarketMode.UpdateIndividualAutodeleverageMarginCallPeriodSecs
|
|
153
159
|
export type UpdateLendingMarketModeJSON =
|
|
154
160
|
| UpdateLendingMarketMode.UpdateOwnerJSON
|
|
155
161
|
| UpdateLendingMarketMode.UpdateEmergencyModeJSON
|
|
@@ -167,9 +173,11 @@ export type UpdateLendingMarketModeJSON =
|
|
|
167
173
|
| UpdateLendingMarketMode.UpdateAutodeleverageEnabledJSON
|
|
168
174
|
| UpdateLendingMarketMode.UpdateBorrowingDisabledJSON
|
|
169
175
|
| UpdateLendingMarketMode.UpdateMinNetValueObligationPostActionJSON
|
|
170
|
-
| UpdateLendingMarketMode.
|
|
176
|
+
| UpdateLendingMarketMode.UpdateMinValueLtvSkipPriorityLiqCheckJSON
|
|
177
|
+
| UpdateLendingMarketMode.UpdateMinValueBfSkipPriorityLiqCheckJSON
|
|
171
178
|
| UpdateLendingMarketMode.UpdatePaddingFieldsJSON
|
|
172
179
|
| UpdateLendingMarketMode.UpdateNameJSON
|
|
180
|
+
| UpdateLendingMarketMode.UpdateIndividualAutodeleverageMarginCallPeriodSecsJSON
|
|
173
181
|
|
|
174
182
|
export { LastUpdate } from "./LastUpdate"
|
|
175
183
|
export type { LastUpdateFields, LastUpdateJSON } from "./LastUpdate"
|
|
@@ -48,8 +48,12 @@ export class ObligationZP {
|
|
|
48
48
|
readonly referrer: PublicKey
|
|
49
49
|
/** Marked = 1 if borrowing disabled, 0 = borrowing enabled */
|
|
50
50
|
readonly borrowingDisabled: number
|
|
51
|
+
/** A target LTV set by the risk council when marking this obligation for deleveraging. Only effective when `deleveraging_margin_call_started_slot != 0`. */
|
|
52
|
+
readonly autodeleverageTargetLtvPct: number
|
|
51
53
|
reserved: Array<BN> = new Array(0)
|
|
52
54
|
highestBorrowFactorPct: BN
|
|
55
|
+
/** A timestamp at which the risk council most-recently marked this obligation for deleveraging. Zero if not currently subject to deleveraging. */
|
|
56
|
+
readonly autodeleverageMarginCallStartedTimestamp: BN
|
|
53
57
|
padding3: Array<BN> = new Array(0)
|
|
54
58
|
|
|
55
59
|
static readonly layout = borsh.struct([
|
|
@@ -72,8 +76,10 @@ export class ObligationZP {
|
|
|
72
76
|
borsh.u8("hasDebt"),
|
|
73
77
|
borsh.publicKey("referrer"),
|
|
74
78
|
borsh.u8("borrowingDisabled"),
|
|
79
|
+
borsh.u8("autodeleverageTargetLtvPct"),
|
|
75
80
|
borsh.array(borsh.u8(), 7, "reserved"),
|
|
76
81
|
borsh.u64("highestBorrowFactorPct"),
|
|
82
|
+
borsh.u64("autodeleverageMarginCallStartedTimestamp"),
|
|
77
83
|
])
|
|
78
84
|
|
|
79
85
|
constructor(fields: ObligationFields) {
|
|
@@ -102,8 +108,10 @@ export class ObligationZP {
|
|
|
102
108
|
this.hasDebt = fields.hasDebt
|
|
103
109
|
this.referrer = fields.referrer
|
|
104
110
|
this.borrowingDisabled = fields.borrowingDisabled
|
|
111
|
+
this.autodeleverageTargetLtvPct = fields.autodeleverageTargetLtvPct
|
|
105
112
|
this.reserved = new Array<BN>(0);
|
|
106
113
|
this.highestBorrowFactorPct = fields.highestBorrowFactorPct
|
|
114
|
+
this.autodeleverageMarginCallStartedTimestamp = fields.autodeleverageMarginCallStartedTimestamp
|
|
107
115
|
this.padding3 = new Array<BN>(0);
|
|
108
116
|
}
|
|
109
117
|
|
|
@@ -178,7 +186,9 @@ export class ObligationZP {
|
|
|
178
186
|
hasDebt: dec.hasDebt,
|
|
179
187
|
referrer: dec.referrer,
|
|
180
188
|
borrowingDisabled: dec.borrowingDisabled,
|
|
189
|
+
autodeleverageTargetLtvPct: dec.autodeleverageTargetLtvPct,
|
|
181
190
|
highestBorrowFactorPct: dec.highestBorrowFactorPct,
|
|
191
|
+
autodeleverageMarginCallStartedTimestamp: dec.autodeleverageMarginCallStartedTimestamp,
|
|
182
192
|
reserved: [],
|
|
183
193
|
padding3: [],
|
|
184
194
|
})
|
|
@@ -76,79 +76,73 @@ export const calcFlashRepayAmount = (props: {
|
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
export function calcMaxWithdrawCollateral(
|
|
79
|
-
|
|
79
|
+
market: KaminoMarket,
|
|
80
|
+
obligation: KaminoObligation,
|
|
80
81
|
collReserveAddr: PublicKey,
|
|
81
82
|
debtReserveAddr: PublicKey,
|
|
82
|
-
obligation: KaminoObligation,
|
|
83
83
|
repayAmountLamports: Decimal
|
|
84
84
|
): {
|
|
85
|
-
|
|
85
|
+
repayAmountLamports: Decimal;
|
|
86
86
|
withdrawableCollLamports: Decimal;
|
|
87
|
+
canWithdrawAllColl: boolean;
|
|
88
|
+
repayingAllDebt: boolean;
|
|
87
89
|
} {
|
|
88
|
-
const
|
|
89
|
-
const
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if (debtPosition.reserveAddress.equals(debtReserveAddr)) {
|
|
103
|
-
remainingDebtAmountLamports = remainingDebtAmountLamports.sub(repayAmountLamports);
|
|
104
|
-
}
|
|
105
|
-
const remainingDebtBfWeightedValue = remainingDebtAmountLamports
|
|
106
|
-
.ceil()
|
|
107
|
-
.div(debtReserve.getMintFactor())
|
|
108
|
-
.mul(debtBorrowFactor)
|
|
109
|
-
.mul(debtOraclePx);
|
|
110
|
-
totalRemainingDebtValue = totalRemainingDebtValue.add(remainingDebtBfWeightedValue);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
let canWithdrawRemainingColl = false;
|
|
114
|
-
if (totalRemainingDebtValue.lte(new Decimal(0)) && borrows.length === 1) {
|
|
115
|
-
canWithdrawRemainingColl = true;
|
|
90
|
+
const deposit = obligation.getDepositByReserve(collReserveAddr)!;
|
|
91
|
+
const borrow = obligation.getBorrowByReserve(debtReserveAddr)!;
|
|
92
|
+
const depositReserve = market.getReserveByAddress(deposit.reserveAddress)!;
|
|
93
|
+
const debtReserve = market.getReserveByAddress(borrow.reserveAddress)!;
|
|
94
|
+
const depositTotalLamports = deposit.amount.floor();
|
|
95
|
+
|
|
96
|
+
const remainingBorrowLamports = borrow.amount.sub(repayAmountLamports).ceil();
|
|
97
|
+
const remainingBorrowAmount = remainingBorrowLamports.div(debtReserve.getMintFactor());
|
|
98
|
+
let remainingBorrowsValue = remainingBorrowAmount.mul(debtReserve.getOracleMarketPrice());
|
|
99
|
+
if (obligation.getBorrows().length > 1) {
|
|
100
|
+
remainingBorrowsValue = obligation
|
|
101
|
+
.getBorrows()
|
|
102
|
+
.filter((p) => !p.reserveAddress.equals(borrow.reserveAddress))
|
|
103
|
+
.reduce((acc, b) => acc.add(b.marketValueRefreshed), new Decimal('0'));
|
|
116
104
|
}
|
|
117
105
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
.floor()
|
|
128
|
-
.div(otherCollReserve.getMintFactor())
|
|
129
|
-
.mul(otherCollOraclePx)
|
|
130
|
-
.mul(otherCollMaxLtv);
|
|
131
|
-
totalOtherCollateralValue = totalOtherCollateralValue.add(otherCollValue);
|
|
106
|
+
let remainingDepositsValueWithLtv = new Decimal('0');
|
|
107
|
+
if (obligation.getDeposits().length > 1) {
|
|
108
|
+
remainingDepositsValueWithLtv = obligation
|
|
109
|
+
.getDeposits()
|
|
110
|
+
.filter((p) => !p.reserveAddress.equals(deposit.reserveAddress))
|
|
111
|
+
.reduce((acc, d) => {
|
|
112
|
+
const { maxLtv } = obligation.getLtvForReserve(market, market.getReserveByAddress(d.reserveAddress)!);
|
|
113
|
+
return acc.add(d.marketValueRefreshed.mul(maxLtv));
|
|
114
|
+
}, new Decimal('0'));
|
|
132
115
|
}
|
|
133
116
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
const maxCollWithdrawAmount = numerator.div(denominator);
|
|
143
|
-
const maxCollateralWithdrawalAmountLamports = maxCollWithdrawAmount.mul(collReserve.getMintFactor()).floor();
|
|
144
|
-
|
|
145
|
-
let withdrawableCollLamports: Decimal;
|
|
146
|
-
if (canWithdrawRemainingColl) {
|
|
147
|
-
withdrawableCollLamports = Decimal.min(maxCollateralWithdrawalAmountLamports, collPosition.amount).floor();
|
|
117
|
+
// can withdraw all coll
|
|
118
|
+
if (remainingDepositsValueWithLtv.gte(remainingBorrowsValue)) {
|
|
119
|
+
return {
|
|
120
|
+
repayAmountLamports: repayAmountLamports,
|
|
121
|
+
withdrawableCollLamports: depositTotalLamports,
|
|
122
|
+
canWithdrawAllColl: true,
|
|
123
|
+
repayingAllDebt: repayAmountLamports.gte(borrow.amount),
|
|
124
|
+
};
|
|
148
125
|
} else {
|
|
149
|
-
|
|
126
|
+
const { maxLtv: collMaxLtv } = obligation.getLtvForReserve(
|
|
127
|
+
market,
|
|
128
|
+
market.getReserveByAddress(depositReserve.address)!
|
|
129
|
+
);
|
|
130
|
+
const numerator = deposit.marketValueRefreshed
|
|
131
|
+
.mul(collMaxLtv)
|
|
132
|
+
.add(remainingDepositsValueWithLtv)
|
|
133
|
+
.sub(remainingBorrowsValue);
|
|
134
|
+
|
|
135
|
+
const denominator = depositReserve.getOracleMarketPrice().mul(collMaxLtv);
|
|
136
|
+
const maxCollWithdrawAmount = numerator.div(denominator);
|
|
137
|
+
const withdrawableCollLamports = maxCollWithdrawAmount.mul(depositReserve.getMintFactor()).floor();
|
|
138
|
+
|
|
139
|
+
return {
|
|
140
|
+
repayAmountLamports: repayAmountLamports,
|
|
141
|
+
withdrawableCollLamports,
|
|
142
|
+
canWithdrawAllColl: false,
|
|
143
|
+
repayingAllDebt: repayAmountLamports.gte(borrow.amount),
|
|
144
|
+
};
|
|
150
145
|
}
|
|
151
|
-
return { canWithdrawRemainingColl, withdrawableCollLamports };
|
|
152
146
|
}
|
|
153
147
|
|
|
154
148
|
export function estimateDebtRepaymentWithColl(props: {
|