import { BigDecimal } from '@sentio/bigdecimal' import { calculateValueInUsd, getCoinInfo, whitelistCoins, whiteListed } from './coin.js' import { MoveCoinList, MoveDex, moveGetPairValue, MovePoolAdaptor, BaseCoinInfo } from '../../move/ext/index.js' import { IotaEvent, IotaMoveNormalizedModule, IotaMoveObject } from '@iota/iota-sdk/client' import { IotaNetwork } from '../network.js' import { IotaContext, IotaObjectContext } from '../context.js' export type PoolAdaptor = MovePoolAdaptor export class CoinList implements MoveCoinList { calculateValueInUsd(amount: bigint, coinInfo: BaseCoinInfo, timestamp: number): Promise { return calculateValueInUsd(amount, coinInfo, timestamp) } async getCoinInfo(type: string) { return getCoinInfo(type) } whiteListed(type: string): boolean { return whiteListed(type) } whitelistCoins(): Map { return whitelistCoins() } } export const IotaCoinList = new CoinList() export class IotaDex extends MoveDex< BaseCoinInfo, IotaNetwork, IotaMoveNormalizedModule, IotaMoveObject, IotaEvent, IotaContext, IotaObjectContext, T > { coinList = IotaCoinList declare poolAdaptor: PoolAdaptor } export async function getPairValue( ctx: IotaContext, coinx: string, coiny: string, coinXAmount: bigint, coinYAmount: bigint ): Promise { return moveGetPairValue(IotaCoinList, ctx, coinx, coiny, coinXAmount, coinYAmount) }