You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There's a lot of if-else branches here that need to be added by the integrator. This gets quite challenging over time to update, which needs to be done ad-hoc.
Proposed Solution
The method that 1inch relies on is the getRate method with the following signature:
function getRate(IERC20srcToken, IERC20dstToken, IERC20connector, uint256thresholdFilter) externalviewoverridereturns (uint256rate, uint256weight)
This is utilised by 1inch to get some sort of a weighting and a rate output for a source token and destination token.
We've come to realise that 1inch could greatly benefit with Curve core handling the integration. Instead of providing a single pool and rate value (and weight), the on-chain api contract could fetch a list of quotes from a list of pool contracts. This contract would need to call a working MetaRegistry in each chain. The flow would be as follows:
If pool is stableswap (check if pool has gamma parameter], then step 2 returns is_underlying as True in the Tuple output.
The rate contract calls get_dy or get_dy_underlying for each pool and coin indices list.
The rate contract compiles this into a list of quotes defined as follows:
MAX_COINS: constant(uint256) =8struct Quote:
# i and j values to be fed into either `exchange_underlying` or `exchange` method# user can infer whether to use int128 or uint256 from `pool_type` and `exchange_underlying`# from `is_underlying`.
source_token_index: uint256
dest_token_index: uint256# Pool which gives the requested quote
pool: address# Balances are necessary for aggregators to know if pool is liquid
balances: DynArray[uint256, MAX_COINS]
# Quoted output amount
amount_out: address# If is_underlying, pool is a stableswap metapool and you can call. # exchange_underlying with the indices directly on the pool contract.
is_underlying: bool# 0 for stableswap, 1 for cryptoswap, 2 for LLAMMA.# If 0, pool needs uint128 as coin index inputs.
pool_type: uint8@external@viewdef getRate(source_token: address, dstToken: address, amount_in: uint256) -> DynArray[Quote, MAX_QUOTES]:
...
The main concern faced here is: there should not be an out-of-gas error while doing multicalls for a large array of coins: gas needs to be a consideration.
The text was updated successfully, but these errors were encountered:
Background
Currently aggregators face steep uphill battles integrating Curve fully. This is because of the following conditions:
This has led to newer pools being slow to integrate of popular aggregator api(s) such as 1inch.
Current integration and its challenges
1inch currently uses an on-chain spot price oracle with the following abi:
https://github.com/1inch/spot-price-aggregator/blob/master/contracts/oracles/CurveOracle.sol
There's a lot of if-else branches here that need to be added by the integrator. This gets quite challenging over time to update, which needs to be done ad-hoc.
Proposed Solution
The method that 1inch relies on is the
getRate
method with the following signature:This is utilised by 1inch to get some sort of a weighting and a rate output for a source token and destination token.
We've come to realise that 1inch could greatly benefit with Curve core handling the integration. Instead of providing a single pool and rate value (and weight), the on-chain api contract could fetch a list of quotes from a list of pool contracts. This contract would need to call a working MetaRegistry in each chain. The flow would be as follows:
metaregistry.find_pools_for_coins
metaregistry.get_coin_indices
gamma
parameter], then step 2 returnsis_underlying
as True in the Tuple output.get_dy
orget_dy_underlying
for each pool and coin indices list.The main concern faced here is: there should not be an out-of-gas error while doing multicalls for a large array of coins: gas needs to be a consideration.
The text was updated successfully, but these errors were encountered: