Token Transfers
ERC20 Tokens
Standard ERC20 token transfers to and from the DEX contract are paid to users with transfer()
calls and collected from users with transferFrom()
calls. Users need to approve()
or permit()
against the CrocSwapDex
contract for any tokens they're planning to deposit or sell in a swap.
Tokens being received from the DEX do not require any approval calls. Tokens that are traded through the surplus collateral facility do not recall any approval. For example a short-term speculator could buy a token, have it settle to their surplus collateral deposit, and sell it back for USDC without ever needing to approve the token.
Native Ethereum
Ambient supports the use of the chain's native token (e.g. ETH on Ethereum) without resorting to ERC20 wrappers.
Native ETH paid by the DEX to the user is sent directly to the user's wallet address.
Native ETH deposited or swapped into the DEX must be sent in the msg.value
of the contract call or transaction. If the user knows the exact quantity of ETH required by the transaction they can set msg.value
exactly. Otherwise the user should attach the upper-bound of the ETH debit they expect the contract to incur. All DEX transactions involving ETH will refund any overpaid amount in msg.value
to the end-user.
WARNING: ETH refunds for msg.value
will not be paid for any transaction not involving native ETH. (E.g. a swap between USDC and DAI.) msg.value
should only be attached on transactions involving ETH deposits or pools.
Last updated