im trying to swap some DAI with USDC Using UniswapV2Router02 function swapExactTokensForTokens() with brownie and python by unlocking a DAI token holder account and im getting this error :
VirtualMachineError: revert: UniswapV2Router: EXPIRED
I think that it because of deadline parameter, and i don't know what value to put
from brownie import accounts, interface
from datetime import datetime
DAI_TOKEN = "0x6B175474E89094C44Da98b954EedeAC495271d0F"
USDC_TOKEN = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"
DAI_HOLDER = "0x6F3F68525E5EdaD6F06f8b0EaE0DD7B9F695aF13"
path = [DAI_TOKEN, USDC_TOKEN]
def main():
manipulate()
def manipulate():
account = DAI_HOLDER
router = interface.IUniswapV2Router02("0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D")
erc = interface.IERC20(DAI_TOKEN)
erc.approve(router, 100, {"from": account})
tx = router.swapExactTokensForTokens(
100, 90, path, DAI_HOLDER, (datetime.now() + 250), {"from": account}
)
Best Answer
Try increasing the timestamp to
(datetime.now() + 60000)
which is basically 1min.,250
is 250 miliseconds which could be not enough for the execution.