@kamino-finance/klend-sdk 5.13.18-beta.0 → 5.14.0-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/configItems.d.ts +137 -0
- package/dist/classes/configItems.d.ts.map +1 -0
- package/dist/classes/configItems.js +143 -0
- package/dist/classes/configItems.js.map +1 -0
- package/dist/classes/farm_utils.d.ts.map +1 -1
- package/dist/classes/farm_utils.js +3 -10
- package/dist/classes/farm_utils.js.map +1 -1
- package/dist/classes/manager.d.ts +4 -7
- package/dist/classes/manager.d.ts.map +1 -1
- package/dist/classes/manager.js +37 -292
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/obligation.d.ts +3 -1
- package/dist/classes/obligation.d.ts.map +1 -1
- package/dist/classes/obligation.js +4 -2
- package/dist/classes/obligation.js.map +1 -1
- package/dist/classes/obligationOrder.d.ts +1 -2
- package/dist/classes/obligationOrder.d.ts.map +1 -1
- package/dist/classes/obligationOrder.js +3 -16
- package/dist/classes/obligationOrder.js.map +1 -1
- package/dist/classes/reserve.d.ts +5 -14
- package/dist/classes/reserve.d.ts.map +1 -1
- package/dist/classes/reserve.js +91 -463
- package/dist/classes/reserve.js.map +1 -1
- package/dist/classes/utils.d.ts +1 -0
- package/dist/classes/utils.d.ts.map +1 -1
- package/dist/classes/utils.js +12 -0
- package/dist/classes/utils.js.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 +4 -5
- package/dist/classes/vault.js.map +1 -1
- package/dist/client_kamino_manager.d.ts.map +1 -1
- package/dist/client_kamino_manager.js +27 -26
- package/dist/client_kamino_manager.js.map +1 -1
- package/dist/idl.json +186 -9
- package/dist/idl_codegen/accounts/GlobalConfig.d.ts +40 -0
- package/dist/idl_codegen/accounts/GlobalConfig.d.ts.map +1 -0
- package/dist/idl_codegen/accounts/GlobalConfig.js +116 -0
- package/dist/idl_codegen/accounts/GlobalConfig.js.map +1 -0
- package/dist/idl_codegen/accounts/LendingMarket.d.ts +24 -3
- package/dist/idl_codegen/accounts/LendingMarket.d.ts.map +1 -1
- package/dist/idl_codegen/accounts/LendingMarket.js +25 -7
- package/dist/idl_codegen/accounts/LendingMarket.js.map +1 -1
- package/dist/idl_codegen/accounts/index.d.ts +2 -0
- package/dist/idl_codegen/accounts/index.d.ts.map +1 -1
- package/dist/idl_codegen/accounts/index.js +3 -1
- package/dist/idl_codegen/accounts/index.js.map +1 -1
- package/dist/idl_codegen/errors/custom.d.ts +25 -1
- package/dist/idl_codegen/errors/custom.d.ts.map +1 -1
- package/dist/idl_codegen/errors/custom.js +43 -1
- package/dist/idl_codegen/errors/custom.js.map +1 -1
- package/dist/idl_codegen/instructions/idlMissingTypes.d.ts +2 -1
- package/dist/idl_codegen/instructions/idlMissingTypes.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/idlMissingTypes.js +2 -1
- package/dist/idl_codegen/instructions/idlMissingTypes.js.map +1 -1
- package/dist/idl_codegen/instructions/index.d.ts +6 -0
- package/dist/idl_codegen/instructions/index.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/index.js +7 -1
- package/dist/idl_codegen/instructions/index.js.map +1 -1
- package/dist/idl_codegen/instructions/initGlobalConfig.d.ts +10 -0
- package/dist/idl_codegen/instructions/initGlobalConfig.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/initGlobalConfig.js +19 -0
- package/dist/idl_codegen/instructions/initGlobalConfig.js.map +1 -0
- package/dist/idl_codegen/instructions/updateGlobalConfig.d.ts +13 -0
- package/dist/idl_codegen/instructions/updateGlobalConfig.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/updateGlobalConfig.js +61 -0
- package/dist/idl_codegen/instructions/updateGlobalConfig.js.map +1 -0
- package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.d.ts +7 -0
- package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.js +16 -0
- package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.js.map +1 -0
- package/dist/idl_codegen/instructions/updateReserveConfig.d.ts +4 -3
- package/dist/idl_codegen/instructions/updateReserveConfig.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/updateReserveConfig.js +5 -3
- package/dist/idl_codegen/instructions/updateReserveConfig.js.map +1 -1
- package/dist/idl_codegen/instructions/withdrawProtocolFee.d.ts +2 -2
- package/dist/idl_codegen/instructions/withdrawProtocolFee.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/withdrawProtocolFee.js +2 -6
- package/dist/idl_codegen/instructions/withdrawProtocolFee.js.map +1 -1
- package/dist/idl_codegen/types/UpdateGlobalConfigMode.d.ts +32 -0
- package/dist/idl_codegen/types/UpdateGlobalConfigMode.d.ts.map +1 -0
- package/dist/idl_codegen/types/UpdateGlobalConfigMode.js +108 -0
- package/dist/idl_codegen/types/UpdateGlobalConfigMode.js.map +1 -0
- package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts +33 -7
- package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts.map +1 -1
- package/dist/idl_codegen/types/UpdateLendingMarketMode.js +60 -12
- package/dist/idl_codegen/types/UpdateLendingMarketMode.js.map +1 -1
- package/dist/idl_codegen/types/index.d.ts +6 -2
- package/dist/idl_codegen/types/index.d.ts.map +1 -1
- package/dist/idl_codegen/types/index.js +3 -1
- package/dist/idl_codegen/types/index.js.map +1 -1
- package/dist/lending_operations/repay_with_collateral_calcs.d.ts.map +1 -1
- package/dist/lending_operations/repay_with_collateral_calcs.js +2 -2
- package/dist/lending_operations/repay_with_collateral_calcs.js.map +1 -1
- package/dist/utils/lookupTable.d.ts.map +1 -1
- package/dist/utils/lookupTable.js +1 -6
- package/dist/utils/lookupTable.js.map +1 -1
- package/dist/utils/managerTypes.d.ts.map +1 -1
- package/dist/utils/managerTypes.js +10 -4
- package/dist/utils/managerTypes.js.map +1 -1
- package/dist/utils/seeds.d.ts +16 -0
- package/dist/utils/seeds.d.ts.map +1 -1
- package/dist/utils/seeds.js +23 -1
- package/dist/utils/seeds.js.map +1 -1
- package/package.json +1 -1
- package/src/classes/configItems.ts +229 -0
- package/src/classes/farm_utils.ts +3 -11
- package/src/classes/manager.ts +49 -392
- package/src/classes/obligation.ts +4 -9
- package/src/classes/obligationOrder.ts +3 -22
- package/src/classes/reserve.ts +119 -783
- package/src/classes/utils.ts +12 -0
- package/src/classes/vault.ts +6 -7
- package/src/client_kamino_manager.ts +42 -34
- package/src/idl.json +186 -9
- package/src/idl_codegen/accounts/GlobalConfig.ts +125 -0
- package/src/idl_codegen/accounts/LendingMarket.ts +41 -9
- package/src/idl_codegen/accounts/index.ts +2 -0
- package/src/idl_codegen/errors/custom.ts +45 -0
- package/src/idl_codegen/instructions/idlMissingTypes.ts +4 -2
- package/src/idl_codegen/instructions/index.ts +9 -0
- package/src/idl_codegen/instructions/initGlobalConfig.ts +30 -0
- package/src/idl_codegen/instructions/updateGlobalConfig.ts +47 -0
- package/src/idl_codegen/instructions/updateGlobalConfigAdmin.ts +24 -0
- package/src/idl_codegen/instructions/updateReserveConfig.ts +7 -5
- package/src/idl_codegen/instructions/withdrawProtocolFee.ts +4 -8
- package/src/idl_codegen/types/UpdateGlobalConfigMode.ts +90 -0
- package/src/idl_codegen/types/UpdateLendingMarketMode.ts +73 -13
- package/src/idl_codegen/types/index.ts +16 -2
- package/src/lending_operations/repay_with_collateral_calcs.ts +5 -2
- package/src/utils/lookupTable.ts +1 -7
- package/src/utils/managerTypes.ts +10 -4
- package/src/utils/seeds.ts +25 -0
package/src/classes/manager.ts
CHANGED
|
@@ -28,7 +28,6 @@ import {
|
|
|
28
28
|
} from './vault';
|
|
29
29
|
import {
|
|
30
30
|
AddAssetToMarketParams,
|
|
31
|
-
assertNever,
|
|
32
31
|
CreateKaminoMarketParams,
|
|
33
32
|
createReserveIxs,
|
|
34
33
|
ENV,
|
|
@@ -45,7 +44,6 @@ import {
|
|
|
45
44
|
KaminoReserve,
|
|
46
45
|
LendingMarket,
|
|
47
46
|
lendingMarketAuthPda,
|
|
48
|
-
LendingMarketFields,
|
|
49
47
|
MarketWithAddress,
|
|
50
48
|
parseForChangesReserveConfigAndGetIxs,
|
|
51
49
|
parseOracleType,
|
|
@@ -53,7 +51,6 @@ import {
|
|
|
53
51
|
PubkeyHashMap,
|
|
54
52
|
Reserve,
|
|
55
53
|
ReserveWithAddress,
|
|
56
|
-
sameLengthArrayEquals,
|
|
57
54
|
ScopeOracleConfig,
|
|
58
55
|
updateEntireReserveConfigIx,
|
|
59
56
|
updateLendingMarket,
|
|
@@ -65,12 +62,7 @@ import {
|
|
|
65
62
|
import { PROGRAM_ID } from '../idl_codegen/programId';
|
|
66
63
|
import { Scope, TokenMetadatas, U16_MAX } from '@kamino-finance/scope-sdk';
|
|
67
64
|
import BN from 'bn.js';
|
|
68
|
-
import {
|
|
69
|
-
ElevationGroup,
|
|
70
|
-
ReserveConfig,
|
|
71
|
-
UpdateLendingMarketMode,
|
|
72
|
-
UpdateLendingMarketModeKind,
|
|
73
|
-
} from '../idl_codegen/types';
|
|
65
|
+
import { ReserveConfig, UpdateLendingMarketMode, UpdateLendingMarketModeKind } from '../idl_codegen/types';
|
|
74
66
|
import Decimal from 'decimal.js';
|
|
75
67
|
import * as anchor from '@coral-xyz/anchor';
|
|
76
68
|
import { VaultState } from '../idl_codegen_kamino_vault/accounts';
|
|
@@ -96,6 +88,7 @@ import { FarmState } from '@kamino-finance/farms-sdk/dist';
|
|
|
96
88
|
import SwitchboardProgram from '@switchboard-xyz/sbv2-lite';
|
|
97
89
|
import { getSquadsMultisigAdminsAndThreshold, walletIsSquadsMultisig, WalletType } from '../utils/multisig';
|
|
98
90
|
import { decodeVaultState } from '../utils/vault';
|
|
91
|
+
import { ConfigUpdater } from './configItems';
|
|
99
92
|
|
|
100
93
|
/**
|
|
101
94
|
* KaminoManager is a class that provides a high-level interface to interact with the Kamino Lend and Kamino Vault programs, in order to create and manage a market, as well as vaults
|
|
@@ -391,7 +384,15 @@ export class KaminoManager {
|
|
|
391
384
|
const ixs: TransactionInstruction[] = [];
|
|
392
385
|
|
|
393
386
|
if (!reserveState || updateEntireConfig) {
|
|
394
|
-
ixs.push(
|
|
387
|
+
ixs.push(
|
|
388
|
+
updateEntireReserveConfigIx(
|
|
389
|
+
marketWithAddress.state.lendingMarketOwner,
|
|
390
|
+
marketWithAddress.address,
|
|
391
|
+
reserve,
|
|
392
|
+
config,
|
|
393
|
+
this._kaminoLendProgramId
|
|
394
|
+
)
|
|
395
|
+
);
|
|
395
396
|
} else {
|
|
396
397
|
ixs.push(
|
|
397
398
|
...parseForChangesReserveConfigAndGetIxs(
|
|
@@ -1247,383 +1248,51 @@ export class KaminoManager {
|
|
|
1247
1248
|
};
|
|
1248
1249
|
}
|
|
1249
1250
|
} // KaminoManager
|
|
1250
|
-
export type BaseLendingMarketKey = keyof LendingMarketFields;
|
|
1251
|
-
const EXCLUDED_LENDING_MARKET_KEYS = [
|
|
1252
|
-
'version',
|
|
1253
|
-
'bumpSeed',
|
|
1254
|
-
'reserved0',
|
|
1255
|
-
'reserved1',
|
|
1256
|
-
'padding1',
|
|
1257
|
-
'padding2',
|
|
1258
|
-
'elevationGroupPadding',
|
|
1259
|
-
'quoteCurrency',
|
|
1260
|
-
] as const;
|
|
1261
|
-
export type ExcludedLendingMarketKey = (typeof EXCLUDED_LENDING_MARKET_KEYS)[number];
|
|
1262
|
-
|
|
1263
|
-
function isExcludedLendingMarketKey(value: unknown): value is ExcludedLendingMarketKey {
|
|
1264
|
-
return EXCLUDED_LENDING_MARKET_KEYS.includes(value as ExcludedLendingMarketKey);
|
|
1265
|
-
}
|
|
1266
1251
|
|
|
1267
|
-
export
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
),
|
|
1296
|
-
});
|
|
1297
|
-
}
|
|
1298
|
-
break;
|
|
1299
|
-
case 'referralFeeBps':
|
|
1300
|
-
if (market.referralFeeBps !== newMarket.referralFeeBps) {
|
|
1301
|
-
updateLendingMarketIxsArgs.push({
|
|
1302
|
-
mode: UpdateLendingMarketMode.UpdateReferralFeeBps.discriminator,
|
|
1303
|
-
value: updateMarketConfigEncodedValue(
|
|
1304
|
-
UpdateLendingMarketMode.UpdateReferralFeeBps.discriminator,
|
|
1305
|
-
newMarket.referralFeeBps
|
|
1306
|
-
),
|
|
1307
|
-
});
|
|
1308
|
-
}
|
|
1309
|
-
break;
|
|
1310
|
-
case 'emergencyMode':
|
|
1311
|
-
if (market.emergencyMode !== newMarket.emergencyMode) {
|
|
1312
|
-
updateLendingMarketIxsArgs.push({
|
|
1313
|
-
mode: UpdateLendingMarketMode.UpdateEmergencyMode.discriminator,
|
|
1314
|
-
value: updateMarketConfigEncodedValue(
|
|
1315
|
-
UpdateLendingMarketMode.UpdateEmergencyMode.discriminator,
|
|
1316
|
-
newMarket.emergencyMode
|
|
1317
|
-
),
|
|
1318
|
-
});
|
|
1319
|
-
}
|
|
1320
|
-
break;
|
|
1321
|
-
case 'autodeleverageEnabled':
|
|
1322
|
-
if (market.autodeleverageEnabled !== newMarket.autodeleverageEnabled) {
|
|
1323
|
-
updateLendingMarketIxsArgs.push({
|
|
1324
|
-
mode: UpdateLendingMarketMode.UpdateAutodeleverageEnabled.discriminator,
|
|
1325
|
-
value: updateMarketConfigEncodedValue(
|
|
1326
|
-
UpdateLendingMarketMode.UpdateAutodeleverageEnabled.discriminator,
|
|
1327
|
-
newMarket.autodeleverageEnabled
|
|
1328
|
-
),
|
|
1329
|
-
});
|
|
1330
|
-
}
|
|
1331
|
-
break;
|
|
1332
|
-
case 'borrowDisabled':
|
|
1333
|
-
if (market.borrowDisabled !== newMarket.borrowDisabled) {
|
|
1334
|
-
updateLendingMarketIxsArgs.push({
|
|
1335
|
-
mode: UpdateLendingMarketMode.UpdateBorrowingDisabled.discriminator,
|
|
1336
|
-
value: updateMarketConfigEncodedValue(
|
|
1337
|
-
UpdateLendingMarketMode.UpdateBorrowingDisabled.discriminator,
|
|
1338
|
-
newMarket.borrowDisabled
|
|
1339
|
-
),
|
|
1340
|
-
});
|
|
1341
|
-
}
|
|
1342
|
-
break;
|
|
1343
|
-
case 'priceRefreshTriggerToMaxAgePct':
|
|
1344
|
-
if (market.priceRefreshTriggerToMaxAgePct !== newMarket.priceRefreshTriggerToMaxAgePct) {
|
|
1345
|
-
updateLendingMarketIxsArgs.push({
|
|
1346
|
-
mode: UpdateLendingMarketMode.UpdatePriceRefreshTriggerToMaxAgePct.discriminator,
|
|
1347
|
-
value: updateMarketConfigEncodedValue(
|
|
1348
|
-
UpdateLendingMarketMode.UpdatePriceRefreshTriggerToMaxAgePct.discriminator,
|
|
1349
|
-
newMarket.priceRefreshTriggerToMaxAgePct
|
|
1350
|
-
),
|
|
1351
|
-
});
|
|
1352
|
-
}
|
|
1353
|
-
break;
|
|
1354
|
-
case 'liquidationMaxDebtCloseFactorPct':
|
|
1355
|
-
if (market.liquidationMaxDebtCloseFactorPct !== newMarket.liquidationMaxDebtCloseFactorPct) {
|
|
1356
|
-
updateLendingMarketIxsArgs.push({
|
|
1357
|
-
mode: UpdateLendingMarketMode.UpdateLiquidationCloseFactor.discriminator,
|
|
1358
|
-
value: updateMarketConfigEncodedValue(
|
|
1359
|
-
UpdateLendingMarketMode.UpdateLiquidationCloseFactor.discriminator,
|
|
1360
|
-
newMarket.liquidationMaxDebtCloseFactorPct
|
|
1361
|
-
),
|
|
1362
|
-
});
|
|
1363
|
-
}
|
|
1364
|
-
break;
|
|
1365
|
-
case 'insolvencyRiskUnhealthyLtvPct':
|
|
1366
|
-
if (market.insolvencyRiskUnhealthyLtvPct !== newMarket.insolvencyRiskUnhealthyLtvPct) {
|
|
1367
|
-
updateLendingMarketIxsArgs.push({
|
|
1368
|
-
mode: UpdateLendingMarketMode.UpdateInsolvencyRiskLtv.discriminator,
|
|
1369
|
-
value: updateMarketConfigEncodedValue(
|
|
1370
|
-
UpdateLendingMarketMode.UpdateInsolvencyRiskLtv.discriminator,
|
|
1371
|
-
newMarket.insolvencyRiskUnhealthyLtvPct
|
|
1372
|
-
),
|
|
1373
|
-
});
|
|
1374
|
-
}
|
|
1375
|
-
break;
|
|
1376
|
-
case 'minFullLiquidationValueThreshold':
|
|
1377
|
-
if (!market.minFullLiquidationValueThreshold.eq(newMarket.minFullLiquidationValueThreshold)) {
|
|
1378
|
-
updateLendingMarketIxsArgs.push({
|
|
1379
|
-
mode: UpdateLendingMarketMode.UpdateMinFullLiquidationThreshold.discriminator,
|
|
1380
|
-
value: updateMarketConfigEncodedValue(
|
|
1381
|
-
UpdateLendingMarketMode.UpdateMinFullLiquidationThreshold.discriminator,
|
|
1382
|
-
newMarket.minFullLiquidationValueThreshold.toNumber()
|
|
1383
|
-
),
|
|
1384
|
-
});
|
|
1385
|
-
}
|
|
1386
|
-
break;
|
|
1387
|
-
case 'maxLiquidatableDebtMarketValueAtOnce':
|
|
1388
|
-
if (!market.maxLiquidatableDebtMarketValueAtOnce.eq(newMarket.maxLiquidatableDebtMarketValueAtOnce)) {
|
|
1389
|
-
updateLendingMarketIxsArgs.push({
|
|
1390
|
-
mode: UpdateLendingMarketMode.UpdateLiquidationMaxValue.discriminator,
|
|
1391
|
-
value: updateMarketConfigEncodedValue(
|
|
1392
|
-
UpdateLendingMarketMode.UpdateLiquidationMaxValue.discriminator,
|
|
1393
|
-
newMarket.maxLiquidatableDebtMarketValueAtOnce.toNumber()
|
|
1394
|
-
),
|
|
1395
|
-
});
|
|
1396
|
-
}
|
|
1397
|
-
break;
|
|
1398
|
-
case 'globalAllowedBorrowValue':
|
|
1399
|
-
if (!market.globalAllowedBorrowValue.eq(newMarket.globalAllowedBorrowValue)) {
|
|
1400
|
-
updateLendingMarketIxsArgs.push({
|
|
1401
|
-
mode: UpdateLendingMarketMode.UpdateGlobalAllowedBorrow.discriminator,
|
|
1402
|
-
value: updateMarketConfigEncodedValue(
|
|
1403
|
-
UpdateLendingMarketMode.UpdateGlobalAllowedBorrow.discriminator,
|
|
1404
|
-
newMarket.globalAllowedBorrowValue.toNumber()
|
|
1405
|
-
),
|
|
1406
|
-
});
|
|
1407
|
-
}
|
|
1408
|
-
break;
|
|
1409
|
-
case 'riskCouncil':
|
|
1410
|
-
if (!market.riskCouncil.equals(newMarket.riskCouncil)) {
|
|
1411
|
-
updateLendingMarketIxsArgs.push({
|
|
1412
|
-
mode: UpdateLendingMarketMode.UpdateRiskCouncil.discriminator,
|
|
1413
|
-
value: updateMarketConfigEncodedValue(
|
|
1414
|
-
UpdateLendingMarketMode.UpdateRiskCouncil.discriminator,
|
|
1415
|
-
newMarket.riskCouncil
|
|
1416
|
-
),
|
|
1417
|
-
});
|
|
1418
|
-
}
|
|
1419
|
-
break;
|
|
1420
|
-
case 'elevationGroups':
|
|
1421
|
-
let elevationGroupsDiffs = 0;
|
|
1422
|
-
for (let i = 0; i < market.elevationGroups.length; i++) {
|
|
1423
|
-
if (
|
|
1424
|
-
market.elevationGroups[i].id !== newMarket.elevationGroups[i].id ||
|
|
1425
|
-
market.elevationGroups[i].maxLiquidationBonusBps !== newMarket.elevationGroups[i].maxLiquidationBonusBps ||
|
|
1426
|
-
market.elevationGroups[i].ltvPct !== newMarket.elevationGroups[i].ltvPct ||
|
|
1427
|
-
market.elevationGroups[i].liquidationThresholdPct !== newMarket.elevationGroups[i].liquidationThresholdPct ||
|
|
1428
|
-
market.elevationGroups[i].allowNewLoans !== newMarket.elevationGroups[i].allowNewLoans ||
|
|
1429
|
-
market.elevationGroups[i].maxReservesAsCollateral !== newMarket.elevationGroups[i].maxReservesAsCollateral ||
|
|
1430
|
-
!market.elevationGroups[i].debtReserve.equals(newMarket.elevationGroups[i].debtReserve)
|
|
1431
|
-
) {
|
|
1432
|
-
updateLendingMarketIxsArgs.push({
|
|
1433
|
-
mode: UpdateLendingMarketMode.UpdateElevationGroup.discriminator,
|
|
1434
|
-
value: updateMarketConfigEncodedValue(
|
|
1435
|
-
UpdateLendingMarketMode.UpdateElevationGroup.discriminator,
|
|
1436
|
-
newMarket.elevationGroups[i]
|
|
1437
|
-
),
|
|
1438
|
-
});
|
|
1439
|
-
elevationGroupsDiffs++;
|
|
1440
|
-
}
|
|
1441
|
-
}
|
|
1442
|
-
if (elevationGroupsDiffs > 1) {
|
|
1443
|
-
throw new Error('Can only update 1 elevation group at a time');
|
|
1444
|
-
}
|
|
1445
|
-
break;
|
|
1446
|
-
case 'minNetValueInObligationSf':
|
|
1447
|
-
if (!market.minNetValueInObligationSf.eq(newMarket.minNetValueInObligationSf)) {
|
|
1448
|
-
updateLendingMarketIxsArgs.push({
|
|
1449
|
-
mode: UpdateLendingMarketMode.UpdateMinNetValueObligationPostAction.discriminator,
|
|
1450
|
-
value: updateMarketConfigEncodedValue(
|
|
1451
|
-
UpdateLendingMarketMode.UpdateMinNetValueObligationPostAction.discriminator,
|
|
1452
|
-
newMarket.minNetValueInObligationSf.toString()
|
|
1453
|
-
),
|
|
1454
|
-
});
|
|
1455
|
-
}
|
|
1456
|
-
break;
|
|
1457
|
-
case 'minValueSkipLiquidationBfChecks':
|
|
1458
|
-
if (!market.minValueSkipLiquidationBfChecks.eq(newMarket.minValueSkipLiquidationBfChecks)) {
|
|
1459
|
-
updateLendingMarketIxsArgs.push({
|
|
1460
|
-
mode: UpdateLendingMarketMode.UpdateMinValueBfSkipPriorityLiqCheck.discriminator,
|
|
1461
|
-
value: updateMarketConfigEncodedValue(
|
|
1462
|
-
UpdateLendingMarketMode.UpdateMinValueBfSkipPriorityLiqCheck.discriminator,
|
|
1463
|
-
newMarket.minValueSkipLiquidationBfChecks.toNumber()
|
|
1464
|
-
),
|
|
1465
|
-
});
|
|
1466
|
-
}
|
|
1467
|
-
break;
|
|
1468
|
-
case 'minValueSkipLiquidationLtvChecks':
|
|
1469
|
-
if (!market.minValueSkipLiquidationLtvChecks.eq(newMarket.minValueSkipLiquidationLtvChecks)) {
|
|
1470
|
-
updateLendingMarketIxsArgs.push({
|
|
1471
|
-
mode: UpdateLendingMarketMode.UpdateMinValueLtvSkipPriorityLiqCheck.discriminator,
|
|
1472
|
-
value: updateMarketConfigEncodedValue(
|
|
1473
|
-
UpdateLendingMarketMode.UpdateMinValueLtvSkipPriorityLiqCheck.discriminator,
|
|
1474
|
-
newMarket.minValueSkipLiquidationLtvChecks.toNumber()
|
|
1475
|
-
),
|
|
1476
|
-
});
|
|
1477
|
-
}
|
|
1478
|
-
break;
|
|
1479
|
-
case 'individualAutodeleverageMarginCallPeriodSecs':
|
|
1480
|
-
if (
|
|
1481
|
-
market.individualAutodeleverageMarginCallPeriodSecs !== newMarket.individualAutodeleverageMarginCallPeriodSecs
|
|
1482
|
-
) {
|
|
1483
|
-
updateLendingMarketIxsArgs.push({
|
|
1484
|
-
mode: UpdateLendingMarketMode.UpdateIndividualAutodeleverageMarginCallPeriodSecs.discriminator,
|
|
1485
|
-
value: updateMarketConfigEncodedValue(
|
|
1486
|
-
UpdateLendingMarketMode.UpdateIndividualAutodeleverageMarginCallPeriodSecs.discriminator,
|
|
1487
|
-
newMarket.individualAutodeleverageMarginCallPeriodSecs.toNumber()
|
|
1488
|
-
),
|
|
1489
|
-
});
|
|
1490
|
-
}
|
|
1491
|
-
break;
|
|
1492
|
-
case 'name':
|
|
1493
|
-
if (!sameLengthArrayEquals(market.name, newMarket.name)) {
|
|
1494
|
-
updateLendingMarketIxsArgs.push({
|
|
1495
|
-
mode: UpdateLendingMarketMode.UpdateName.discriminator,
|
|
1496
|
-
value: updateMarketConfigEncodedValue(UpdateLendingMarketMode.UpdateName.discriminator, newMarket.name),
|
|
1497
|
-
});
|
|
1498
|
-
}
|
|
1499
|
-
break;
|
|
1500
|
-
case 'minInitialDepositAmount':
|
|
1501
|
-
if (!market.minInitialDepositAmount.eq(newMarket.minInitialDepositAmount)) {
|
|
1502
|
-
updateLendingMarketIxsArgs.push({
|
|
1503
|
-
mode: UpdateLendingMarketMode.UpdateInitialDepositAmount.discriminator,
|
|
1504
|
-
value: updateMarketConfigEncodedValue(
|
|
1505
|
-
UpdateLendingMarketMode.UpdateInitialDepositAmount.discriminator,
|
|
1506
|
-
newMarket.minInitialDepositAmount.toNumber()
|
|
1507
|
-
),
|
|
1508
|
-
});
|
|
1509
|
-
}
|
|
1510
|
-
break;
|
|
1511
|
-
case 'obligationOrdersEnabled':
|
|
1512
|
-
if (market.obligationOrdersEnabled !== newMarket.obligationOrdersEnabled) {
|
|
1513
|
-
updateLendingMarketIxsArgs.push({
|
|
1514
|
-
mode: UpdateLendingMarketMode.UpdateObligationOrdersEnabled.discriminator,
|
|
1515
|
-
value: updateMarketConfigEncodedValue(
|
|
1516
|
-
UpdateLendingMarketMode.UpdateObligationOrdersEnabled.discriminator,
|
|
1517
|
-
newMarket.obligationOrdersEnabled
|
|
1518
|
-
),
|
|
1519
|
-
});
|
|
1520
|
-
}
|
|
1521
|
-
break;
|
|
1522
|
-
default:
|
|
1523
|
-
assertNever(key);
|
|
1524
|
-
}
|
|
1525
|
-
return updateLendingMarketIxsArgs;
|
|
1526
|
-
};
|
|
1252
|
+
export const MARKET_UPDATER = new ConfigUpdater(UpdateLendingMarketMode.fromDecoded, LendingMarket, (config) => ({
|
|
1253
|
+
[UpdateLendingMarketMode.UpdateOwner.kind]: config.lendingMarketOwnerCached,
|
|
1254
|
+
[UpdateLendingMarketMode.UpdateImmutableFlag.kind]: config.immutable,
|
|
1255
|
+
[UpdateLendingMarketMode.UpdateEmergencyMode.kind]: config.emergencyMode,
|
|
1256
|
+
[UpdateLendingMarketMode.UpdateLiquidationCloseFactor.kind]: config.liquidationMaxDebtCloseFactorPct,
|
|
1257
|
+
[UpdateLendingMarketMode.UpdateLiquidationMaxValue.kind]: config.maxLiquidatableDebtMarketValueAtOnce,
|
|
1258
|
+
[UpdateLendingMarketMode.DeprecatedUpdateGlobalUnhealthyBorrow.kind]: null, // deprecated
|
|
1259
|
+
[UpdateLendingMarketMode.UpdateGlobalAllowedBorrow.kind]: config.globalAllowedBorrowValue,
|
|
1260
|
+
[UpdateLendingMarketMode.UpdateRiskCouncil.kind]: config.riskCouncil,
|
|
1261
|
+
[UpdateLendingMarketMode.UpdateMinFullLiquidationThreshold.kind]: config.minFullLiquidationValueThreshold,
|
|
1262
|
+
[UpdateLendingMarketMode.UpdateInsolvencyRiskLtv.kind]: config.insolvencyRiskUnhealthyLtvPct,
|
|
1263
|
+
[UpdateLendingMarketMode.UpdateElevationGroup.kind]: config.elevationGroups,
|
|
1264
|
+
[UpdateLendingMarketMode.UpdateReferralFeeBps.kind]: config.referralFeeBps,
|
|
1265
|
+
[UpdateLendingMarketMode.DeprecatedUpdateMultiplierPoints.kind]: null, // deprecated
|
|
1266
|
+
[UpdateLendingMarketMode.UpdatePriceRefreshTriggerToMaxAgePct.kind]: config.priceRefreshTriggerToMaxAgePct,
|
|
1267
|
+
[UpdateLendingMarketMode.UpdateAutodeleverageEnabled.kind]: config.autodeleverageEnabled,
|
|
1268
|
+
[UpdateLendingMarketMode.UpdateBorrowingDisabled.kind]: config.borrowDisabled,
|
|
1269
|
+
[UpdateLendingMarketMode.UpdateMinNetValueObligationPostAction.kind]: config.minNetValueInObligationSf,
|
|
1270
|
+
[UpdateLendingMarketMode.UpdateMinValueLtvSkipPriorityLiqCheck.kind]: config.minValueSkipLiquidationLtvChecks,
|
|
1271
|
+
[UpdateLendingMarketMode.UpdateMinValueBfSkipPriorityLiqCheck.kind]: config.minValueSkipLiquidationBfChecks,
|
|
1272
|
+
[UpdateLendingMarketMode.UpdatePaddingFields.kind]: null, // we do not update padding this way
|
|
1273
|
+
[UpdateLendingMarketMode.UpdateName.kind]: config.name,
|
|
1274
|
+
[UpdateLendingMarketMode.UpdateIndividualAutodeleverageMarginCallPeriodSecs.kind]:
|
|
1275
|
+
config.individualAutodeleverageMarginCallPeriodSecs,
|
|
1276
|
+
[UpdateLendingMarketMode.UpdateInitialDepositAmount.kind]: config.minInitialDepositAmount,
|
|
1277
|
+
[UpdateLendingMarketMode.UpdateObligationOrderCreationEnabled.kind]: config.obligationOrderCreationEnabled,
|
|
1278
|
+
[UpdateLendingMarketMode.UpdateObligationOrderExecutionEnabled.kind]: config.obligationOrderExecutionEnabled,
|
|
1279
|
+
}));
|
|
1527
1280
|
|
|
1528
1281
|
function parseForChangesMarketConfigAndGetIxs(
|
|
1529
1282
|
marketWithAddress: MarketWithAddress,
|
|
1530
1283
|
newMarket: LendingMarket,
|
|
1531
1284
|
programId: PublicKey
|
|
1532
1285
|
): TransactionInstruction[] {
|
|
1533
|
-
const
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
if (isExcludedLendingMarketKey(key)) {
|
|
1538
|
-
continue;
|
|
1539
|
-
}
|
|
1540
|
-
updateLendingMarketIxsArgs.push(...updateLendingMarketConfig(key as LendingMarketKey, market, newMarket));
|
|
1541
|
-
}
|
|
1542
|
-
|
|
1543
|
-
const ixs: TransactionInstruction[] = [];
|
|
1544
|
-
|
|
1545
|
-
updateLendingMarketIxsArgs.forEach((updateLendingMarketConfigArgs) => {
|
|
1546
|
-
ixs.push(
|
|
1547
|
-
updateMarketConfigIx(
|
|
1548
|
-
marketWithAddress,
|
|
1549
|
-
updateLendingMarketConfigArgs.mode,
|
|
1550
|
-
updateLendingMarketConfigArgs.value,
|
|
1551
|
-
programId
|
|
1552
|
-
)
|
|
1553
|
-
);
|
|
1554
|
-
});
|
|
1555
|
-
|
|
1556
|
-
return ixs;
|
|
1557
|
-
}
|
|
1558
|
-
|
|
1559
|
-
function updateMarketConfigEncodedValue(
|
|
1560
|
-
discriminator: UpdateLendingMarketModeKind['discriminator'],
|
|
1561
|
-
value: number | number[] | PublicKey | ElevationGroup | string
|
|
1562
|
-
): Buffer {
|
|
1563
|
-
let buffer: Buffer = Buffer.alloc(72);
|
|
1564
|
-
let pkBuffer: Buffer;
|
|
1565
|
-
let valueBigInt: bigint;
|
|
1566
|
-
let valueArray: number[];
|
|
1567
|
-
|
|
1568
|
-
switch (discriminator) {
|
|
1569
|
-
case UpdateLendingMarketMode.UpdateEmergencyMode.discriminator:
|
|
1570
|
-
case UpdateLendingMarketMode.UpdateLiquidationCloseFactor.discriminator:
|
|
1571
|
-
case UpdateLendingMarketMode.UpdateInsolvencyRiskLtv.discriminator:
|
|
1572
|
-
case UpdateLendingMarketMode.UpdatePriceRefreshTriggerToMaxAgePct.discriminator:
|
|
1573
|
-
case UpdateLendingMarketMode.UpdateAutodeleverageEnabled.discriminator:
|
|
1574
|
-
case UpdateLendingMarketMode.UpdateObligationOrdersEnabled.discriminator:
|
|
1575
|
-
case UpdateLendingMarketMode.UpdateBorrowingDisabled.discriminator:
|
|
1576
|
-
buffer.writeUIntLE(value as number, 0, 1);
|
|
1577
|
-
break;
|
|
1578
|
-
case UpdateLendingMarketMode.UpdateReferralFeeBps.discriminator:
|
|
1579
|
-
buffer.writeUInt16LE(value as number, 0);
|
|
1580
|
-
break;
|
|
1581
|
-
case UpdateLendingMarketMode.UpdateLiquidationMaxValue.discriminator:
|
|
1582
|
-
case UpdateLendingMarketMode.UpdateGlobalAllowedBorrow.discriminator:
|
|
1583
|
-
case UpdateLendingMarketMode.UpdateMinFullLiquidationThreshold.discriminator:
|
|
1584
|
-
case UpdateLendingMarketMode.UpdateMinValueBfSkipPriorityLiqCheck.discriminator:
|
|
1585
|
-
case UpdateLendingMarketMode.UpdateMinValueLtvSkipPriorityLiqCheck.discriminator:
|
|
1586
|
-
case UpdateLendingMarketMode.UpdateIndividualAutodeleverageMarginCallPeriodSecs.discriminator:
|
|
1587
|
-
case UpdateLendingMarketMode.UpdateInitialDepositAmount.discriminator:
|
|
1588
|
-
value = value as number;
|
|
1589
|
-
buffer.writeBigUint64LE(BigInt(value), 0);
|
|
1590
|
-
break;
|
|
1591
|
-
case UpdateLendingMarketMode.UpdateOwner.discriminator:
|
|
1592
|
-
case UpdateLendingMarketMode.UpdateRiskCouncil.discriminator:
|
|
1593
|
-
pkBuffer = (value as PublicKey).toBuffer();
|
|
1594
|
-
pkBuffer.copy(buffer, 0);
|
|
1595
|
-
break;
|
|
1596
|
-
case UpdateLendingMarketMode.UpdateElevationGroup.discriminator:
|
|
1597
|
-
buffer = serializeElevationGroup(value as ElevationGroup);
|
|
1598
|
-
break;
|
|
1599
|
-
case UpdateLendingMarketMode.UpdateMinNetValueObligationPostAction.discriminator:
|
|
1600
|
-
valueBigInt = BigInt(value as string);
|
|
1601
|
-
for (let i = 0; i < 16; i++) {
|
|
1602
|
-
buffer[15 - i] = Number((valueBigInt >> BigInt(i * 8)) & BigInt(0xff));
|
|
1603
|
-
}
|
|
1604
|
-
break;
|
|
1605
|
-
case UpdateLendingMarketMode.UpdateName.discriminator:
|
|
1606
|
-
valueArray = value as number[];
|
|
1607
|
-
for (let i = 0; i < valueArray.length; i++) {
|
|
1608
|
-
buffer.writeUIntLE(valueArray[i], i, 1);
|
|
1609
|
-
}
|
|
1610
|
-
break;
|
|
1611
|
-
case UpdateLendingMarketMode.UpdatePaddingFields.discriminator:
|
|
1612
|
-
case UpdateLendingMarketMode.DeprecatedUpdateGlobalUnhealthyBorrow.discriminator:
|
|
1613
|
-
case UpdateLendingMarketMode.DeprecatedUpdateMultiplierPoints.discriminator:
|
|
1614
|
-
// Deliberately skipped - we are not updating padding or deprecated fields using this method
|
|
1615
|
-
break;
|
|
1616
|
-
default:
|
|
1617
|
-
assertNever(discriminator);
|
|
1618
|
-
}
|
|
1619
|
-
|
|
1620
|
-
return buffer;
|
|
1286
|
+
const encodedMarketUpdates = MARKET_UPDATER.encodeAllUpdates(marketWithAddress.state, newMarket);
|
|
1287
|
+
return encodedMarketUpdates.map((encodedMarketUpdate) =>
|
|
1288
|
+
updateMarketConfigIx(marketWithAddress, encodedMarketUpdate.mode, encodedMarketUpdate.value, programId)
|
|
1289
|
+
);
|
|
1621
1290
|
}
|
|
1622
1291
|
|
|
1623
1292
|
function updateMarketConfigIx(
|
|
1624
1293
|
marketWithAddress: MarketWithAddress,
|
|
1625
|
-
|
|
1626
|
-
value:
|
|
1294
|
+
mode: UpdateLendingMarketModeKind,
|
|
1295
|
+
value: Uint8Array,
|
|
1627
1296
|
programId: PublicKey
|
|
1628
1297
|
): TransactionInstruction {
|
|
1629
1298
|
const accounts: UpdateLendingMarketAccounts = {
|
|
@@ -1632,25 +1301,13 @@ function updateMarketConfigIx(
|
|
|
1632
1301
|
};
|
|
1633
1302
|
|
|
1634
1303
|
const args: UpdateLendingMarketArgs = {
|
|
1635
|
-
mode: new anchor.BN(
|
|
1636
|
-
|
|
1304
|
+
mode: new anchor.BN(mode.discriminator),
|
|
1305
|
+
// NOTE: the Market's update handler expects a `[u8; 72]` (contrary to e.g. the Reserve's update handler accepting
|
|
1306
|
+
// `Vec<u8>`). Hence, we need to add explicit padding here:
|
|
1307
|
+
value: [...value, ...Array(72 - value.length).fill(0)],
|
|
1637
1308
|
};
|
|
1638
1309
|
|
|
1639
1310
|
const ix = updateLendingMarket(args, accounts, programId);
|
|
1640
1311
|
|
|
1641
1312
|
return ix;
|
|
1642
1313
|
}
|
|
1643
|
-
|
|
1644
|
-
function serializeElevationGroup(elevationGroup: ElevationGroup): Buffer {
|
|
1645
|
-
const buffer = Buffer.alloc(72);
|
|
1646
|
-
buffer.writeUInt16LE(elevationGroup.maxLiquidationBonusBps, 0);
|
|
1647
|
-
buffer.writeUIntLE(elevationGroup.id, 2, 1);
|
|
1648
|
-
buffer.writeUIntLE(elevationGroup.ltvPct, 3, 1);
|
|
1649
|
-
buffer.writeUIntLE(elevationGroup.liquidationThresholdPct, 4, 1);
|
|
1650
|
-
buffer.writeUIntLE(elevationGroup.allowNewLoans, 5, 1);
|
|
1651
|
-
buffer.writeUIntLE(elevationGroup.maxReservesAsCollateral, 6, 1);
|
|
1652
|
-
buffer.writeUIntLE(elevationGroup.padding0, 7, 1);
|
|
1653
|
-
const debtReserveBuffer = elevationGroup.debtReserve.toBuffer();
|
|
1654
|
-
debtReserveBuffer.copy(buffer, 8);
|
|
1655
|
-
return buffer;
|
|
1656
|
-
}
|
|
@@ -436,16 +436,11 @@ export class KaminoObligation {
|
|
|
436
436
|
|
|
437
437
|
/**
|
|
438
438
|
* Get the loan to value and liquidation loan to value for a collateral token reserve as ratios, accounting for the obligation elevation group if it is active
|
|
439
|
+
* @param market
|
|
440
|
+
* @param reserve
|
|
439
441
|
*/
|
|
440
|
-
public getLtvForReserve(
|
|
441
|
-
market
|
|
442
|
-
reserveAddress: PublicKey
|
|
443
|
-
): { maxLtv: Decimal; liquidationLtv: Decimal } {
|
|
444
|
-
return KaminoObligation.getLtvForReserve(
|
|
445
|
-
market,
|
|
446
|
-
market.getExistingReserveByAddress(reserveAddress),
|
|
447
|
-
this.state.elevationGroup
|
|
448
|
-
);
|
|
442
|
+
public getLtvForReserve(market: KaminoMarket, reserve: KaminoReserve): { maxLtv: Decimal; liquidationLtv: Decimal } {
|
|
443
|
+
return KaminoObligation.getLtvForReserve(market, reserve, this.state.elevationGroup);
|
|
449
444
|
}
|
|
450
445
|
|
|
451
446
|
/**
|
|
@@ -8,7 +8,6 @@ import { KaminoObligation, Position } from './obligation';
|
|
|
8
8
|
import { TokenAmount } from './shared';
|
|
9
9
|
import { ONE_HUNDRED_PCT_IN_BPS } from '../utils';
|
|
10
10
|
import { getSingleElement } from '../utils/validations';
|
|
11
|
-
import { KaminoMarket } from './market';
|
|
12
11
|
|
|
13
12
|
// Polymorphic parts of an order:
|
|
14
13
|
|
|
@@ -301,10 +300,7 @@ export class KaminoObligationOrder {
|
|
|
301
300
|
*
|
|
302
301
|
* May return `undefined` when the order's condition is not met.
|
|
303
302
|
*/
|
|
304
|
-
findMaxAvailableExecution(
|
|
305
|
-
kaminoMarket: KaminoMarket,
|
|
306
|
-
obligation: KaminoObligation
|
|
307
|
-
): AvailableOrderExecution | undefined {
|
|
303
|
+
findMaxAvailableExecution(obligation: KaminoObligation): AvailableOrderExecution | undefined {
|
|
308
304
|
const conditionHit = this.condition.evaluate(obligation);
|
|
309
305
|
if (conditionHit === null) {
|
|
310
306
|
return undefined; // condition not met - cannot execute
|
|
@@ -315,24 +311,9 @@ export class KaminoObligationOrder {
|
|
|
315
311
|
const executionBonusRate = this.calculateExecutionBonusRate(conditionHit, obligation);
|
|
316
312
|
const executionBonusFactor = new Decimal(1).add(executionBonusRate);
|
|
317
313
|
const maxWithdrawValue = maxRepayValue.mul(executionBonusFactor);
|
|
318
|
-
|
|
319
|
-
// The order execution only allows us to pick the lowest-liquidation-LTV deposit for withdrawal (excluding 0-LTV
|
|
320
|
-
// assets, which are never liquidatable), hence we pre-filter the candidate deposits:
|
|
321
|
-
const liquidationLtvsOfDeposits = obligation
|
|
314
|
+
const [actualWithdrawValue, withdrawDeposit] = obligation
|
|
322
315
|
.getDeposits()
|
|
323
|
-
.map((deposit): [Decimal, Position] =>
|
|
324
|
-
obligation.getLtvForReserve(kaminoMarket, deposit.reserveAddress).liquidationLtv,
|
|
325
|
-
deposit,
|
|
326
|
-
]);
|
|
327
|
-
const liquidatableDeposits = liquidationLtvsOfDeposits.filter(([liquidationLtv, _deposit]) => liquidationLtv.gt(0));
|
|
328
|
-
// Note: in theory, we could use the Obligation's `lowestReserveDepositLiquidationLtv` (cached by SC) here, but it
|
|
329
|
-
// is equally easy to just find the minimum (and avoid any issues related to stale `KaminoObligation` state or
|
|
330
|
-
// `Decimal` rounding/comparison).
|
|
331
|
-
const minLiquidationLtv = Decimal.min(...liquidatableDeposits.map(([liquidationLtv, _deposit]) => liquidationLtv));
|
|
332
|
-
|
|
333
|
-
const [actualWithdrawValue, withdrawDeposit] = liquidatableDeposits
|
|
334
|
-
.filter(([liquidationLtv, _deposit]) => liquidationLtv.eq(minLiquidationLtv))
|
|
335
|
-
.map(([_liquidationLtv, deposit]): [Decimal, Position] => {
|
|
316
|
+
.map((deposit): [Decimal, Position] => {
|
|
336
317
|
const availableWithdrawValue = Decimal.min(deposit.marketValueRefreshed, maxWithdrawValue);
|
|
337
318
|
return [availableWithdrawValue, deposit];
|
|
338
319
|
})
|