@gearbox-protocol/sdk 17.12.1 → 17.13.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/onchain/accounts/CreditAccountsServiceV310.js +1 -1
- package/dist/cjs/onchain/accounts/index.js +3 -0
- package/dist/cjs/onchain/accounts/liquidations/LiquidationsService.js +43 -1
- package/dist/cjs/onchain/accounts/liquidations/index.js +3 -0
- package/dist/cjs/onchain/accounts/liquidations/partialLiquidation.js +74 -0
- package/dist/cjs/onchain/index.js +4 -1
- package/dist/cjs/onchain/market/credit/CreditSuite.js +0 -60
- package/dist/cjs/onchain/market/credit/collateralUtils.js +3 -2
- package/dist/cjs/onchain/market/index.js +1 -1
- package/dist/cjs/onchain/market/math.js +34 -12
- package/dist/cjs/permissionless/api/chains/ChainsNamespace.js +17 -6
- package/dist/cjs/permissionless/api/transactions/InstanceOwnerTransactions.js +1 -4
- package/dist/cjs/permissionless/bindings/index.js +1 -1
- package/dist/cjs/permissionless/index.js +1 -1
- package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +1 -1
- package/dist/esm/onchain/accounts/index.js +2 -1
- package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +43 -1
- package/dist/esm/onchain/accounts/liquidations/index.js +2 -1
- package/dist/esm/onchain/accounts/liquidations/partialLiquidation.js +72 -0
- package/dist/esm/onchain/index.js +3 -2
- package/dist/esm/onchain/market/credit/CreditSuite.js +2 -62
- package/dist/esm/onchain/market/credit/collateralUtils.js +3 -2
- package/dist/esm/onchain/market/index.js +2 -2
- package/dist/esm/onchain/market/math.js +34 -12
- package/dist/esm/permissionless/api/chains/ChainsNamespace.js +17 -6
- package/dist/esm/permissionless/api/transactions/InstanceOwnerTransactions.js +1 -4
- package/dist/esm/permissionless/bindings/index.js +1 -1
- package/dist/esm/permissionless/index.js +1 -1
- package/dist/types/onchain/OnchainSDK.d.ts +1 -1
- package/dist/types/onchain/accounts/index.d.ts +7 -6
- package/dist/types/onchain/accounts/liquidations/LiquidationsService.d.ts +27 -1
- package/dist/types/onchain/accounts/liquidations/index.d.ts +3 -2
- package/dist/types/onchain/accounts/liquidations/partialLiquidation.d.ts +81 -0
- package/dist/types/onchain/accounts/liquidations/types.d.ts +36 -1
- package/dist/types/onchain/accounts/types.d.ts +3 -1
- package/dist/types/onchain/index.d.ts +8 -7
- package/dist/types/onchain/market/credit/CreditSuite.d.ts +1 -11
- package/dist/types/onchain/market/credit/collateralUtils.d.ts +2 -1
- package/dist/types/onchain/market/credit/index.d.ts +2 -2
- package/dist/types/onchain/market/credit/types.d.ts +1 -36
- package/dist/types/onchain/market/index.d.ts +3 -3
- package/dist/types/onchain/market/math.d.ts +29 -10
- package/dist/types/permissionless/api/types.d.ts +16 -1
- package/package.json +1 -1
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { minSeizedAmount, optimalPartialLiquidationAmounts } from "../../market/math.js";
|
|
2
|
+
import { dominantCollateral } from "../../market/credit/collateralUtils.js";
|
|
3
|
+
import "../../market/index.js";
|
|
4
|
+
//#region src/onchain/accounts/liquidations/partialLiquidation.ts
|
|
5
|
+
/**
|
|
6
|
+
* Optimal partial liquidation of an account: the collateral to seize and the
|
|
7
|
+
* amounts that bring its health factor close to `optimalHF`.
|
|
8
|
+
*
|
|
9
|
+
* Ported from solidity, without the price updates the contract applies first:
|
|
10
|
+
* https://github.com/Gearbox-protocol/router-v3/blob/56e2d515ec6d9bb1e324e71c3708e59710779b24/contracts/liquidation/AbstractLiquidator.sol#L252
|
|
11
|
+
*
|
|
12
|
+
* @throws If no `tokenOut` can be picked.
|
|
13
|
+
**/
|
|
14
|
+
function optimalPartialLiquidation({ suite, account, optimalHF = suite.optimalHFForPartialLiquidation(account), exclude }) {
|
|
15
|
+
const tokenOut = bestTokenOut(suite, account, exclude);
|
|
16
|
+
return {
|
|
17
|
+
tokenOut,
|
|
18
|
+
...optimalAmounts(suite, account, tokenOut, optimalHF)
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Everything a partial liquidation of credit account needs, with any parameter
|
|
23
|
+
* the caller pinned down taken as given and the rest derived from current state.
|
|
24
|
+
*
|
|
25
|
+
* @throws If a derived `tokenOut` cannot be picked, or if the seized token is
|
|
26
|
+
* not a collateral token of the credit manager.
|
|
27
|
+
**/
|
|
28
|
+
function partialLiquidationParams({ suite, account, overrides = {}, exclude }) {
|
|
29
|
+
const tokenOut = overrides.tokenOut ?? bestTokenOut(suite, account, exclude);
|
|
30
|
+
const optimalHF = overrides.optimalHF ?? suite.optimalHFForPartialLiquidation(account);
|
|
31
|
+
const repaidAmount = overrides.repaidAmount ?? optimalAmounts(suite, account, tokenOut, optimalHF).repaidAmount;
|
|
32
|
+
return {
|
|
33
|
+
tokenOut,
|
|
34
|
+
optimalHF,
|
|
35
|
+
repaidAmount,
|
|
36
|
+
minSeizedAmount: overrides.minSeizedAmount ?? minSeizedAmountOf(suite, tokenOut, repaidAmount)
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function bestTokenOut(suite, account, exclude) {
|
|
40
|
+
const collateral = dominantCollateral(account, suite.market, exclude);
|
|
41
|
+
if (!collateral) throw new Error(`cannot determine tokenOut for partial liquidation of ${suite.register.labelAddress(account.creditAccount)}: no enabled non-underlying collateral with value`);
|
|
42
|
+
return collateral;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* @throws If `tokenOut` is not a collateral token of the credit manager.
|
|
46
|
+
**/
|
|
47
|
+
function optimalAmounts(suite, account, tokenOut, optimalHF) {
|
|
48
|
+
const { creditManager: cm, market } = suite;
|
|
49
|
+
const { feeLiquidation, liquidationDiscount } = suite.liquidationFees();
|
|
50
|
+
const ltTokenOut = cm.liquidationThresholds.get(tokenOut);
|
|
51
|
+
if (ltTokenOut === void 0) throw new Error(`token ${suite.register.labelAddress(tokenOut)} is not a collateral token in credit manager ${suite.register.labelAddress(cm.address)}`);
|
|
52
|
+
return optimalPartialLiquidationAmounts({
|
|
53
|
+
totalDebt: account.debt + account.accruedInterest + account.accruedFees,
|
|
54
|
+
twvUnderlying: market.priceOracle.convertFromUSD(market.underlying, account.twvUSD),
|
|
55
|
+
minDebt: suite.creditFacade.minDebt,
|
|
56
|
+
optimalHF,
|
|
57
|
+
liquidationDiscount: BigInt(liquidationDiscount),
|
|
58
|
+
discount: BigInt(liquidationDiscount) - BigInt(feeLiquidation),
|
|
59
|
+
ltTokenOut: BigInt(ltTokenOut)
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Minimum amount of `token` that must be seized when repaying `repaidAmount`
|
|
64
|
+
* of underlying.
|
|
65
|
+
**/
|
|
66
|
+
function minSeizedAmountOf(suite, token, repaidAmount) {
|
|
67
|
+
const { market } = suite;
|
|
68
|
+
const tokenAmount = market.priceOracle.convert(market.underlying, token, repaidAmount);
|
|
69
|
+
return minSeizedAmount(tokenAmount, suite.liquidationFees().liquidationDiscount);
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
export { optimalPartialLiquidation, partialLiquidationParams };
|
|
@@ -133,7 +133,7 @@ import { createAdapter } from "./market/adapters/createAdapter.js";
|
|
|
133
133
|
import { CreditConfiguratorV310Contract } from "./market/credit/CreditConfiguratorV310Contract.js";
|
|
134
134
|
import { CreditFacadeV310BaseContract, creditFacadeV310Abi as abi } from "./market/credit/CreditFacadeV310BaseContract.js";
|
|
135
135
|
import { CreditFacadeV310Contract } from "./market/credit/CreditFacadeV310Contract.js";
|
|
136
|
-
import { DEFAULT_QUOTA_BUFFER_BPS, MAX_LEVERAGE_BUFFER_BPS, PARTIAL_LIQUIDATION_BUFFER_BPS, bpsToRay, calcBorrowApy, calcEffectiveBorrowApy, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcUtilization, calcUtilizationRaw, healthFactorBps, minSeizedAmount, optimalHFForPartialLiquidation,
|
|
136
|
+
import { DEFAULT_QUOTA_BUFFER_BPS, MAX_LEVERAGE_BUFFER_BPS, PARTIAL_LIQUIDATION_BUFFER_BPS, bpsToRay, calcBorrowApy, calcEffectiveBorrowApy, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcUtilization, calcUtilizationRaw, healthFactorBps, minSeizedAmount, optimalHFForPartialLiquidation, optimalPartialLiquidationAmounts, rayToBps, usdToNumber } from "./market/math.js";
|
|
137
137
|
import { CreditManagerV310Contract } from "./market/credit/CreditManagerV310Contract.js";
|
|
138
138
|
import { DEGEN_NFT_MIDAS, PHANTOM_TOKEN_MIDAS_REDEMPTION, RWA_LIQUIDATOR_MIDAS } from "./market/rwa/midas/constants.js";
|
|
139
139
|
import { MidasDegenNFT } from "./market/rwa/midas/MidasDegenNFT.js";
|
|
@@ -245,6 +245,7 @@ import { fetchCreditAccountSlice, toCreditAccountSlice } from "./accounts/intent
|
|
|
245
245
|
import { DIRECT_TRANSFERS_QUOTA, calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, maxAmountForQuota, roundUpQuota } from "./accounts/quota-utils.js";
|
|
246
246
|
import { CreditAccountOperationsService } from "./accounts/intents/index.js";
|
|
247
247
|
import { LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS } from "./accounts/liquidations/constants.js";
|
|
248
|
+
import { optimalPartialLiquidation, partialLiquidationParams } from "./accounts/liquidations/partialLiquidation.js";
|
|
248
249
|
import { LiquidationsService } from "./accounts/liquidations/LiquidationsService.js";
|
|
249
250
|
import { MultichainLiquidationsService } from "./accounts/liquidations/MultichainLiquidationsService.js";
|
|
250
251
|
import { DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, decodeDelayedIntent, encodeDelayedIntent } from "./accounts/withdrawal-compressor/intent-codec.js";
|
|
@@ -305,4 +306,4 @@ import { replayMulticall } from "./preview/preview/replayMulticall.js";
|
|
|
305
306
|
import { previewOperation } from "./preview/preview/previewOperation.js";
|
|
306
307
|
import "./preview/index.js";
|
|
307
308
|
import "./types/index.js";
|
|
308
|
-
export { ADDRESS_0X0, ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractAdapterContract, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AbstractWithdrawalCompressorContract, AccountBotsService, AccountMigratorAdapterContract, AdapterType, AddressMap, AddressProviderV310Contract, AddressSet, AssetsMap, BLOCKS_PER_WEEK_BY_NETWORK, BalancerStablePriceFeedContract, BalancerV3PoolStatus, BalancerV3RouterAdapterContract, BalancerV3WrapperAdapterContract, BalancerWeightedPriceFeedContract, BaseContract, BasePlugin, BigIntMath, BotPermissions, BoundedPriceFeedContract, CamelotV3AdapterContract, ChainContractsRegister, ChainNotConfiguredError, CompositePriceFeedContract, ConstantPriceFeedContract, Construct, ContractParseError, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountOperationsService, CreditAccountState, CreditAccountsServiceV310, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, CreditSuiteStrategy, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, DEFAULT_QUOTA_BUFFER_BPS, DEGEN_NFT_MIDAS, DEGEN_NFT_SECURITIZE, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DIRECT_TRANSFERS_QUOTA, DUST_THRESHOLD, DaiUsdsAdapterContract, ERC4626AdapterContract, ERC4626ReferralAdapterContract, EXECUTE_BYTES_SELECTOR, Erc4626PriceFeedContract, ExternalPriceFeedContract, FluidDexAdapterContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, KelpLRTDepositPoolAdapterContract, KelpLRTWithdrawalManagerAdapterContract, LEVERAGE_DECIMALS, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LidoV1AdapterContract, LinearInterestRateModelContract, LiquidationsService, MAX_INT, MAX_LEVERAGE_BUFFER_BPS, MAX_UINT16, MAX_UINT256, MIN_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_INT96, MIN_SAFE_HEALTH_FACTOR_FORM, MULTICALL_ADDRESS, MarketRegister, MarketSuite, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, MidasDegenNFT, MidasGatewayAdapterContract, MidasIssuanceVaultAdapterContract, MidasLiquidatorContract, MidasRedemptionVaultAdapterContract, MissingSerializedParamsError, MultichainConstruct, MultichainLiquidationsService, MultichainOpportunitiesService, MultichainPositionsService, MultichainSDK, NATIVE_ADDRESS, NON_STRATEGY_PHANTOM_TOKEN_TYPES, NOT_DEPLOYED, NO_VERSION, NetworkType, OnchainSDK, OpportunitiesService, PARTIAL_LIQUIDATION_BUFFER_BPS, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PERIPHERY_CONTRACTS, PHANTOM_TOKEN_CONTRACT_TYPES, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PRICE_DECIMALS, PRICE_DECIMALS_POW, PartialPriceFeedInitError, PendlePairStatus, PendleRouterAdapterContract, PendleTWAPPTPriceFeed, PendleTokenType, PeripheryCompressorV310Contract, PluginStateVersionError, PoolService, PoolSuite, PoolV310Contract, PositionsService, PriceFeedRef, PriceFeedRegistry, PriceOracleV310Contract, PriceUpdatesCache, PythPriceFeed, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWARegistry, RWA_COMPRESSOR_ADDRESS, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND, RedemptionLoggerV310Contract, RedstonePriceFeedContract, RouterV310Contract, SDKConstruct, SECONDS_PER_YEAR, SLIPPAGE_DECIMALS, STATE_VERSION, SUPPORTED_NETWORKS, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkRWADataNotLoadedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeDegenNFT, SecuritizeLiquidatorContract, SecuritizeOnRampAdapterContract, SecuritizeRWAFactory, SecuritizeRedemptionGatewayAdapterContract, SimulateWithPriceUpdatesError, SimulationError, StakingRewardsAdapterContract, TokensMeta, TraderJoePoolVersion, TraderJoeRouterAdapterContract, TypedObjectUtils, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UpdatablePriceFeedRegistry, UpshiftVaultAdapterContract, VERSION_RANGE_310, VelodromeV2RouterAdapterContract, VotingContractStatus, WAD, WAD_DECIMALS_POW, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WstETHPriceFeedContract, WstETHV1AdapterContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, ZodAddress, ZodBigInt, ZodHex, accountSnapshotFromCreditAccountData, adapterActionAbi, adapterActionSelectors, adapterActionSignatures, adapterConstructorAbi, allTransfersAsTokenAmounts, amountOf, assetsMap, attachOptionsSchema, botPermissionsToString, bpsToRay, buildDelayedStrategyPositionOperationPreview, bytes32ToString, calcBorrowApy, calcBorrowRate, calcDefaultQuota, calcEffectiveBorrowApy, calcHealthFactor, calcLiquidationPrice, calcLiquidationPriceForTarget, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcQuotaUpdate, calcRecommendedQuota, calcTimeToLiquidationMs, calcUtilization, calcUtilizationRaw, chains, checkAccountQuotas, checkBorrowLimit, checkCollateralFunding, checkCollateralised, checkCreditAccountFrozen, checkCreditManagerPaused, checkCreditOperation, checkDebtLimits, checkEmergencyLiquidator, checkForbiddenToken, checkHealthFactors, checkIncreaseDebt, checkIncreaseQuota, checkLeverage, checkLiquidation, checkLiquidationEligibility, checkLiquidationFunding, checkLiquidatorEligible, checkMarket, checkMarketExpired, checkMidasAccountGreenlist, checkObtained, checkOperation, checkPoolFunding, checkPoolLiquidity, checkPoolOperation, checkPoolPaused, checkPoolSunset, checkQuotaCount, checkQuotaLimit, checkRWAOpenRequirements, checkRWAOpening, checkReservePriceLimited, checkSimulation, checkWallet, checkWalletAllowance, checkWalletBalance, childLogger, classifyCloseOrRepay, classifyCurveOperation, classifyInnerOperations, collateralPriceInUnderlying, collectTraces, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, abi as creditFacadeV310Abi, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, decodeDelayedIntent, detectDelayedClaim, detectDelayedOperation, detectNetwork, dominantCollateral, encodeDelayedIntent, erc4626ReferralAdapterAbi, estimateClaimableAt, estimateRawTxGas, etherscanApiUrl, etherscanUrl, executeDelegatedMulticalls, executeMulticallBatches, expectedBalanceDeltas, fetchCreditAccountSlice, filterDust, filterDustUSD, findCallTo, findCallWithInput, findCuratorMarketConfigurator, findExecuteBytes, fmtBinaryMask, fnSigToName, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, generateCastTraceCall, getAccountTargetCollateral, getAdapterActionAbi, getAdapterDeployParamsAbi, getAdapterType, getAssetType, getCastTraceArgs, getChain, getCuratorName, getDirectTransferToken, getFunctionSignature, getLegacyStrategyTarget, getNetworkType, getRawPriceUpdates, getSimulateWithPriceUpdatesError, getWithdrawalCompressorAddress, halfRAY, hasAdapterDeployParamsAbi, healthFactorBps, hexEq, hydrateAddressProvider, iBalancerV3RouterAbi, iBalancerV3RouterAdapterAbi, iBalancerV3WrapperAbi, iBalancerV3WrapperAdapterAbi, iBaseOnRampAbi, iBaseRewardPoolAbi, iBoosterAbi, iCamelotV3AdapterAbi, iCamelotV3RouterAbi, iConvexV1BaseRewardPoolAdapterAbi, iConvexV1BoosterAdapterAbi, iCreditAccountAbi, iCurvePoolAbi, iCurvePoolStableNGAbi, iCurvePool_2Abi, iCurvePool_3Abi, iCurvePool_4Abi, iCurveV1StableNgAdapterAbi, iCurveV1_2AssetsAdapterAbi, iCurveV1_3AssetsAdapterAbi, iCurveV1_4AssetsAdapterAbi, iDaiUsdsAbi, iDaiUsdsAdapterAbi, iERC4626Abi, iERC4626ReferralAbi, iFluidDexAbi, iFluidDexAdapterAbi, iInfinifiGatewayAbi, iInfinifiGatewayAdapterAbi, iInfinifiUnwindingGatewayAbi, iInfinifiUnwindingGatewayAdapterAbi, iKelpLRTDepositPoolGatewayAbi, iKelpLRTWithdrawalManagerGatewayAbi, iKelpLrtDepositPoolAdapterAbi, iKelpLrtDepositPoolGatewayAbi, iKelpLrtWithdrawalManagerAdapterAbi, iKelpLrtWithdrawalManagerGatewayAbi, iLidoV1AdapterAbi, iMellow4626VaultAdapterAbi, iMellowClaimerAbi, iMellowClaimerAdapterAbi, iMellowWrapperAbi, iMellowWrapperAdapterAbi, iMidasGatewayAdapterV311Abi, iMidasGatewayV311Abi, iMidasIssuanceVaultAdapterV310Abi, iMidasIssuanceVaultV310Abi, iMidasRedemptionVaultAdapterV310Abi, iMidasRedemptionVaultGatewayV310Abi, iPendleRouterAbi, iPendleRouterAdapterAbi, iSecuritizeOnRampAbi, iSecuritizeOnRampAdapterV310Abi, iSecuritizeRedemptionGatewayAdapterV311Abi, iSecuritizeRedemptionGatewayV311Abi, iStakingRewardsAbi, iStakingRewardsAdapterAbi, iTraderJoeRouterAbi, iTraderJoeRouterAdapterAbi, iUniswapV2AdapterAbi, iUniswapV2Router02Abi, iUniswapV3Abi, iUniswapV3AdapterAbi, iUniswapV4AdapterAbi, iUniswapV4GatewayAbi, iUpshiftVaultAdapterAbi, iUpshiftVaultGatewayAbi, iVelodromeV2RouterAbi, iVelodromeV2RouterAdapterAbi, isCloseOrRepay, isDust, isLPPriceFeed, isPhantomToken, isPoolOperation, isPublicNetwork, isRWAFactory, isRWAOperation, isRWAToken, isStrategyCollateral, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, isZeroBalance, iwstETHAbi, iwstEthv1AdapterAbi, json_parse, json_stringify, lidoV1_WETHGatewayAbi, makeReplayState, maxAmountForQuota, mellowDvvAdapterAbi, midasGreenlistsAccount, minSeizedAmount, numberWithCommas, onchainSDKOptionsSchema, optimalHFForPartialLiquidation, optimalRepaidAmount, parseAdapterAction, parseAdapterDeployParams, parseFacadeOperationCalldata, parseOperationCalldata, parsePoolOperationCalldata, parsePosNegAmount, parseRWAFactoryOperationCalldata, percentFmt, pickStrategyTargetCollateral, previewAdjustStrategyPosition, previewExitOrRepayStrategyPosition, previewOperation, raise, rayToBps, rayToNumber, replayInnerOperations, replayMulticall, resolveDelayedClaimIntent, resolveProtocolCall, retry, rewardsFromTransfers, roundUpQuota, sendRawTx, shortAddress, shortHash, simulateCall, simulateMulticall, simulateWithPriceUpdates, soleNonUnderlyingCollateral, strategyName, swapFromTransfers, toAddress, toBN, toBigInt, toChainIds, toClaimableWithdrawal, toCreditAccountSlice, toNetTransfers, toPendingWithdrawal, toRequestableWithdrawal, toSignificant, toToken, toTokenAmount, toWithdrawalStatus, updatableDependencies, usdToNumber, watchBlocksAsync };
|
|
309
|
+
export { ADDRESS_0X0, ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractAdapterContract, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AbstractWithdrawalCompressorContract, AccountBotsService, AccountMigratorAdapterContract, AdapterType, AddressMap, AddressProviderV310Contract, AddressSet, AssetsMap, BLOCKS_PER_WEEK_BY_NETWORK, BalancerStablePriceFeedContract, BalancerV3PoolStatus, BalancerV3RouterAdapterContract, BalancerV3WrapperAdapterContract, BalancerWeightedPriceFeedContract, BaseContract, BasePlugin, BigIntMath, BotPermissions, BoundedPriceFeedContract, CamelotV3AdapterContract, ChainContractsRegister, ChainNotConfiguredError, CompositePriceFeedContract, ConstantPriceFeedContract, Construct, ContractParseError, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountOperationsService, CreditAccountState, CreditAccountsServiceV310, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, CreditSuiteStrategy, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, DEFAULT_QUOTA_BUFFER_BPS, DEGEN_NFT_MIDAS, DEGEN_NFT_SECURITIZE, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DIRECT_TRANSFERS_QUOTA, DUST_THRESHOLD, DaiUsdsAdapterContract, ERC4626AdapterContract, ERC4626ReferralAdapterContract, EXECUTE_BYTES_SELECTOR, Erc4626PriceFeedContract, ExternalPriceFeedContract, FluidDexAdapterContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, KelpLRTDepositPoolAdapterContract, KelpLRTWithdrawalManagerAdapterContract, LEVERAGE_DECIMALS, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LidoV1AdapterContract, LinearInterestRateModelContract, LiquidationsService, MAX_INT, MAX_LEVERAGE_BUFFER_BPS, MAX_UINT16, MAX_UINT256, MIN_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_INT96, MIN_SAFE_HEALTH_FACTOR_FORM, MULTICALL_ADDRESS, MarketRegister, MarketSuite, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, MidasDegenNFT, MidasGatewayAdapterContract, MidasIssuanceVaultAdapterContract, MidasLiquidatorContract, MidasRedemptionVaultAdapterContract, MissingSerializedParamsError, MultichainConstruct, MultichainLiquidationsService, MultichainOpportunitiesService, MultichainPositionsService, MultichainSDK, NATIVE_ADDRESS, NON_STRATEGY_PHANTOM_TOKEN_TYPES, NOT_DEPLOYED, NO_VERSION, NetworkType, OnchainSDK, OpportunitiesService, PARTIAL_LIQUIDATION_BUFFER_BPS, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PERIPHERY_CONTRACTS, PHANTOM_TOKEN_CONTRACT_TYPES, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PRICE_DECIMALS, PRICE_DECIMALS_POW, PartialPriceFeedInitError, PendlePairStatus, PendleRouterAdapterContract, PendleTWAPPTPriceFeed, PendleTokenType, PeripheryCompressorV310Contract, PluginStateVersionError, PoolService, PoolSuite, PoolV310Contract, PositionsService, PriceFeedRef, PriceFeedRegistry, PriceOracleV310Contract, PriceUpdatesCache, PythPriceFeed, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWARegistry, RWA_COMPRESSOR_ADDRESS, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND, RedemptionLoggerV310Contract, RedstonePriceFeedContract, RouterV310Contract, SDKConstruct, SECONDS_PER_YEAR, SLIPPAGE_DECIMALS, STATE_VERSION, SUPPORTED_NETWORKS, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkRWADataNotLoadedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeDegenNFT, SecuritizeLiquidatorContract, SecuritizeOnRampAdapterContract, SecuritizeRWAFactory, SecuritizeRedemptionGatewayAdapterContract, SimulateWithPriceUpdatesError, SimulationError, StakingRewardsAdapterContract, TokensMeta, TraderJoePoolVersion, TraderJoeRouterAdapterContract, TypedObjectUtils, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UpdatablePriceFeedRegistry, UpshiftVaultAdapterContract, VERSION_RANGE_310, VelodromeV2RouterAdapterContract, VotingContractStatus, WAD, WAD_DECIMALS_POW, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WstETHPriceFeedContract, WstETHV1AdapterContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, ZodAddress, ZodBigInt, ZodHex, accountSnapshotFromCreditAccountData, adapterActionAbi, adapterActionSelectors, adapterActionSignatures, adapterConstructorAbi, allTransfersAsTokenAmounts, amountOf, assetsMap, attachOptionsSchema, botPermissionsToString, bpsToRay, buildDelayedStrategyPositionOperationPreview, bytes32ToString, calcBorrowApy, calcBorrowRate, calcDefaultQuota, calcEffectiveBorrowApy, calcHealthFactor, calcLiquidationPrice, calcLiquidationPriceForTarget, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcQuotaUpdate, calcRecommendedQuota, calcTimeToLiquidationMs, calcUtilization, calcUtilizationRaw, chains, checkAccountQuotas, checkBorrowLimit, checkCollateralFunding, checkCollateralised, checkCreditAccountFrozen, checkCreditManagerPaused, checkCreditOperation, checkDebtLimits, checkEmergencyLiquidator, checkForbiddenToken, checkHealthFactors, checkIncreaseDebt, checkIncreaseQuota, checkLeverage, checkLiquidation, checkLiquidationEligibility, checkLiquidationFunding, checkLiquidatorEligible, checkMarket, checkMarketExpired, checkMidasAccountGreenlist, checkObtained, checkOperation, checkPoolFunding, checkPoolLiquidity, checkPoolOperation, checkPoolPaused, checkPoolSunset, checkQuotaCount, checkQuotaLimit, checkRWAOpenRequirements, checkRWAOpening, checkReservePriceLimited, checkSimulation, checkWallet, checkWalletAllowance, checkWalletBalance, childLogger, classifyCloseOrRepay, classifyCurveOperation, classifyInnerOperations, collateralPriceInUnderlying, collectTraces, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, abi as creditFacadeV310Abi, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, decodeDelayedIntent, detectDelayedClaim, detectDelayedOperation, detectNetwork, dominantCollateral, encodeDelayedIntent, erc4626ReferralAdapterAbi, estimateClaimableAt, estimateRawTxGas, etherscanApiUrl, etherscanUrl, executeDelegatedMulticalls, executeMulticallBatches, expectedBalanceDeltas, fetchCreditAccountSlice, filterDust, filterDustUSD, findCallTo, findCallWithInput, findCuratorMarketConfigurator, findExecuteBytes, fmtBinaryMask, fnSigToName, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, generateCastTraceCall, getAccountTargetCollateral, getAdapterActionAbi, getAdapterDeployParamsAbi, getAdapterType, getAssetType, getCastTraceArgs, getChain, getCuratorName, getDirectTransferToken, getFunctionSignature, getLegacyStrategyTarget, getNetworkType, getRawPriceUpdates, getSimulateWithPriceUpdatesError, getWithdrawalCompressorAddress, halfRAY, hasAdapterDeployParamsAbi, healthFactorBps, hexEq, hydrateAddressProvider, iBalancerV3RouterAbi, iBalancerV3RouterAdapterAbi, iBalancerV3WrapperAbi, iBalancerV3WrapperAdapterAbi, iBaseOnRampAbi, iBaseRewardPoolAbi, iBoosterAbi, iCamelotV3AdapterAbi, iCamelotV3RouterAbi, iConvexV1BaseRewardPoolAdapterAbi, iConvexV1BoosterAdapterAbi, iCreditAccountAbi, iCurvePoolAbi, iCurvePoolStableNGAbi, iCurvePool_2Abi, iCurvePool_3Abi, iCurvePool_4Abi, iCurveV1StableNgAdapterAbi, iCurveV1_2AssetsAdapterAbi, iCurveV1_3AssetsAdapterAbi, iCurveV1_4AssetsAdapterAbi, iDaiUsdsAbi, iDaiUsdsAdapterAbi, iERC4626Abi, iERC4626ReferralAbi, iFluidDexAbi, iFluidDexAdapterAbi, iInfinifiGatewayAbi, iInfinifiGatewayAdapterAbi, iInfinifiUnwindingGatewayAbi, iInfinifiUnwindingGatewayAdapterAbi, iKelpLRTDepositPoolGatewayAbi, iKelpLRTWithdrawalManagerGatewayAbi, iKelpLrtDepositPoolAdapterAbi, iKelpLrtDepositPoolGatewayAbi, iKelpLrtWithdrawalManagerAdapterAbi, iKelpLrtWithdrawalManagerGatewayAbi, iLidoV1AdapterAbi, iMellow4626VaultAdapterAbi, iMellowClaimerAbi, iMellowClaimerAdapterAbi, iMellowWrapperAbi, iMellowWrapperAdapterAbi, iMidasGatewayAdapterV311Abi, iMidasGatewayV311Abi, iMidasIssuanceVaultAdapterV310Abi, iMidasIssuanceVaultV310Abi, iMidasRedemptionVaultAdapterV310Abi, iMidasRedemptionVaultGatewayV310Abi, iPendleRouterAbi, iPendleRouterAdapterAbi, iSecuritizeOnRampAbi, iSecuritizeOnRampAdapterV310Abi, iSecuritizeRedemptionGatewayAdapterV311Abi, iSecuritizeRedemptionGatewayV311Abi, iStakingRewardsAbi, iStakingRewardsAdapterAbi, iTraderJoeRouterAbi, iTraderJoeRouterAdapterAbi, iUniswapV2AdapterAbi, iUniswapV2Router02Abi, iUniswapV3Abi, iUniswapV3AdapterAbi, iUniswapV4AdapterAbi, iUniswapV4GatewayAbi, iUpshiftVaultAdapterAbi, iUpshiftVaultGatewayAbi, iVelodromeV2RouterAbi, iVelodromeV2RouterAdapterAbi, isCloseOrRepay, isDust, isLPPriceFeed, isPhantomToken, isPoolOperation, isPublicNetwork, isRWAFactory, isRWAOperation, isRWAToken, isStrategyCollateral, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, isZeroBalance, iwstETHAbi, iwstEthv1AdapterAbi, json_parse, json_stringify, lidoV1_WETHGatewayAbi, makeReplayState, maxAmountForQuota, mellowDvvAdapterAbi, midasGreenlistsAccount, minSeizedAmount, numberWithCommas, onchainSDKOptionsSchema, optimalHFForPartialLiquidation, optimalPartialLiquidation, optimalPartialLiquidationAmounts, parseAdapterAction, parseAdapterDeployParams, parseFacadeOperationCalldata, parseOperationCalldata, parsePoolOperationCalldata, parsePosNegAmount, parseRWAFactoryOperationCalldata, partialLiquidationParams, percentFmt, pickStrategyTargetCollateral, previewAdjustStrategyPosition, previewExitOrRepayStrategyPosition, previewOperation, raise, rayToBps, rayToNumber, replayInnerOperations, replayMulticall, resolveDelayedClaimIntent, resolveProtocolCall, retry, rewardsFromTransfers, roundUpQuota, sendRawTx, shortAddress, shortHash, simulateCall, simulateMulticall, simulateWithPriceUpdates, soleNonUnderlyingCollateral, strategyName, swapFromTransfers, toAddress, toBN, toBigInt, toChainIds, toClaimableWithdrawal, toCreditAccountSlice, toNetTransfers, toPendingWithdrawal, toRequestableWithdrawal, toSignificant, toToken, toTokenAmount, toWithdrawalStatus, updatableDependencies, usdToNumber, watchBlocksAsync };
|
|
@@ -6,11 +6,11 @@ import "../../constants/index.js";
|
|
|
6
6
|
import "../../utils/index.js";
|
|
7
7
|
import { SDKConstruct } from "../../base/SDKConstruct.js";
|
|
8
8
|
import "../../base/index.js";
|
|
9
|
-
import {
|
|
9
|
+
import { optimalHFForPartialLiquidation } from "../math.js";
|
|
10
10
|
import { createDegenNFT } from "../rwa/createDegenNFT.js";
|
|
11
11
|
import { strategyName } from "../strategyName.js";
|
|
12
12
|
import { CreditSuiteStrategy } from "./CreditSuiteStrategy.js";
|
|
13
|
-
import {
|
|
13
|
+
import { isStrategyCollateral, pickStrategyTargetCollateral } from "./collateralUtils.js";
|
|
14
14
|
import createCreditConfigurator from "./createCreditConfigurator.js";
|
|
15
15
|
import createCreditFacade from "./createCreditFacade.js";
|
|
16
16
|
import createCreditManager from "./createCreditManager.js";
|
|
@@ -334,26 +334,6 @@ var CreditSuite = class extends SDKConstruct {
|
|
|
334
334
|
return target ? strategyName(target, this.underlyingToken) : this.underlyingToken.symbol;
|
|
335
335
|
}
|
|
336
336
|
/**
|
|
337
|
-
* Everything a partial liquidation of credit account needs, with any parameter the
|
|
338
|
-
* caller pinned down taken as given and the rest derived from current state.
|
|
339
|
-
*
|
|
340
|
-
* @param ca - Credit account to partially liquidate.
|
|
341
|
-
* @param overrides - Parameters to use instead of the derived defaults.
|
|
342
|
-
* @throws If a derived `tokenOut` cannot be picked, or if the seized token is
|
|
343
|
-
* not a collateral token of this credit manager.
|
|
344
|
-
*/
|
|
345
|
-
partialLiquidationParams(ca, overrides = {}) {
|
|
346
|
-
const tokenOut = overrides.tokenOut ?? this.#bestTokenOut(ca);
|
|
347
|
-
const optimalHF = overrides.optimalHF ?? this.optimalHFForPartialLiquidation(ca);
|
|
348
|
-
const repaidAmount = overrides.repaidAmount ?? this.#optimalRepaidAmount(ca, tokenOut, optimalHF);
|
|
349
|
-
return {
|
|
350
|
-
tokenOut,
|
|
351
|
-
optimalHF,
|
|
352
|
-
repaidAmount,
|
|
353
|
-
minSeizedAmount: overrides.minSeizedAmount ?? this.#minSeizedAmount(tokenOut, repaidAmount)
|
|
354
|
-
};
|
|
355
|
-
}
|
|
356
|
-
/**
|
|
357
337
|
* Health factor a partial liquidation of `ca` should target, in basis points.
|
|
358
338
|
*
|
|
359
339
|
* @param ca - Credit account to partially liquidate.
|
|
@@ -362,17 +342,6 @@ var CreditSuite = class extends SDKConstruct {
|
|
|
362
342
|
return optimalHFForPartialLiquidation(this.#borrowRate(ca));
|
|
363
343
|
}
|
|
364
344
|
/**
|
|
365
|
-
* Collateral token a partial liquidation seizes by default.
|
|
366
|
-
*
|
|
367
|
-
* Ported from solidity:
|
|
368
|
-
* https://github.com/Gearbox-protocol/router-v3/blob/main/contracts/liquidation/AbstractLiquidator.sol#L270
|
|
369
|
-
*/
|
|
370
|
-
#bestTokenOut(ca) {
|
|
371
|
-
const collateral = dominantCollateral(ca, this.market);
|
|
372
|
-
if (!collateral) throw new Error(`cannot determine tokenOut for partial liquidation of ${this.labelAddress(ca.creditAccount)}: no enabled non-underlying collateral with value`);
|
|
373
|
-
return collateral;
|
|
374
|
-
}
|
|
375
|
-
/**
|
|
376
345
|
* Shared inputs of {@link isStrategyCollateral} for one of this suite's
|
|
377
346
|
* collateral tokens.
|
|
378
347
|
*/
|
|
@@ -390,35 +359,6 @@ var CreditSuite = class extends SDKConstruct {
|
|
|
390
359
|
};
|
|
391
360
|
}
|
|
392
361
|
/**
|
|
393
|
-
* Minimum amount of `token` that must be seized when repaying `repaidAmount`
|
|
394
|
-
* of underlying.
|
|
395
|
-
*/
|
|
396
|
-
#minSeizedAmount(token, repaidAmount) {
|
|
397
|
-
const { market } = this;
|
|
398
|
-
const tokenAmount = market.priceOracle.convert(market.underlying, token, repaidAmount);
|
|
399
|
-
return minSeizedAmount(tokenAmount, this.liquidationFees().liquidationDiscount);
|
|
400
|
-
}
|
|
401
|
-
/**
|
|
402
|
-
* Amount of underlying to repay to bring `ca`'s health factor close to
|
|
403
|
-
* `optimalHF` by seizing `token`.
|
|
404
|
-
*
|
|
405
|
-
* @throws If `token` is not a collateral token of this credit manager.
|
|
406
|
-
*/
|
|
407
|
-
#optimalRepaidAmount(ca, token, optimalHF) {
|
|
408
|
-
const { creditManager: cm, market } = this;
|
|
409
|
-
const { feeLiquidation, liquidationDiscount } = this.liquidationFees();
|
|
410
|
-
const ltTokenOut = cm.liquidationThresholds.get(token);
|
|
411
|
-
if (ltTokenOut === void 0) throw new Error(`token ${this.labelAddress(token)} is not a collateral token in credit manager ${this.labelAddress(cm.address)}`);
|
|
412
|
-
return optimalRepaidAmount({
|
|
413
|
-
totalDebt: ca.debt + ca.accruedInterest + ca.accruedFees,
|
|
414
|
-
twvUnderlying: market.priceOracle.convertFromUSD(market.underlying, ca.twvUSD),
|
|
415
|
-
minDebt: this.creditFacade.minDebt,
|
|
416
|
-
optimalHF,
|
|
417
|
-
discount: BigInt(liquidationDiscount) - BigInt(feeLiquidation),
|
|
418
|
-
ltTokenOut: BigInt(ltTokenOut)
|
|
419
|
-
});
|
|
420
|
-
}
|
|
421
|
-
/**
|
|
422
362
|
* Blended annual cost of credit account's debt, in basis points: base interest weighted
|
|
423
363
|
* by the account's share of its own total debt, plus the quota rates of the
|
|
424
364
|
* collaterals it actually holds, both marked up by the interest fee.
|
|
@@ -62,14 +62,15 @@ function pickStrategyTargetCollateral(tokens) {
|
|
|
62
62
|
*
|
|
63
63
|
* @param account - Account to inspect.
|
|
64
64
|
* @param market - Market of the account, whose oracle prices the candidates.
|
|
65
|
+
* @param exclude - Tokens that cannot be the dominant collateral.
|
|
65
66
|
* @returns The dominant collateral, or `undefined` when the account holds
|
|
66
67
|
* nothing but its underlying, or nothing the oracle can price.
|
|
67
68
|
**/
|
|
68
|
-
function dominantCollateral(account, market) {
|
|
69
|
+
function dominantCollateral(account, market, exclude) {
|
|
69
70
|
let bestValue = 0n;
|
|
70
71
|
let dominant;
|
|
71
72
|
for (const t of account.tokens) {
|
|
72
|
-
if (isAddressEqual(t.token, account.underlying) || (t.mask & account.enabledTokensMask) === 0n || t.balance <= 10n) continue;
|
|
73
|
+
if (isAddressEqual(t.token, account.underlying) || (t.mask & account.enabledTokensMask) === 0n || t.balance <= 10n || exclude?.(t.token)) continue;
|
|
73
74
|
const value = market.priceOracle.safeConvertToUSD(t.token, t.balance).value;
|
|
74
75
|
if (value > bestValue) {
|
|
75
76
|
bestValue = value;
|
|
@@ -87,7 +87,7 @@ import "./adapters/index.js";
|
|
|
87
87
|
import { CreditConfiguratorV310Contract } from "./credit/CreditConfiguratorV310Contract.js";
|
|
88
88
|
import { CreditFacadeV310BaseContract, creditFacadeV310Abi as abi } from "./credit/CreditFacadeV310BaseContract.js";
|
|
89
89
|
import { CreditFacadeV310Contract } from "./credit/CreditFacadeV310Contract.js";
|
|
90
|
-
import { DEFAULT_QUOTA_BUFFER_BPS, MAX_LEVERAGE_BUFFER_BPS, PARTIAL_LIQUIDATION_BUFFER_BPS, bpsToRay, calcBorrowApy, calcEffectiveBorrowApy, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcUtilization, calcUtilizationRaw, healthFactorBps, minSeizedAmount, optimalHFForPartialLiquidation,
|
|
90
|
+
import { DEFAULT_QUOTA_BUFFER_BPS, MAX_LEVERAGE_BUFFER_BPS, PARTIAL_LIQUIDATION_BUFFER_BPS, bpsToRay, calcBorrowApy, calcEffectiveBorrowApy, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcUtilization, calcUtilizationRaw, healthFactorBps, minSeizedAmount, optimalHFForPartialLiquidation, optimalPartialLiquidationAmounts, rayToBps, usdToNumber } from "./math.js";
|
|
91
91
|
import { CreditManagerV310Contract } from "./credit/CreditManagerV310Contract.js";
|
|
92
92
|
import { DEGEN_NFT_MIDAS, PHANTOM_TOKEN_MIDAS_REDEMPTION, RWA_LIQUIDATOR_MIDAS } from "./rwa/midas/constants.js";
|
|
93
93
|
import { MidasDegenNFT } from "./rwa/midas/MidasDegenNFT.js";
|
|
@@ -149,4 +149,4 @@ import { RWARegistry, RWA_COMPRESSOR_ADDRESS } from "./rwa/RWARegistry.js";
|
|
|
149
149
|
import { isRWAFactory } from "./rwa/types.js";
|
|
150
150
|
import "./rwa/index.js";
|
|
151
151
|
import "./types.js";
|
|
152
|
-
export { AbstractAdapterContract, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AccountMigratorAdapterContract, AdapterType, BalancerStablePriceFeedContract, BalancerV3PoolStatus, BalancerV3RouterAdapterContract, BalancerV3WrapperAdapterContract, BalancerWeightedPriceFeedContract, BoundedPriceFeedContract, CamelotV3AdapterContract, CompositePriceFeedContract, ConstantPriceFeedContract, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, CreditSuiteStrategy, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, DEFAULT_QUOTA_BUFFER_BPS, DEGEN_NFT_MIDAS, DEGEN_NFT_SECURITIZE, DaiUsdsAdapterContract, ERC4626AdapterContract, ERC4626ReferralAdapterContract, Erc4626PriceFeedContract, ExternalPriceFeedContract, FluidDexAdapterContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, KelpLRTDepositPoolAdapterContract, KelpLRTWithdrawalManagerAdapterContract, LidoV1AdapterContract, LinearInterestRateModelContract, MAX_LEVERAGE_BUFFER_BPS, MarketRegister, MarketSuite, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, MidasDegenNFT, MidasGatewayAdapterContract, MidasIssuanceVaultAdapterContract, MidasLiquidatorContract, MidasRedemptionVaultAdapterContract, PARTIAL_LIQUIDATION_BUFFER_BPS, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PartialPriceFeedInitError, PendlePairStatus, PendleRouterAdapterContract, PendleTWAPPTPriceFeed, PendleTokenType, PoolSuite, PoolV310Contract, PriceFeedRef, PriceFeedRegistry, PriceOracleV310Contract, PriceUpdatesCache, PythPriceFeed, RWARegistry, RWA_COMPRESSOR_ADDRESS, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RedstonePriceFeedContract, SecuritizeDegenNFT, SecuritizeLiquidatorContract, SecuritizeOnRampAdapterContract, SecuritizeRWAFactory, SecuritizeRedemptionGatewayAdapterContract, StakingRewardsAdapterContract, TraderJoePoolVersion, TraderJoeRouterAdapterContract, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UpdatablePriceFeedRegistry, UpshiftVaultAdapterContract, VelodromeV2RouterAdapterContract, WstETHPriceFeedContract, WstETHV1AdapterContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, adapterActionAbi, adapterActionSelectors, adapterActionSignatures, adapterConstructorAbi, allTransfersAsTokenAmounts, bpsToRay, calcBorrowApy, calcEffectiveBorrowApy, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcUtilization, calcUtilizationRaw, classifyCurveOperation, collateralPriceInUnderlying, createAdapter, createPriceOracle, createZapper, abi as creditFacadeV310Abi, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, dominantCollateral, erc4626ReferralAdapterAbi, expectedBalanceDeltas, fnSigToName, getAdapterActionAbi, getAdapterDeployParamsAbi, getAdapterType, getRawPriceUpdates, hasAdapterDeployParamsAbi, healthFactorBps, iBalancerV3RouterAbi, iBalancerV3RouterAdapterAbi, iBalancerV3WrapperAbi, iBalancerV3WrapperAdapterAbi, iBaseOnRampAbi, iBaseRewardPoolAbi, iBoosterAbi, iCamelotV3AdapterAbi, iCamelotV3RouterAbi, iConvexV1BaseRewardPoolAdapterAbi, iConvexV1BoosterAdapterAbi, iCurvePoolAbi, iCurvePoolStableNGAbi, iCurvePool_2Abi, iCurvePool_3Abi, iCurvePool_4Abi, iCurveV1StableNgAdapterAbi, iCurveV1_2AssetsAdapterAbi, iCurveV1_3AssetsAdapterAbi, iCurveV1_4AssetsAdapterAbi, iDaiUsdsAbi, iDaiUsdsAdapterAbi, iERC4626Abi, iERC4626ReferralAbi, iFluidDexAbi, iFluidDexAdapterAbi, iInfinifiGatewayAbi, iInfinifiGatewayAdapterAbi, iInfinifiUnwindingGatewayAbi, iInfinifiUnwindingGatewayAdapterAbi, iKelpLRTDepositPoolGatewayAbi, iKelpLRTWithdrawalManagerGatewayAbi, iKelpLrtDepositPoolAdapterAbi, iKelpLrtDepositPoolGatewayAbi, iKelpLrtWithdrawalManagerAdapterAbi, iKelpLrtWithdrawalManagerGatewayAbi, iLidoV1AdapterAbi, iMellow4626VaultAdapterAbi, iMellowClaimerAbi, iMellowClaimerAdapterAbi, iMellowWrapperAbi, iMellowWrapperAdapterAbi, iMidasGatewayAdapterV311Abi, iMidasGatewayV311Abi, iMidasIssuanceVaultAdapterV310Abi, iMidasIssuanceVaultV310Abi, iMidasRedemptionVaultAdapterV310Abi, iMidasRedemptionVaultGatewayV310Abi, iPendleRouterAbi, iPendleRouterAdapterAbi, iSecuritizeOnRampAbi, iSecuritizeOnRampAdapterV310Abi, iSecuritizeRedemptionGatewayAdapterV311Abi, iSecuritizeRedemptionGatewayV311Abi, iStakingRewardsAbi, iStakingRewardsAdapterAbi, iTraderJoeRouterAbi, iTraderJoeRouterAdapterAbi, iUniswapV2AdapterAbi, iUniswapV2Router02Abi, iUniswapV3Abi, iUniswapV3AdapterAbi, iUniswapV4AdapterAbi, iUniswapV4GatewayAbi, iUpshiftVaultAdapterAbi, iUpshiftVaultGatewayAbi, iVelodromeV2RouterAbi, iVelodromeV2RouterAdapterAbi, isLPPriceFeed, isRWAFactory, isStrategyCollateral, isUpdatablePriceFeed, iwstETHAbi, iwstEthv1AdapterAbi, lidoV1_WETHGatewayAbi, mellowDvvAdapterAbi, minSeizedAmount, optimalHFForPartialLiquidation,
|
|
152
|
+
export { AbstractAdapterContract, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AccountMigratorAdapterContract, AdapterType, BalancerStablePriceFeedContract, BalancerV3PoolStatus, BalancerV3RouterAdapterContract, BalancerV3WrapperAdapterContract, BalancerWeightedPriceFeedContract, BoundedPriceFeedContract, CamelotV3AdapterContract, CompositePriceFeedContract, ConstantPriceFeedContract, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, CreditSuiteStrategy, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, DEFAULT_QUOTA_BUFFER_BPS, DEGEN_NFT_MIDAS, DEGEN_NFT_SECURITIZE, DaiUsdsAdapterContract, ERC4626AdapterContract, ERC4626ReferralAdapterContract, Erc4626PriceFeedContract, ExternalPriceFeedContract, FluidDexAdapterContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, KelpLRTDepositPoolAdapterContract, KelpLRTWithdrawalManagerAdapterContract, LidoV1AdapterContract, LinearInterestRateModelContract, MAX_LEVERAGE_BUFFER_BPS, MarketRegister, MarketSuite, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, MidasDegenNFT, MidasGatewayAdapterContract, MidasIssuanceVaultAdapterContract, MidasLiquidatorContract, MidasRedemptionVaultAdapterContract, PARTIAL_LIQUIDATION_BUFFER_BPS, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PartialPriceFeedInitError, PendlePairStatus, PendleRouterAdapterContract, PendleTWAPPTPriceFeed, PendleTokenType, PoolSuite, PoolV310Contract, PriceFeedRef, PriceFeedRegistry, PriceOracleV310Contract, PriceUpdatesCache, PythPriceFeed, RWARegistry, RWA_COMPRESSOR_ADDRESS, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RedstonePriceFeedContract, SecuritizeDegenNFT, SecuritizeLiquidatorContract, SecuritizeOnRampAdapterContract, SecuritizeRWAFactory, SecuritizeRedemptionGatewayAdapterContract, StakingRewardsAdapterContract, TraderJoePoolVersion, TraderJoeRouterAdapterContract, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UpdatablePriceFeedRegistry, UpshiftVaultAdapterContract, VelodromeV2RouterAdapterContract, WstETHPriceFeedContract, WstETHV1AdapterContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, adapterActionAbi, adapterActionSelectors, adapterActionSignatures, adapterConstructorAbi, allTransfersAsTokenAmounts, bpsToRay, calcBorrowApy, calcEffectiveBorrowApy, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcUtilization, calcUtilizationRaw, classifyCurveOperation, collateralPriceInUnderlying, createAdapter, createPriceOracle, createZapper, abi as creditFacadeV310Abi, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, dominantCollateral, erc4626ReferralAdapterAbi, expectedBalanceDeltas, fnSigToName, getAdapterActionAbi, getAdapterDeployParamsAbi, getAdapterType, getRawPriceUpdates, hasAdapterDeployParamsAbi, healthFactorBps, iBalancerV3RouterAbi, iBalancerV3RouterAdapterAbi, iBalancerV3WrapperAbi, iBalancerV3WrapperAdapterAbi, iBaseOnRampAbi, iBaseRewardPoolAbi, iBoosterAbi, iCamelotV3AdapterAbi, iCamelotV3RouterAbi, iConvexV1BaseRewardPoolAdapterAbi, iConvexV1BoosterAdapterAbi, iCurvePoolAbi, iCurvePoolStableNGAbi, iCurvePool_2Abi, iCurvePool_3Abi, iCurvePool_4Abi, iCurveV1StableNgAdapterAbi, iCurveV1_2AssetsAdapterAbi, iCurveV1_3AssetsAdapterAbi, iCurveV1_4AssetsAdapterAbi, iDaiUsdsAbi, iDaiUsdsAdapterAbi, iERC4626Abi, iERC4626ReferralAbi, iFluidDexAbi, iFluidDexAdapterAbi, iInfinifiGatewayAbi, iInfinifiGatewayAdapterAbi, iInfinifiUnwindingGatewayAbi, iInfinifiUnwindingGatewayAdapterAbi, iKelpLRTDepositPoolGatewayAbi, iKelpLRTWithdrawalManagerGatewayAbi, iKelpLrtDepositPoolAdapterAbi, iKelpLrtDepositPoolGatewayAbi, iKelpLrtWithdrawalManagerAdapterAbi, iKelpLrtWithdrawalManagerGatewayAbi, iLidoV1AdapterAbi, iMellow4626VaultAdapterAbi, iMellowClaimerAbi, iMellowClaimerAdapterAbi, iMellowWrapperAbi, iMellowWrapperAdapterAbi, iMidasGatewayAdapterV311Abi, iMidasGatewayV311Abi, iMidasIssuanceVaultAdapterV310Abi, iMidasIssuanceVaultV310Abi, iMidasRedemptionVaultAdapterV310Abi, iMidasRedemptionVaultGatewayV310Abi, iPendleRouterAbi, iPendleRouterAdapterAbi, iSecuritizeOnRampAbi, iSecuritizeOnRampAdapterV310Abi, iSecuritizeRedemptionGatewayAdapterV311Abi, iSecuritizeRedemptionGatewayV311Abi, iStakingRewardsAbi, iStakingRewardsAdapterAbi, iTraderJoeRouterAbi, iTraderJoeRouterAdapterAbi, iUniswapV2AdapterAbi, iUniswapV2Router02Abi, iUniswapV3Abi, iUniswapV3AdapterAbi, iUniswapV4AdapterAbi, iUniswapV4GatewayAbi, iUpshiftVaultAdapterAbi, iUpshiftVaultGatewayAbi, iVelodromeV2RouterAbi, iVelodromeV2RouterAdapterAbi, isLPPriceFeed, isRWAFactory, isStrategyCollateral, isUpdatablePriceFeed, iwstETHAbi, iwstEthv1AdapterAbi, lidoV1_WETHGatewayAbi, mellowDvvAdapterAbi, minSeizedAmount, optimalHFForPartialLiquidation, optimalPartialLiquidationAmounts, parseAdapterAction, parseAdapterDeployParams, parsePosNegAmount, pickStrategyTargetCollateral, rayToBps, rewardsFromTransfers, strategyName, swapFromTransfers, toNetTransfers, updatableDependencies, usdToNumber };
|
|
@@ -256,28 +256,50 @@ function minSeizedAmount(tokenAmount, liquidationDiscount) {
|
|
|
256
256
|
return tokenAmount * PARTIAL_LIQUIDATION_BUFFER_BPS / BigInt(liquidationDiscount);
|
|
257
257
|
}
|
|
258
258
|
/**
|
|
259
|
-
*
|
|
260
|
-
* to `optimalHF`, capped so the account keeps at least `minDebt` of debt.
|
|
259
|
+
* Amounts of a partial liquidation that brings the account's health factor
|
|
260
|
+
* close to `optimalHF`, capped so the account keeps at least `minDebt` of debt.
|
|
261
261
|
*
|
|
262
262
|
* Ported from solidity:
|
|
263
|
-
* https://github.com/Gearbox-protocol/router-v3/blob/56e2d515ec6d9bb1e324e71c3708e59710779b24/contracts/liquidation/AbstractLiquidator.sol#
|
|
263
|
+
* https://github.com/Gearbox-protocol/router-v3/blob/56e2d515ec6d9bb1e324e71c3708e59710779b24/contracts/liquidation/AbstractLiquidator.sol#L252
|
|
264
264
|
*
|
|
265
|
-
* @returns
|
|
266
|
-
*
|
|
265
|
+
* @returns Zero amounts when the account is already healthy enough or
|
|
266
|
+
* carries less than the minimum debt.
|
|
267
267
|
* @throws If the discounted target health factor does not exceed the seized
|
|
268
268
|
* token's liquidation threshold, in which case no repayment improves the
|
|
269
269
|
* account.
|
|
270
270
|
**/
|
|
271
|
-
function
|
|
271
|
+
function optimalPartialLiquidationAmounts({ totalDebt, twvUnderlying, minDebt, optimalHF, liquidationDiscount, discount, ltTokenOut }) {
|
|
272
272
|
const denominator = discount * optimalHF / PERCENTAGE_FACTOR - ltTokenOut;
|
|
273
273
|
if (denominator <= 0n) throw new Error("cannot compute optimal repaid amount: invalid liquidation parameters (discount * hfOptimal <= ltTokenOut)");
|
|
274
274
|
const numerator = totalDebt * optimalHF - twvUnderlying * PERCENTAGE_FACTOR;
|
|
275
|
-
if (numerator <= 0n) return
|
|
276
|
-
|
|
277
|
-
|
|
275
|
+
if (numerator <= 0n) return {
|
|
276
|
+
optimalAmount: 0n,
|
|
277
|
+
repaidAmount: 0n,
|
|
278
|
+
flashLoanAmount: 0n,
|
|
279
|
+
isOptimalRepayable: true
|
|
280
|
+
};
|
|
281
|
+
if (totalDebt < minDebt) return {
|
|
282
|
+
optimalAmount: 0n,
|
|
283
|
+
repaidAmount: 0n,
|
|
284
|
+
flashLoanAmount: 0n,
|
|
285
|
+
isOptimalRepayable: false
|
|
286
|
+
};
|
|
287
|
+
const optimalValueSeized = numerator / denominator;
|
|
288
|
+
let optimalAmount = optimalValueSeized * liquidationDiscount / PERCENTAGE_FACTOR;
|
|
289
|
+
let repaidAmount = optimalValueSeized * discount / PERCENTAGE_FACTOR;
|
|
290
|
+
let isOptimalRepayable = true;
|
|
278
291
|
const surplusDebt = totalDebt - minDebt;
|
|
279
|
-
if (repaidAmount > surplusDebt)
|
|
280
|
-
|
|
292
|
+
if (repaidAmount > surplusDebt) {
|
|
293
|
+
optimalAmount = optimalAmount * surplusDebt * PARTIAL_LIQUIDATION_BUFFER_BPS / (repaidAmount * PERCENTAGE_FACTOR);
|
|
294
|
+
repaidAmount = surplusDebt * PARTIAL_LIQUIDATION_BUFFER_BPS / PERCENTAGE_FACTOR;
|
|
295
|
+
isOptimalRepayable = false;
|
|
296
|
+
}
|
|
297
|
+
return {
|
|
298
|
+
optimalAmount,
|
|
299
|
+
repaidAmount,
|
|
300
|
+
flashLoanAmount: optimalAmount * 1001n / 1000n,
|
|
301
|
+
isOptimalRepayable
|
|
302
|
+
};
|
|
281
303
|
}
|
|
282
304
|
/**
|
|
283
305
|
* Health factor a partial liquidation should target, in basis points: just
|
|
@@ -290,4 +312,4 @@ function optimalHFForPartialLiquidation(borrowRate) {
|
|
|
290
312
|
return PERCENTAGE_FACTOR + (borrowRate < 100n ? borrowRate : 100n);
|
|
291
313
|
}
|
|
292
314
|
//#endregion
|
|
293
|
-
export { DEFAULT_QUOTA_BUFFER_BPS, MAX_LEVERAGE_BUFFER_BPS, PARTIAL_LIQUIDATION_BUFFER_BPS, bpsToRay, calcBorrowApy, calcEffectiveBorrowApy, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcUtilization, calcUtilizationRaw, healthFactorBps, minSeizedAmount, optimalHFForPartialLiquidation,
|
|
315
|
+
export { DEFAULT_QUOTA_BUFFER_BPS, MAX_LEVERAGE_BUFFER_BPS, PARTIAL_LIQUIDATION_BUFFER_BPS, bpsToRay, calcBorrowApy, calcEffectiveBorrowApy, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcUtilization, calcUtilizationRaw, healthFactorBps, minSeizedAmount, optimalHFForPartialLiquidation, optimalPartialLiquidationAmounts, rayToBps, usdToNumber };
|
|
@@ -34,6 +34,8 @@ import { createPublicClient, fallback, http } from "viem";
|
|
|
34
34
|
**/
|
|
35
35
|
var ChainsNamespace = class extends AbstractOffchainNamespace {
|
|
36
36
|
#clients = /* @__PURE__ */ new Map();
|
|
37
|
+
/** Transports the caller supplied, by chain id. See {@link #client}. */
|
|
38
|
+
#transports;
|
|
37
39
|
#chains;
|
|
38
40
|
#attaching;
|
|
39
41
|
/** The scope {@link attach} settled on, which {@link summary} follows. */
|
|
@@ -43,6 +45,7 @@ var ChainsNamespace = class extends AbstractOffchainNamespace {
|
|
|
43
45
|
...options,
|
|
44
46
|
chainIds: []
|
|
45
47
|
});
|
|
48
|
+
this.#transports = options.transports ?? {};
|
|
46
49
|
}
|
|
47
50
|
/**
|
|
48
51
|
* Reads the chain list off the backend and builds a client for each chain
|
|
@@ -146,14 +149,17 @@ var ChainsNamespace = class extends AbstractOffchainNamespace {
|
|
|
146
149
|
this.#chains = chains;
|
|
147
150
|
}
|
|
148
151
|
/**
|
|
149
|
-
* A client over the
|
|
150
|
-
* has no definition
|
|
152
|
+
* A client over the transport the caller gave for the chain, or over the
|
|
153
|
+
* chain's own public endpoints, or nothing when this SDK has no definition
|
|
154
|
+
* for it.
|
|
151
155
|
*
|
|
152
156
|
* The backend will not hand over its endpoints — they carry provider keys —
|
|
153
|
-
* so the chain definition is all there is to go on
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
+
* so without `transports` the chain definition is all there is to go on,
|
|
158
|
+
* and its public endpoints rate limit anything past a glance. A caller that
|
|
159
|
+
* reads in earnest supplies its own. A chain the SDK does not know stays in
|
|
160
|
+
* {@link list}, because the backend serves it and its rows are readable
|
|
161
|
+
* through the backend; only the calls that have to reach it directly fail,
|
|
162
|
+
* and they say which chain they could not reach.
|
|
157
163
|
**/
|
|
158
164
|
#client(chainId) {
|
|
159
165
|
let chain;
|
|
@@ -163,6 +169,11 @@ var ChainsNamespace = class extends AbstractOffchainNamespace {
|
|
|
163
169
|
this.logger?.warn(`no chain definition for ${chainId}: it will be listed, but nothing can be read off it directly`);
|
|
164
170
|
return;
|
|
165
171
|
}
|
|
172
|
+
const supplied = this.#transports[chainId];
|
|
173
|
+
if (supplied) return createPublicClient({
|
|
174
|
+
chain,
|
|
175
|
+
transport: supplied
|
|
176
|
+
});
|
|
166
177
|
const urls = chain.rpcUrls.default.http;
|
|
167
178
|
if (urls.length === 0) {
|
|
168
179
|
this.logger?.warn(`no public endpoint for chain ${chainId}`);
|
|
@@ -6,10 +6,8 @@ import { ChainContractsRegister } from "../../../onchain/base/ChainContractsRegi
|
|
|
6
6
|
import { OnchainSDK } from "../../../onchain/OnchainSDK.js";
|
|
7
7
|
import "../../../onchain/index.js";
|
|
8
8
|
import { PriceFeedNotInStoreError } from "../errors.js";
|
|
9
|
-
import { INSTANCE_MANAGER } from "../../utils/literals.js";
|
|
10
9
|
import { PriceFeedStoreContract } from "../../bindings/price-feed-store.js";
|
|
11
10
|
import "../../deployment/addresses.js";
|
|
12
|
-
import { AddressProviderContract } from "../../bindings/address-provider.js";
|
|
13
11
|
import { InstanceManagerContract } from "../../bindings/instance-manager.js";
|
|
14
12
|
import { convertRawTxToSafeMultisigTx, getSafeBatch } from "../../utils/governance/batch.js";
|
|
15
13
|
import { getUpdatablePriceFeeds } from "../../utils/price-update/get-updatable-feeds.js";
|
|
@@ -162,8 +160,7 @@ var InstanceOwnerTransactions = class {
|
|
|
162
160
|
**/
|
|
163
161
|
async #batchContext(chainId) {
|
|
164
162
|
const client = this.#chains.client(chainId);
|
|
165
|
-
const
|
|
166
|
-
const instanceManager = new InstanceManagerContract(await addressProvider.getAddressOrRevert(INSTANCE_MANAGER), new ChainContractsRegister(client));
|
|
163
|
+
const instanceManager = new InstanceManagerContract("0x77777777144339Bdc3aCceE992D8d4D31734CB2e", new ChainContractsRegister(client));
|
|
167
164
|
return {
|
|
168
165
|
chainId,
|
|
169
166
|
client,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { BytecodeRepositoryContract } from "./bytecode-repository.js";
|
|
2
2
|
import { priceFeedSetupParams } from "./pricefeeds/index.js";
|
|
3
3
|
import { PriceFeedStoreContract } from "./price-feed-store.js";
|
|
4
|
-
import { AddressProviderContract } from "./address-provider.js";
|
|
5
4
|
import { TokenCompressorContract } from "./compressors/token-compressor.js";
|
|
6
5
|
import { WithdrawalCompressorContract } from "./compressors/withdrawal-compressor.js";
|
|
7
6
|
import "./compressors/index.js";
|
|
@@ -9,6 +8,7 @@ import { RoutingManagerContract } from "./router/routing-manager.js";
|
|
|
9
8
|
import "./router/index.js";
|
|
10
9
|
import { TreasurySplitterContract } from "./treasury-splitter.js";
|
|
11
10
|
import { InstanceManagerContract } from "./instance-manager.js";
|
|
11
|
+
import { AddressProviderContract } from "./address-provider.js";
|
|
12
12
|
import { MarketConfiguratorFactoryContract } from "./market-configurator-factory.js";
|
|
13
13
|
import { CrossChainMultisigContract } from "./cross-chain-multisig.js";
|
|
14
14
|
import { AccessMode } from "./types.js";
|
|
@@ -11,7 +11,6 @@ import { encodeFunctionParams } from "./utils/abi-encoder.js";
|
|
|
11
11
|
import { DEFAULT_DEPLOY_SALT, PermissionlessDeploy, priceFeedSalt } from "./api/deploy/PermissionlessDeploy.js";
|
|
12
12
|
import { getPrices } from "./utils/price-update/get-prices.js";
|
|
13
13
|
import { GET_PRICES_CHUNK_SIZE, GET_PRICES_GAS_LIMIT_BY_CHAIN_ID, PermissionlessOracles } from "./api/oracles/PermissionlessOracles.js";
|
|
14
|
-
import { AddressProviderContract } from "./bindings/address-provider.js";
|
|
15
14
|
import { TokenCompressorContract } from "./bindings/compressors/token-compressor.js";
|
|
16
15
|
import { WithdrawalCompressorContract } from "./bindings/compressors/withdrawal-compressor.js";
|
|
17
16
|
import { RoutingManagerContract } from "./bindings/router/routing-manager.js";
|
|
@@ -22,6 +21,7 @@ import { getUpdatablePriceFeeds } from "./utils/price-update/get-updatable-feeds
|
|
|
22
21
|
import { InstanceOwnerTransactions } from "./api/transactions/InstanceOwnerTransactions.js";
|
|
23
22
|
import { GearboxPermissionless } from "./api/GearboxPermissionless.js";
|
|
24
23
|
import "./api/index.js";
|
|
24
|
+
import { AddressProviderContract } from "./bindings/address-provider.js";
|
|
25
25
|
import { MarketConfiguratorFactoryContract } from "./bindings/market-configurator-factory.js";
|
|
26
26
|
import { CrossChainMultisigContract } from "./bindings/cross-chain-multisig.js";
|
|
27
27
|
import { PUBLIC_CREATE2_FACTORY, checkCreate2Deployment, checkCreate2DeploymentAddress, createCreate2DeployRawTx, deployUsingPublicCreate2, getCreate2AddressPublicFactory, getCreate2DeploymentAddress, handleSalt } from "./utils/create2.js";
|
|
@@ -26,8 +26,8 @@ import "./core/index.js";
|
|
|
26
26
|
import { GearboxState } from "./types/state.js";
|
|
27
27
|
import "./types/index.js";
|
|
28
28
|
import "./base/index.js";
|
|
29
|
-
import { ICreditAccountsService } from "./accounts/types.js";
|
|
30
29
|
import { LiquidationsService } from "./accounts/liquidations/LiquidationsService.js";
|
|
30
|
+
import { ICreditAccountsService } from "./accounts/types.js";
|
|
31
31
|
import "./accounts/index.js";
|
|
32
32
|
import { Address, PublicClient, Transport } from "viem";
|
|
33
33
|
import { HttpRpcClientOptions } from "viem/utils";
|
|
@@ -3,6 +3,12 @@ import { CreditAccountDataCall, CreditAccountFilter, CreditAccountReadOptions, C
|
|
|
3
3
|
import { CreditAccountCompressor } from "./credit-account-compressor/CreditAccountCompressor.js";
|
|
4
4
|
import { CreditAccountCompressorV310Contract } from "./credit-account-compressor/CreditAccountCompressorV310Contract.js";
|
|
5
5
|
import "./credit-account-compressor/index.js";
|
|
6
|
+
import { LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS } from "./liquidations/constants.js";
|
|
7
|
+
import { BuildLiquidationTxProps, BuildLiquidationTxPropsBase, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, LoadRWALiquidatorsProps, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, PartialLiquidationParams, RWALiquidatorInfo } from "./liquidations/types.js";
|
|
8
|
+
import { OptimalPartialLiquidation, OptimalPartialLiquidationProps, PartialLiquidationParamsProps, optimalPartialLiquidation, partialLiquidationParams } from "./liquidations/partialLiquidation.js";
|
|
9
|
+
import { LiquidationsService } from "./liquidations/LiquidationsService.js";
|
|
10
|
+
import { MultichainLiquidationsService } from "./liquidations/MultichainLiquidationsService.js";
|
|
11
|
+
import "./liquidations/index.js";
|
|
6
12
|
import { AbstractWithdrawalCompressorContract, OnchainRequestableWithdrawal, iCreditAccountAbi, toClaimableWithdrawal, toPendingWithdrawal, toRequestableWithdrawal } from "./withdrawal-compressor/AbstractWithdrawalCompressorContract.js";
|
|
7
13
|
import { WithdrawalCompressorLocation, WithdrawalCompressorVersion, getWithdrawalCompressorAddress } from "./withdrawal-compressor/addresses.js";
|
|
8
14
|
import { createRedemptionLogger } from "./withdrawal-compressor/createRedemptionLogger.js";
|
|
@@ -28,9 +34,4 @@ import { OpenStrategyProps, OpenStrategyState } from "./intents/open-strategy.js
|
|
|
28
34
|
import { fetchCreditAccountSlice, toCreditAccountSlice } from "./intents/utils/credit-account-slice.js";
|
|
29
35
|
import { isPhantomToken } from "./intents/utils/pick-token.js";
|
|
30
36
|
import { BorrowPreviewResult, CreditAccountOperationsService, EmptyAccountPreviewResult, OpenStrategyPreviewResult } from "./intents/index.js";
|
|
31
|
-
|
|
32
|
-
import { BuildLiquidationTxProps, BuildLiquidationTxPropsBase, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, LoadRWALiquidatorsProps, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, RWALiquidatorInfo } from "./liquidations/types.js";
|
|
33
|
-
import { LiquidationsService } from "./liquidations/LiquidationsService.js";
|
|
34
|
-
import { MultichainLiquidationsService } from "./liquidations/MultichainLiquidationsService.js";
|
|
35
|
-
import "./liquidations/index.js";
|
|
36
|
-
export { AbstractWithdrawalCompressorContract, AccountBotsService, type AccountCalculatorOperation, AccountToCheck, type AddCollateralIntent, type AdjustLeverageIntent, AssembleCaOperationsProps, AssembleClaimDelayedCallsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, AssembleStartDelayedWithdrawalCallsProps, BorrowPreviewResult, type BorrowProps, type BorrowState, BotStatusCall, BotsDirectResponse, BuildLiquidationTxProps, BuildLiquidationTxPropsBase, CMSlice, CalcDefaultQuotaProps, CalcQuotaUpdateProps, CalcRecommendedQuotaProps, ClaimFarmRewardsProps, type ClaimRemainder, ClaimableWithdrawal, CloseCreditAccountResult, ConnectedBotsCall, ConnectedBotsPerAccount, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountDataCall, CreditAccountFilter, CreditAccountOperationResult, CreditAccountOperationsService, CreditAccountReadOptions, type CreditAccountSlice, CreditAccountsCall, CreditAccountsQuery, CreditAccountsReadOptions, CreditAccountsServiceV310, CreditAccountsTarget, CreditManagerFilter, CreditManagerOperationResult, CurrentWithdrawals, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DIRECT_TRANSFERS_QUOTA, type DelayableIntent, DelayedIntentExtended, type DelayedRoute, type DelayedStart, type DelayedStartResult, type DepositStrategyIntent, EmptyAccountPreviewResult, EncodableCreditAccountOperation, type ExecutionCost, type FinishIntentProps, type FinishIntentResult, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResponse, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsArgs, GetCreditAccountsOptions, GetExternalAccountCurrentWithdrawalsProps, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, GetWithdrawalRequestResultProps, ICreditAccountsService, IRedemptionLoggerContract, IWithdrawalCompressorContract, type InstantRoute, type IntentPreviewResult, type IntentRoutesResult, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, type LeverageBand, LiquidationsService, LoadRWALiquidatorsProps, MaxAmountForQuotaProps, MulticallWithFailure, MultichainLiquidationsService, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, OnchainRequestableWithdrawal, OpenCAProps, OpenStrategyPreviewResult, type OpenStrategyProps, type OpenStrategyState, type OperationState, PartiallyLiquidateProps, type PathLossRate, PendingWithdrawal, PeripheryCompressorV310Contract, PreviewDelayedWithdrawalProps, RWALiquidatorInfo, RedemptionLog, RedemptionLoggerV310Contract, type RefusedIntent, type RepayStrategyIntent, RequestableWithdrawal, type ResumableIntent, Rewards, type RouteErrors, SetBotProps, SetBotResult, type StartIntent, type WithPartialState, type WithdrawAssetIntent, type WithdrawCeilings, type WithdrawStrategyIntent, WithdrawableAsset, WithdrawalCompressorLocation, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WithdrawalCompressorVersion, WithdrawalOutput, WithdrawalStatus, WithdrawalsState, calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, createRedemptionLogger, createWithdrawalCompressor, decodeDelayedIntent, encodeDelayedIntent, fetchCreditAccountSlice, getWithdrawalCompressorAddress, iCreditAccountAbi, isPhantomToken, maxAmountForQuota, roundUpQuota, toClaimableWithdrawal, toCreditAccountSlice, toPendingWithdrawal, toRequestableWithdrawal, toWithdrawalStatus };
|
|
37
|
+
export { AbstractWithdrawalCompressorContract, AccountBotsService, type AccountCalculatorOperation, AccountToCheck, type AddCollateralIntent, type AdjustLeverageIntent, AssembleCaOperationsProps, AssembleClaimDelayedCallsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, AssembleStartDelayedWithdrawalCallsProps, BorrowPreviewResult, type BorrowProps, type BorrowState, BotStatusCall, BotsDirectResponse, BuildLiquidationTxProps, BuildLiquidationTxPropsBase, CMSlice, CalcDefaultQuotaProps, CalcQuotaUpdateProps, CalcRecommendedQuotaProps, ClaimFarmRewardsProps, type ClaimRemainder, ClaimableWithdrawal, CloseCreditAccountResult, ConnectedBotsCall, ConnectedBotsPerAccount, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountDataCall, CreditAccountFilter, CreditAccountOperationResult, CreditAccountOperationsService, CreditAccountReadOptions, type CreditAccountSlice, CreditAccountsCall, CreditAccountsQuery, CreditAccountsReadOptions, CreditAccountsServiceV310, CreditAccountsTarget, CreditManagerFilter, CreditManagerOperationResult, CurrentWithdrawals, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DIRECT_TRANSFERS_QUOTA, type DelayableIntent, DelayedIntentExtended, type DelayedRoute, type DelayedStart, type DelayedStartResult, type DepositStrategyIntent, EmptyAccountPreviewResult, EncodableCreditAccountOperation, type ExecutionCost, type FinishIntentProps, type FinishIntentResult, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResponse, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsArgs, GetCreditAccountsOptions, GetExternalAccountCurrentWithdrawalsProps, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, GetWithdrawalRequestResultProps, ICreditAccountsService, IRedemptionLoggerContract, IWithdrawalCompressorContract, type InstantRoute, type IntentPreviewResult, type IntentRoutesResult, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, type LeverageBand, LiquidationsService, LoadRWALiquidatorsProps, MaxAmountForQuotaProps, MulticallWithFailure, MultichainLiquidationsService, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, OnchainRequestableWithdrawal, OpenCAProps, OpenStrategyPreviewResult, type OpenStrategyProps, type OpenStrategyState, type OperationState, OptimalPartialLiquidation, OptimalPartialLiquidationProps, PartialLiquidationParams, PartialLiquidationParamsProps, PartiallyLiquidateProps, type PathLossRate, PendingWithdrawal, PeripheryCompressorV310Contract, PreviewDelayedWithdrawalProps, RWALiquidatorInfo, RedemptionLog, RedemptionLoggerV310Contract, type RefusedIntent, type RepayStrategyIntent, RequestableWithdrawal, type ResumableIntent, Rewards, type RouteErrors, SetBotProps, SetBotResult, type StartIntent, type WithPartialState, type WithdrawAssetIntent, type WithdrawCeilings, type WithdrawStrategyIntent, WithdrawableAsset, WithdrawalCompressorLocation, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WithdrawalCompressorVersion, WithdrawalOutput, WithdrawalStatus, WithdrawalsState, calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, createRedemptionLogger, createWithdrawalCompressor, decodeDelayedIntent, encodeDelayedIntent, fetchCreditAccountSlice, getWithdrawalCompressorAddress, iCreditAccountAbi, isPhantomToken, maxAmountForQuota, optimalPartialLiquidation, partialLiquidationParams, roundUpQuota, toClaimableWithdrawal, toCreditAccountSlice, toPendingWithdrawal, toRequestableWithdrawal, toWithdrawalStatus };
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { TxCall } from "../../../model/primitives.js";
|
|
2
2
|
import { LiquidatableAccount, LiquidationDetails, LiquidationPosition } from "../../../model/liquidations.js";
|
|
3
3
|
import "../../../model/index.js";
|
|
4
|
+
import { CreditAccountData } from "../../base/types.js";
|
|
4
5
|
import { SDKConstruct } from "../../base/SDKConstruct.js";
|
|
5
6
|
import "../../base/index.js";
|
|
6
|
-
import { BuildLiquidationTxProps, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationPositionsProps, LoadRWALiquidatorsProps } from "./types.js";
|
|
7
|
+
import { BuildLiquidationTxProps, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationPositionsProps, LoadRWALiquidatorsProps, PartialLiquidationParams } from "./types.js";
|
|
8
|
+
import { OptimalPartialLiquidation } from "./partialLiquidation.js";
|
|
7
9
|
//#region src/onchain/accounts/liquidations/LiquidationsService.d.ts
|
|
8
10
|
/**
|
|
9
11
|
* Service for discovering liquidatable credit accounts and previewing manual
|
|
@@ -28,6 +30,30 @@ declare class LiquidationsService extends SDKConstruct {
|
|
|
28
30
|
* the debt from own funds and receiving the collateral from the credit account.
|
|
29
31
|
**/
|
|
30
32
|
buildLiquidationTx(props: BuildLiquidationTxProps): Promise<TxCall>;
|
|
33
|
+
/**
|
|
34
|
+
* Optimal partial liquidation of a credit account: the collateral to seize
|
|
35
|
+
* and the amounts that bring its health factor close to `optimalHF`.
|
|
36
|
+
*
|
|
37
|
+
* Prices come from the last synced oracle state and `ca`, not from fresh
|
|
38
|
+
* price updates. Withdrawal phantom tokens are never seized.
|
|
39
|
+
*
|
|
40
|
+
* @param ca - Credit account to partially liquidate.
|
|
41
|
+
* @param optimalHF - Health factor to aim for, in basis points. Defaults to
|
|
42
|
+
* {@link CreditSuite.optimalHFForPartialLiquidation}.
|
|
43
|
+
* @throws If no `tokenOut` can be picked.
|
|
44
|
+
**/
|
|
45
|
+
getOptimalPartialLiquidation(ca: CreditAccountData, optimalHF?: bigint): OptimalPartialLiquidation;
|
|
46
|
+
/**
|
|
47
|
+
* Everything a partial liquidation of a credit account needs, with any
|
|
48
|
+
* parameter the caller pinned down taken as given and the rest derived from
|
|
49
|
+
* current state. A derived `tokenOut` is never a withdrawal phantom token.
|
|
50
|
+
*
|
|
51
|
+
* @param ca - Credit account to partially liquidate.
|
|
52
|
+
* @param overrides - Parameters to use instead of the derived defaults.
|
|
53
|
+
* @throws If a derived `tokenOut` cannot be picked, or if the seized token is
|
|
54
|
+
* not a collateral token of the credit manager.
|
|
55
|
+
**/
|
|
56
|
+
getPartialLiquidationParams(ca: CreditAccountData, overrides?: PartialLiquidationParams): Required<PartialLiquidationParams>;
|
|
31
57
|
/**
|
|
32
58
|
* Returns the status of delayed-withdrawal positions (redemption receipts)
|
|
33
59
|
* owned by a liquidator wallet: what is receivable, how much, and when it
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS } from "./constants.js";
|
|
2
|
-
import { BuildLiquidationTxProps, BuildLiquidationTxPropsBase, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, LoadRWALiquidatorsProps, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, RWALiquidatorInfo } from "./types.js";
|
|
2
|
+
import { BuildLiquidationTxProps, BuildLiquidationTxPropsBase, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, LoadRWALiquidatorsProps, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, PartialLiquidationParams, RWALiquidatorInfo } from "./types.js";
|
|
3
|
+
import { OptimalPartialLiquidation, OptimalPartialLiquidationProps, PartialLiquidationParamsProps, optimalPartialLiquidation, partialLiquidationParams } from "./partialLiquidation.js";
|
|
3
4
|
import { LiquidationsService } from "./LiquidationsService.js";
|
|
4
5
|
import { MultichainLiquidationsService } from "./MultichainLiquidationsService.js";
|
|
5
|
-
export { BuildLiquidationTxProps, BuildLiquidationTxPropsBase, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LiquidationsService, LoadRWALiquidatorsProps, MultichainLiquidationsService, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, RWALiquidatorInfo };
|
|
6
|
+
export { BuildLiquidationTxProps, BuildLiquidationTxPropsBase, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LiquidationsService, LoadRWALiquidatorsProps, MultichainLiquidationsService, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, OptimalPartialLiquidation, OptimalPartialLiquidationProps, PartialLiquidationParams, PartialLiquidationParamsProps, RWALiquidatorInfo, optimalPartialLiquidation, partialLiquidationParams };
|