Skip to content

Commit

Permalink
chore: update subgraph url
Browse files Browse the repository at this point in the history
  • Loading branch information
Amedrontadora committed Jun 2, 2024
1 parent 5b1d265 commit 60bfbba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 1 addition & 3 deletions adapters/syncswap/src/sdk/config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { createPublicClient, http } from "viem";
import { linea } from "viem/chains"

export const V2_SUBGRAPH_URL = "https://gateway-arbitrum.network.thegraph.com/api/06a21853c18afff683a7ff52c764d434/subgraphs/id/3xpZFx5YNWzqemwdtRhyaTXVidKNnjY19XAWoHtvR6Lh"

export const V2_SUBGRAPH_URL_AFTER_4515693 = "https://gateway-arbitrum.network.thegraph.com/api/06a21853c18afff683a7ff52c764d434/subgraphs/id/2Zv5F95PUMA95BA1b7Vzek6gtGx9kWf6XaW6ijnsVMBS"
export const V2_SUBGRAPH_URL = "https://gateway-arbitrum.network.thegraph.com/api/06a21853c18afff683a7ff52c764d434/deployments/id/QmT8aCpWka6j2maHmedHQGtu13ru6tx7avsT8Y9tNYrP7s"

export const client = createPublicClient({
chain: linea,
Expand Down
7 changes: 5 additions & 2 deletions adapters/syncswap/src/sdk/lib.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {V2_SUBGRAPH_URL, client, V2_SUBGRAPH_URL_AFTER_4515693} from "./config"
import {V2_SUBGRAPH_URL, client} from "./config"
import { UserPosition } from "./types"
import {Decimal} from 'decimal.js'

Expand Down Expand Up @@ -79,12 +79,14 @@ export const getV2UserPositionsAtBlock = async (blockNumber: number): Promise<Us
}
}`

const response = await fetch(blockNumber >= 4515693 ? V2_SUBGRAPH_URL_AFTER_4515693 : V2_SUBGRAPH_URL, {
const response = await fetch(V2_SUBGRAPH_URL, {
method: "POST",
body: JSON.stringify({ query }),
headers: { "Content-Type": "application/json" },
})
const jsonData = await response.json();

console.log("jsonData",jsonData,blockNumber)
const liquidityPositions: V2Position[] = [];
if(jsonData.data.hasOwnProperty('liquidityPositions')) {
liquidityPositions.push(...jsonData.data.liquidityPositions)
Expand Down Expand Up @@ -113,6 +115,7 @@ export const getV2UserPositionsAtBlock = async (blockNumber: number): Promise<Us
} else {
skip += 1000;
}
console.log("skip",skip, liquidityPositions.length)
if(skip > 5000) {
lastLiquidityTokenBalance = liquidityPositions[liquidityPositions.length - 1].liquidityTokenBalance
skip = 0
Expand Down

0 comments on commit 60bfbba

Please sign in to comment.