@gearbox-protocol/sdk 14.12.0-next.65 → 14.12.0-next.67
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/common-utils/index.js +2 -2
- package/dist/cjs/common-utils/utils/apy/calculate-safe-borrow-rate.js +3 -3
- package/dist/cjs/common-utils/utils/assets-math.js +7 -7
- package/dist/cjs/common-utils/utils/creditAccount/calc-health-factor.js +2 -2
- package/dist/cjs/common-utils/utils/creditAccount/debt.js +2 -2
- package/dist/cjs/common-utils/utils/creditAccount/quota-utils.js +5 -5
- package/dist/cjs/common-utils/utils/index.js +2 -2
- package/dist/cjs/common-utils/utils/strategies/leverage/calculate-max-leverage-factor.js +2 -2
- package/dist/cjs/common-utils/utils/strategies/leverage/calculate-max-strategy-debt.js +5 -5
- package/dist/cjs/common-utils/utils/strategies/strategy-info/calculate-total-points.js +2 -2
- package/dist/cjs/common-utils/utils/strategies/strategy-info/get-cm-you-can-earn.js +2 -2
- package/dist/cjs/common-utils/utils/validation/validate-open-account-pool-status.js +4 -4
- package/dist/cjs/dev/index.js +2 -1
- package/dist/cjs/dev/kycUtils.js +1 -1
- package/dist/cjs/dev/midasUtils.js +104 -0
- package/dist/cjs/model/history.js +28 -0
- package/dist/cjs/model/history.schema.js +84 -0
- package/dist/cjs/model/index.js +64 -0
- package/dist/cjs/model/liquidations.js +23 -0
- package/dist/cjs/model/liquidations.schema.js +91 -0
- package/dist/cjs/model/opportunities.js +55 -0
- package/dist/cjs/model/opportunities.schema.js +220 -0
- package/dist/cjs/model/package.json +1 -0
- package/dist/cjs/model/positions.js +1 -0
- package/dist/cjs/model/primitives.js +1 -0
- package/dist/cjs/model/primitives.schema.js +85 -0
- package/dist/cjs/new-sdk/AbstractNamespace.js +158 -0
- package/dist/cjs/new-sdk/GearboxSDK.js +122 -0
- package/dist/cjs/new-sdk/index.js +11 -0
- package/dist/cjs/new-sdk/opportunities/OpportunitiesNamespace.js +122 -0
- package/dist/cjs/new-sdk/opportunities/index.js +4 -0
- package/dist/cjs/new-sdk/opportunities/types.js +1 -0
- package/dist/cjs/new-sdk/package.json +1 -0
- package/dist/cjs/new-sdk/types.js +22 -0
- package/dist/cjs/new-sdk/utils/history.js +1 -0
- package/dist/cjs/new-sdk/utils/index.js +2 -0
- package/dist/cjs/offchain/GearboxAPI.js +33 -0
- package/dist/cjs/offchain/index.js +8 -0
- package/dist/cjs/offchain/opportunities/OffchainOpportunities.js +97 -0
- package/dist/cjs/offchain/opportunities/index.js +4 -0
- package/dist/cjs/offchain/package.json +1 -0
- package/dist/cjs/offchain/types.js +1 -0
- package/dist/cjs/preview/preview/buildDelayedPreview.js +5 -5
- package/dist/cjs/rewards/rewards/api.js +2 -2
- package/dist/cjs/rewards/rewards/extra-apy.js +2 -2
- package/dist/cjs/sdk/MultichainSDK.js +18 -2
- package/dist/cjs/sdk/OnchainSDK.js +8 -1
- package/dist/cjs/sdk/accounts/index.js +2 -0
- package/dist/cjs/sdk/accounts/liquidations/LiquidationsService.js +150 -106
- package/dist/cjs/sdk/accounts/liquidations/MultichainLiquidationsService.js +32 -38
- package/dist/cjs/sdk/accounts/liquidations/constants.js +13 -0
- package/dist/cjs/sdk/accounts/liquidations/index.js +2 -0
- package/dist/cjs/sdk/base/MultichainConstruct.js +80 -0
- package/dist/cjs/sdk/base/TokensMeta.js +51 -0
- package/dist/cjs/sdk/base/index.js +2 -0
- package/dist/cjs/sdk/chain/chains.js +76 -0
- package/dist/cjs/sdk/chain/index.js +4 -0
- package/dist/cjs/sdk/core/errors.js +13 -0
- package/dist/cjs/sdk/core/index.js +2 -1
- package/dist/cjs/sdk/index.js +25 -1
- package/dist/cjs/sdk/market/MarketConfiguratorContract.js +14 -0
- package/dist/cjs/sdk/market/MarketSuite.js +163 -0
- package/dist/cjs/sdk/market/credit/CreditManagerV310Contract.js +26 -0
- package/dist/cjs/sdk/market/credit/CreditSuite.js +102 -0
- package/dist/cjs/sdk/market/math.js +104 -0
- package/dist/cjs/sdk/market/oracle/PriceOracleBaseContract.js +52 -0
- package/dist/cjs/sdk/market/pool/LinearInterestRateModelContract.js +30 -0
- package/dist/cjs/sdk/market/pool/PoolQuotaKeeperV310Contract.js +26 -0
- package/dist/cjs/sdk/market/pool/PoolSuite.js +28 -0
- package/dist/cjs/sdk/market/pool/PoolV310Contract.js +27 -0
- package/dist/cjs/sdk/market/pool/math.js +44 -0
- package/dist/cjs/sdk/market/pricefeeds/AbstractPriceFeed.js +17 -0
- package/dist/cjs/sdk/opportunities/MultichainOpportunitiesService.js +60 -0
- package/dist/cjs/sdk/opportunities/OpportunitiesService.js +103 -0
- package/dist/cjs/sdk/opportunities/index.js +12 -0
- package/dist/cjs/sdk/types/multichain.js +1 -0
- package/dist/cjs/{common-utils → sdk}/utils/bigint-math.js +11 -11
- package/dist/cjs/sdk/utils/index.js +3 -0
- package/dist/cjs/sdk/utils/zod.js +12 -0
- package/dist/esm/common-utils/index.js +1 -1
- package/dist/esm/common-utils/utils/apy/calculate-safe-borrow-rate.js +1 -1
- package/dist/esm/common-utils/utils/assets-math.js +1 -1
- package/dist/esm/common-utils/utils/creditAccount/calc-health-factor.js +1 -1
- package/dist/esm/common-utils/utils/creditAccount/debt.js +1 -1
- package/dist/esm/common-utils/utils/creditAccount/quota-utils.js +1 -1
- package/dist/esm/common-utils/utils/index.js +1 -1
- package/dist/esm/common-utils/utils/strategies/leverage/calculate-max-leverage-factor.js +1 -1
- package/dist/esm/common-utils/utils/strategies/leverage/calculate-max-strategy-debt.js +1 -1
- package/dist/esm/common-utils/utils/strategies/strategy-info/calculate-total-points.js +1 -1
- package/dist/esm/common-utils/utils/strategies/strategy-info/get-cm-you-can-earn.js +1 -1
- package/dist/esm/common-utils/utils/validation/validate-open-account-pool-status.js +1 -1
- package/dist/esm/dev/AccountOpener.js +1 -1
- package/dist/esm/dev/index.js +3 -3
- package/dist/esm/dev/kycUtils.js +1 -1
- package/dist/esm/dev/midasUtils.js +105 -2
- package/dist/esm/dev/withdrawalUtils.js +1 -1
- package/dist/esm/model/history.js +26 -0
- package/dist/esm/model/history.schema.js +76 -0
- package/dist/esm/model/index.js +9 -0
- package/dist/esm/model/liquidations.js +22 -0
- package/dist/esm/model/liquidations.schema.js +83 -0
- package/dist/esm/model/opportunities.js +51 -0
- package/dist/esm/model/opportunities.schema.js +198 -0
- package/dist/esm/model/package.json +1 -0
- package/dist/esm/model/positions.js +1 -0
- package/dist/esm/model/primitives.js +1 -0
- package/dist/esm/model/primitives.schema.js +75 -0
- package/dist/esm/new-sdk/AbstractNamespace.js +157 -0
- package/dist/esm/new-sdk/GearboxSDK.js +121 -0
- package/dist/esm/new-sdk/index.js +7 -0
- package/dist/esm/new-sdk/opportunities/OpportunitiesNamespace.js +121 -0
- package/dist/esm/new-sdk/opportunities/index.js +3 -0
- package/dist/esm/new-sdk/opportunities/types.js +1 -0
- package/dist/esm/new-sdk/package.json +1 -0
- package/dist/esm/new-sdk/types.js +21 -0
- package/dist/esm/new-sdk/utils/history.js +1 -0
- package/dist/esm/new-sdk/utils/index.js +2 -0
- package/dist/esm/offchain/GearboxAPI.js +32 -0
- package/dist/esm/offchain/index.js +5 -0
- package/dist/esm/offchain/opportunities/OffchainOpportunities.js +95 -0
- package/dist/esm/offchain/opportunities/index.js +2 -0
- package/dist/esm/offchain/package.json +1 -0
- package/dist/esm/offchain/types.js +1 -0
- package/dist/esm/preview/preview/buildDelayedPreview.js +1 -1
- package/dist/esm/preview/simulate/simulatePoolOperation.js +1 -1
- package/dist/esm/preview/trace/extractTransfers.js +1 -1
- package/dist/esm/rewards/rewards/api.js +1 -1
- package/dist/esm/rewards/rewards/extra-apy.js +1 -1
- package/dist/esm/sdk/MultichainSDK.js +18 -2
- package/dist/esm/sdk/OnchainSDK.js +8 -1
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +2 -2
- package/dist/esm/sdk/accounts/index.js +2 -2
- package/dist/esm/sdk/accounts/liquidations/LiquidationsService.js +153 -109
- package/dist/esm/sdk/accounts/liquidations/MultichainLiquidationsService.js +32 -38
- package/dist/esm/sdk/accounts/liquidations/constants.js +12 -1
- package/dist/esm/sdk/accounts/liquidations/index.js +2 -2
- package/dist/esm/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
- package/dist/esm/sdk/base/MultichainConstruct.js +79 -0
- package/dist/esm/sdk/base/TokensMeta.js +53 -2
- package/dist/esm/sdk/base/index.js +2 -1
- package/dist/esm/sdk/chain/chains.js +74 -2
- package/dist/esm/sdk/chain/detectNetwork.js +1 -1
- package/dist/esm/sdk/chain/index.js +2 -2
- package/dist/esm/sdk/core/createAddressProvider.js +1 -1
- package/dist/esm/sdk/core/errors.js +13 -1
- package/dist/esm/sdk/core/index.js +2 -2
- package/dist/esm/sdk/index.js +11 -5
- package/dist/esm/sdk/market/MarketConfiguratorContract.js +14 -0
- package/dist/esm/sdk/market/MarketSuite.js +163 -0
- package/dist/esm/sdk/market/credit/CreditFacadeV310BaseContract.js +1 -1
- package/dist/esm/sdk/market/credit/CreditManagerV310Contract.js +26 -0
- package/dist/esm/sdk/market/credit/CreditSuite.js +102 -0
- package/dist/esm/sdk/market/math.js +98 -0
- package/dist/esm/sdk/market/oracle/PriceOracleBaseContract.js +52 -0
- package/dist/esm/sdk/market/pool/LinearInterestRateModelContract.js +30 -0
- package/dist/esm/sdk/market/pool/PoolQuotaKeeperV310Contract.js +26 -0
- package/dist/esm/sdk/market/pool/PoolSuite.js +28 -0
- package/dist/esm/sdk/market/pool/PoolV310Contract.js +28 -1
- package/dist/esm/sdk/market/pool/math.js +41 -0
- package/dist/esm/sdk/market/pricefeeds/AbstractPriceFeed.js +17 -0
- package/dist/esm/sdk/market/zapper/IETHZapperContract.js +1 -1
- package/dist/esm/sdk/market/zapper/ZapperContract.js +1 -1
- package/dist/esm/sdk/opportunities/MultichainOpportunitiesService.js +59 -0
- package/dist/esm/sdk/opportunities/OpportunitiesService.js +102 -0
- package/dist/esm/sdk/opportunities/index.js +4 -0
- package/dist/esm/sdk/pools/PoolService.js +1 -1
- package/dist/esm/sdk/types/multichain.js +1 -0
- package/dist/esm/{common-utils → sdk}/utils/bigint-math.js +11 -11
- package/dist/esm/sdk/utils/index.js +3 -2
- package/dist/esm/sdk/utils/viem/simulateWithPriceUpdates.js +1 -1
- package/dist/esm/sdk/utils/zod.js +13 -2
- package/dist/types/common-utils/index.d.ts +1 -1
- package/dist/types/common-utils/utils/index.d.ts +1 -1
- package/dist/types/dev/index.d.ts +2 -2
- package/dist/types/dev/midasUtils.d.ts +31 -2
- package/dist/types/model/history.d.ts +105 -0
- package/dist/types/model/history.schema.d.ts +66 -0
- package/dist/types/model/index.d.ts +9 -0
- package/dist/types/model/liquidations.d.ts +230 -0
- package/dist/types/model/liquidations.schema.d.ts +292 -0
- package/dist/types/model/opportunities.d.ts +543 -0
- package/dist/types/model/opportunities.schema.d.ts +1066 -0
- package/dist/types/model/positions.d.ts +11 -0
- package/dist/types/model/primitives.d.ts +193 -0
- package/dist/types/model/primitives.schema.d.ts +81 -0
- package/dist/types/new-sdk/AbstractNamespace.d.ts +119 -0
- package/dist/types/new-sdk/GearboxSDK.d.ts +78 -0
- package/dist/types/new-sdk/index.d.ts +9 -0
- package/dist/types/new-sdk/opportunities/OpportunitiesNamespace.d.ts +69 -0
- package/dist/types/new-sdk/opportunities/index.d.ts +3 -0
- package/dist/types/new-sdk/opportunities/types.d.ts +66 -0
- package/dist/types/new-sdk/types.d.ts +149 -0
- package/dist/types/new-sdk/utils/history.d.ts +44 -0
- package/dist/types/new-sdk/utils/index.d.ts +2 -0
- package/dist/types/offchain/GearboxAPI.d.ts +31 -0
- package/dist/types/offchain/index.d.ts +5 -0
- package/dist/types/offchain/opportunities/OffchainOpportunities.d.ts +69 -0
- package/dist/types/offchain/opportunities/index.d.ts +2 -0
- package/dist/types/offchain/types.d.ts +50 -0
- package/dist/types/sdk/MultichainSDK.d.ts +15 -2
- package/dist/types/sdk/OnchainSDK.d.ts +9 -3
- package/dist/types/sdk/accounts/index.d.ts +3 -3
- package/dist/types/sdk/accounts/liquidations/LiquidationsService.d.ts +24 -16
- package/dist/types/sdk/accounts/liquidations/MultichainLiquidationsService.d.ts +26 -20
- package/dist/types/sdk/accounts/liquidations/constants.d.ts +12 -1
- package/dist/types/sdk/accounts/liquidations/index.d.ts +3 -3
- package/dist/types/sdk/accounts/liquidations/types.d.ts +34 -309
- package/dist/types/sdk/base/MultichainConstruct.d.ts +57 -0
- package/dist/types/sdk/base/TokensMeta.d.ts +26 -0
- package/dist/types/sdk/base/index.d.ts +2 -1
- package/dist/types/sdk/chain/chains.d.ts +68 -1
- package/dist/types/sdk/chain/index.d.ts +2 -2
- package/dist/types/sdk/core/errors.d.ts +10 -1
- package/dist/types/sdk/core/index.d.ts +2 -2
- package/dist/types/sdk/index.d.ts +15 -8
- package/dist/types/sdk/market/MarketConfiguratorContract.d.ts +9 -0
- package/dist/types/sdk/market/MarketSuite.d.ts +109 -1
- package/dist/types/sdk/market/credit/CreditManagerV310Contract.d.ts +14 -0
- package/dist/types/sdk/market/credit/CreditSuite.d.ts +47 -0
- package/dist/types/sdk/market/credit/types.d.ts +22 -0
- package/dist/types/sdk/market/index.d.ts +2 -2
- package/dist/types/sdk/market/math.d.ts +74 -0
- package/dist/types/sdk/market/oracle/PriceOracleBaseContract.d.ts +23 -0
- package/dist/types/sdk/market/oracle/types.d.ts +46 -0
- package/dist/types/sdk/market/pool/LinearInterestRateModelContract.d.ts +12 -0
- package/dist/types/sdk/market/pool/PoolQuotaKeeperV310Contract.d.ts +22 -1
- package/dist/types/sdk/market/pool/PoolSuite.d.ts +23 -0
- package/dist/types/sdk/market/pool/PoolV310Contract.d.ts +18 -0
- package/dist/types/sdk/market/pool/math.d.ts +57 -0
- package/dist/types/sdk/market/pool/types.d.ts +23 -0
- package/dist/types/sdk/market/pricefeeds/AbstractPriceFeed.d.ts +6 -0
- package/dist/types/sdk/market/pricefeeds/types.d.ts +10 -0
- package/dist/types/sdk/opportunities/MultichainOpportunitiesService.d.ts +40 -0
- package/dist/types/sdk/opportunities/OpportunitiesService.d.ts +47 -0
- package/dist/types/sdk/opportunities/index.d.ts +4 -0
- package/dist/types/sdk/types/index.d.ts +2 -1
- package/dist/types/sdk/types/multichain.d.ts +65 -0
- package/dist/types/sdk/types/state.d.ts +1 -1
- package/dist/types/sdk/types/transactions.d.ts +3 -0
- package/dist/types/{common-utils → sdk}/utils/bigint-math.d.ts +7 -11
- package/dist/types/sdk/utils/index.d.ts +3 -2
- package/dist/types/sdk/utils/zod.d.ts +6 -2
- package/package.json +16 -1
- package/dist/cjs/sdk/accounts/liquidations/helpers.js +0 -201
- package/dist/esm/sdk/accounts/liquidations/helpers.js +0 -192
- package/dist/types/sdk/accounts/liquidations/helpers.d.ts +0 -140
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
require("../../constants/addresses.js");
|
|
3
|
-
const require_sdk_constants_math = require("../../constants/math.js");
|
|
4
|
-
require("../../constants/index.js");
|
|
5
|
-
const require_sdk_utils_hex = require("../../utils/hex.js");
|
|
6
|
-
require("../../utils/index.js");
|
|
7
|
-
let viem = require("viem");
|
|
8
|
-
//#region src/sdk/accounts/liquidations/helpers.ts
|
|
9
|
-
/**
|
|
10
|
-
* Token balances at or below this threshold are treated as dust and ignored,
|
|
11
|
-
* consistent with the rest of the SDK (see `filterDust`).
|
|
12
|
-
**/
|
|
13
|
-
const DUST_THRESHOLD = 10n;
|
|
14
|
-
/**
|
|
15
|
-
* Headroom (in bps) added on top of the amount the liquidation pulls when
|
|
16
|
-
* building the liquidator's approval, so that the transaction does not revert
|
|
17
|
-
* when prices move between the preview and the execution.
|
|
18
|
-
**/
|
|
19
|
-
const LIQUIDATION_APPROVAL_BUFFER = 50n;
|
|
20
|
-
/**
|
|
21
|
-
* Estimated amount (in underlying) the liquidator pays to fully liquidate an
|
|
22
|
-
* account: the part of total value used to repay debt and protocol fees.
|
|
23
|
-
*
|
|
24
|
-
* @param totalValue - Account total value in underlying
|
|
25
|
-
* @param liquidationDiscount - Liquidation discount in bps (`100% - liquidation premium`)
|
|
26
|
-
**/
|
|
27
|
-
function calcRepaymentAmount(totalValue, liquidationDiscount) {
|
|
28
|
-
return totalValue * BigInt(liquidationDiscount) / require_sdk_constants_math.PERCENTAGE_FACTOR;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Estimated liquidator profit (in underlying): the liquidation premium part
|
|
32
|
-
* of total value.
|
|
33
|
-
*
|
|
34
|
-
* @param totalValue - Account total value in underlying
|
|
35
|
-
* @param liquidationDiscount - Liquidation discount in bps (`100% - liquidation premium`)
|
|
36
|
-
**/
|
|
37
|
-
function calcEstimatedProfit(totalValue, liquidationDiscount) {
|
|
38
|
-
return totalValue * (require_sdk_constants_math.PERCENTAGE_FACTOR - BigInt(liquidationDiscount)) / require_sdk_constants_math.PERCENTAGE_FACTOR;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Picks the main asset being liquidated: the most valuable enabled
|
|
42
|
-
* non-underlying collateral token above dust (by oracle value in underlying).
|
|
43
|
-
* Returns `undefined` when the account has no eligible non-underlying
|
|
44
|
-
* collateral above dust.
|
|
45
|
-
*
|
|
46
|
-
* @param ca - Credit account data
|
|
47
|
-
* @param convert - Converts a token balance into its value in underlying;
|
|
48
|
-
* must return `0n` when the price is unavailable
|
|
49
|
-
**/
|
|
50
|
-
function pickMainAsset(ca, convert) {
|
|
51
|
-
let bestValue = 0n;
|
|
52
|
-
let bestToken;
|
|
53
|
-
for (const t of ca.tokens) {
|
|
54
|
-
if (require_sdk_utils_hex.hexEq(t.token, ca.underlying)) continue;
|
|
55
|
-
if ((t.mask & ca.enabledTokensMask) === 0n) continue;
|
|
56
|
-
if (t.balance <= 10n) continue;
|
|
57
|
-
const value = convert(t.token, t.balance);
|
|
58
|
-
if (value > bestValue) {
|
|
59
|
-
bestValue = value;
|
|
60
|
-
bestToken = t.token;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return bestToken;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Converts the single output of a liquidator's delayed withdrawal into an asset.
|
|
67
|
-
*
|
|
68
|
-
* @param outputs - `outputs` or `expectedOutputs` of a withdrawal
|
|
69
|
-
* @param sourceToken - Source token of the withdrawal, for error reporting
|
|
70
|
-
**/
|
|
71
|
-
function toWithdrawalOutputAsset(outputs, sourceToken) {
|
|
72
|
-
const [output] = outputs;
|
|
73
|
-
if (outputs.length !== 1 || !output) throw new Error(`expected exactly one output for withdrawal of ${sourceToken}, got ${outputs.length}`);
|
|
74
|
-
return {
|
|
75
|
-
balance: output.amount,
|
|
76
|
-
token: output.token
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Converts the claim calls of a liquidator's delayed withdrawal into a
|
|
81
|
-
* transaction.
|
|
82
|
-
*
|
|
83
|
-
* @param claimCalls - `claimCalls` of a claimable withdrawal
|
|
84
|
-
* @param sourceToken - Source token of the withdrawal, for error reporting
|
|
85
|
-
* @returns The claim transaction, or `undefined` when there is no claim call
|
|
86
|
-
**/
|
|
87
|
-
function toWithdrawalClaimTx(claimCalls, sourceToken) {
|
|
88
|
-
if (claimCalls.length > 1) throw new Error(`expected at most one claim call for withdrawal of ${sourceToken}, got ${claimCalls.length}`);
|
|
89
|
-
const [call] = claimCalls;
|
|
90
|
-
return call ? liquidationCallToRawTx(call) : void 0;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Flattens delayed withdrawals of a liquidator into rows: claimable
|
|
94
|
-
* withdrawals have no `claimableAt` (claimable now) and carry a `claimTx`,
|
|
95
|
-
* pending ones carry the estimated claim timestamp.
|
|
96
|
-
*
|
|
97
|
-
* @param current - Claimable and pending withdrawals from the withdrawal compressor
|
|
98
|
-
* @param network - Network the withdrawals live on
|
|
99
|
-
**/
|
|
100
|
-
function toLiquidatorWithdrawals(current, network, chainId) {
|
|
101
|
-
const rows = [];
|
|
102
|
-
for (const w of current.claimable) rows.push({
|
|
103
|
-
network,
|
|
104
|
-
chainId,
|
|
105
|
-
sourceToken: w.token,
|
|
106
|
-
output: toWithdrawalOutputAsset(w.outputs, w.token),
|
|
107
|
-
claimTx: toWithdrawalClaimTx(w.claimCalls, w.token),
|
|
108
|
-
redeemer: w.redeemer
|
|
109
|
-
});
|
|
110
|
-
for (const w of current.pending) rows.push({
|
|
111
|
-
network,
|
|
112
|
-
chainId,
|
|
113
|
-
sourceToken: w.token,
|
|
114
|
-
output: toWithdrawalOutputAsset(w.expectedOutputs, w.token),
|
|
115
|
-
claimableAt: w.claimableAt,
|
|
116
|
-
redeemer: w.redeemer
|
|
117
|
-
});
|
|
118
|
-
return rows;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Normalizes the liquidation compressor outputs into assets the liquidator
|
|
122
|
-
* receives. Zero `redeemerAddress` and `claimableAt` (used by the contracts
|
|
123
|
-
* for "not applicable") become `undefined`.
|
|
124
|
-
*
|
|
125
|
-
* @param outputs - `expectedOutputs` of the compressor's liquidation data
|
|
126
|
-
**/
|
|
127
|
-
function toReceivedAssets(outputs) {
|
|
128
|
-
return outputs.map((o) => {
|
|
129
|
-
if (!o.delayed) return {
|
|
130
|
-
isDelayed: false,
|
|
131
|
-
token: o.token,
|
|
132
|
-
amount: o.amount
|
|
133
|
-
};
|
|
134
|
-
return {
|
|
135
|
-
isDelayed: true,
|
|
136
|
-
token: o.token,
|
|
137
|
-
amount: o.amount,
|
|
138
|
-
redeemerAddress: require_sdk_utils_hex.hexEq(o.redeemerAddress, "0x0000000000000000000000000000000000000000") ? void 0 : o.redeemerAddress,
|
|
139
|
-
claimableAt: o.claimableAt === 0n ? void 0 : o.claimableAt
|
|
140
|
-
};
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Resolves the approval the liquidator must grant for the liquidation call.
|
|
145
|
-
*
|
|
146
|
-
* A call targeting the credit facade is paid by `msg.sender` but transferred by
|
|
147
|
-
* the credit manager, so the latter is the spender. Any other target is a
|
|
148
|
-
* dedicated liquidator contract (Midas / Securitize) that pulls the token to
|
|
149
|
-
* itself and re-approves the credit manager, so it is the spender itself.
|
|
150
|
-
*
|
|
151
|
-
* The approved amount includes {@link LIQUIDATION_APPROVAL_BUFFER} of headroom
|
|
152
|
-
* over the pulled amount to tolerate price movements.
|
|
153
|
-
*
|
|
154
|
-
* @param props - See {@link ToLiquidationApprovalProps}
|
|
155
|
-
* @returns The approval, or `undefined` when the call pulls nothing
|
|
156
|
-
**/
|
|
157
|
-
function toLiquidationApproval(props) {
|
|
158
|
-
const { target, creditFacade, creditManager, token, amount } = props;
|
|
159
|
-
if (amount === 0n) return;
|
|
160
|
-
return {
|
|
161
|
-
spender: require_sdk_utils_hex.hexEq(target, creditFacade) ? creditManager : target,
|
|
162
|
-
token,
|
|
163
|
-
amount: amount * (require_sdk_constants_math.PERCENTAGE_FACTOR + LIQUIDATION_APPROVAL_BUFFER) / require_sdk_constants_math.PERCENTAGE_FACTOR
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Converts the compressor's liquidation call into a raw transaction.
|
|
168
|
-
*
|
|
169
|
-
* The calldata is passed through as-is: depending on the liquidated assets,
|
|
170
|
-
* the target is either the credit facade or a dedicated liquidator contract
|
|
171
|
-
* (with its own function signature), so it cannot be re-encoded from a single
|
|
172
|
-
* known ABI.
|
|
173
|
-
*
|
|
174
|
-
* @param call - `liquidationCall` of the compressor's liquidation data
|
|
175
|
-
* @param description - Optional human-readable description
|
|
176
|
-
**/
|
|
177
|
-
function liquidationCallToRawTx(call, description) {
|
|
178
|
-
return {
|
|
179
|
-
to: call.target,
|
|
180
|
-
value: "0",
|
|
181
|
-
signature: "",
|
|
182
|
-
callData: call.callData,
|
|
183
|
-
contractMethod: {
|
|
184
|
-
name: (0, viem.slice)(call.callData, 0, 4),
|
|
185
|
-
inputs: [],
|
|
186
|
-
payable: false
|
|
187
|
-
},
|
|
188
|
-
contractInputsValues: {},
|
|
189
|
-
description
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
//#endregion
|
|
193
|
-
exports.DUST_THRESHOLD = DUST_THRESHOLD;
|
|
194
|
-
exports.LIQUIDATION_APPROVAL_BUFFER = LIQUIDATION_APPROVAL_BUFFER;
|
|
195
|
-
exports.calcEstimatedProfit = calcEstimatedProfit;
|
|
196
|
-
exports.calcRepaymentAmount = calcRepaymentAmount;
|
|
197
|
-
exports.liquidationCallToRawTx = liquidationCallToRawTx;
|
|
198
|
-
exports.pickMainAsset = pickMainAsset;
|
|
199
|
-
exports.toLiquidationApproval = toLiquidationApproval;
|
|
200
|
-
exports.toLiquidatorWithdrawals = toLiquidatorWithdrawals;
|
|
201
|
-
exports.toReceivedAssets = toReceivedAssets;
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import "../../constants/addresses.js";
|
|
2
|
-
import { PERCENTAGE_FACTOR } from "../../constants/math.js";
|
|
3
|
-
import "../../constants/index.js";
|
|
4
|
-
import { hexEq } from "../../utils/hex.js";
|
|
5
|
-
import "../../utils/index.js";
|
|
6
|
-
import { slice } from "viem";
|
|
7
|
-
//#region src/sdk/accounts/liquidations/helpers.ts
|
|
8
|
-
/**
|
|
9
|
-
* Token balances at or below this threshold are treated as dust and ignored,
|
|
10
|
-
* consistent with the rest of the SDK (see `filterDust`).
|
|
11
|
-
**/
|
|
12
|
-
const DUST_THRESHOLD = 10n;
|
|
13
|
-
/**
|
|
14
|
-
* Headroom (in bps) added on top of the amount the liquidation pulls when
|
|
15
|
-
* building the liquidator's approval, so that the transaction does not revert
|
|
16
|
-
* when prices move between the preview and the execution.
|
|
17
|
-
**/
|
|
18
|
-
const LIQUIDATION_APPROVAL_BUFFER = 50n;
|
|
19
|
-
/**
|
|
20
|
-
* Estimated amount (in underlying) the liquidator pays to fully liquidate an
|
|
21
|
-
* account: the part of total value used to repay debt and protocol fees.
|
|
22
|
-
*
|
|
23
|
-
* @param totalValue - Account total value in underlying
|
|
24
|
-
* @param liquidationDiscount - Liquidation discount in bps (`100% - liquidation premium`)
|
|
25
|
-
**/
|
|
26
|
-
function calcRepaymentAmount(totalValue, liquidationDiscount) {
|
|
27
|
-
return totalValue * BigInt(liquidationDiscount) / PERCENTAGE_FACTOR;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Estimated liquidator profit (in underlying): the liquidation premium part
|
|
31
|
-
* of total value.
|
|
32
|
-
*
|
|
33
|
-
* @param totalValue - Account total value in underlying
|
|
34
|
-
* @param liquidationDiscount - Liquidation discount in bps (`100% - liquidation premium`)
|
|
35
|
-
**/
|
|
36
|
-
function calcEstimatedProfit(totalValue, liquidationDiscount) {
|
|
37
|
-
return totalValue * (PERCENTAGE_FACTOR - BigInt(liquidationDiscount)) / PERCENTAGE_FACTOR;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Picks the main asset being liquidated: the most valuable enabled
|
|
41
|
-
* non-underlying collateral token above dust (by oracle value in underlying).
|
|
42
|
-
* Returns `undefined` when the account has no eligible non-underlying
|
|
43
|
-
* collateral above dust.
|
|
44
|
-
*
|
|
45
|
-
* @param ca - Credit account data
|
|
46
|
-
* @param convert - Converts a token balance into its value in underlying;
|
|
47
|
-
* must return `0n` when the price is unavailable
|
|
48
|
-
**/
|
|
49
|
-
function pickMainAsset(ca, convert) {
|
|
50
|
-
let bestValue = 0n;
|
|
51
|
-
let bestToken;
|
|
52
|
-
for (const t of ca.tokens) {
|
|
53
|
-
if (hexEq(t.token, ca.underlying)) continue;
|
|
54
|
-
if ((t.mask & ca.enabledTokensMask) === 0n) continue;
|
|
55
|
-
if (t.balance <= 10n) continue;
|
|
56
|
-
const value = convert(t.token, t.balance);
|
|
57
|
-
if (value > bestValue) {
|
|
58
|
-
bestValue = value;
|
|
59
|
-
bestToken = t.token;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return bestToken;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Converts the single output of a liquidator's delayed withdrawal into an asset.
|
|
66
|
-
*
|
|
67
|
-
* @param outputs - `outputs` or `expectedOutputs` of a withdrawal
|
|
68
|
-
* @param sourceToken - Source token of the withdrawal, for error reporting
|
|
69
|
-
**/
|
|
70
|
-
function toWithdrawalOutputAsset(outputs, sourceToken) {
|
|
71
|
-
const [output] = outputs;
|
|
72
|
-
if (outputs.length !== 1 || !output) throw new Error(`expected exactly one output for withdrawal of ${sourceToken}, got ${outputs.length}`);
|
|
73
|
-
return {
|
|
74
|
-
balance: output.amount,
|
|
75
|
-
token: output.token
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Converts the claim calls of a liquidator's delayed withdrawal into a
|
|
80
|
-
* transaction.
|
|
81
|
-
*
|
|
82
|
-
* @param claimCalls - `claimCalls` of a claimable withdrawal
|
|
83
|
-
* @param sourceToken - Source token of the withdrawal, for error reporting
|
|
84
|
-
* @returns The claim transaction, or `undefined` when there is no claim call
|
|
85
|
-
**/
|
|
86
|
-
function toWithdrawalClaimTx(claimCalls, sourceToken) {
|
|
87
|
-
if (claimCalls.length > 1) throw new Error(`expected at most one claim call for withdrawal of ${sourceToken}, got ${claimCalls.length}`);
|
|
88
|
-
const [call] = claimCalls;
|
|
89
|
-
return call ? liquidationCallToRawTx(call) : void 0;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Flattens delayed withdrawals of a liquidator into rows: claimable
|
|
93
|
-
* withdrawals have no `claimableAt` (claimable now) and carry a `claimTx`,
|
|
94
|
-
* pending ones carry the estimated claim timestamp.
|
|
95
|
-
*
|
|
96
|
-
* @param current - Claimable and pending withdrawals from the withdrawal compressor
|
|
97
|
-
* @param network - Network the withdrawals live on
|
|
98
|
-
**/
|
|
99
|
-
function toLiquidatorWithdrawals(current, network, chainId) {
|
|
100
|
-
const rows = [];
|
|
101
|
-
for (const w of current.claimable) rows.push({
|
|
102
|
-
network,
|
|
103
|
-
chainId,
|
|
104
|
-
sourceToken: w.token,
|
|
105
|
-
output: toWithdrawalOutputAsset(w.outputs, w.token),
|
|
106
|
-
claimTx: toWithdrawalClaimTx(w.claimCalls, w.token),
|
|
107
|
-
redeemer: w.redeemer
|
|
108
|
-
});
|
|
109
|
-
for (const w of current.pending) rows.push({
|
|
110
|
-
network,
|
|
111
|
-
chainId,
|
|
112
|
-
sourceToken: w.token,
|
|
113
|
-
output: toWithdrawalOutputAsset(w.expectedOutputs, w.token),
|
|
114
|
-
claimableAt: w.claimableAt,
|
|
115
|
-
redeemer: w.redeemer
|
|
116
|
-
});
|
|
117
|
-
return rows;
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Normalizes the liquidation compressor outputs into assets the liquidator
|
|
121
|
-
* receives. Zero `redeemerAddress` and `claimableAt` (used by the contracts
|
|
122
|
-
* for "not applicable") become `undefined`.
|
|
123
|
-
*
|
|
124
|
-
* @param outputs - `expectedOutputs` of the compressor's liquidation data
|
|
125
|
-
**/
|
|
126
|
-
function toReceivedAssets(outputs) {
|
|
127
|
-
return outputs.map((o) => {
|
|
128
|
-
if (!o.delayed) return {
|
|
129
|
-
isDelayed: false,
|
|
130
|
-
token: o.token,
|
|
131
|
-
amount: o.amount
|
|
132
|
-
};
|
|
133
|
-
return {
|
|
134
|
-
isDelayed: true,
|
|
135
|
-
token: o.token,
|
|
136
|
-
amount: o.amount,
|
|
137
|
-
redeemerAddress: hexEq(o.redeemerAddress, "0x0000000000000000000000000000000000000000") ? void 0 : o.redeemerAddress,
|
|
138
|
-
claimableAt: o.claimableAt === 0n ? void 0 : o.claimableAt
|
|
139
|
-
};
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Resolves the approval the liquidator must grant for the liquidation call.
|
|
144
|
-
*
|
|
145
|
-
* A call targeting the credit facade is paid by `msg.sender` but transferred by
|
|
146
|
-
* the credit manager, so the latter is the spender. Any other target is a
|
|
147
|
-
* dedicated liquidator contract (Midas / Securitize) that pulls the token to
|
|
148
|
-
* itself and re-approves the credit manager, so it is the spender itself.
|
|
149
|
-
*
|
|
150
|
-
* The approved amount includes {@link LIQUIDATION_APPROVAL_BUFFER} of headroom
|
|
151
|
-
* over the pulled amount to tolerate price movements.
|
|
152
|
-
*
|
|
153
|
-
* @param props - See {@link ToLiquidationApprovalProps}
|
|
154
|
-
* @returns The approval, or `undefined` when the call pulls nothing
|
|
155
|
-
**/
|
|
156
|
-
function toLiquidationApproval(props) {
|
|
157
|
-
const { target, creditFacade, creditManager, token, amount } = props;
|
|
158
|
-
if (amount === 0n) return;
|
|
159
|
-
return {
|
|
160
|
-
spender: hexEq(target, creditFacade) ? creditManager : target,
|
|
161
|
-
token,
|
|
162
|
-
amount: amount * (PERCENTAGE_FACTOR + LIQUIDATION_APPROVAL_BUFFER) / PERCENTAGE_FACTOR
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Converts the compressor's liquidation call into a raw transaction.
|
|
167
|
-
*
|
|
168
|
-
* The calldata is passed through as-is: depending on the liquidated assets,
|
|
169
|
-
* the target is either the credit facade or a dedicated liquidator contract
|
|
170
|
-
* (with its own function signature), so it cannot be re-encoded from a single
|
|
171
|
-
* known ABI.
|
|
172
|
-
*
|
|
173
|
-
* @param call - `liquidationCall` of the compressor's liquidation data
|
|
174
|
-
* @param description - Optional human-readable description
|
|
175
|
-
**/
|
|
176
|
-
function liquidationCallToRawTx(call, description) {
|
|
177
|
-
return {
|
|
178
|
-
to: call.target,
|
|
179
|
-
value: "0",
|
|
180
|
-
signature: "",
|
|
181
|
-
callData: call.callData,
|
|
182
|
-
contractMethod: {
|
|
183
|
-
name: slice(call.callData, 0, 4),
|
|
184
|
-
inputs: [],
|
|
185
|
-
payable: false
|
|
186
|
-
},
|
|
187
|
-
contractInputsValues: {},
|
|
188
|
-
description
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
//#endregion
|
|
192
|
-
export { DUST_THRESHOLD, LIQUIDATION_APPROVAL_BUFFER, calcEstimatedProfit, calcRepaymentAmount, liquidationCallToRawTx, pickMainAsset, toLiquidationApproval, toLiquidatorWithdrawals, toReceivedAssets };
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { iLiquidationCompressorV313Abi } from "../../../abi/ILiquidationCompressorV313.js";
|
|
2
|
-
import { CurrentWithdrawals } from "../withdrawal-compressor/types.js";
|
|
3
|
-
import { NetworkType } from "../../chain/chains.js";
|
|
4
|
-
import "../../chain/index.js";
|
|
5
|
-
import { CreditAccountData } from "../../base/types.js";
|
|
6
|
-
import "../withdrawal-compressor/index.js";
|
|
7
|
-
import { RawTx } from "../../types/transactions.js";
|
|
8
|
-
import "../../types/index.js";
|
|
9
|
-
import "../../base/index.js";
|
|
10
|
-
import { LiquidationApproval, LiquidatorWithdrawal, ReceivedAsset } from "./types.js";
|
|
11
|
-
import { Address, ContractFunctionReturnType } from "viem";
|
|
12
|
-
//#region src/sdk/accounts/liquidations/helpers.d.ts
|
|
13
|
-
/**
|
|
14
|
-
* Raw `LiquidationData` returned by `LiquidationCompressor.getLiquidationData`.
|
|
15
|
-
**/
|
|
16
|
-
type OnchainLiquidationData = ContractFunctionReturnType<typeof iLiquidationCompressorV313Abi, "nonpayable", "getLiquidationData">;
|
|
17
|
-
/**
|
|
18
|
-
* Single element of {@link OnchainLiquidationData.expectedOutputs}.
|
|
19
|
-
**/
|
|
20
|
-
type OnchainLiquidationOutput = OnchainLiquidationData["expectedOutputs"][number];
|
|
21
|
-
/**
|
|
22
|
-
* Single call built by the liquidation compressor.
|
|
23
|
-
**/
|
|
24
|
-
type OnchainLiquidationCall = OnchainLiquidationData["liquidationCall"];
|
|
25
|
-
/**
|
|
26
|
-
* A dedicated RWA liquidator contract (Midas / Securitize) discovered by
|
|
27
|
-
* `LiquidationCompressor.getRWALiquidators`. `contractType` is the bytes32
|
|
28
|
-
* contract type of the liquidator itself (e.g. `RWA_LIQUIDATOR::MIDAS`),
|
|
29
|
-
* not of the phantom token it was found through.
|
|
30
|
-
**/
|
|
31
|
-
type RWALiquidatorInfo = ContractFunctionReturnType<typeof iLiquidationCompressorV313Abi, "view", "getRWALiquidators">[number];
|
|
32
|
-
/**
|
|
33
|
-
* Token balances at or below this threshold are treated as dust and ignored,
|
|
34
|
-
* consistent with the rest of the SDK (see `filterDust`).
|
|
35
|
-
**/
|
|
36
|
-
declare const DUST_THRESHOLD = 10n;
|
|
37
|
-
/**
|
|
38
|
-
* Headroom (in bps) added on top of the amount the liquidation pulls when
|
|
39
|
-
* building the liquidator's approval, so that the transaction does not revert
|
|
40
|
-
* when prices move between the preview and the execution.
|
|
41
|
-
**/
|
|
42
|
-
declare const LIQUIDATION_APPROVAL_BUFFER = 50n;
|
|
43
|
-
/**
|
|
44
|
-
* Estimated amount (in underlying) the liquidator pays to fully liquidate an
|
|
45
|
-
* account: the part of total value used to repay debt and protocol fees.
|
|
46
|
-
*
|
|
47
|
-
* @param totalValue - Account total value in underlying
|
|
48
|
-
* @param liquidationDiscount - Liquidation discount in bps (`100% - liquidation premium`)
|
|
49
|
-
**/
|
|
50
|
-
declare function calcRepaymentAmount(totalValue: bigint, liquidationDiscount: number): bigint;
|
|
51
|
-
/**
|
|
52
|
-
* Estimated liquidator profit (in underlying): the liquidation premium part
|
|
53
|
-
* of total value.
|
|
54
|
-
*
|
|
55
|
-
* @param totalValue - Account total value in underlying
|
|
56
|
-
* @param liquidationDiscount - Liquidation discount in bps (`100% - liquidation premium`)
|
|
57
|
-
**/
|
|
58
|
-
declare function calcEstimatedProfit(totalValue: bigint, liquidationDiscount: number): bigint;
|
|
59
|
-
/**
|
|
60
|
-
* Picks the main asset being liquidated: the most valuable enabled
|
|
61
|
-
* non-underlying collateral token above dust (by oracle value in underlying).
|
|
62
|
-
* Returns `undefined` when the account has no eligible non-underlying
|
|
63
|
-
* collateral above dust.
|
|
64
|
-
*
|
|
65
|
-
* @param ca - Credit account data
|
|
66
|
-
* @param convert - Converts a token balance into its value in underlying;
|
|
67
|
-
* must return `0n` when the price is unavailable
|
|
68
|
-
**/
|
|
69
|
-
declare function pickMainAsset(ca: CreditAccountData, convert: (token: Address, balance: bigint) => bigint): Address | undefined;
|
|
70
|
-
/**
|
|
71
|
-
* Flattens delayed withdrawals of a liquidator into rows: claimable
|
|
72
|
-
* withdrawals have no `claimableAt` (claimable now) and carry a `claimTx`,
|
|
73
|
-
* pending ones carry the estimated claim timestamp.
|
|
74
|
-
*
|
|
75
|
-
* @param current - Claimable and pending withdrawals from the withdrawal compressor
|
|
76
|
-
* @param network - Network the withdrawals live on
|
|
77
|
-
**/
|
|
78
|
-
declare function toLiquidatorWithdrawals(current: CurrentWithdrawals, network: NetworkType, chainId: number): LiquidatorWithdrawal[];
|
|
79
|
-
/**
|
|
80
|
-
* Normalizes the liquidation compressor outputs into assets the liquidator
|
|
81
|
-
* receives. Zero `redeemerAddress` and `claimableAt` (used by the contracts
|
|
82
|
-
* for "not applicable") become `undefined`.
|
|
83
|
-
*
|
|
84
|
-
* @param outputs - `expectedOutputs` of the compressor's liquidation data
|
|
85
|
-
**/
|
|
86
|
-
declare function toReceivedAssets(outputs: readonly OnchainLiquidationOutput[]): ReceivedAsset[];
|
|
87
|
-
/**
|
|
88
|
-
* Props for {@link toLiquidationApproval}.
|
|
89
|
-
**/
|
|
90
|
-
interface ToLiquidationApprovalProps {
|
|
91
|
-
/**
|
|
92
|
-
* Target of the compressor's `liquidationCall`.
|
|
93
|
-
**/
|
|
94
|
-
target: Address;
|
|
95
|
-
/**
|
|
96
|
-
* Credit facade of the liquidated account's credit manager.
|
|
97
|
-
**/
|
|
98
|
-
creditFacade: Address;
|
|
99
|
-
/**
|
|
100
|
-
* Credit manager of the liquidated account.
|
|
101
|
-
**/
|
|
102
|
-
creditManager: Address;
|
|
103
|
-
/**
|
|
104
|
-
* Token the liquidation transaction pulls from the liquidator.
|
|
105
|
-
**/
|
|
106
|
-
token: Address;
|
|
107
|
-
/**
|
|
108
|
-
* Amount of `token` the liquidation transaction pulls.
|
|
109
|
-
**/
|
|
110
|
-
amount: bigint;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Resolves the approval the liquidator must grant for the liquidation call.
|
|
114
|
-
*
|
|
115
|
-
* A call targeting the credit facade is paid by `msg.sender` but transferred by
|
|
116
|
-
* the credit manager, so the latter is the spender. Any other target is a
|
|
117
|
-
* dedicated liquidator contract (Midas / Securitize) that pulls the token to
|
|
118
|
-
* itself and re-approves the credit manager, so it is the spender itself.
|
|
119
|
-
*
|
|
120
|
-
* The approved amount includes {@link LIQUIDATION_APPROVAL_BUFFER} of headroom
|
|
121
|
-
* over the pulled amount to tolerate price movements.
|
|
122
|
-
*
|
|
123
|
-
* @param props - See {@link ToLiquidationApprovalProps}
|
|
124
|
-
* @returns The approval, or `undefined` when the call pulls nothing
|
|
125
|
-
**/
|
|
126
|
-
declare function toLiquidationApproval(props: ToLiquidationApprovalProps): LiquidationApproval | undefined;
|
|
127
|
-
/**
|
|
128
|
-
* Converts the compressor's liquidation call into a raw transaction.
|
|
129
|
-
*
|
|
130
|
-
* The calldata is passed through as-is: depending on the liquidated assets,
|
|
131
|
-
* the target is either the credit facade or a dedicated liquidator contract
|
|
132
|
-
* (with its own function signature), so it cannot be re-encoded from a single
|
|
133
|
-
* known ABI.
|
|
134
|
-
*
|
|
135
|
-
* @param call - `liquidationCall` of the compressor's liquidation data
|
|
136
|
-
* @param description - Optional human-readable description
|
|
137
|
-
**/
|
|
138
|
-
declare function liquidationCallToRawTx(call: OnchainLiquidationCall, description?: string): RawTx;
|
|
139
|
-
//#endregion
|
|
140
|
-
export { DUST_THRESHOLD, LIQUIDATION_APPROVAL_BUFFER, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, RWALiquidatorInfo, ToLiquidationApprovalProps, calcEstimatedProfit, calcRepaymentAmount, liquidationCallToRawTx, pickMainAsset, toLiquidationApproval, toLiquidatorWithdrawals, toReceivedAssets };
|