mirror of
https://github.com/alexgo-io/alex-sdk.git
synced 2026-01-12 14:25:02 +08:00
feat: add pool id to PoolData
This commit is contained in:
@@ -51,6 +51,7 @@ export type PoolData = {
|
||||
tokenX: Currency;
|
||||
tokenY: Currency;
|
||||
factor: bigint;
|
||||
poolId: bigint
|
||||
};
|
||||
|
||||
export type PriceData = {
|
||||
|
||||
@@ -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),
|
||||
];
|
||||
})
|
||||
)
|
||||
|
||||
@@ -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),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user