4

I see lots of ensure(deadline) in uniswap's code like

function swapExactTokensForTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external virtual override ensure(deadline) returns (uint[] memory amounts) {
omitted
}

But I had been searching for a while and could not find any reference for it.

1 Answer 1

9

ensure isn't a keyword, it is a function modifier. As you can guess, the ensure modifier requires that the swap transaction is executed before the given deadline:

modifier ensure(uint deadline) {
require(deadline >= block.timestamp, 'UniswapV2Router: EXPIRED'); 
_;
    }
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.