feat: add pool id to PoolData

This commit is contained in:
Kyle Fang
2025-02-24 10:06:51 +00:00
parent 57d5b59b54
commit 885a8f433c
4 changed files with 13 additions and 3 deletions

View File

@@ -51,6 +51,7 @@ export type PoolData = {
tokenX: Currency; tokenX: Currency;
tokenY: Currency; tokenY: Currency;
factor: bigint; factor: bigint;
poolId: bigint
}; };
export type PriceData = { export type PriceData = {

View File

@@ -18,11 +18,17 @@ import {
} from 'clarity-codegen'; } from 'clarity-codegen';
export async function getAlexSDKData(): Promise<AlexSDKResponse> { export async function getAlexSDKData(): Promise<AlexSDKResponse> {
return fetch(configs.SDK_API_HOST).then((r) => { return fetch(configs.SDK_API_HOST).then((r): Promise<AlexSDKResponse> => {
if (r.ok) { if (r.ok) {
return r.json(); return r.json();
} }
throw new Error('Failed to fetch token mappings'); throw new Error('Failed to fetch token mappings');
}).then(x => {
for (const a of x.pools) {
a.poolId = BigInt(a.poolId)
a.factor = BigInt(a.factor)
}
return x
}); });
} }

View File

@@ -108,5 +108,6 @@ function toPoolData(pool: string): PoolData {
tokenX: tokenX as Currency, tokenX: tokenX as Currency,
tokenY: tokenY as Currency, tokenY: tokenY as Currency,
factor: BigInt(Number(factor) * 1e8), factor: BigInt(Number(factor) * 1e8),
poolId: BigInt(0),
}; };
} }

View File

@@ -23,6 +23,7 @@ export const dummyAmmRoute: AMMRouteSegment[] = [
tokenX: dummyTokenA, tokenX: dummyTokenA,
tokenY: dummyTokenC, tokenY: dummyTokenC,
factor: dummyFactorA, factor: dummyFactorA,
poolId: BigInt(1),
}, },
}, },
{ {
@@ -32,6 +33,7 @@ export const dummyAmmRoute: AMMRouteSegment[] = [
tokenX: dummyTokenC, tokenX: dummyTokenC,
tokenY: dummyTokenB, tokenY: dummyTokenB,
factor: dummyFactorB, factor: dummyFactorB,
poolId: BigInt(2),
}, },
}, },
]; ];