ypricemagic
ypricemagic copied to clipboard
Curve overloaded functions error
Issue: Different curve pools sometimes have slightly different ABIs and/or overloaded functions not accounted for.
Stacktrace:
>>> y.get_price("0x6B3595068778DD592e39A122f4f5a5cF09C90fE2", 14974989)
File "<console>", line 1, in <module>
File "a_sync/modified.py", line 36, in __call__
return self.fn(*args, **kwargs)
File "a_sync/modified.py", line 83, in async_wrap
return self._await(coro) if should_await else coro
File "a_sync/modifiers/manager.py", line 68, in sync_modifier_wrap
return function(*args, **kwargs)
File "a_sync/_helpers.py", line 30, in _await
return asyncio.get_event_loop().run_until_complete(awaitable)
File "/opt/homebrew/Cellar/[email protected]/3.9.16/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
return future.result()
File "y/prices/magic.py", line 63, in get_price
return await _get_price(token_address, block, fail_to_None=fail_to_None, silent=silent)
File "async_lru/__init__.py", line 218, in __call__
return await asyncio.shield(fut)
File "y/prices/magic.py", line 146, in _get_price
price = await curve.get_price_for_underlying(token, block=block, sync=False)
File "async_lru/__init__.py", line 218, in __call__
return await asyncio.shield(fut)
File "y/prices/stable_swap/curve.py", line 452, in get_price_for_underlying
dy = await pool.get_dy(token_in_ix, token_out_ix, block = block, sync=False)
File "y/prices/stable_swap/curve.py", line 98, in get_dy
amount_out = await self.contract.get_dy.coroutine(coin_ix_in, coin_ix_out, amount_in, block_identifier=block)
File "dank_mids/brownie_patch/overloaded.py", line 19, in coroutine
fn = self._get_fn_from_args(args)
File "brownie/network/contract.py", line 1466, in _get_fn_from_args
raise ValueError(
ValueError: Contract has more than one function '.get_dy' requiring 3 arguments. You must explicitly declare which function you are calling, e.g. .get_dy['int128,int128,uint'](*args)
Example of overloaded function usage w/ dank_mids
get_dy['int128,int128,uint'].coroutine(*args)
Perhaps, you could also explore the Curve simulator lib: https://curvesim.readthedocs.io/en/latest/#api-documentation