Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Commit

Permalink
Touch up attemptToLiquidateOnchain comments
Browse files Browse the repository at this point in the history
  • Loading branch information
liamzebedee committed Oct 17, 2019
1 parent 9d9bda2 commit 04b7d2e
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions implementation/contracts/deposit/DepositLiquidation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -241,23 +241,22 @@ library DepositLiquidation {
function attemptToLiquidateOnchain(
DepositUtils.Deposit storage _d
) internal returns (bool) {
// Return early if there is no Uniswap TBTC Exchange
// Return early if there is no Uniswap TBTC Exchange.
IUniswapExchange exchange = IUniswapExchange(ITBTCSystem(_d.TBTCSystem).getTBTCUniswapExchange());
if(address(exchange) == address(0x0)) {
return false;
}

// Only liquidate if we can buy up enough TBTC to burn,
// otherwise to go 100% for the falling-price auction
// otherwise go 100% for the falling-price auction
uint tbtcAmount = _d.liquidationTBTCAmount();
uint ethAmount = exchange.getEthToTokenOutputPrice(tbtcAmount);

if(address(this).balance < ethAmount) {
return false;
}

// `deadline` ensures that the order does not get withheld by miners and submitted later
// (commonly referred to as frontrunning)
// Leverage uniswap’s frontrunning mitigation functionality.
uint deadline = block.timestamp;
exchange.ethToTokenSwapOutput.value(ethAmount)(tbtcAmount, deadline);

Expand Down

0 comments on commit 04b7d2e

Please sign in to comment.