Skip to main content



Helper contract to enable a liquidator to hold one reserver currency and liquidate against any number of financial contracts. Is assumed to be called by a DSProxy which holds reserve currency.


swapMintLiquidate(address uniswapRouter, address financialContract, address reserveCurrency, address liquidatedSponsor, struct FixedPoint.Unsigned minCollateralPerTokenLiquidated, struct FixedPoint.Unsigned maxCollateralPerTokenLiquidated, struct FixedPoint.Unsigned maxTokensToLiquidate, uint256 maxSlippage, 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.


  • 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.
  • maxSlippage: max slip the trade on uniswap will accept before reverting.
  • 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.
subOrZero(struct FixedPoint.Unsigned a, struct FixedPoint.Unsigned b) โ†’ struct FixedPoint.Unsigned (internal)
getFinalFee(contract IFinancialContract fc) โ†’ struct FixedPoint.Unsigned (internal)
getCollateralBalance(contract IFinancialContract fc) โ†’ struct FixedPoint.Unsigned (internal)
getSyntheticBalance(contract IFinancialContract fc) โ†’ struct FixedPoint.Unsigned (internal)