Permit

For swaps from supported EIP-2616 tokens, the `permit` parameter allows swapping without an approval transaction beforehand.

Refer to EVM Swaps for details on where permitcan be used

EIP-2612 tokens can be swapped directly without an initial approval transaction. The client needs to provide a directly usable permit calldata as a parameter to EVM Swaps API call. Refer to the EIP-2612 specification for how to sign and encode this call. permit ABI is provided below for reference:

function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external
  • owner: the swap's token sender

  • spender: the KyberSwap router address as returned by the GET-route API

  • value: the amount of token to be swapped

  • deadline: deadline by which the permit is valid

  • v, r, s: a valid secp256k1 signature from the swap's token sender for the following message:

keccak256(abi.encodePacked(
   hex"1901",
   DOMAIN_SEPARATOR,
   keccak256(abi.encode(
            keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"),
            owner,
            spender,
            value,
            nonce,
            deadline))
))

Last updated

Was this helpful?