ADD: Stateless EVM Router V6
Background
Router V6 has the following upgrades
- Stateless: routes tokens to vaults directly
- Makes
expiryoptional on deposit - Supports Mixed Batched Outbounds (ETH + ERC20)
- More advanced Dex Aggregation (passes additional parameters)
note: Batched Dex Aggregation support is not included.
Stateless
Router V4 is stateful, holding ERC20 tokens.
- Different pattern to every other asset, which is held on the vaults instead.
- Makes Router upgrades hard (requires a router migration)
- Prevents memoless deposits for ERC20s since they can not be "sent" to a vault.
The router is only needed to emit a "memo" in an event. The memo is optional when needed for memoless (the amount encodes intent instead) #1569 (closed)
Deposits
Current:
safeAmount = safeTransferFrom(asset, amount); // Transfer asset here
_vaultAllowance[vault][asset] += safeAmount; // Credit to chosen vaultChange:
safeAmount = safeTransferFrom(asset, amount, vault); // move tokens to vaultTransferOuts
Instead of
_vaultAllowance[msg.sender][asset] -= amount; // Reduce allowance
asset.call(abi.encodeWithSignature("transfer(address,uint256)" , to, amount));Change
safeAmount = safeTransferFrom(asset, amount, to); // Send direct to recipientBalance Tracking
instead of
return _vaultAllowance[vault][token];change
return iERC20(token).balanceOf(vault);Optional Expiry
Expiry can be set to 0 on deposit to skip expiry check
Expiry was added prior to TC processing refunds to inactive vaults, less important now.
Batching
batchTransferOut() is added back in to accept an array of coins.
Upgraded Dex Aggregation
Emit Failure Log
transferOutAndCall() now emits a failure log if failing
V2 Function
transferOutAndCallV2() is added with additional parameters
struct Params {
address payable target;
address fromAsset;
uint256 fromAmount; // new for tracking
address toAsset;
address recipient;
uint256 amountOutMin;
string memo;
bytes payload; // new for tracking
string originAddress; // new for refunds
}Edited by THORChain