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

Attempt to subtract with overflow #98

Closed
arb000r opened this issue Sep 21, 2023 · 8 comments
Closed

Attempt to subtract with overflow #98

arb000r opened this issue Sep 21, 2023 · 8 comments

Comments

@arb000r
Copy link

arb000r commented Sep 21, 2023

This issue is still apparent. Syncing from block 0 doesn't fix it :)

Context:
Chain: Optimism
TokenA: 0x4200000000000000000000000000000000000006
TokenB: 0xda10009cbd5d07dd0cecc66161fc93d7c9000da1

Attempting to sync all fee types (100/500/3000/10000).
thread 'tokio-runtime-worker' panicked at 'attempt to subtract with overflow', /Users/xxx/.cargo/registry/src/github.com-1ecc6299db9ec823/amms-0.6.1/src/amm/uniswap_v3/mod.rs:850:13

Originally posted by @1saf in #84 (comment)

@0xOsiris
Copy link
Member

Hey, I am not able to recreate this. I ran this example on Optimism & was able to sync all amms from the v3 factory without any issues with a basic alchemy node.

#[tokio::main]
async fn main() -> eyre::Result<()> {
    //Add rpc endpoint here:
    let rpc_endpoint = std::env::var("OPTIMISM_RPC_ENDPOINT")?;
    let provider = Arc::new(Provider::<Http>::try_from(rpc_endpoint)?);

    let factories = vec![
        //Add UniswapV3
        Factory::UniswapV3Factory(UniswapV3Factory::new(
            H160::from_str("0x1F98431c8aD98523631AE4a59f267346ea31F984")?,
            0,
        )),
    ];

    //Sync pairs
    sync::sync_amms(factories, provider, None, 1000).await?;

    Ok(())
}

@arb000r
Copy link
Author

arb000r commented Oct 5, 2023

I will try that. Maybe the difference we are having here is that I am attempting to sync via specific pool addresses

@arb000r
Copy link
Author

arb000r commented Oct 5, 2023

This is panicking

use std::sync::Arc;

use amms::amm::uniswap_v3::UniswapV3Pool;
use common::utils::{crypto::Chain, wallet::get_provider};
use ethers::types::Address;

#[tokio::main]
async fn main() {
    let provider = Arc::new(get_provider(&Chain::Optimism)); // this returns an alchemy optimism provider
    let pool = UniswapV3Pool::new_from_address(
        "0x03af20bdaaffb4cc0a521796a223f7d85e2aac31"
            .parse::<Address>()
            .unwrap(),
        0,
        provider.clone(),
    )
    .await
    .unwrap();
}

@arb000r
Copy link
Author

arb000r commented Oct 5, 2023

@0xOsiris Just did a sync from block 0 of the Uniswap V3 factory and I don't see that pool in the list. Is it skipping certain pools?

@arb000r
Copy link
Author

arb000r commented Oct 31, 2023

Any updates on this?

@0xOsiris
Copy link
Member

0xOsiris commented Nov 6, 2023

Hey apologies for the late response on this. I should have some time to investigate early this week

@arb000r
Copy link
Author

arb000r commented Nov 8, 2023

Let me know if I can help. I am trying to get around it by syncing the pool state from subgraph.

@0xKitsune
Copy link
Collaborator

Cleaning up old issues and closing for now, we are introducing significant upgrades in the 0.7.0 release that should address all of these issues. Feel free to reopen if you encounter this issue in the future.

#235 for reference

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

3 participants