Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cross oracle router to allow more complex paths #76

Closed
0xruhum opened this issue Dec 27, 2024 · 1 comment
Closed

cross oracle router to allow more complex paths #76

0xruhum opened this issue Dec 27, 2024 · 1 comment

Comments

@0xruhum
Copy link

0xruhum commented Dec 27, 2024

Hi,

just wanted to know whether there would be any interest in adding more complex pathing to the router, e.g. ETH-USD-USDC

The idea is to provide an asset amount & a path of assets, e.g. 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc200000000000000000000000000000000000003480xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 which would return the equivalent amount of USDC for the given amount of WETH.
I've implemented it as a wrapper to the current router contract in my own project:

    function getCrossQuote(uint256 inAmount, bytes calldata path) external view returns (uint256) {
        uint256 len = path.length;
        // getPair will read 40 bytes at a time. To not overrun the bounds,
        // we need to stop at len - 20, i.e. at the last full pair.
        for (uint256 i = 0; i < len - 20; i += 20) {
            (address base, address quote) = BytesLib.getPair(path, i);
            inAmount = router.getQuote(inAmount, base, quote);
        }
        return inAmount;
    }

It is especially handy for vault-like contracts where you have to get a token's value in terms of the vault's base asset.

That would also make the CrossAdapter obsolete and spare us the extra deployment overhead.

@totomanov
Copy link
Collaborator

Yep, the path pattern is seen in many dex routers. The EPO contracts follow the https://eips.ethereum.org/EIPS/eip-7726 spec for getQuote and getQuotes by extension. So to conform to the interface the path would need to be placed in storage in the router, rather than come as calldata from outside.

@totomanov totomanov closed this as not planned Won't fix, can't repro, duplicate, stale Jan 8, 2025
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

No branches or pull requests

2 participants