TwapRelayer Upgrades: Multihop Support (coming soon)
Changes are not live yet, and no changes to TwapRelayer integration should be made until further notice.
The upcoming TwapRelayer
upgrade adds support for trades between tokens
along 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 isPairEnabled
event TokenLimitMinSet
event TokenLimitMaxMultiplierSet
function tokenLimitMin
function tokenLimitMaxMultiplier
function getTokenLimitMin
function getTokenLimitMaxMultiplier
Link to Smart Contracts upgrade PR: https://github.com/IntegralHQ/Integral-SIZE-Smart-Contracts/pull/1
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
,getPoolState
still take the parameters:tokenIn
andtokenOut
and now automatically route usingpaths
under 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:
tokenLimitMin
now applies to the input token amounttokenLimitMax
now applies to the input token amount
We will provide an updated list of tradable
paths
based on the networkExisting
pairs
will still be tradable and unchangedNew
paths
, which involve trading across multiplepairs
atomically will be added
Summary
Adds Multihop Support
The TwapRelayer
update adds support for trades between tokens
along 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
; originalpairs
are still tradable.paths
are composed of one or morepairs
all original
pairs
are still tradable via apath
that 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
,getPoolState
still take the parameters:tokenIn
andtokenOut
and now automatically route usingpaths
under the hood when available.
isPairEnabled
is still available but is now deprecated in favor ofisPathEnabled
, which tells developers if anypath
or anypair
is available while the former only tells users if apair
is enabled.
Refactors Token Limits
In addition, token limits
have been refactored to take on new meaning and use:
TokenLimitMin
remains but now only applies to the input token, instead of the output token.TokenLimitMaxMultiplier
has 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:
These events have been refactored to the RelayerMacros
library but will still be emitted from TwapRelayer
, so no developer changes should need to be made
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