From 6527adae63b3724903065c2ee09cca99f56cf4ce Mon Sep 17 00:00:00 2001 From: Fuyao Zhao Date: Fri, 8 Nov 2024 20:03:23 +0800 Subject: [PATCH] feat(aptos): aptos dex support fatoken (#1028) --- packages/sdk/src/aptos/aptos-plugin.ts | 4 +- packages/sdk/src/aptos/ext/aptos-dex.ts | 21 +- packages/sdk/src/aptos/ext/coin.test.ts | 4 +- packages/sdk/src/aptos/ext/coin.ts | 1583 ----------------------- packages/sdk/src/aptos/ext/index.ts | 1 - packages/sdk/src/aptos/ext/token.ts | 28 +- packages/sdk/src/move/ext/coin-list.ts | 14 - packages/sdk/src/move/ext/coin.ts | 17 + packages/sdk/src/move/ext/index.ts | 2 +- packages/sdk/src/move/ext/move-dex.ts | 35 +- packages/sdk/src/sui/ext/coin.ts | 21 +- packages/sdk/src/sui/ext/move-dex.ts | 11 +- 12 files changed, 82 insertions(+), 1659 deletions(-) delete mode 100644 packages/sdk/src/aptos/ext/coin.ts delete mode 100644 packages/sdk/src/move/ext/coin-list.ts create mode 100644 packages/sdk/src/move/ext/coin.ts diff --git a/packages/sdk/src/aptos/aptos-plugin.ts b/packages/sdk/src/aptos/aptos-plugin.ts index d56d5d1a70..dedcdec475 100644 --- a/packages/sdk/src/aptos/aptos-plugin.ts +++ b/packages/sdk/src/aptos/aptos-plugin.ts @@ -19,7 +19,7 @@ import { ServerError, Status } from 'nice-grpc' import { AptosProcessorState, AptosResourceProcessorState } from './aptos-processor.js' -import { initCoinList } from './ext/coin.js' +import { initTokenList } from './ext/token.js' import { AptosChainId } from '@sentio/chain' import { AptosResourcesContext } from './context.js' import { @@ -42,7 +42,7 @@ export class AptosPlugin extends Plugin { } async start(request: StartRequest) { - await initCoinList() + await initTokenList() const allowedChainIds = new Set(Object.values(AptosChainId)) for (const instance of request.templateInstances) { diff --git a/packages/sdk/src/aptos/ext/aptos-dex.ts b/packages/sdk/src/aptos/ext/aptos-dex.ts index 75301bd2dc..4dc4327d79 100644 --- a/packages/sdk/src/aptos/ext/aptos-dex.ts +++ b/packages/sdk/src/aptos/ext/aptos-dex.ts @@ -1,37 +1,38 @@ import { BigDecimal } from '@sentio/bigdecimal' -import { calculateValueInUsd, getCoinInfo, whitelistCoins, whiteListed } from './coin.js' import { AptosResourcesContext, AptosContext, AptosNetwork } from '../index.js' -import { MoveCoinList, MoveDex, moveGetPairValue, MovePoolAdaptor, SimpleCoinInfo } from '../../move/ext/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 { +export class CoinList implements MoveCoinList { calculateValueInUsd( amount: bigint, - coinInfo: SimpleCoinInfo, + coinInfo: TokenInfo, timestamp: number, network: AptosNetwork = AptosNetwork.MAIN_NET ): Promise { - return calculateValueInUsd(amount, coinInfo, timestamp, network) + return tokenTokenValueInUsd(amount, coinInfo, timestamp, network) } - getCoinInfo(type: string): SimpleCoinInfo { - return getCoinInfo(type) + async getCoinInfo(type: string) { + return getTokenInfoWithFallback(type) } whiteListed(type: string): boolean { - return whiteListed(type) + return whitelistTokens().has(type) } - whitelistCoins(): Map { - return whitelistCoins() + whitelistCoins() { + return whitelistTokens() } } export const AptosCoinList = new CoinList() export class AptosDex extends MoveDex< + TokenInfo, AptosNetwork, MoveModuleBytecode, MoveResource, diff --git a/packages/sdk/src/aptos/ext/coin.test.ts b/packages/sdk/src/aptos/ext/coin.test.ts index b5796b3d32..e6e0071f71 100644 --- a/packages/sdk/src/aptos/ext/coin.test.ts +++ b/packages/sdk/src/aptos/ext/coin.test.ts @@ -1,10 +1,10 @@ import { describe, test } from 'node:test' -import { getCoinInfoWithFallback } from './coin.js' import { expect } from 'chai' +import { getTokenInfoWithFallback } from './token.js' describe('coin test', () => { test('get coin info', async () => { - const info = await getCoinInfoWithFallback( + const info = await getTokenInfoWithFallback( '0xe4ccb6d39136469f376242c31b34d10515c8eaaa38092f804db8e08a8f53c5b2::assets_v1::EchoCoin002' ) diff --git a/packages/sdk/src/aptos/ext/coin.ts b/packages/sdk/src/aptos/ext/coin.ts deleted file mode 100644 index 4b6e7d3a26..0000000000 --- a/packages/sdk/src/aptos/ext/coin.ts +++ /dev/null @@ -1,1583 +0,0 @@ -import { getPriceByType } from '../../utils/index.js' -import fetch from 'node-fetch' -import { accountTypeString, parseMoveType, SPLITTER } from '@typemove/move' -import { SimpleCoinInfo } from '../../move/ext/move-dex.js' -import { AptosNetwork, getClient } from '../network.js' -import { coin } from '../builtin/0x1.js' -import { MoveStructId } from '@aptos-labs/ts-sdk' -import { AptosChainId } from '@sentio/chain' - -const WHITELISTED_COINS = new Map() - -export async function initCoinList() { - let list = DEFAULT_LIST - try { - const resp = await fetch( - 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/src/permissionless.json' - ) - list = (await resp.json()) as any[] - } catch (e) { - console.warn("Can't not fetch newest coin list, use default list") - } - - setCoinList(list) -} - -function setCoinList(list: (Omit & { name: string })[]) { - for (const info of list) { - let bridge = 'native' - if (info.name.includes('Celer')) { - bridge = 'Celer' - } - if (info.name.includes('LayerZero')) { - bridge = 'LayerZero' - } - if (info.name.includes('Wormhole')) { - bridge = 'Wormhole' - } - if ( - info.token_type.type === - '0x111ae3e5bc816a5e63c2da97d0aa3886519e0cd5e4b046659fa35796bd11542a::stapt_token::StakedApt' && - info.symbol === 'stAPT' - ) { - info.symbol = 'amStApt' - } else { - if (info.hippo_symbol) { - info.symbol = info.hippo_symbol - } - } - WHITELISTED_COINS.set(info.token_type.type, { ...info, bridge }) - } -} - -export function whitelistCoins() { - return WHITELISTED_COINS -} - -export function whiteListed(coin: string): boolean { - const [addr, module, type] = coin.split(SPLITTER) - const normalized = [accountTypeString(addr), module, type].join(SPLITTER) - return WHITELISTED_COINS.has(normalized) -} - -export function getCoinInfo(type: string): SimpleCoinInfo { - const r = WHITELISTED_COINS.get(type) - if (!r) { - const parts = type.split('::') - // TDDO retrive from network - return { - token_type: { type: type, account_address: parts[0] }, - symbol: parts[2], - decimals: 8, - bridge: 'native' - } - } - return r -} - -const COIN_METADATA_CACHE = new Map>() - -export async function getCoinInfoWithFallback(type: string, network?: AptosNetwork): Promise { - const r = WHITELISTED_COINS.get(type) - if (!r) { - network = network || AptosNetwork.MAIN_NET - const key = network + '_' + type - let promise = COIN_METADATA_CACHE.get(key) - if (!promise) { - const client = getClient(network) - // client.getDigitalAssetData() - const account = type.split(SPLITTER)[0] - const coinInfo = coin.CoinInfo.type(parseMoveType(type)).getSignature() as MoveStructId - promise = client.getAccountResource({ accountAddress: account, resourceType: coinInfo }) - COIN_METADATA_CACHE.set(key, promise) - } - const meta = await promise - if (meta === null) { - throw Error('Coin not existed ' + key) - } - - const parts = type.split(SPLITTER) - return { - token_type: { type: type, account_address: parts[0] }, - symbol: meta.symbol, - decimals: meta.decimals, - bridge: 'native' - } - } - return r -} - -export async function getPrice( - coinType: string, - timestamp: number, - network = AptosChainId.APTOS_MAINNET -): Promise { - if (!whiteListed(coinType)) { - return 0.0 - } - const date = new Date(timestamp / 1000) - try { - return (await getPriceByType(network, coinType, date)) || 0 - } catch (error) { - console.log(JSON.stringify(error)) - throw error - } -} - -export async function calculateValueInUsd( - n: bigint, - coinInfo: SimpleCoinInfo, - timestamp: number, - network = AptosChainId.APTOS_MAINNET -) { - const price = await getPrice(coinInfo.token_type.type, timestamp, network) - const amount = n.scaleDown(coinInfo.decimals) - return amount.multipliedBy(price) -} - -export function delay(ms: number) { - return new Promise((resolve) => setTimeout(resolve, ms)) -} - -const DEFAULT_LIST = [ - { - name: 'Aptos Coin', - symbol: 'APT', - official_symbol: 'APT', - coingecko_id: 'aptos', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/APT.webp', - project_url: 'https://aptoslabs.com/', - token_type: { - type: '0x1::aptos_coin::AptosCoin', - account_address: '0x1', - module_name: 'aptos_coin', - struct_name: 'AptosCoin' - }, - extensions: { - data: [['bridge', 'native']] - }, - unique_index: 1, - source: 'native', - permissioned_listing: true, - hippo_symbol: 'APT', - pancake_symbol: 'APT' - }, - { - name: 'Meeiro', - symbol: 'MEE', - official_symbol: 'MEE', - coingecko_id: '', - decimals: 6, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/MEE.svg', - project_url: 'https://meeiro.xyz', - token_type: { - type: '0xe9c192ff55cffab3963c695cff6dbf9dad6aff2bb5ac19a6415cad26a81860d9::mee_coin::MeeCoin', - account_address: '0xe9c192ff55cffab3963c695cff6dbf9dad6aff2bb5ac19a6415cad26a81860d9', - module_name: 'mee_coin', - struct_name: 'MeeCoin' - }, - extensions: { - data: [['bridge', 'native']] - }, - unique_index: 101, - source: 'native', - permissioned_listing: true, - hippo_symbol: 'MEE', - pancake_symbol: 'MEE' - }, - { - name: 'Move Dollar', - symbol: 'MOD', - official_symbol: 'MOD', - coingecko_id: 'move-dollar', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/MOD.svg', - project_url: 'https://www.thala.fi/', - token_type: { - type: '0x6f986d146e4a90b828d8c12c14b6f4e003fdff11a8eecceceb63744363eaac01::mod_coin::MOD', - account_address: '0x6f986d146e4a90b828d8c12c14b6f4e003fdff11a8eecceceb63744363eaac01', - module_name: 'mod_coin', - struct_name: 'MOD' - }, - extensions: { - data: [] - }, - unique_index: 128, - source: 'native', - permissioned_listing: true, - hippo_symbol: 'MOD', - pancake_symbol: 'MOD' - }, - { - name: 'Thala Token', - symbol: 'THL', - official_symbol: 'THL', - coingecko_id: 'thala', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/THL.svg', - project_url: 'https://www.thala.fi/', - token_type: { - type: '0x7fd500c11216f0fe3095d0c4b8aa4d64a4e2e04f83758462f2b127255643615::thl_coin::THL', - account_address: '0x7fd500c11216f0fe3095d0c4b8aa4d64a4e2e04f83758462f2b127255643615', - module_name: 'thl_coin', - struct_name: 'THL' - }, - extensions: { - data: [] - }, - unique_index: 129, - source: 'native', - permissioned_listing: true, - hippo_symbol: 'THL', - pancake_symbol: 'THL' - }, - { - name: 'Aptopad Coin', - symbol: 'APD', - official_symbol: 'APD', - coingecko_id: '', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/aptopad.png', - project_url: 'https://aptopad.io', - token_type: { - type: '0xcc78307c77f1c2c0fdfee17269bfca7876a0b35438c3442417480c0d5c370fbc::AptopadCoin::APD', - account_address: '0xcc78307c77f1c2c0fdfee17269bfca7876a0b35438c3442417480c0d5c370fbc', - module_name: 'AptopadCoin', - struct_name: 'APD' - }, - extensions: { - data: [] - }, - unique_index: 130, - source: 'native', - hippo_symbol: 'APD', - pancake_symbol: 'APD', - permissioned_listing: false - }, - { - name: 'Mover', - symbol: 'MOVER', - official_symbol: 'MOVER', - coingecko_id: 'mover-xyz', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/MOVER.svg', - project_url: 'https://mov3r.xyz/', - token_type: { - type: '0x14b0ef0ec69f346bea3dfa0c5a8c3942fb05c08760059948f9f24c02cd0d4fd8::mover_token::Mover', - account_address: '0x14b0ef0ec69f346bea3dfa0c5a8c3942fb05c08760059948f9f24c02cd0d4fd8', - module_name: 'mover_token', - struct_name: 'Mover' - }, - extensions: { - data: [] - }, - unique_index: 131, - source: 'native', - permissioned_listing: true, - hippo_symbol: 'MOVER', - pancake_symbol: 'MOVER' - }, - { - name: 'Ditto Staked Aptos', - symbol: 'stAPT', - official_symbol: 'stAPT', - coingecko_id: 'ditto-staked-aptos', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/DittoStakedAptos.svg', - project_url: 'https://www.dittofinance.io/', - token_type: { - type: '0xd11107bdf0d6d7040c6c0bfbdecb6545191fdf13e8d8d259952f53e1713f61b5::staked_coin::StakedAptos', - account_address: '0xd11107bdf0d6d7040c6c0bfbdecb6545191fdf13e8d8d259952f53e1713f61b5', - module_name: 'staked_coin', - struct_name: 'StakedAptos' - }, - extensions: { - data: [['bridge', 'native']] - }, - unique_index: 156, - source: 'native', - permissioned_listing: true, - hippo_symbol: 'stAPT', - pancake_symbol: 'stAPT' - }, - { - name: 'Ditto Discount Token', - symbol: 'DTO', - official_symbol: 'DTO', - coingecko_id: 'ditto-discount-token', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/DTO.svg', - project_url: 'https://www.dittofinance.io/', - token_type: { - type: '0xd11107bdf0d6d7040c6c0bfbdecb6545191fdf13e8d8d259952f53e1713f61b5::ditto_discount_coin::DittoDiscountCoin', - account_address: '0xd11107bdf0d6d7040c6c0bfbdecb6545191fdf13e8d8d259952f53e1713f61b5', - module_name: 'ditto_discount_coin', - struct_name: 'DittoDiscountCoin' - }, - extensions: { - data: [['bridge', 'native']] - }, - unique_index: 191, - source: 'native', - permissioned_listing: true, - hippo_symbol: 'DTO', - pancake_symbol: 'DTO' - }, - { - name: 'Aptoge', - symbol: 'APTOGE', - official_symbol: 'APTOGE', - coingecko_id: '', - decimals: 6, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/APTOGE.svg', - project_url: 'https://aptoge.com', - token_type: { - type: '0x5c738a5dfa343bee927c39ebe85b0ceb95fdb5ee5b323c95559614f5a77c47cf::Aptoge::Aptoge', - account_address: '0x5c738a5dfa343bee927c39ebe85b0ceb95fdb5ee5b323c95559614f5a77c47cf', - module_name: 'Aptoge', - struct_name: 'Aptoge' - }, - extensions: { - data: [['bridge', 'native']] - }, - unique_index: 231, - source: 'native', - permissioned_listing: true, - hippo_symbol: 'APTOGE', - pancake_symbol: 'APTOGE' - }, - { - name: 'Eternal Token', - symbol: 'ETERN', - official_symbol: 'ETERN', - coingecko_id: '', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/ETERN.svg', - project_url: 'https://eternalfinance.io', - token_type: { - type: '0x25a64579760a4c64be0d692327786a6375ec80740152851490cfd0b53604cf95::coin::ETERN', - account_address: '0x25a64579760a4c64be0d692327786a6375ec80740152851490cfd0b53604cf95', - module_name: 'coin', - struct_name: 'ETERN' - }, - extensions: { - data: [] - }, - unique_index: 256, - source: 'native', - permissioned_listing: true, - hippo_symbol: 'ETERN', - pancake_symbol: 'ETERN' - }, - { - name: 'Argo USD', - symbol: 'USDA', - official_symbol: 'USDA', - coingecko_id: '', - decimals: 6, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/USDA.svg', - project_url: 'https://argo.fi/', - token_type: { - type: '0x1000000fa32d122c18a6a31c009ce5e71674f22d06a581bb0a15575e6addadcc::usda::USDA', - account_address: '0x1000000fa32d122c18a6a31c009ce5e71674f22d06a581bb0a15575e6addadcc', - module_name: 'usda', - struct_name: 'USDA' - }, - extensions: { - data: [['bridge', 'native']] - }, - unique_index: 351, - source: 'native', - permissioned_listing: true, - hippo_symbol: 'USDA', - pancake_symbol: 'USDA' - }, - { - name: 'APass Coin', - symbol: 'APC', - official_symbol: 'APC', - coingecko_id: '', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/APC.svg', - project_url: 'https://aptpp.com', - token_type: { - type: '0x777821c78442e17d82c3d7a371f42de7189e4248e529fe6eee6bca40ddbb::apcoin::ApCoin', - account_address: '0x777821c78442e17d82c3d7a371f42de7189e4248e529fe6eee6bca40ddbb', - module_name: 'apcoin', - struct_name: 'ApCoin' - }, - extensions: { - data: [['bridge', 'native']] - }, - unique_index: 392, - source: 'native', - hippo_symbol: 'APC', - pancake_symbol: 'APC', - permissioned_listing: false - }, - { - name: 'PancakeSwap Token', - symbol: 'CAKE', - official_symbol: 'CAKE', - coingecko_id: 'pancakeswap-token', - decimals: 8, - logo_url: 'https://pancakeswap.finance/images/tokens/0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82.svg', - project_url: 'https://pancakeswap.finance/', - token_type: { - type: '0x159df6b7689437016108a019fd5bef736bac692b6d4a1f10c941f6fbb9a74ca6::oft::CakeOFT', - account_address: '0x159df6b7689437016108a019fd5bef736bac692b6d4a1f10c941f6fbb9a74ca6', - module_name: 'oft', - struct_name: 'CakeOFT' - }, - extensions: { - data: [['bridge', 'native']] - }, - unique_index: 397, - source: 'native', - permissioned_listing: true, - hippo_symbol: 'CAKE', - pancake_symbol: 'CAKE' - }, - { - name: 'EON', - symbol: 'EON', - official_symbol: 'EON', - coingecko_id: '', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/EON.svg', - project_url: 'https://eonlabz.com/', - token_type: { - type: '0x389dbbc6884a1d5b1ab4e1df2913a8c1b01251e50aed377554372b2842c5e3ef::EONcoin::EONCoin', - account_address: '0x389dbbc6884a1d5b1ab4e1df2913a8c1b01251e50aed377554372b2842c5e3ef', - module_name: 'EONcoin', - struct_name: 'EONCoin' - }, - extensions: { - data: [['bridge', 'native']] - }, - unique_index: 477, - source: 'native', - hippo_symbol: 'EON', - pancake_symbol: 'EON', - permissioned_listing: false - }, - { - name: 'Mojito', - symbol: 'MOJO', - official_symbol: 'MOJO', - coingecko_id: 'mojito', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/MOJO.svg', - project_url: 'https://www.mojito.markets/', - token_type: { - type: '0x881ac202b1f1e6ad4efcff7a1d0579411533f2502417a19211cfc49751ddb5f4::coin::MOJO', - account_address: '0x881ac202b1f1e6ad4efcff7a1d0579411533f2502417a19211cfc49751ddb5f4', - module_name: 'coin', - struct_name: 'MOJO' - }, - extensions: { - data: [['bridge', 'native']] - }, - unique_index: 551, - source: 'native', - hippo_symbol: 'MOJO', - pancake_symbol: 'MOJO', - permissioned_listing: false - }, - { - name: 'Doglaika Coin', - symbol: 'DLC', - official_symbol: 'DLC', - coingecko_id: 'doglaikacoin', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/DLC.svg', - project_url: 'http://linktr.ee/doglaikacoin', - token_type: { - type: '0x84edd115c901709ef28f3cb66a82264ba91bfd24789500b6fd34ab9e8888e272::coin::DLC', - account_address: '0x84edd115c901709ef28f3cb66a82264ba91bfd24789500b6fd34ab9e8888e272', - module_name: 'coin', - struct_name: 'DLC' - }, - extensions: { - data: [['bridge', 'native']] - }, - unique_index: 591, - source: 'native', - permissioned_listing: true, - hippo_symbol: 'DLC', - pancake_symbol: 'DLC' - }, - { - name: 'The People', - symbol: 'People', - official_symbol: 'People', - coingecko_id: '', - decimals: 6, - logo_url: 'https://raw.githubusercontent.com/ThePeopleAPT/the_peoplemove/main/Logo.png', - project_url: 'https://thepeopleapt.xyz/', - token_type: { - type: '0x5a1e84cdd217034d764abb91bf20aa0536c5a8c900831a37b393fe3af98c3f55::thepeoplecoin::The_People', - account_address: '0x5a1e84cdd217034d764abb91bf20aa0536c5a8c900831a37b393fe3af98c3f55', - module_name: 'thepeoplecoin', - struct_name: 'The_People' - }, - extensions: { - data: [['bridge', 'native']] - }, - unique_index: 691, - source: 'native', - hippo_symbol: 'People', - pancake_symbol: 'People', - permissioned_listing: false - }, - { - name: 'AnimeSwap Coin', - symbol: 'ANI', - official_symbol: 'ANI', - coingecko_id: '', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/ANI.png', - project_url: 'http://animeswap.org/', - token_type: { - type: '0x16fe2df00ea7dde4a63409201f7f4e536bde7bb7335526a35d05111e68aa322c::AnimeCoin::ANI', - account_address: '0x16fe2df00ea7dde4a63409201f7f4e536bde7bb7335526a35d05111e68aa322c', - module_name: 'AnimeCoin', - struct_name: 'ANI' - }, - extensions: { - data: [['bridge', 'native']] - }, - unique_index: 712, - source: 'native', - permissioned_listing: true, - hippo_symbol: 'ANI', - pancake_symbol: 'ANI' - }, - { - name: 'Abel Coin', - symbol: 'ABEL', - official_symbol: 'ABEL', - coingecko_id: '', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/ABEL.svg', - project_url: 'https://www.abelfinance.xyz/', - token_type: { - type: '0x7c0322595a73b3fc53bb166f5783470afeb1ed9f46d1176db62139991505dc61::abel_coin::AbelCoin', - account_address: '0x7c0322595a73b3fc53bb166f5783470afeb1ed9f46d1176db62139991505dc61', - module_name: 'abel_coin', - struct_name: 'AbelCoin' - }, - extensions: { - data: [['bridge', 'native']] - }, - unique_index: 790, - source: 'native', - permissioned_listing: true, - hippo_symbol: 'ABEL', - pancake_symbol: 'ABEL' - }, - { - name: 'SPRING', - symbol: 'SPRING', - official_symbol: 'SPRING', - coingecko_id: 'spring', - decimals: 9, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/SPRING.webp', - project_url: 'https://springers.co.in/', - token_type: { - type: '0x7bdeaba6f037caf06bb5b2d57df9ee03a07e2a9df45b338ef3deb44d16c01d10::spring_coin::Spring_Coin', - account_address: '0x7bdeaba6f037caf06bb5b2d57df9ee03a07e2a9df45b338ef3deb44d16c01d10', - module_name: 'spring_coin', - struct_name: 'Spring_Coin' - }, - extensions: { - data: [] - }, - unique_index: 797, - source: 'native', - hippo_symbol: 'SPRING', - pancake_symbol: 'SPRING', - permissioned_listing: false - }, - { - name: 'Gari', - symbol: 'GARI', - official_symbol: 'GARI', - coingecko_id: 'gari-network', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/GARI.svg', - project_url: 'https://gari.network', - token_type: { - type: '0x4def3d3dee27308886f0a3611dd161ce34f977a9a5de4e80b237225923492a2a::coin::T', - account_address: '0x4def3d3dee27308886f0a3611dd161ce34f977a9a5de4e80b237225923492a2a', - module_name: 'coin', - struct_name: 'T' - }, - extensions: { - data: [['bridge', 'wormhole']] - }, - unique_index: 800, - source: 'wormhole', - permissioned_listing: true, - hippo_symbol: 'wGARI', - pancake_symbol: 'whGARI' - }, - { - name: 'BlueMove', - symbol: 'MOVE', - official_symbol: 'MOVE', - coingecko_id: 'bluemove', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/MOVE.svg', - project_url: 'https://bluemove.net/', - token_type: { - type: '0x27fafcc4e39daac97556af8a803dbb52bcb03f0821898dc845ac54225b9793eb::move_coin::MoveCoin', - account_address: '0x27fafcc4e39daac97556af8a803dbb52bcb03f0821898dc845ac54225b9793eb', - module_name: 'move_coin', - struct_name: 'MoveCoin' - }, - extensions: { - data: [] - }, - unique_index: 912, - source: 'native', - permissioned_listing: true, - hippo_symbol: 'MOVE', - pancake_symbol: 'MOVE' - }, - { - name: 'AptosLaunch Token', - symbol: 'ALT', - official_symbol: 'ALT', - coingecko_id: '', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/Aptoslaunchlogob.svg', - project_url: 'https://aptoslaunch.io', - token_type: { - type: '0xd0b4efb4be7c3508d9a26a9b5405cf9f860d0b9e5fe2f498b90e68b8d2cedd3e::aptos_launch_token::AptosLaunchToken', - account_address: '0xd0b4efb4be7c3508d9a26a9b5405cf9f860d0b9e5fe2f498b90e68b8d2cedd3e', - module_name: 'aptos_launch_token', - struct_name: 'AptosLaunchToken' - }, - extensions: { - data: [['bridge', 'native']] - }, - unique_index: 928, - source: 'native', - permissioned_listing: true, - hippo_symbol: 'ALT', - pancake_symbol: 'ALT' - }, - { - name: 'AlpacaINU Coin', - symbol: 'ALI', - official_symbol: 'ALI', - coingecko_id: '', - decimals: 6, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/ALI.svg', - project_url: 'https://twitter.com/AlpacaINU', - token_type: { - type: '0x27975005fd8b836a905dc7f81c51f89e76091a4d0c4d694265f6eae0c05cb400::proton_a5d::PROTON_E54', - account_address: '0x27975005fd8b836a905dc7f81c51f89e76091a4d0c4d694265f6eae0c05cb400', - module_name: 'proton_a5d', - struct_name: 'PROTON_E54' - }, - extensions: { - data: [] - }, - unique_index: 937, - source: 'native', - hippo_symbol: 'ALI', - pancake_symbol: 'ALI', - permissioned_listing: false - }, - { - name: 'Tortuga Staked Aptos', - symbol: 'tAPT', - official_symbol: 'tAPT', - coingecko_id: 'tortuga-staked-aptos', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/TortugaStakedAptos.png', - project_url: 'https://tortuga.finance/', - token_type: { - type: '0x84d7aeef42d38a5ffc3ccef853e1b82e4958659d16a7de736a29c55fbbeb0114::staked_aptos_coin::StakedAptosCoin', - account_address: '0x84d7aeef42d38a5ffc3ccef853e1b82e4958659d16a7de736a29c55fbbeb0114', - module_name: 'staked_aptos_coin', - struct_name: 'StakedAptosCoin' - }, - extensions: { - data: [['bridge', 'native']] - }, - unique_index: 952, - source: 'native', - permissioned_listing: true, - hippo_symbol: 'tAPT', - pancake_symbol: 'tAPT' - }, - { - name: 'AptSwap Governance Token', - symbol: 'APTSWAP', - official_symbol: 'APTSWAP', - coingecko_id: '', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/AptSwap.svg', - project_url: 'http://aptswap.io', - token_type: { - type: '0x5c738a5dfa343bee927c39ebe85b0ceb95fdb5ee5b323c95559614f5a77c47cf::AptSwap::AptSwapGovernance', - account_address: '0x5c738a5dfa343bee927c39ebe85b0ceb95fdb5ee5b323c95559614f5a77c47cf', - module_name: 'AptSwap', - struct_name: 'AptSwapGovernance' - }, - extensions: { - data: [['bridge', 'native']] - }, - unique_index: 971, - source: 'native', - hippo_symbol: 'APTSWAP', - pancake_symbol: 'APTSWAP', - permissioned_listing: false - }, - { - name: 'USD Coin (Wormhole)', - symbol: 'USDC', - official_symbol: 'USDC', - coingecko_id: 'usd-coin', - decimals: 6, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/USDC.svg', - project_url: '', - token_type: { - type: '0x5e156f1207d0ebfa19a9eeff00d62a282278fb8719f4fab3a586a0a2c0fffbea::coin::T', - account_address: '0x5e156f1207d0ebfa19a9eeff00d62a282278fb8719f4fab3a586a0a2c0fffbea', - module_name: 'coin', - struct_name: 'T' - }, - extensions: { - data: [['bridge', 'wormhole']] - }, - unique_index: 2001, - source: 'wormhole', - permissioned_listing: true, - hippo_symbol: 'wUSDC', - pancake_symbol: 'whUSDC' - }, - { - name: 'Tether USD (Wormhole)', - symbol: 'USDT', - official_symbol: 'USDT', - coingecko_id: 'tether', - decimals: 6, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/USDT.svg', - project_url: '', - token_type: { - type: '0xa2eda21a58856fda86451436513b867c97eecb4ba099da5775520e0f7492e852::coin::T', - account_address: '0xa2eda21a58856fda86451436513b867c97eecb4ba099da5775520e0f7492e852', - module_name: 'coin', - struct_name: 'T' - }, - extensions: { - data: [['bridge', 'wormhole']] - }, - unique_index: 2002, - source: 'wormhole', - permissioned_listing: true, - hippo_symbol: 'wUSDT', - pancake_symbol: 'whUSDT' - }, - { - name: 'Wrapped BTC (Wormhole)', - symbol: 'WBTC', - official_symbol: 'WBTC', - coingecko_id: 'wrapped-bitcoin', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/BTC.webp', - project_url: '', - token_type: { - type: '0xae478ff7d83ed072dbc5e264250e67ef58f57c99d89b447efd8a0a2e8b2be76e::coin::T', - account_address: '0xae478ff7d83ed072dbc5e264250e67ef58f57c99d89b447efd8a0a2e8b2be76e', - module_name: 'coin', - struct_name: 'T' - }, - extensions: { - data: [['bridge', 'wormhole']] - }, - unique_index: 2003, - source: 'wormhole', - permissioned_listing: true, - hippo_symbol: 'wWBTC', - pancake_symbol: 'whWBTC' - }, - { - name: 'Wrapped Ether (Wormhole)', - symbol: 'WETH', - official_symbol: 'WETH', - coingecko_id: 'weth', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/WETH.svg', - project_url: '', - token_type: { - type: '0xcc8a89c8dce9693d354449f1f73e60e14e347417854f029db5bc8e7454008abb::coin::T', - account_address: '0xcc8a89c8dce9693d354449f1f73e60e14e347417854f029db5bc8e7454008abb', - module_name: 'coin', - struct_name: 'T' - }, - extensions: { - data: [['bridge', 'wormhole']] - }, - unique_index: 2004, - source: 'wormhole', - permissioned_listing: true, - hippo_symbol: 'wWETH', - pancake_symbol: 'whWETH' - }, - { - name: 'Dai Stablecoin (Wormhole)', - symbol: 'DAI', - official_symbol: 'DAI', - coingecko_id: 'dai', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/DAI.webp', - project_url: '', - token_type: { - type: '0x407a220699982ebb514568d007938d2447d33667e4418372ffec1ddb24491b6c::coin::T', - account_address: '0x407a220699982ebb514568d007938d2447d33667e4418372ffec1ddb24491b6c', - module_name: 'coin', - struct_name: 'T' - }, - extensions: { - data: [['bridge', 'wormhole']] - }, - unique_index: 2005, - source: 'wormhole', - permissioned_listing: true, - hippo_symbol: 'wDAI', - pancake_symbol: 'whDAI' - }, - { - name: 'BUSD Token (Wormhole)', - symbol: 'BUSD', - official_symbol: 'BUSD', - coingecko_id: 'binance-usd', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/BUSD.webp', - project_url: '', - token_type: { - type: '0xccc9620d38c4f3991fa68a03ad98ef3735f18d04717cb75d7a1300dd8a7eed75::coin::T', - account_address: '0xccc9620d38c4f3991fa68a03ad98ef3735f18d04717cb75d7a1300dd8a7eed75', - module_name: 'coin', - struct_name: 'T' - }, - extensions: { - data: [['bridge', 'wormhole']] - }, - unique_index: 2006, - source: 'wormhole', - permissioned_listing: true, - hippo_symbol: 'wBUSD', - pancake_symbol: 'whBUSD' - }, - { - name: 'Wrapped BNB (Wormhole)', - symbol: 'WBNB', - official_symbol: 'WBNB', - coingecko_id: 'binancecoin', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/BNB.webp', - project_url: '', - token_type: { - type: '0x6312bc0a484bc4e37013befc9949df2d7c8a78e01c6fe14a34018449d136ba86::coin::T', - account_address: '0x6312bc0a484bc4e37013befc9949df2d7c8a78e01c6fe14a34018449d136ba86', - module_name: 'coin', - struct_name: 'T' - }, - extensions: { - data: [['bridge', 'wormhole']] - }, - unique_index: 2009, - source: 'wormhole', - permissioned_listing: true, - hippo_symbol: 'wWBNB', - pancake_symbol: 'whWBNB' - }, - { - name: 'SOL (Wormhole)', - symbol: 'SOL', - official_symbol: 'SOL', - coingecko_id: 'solana', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/SOL.webp', - project_url: '', - token_type: { - type: '0xdd89c0e695df0692205912fb69fc290418bed0dbe6e4573d744a6d5e6bab6c13::coin::T', - account_address: '0xdd89c0e695df0692205912fb69fc290418bed0dbe6e4573d744a6d5e6bab6c13', - module_name: 'coin', - struct_name: 'T' - }, - extensions: { - data: [['bridge', 'wormhole-solana']] - }, - unique_index: 2011, - source: 'wormhole', - permissioned_listing: true, - hippo_symbol: 'wSOL', - pancake_symbol: 'whSOL' - }, - { - name: 'Tether USD', - symbol: 'USDTbs', - official_symbol: 'USDT', - coingecko_id: 'tether', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/USDT.svg', - project_url: '', - token_type: { - type: '0xacd014e8bdf395fa8497b6d585b164547a9d45269377bdf67c96c541b7fec9ed::coin::T', - account_address: '0xacd014e8bdf395fa8497b6d585b164547a9d45269377bdf67c96c541b7fec9ed', - module_name: 'coin', - struct_name: 'T' - }, - extensions: { - data: [['bridge', 'wormhole-bsc']] - }, - unique_index: 2050, - source: 'wormhole-bsc', - permissioned_listing: true, - hippo_symbol: 'USDTbs', - pancake_symbol: 'USDTbs' - }, - { - name: 'USD Coin (Wormhole Solana)', - symbol: 'USDCso', - official_symbol: 'USDC', - coingecko_id: '', - decimals: 6, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/USDC.svg', - project_url: '', - token_type: { - type: '0xc91d826e29a3183eb3b6f6aa3a722089fdffb8e9642b94c5fcd4c48d035c0080::coin::T', - account_address: '0xc91d826e29a3183eb3b6f6aa3a722089fdffb8e9642b94c5fcd4c48d035c0080', - module_name: 'coin', - struct_name: 'T' - }, - extensions: { - data: [['bridge', 'wormhole-solana']] - }, - unique_index: 2113, - source: 'wormhole-solana', - permissioned_listing: true, - hippo_symbol: 'USDCso', - pancake_symbol: 'USDCso' - }, - { - name: 'USD Coin (Wormhole Polygon)', - symbol: 'USDCpo', - official_symbol: 'USDC', - coingecko_id: 'usd-coin', - decimals: 6, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/USDC.svg', - project_url: '', - token_type: { - type: '0xc7160b1c2415d19a88add188ec726e62aab0045f0aed798106a2ef2994a9101e::coin::T', - account_address: '0xc7160b1c2415d19a88add188ec726e62aab0045f0aed798106a2ef2994a9101e', - module_name: 'coin', - struct_name: 'T' - }, - extensions: { - data: [['bridge', 'wormhole-polygon']] - }, - unique_index: 2171, - source: 'wormhole-polygon', - permissioned_listing: true, - hippo_symbol: 'USDCpo', - pancake_symbol: 'USDCpo' - }, - { - name: 'USD Coin (Wormhole, BSC)', - symbol: 'USDCbs', - official_symbol: 'USDC', - coingecko_id: 'usd-coin', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/USDC.svg', - project_url: '', - token_type: { - type: '0x79a6ed7a0607fdad2d18d67d1a0e552d4b09ebce5951f1e5c851732c02437595::coin::T', - account_address: '0x79a6ed7a0607fdad2d18d67d1a0e552d4b09ebce5951f1e5c851732c02437595', - module_name: 'coin', - struct_name: 'T' - }, - extensions: { - data: [['bridge', 'wormhole-bsc']] - }, - unique_index: 2202, - source: 'wormhole-bsc', - permissioned_listing: true, - hippo_symbol: 'USDCbs', - pancake_symbol: 'USDCbs' - }, - { - name: 'USD Coin (Wormhole Avalanche)', - symbol: 'USDCav', - official_symbol: 'USDC', - coingecko_id: 'usd-coin', - decimals: 6, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/USDC.svg', - project_url: '', - token_type: { - type: '0x39d84c2af3b0c9895b45d4da098049e382c451ba63bec0ce0396ff7af4bb5dff::coin::T', - account_address: '0x39d84c2af3b0c9895b45d4da098049e382c451ba63bec0ce0396ff7af4bb5dff', - module_name: 'coin', - struct_name: 'T' - }, - extensions: { - data: [['bridge', 'wormhole-avalanche']] - }, - unique_index: 2304, - source: 'wormhole-avalanche', - permissioned_listing: true, - hippo_symbol: 'USDCav', - pancake_symbol: 'USDCav' - }, - { - name: 'Wrapped AVAX (Wormhole)', - symbol: 'WAVAX', - official_symbol: 'WAVAX', - coingecko_id: 'avalanche-2', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/AVAX.webp', - project_url: '', - token_type: { - type: '0x5b1bbc25524d41b17a95dac402cf2f584f56400bf5cc06b53c36b331b1ec6e8f::coin::T', - account_address: '0x5b1bbc25524d41b17a95dac402cf2f584f56400bf5cc06b53c36b331b1ec6e8f', - module_name: 'coin', - struct_name: 'T' - }, - extensions: { - data: [['bridge', 'wormhole']] - }, - unique_index: 2332, - source: 'wormhole', - permissioned_listing: true, - hippo_symbol: 'wWAVAX', - pancake_symbol: 'whWAVAX' - }, - { - name: 'SWEAT', - symbol: 'SWEAT', - official_symbol: 'SWEAT', - coingecko_id: 'sweatcoin', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/SWEAT.webp', - project_url: '', - token_type: { - type: '0x9aa4c03344444b53f4d9b1bca229ed2ac47504e3ea6cd0683ebdc0c5ecefd693::coin::T', - account_address: '0x9aa4c03344444b53f4d9b1bca229ed2ac47504e3ea6cd0683ebdc0c5ecefd693', - module_name: 'coin', - struct_name: 'T' - }, - extensions: { - data: [['bridge', 'wormhole']] - }, - unique_index: 2409, - source: 'wormhole', - permissioned_listing: true, - hippo_symbol: 'wSWEAT', - pancake_symbol: 'whSWEAT' - }, - { - name: 'NEAR (Wormhole)', - symbol: 'NEAR', - official_symbol: 'NEAR', - coingecko_id: 'near', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/NEAR.webp', - project_url: '', - token_type: { - type: '0x394205c024d8e932832deef4cbfc7d3bb17ff2e9dc184fa9609405c2836b94aa::coin::T', - account_address: '0x394205c024d8e932832deef4cbfc7d3bb17ff2e9dc184fa9609405c2836b94aa', - module_name: 'coin', - struct_name: 'T' - }, - extensions: { - data: [['bridge', 'wormhole']] - }, - unique_index: 2492, - source: 'wormhole', - permissioned_listing: true, - hippo_symbol: 'wNEAR', - pancake_symbol: 'whNEAR' - }, - { - name: 'Nexum Coin', - symbol: 'NEXM', - official_symbol: 'NEXM', - coingecko_id: 'nexum', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/NEXM.webp', - project_url: '', - token_type: { - type: '0x1f9dca8eb42832b9ea07a804d745ef08833051e0c75c45b82665ef6f6e7fac32::coin::T', - account_address: '0x1f9dca8eb42832b9ea07a804d745ef08833051e0c75c45b82665ef6f6e7fac32', - module_name: 'coin', - struct_name: 'T' - }, - extensions: { - data: [['bridge', 'wormhole']] - }, - unique_index: 2527, - source: 'wormhole', - permissioned_listing: true, - hippo_symbol: 'wNEXM', - pancake_symbol: 'whNEXM' - }, - { - name: 'SushiToken (Wormhole)', - symbol: 'SUSHI', - official_symbol: 'SUSHI', - coingecko_id: 'sushi', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/SUSHI.webp', - project_url: '', - token_type: { - type: '0x2305dd96edd8debb5a2049be54379c74e61b37ceb54a49bd7dee4726d2a6b689::coin::T', - account_address: '0x2305dd96edd8debb5a2049be54379c74e61b37ceb54a49bd7dee4726d2a6b689', - module_name: 'coin', - struct_name: 'T' - }, - extensions: { - data: [['bridge', 'wormhole']] - }, - unique_index: 2700, - source: 'wormhole', - permissioned_listing: true, - hippo_symbol: 'wSUSHI', - pancake_symbol: 'whSUSHI' - }, - { - name: 'Celo (Wormhole)', - symbol: 'CELO', - official_symbol: 'CELO', - coingecko_id: 'celo', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/CELO.webp', - project_url: '', - token_type: { - type: '0xac0c3c35d50f6ef00e3b4db6998732fe9ed6331384925fe8ec95fcd7745a9112::coin::T', - account_address: '0xac0c3c35d50f6ef00e3b4db6998732fe9ed6331384925fe8ec95fcd7745a9112', - module_name: 'coin', - struct_name: 'T' - }, - extensions: { - data: [['bridge', 'wormhole']] - }, - unique_index: 2801, - source: 'wormhole', - permissioned_listing: true, - hippo_symbol: 'wCELO', - pancake_symbol: 'whCELO' - }, - { - name: 'FTX Token', - symbol: 'FTT', - official_symbol: 'FTT', - coingecko_id: 'ftx-token', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/FTXToken.webp', - project_url: '', - token_type: { - type: '0x419d16ebaeda8dc374b1178a61d24fb699799d55a3f475f427998769c537b51b::coin::T', - account_address: '0x419d16ebaeda8dc374b1178a61d24fb699799d55a3f475f427998769c537b51b', - module_name: 'coin', - struct_name: 'T' - }, - extensions: { - data: [['bridge', 'wormhole']] - }, - unique_index: 2971, - source: 'wormhole', - permissioned_listing: true, - hippo_symbol: 'wFTT', - pancake_symbol: 'whFTT' - }, - { - name: 'Chain', - symbol: 'XCN', - official_symbol: 'XCN', - coingecko_id: 'chain-2', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/XCN.webp', - project_url: '', - token_type: { - type: '0xcefd39b563951a9ec2670aa57086f9adb3493671368ea60ff99e0bc98f697bb5::coin::T', - account_address: '0xcefd39b563951a9ec2670aa57086f9adb3493671368ea60ff99e0bc98f697bb5', - module_name: 'coin', - struct_name: 'T' - }, - extensions: { - data: [['bridge', 'wormhole']] - }, - unique_index: 2991, - source: 'wormhole', - permissioned_listing: true, - hippo_symbol: 'wXCN', - pancake_symbol: 'whXCN' - }, - { - name: 'USD Coin (LayerZero)', - symbol: 'zUSDC', - official_symbol: 'USDC', - coingecko_id: 'usd-coin', - decimals: 6, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/USDC.svg', - project_url: '', - token_type: { - type: '0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC', - account_address: '0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa', - module_name: 'asset', - struct_name: 'USDC' - }, - extensions: { - data: [['bridge', 'layerzero']] - }, - unique_index: 3001, - source: 'layerzero', - permissioned_listing: true, - hippo_symbol: 'zUSDC', - pancake_symbol: 'lzUSDC' - }, - { - name: 'USD Tether (LayerZero)', - symbol: 'zUSDT', - official_symbol: 'USDT', - coingecko_id: 'tether', - decimals: 6, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/USDT.svg', - project_url: '', - token_type: { - type: '0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDT', - account_address: '0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa', - module_name: 'asset', - struct_name: 'USDT' - }, - extensions: { - data: [['bridge', 'layerzero']] - }, - unique_index: 3002, - source: 'layerzero', - permissioned_listing: true, - hippo_symbol: 'zUSDT', - pancake_symbol: 'lzUSDT' - }, - { - name: 'Wrapped Ether (LayerZero)', - symbol: 'zWETH', - official_symbol: 'WETH', - coingecko_id: 'weth', - decimals: 6, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/WETH.svg', - project_url: '', - token_type: { - type: '0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::WETH', - account_address: '0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa', - module_name: 'asset', - struct_name: 'WETH' - }, - extensions: { - data: [['bridge', 'layerzero']] - }, - unique_index: 3004, - source: 'layerzero', - permissioned_listing: true, - hippo_symbol: 'zWETH', - pancake_symbol: 'lzWETH' - }, - { - name: 'USD Coin (Celer)', - symbol: 'ceUSDC', - official_symbol: 'USDC', - coingecko_id: 'usd-coin', - decimals: 6, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/USDC.svg', - project_url: 'https://celer.network', - token_type: { - type: '0x8d87a65ba30e09357fa2edea2c80dbac296e5dec2b18287113500b902942929d::celer_coin_manager::UsdcCoin', - account_address: '0x8d87a65ba30e09357fa2edea2c80dbac296e5dec2b18287113500b902942929d', - module_name: 'celer_coin_manager', - struct_name: 'UsdcCoin' - }, - extensions: { - data: [['bridge', 'celer']] - }, - unique_index: 4001, - source: 'celer', - permissioned_listing: true, - hippo_symbol: 'ceUSDC', - pancake_symbol: 'ceUSDC' - }, - { - name: 'Tether USD (Celer)', - symbol: 'ceUSDT', - official_symbol: 'USDT', - coingecko_id: 'tether', - decimals: 6, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/USDT.svg', - project_url: 'https://celer.network', - token_type: { - type: '0x8d87a65ba30e09357fa2edea2c80dbac296e5dec2b18287113500b902942929d::celer_coin_manager::UsdtCoin', - account_address: '0x8d87a65ba30e09357fa2edea2c80dbac296e5dec2b18287113500b902942929d', - module_name: 'celer_coin_manager', - struct_name: 'UsdtCoin' - }, - extensions: { - data: [['bridge', 'celer']] - }, - unique_index: 4002, - source: 'celer', - permissioned_listing: true, - hippo_symbol: 'ceUSDT', - pancake_symbol: 'ceUSDT' - }, - { - name: 'Wrapped BTC (Celer)', - symbol: 'ceWBTC', - official_symbol: 'WBTC', - coingecko_id: 'wrapped-bitcoin', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/WBTC.svg', - project_url: 'https://celer.network', - token_type: { - type: '0x8d87a65ba30e09357fa2edea2c80dbac296e5dec2b18287113500b902942929d::celer_coin_manager::WbtcCoin', - account_address: '0x8d87a65ba30e09357fa2edea2c80dbac296e5dec2b18287113500b902942929d', - module_name: 'celer_coin_manager', - struct_name: 'WbtcCoin' - }, - extensions: { - data: [['bridge', 'celer']] - }, - unique_index: 4003, - source: 'celer', - permissioned_listing: true, - hippo_symbol: 'ceWBTC', - pancake_symbol: 'ceWBTC' - }, - { - name: 'Wrapped Ether (Celer)', - symbol: 'ceWETH', - official_symbol: 'WETH', - coingecko_id: 'ethereum', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/WETH.svg', - project_url: 'https://celer.network', - token_type: { - type: '0x8d87a65ba30e09357fa2edea2c80dbac296e5dec2b18287113500b902942929d::celer_coin_manager::WethCoin', - account_address: '0x8d87a65ba30e09357fa2edea2c80dbac296e5dec2b18287113500b902942929d', - module_name: 'celer_coin_manager', - struct_name: 'WethCoin' - }, - extensions: { - data: [['bridge', 'celer']] - }, - unique_index: 4004, - source: 'celer', - permissioned_listing: true, - hippo_symbol: 'ceWETH', - pancake_symbol: 'ceWETH' - }, - { - name: 'Dai Stablecoin (Celer)', - symbol: 'ceDAI', - official_symbol: 'DAI', - coingecko_id: 'dai', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/DAI.svg', - project_url: 'https://celer.network', - token_type: { - type: '0x8d87a65ba30e09357fa2edea2c80dbac296e5dec2b18287113500b902942929d::celer_coin_manager::DaiCoin', - account_address: '0x8d87a65ba30e09357fa2edea2c80dbac296e5dec2b18287113500b902942929d', - module_name: 'celer_coin_manager', - struct_name: 'DaiCoin' - }, - extensions: { - data: [['bridge', 'celer']] - }, - unique_index: 4005, - source: 'celer', - permissioned_listing: true, - hippo_symbol: 'ceDAI', - pancake_symbol: 'ceDAI' - }, - { - name: 'Binance Coin (Celer)', - symbol: 'ceBNB', - official_symbol: 'BNB', - coingecko_id: 'binancecoin', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/BNB.svg', - project_url: 'https://celer.network', - token_type: { - type: '0x8d87a65ba30e09357fa2edea2c80dbac296e5dec2b18287113500b902942929d::celer_coin_manager::BnbCoin', - account_address: '0x8d87a65ba30e09357fa2edea2c80dbac296e5dec2b18287113500b902942929d', - module_name: 'celer_coin_manager', - struct_name: 'BnbCoin' - }, - extensions: { - data: [['bridge', 'celer']] - }, - unique_index: 4113, - source: 'celer', - permissioned_listing: true, - hippo_symbol: 'ceBNB', - pancake_symbol: 'ceBNB' - }, - { - name: 'Binance USD (Celer)', - symbol: 'ceBUSD', - official_symbol: 'BUSD', - coingecko_id: 'binance-usd', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/BUSD.svg', - project_url: 'https://celer.network', - token_type: { - type: '0x8d87a65ba30e09357fa2edea2c80dbac296e5dec2b18287113500b902942929d::celer_coin_manager::BusdCoin', - account_address: '0x8d87a65ba30e09357fa2edea2c80dbac296e5dec2b18287113500b902942929d', - module_name: 'celer_coin_manager', - struct_name: 'BusdCoin' - }, - extensions: { - data: [['bridge', 'celer']] - }, - unique_index: 4119, - source: 'celer', - permissioned_listing: true, - hippo_symbol: 'ceBUSD', - pancake_symbol: 'ceBUSD' - }, - { - name: 'XBTC', - symbol: 'XBTC', - official_symbol: 'XBTC', - coingecko_id: '', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/XBTC.svg', - project_url: 'https://github.com/OmniBTC/OmniBridge', - token_type: { - type: '0x3b0a7c06837e8fbcce41af0e629fdc1f087b06c06ff9e86f81910995288fd7fb::xbtc::XBTC', - account_address: '0x3b0a7c06837e8fbcce41af0e629fdc1f087b06c06ff9e86f81910995288fd7fb', - module_name: 'xbtc', - struct_name: 'XBTC' - }, - extensions: { - data: [] - }, - unique_index: 5003, - source: 'omnibridge', - permissioned_listing: true, - hippo_symbol: 'XBTC', - pancake_symbol: 'XBTC' - }, - { - name: 'Aries Aptos Coin LP Token', - symbol: 'ar-APT', - official_symbol: 'aAPT', - coingecko_id: '', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/ar-APT.svg', - project_url: 'https://ariesmarkets.xyz/', - token_type: { - type: '0x9770fa9c725cbd97eb50b2be5f7416efdfd1f1554beb0750d4dae4c64e860da3::reserve::LP<0x1::aptos_coin::AptosCoin>', - account_address: '0x9770fa9c725cbd97eb50b2be5f7416efdfd1f1554beb0750d4dae4c64e860da3', - module_name: 'reserve', - struct_name: 'LP<0x1::aptos_coin::AptosCoin>' - }, - extensions: { - data: [ - ['lp', 'aries'], - ['bridge', 'native'] - ] - }, - unique_index: 15338, - source: 'native', - permissioned_listing: true, - hippo_symbol: 'ar-APT', - pancake_symbol: 'ar-APT' - }, - { - name: 'Aries Solana (Wormhole) LP Token', - symbol: 'ar-SOL', - official_symbol: 'aSOL', - coingecko_id: '', - decimals: 8, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/ar-SOL.svg', - project_url: 'https://ariesmarkets.xyz/', - token_type: { - type: '0x9770fa9c725cbd97eb50b2be5f7416efdfd1f1554beb0750d4dae4c64e860da3::reserve::LP<0xdd89c0e695df0692205912fb69fc290418bed0dbe6e4573d744a6d5e6bab6c13::coin::T>', - account_address: '0x9770fa9c725cbd97eb50b2be5f7416efdfd1f1554beb0750d4dae4c64e860da3', - module_name: 'reserve', - struct_name: 'LP<0xdd89c0e695df0692205912fb69fc290418bed0dbe6e4573d744a6d5e6bab6c13::coin::T>' - }, - extensions: { - data: [ - ['lp', 'aries'], - ['bridge', 'native'] - ] - }, - unique_index: 15339, - source: 'native', - permissioned_listing: true, - hippo_symbol: 'ar-SOL', - pancake_symbol: 'ar-SOL' - }, - { - name: 'Aries USDC (Layerzero) LP Token', - symbol: 'ar-zUSDC', - official_symbol: 'aUSDC', - coingecko_id: '', - decimals: 6, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/ar-USDC.svg', - project_url: 'https://ariesmarkets.xyz/', - token_type: { - type: '0x9770fa9c725cbd97eb50b2be5f7416efdfd1f1554beb0750d4dae4c64e860da3::reserve::LP<0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC>', - account_address: '0x9770fa9c725cbd97eb50b2be5f7416efdfd1f1554beb0750d4dae4c64e860da3', - module_name: 'reserve', - struct_name: 'LP<0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC>' - }, - extensions: { - data: [ - ['lp', 'aries'], - ['bridge', 'native'] - ] - }, - unique_index: 15340, - source: 'native', - permissioned_listing: true, - hippo_symbol: 'ar-zUSDC', - pancake_symbol: 'ar-zUSDC' - }, - { - name: 'Aries USDC (Wormhole) LP Token', - symbol: 'ar-USDC', - official_symbol: 'aUSDC', - coingecko_id: '', - decimals: 6, - logo_url: 'https://raw.githubusercontent.com/hippospace/aptos-coin-list/main/icons/ar-USDC.svg', - project_url: 'https://ariesmarkets.xyz/', - token_type: { - type: '0x9770fa9c725cbd97eb50b2be5f7416efdfd1f1554beb0750d4dae4c64e860da3::reserve::LP<0x5e156f1207d0ebfa19a9eeff00d62a282278fb8719f4fab3a586a0a2c0fffbea::coin::T>', - account_address: '0x9770fa9c725cbd97eb50b2be5f7416efdfd1f1554beb0750d4dae4c64e860da3', - module_name: 'reserve', - struct_name: 'LP<0x5e156f1207d0ebfa19a9eeff00d62a282278fb8719f4fab3a586a0a2c0fffbea::coin::T>' - }, - extensions: { - data: [ - ['lp', 'aries'], - ['bridge', 'native'] - ] - }, - unique_index: 15341, - source: 'native', - permissioned_listing: true, - hippo_symbol: 'ar-USDC', - pancake_symbol: 'ar-USDC' - } -] - -setCoinList(DEFAULT_LIST) diff --git a/packages/sdk/src/aptos/ext/index.ts b/packages/sdk/src/aptos/ext/index.ts index 4bcfcebffd..721a0c0ecf 100644 --- a/packages/sdk/src/aptos/ext/index.ts +++ b/packages/sdk/src/aptos/ext/index.ts @@ -1,4 +1,3 @@ export * from './aptos-dex.js' -export * from './coin.js' export * from './token.js' export { findNewCoinBalances } from './coin-event.js' diff --git a/packages/sdk/src/aptos/ext/token.ts b/packages/sdk/src/aptos/ext/token.ts index 7f055ecd7f..4ac8c17a23 100644 --- a/packages/sdk/src/aptos/ext/token.ts +++ b/packages/sdk/src/aptos/ext/token.ts @@ -6,8 +6,9 @@ import { coin } from '../builtin/0x1.js' import { MoveStructId } from '@aptos-labs/ts-sdk' import { AptosChainId } from '@sentio/chain' import DEFAULT_TOKEN_LIST from './token-list.json' assert { type: 'json' } +import { BaseCoinInfo } from '../../move/ext/index.js' -type TokenInfo = { +type InternalTokenInfo = { chainId: number tokenAddress: `0x${string}` | null faAddress: `0x${string}` | null @@ -26,7 +27,8 @@ type TokenInfo = { coinMarketCapId: number | null } -export type SimpleTokenInfo = { +export interface TokenInfo extends BaseCoinInfo { + type: `0x${string}` // either tokenAddress or faAddress tokenAddress?: `0x${string}` faAddress?: `0x${string}` name: string @@ -40,15 +42,15 @@ export type SimpleTokenInfo = { coinMarketCapId?: number } -const TOKEN_MAP = new Map() +const TOKEN_MAP = new Map() export async function initTokenList() { - let list = DEFAULT_TOKEN_LIST as TokenInfo[] + let list = DEFAULT_TOKEN_LIST as InternalTokenInfo[] try { const resp = await fetch( 'https://raw.githubusercontent.com/PanoraExchange/Aptos-Tokens/refs/heads/main/token-list.json' ) - list = (await resp.json()) as TokenInfo[] + list = (await resp.json()) as InternalTokenInfo[] } catch (e) { console.warn("Can't not fetch newest token list, use default list") } @@ -56,8 +58,13 @@ export async function initTokenList() { setTokenList(list) } -function tokenInfoToSimple(info: TokenInfo): SimpleTokenInfo { +function tokenInfoToSimple(info: InternalTokenInfo): TokenInfo { + const type = info.tokenAddress || info.faAddress + if (!type) { + throw Error('Token info must have tokenAddress or faAddress') + } return { + type, tokenAddress: info.tokenAddress || undefined, faAddress: info.faAddress || undefined, name: info.name, @@ -72,7 +79,7 @@ function tokenInfoToSimple(info: TokenInfo): SimpleTokenInfo { } } -function setTokenList(list: TokenInfo[]) { +function setTokenList(list: InternalTokenInfo[]) { for (const info of list) { const simpleInfo = tokenInfoToSimple(info) if ( @@ -107,7 +114,7 @@ export function isWhiteListToken(token: string): boolean { const TOKEN_METADATA_CACHE = new Map>() // token: address of the fungible asset, e.g. "0xa", or the coin type, e.g. "0x1::aptos::AptosCoin" -export async function getTokenInfoWithFallback(token: string, network?: AptosNetwork): Promise { +export async function getTokenInfoWithFallback(token: string, network?: AptosNetwork): Promise { const r = TOKEN_MAP.get(token) if (!r) { network = network || AptosNetwork.MAIN_NET @@ -134,6 +141,7 @@ export async function getTokenInfoWithFallback(token: string, network?: AptosNet // const parts = type.split(SPLITTER) return { + type: token as `0x${string}`, category: 'Native', tokenAddress: token as `0x${string}`, name: meta.name, @@ -166,7 +174,7 @@ export async function getPriceForToken( export async function tokenTokenValueInUsd( n: bigint, - coinInfo: SimpleTokenInfo, + coinInfo: TokenInfo, timestamp: number, network = AptosChainId.APTOS_MAINNET ) { @@ -179,4 +187,4 @@ export async function tokenTokenValueInUsd( throw Error('Token not found' + JSON.stringify(coinInfo)) } -setTokenList(DEFAULT_TOKEN_LIST as TokenInfo[]) +setTokenList(DEFAULT_TOKEN_LIST as InternalTokenInfo[]) diff --git a/packages/sdk/src/move/ext/coin-list.ts b/packages/sdk/src/move/ext/coin-list.ts deleted file mode 100644 index 5c1de7ba96..0000000000 --- a/packages/sdk/src/move/ext/coin-list.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { BigDecimal } from '@sentio/bigdecimal' -import { SimpleCoinInfo } from './move-dex.js' - -export interface MoveCoinList { - whiteListed(type: string): boolean - whitelistCoins(): Map - getCoinInfo(type: string): SimpleCoinInfo - calculateValueInUsd( - amount: bigint, - coinInfo: SimpleCoinInfo, - timestamp: number, - network: Network - ): Promise -} diff --git a/packages/sdk/src/move/ext/coin.ts b/packages/sdk/src/move/ext/coin.ts new file mode 100644 index 0000000000..1c9d98bec3 --- /dev/null +++ b/packages/sdk/src/move/ext/coin.ts @@ -0,0 +1,17 @@ +import { BigDecimal } from '@sentio/bigdecimal' + +export interface BaseCoinInfo { + // token_type: { type: string; account_address: string } + type: string + symbol: string + hippo_symbol?: string + decimals: number + bridge: string +} + +export interface MoveCoinList { + whiteListed(type: string): boolean + whitelistCoins(): Map + getCoinInfo(type: string): Promise + calculateValueInUsd(amount: bigint, coinInfo: TokenType, timestamp: number, network: Network): Promise +} diff --git a/packages/sdk/src/move/ext/index.ts b/packages/sdk/src/move/ext/index.ts index b0e4354393..960eead797 100644 --- a/packages/sdk/src/move/ext/index.ts +++ b/packages/sdk/src/move/ext/index.ts @@ -1,2 +1,2 @@ -export * from './coin-list.js' +export * from './coin.js' export * from './move-dex.js' diff --git a/packages/sdk/src/move/ext/move-dex.ts b/packages/sdk/src/move/ext/move-dex.ts index 2fcbe9ed6d..1299c32502 100644 --- a/packages/sdk/src/move/ext/move-dex.ts +++ b/packages/sdk/src/move/ext/move-dex.ts @@ -2,15 +2,7 @@ import { DecodedStruct, TypeDescriptor } from '@typemove/move' import { BigDecimal } from '@sentio/bigdecimal' import { Gauge } from '../../core/index.js' import { MoveAccountContext, MoveContext } from '../move-context.js' -import { MoveCoinList } from './coin-list.js' - -export interface SimpleCoinInfo { - token_type: { type: string; account_address: string } - symbol: string - hippo_symbol?: string - decimals: number - bridge: string -} +import { MoveCoinList, BaseCoinInfo } from './coin.js' export interface MovePoolAdaptor { getXReserve(pool: T): bigint @@ -23,6 +15,7 @@ export interface MovePoolAdaptor { } export class MoveDex< + TokenType extends BaseCoinInfo, Network, ModuleType, StructType, @@ -31,7 +24,7 @@ export class MoveDex< AccountContextType extends MoveAccountContext, T > { - coinList: MoveCoinList + coinList: MoveCoinList poolAdaptor: MovePoolAdaptor volume: Gauge volumeByCoin: Gauge @@ -100,14 +93,14 @@ export class MoveDex< this.volumeByCoin.record(ctx, resultX, { coin: coinXInfo.symbol, bridge: coinXInfo.bridge, - type: coinXInfo.token_type.type + type: coinXInfo.type }) } if (resultY.gt(0)) { this.volumeByCoin.record(ctx, resultY, { coin: coinYInfo.symbol, bridge: coinYInfo.bridge, - type: coinYInfo.token_type.type + type: coinYInfo.type }) } result = resultX.plus(resultY).div(2) @@ -152,23 +145,23 @@ export class MoveDex< if (whitelistx) { resultX = await this.coinList.calculateValueInUsd(coinx_amount, coinXInfo, timestamp, ctx.network) - let coinXTotal = volumeByCoin.get(coinXInfo.token_type.type) + let coinXTotal = volumeByCoin.get(coinXInfo.type) if (!coinXTotal) { coinXTotal = resultX } else { coinXTotal = coinXTotal.plus(resultX) } - volumeByCoin.set(coinXInfo.token_type.type, coinXTotal) + volumeByCoin.set(coinXInfo.type, coinXTotal) } if (whitelisty) { resultY = await this.coinList.calculateValueInUsd(coiny_amount, coinYInfo, timestamp, ctx.network) - let coinYTotal = volumeByCoin.get(coinYInfo.token_type.type) + let coinYTotal = volumeByCoin.get(coinYInfo.type) if (!coinYTotal) { coinYTotal = resultY } else { coinYTotal = coinYTotal.plus(resultY) } - volumeByCoin.set(coinYInfo.token_type.type, coinYTotal) + volumeByCoin.set(coinYInfo.type, coinYTotal) } if (resultX.eq(0)) { @@ -202,7 +195,7 @@ export class MoveDex< this.tvlByCoin.record(ctx, v, { coin: coinInfo.symbol, bridge: coinInfo.bridge, - type: coinInfo.token_type.type + type: coinInfo.type }) } } @@ -218,8 +211,12 @@ export class MoveDex< } } -export async function moveGetPairValue>( - coinList: MoveCoinList, +export async function moveGetPairValue< + TokenType extends BaseCoinInfo, + Network, + ContextType extends MoveAccountContext +>( + coinList: MoveCoinList, ctx: ContextType, coinx: string, coiny: string, diff --git a/packages/sdk/src/sui/ext/coin.ts b/packages/sdk/src/sui/ext/coin.ts index 182c8d50c2..504946399b 100644 --- a/packages/sdk/src/sui/ext/coin.ts +++ b/packages/sdk/src/sui/ext/coin.ts @@ -1,4 +1,4 @@ -import { SimpleCoinInfo } from '../../move/ext/index.js' +import { BaseCoinInfo } from '../../move/ext/index.js' import fetch from 'node-fetch' import { accountTypeString, SPLITTER } from '../../move/index.js' import { getPriceByType } from '../../utils/index.js' @@ -7,7 +7,7 @@ import { SuiChainId } from '@sentio/chain' import { getClient, SuiNetwork } from '../network.js' import { CoinMetadata } from '@mysten/sui/client' -const WHITELISTED_COINS = new Map() +const WHITELISTED_COINS = new Map() export async function initCoinList() { let list = DEFAULT_LIST.coinlist @@ -48,10 +48,7 @@ function setCoinList(list: SuiCoinInfo[]) { bridge = 'Wormhole' } WHITELISTED_COINS.set(info.address, { - token_type: { - type: info.address, - account_address: info.address.split('::')[0] - }, + type: info.address, symbol: info.symbol, decimals: info.decimals, bridge @@ -69,13 +66,13 @@ export function whiteListed(coin: string): boolean { return WHITELISTED_COINS.has(normalized) } -export function getCoinInfo(type: string): SimpleCoinInfo { +export function getCoinInfo(type: string): BaseCoinInfo { const r = WHITELISTED_COINS.get(type) if (!r) { const parts = type.split('::') // TDDO retrive from network return { - token_type: { type: type, account_address: parts[0] }, + type, symbol: parts[2], decimals: 8, bridge: 'native' @@ -86,7 +83,7 @@ export function getCoinInfo(type: string): SimpleCoinInfo { const COIN_METADATA_CACHE = new Map>() -export async function getCoinInfoWithFallback(type: string, network?: SuiNetwork): Promise { +export async function getCoinInfoWithFallback(type: string, network?: SuiNetwork): Promise { const r = WHITELISTED_COINS.get(type) if (!r) { network = network || SuiChainId.SUI_MAINNET @@ -104,7 +101,7 @@ export async function getCoinInfoWithFallback(type: string, network?: SuiNetwork const parts = type.split(SPLITTER) return { - token_type: { type: type, account_address: parts[0] }, + type, symbol: meta.symbol, decimals: meta.decimals, bridge: 'native' @@ -126,8 +123,8 @@ export async function getPrice(coinType: string, timestamp: number): Promise = MovePoolAdaptor -export class CoinList implements MoveCoinList { - calculateValueInUsd(amount: bigint, coinInfo: SimpleCoinInfo, timestamp: number): Promise { +export class CoinList implements MoveCoinList { + calculateValueInUsd(amount: bigint, coinInfo: BaseCoinInfo, timestamp: number): Promise { return calculateValueInUsd(amount, coinInfo, timestamp) } - getCoinInfo(type: string): SimpleCoinInfo { + async getCoinInfo(type: string) { return getCoinInfo(type) } @@ -20,7 +20,7 @@ export class CoinList implements MoveCoinList { return whiteListed(type) } - whitelistCoins(): Map { + whitelistCoins(): Map { return whitelistCoins() } } @@ -28,6 +28,7 @@ export class CoinList implements MoveCoinList { export const SuiCoinList = new CoinList() export class SuiDex extends MoveDex< + BaseCoinInfo, SuiNetwork, SuiMoveNormalizedModule, SuiMoveObject,