ReserveCurrencyLiquidator
ReserveCurrencyLiquidator
swapMintLiquidate(address uniswapRouter, address financialContract, address reserveCurrency, address liquidatedSponsor, struct FixedPoint.Unsigned maxReserveTokenSpent, struct FixedPoint.Unsigned minCollateralPerTokenLiquidated, struct FixedPoint.Unsigned maxCollateralPerTokenLiquidated, struct FixedPoint.Unsigned maxTokensToLiquidate, uint256 deadline)
public
Swaps required amount of reserve currency to collateral currency which is then used to mint tokens to liquidate a position within one transaction.
After the liquidation is done the DSProxy that called this method will have an open position AND pending liquidation within the financial contract. The bot using the DSProxy should withdraw the liquidation once it has passed liveness. At this point the position can be manually unwound. Any synthetics & collateral that the DSProxy already has are considered in the amount swapped and minted. These existing tokens will be used first before any swaps or mints are done. If there is a token shortfall (either from not enough reserve to buy sufficient collateral or not enough collateral to begins with or due to slippage) the script will liquidate as much as possible given the reserves.
Parameters:
-
uniswapRouter
: address of the uniswap router used to facilitate trades. -
financialContract
: address of the financial contract on which the liquidation is occurring. -
reserveCurrency
: address of the token to swap for collateral. THis is the common currency held by the DSProxy. -
liquidatedSponsor
: address of the sponsor to be liquidated. -
maxReserveTokenSpent
: maximum number of reserve tokens to spend in the trade. Bounds slippage. -
minCollateralPerTokenLiquidated
: abort the liquidation if the position’s collateral per token is below this value. -
maxCollateralPerTokenLiquidated
: abort the liquidation if the position’s collateral per token exceeds this value. -
maxTokensToLiquidate
: max number of tokens to liquidate. For a full liquidation this is the full position debt. -
deadline
: abort the trade and liquidation if the transaction is mined after this timestamp.