credmark / credmark-models-py

The Credmark Models Repository
MIT License
36 stars 36 forks source link

Does our pricing model include all the right DEXes? #174

Open murphy opened 1 year ago

murphy commented 1 year ago

We currently use:

Should we be adding others, like Pancake, or even looking at aggregators like 1inch?

leafyoung commented 1 year ago

UniV2/V3/Curve/Sushi cover majority of the liquidty on ethereum Mainnet.

We add support to 1Inch to include those smaller exchanges and small-volume tokens (Shiba, Moon) and two more exchanges (Bancor and Balancer)

Previous PR on Bancor and Balancer: https://github.com/credmark/credmark-models-py/issues

The roadmap ahead could be:

Cross-chain exchanges

Chain-specific exchages

leafyoung commented 1 year ago

I created the model for 1Inch. Testing the price for AAVE token is close to existing model, however testing with special case like ETH (not WETH) gives 1 ETH = 0.973748 ETH. Strange result. I will not add it to our pricing model till we identify some special tokens.

leafyoung commented 1 year ago

1 ETH = 0.973748 ETH. Strange result

Filed this issue to 1Inch team.

leafyoung commented 1 year ago

Bug 2: the node we are using on the gateway does not fully support 1inch.

{
    "slug": "price.one-inch",
    "version": null,
    "chainId": 1,
    "blockNumber": 14249443,
    "error": {
        "type": "ModelRunError",
        "message": "Exception running model price.one-inch({'address': '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'}) on chain 1 block 14249443 (2022-02-21 12:31:34) with {'code': -32000, 'message': 'execution aborted (timeout = 5s)'}",
        "stack": [
            {
                "slug": "price.one-inch",
                "version": "0.1",
                "chainId": 1,
                "blockNumber": 14249443,
                "trace": "Traceback (most recent call last):
  File '/var/task/packages/credmark/cmf/engine/context.py', line 644, in _run_local_model_with_class
    output = model.run(input)
  File 'models/credmark/price/one_inch.py', line 24, in run
    p = offchain_contract.functions.getRateToEth(input.address, True).call(
  File '/var/task/packages/web3/contract.py', line 957, in call
    return call_contract_function(
  File '/var/task/packages/web3/contract.py', line 1501, in call_contract_function
    return_data = web3.eth.call(
  File '/var/task/packages/web3/module.py', line 57, in caller
    result = w3.manager.request_blocking(method_str,
  File '/var/task/packages/web3/manager.py', line 198, in request_blocking
    return self.formatted_response(response,
  File '/var/task/packages/web3/manager.py', line 171, in formatted_response
    raise ValueError(response['error'])
ValueError: {'code': -32000, 'message': 'execution aborted (timeout = 5s)'}
"
            }
        ],

While the custom erigon node returns

credmark-dev run price.one-inch -j -i {"address": "0xdac17f958d2ee523a2206206994597c13d831ec7"} -b 14249443 -j

{
    "slug": "price.one-inch",
    "version": "0.1",
    "chainId": 1,
    "blockNumber": 14249443,
    "output": {
        "just": {
            "price": 0.0003810711693737641,
            "src": "price.one-inch"
        }
    },
    "dependencies": {
        "contract.metadata": {
            "1.0": 2
        },
        "price.one-inch": {
            "0.1": 1
        }
    }
}
murphy commented 1 year ago

@leafyoung so is the implication is that it's good we're switching to new node?

@0xpetersatoshi @abhishektvz are you guys close to finishing testing necessary to switch to new node?

MattCMK commented 1 year ago

1 ETH = 0.973748 ETH. Strange result

Filed this issue to 1Inch team.

@leafyoung seems like the price of stETH compared to ETH as stETH is trading at this price

MattCMK commented 1 year ago

UniV2/V3/Curve/Sushi cover majority of the liquidty on ethereum Mainnet.

We add support to 1Inch to include those smaller exchanges and small-volume tokens (Shiba, Moon) and two more exchanges (Bancor and Balancer)

Previous PR on Bancor and Balancer: https://github.com/credmark/credmark-models-py/issues

The roadmap ahead could be:

Cross-chain exchanges

Chain-specific exchages

@murphy @leafyoung I would agree with Kunlun to use 1nch for some smaller token and then definitely Balancer, Bancor and Loopring (this would be an L2 rollup).

In terms of PanCake Swap and Quickswap - not sure if this makes sense to add them already until we decide to have BSC Data and Polygon Data available as a whole (so in terms of a separate Data ETL).

@murphy OR do we go a different route with the price API and offer price data only for different chains "without" anything else, so no complete Data ETL? not sure if this is possible

leafyoung commented 1 year ago

Balancer is larger than Sushiswap, next to be implemented. https://dune.com/hagaetc/dex-metrics

leafyoung commented 1 year ago

1 ETH = 0.973748 ETH. Strange result

Filed this issue to 1Inch team.

@leafyoung seems like the price of stETH compared to ETH as stETH is trading at this price

Good guess but it's coincidence. stETH is 0.9709 now.

For a past block 14249443 (2022-02-21), ETH was 1.123 ETH while stETH was 0.9989 ETH.