import { BigDecimal } from '@sentio/bigdecimal' import { AptosResourcesContext, AptosContext, AptosNetwork } from '../index.js' import { MoveCoinList, MoveDex, moveGetPairValue, MovePoolAdaptor } from '../../move/ext/index.js' import { MoveResource, Event, MoveModuleBytecode } from '@aptos-labs/ts-sdk' import { getTokenInfoWithFallback, TokenInfo, tokenTokenValueInUsd, whitelistTokens } from './token.js' export type PoolAdaptor = MovePoolAdaptor export class CoinList implements MoveCoinList { calculateValueInUsd( amount: bigint, coinInfo: TokenInfo, timestamp: number, network: AptosNetwork = AptosNetwork.MAIN_NET ): Promise { return tokenTokenValueInUsd(amount, coinInfo, timestamp, network) } async getCoinInfo(type: string, network: AptosNetwork = AptosNetwork.MAIN_NET) { return getTokenInfoWithFallback(type, network) } whiteListed(type: string): boolean { return whitelistTokens().has(type) } whitelistCoins() { return whitelistTokens() } } export const AptosCoinList = new CoinList() export class AptosDex extends MoveDex< TokenInfo, AptosNetwork, MoveModuleBytecode, MoveResource, Event, AptosContext, AptosResourcesContext, T > { coinList = new CoinList() declare poolAdaptor: PoolAdaptor } export async function getPairValue( ctx: AptosContext, coinx: string, coiny: string, coinXAmount: bigint, coinYAmount: bigint ): Promise { return moveGetPairValue(AptosCoinList, ctx, coinx, coiny, coinXAmount, coinYAmount) }