ebtc-protocol/ebtc

Return totalCollToSend to help off-chain liquidation sim

Closed this issue · 3 comments

this is to help facilitate bots by allowing them to eth.call() and easily estimate how much collateral they will get for a given liquidation call.

one way to do this would be to have all the liquidation functions return the totalCollToSend such that when called that value can be seen.

if there is another way to do that without changing the code, that solution works as well.

@dapp-whisperer IMO, with latest code in LiquidationLibrary, off-chain bot could easily and deterministically estimate (in JS or Python or any language they desire) the expected collateral for any full(single/batch) or partial liquidation.

Here is a detailed calculation description (the collateral for liquidator to receive column) for each liquidation scenario https://hackmd.io/@re73/r19oq9LM2#How-does-full-liquidation-work-in-eBTC.

For example, this is how our hardhat test estimate the received collateral for liquidator:
https://github.com/Badger-Finance/ebtc/blob/main/packages/contracts/test/CdpManager_SimpleLiquidation_Test.js#L155

There are also many simulation tools to help bot developer to compare the collateral balance difference before and after liquidation like phalcon fork (similar to tenderly but maybe with better analytic support)

As a result, it seems to me there is no need to add this feature in the smart contract. Please lmk if I miss sth

duplicate for #469 ? PR is #480