0

Pretty much every coin with taxes has an allowance function to give the router allowance over max uint to be able to sell the tokens.

However, I always see the allowance given to 'router', which inclues the address in combination of the interface.

    routerAdd = 0x...;
    router = IDEX(routerAdd);
    allowance[address(this)][address(router)] = type(uint256).max;

My question is, why does everyone use 'router' instead of 'routerAdd' on its own? Is there a specific reason for doing so, or would it be actually equivalent to use:

    routerAdd= 0x...;
    router = IDEX(routerAdd);
    allowance[address(this)][address(routerAdd)] = type(uint256).max;

1 Answer 1

0

There is no need to cast routerAdd to an address, as it is an address already. You can therefore just use allowance[address(this)][routerAdd] =...

The reason developers do it this way is, that is it simpler and more readable to store the router as an interface and cast it to address when needed than the other way around. But it works just as well if you do it the other way around.

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.