Skip to content

Conversation

yucanliu
Copy link
Contributor

@yucanliu yucanliu commented Oct 1, 2025

ROUTE-651 Get Euler TVL

@yucanliu yucanliu requested a review from jsy1218 October 1, 2025 19:30
@yucanliu yucanliu self-assigned this Oct 1, 2025
Comment on lines 324 to 326
const limits = await contract.getLimits(pool.token0.id, pool.token1.id)
;(pool as V4SubgraphPool).tvlUSD = limits[0].toNumber()
;(pool as V4SubgraphPool).tvlETH = limits[1].toNumber()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsy1218 this doesn't quite make sense to me now.

based on the documentation: https://github.com/euler-xyz/euler-swap/blob/be4f1d50018da4dafbaffe19f77faa9dc883ade6/src/interfaces/IEulerSwap.sol

    /// @notice Upper-bounds on the amounts of each token that this pool can currently support swaps for.
    /// @return limitIn Max amount of `tokenIn` that can be sold.
    /// @return limitOut Max amount of `tokenOut` that can be bought.
    function getLimits(address tokenIn, address tokenOut) external view returns (uint256 limitIn, uint256 limitOut);

How should we map those values with tvlETH and tvlUSD?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call - we will have to make additional call to get the spot prices of tokenIn and of tokenOut

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think two ways - calling coingecko via gql or calling routing endpoint for ETH and for USDC pricing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

synced offline - to ship the feature, we can split into two parts -

  1. if the pool contains USDC or WETH, calculating from the eth<>usd average price from the top 3 tvl pools
    2 if the pool does not, then make additional calls to get tvlETH & tvlUSDC (later in the future)

@yucanliu yucanliu force-pushed the yucanliu/route-651-integrate-eulerswap-full-tvl-for-routing branch from 380fd43 to 49d0f0c Compare October 2, 2025 21:11
;(pool as V4SubgraphPool).tvlETH = 5500000
}

log.info(`Pool TVL USD: ${pool.tvlUSD}, Pool TVL ETH: ${pool.tvlETH}`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you share the logs from your local AWS, as to make sure the above algo works?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the current getLimits method is always getting 0s for both token in and out.

The usd<>eth rate logline looks like:

2025-10-02T16:45:53.959-04:00 | {"name":"RoutingLambda","hostname":"169.254.35.123","pid":14,"level":30,"msg":"Eth to USD rate: 4474.563832095389","time":"2025-10-02T20:45:53.9
-- | --

The rest of the log lines look like:


2025-10-02T16:45:54.372-04:00 | {"name":"RoutingLambda","hostname":"169.254.35.123","pid":14,"level":30,"msg":"Pool 0x92df19cc123fa5eb658f0a43866f34293353fdcffc898beed3e1e946e0b13440 has 0 TVL","time":"2025-10-02T20:45:54.372Z","v":0}
-- | --
  | 2025-10-02T16:45:54.372-04:00 | {"name":"RoutingLambda","hostname":"169.254.35.123","pid":14,"level":30,"msg":"Pool TVL USD: 1000, Pool TVL ETH: 5500000","time":"2025-10-02T20:45:54.372Z","v":0}
  | 2025-10-02T16:45:54.379-04:00 | {"name":"RoutingLambda","hostname":"169.254.35.123","pid":14,"level":30,"msg":"Limits: [{\"type\":\"BigNumber\",\"hex\":\"0x00\"},{\"type\":\"BigNumber\",\"hex\":\"0x00\"}]","time":"2025-10-02T20:45:54.379Z","v":0}
  | 2025-10-02T16:45:54.379-04:00 | {"name":"RoutingLambda","hostname":"169.254.35.123","pid":14,"level":30,"msg":"Pool 0x32719c81952962e513b8e1067780051bd17db0dec5bcab069b2c340204b1279e has 0 TVL","time":"2025-10-02T20:45:54.379Z","v":0}
  | 2025-10-02T16:45:54.379-04:00 | {"name":"RoutingLambda","hostname":"169.254.35.123","pid":14,"level":30,"msg":"Pool TVL USD: 1000, Pool TVL ETH: 5500000","time":"2025-10-02T20:45:54.379Z","v":0}
  | 2025-10-02T16:45:54.380-04:00 | {"name":"RoutingLambda","hostname":"169.254.35.123","pid":14,"level":30,"msg":"Limits: [{\"type\":\"BigNumber\",\"hex\":\"0x00\"},{\"type\":\"BigNumber\",\"hex\":\"0x00\"}]","time":"2025-10-02T20:45:54.380Z","v":0}
  | 2025-10-02T16:45:54.380-04:00 | {"name":"RoutingLambda","hostname":"169.254.35.123","pid":14,"level":30,"msg":"Pool 0xb29e822eeea2ec9b75bb91d6c133fed78ba560251e85cd89233ebfc06df6a7f3 has 0 TVL","time":"2025-10-02T20:45:54.380Z","v":0}
  | 2025-10-02T16:45:54.380-04:00 | {"name":"RoutingLambda","hostname":"169.254.35.123","pid":14,"level":30,"msg":"Pool TVL USD: 1000, Pool TVL ETH: 5500000","time":"2025-10-02T20:45:54.380Z","v":0}
  | 2025-10-02T16:45:54.382-04:00 | {"name":"RoutingLambda","hostname":"169.254.35.123","pid":14,"level":30,"msg":"Limits: [{\"type\":\"BigNumber\",\"hex\":\"0x00\"},{\"type\":\"Big


We are always falling back to your previous implementation

@yucanliu yucanliu requested review from jsy1218 October 3, 2025 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants