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;
tokenY: Currency;
factor: bigint;
poolId: bigint
};
export type PriceData = {

View File

@@ -18,11 +18,17 @@ import {
} from 'clarity-codegen';
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) {
return r.json();
}
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
});
}
@@ -99,7 +105,7 @@ export async function fetchBalanceForAccount(
return [
a.id,
(BigInt(amount) * BigInt(1e8)) /
BigInt(10 ** a.underlyingTokenDecimals),
BigInt(10 ** a.underlyingTokenDecimals),
];
}
if (a.id === Currency.STX) {
@@ -113,7 +119,7 @@ export async function fetchBalanceForAccount(
return [
a.id,
(BigInt(fungibleToken) * BigInt(1e8)) /
BigInt(10 ** a.underlyingTokenDecimals),
BigInt(10 ** a.underlyingTokenDecimals),
];
})
)

View File

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

View File

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