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

Can't sync Uni V3 pool #105

Open
olegggatttor opened this issue Oct 24, 2023 · 2 comments
Open

Can't sync Uni V3 pool #105

olegggatttor opened this issue Oct 24, 2023 · 2 comments

Comments

@olegggatttor
Copy link

olegggatttor commented Oct 24, 2023

Hey! I am trying to sync Uni V3 pools on Polygon, but always getting Middleware Error (⠦ Syncing AMMs...Error: Middleware error).

I am using basic alchemy node.

Code sample (very similar to one in examples):

use dotenv::dotenv;
use amms::{
    amm::{
        factory::Factory, uniswap_v2::factory::UniswapV2Factory,
        uniswap_v3::factory::UniswapV3Factory,
    },
    sync,
};
use ethers::{
    providers::{Http, Provider},
    types::H160,
};
use std::{str::FromStr, sync::Arc};


#[tokio::main]
async fn main() -> eyre::Result<()> {
    dotenv().ok();
    //Add rpc endpoint here:
    let rpc_endpoint = std::env::var("POLYGON_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, Some("my_poly_checkpoint.pt"), 100).await?;

    Ok(())
}

What am I doing wrong?

@0xOsiris
Copy link
Member

Syncing from a checkpoint is not stable with V3 currently, this should only be done with V2/Vaults since the current logic isn't syncing the mint/burn logs from the last synced block on the checkpoint to the current chain head, the liquidity positions will be outdated on the pools. Does it sync without a checkpoint?

@olegggatttor
Copy link
Author

@0xOsiris haven't checked yet. As I understood, I have to sync from 0 block every time I run the program, then?

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