TwapRelayer Upgrades: Multihop Support (coming soon)
The upcoming TwapRelayer upgrade adds support for trades between tokensalong whitelisted paths that involve one or more pairs. For example, usdc-wbtc is a new path that has been whitelisted in the system that allows trades between usdc and wbtc (bidirectionally) via the existing weth-usdc and weth-wbtc pairs.
As a result of this upgrade, aggregators and solvers who have integrated the TwapRelayer using the following events or functions, please make the recommended changes below. No changes needed if the current integration does not directly use any of the following events or functions.
function isPairEnabledevent TokenLimitMinSetevent TokenLimitMaxMultiplierSetfunction tokenLimitMinfunction tokenLimitMaxMultiplierfunction getTokenLimitMinfunction getTokenLimitMaxMultiplier
How to Upgrade
Common functions have been automatically updated to take advantage of paths without the need for developers to make any changes:
sell,buy,quoteBuy,quoteSell,getPoolStatestill take the parameters:tokenInandtokenOutand now automatically route usingpathsunder the hood when available.
If you rely on any of the events or functions below, please make the recommended changes. If your current integration does not directly use any of the following events or functions, you should not have to make any changes:
Replace calls to
function isPairEnabled(bool pairAddress) returns (bool isEnabled)withfunction isPathEnabled(address tokenIn, address tokenOut) returns (bool isEnabled)Replace event listeners
event TokenLimitMinSet(address token, uint256 limit)andevent TokenLimitMaxMultiplierSet(address token, uint256 limit)withevent TokenLimitsSet(address token, uint256 min, uint256 max)Replace calls to
function tokenLimitMin(address token) returns (uint256),function tokenLimitMaxMultiplier(address token) returns (uint256),function getTokenLimitMin(address token) returns (uint256), andfunction getTokenLimitMaxMultiplier(address token) returns (uint256)withfunction getTokenLimits(address token) returns (uint256 min, uint256 max)Note:
tokenLimitMinnow applies to the input token amounttokenLimitMaxnow applies to the input token amount
We will provide an updated list of tradable
pathsbased on the networkExisting
pairswill still be tradable and unchangedNew
paths, which involve trading across multiplepairsatomically will be added
Summary
Adds Multihop Support
The TwapRelayer update adds support for trades between tokensalong whitelisted paths that involve one or more pairs. For example, usdc-wbtc is a new path that has been whitelisted in our system that allows trades between usdc and wbtc (bidirectionally) via the existing weth-usdc and weth-wbtc pairs.
The original set of tradable tokens has been expanded by the addition of new
paths; originalpairsare still tradable.pathsare composed of one or morepairsall original
pairsare still tradable via apaththat only contains onepair
Functions for trading and quoting have not changed and are 100% backwards compatible.
Common functions have been automatically updated to take advantage of paths without the need for developers to make any changes:
sell,buy,quoteBuy,quoteSell,getPoolStatestill take the parameters:tokenInandtokenOutand now automatically route usingpathsunder the hood when available.
isPairEnabledis still available but is now deprecated in favor ofisPathEnabled, which tells developers if anypathor anypairis available while the former only tells users if apairis enabled.
Refactors Token Limits
In addition, token limits have been refactored to take on new meaning and use:
TokenLimitMinremains but now only applies to the input token, instead of the output token.TokenLimitMaxMultiplierhas been removed and replaced byTokenLimitMax, which checks the input token amount does not exceed a certain limit.
Smart Contract Changes
Removed from SCs or Deprecated
Deprecated:
mapping(address => bool) public override isPairEnabled;
Removed:
event TokenLimitMinSet(address token, uint256 limit);event TokenLimitMaxMultiplierSet(address token, uint256 limit);function tokenLimitMin(address token) external pure returns (uint256);function tokenLimitMaxMultiplier(address token) external pure returns (uint256);function getTokenLimitMin(address token) external pure returns (uint256);function getTokenLimitMaxMultiplier(address token) external pure returns (uint256);
Moved:
event EthTransferGasCostSet(uint256 gasCost);event TwapIntervalSet(address pair, uint32 interval);event ToleranceSet(address pair, uint16 tolerance);
Added to SCs
event TokenLimitsSet(address token, uint256 min, uint256 max);function getTokenLimits(address token) external pure returns (uint256 min, uint256 max);function isPathEnabled(address tokenIn, address tokenOut) external view returns (bool);
Last updated