-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from balancer/replace-onchainPoolData
Replace dataQueries with multicallV3 (with batching)
- Loading branch information
Showing
18 changed files
with
1,206 additions
and
1,019 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@balancer/sdk": minor | ||
--- | ||
|
||
Add Fantom config. Update to have network specific vault addr. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
"@balancer/sdk": minor | ||
--- | ||
|
||
Replace dataQueries with multicall (using Viem): | ||
|
||
- Add `BATCHSIZE` config per network | ||
- Onchain calls correctly mapped to pool/version | ||
- Filter bricked pools from vulnerability | ||
- Fix scalingFactor scaling |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// bun run debug/multicall.ts | ||
import { | ||
OnChainPoolDataEnricher, | ||
BATCHSIZE, | ||
ProviderSwapOptions, | ||
VAULT, | ||
} from '../src'; | ||
// rome-ignore lint/correctness/noUnusedVariables: <this is a test file> | ||
import { mainnet, polygonZkEvm } from 'viem/chains'; | ||
|
||
const chain = polygonZkEvm; | ||
const rpc = 'https://rpc.ankr.com/polygon_zkevm'; | ||
|
||
const poolsQuery = `{ | ||
pools(first: 10, orderBy: id, orderDirection: desc, where: { totalShares_gt: 0, poolType_contains: "ComposableStable" }) { | ||
id | ||
address | ||
poolType | ||
wrappedIndex | ||
tokens { | ||
address | ||
decimals | ||
index | ||
} | ||
} | ||
}`; | ||
|
||
const pools = await fetch( | ||
'https://api.studio.thegraph.com/query/24660/balancer-polygon-zk-v2/version/latest', | ||
// 'https://api.thegraph.com/subgraphs/name/balancer-labs/balancer-v2', | ||
{ | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify({ query: poolsQuery }), | ||
}, | ||
) | ||
.then((res) => res.json()) | ||
.then((res) => res.data); | ||
|
||
const onChainEnricher = new OnChainPoolDataEnricher( | ||
chain.id, | ||
rpc, | ||
BATCHSIZE[chain.id], | ||
VAULT[chain.id], | ||
); | ||
// const blockNumber = | ||
const providerOptions: ProviderSwapOptions = { | ||
// block: blockNumber, | ||
timestamp: BigInt(Date.now()), | ||
}; | ||
const data = await onChainEnricher.fetchAdditionalPoolData( | ||
pools, | ||
providerOptions, | ||
); | ||
const enriched = onChainEnricher.enrichPoolsWithData(pools.pools, data); | ||
|
||
console.log(enriched, data.length); |
Oops, something went wrong.