@bolt-liquidity-hq/sui-client 0.1.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/client.ts","../src/config/mainnet.ts","../src/config/testnet.ts","../src/lib/oracle/get-asset-pairs.ts","../src/lib/constants/defaults.ts","../src/lib/constants/sui-objects.ts","../src/lib/helpers/bcs-parse.ts","../src/lib/helpers/queries.ts","../src/lib/oracle/parsers.ts","../src/types/bcs.ts","../src/types/oracle.ts","../src/types/router.ts","../src/types/pool.ts","../src/lib/oracle/get-assets.ts","../src/lib/oracle/get-oracle-config.ts","../src/lib/oracle/get-price.ts","../src/lib/oracle/get-prices.ts","../src/lib/router/get-all-base-liquidity.ts","../src/lib/router/parsers.ts","../src/lib/router/get-all-quotes-for-user.ts","../src/lib/router/get-pool-for-base.ts","../src/lib/router/get-pools.ts","../src/lib/router/get-router-config.ts","../src/lib/router/swap-exact-in.ts","../src/lib/settlement/get-pool-info.ts","../src/lib/settlement/parsers.ts","../src/tests/constants/sui-objects.ts","../src/lib/settlement/get-pool-info-for-base.ts"],"sourcesContent":["import type {\n Address,\n BaseLiquidityDetails,\n Coin,\n InvertiblePrice,\n OracleAssetPair,\n OracleConfig,\n PoolConfig,\n Pool,\n Price,\n RouterConfig,\n SwapParams,\n SwapResult,\n Contracts,\n AssetsConfig,\n Asset,\n} from '@bolt-liquidity-hq/core';\nimport { BaseClient } from '@bolt-liquidity-hq/core';\nimport { SuiClient, type SuiTransactionBlockResponse } from '@mysten/sui/client';\nimport type { Signer } from '@mysten/sui/cryptography';\n\nimport {\n MainnetAssets,\n MainnetChainConfig,\n MainnetContracts,\n MainnetPackageId,\n TestnetAssets,\n TestnetChainConfig,\n TestnetContracts,\n TestnetPackageId,\n} from '../config';\nimport {\n getAssets,\n getAssetPairs,\n getOracleConfig,\n getPrice as getOraclePrice,\n getPrices as getOraclePrices,\n} from './oracle';\nimport {\n getAllBaseLiquidity,\n getAllQuotesForUser,\n getPoolForBase,\n getPools,\n getRouterConfig,\n swapExactIn,\n} from './router';\nimport { getPoolInfo, getPoolInfoForBase } from './settlement';\nimport type { SuiChainConfig, SuiClientConfig } from '../types';\n\n/**\n * Client implementation for interacting with the Bolt Liquidity Outpost on Sui blockchain.\n *\n * This class extends the abstract {@link BaseClient} to provide Sui-specific functionality\n * for querying and executing transactions on Bolt Protocol's oracle and router smart contracts.\n * It uses SuiTransactionBlockResponse as the transaction output type, providing detailed transaction execution information.\n *\n * @extends {BaseClient<Signer, SuiTransactionBlockResponse>}\n *\n * @group Bolt API Clients\n *\n * @example\n * ```typescript\n * // Create a client for Sui mainnet\n * const client = new BoltSuiClient();\n *\n * // Query oracle prices\n * const price = await client.getPrice(\"0x2::sui::SUI\", \"0xusdcAddress...\");\n *\n * // Execute a swap (requires signer)\n * const signer = // ... get signer from wallet\n * const result = await client.swap(signer, {\n * assetIn: \"0x2::sui::SUI\",\n * amountIn: \"1000000000\", // 1 SUI (9 decimals)\n * assetOut: \"0xusdcAddress...\"\n * });\n * ```\n */\nexport class BoltSuiClient extends BaseClient<Signer, SuiTransactionBlockResponse> {\n /**\n * The Sui-specific chain configuration including RPC endpoint\n */\n public override chainConfig: SuiChainConfig;\n\n /**\n * Package Id for the deployed Bolt contracts on Sui\n */\n public packageId: string;\n\n /**\n * Instance of the Sui client to interact with the blockchain\n */\n public suiClient: SuiClient;\n\n /**\n * Creates a new instance of the BoltSuiClient.\n *\n * The client automatically configures itself based on the specified chain and environment,\n * loading the appropriate contract addresses, chain configuration, and assets from configuration files.\n *\n * @param config - (Optional) Configuration for the client\n * @param config.environment - (Optional) The deployment environment ('mainnet' or 'testnet'). Defaults to 'mainnet'\n * @param config.customOverride - (Optional) Custom overrides for chain configuration, contracts, and assets\n * @param config.customOverride.chainConfig - (Optional) Override chain configuration\n * @param config.customOverride.chainConfig.id - (Optional) Custom chain ID\n * @param config.customOverride.chainConfig.name - (Optional) Custom chain name\n * @param config.customOverride.chainConfig.rpcEndpoint - (Optional) Custom RPC endpoint URL\n * @param config.customOverride.packageId - (Optional) Custom package ID for Bolt contracts\n * @param config.customOverride.contracts - (Optional) Override contract addresses\n * @param config.customOverride.contracts.oracle - (Optional) Custom oracle contract address\n * @param config.customOverride.contracts.router - (Optional) Custom router contract address\n * @param config.customOverride.assetsConfig - (Optional) Custom asset configurations indexed by denom\n * @param config.suiClient - (Optional) Pre-existing SuiClient to use for blockchain queries\n *\n * @throws {InvalidObjectError} Thrown when required configuration fields are missing\n *\n * @example\n * ```typescript\n * // Use default configuration (Sui mainnet)\n * const client = new BoltSuiClient();\n *\n * // Use testnet configuration\n * const testnetClient = new BoltSuiClient({\n * environment: 'testnet'\n * });\n *\n * // Use custom chain configuration\n * const customClient = new BoltSuiClient({\n * customOverride: {\n * chainConfig: {\n * id: 'sui-custom',\n * name: 'Sui Custom',\n * rpcEndpoint: 'https://custom-rpc.example.com'\n * },\n * packageId: '0xcustom_package_id...',\n * contracts: {\n * oracle: '0xcustom_oracle...',\n * router: '0xcustom_router...'\n * },\n * assetsConfig: {\n * '0x2::sui::SUI': {\n * symbol: 'SUI',\n * name: 'Sui',\n * chainId: 'sui-custom',\n * denom: '0x2::sui::SUI',\n * decimals: 9,\n * logo: 'https://example.com/sui.png',\n * coingeckoId: 'sui'\n * }\n * }\n * }\n * });\n *\n * // Use pre-existing Sui client\n * const clientWithCustomClient = new BoltSuiClient({\n * suiClient: mySuiClient\n * });\n * ```\n */\n constructor(config?: SuiClientConfig) {\n const { environment = 'mainnet', customOverride, suiClient } = config ?? {};\n\n const defaultChainConfig: SuiChainConfig =\n environment === 'mainnet' ? MainnetChainConfig : TestnetChainConfig;\n const defaultContracts: Contracts =\n environment === 'mainnet' ? MainnetContracts : TestnetContracts;\n const defaultPackageId = environment === 'mainnet' ? MainnetPackageId : TestnetPackageId;\n const assetsConfig: AssetsConfig = environment === 'mainnet' ? MainnetAssets : TestnetAssets;\n\n // Apply overrides\n const chainConfig: SuiChainConfig = {\n id: customOverride?.chainConfig?.id ?? defaultChainConfig.id,\n name: customOverride?.chainConfig?.name ?? defaultChainConfig.name,\n rpcEndpoint: customOverride?.chainConfig?.rpcEndpoint ?? defaultChainConfig.rpcEndpoint,\n };\n const packageId = customOverride?.packageId ?? defaultPackageId;\n const contracts: Contracts = {\n oracle: customOverride?.contracts?.oracle ?? defaultContracts.oracle,\n router: customOverride?.contracts?.router ?? defaultContracts.router,\n };\n\n for (const item of Object.values(customOverride?.assetsConfig ?? {})) {\n assetsConfig[item.denom] = item;\n }\n\n super({\n customOverride: {\n chainConfig,\n contracts,\n assetsConfig,\n },\n });\n\n this.chainConfig = chainConfig;\n this.packageId = packageId;\n this.suiClient = suiClient ?? new SuiClient({ url: chainConfig.rpcEndpoint });\n }\n\n // The following methods inherit their documentation from BaseClient\n // Only add documentation here if you need to override or add implementation-specific details\n\n /** @inheritdoc */\n public async getOracleConfig(): Promise<OracleConfig> {\n return await getOracleConfig(this);\n }\n\n /** @inheritdoc */\n async getAllOracleAssetPairs(): Promise<OracleAssetPair[]> {\n return await getAssetPairs(this);\n }\n\n /** @inheritdoc */\n async getPrice(baseDenom: string, quoteDenom: string): Promise<InvertiblePrice> {\n return await getOraclePrice(this, baseDenom, quoteDenom);\n }\n\n /** @inheritdoc */\n async getAllPrices(): Promise<Price[]> {\n return await getOraclePrices(this);\n }\n\n /** @inheritdoc */\n async getRouterConfig(): Promise<RouterConfig> {\n return await getRouterConfig(this);\n }\n\n /** @inheritdoc */\n async getAllBaseAssetsLiquidity(): Promise<Record<Address, BaseLiquidityDetails>> {\n return await getAllBaseLiquidity(this);\n }\n\n /** @inheritdoc */\n async getAllQuotesByUser(address: Address): Promise<Record<Address, Coin[]>> {\n return await getAllQuotesForUser(this, address);\n }\n\n /** @inheritdoc */\n async getPoolByBaseAsset(baseDenom: string): Promise<Pool> {\n return await getPoolForBase(this, baseDenom);\n }\n\n /** @inheritdoc */\n async getAllPools(): Promise<Pool[]> {\n return await getPools(this);\n }\n\n // Satisfy the base class requirement\n async getPoolConfig(poolContractAddress: string): Promise<PoolConfig> {\n return await getPoolInfo(this, poolContractAddress);\n }\n\n /** @inheritdoc */\n async getAssets(): Promise<Asset[]> {\n return await getAssets(this);\n }\n\n /** @inheritdoc */\n async getPoolConfigByBaseAsset(baseDenom: string): Promise<PoolConfig> {\n return await getPoolInfoForBase(this, baseDenom);\n }\n\n /**\n * @inheritdoc\n *\n * @example\n * ```typescript\n * // Get signer from wallet (e.g., Sui Wallet, Suiet, etc.)\n * const signer = // ... obtain signer from wallet\n *\n * // Execute swap: 1 SUI for USDC\n * const result = await client.swap(signer, {\n * assetIn: \"0x2::sui::SUI\",\n * amountIn: \"1000000000\", // 1 SUI (9 decimals)\n * assetOut: \"0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN\", // USDC address\n * minimumAmountOut: \"1950000\", // Minimum 1.95 USDC expected (6 decimals)\n * receiver: \"0x...\" // Optional custom receiver address\n * });\n *\n * console.log(`Swap successful!`);\n * console.log(`Transaction digest: ${result.txHash}`);\n * console.log(`Received: ${result.amountOut} ${result.assetOut}`);\n * console.log(`Gas cost: ${result.txOutput.effects.gasUsed.computationCost}`);\n * console.log(`Status: ${result.txOutput.effects.status.status}`);\n * ```\n *\n * @remarks\n * This implementation returns a SuiTransactionBlockResponse as the transaction output,\n * which includes details like gas costs, transaction effects, object changes, and events.\n */\n async swap(signer: Signer, params: SwapParams): Promise<SwapResult<SuiTransactionBlockResponse>> {\n return await swapExactIn(this, signer, params);\n }\n}\n","import type { AssetsConfig, Contracts } from '@bolt-liquidity-hq/core';\nimport type { SuiChainConfig } from '../types';\n\nexport const MainnetChainConfig: SuiChainConfig = {\n name: 'Sui',\n id: '101',\n rpcEndpoint: 'https://fullnode.mainnet.sui.io:443',\n};\n\nexport const MainnetContracts: Contracts = {\n oracle: '0x...',\n router: '0x...',\n};\n\nexport const MainnetPackageId: string = '0x...';\n\nexport const MainnetAssets: AssetsConfig = {\n '0x2::sui::SUI': {\n symbol: 'SUI',\n name: 'Sui',\n chainId: '101',\n denom: '0x2::sui::SUI',\n decimals: 9,\n logo: 'https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/sui/info/logo.png',\n coingeckoId: 'sui',\n },\n '0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC': {\n symbol: 'USDC',\n name: 'Circle USDC',\n chainId: '101',\n denom: '0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC',\n decimals: 6,\n logo: 'https://raw.githubusercontent.com/cosmos/chain-registry/master/noble/images/USDCoin.png',\n coingeckoId: 'usd-coin',\n },\n};\n","import type { AssetsConfig, Contracts } from '@bolt-liquidity-hq/core';\n\nimport type { SuiChainConfig } from '../types';\n\nexport const TestnetChainConfig: SuiChainConfig = {\n name: 'Sui Testnet',\n id: '103',\n rpcEndpoint: 'https://fullnode.testnet.sui.io:443',\n};\n\nexport const TestnetContracts: Contracts = {\n oracle: '0xecece01cfb23b5439e04b18fe656eaf2746b9087cf68f1d48797c8f71a3dd93b',\n router: '0x3881fdcb4a7fbcda8edc230e6f92eb57b24c0be6b44af0b5e1d0b45564f3ed00',\n};\n\nexport const TestnetPackageId: string =\n '0x22384b1841229e2be878bb7e88833c03e23ff5dc39accd050fb932120602f85e';\n\nexport const TestnetAssets: AssetsConfig = {\n '0x2::sui::SUI': {\n symbol: 'SUI',\n name: 'Sui',\n chainId: '103',\n denom: '0x2::sui::SUI',\n decimals: 9,\n logo: 'https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/sui/info/logo.png',\n coingeckoId: 'sui',\n },\n '0xa1ec7fc00a6f40db9693ad1415d0c193ad3906494428cf252621037bd7117e29::usdc::USDC': {\n symbol: 'USDC',\n name: 'Circle USDC',\n chainId: '103',\n denom: '0xa1ec7fc00a6f40db9693ad1415d0c193ad3906494428cf252621037bd7117e29::usdc::USDC',\n decimals: 6,\n logo: 'https://raw.githubusercontent.com/cosmos/chain-registry/master/noble/images/USDCoin.png',\n coingeckoId: 'usd-coin',\n },\n};\n","import type { OracleAssetPair } from '@bolt-liquidity-hq/core';\nimport { bcs } from '@mysten/bcs';\n\nimport type { BoltSuiClient } from '../client';\nimport { DEFAULT_PAGINATION_LIMIT, PRICE_ORACLE_MODULE } from '../constants';\nimport { parseDevInspectResult, queryDevInspect } from '../helpers';\nimport { parseAssetPairsResponsePaginatedStructOutput } from './parsers';\nimport { AssetPairsResponsePaginatedStruct } from '../../types';\n\n/**\n * Queries the oracle smart contract to retrieve all supported asset pairs with automatic pagination handling.\n *\n * This function fetches the complete list of trading pairs that the oracle contract\n * supports for price feeds. Each asset pair represents a base/quote relationship\n * that can be used for price queries and swaps within the Bolt protocol. The function\n * automatically handles pagination to ensure all pairs are retrieved, regardless of\n * the total number.\n *\n * @param client - The BoltSuiClient instance.\n *\n * @returns A promise that resolves to an array of OracleAssetPair objects, each containing:\n * - base: Information about the base asset\n * - name: The full name of the base asset (currently same as symbol)\n * - symbol: The trading symbol (e.g., \"SUI\", \"ETH\")\n * - precision: The number of decimal places for the base asset\n * - quote: Information about the quote asset\n * - name: The full name of the quote asset (currently same as symbol)\n * - symbol: The trading symbol (e.g., \"USDC\", \"USDT\")\n * - precision: The number of decimal places for the quote asset\n *\n * @throws {TransactionFailedError} When the oracle contract query fails, which could happen if:\n * - The oracle contract is not properly initialized\n * - The contract address is incorrect\n * - Network connection issues occur\n * @throws {ParseError} When the response cannot be parsed, indicating:\n * - The contract returned data in an unexpected format\n * - The BCS deserialization failed\n * - The contract ABI has changed\n */\nexport const getAssetPairs = async (client: BoltSuiClient): Promise<OracleAssetPair[]> => {\n /**\n * The Move function name in the oracle module that returns paginated asset pairs.\n * This function signature in Move:\n * public fun asset_pairs_paginated(\n * oracle: &Oracle,\n * limit: Option<u64>,\n * cursor: Option<String>\n * ): AssetPairsResponsePaginated\n */\n const ASSET_PAIRS_PAGINATED_FUNCTION = 'asset_pairs_paginated';\n\n const result: OracleAssetPair[] = [];\n\n let currentCursor = null;\n\n let hasNextPage = true;\n\n while (hasNextPage) {\n const response = await queryDevInspect(\n client.suiClient,\n [client.packageId, PRICE_ORACLE_MODULE, ASSET_PAIRS_PAGINATED_FUNCTION],\n [\n client.contracts.oracle,\n bcs.option(bcs.u64()).serialize(DEFAULT_PAGINATION_LIMIT),\n bcs.option(bcs.string()).serialize(currentCursor),\n ]\n );\n\n const output = parseDevInspectResult(response, AssetPairsResponsePaginatedStruct);\n\n const assetPairs = parseAssetPairsResponsePaginatedStructOutput(output);\n\n result.push(...assetPairs);\n\n currentCursor = output.next_cursor;\n hasNextPage = output.has_next_page;\n }\n\n return result;\n};\n","export const DEFAULT_PAGINATION_LIMIT = 50;\n","export const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000000000000000000000000000';\n\nexport const SUI_SYSTEM_CLOCK = '0x6';\n\nexport const PRICE_ORACLE_MODULE = 'price_oracle';\n\nexport const ROUTER_MODULE = 'router';\n\nexport const POOL_MODULE = 'settlement';\n","import { InvalidObjectError, ParseError } from '@bolt-liquidity-hq/core';\nimport type { BcsType } from '@mysten/bcs';\nimport { bcs } from '@mysten/bcs';\nimport type { DevInspectResults } from '@mysten/sui/client';\n\nimport type { BcsParsed } from '../../types';\n\n/**\n * Extracts raw bytes from a DevInspectResults object at the specified indices.\n *\n * This utility function navigates the nested structure of Sui's DevInspectResults\n * to extract the raw byte array from a specific return value.\n *\n * @param result - The DevInspectResults object returned from a Sui devInspect call\n * @param resultIndex - The index of the result to extract from (defaults to 0)\n * @param returnValueIndex - The index of the return value within the result (defaults to 0)\n *\n * @returns The extracted bytes as a Uint8Array, or null if the specified indices don't exist\n *\n * @example\n * ```typescript\n * const result = await suiClient.devInspectTransactionBlock({...});\n * const bytes = extractBytes(result, 0, 0);\n * if (bytes) {\n * const parsedValue = bcs.u64().parse(bytes);\n * }\n * ```\n */\nexport const extractBytes = (\n result: DevInspectResults,\n resultIndex: number = 0,\n returnValueIndex: number = 0\n): Uint8Array | null => {\n const returnValues = result.results?.[resultIndex]?.returnValues;\n if (!returnValues || !returnValues[returnValueIndex]) {\n return null;\n }\n\n const [bytes] = returnValues[returnValueIndex];\n return new Uint8Array(bytes);\n};\n\n/**\n * A utility class providing static methods for parsing common BCS (Binary Canonical Serialization) types.\n *\n * BCS is the serialization format used by Sui for encoding Move types. This class\n * provides convenient wrappers around the @mysten/bcs library's parsing functions\n * for commonly used primitive and composite types.\n *\n * @example\n * ```typescript\n * // Parse a u64 value\n * const bytes = new Uint8Array([1, 0, 0, 0, 0, 0, 0, 0]);\n * const value = BcsCommonParser.parseU64(bytes); // \"1\"\n *\n * // Parse a vector of strings\n * const vectorBytes = // ... bytes from Sui\n * const strings = BcsCommonParser.parseVector(vectorBytes, bcs.string());\n *\n * // Parse an optional value\n * const optionBytes = // ... bytes from Sui\n * const maybeValue = BcsCommonParser.parseOption(optionBytes, bcs.u32());\n * ```\n */\nexport class BcsCommonParser {\n /**\n * Parses a BCS-encoded unsigned 8-bit integer.\n *\n * @param bytes - The BCS-encoded bytes to parse\n * @returns The parsed u8 value as a number (0-255)\n */\n static parseU8(bytes: Uint8Array): number {\n return bcs.u8().parse(bytes);\n }\n\n /**\n * Parses a BCS-encoded unsigned 16-bit integer.\n *\n * @param bytes - The BCS-encoded bytes to parse\n * @returns The parsed u16 value as a number (0-65535)\n */\n static parseU16(bytes: Uint8Array): number {\n return bcs.u16().parse(bytes);\n }\n\n /**\n * Parses a BCS-encoded unsigned 32-bit integer.\n *\n * @param bytes - The BCS-encoded bytes to parse\n * @returns The parsed u32 value as a number (0-4294967295)\n */\n static parseU32(bytes: Uint8Array): number {\n return bcs.u32().parse(bytes);\n }\n\n /**\n * Parses a BCS-encoded unsigned 64-bit integer.\n *\n * @param bytes - The BCS-encoded bytes to parse\n * @returns The parsed u64 value as a string (to preserve precision)\n *\n * @remarks\n * Returns a string because JavaScript numbers cannot safely represent\n * all 64-bit integer values without loss of precision.\n */\n static parseU64(bytes: Uint8Array): string {\n return bcs.u64().parse(bytes);\n }\n\n /**\n * Parses a BCS-encoded unsigned 128-bit integer.\n *\n * @param bytes - The BCS-encoded bytes to parse\n * @returns The parsed u128 value as a string\n */\n static parseU128(bytes: Uint8Array): string {\n return bcs.u128().parse(bytes);\n }\n\n /**\n * Parses a BCS-encoded unsigned 256-bit integer.\n *\n * @param bytes - The BCS-encoded bytes to parse\n * @returns The parsed u256 value as a string\n */\n static parseU256(bytes: Uint8Array): string {\n return bcs.u256().parse(bytes);\n }\n\n /**\n * Parses a BCS-encoded boolean value.\n *\n * @param bytes - The BCS-encoded bytes to parse\n * @returns The parsed boolean value\n */\n static parseBool(bytes: Uint8Array): boolean {\n return bcs.bool().parse(bytes);\n }\n\n /**\n * Parses a BCS-encoded string.\n *\n * @param bytes - The BCS-encoded bytes to parse\n * @returns The parsed string value\n */\n static parseString(bytes: Uint8Array): string {\n return bcs.string().parse(bytes);\n }\n\n /**\n * Parses a BCS-encoded vector (dynamic array) of elements.\n *\n * @template T - The type of elements in the vector\n * @param bytes - The BCS-encoded bytes to parse\n * @param elementParser - The BCS parser for individual vector elements\n * @returns An array of parsed elements\n *\n * @example\n * ```typescript\n * // Parse a vector of u64 values\n * const numbers = BcsCommonParser.parseVector(bytes, bcs.u64());\n *\n * // Parse a vector of custom structs\n * const customType = bcs.struct('MyStruct', {\n * id: bcs.u64(),\n * name: bcs.string()\n * });\n * const structs = BcsCommonParser.parseVector(bytes, customType);\n * ```\n */\n static parseVector<T>(bytes: Uint8Array, elementParser: BcsType<T>): T[] {\n return bcs.vector(elementParser).parse(bytes);\n }\n\n /**\n * Parses a BCS-encoded Option type (similar to Rust's Option or Move's Option).\n *\n * @template T - The type of the optional value\n * @param bytes - The BCS-encoded bytes to parse\n * @param elementParser - The BCS parser for the optional value if present\n * @returns The parsed value if Some, or null if None\n *\n * @example\n * ```typescript\n * // Parse an optional address\n * const maybeAddress = BcsCommonParser.parseOption(bytes, bcs.string());\n * if (maybeAddress) {\n * console.log(`Address: ${maybeAddress}`);\n * } else {\n * console.log('No address provided');\n * }\n * ```\n */\n static parseOption<T>(bytes: Uint8Array, elementParser: BcsType<T>): T | null {\n return bcs.option(elementParser).parse(bytes);\n }\n}\n\n/**\n * Parses a single return value from a DevInspectResults object using a specified BCS parser.\n *\n * This function combines byte extraction and BCS parsing into a single operation,\n * handling errors appropriately and providing detailed error context.\n *\n * @template T - The expected TypeScript type after parsing\n * @template Input - The input type for the BCS parser (usually the same as T)\n *\n * @param result - The DevInspectResults object from a Sui devInspect call\n * @param bcsType - The BCS parser to use for deserializing the bytes\n * @param resultIndex - The index of the result to parse (defaults to 0)\n * @param returnValueIndex - The index of the return value within the result (defaults to 0)\n *\n * @returns The parsed value of type T\n *\n * @throws {InvalidObjectError} When no bytes are found at the specified indices\n * @throws {ParseError} When BCS parsing fails due to malformed data\n *\n * @example\n * ```typescript\n * // Parse a u64 return value\n * const result = await suiClient.devInspectTransactionBlock({...});\n * const balance = parseDevInspectResult(result, bcs.u64());\n *\n * // Parse a custom struct\n * const PriceInfo = bcs.struct('PriceInfo', {\n * price: bcs.u64(),\n * timestamp: bcs.u64(),\n * });\n * const priceInfo = parseDevInspectResult(result, PriceInfo);\n *\n * // Parse from a specific return value\n * const secondReturnValue = parseDevInspectResult(result, bcs.string(), 0, 1);\n * ```\n */\nexport const parseDevInspectResult = <T, Input>(\n result: DevInspectResults,\n bcsType: BcsType<T, Input>,\n resultIndex: number = 0,\n returnValueIndex: number = 0\n): T => {\n const bytes = extractBytes(result, resultIndex, returnValueIndex);\n if (!bytes) {\n throw new InvalidObjectError('When trying to parse result, no bytes found', {\n bcsType,\n resultIndex,\n returnValueIndex,\n });\n }\n\n try {\n return bcsType.parse(bytes);\n } catch (error) {\n throw new ParseError('DevInspectResult', 'from bcs to a typescript type', {\n error,\n result,\n bcsType,\n resultIndex,\n returnValueIndex,\n });\n }\n};\n\n/**\n * Parses multiple return values from a DevInspectResults object using an array of BCS parsers.\n *\n * This function is useful when a Move function returns multiple values that need to be\n * parsed with different BCS types. It applies each parser in the schema array to the\n * corresponding return value index.\n *\n * @template T - A tuple type representing the array of BCS parsers\n *\n * @param info - The DevInspectResults object from a Sui devInspect call\n * @param schema - An array of BCS parsers, one for each expected return value\n *\n * @returns A tuple containing the parsed values, with types matching the schema\n *\n * @example\n * ```typescript\n * // Parse multiple return values of different types\n * const result = await suiClient.devInspectTransactionBlock({...});\n * const [balance, isActive, userName] = parseMultipleResults(\n * result,\n * [bcs.u64(), bcs.bool(), bcs.string()] as const\n * );\n *\n * // Parse multiple complex types\n * const TokenInfo = bcs.struct('TokenInfo', {\n * symbol: bcs.string(),\n * decimals: bcs.u8(),\n * });\n * const [tokenA, tokenB, liquidityAmount] = parseMultipleResults(\n * result,\n * [TokenInfo, TokenInfo, bcs.u128()] as const\n * );\n * ```\n *\n * @remarks\n * - The function assumes all return values are from the first result (index 0)\n * - Each parser in the schema array corresponds to a return value at the same index\n * - Type safety is preserved through TypeScript's tuple types\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const parseMultipleResults = <T extends readonly BcsType<any>[]>(\n info: DevInspectResults,\n schema: T\n): { [K in keyof T]: BcsParsed<T[K]> } => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return schema.map((bcsType, index) => parseDevInspectResult(info, bcsType, 0, index)) as {\n [K in keyof T]: BcsParsed<T[K]>;\n };\n};\n","import { type Address, TransactionFailedError, UnexpectedError } from '@bolt-liquidity-hq/core';\nimport type { SerializedBcs } from '@mysten/bcs';\nimport type { DevInspectResults, SuiClient } from '@mysten/sui/client';\nimport { Transaction } from '@mysten/sui/transactions';\n\nimport { ZERO_ADDRESS } from '../constants';\n\n/**\n * Executes a read-only query against a Sui Move function using devInspect.\n *\n * This function allows you to call Move functions without committing a transaction\n * to the blockchain. It's perfect for querying contract state, simulating transactions,\n * or getting computed values from view functions. The devInspect feature runs the\n * transaction in a sandboxed environment and returns the results without any state changes.\n *\n * @param suiClient - The SuiClient instance used to interact with the Sui network\n * @param target - The Move function to call, either as:\n * - A string in the format \"packageId::module::function\"\n * - A tuple of [packageId, module, function]\n * @param args - Optional array of arguments to pass to the Move function. Each argument can be:\n * - A string representing an object ID (will be passed as an object reference)\n * - A SerializedBcs object containing pre-serialized BCS data (will be passed as a pure value)\n * @param typeArguments - Optional array of type arguments for generic Move functions\n * @param senderAddress - Optional sender address for the simulated transaction.\n * Defaults to ZERO_ADDRESS if not provided. Some functions may require a specific\n * sender to check permissions or balances.\n *\n * @returns A promise that resolves to DevInspectResults containing:\n * - effects: Transaction effects showing gas costs and object changes\n * - events: Events that would be emitted by the transaction\n * - results: Array of results with return values from the Move function\n * - error: Any execution errors (if status is not 'success')\n *\n * @throws {TransactionFailedError} When the Move function execution fails\n * @throws {UnexpectedError} When there's a network error or other unexpected failure\n *\n * @example\n * ```typescript\n * // Query a simple getter function\n * const result = await queryDevInspect(\n * suiClient,\n * `${packageId}::oracle::get_price`,\n * [baseAssetId, quoteAssetId]\n * );\n *\n * // Query with type arguments\n * const balanceResult = await queryDevInspect(\n * suiClient,\n * [packageId, \"pool\", \"get_balance\"],\n * [poolObjectId],\n * [\"0x2::sui::SUI\"] // Type argument for the coin type\n * );\n *\n * // Query with serialized BCS arguments\n * const amountBcs = bcs.u64().serialize(1000000).toBytes();\n * const swapResult = await queryDevInspect(\n * suiClient,\n * `${packageId}::router::get_amount_out`,\n * [amountBcs, poolObjectId],\n * undefined,\n * userAddress // Use actual user address for more specific simulation\n * );\n *\n * // Parse the results\n * if (result.effects.status.status === 'success') {\n * const returnValue = result.results?.[0]?.returnValues?.[0];\n * if (returnValue) {\n * const price = bcs.u64().parse(new Uint8Array(returnValue[0]));\n * }\n * }\n * ```\n *\n * @remarks\n * - devInspect is read-only and cannot modify blockchain state\n * - Gas is still calculated but not charged\n * - Object modifications are simulated but not persisted\n * - Some functions may behave differently in devInspect vs actual execution\n * - The ZERO_ADDRESS default sender may not work for functions that check ownership\n */\nexport const queryDevInspect = async (\n suiClient: SuiClient,\n target: string | [string, string, string],\n args?: (SerializedBcs<unknown> | string)[],\n typeArguments?: string[],\n senderAddress?: Address\n): Promise<DevInspectResults> => {\n const tx = new Transaction();\n\n const targetString = Array.isArray(target) ? `${target[0]}::${target[1]}::${target[2]}` : target;\n\n const txArgs = args?.map((item) =>\n typeof item === 'string' ? tx.object(item) : tx.pure(item.toBytes())\n );\n\n tx.moveCall({\n target: targetString,\n arguments: txArgs,\n typeArguments,\n });\n\n try {\n // Use devInspectTransactionBlock to execute without submitting to chain\n const result = await suiClient.devInspectTransactionBlock({\n transactionBlock: tx,\n sender: senderAddress ?? ZERO_ADDRESS,\n });\n\n // Process the results\n if (result.effects.status.status === 'success') {\n return result;\n } else {\n throw new TransactionFailedError('N/A', 'Failed to query smart contract', { result });\n }\n } catch (error) {\n throw UnexpectedError.from(error, 'Failed to query smart contract', {\n target: targetString,\n args,\n typeArguments,\n });\n }\n};\n","import type {\n InvertiblePrice,\n OracleConfig,\n OracleAssetPair,\n Price,\n} from '@bolt-liquidity-hq/core';\nimport { InvalidObjectError } from '@bolt-liquidity-hq/core';\nimport { BigNumber } from 'bignumber.js';\n\nimport type {\n AssetPairsResponsePaginatedStructOutput,\n AssetPairsResponseStructOutput,\n AssetPairStructOutput,\n OracleConfigStructOutput,\n PriceDataStructOutput,\n PriceResponseStructOutput,\n PricesResponsePaginatedStructOutput,\n} from '../../types';\n\n/**\n * Parses a raw oracle configuration response from the Sui blockchain into a structured OracleConfig object.\n *\n * This function transforms the snake_case properties from the Sui Move contract response\n * into camelCase properties following TypeScript conventions. It also converts the\n * price expiry time from seconds to a structured format with seconds and nanoseconds.\n *\n * @param output - The raw oracle configuration response from the contract query\n * @param output.admin - The admin address that can update oracle prices\n * @param output.price_threshold_ratio - The maximum allowed price deviation ratio\n * @param output.default_price_expiry_seconds - The default time in seconds before prices expire\n *\n * @returns A parsed OracleConfig object with:\n * - admin: The admin address of the oracle contract\n * - priceThresholdRatio: The threshold ratio for price updates (e.g., \"0.01\" for 1%)\n * - priceExpireTime: Object with seconds and nanoseconds representing expiry duration\n *\n * @example\n * ```typescript\n * const rawResponse = {\n * admin: \"0x1234...\",\n * price_threshold_ratio: \"0.01\",\n * default_price_expiry_seconds: \"3600\" // 1 hour\n * };\n *\n * const config = parseOracleConfigStructOutput(rawResponse);\n * console.log(config.admin); // \"0x1234...\"\n * console.log(config.priceThresholdRatio); // \"0.01\"\n * console.log(config.priceExpireTime.secs); // 3600\n * ```\n */\nexport const parseOracleConfigStructOutput = (output: OracleConfigStructOutput): OracleConfig => {\n return {\n admin: output.admin,\n priceThresholdRatio: output.price_threshold_ratio,\n priceExpireTime: {\n secs: Number(output.default_price_expiry_seconds),\n nanos: 0,\n },\n };\n};\n\n/**\n * Parses a single asset pair structure from the Sui oracle contract into an OracleAssetPair object.\n *\n * This function converts the raw asset pair data containing base and quote asset information\n * into a structured format. Note that the name field is currently set to the same value\n * as the symbol field in the Sui implementation.\n *\n * @param output - The raw asset pair data from the contract\n * @param output.base_symbol - The symbol of the base asset (e.g., \"SUI\", \"USDC\")\n * @param output.base_precision - The decimal precision of the base asset (e.g., 9 for SUI)\n * @param output.quote_symbol - The symbol of the quote asset\n * @param output.quote_precision - The decimal precision of the quote asset\n *\n * @returns An OracleAssetPair object containing:\n * - base: Object with name, symbol, and precision for the base asset\n * - quote: Object with name, symbol, and precision for the quote asset\n *\n * @example\n * ```typescript\n * const rawPair = {\n * base_symbol: \"SUI\",\n * base_precision: 9,\n * quote_symbol: \"USDC\",\n * quote_precision: 6\n * };\n *\n * const pair = parseAssetPairStructOutput(rawPair);\n * console.log(pair.base.symbol); // \"SUI\"\n * console.log(pair.base.precision); // 9\n * console.log(pair.quote.symbol); // \"USDC\"\n * ```\n */\nexport const parseAssetPairStructOutput = (output: AssetPairStructOutput): OracleAssetPair => {\n return {\n base: {\n name: output.base_symbol,\n symbol: output.base_symbol,\n precision: output.base_precision,\n },\n quote: {\n name: output.quote_symbol,\n symbol: output.quote_symbol,\n precision: output.quote_precision,\n },\n };\n};\n\n/**\n * Parses a response containing multiple asset pairs from the oracle contract.\n *\n * This function processes an array of asset pairs returned by the oracle's\n * get_asset_pairs query, converting each raw pair into the standardized format.\n *\n * @param output - The response object containing an array of asset pairs\n * @param output.asset_pairs - Array of raw asset pair data\n *\n * @returns An array of parsed OracleAssetPair objects\n *\n * @example\n * ```typescript\n * const response = {\n * asset_pairs: [\n * { base_symbol: \"SUI\", base_precision: 9, quote_symbol: \"USDC\", quote_precision: 6 },\n * { base_symbol: \"ETH\", base_precision: 18, quote_symbol: \"USDC\", quote_precision: 6 }\n * ]\n * };\n *\n * const pairs = parseAssetPairsResponseStructOutput(response);\n * console.log(pairs.length); // 2\n * console.log(pairs[0].base.symbol); // \"SUI\"\n * ```\n */\nexport const parseAssetPairsResponseStructOutput = (\n output: AssetPairsResponseStructOutput\n): OracleAssetPair[] => {\n return output.asset_pairs.map((item) => parseAssetPairStructOutput(item));\n};\n\n/**\n * Parses raw price data from the oracle contract into an InvertiblePrice object.\n *\n * This function converts the price information including the price value and expiry time.\n * The expiry time is converted from milliseconds to nanoseconds for consistency with\n * the broader system's time representation.\n *\n * @param response - The raw price data from the contract\n * @param response.price - The price value as a string (to maintain precision)\n * @param response.expiry_time_ms - The price expiry time in milliseconds since Unix epoch\n * @param baseDenom - The denomination of the base asset (e.g., \"0x2::sui::SUI\")\n * @param quoteDenom - The denomination of the quote asset (e.g., \"0xusdcAddress...\")\n *\n * @returns An InvertiblePrice object containing:\n * - assetPair: String representation of the pair in format \"baseDenom:quoteDenom\"\n * - price: The price value as a string\n * - expiryTime: The expiry time in nanoseconds as a string\n * - isInverse: Always false (price is not inverted)\n *\n * @example\n * ```typescript\n * const priceData = {\n * price: \"2.5\",\n * expiry_time_ms: \"1700000000000\" // milliseconds\n * };\n *\n * const price = parsePriceDataStructOutput(\n * priceData,\n * \"0x2::sui::SUI\",\n * \"0xusdcAddress...\"\n * );\n * console.log(price.price); // \"2.5\"\n * console.log(price.assetPair); // \"0x2::sui::SUI:0xusdcAddress...\"\n * console.log(price.expiryTime); // \"1700000000000000000\" (nanoseconds)\n * ```\n */\nexport const parsePriceDataStructOutput = (\n response: PriceDataStructOutput,\n baseDenom: string,\n quoteDenom: string\n): InvertiblePrice => {\n return {\n assetPair: `${baseDenom}:${quoteDenom}`,\n price: response.price,\n expiryTime: BigNumber(response.expiry_time_ms).times(1_000_000).toFixed(),\n isInverse: false,\n };\n};\n\n/**\n * Parses a price response from the oracle contract, extracting the price data if available.\n *\n * This function handles the response from price queries which may or may not contain\n * valid price data. It checks for the presence of pair_data and throws an error\n * if the price is not available.\n *\n * @param response - The price response from the oracle contract\n * @param response.pair_data - Optional price data for the requested pair\n * @param baseDenom - The denomination of the base asset\n * @param quoteDenom - The denomination of the quote asset\n *\n * @returns An InvertiblePrice object with the parsed price information\n *\n * @throws {InvalidObjectError} When pair_data is not present in the response,\n * indicating that no price is available for the requested pair\n *\n * @example\n * ```typescript\n * // Successful response with price data\n * const response = {\n * pair_data: {\n * price: \"2.5\",\n * expiry_time_ms: \"1700000000000\"\n * }\n * };\n *\n * const price = parsePriceResponseStructOutput(\n * response,\n * \"0x2::sui::SUI\",\n * \"0xusdcAddress...\"\n * );\n * console.log(price.price); // \"2.5\"\n *\n * // Response without price data\n * const emptyResponse = { pair_data: null };\n * // This will throw InvalidObjectError\n * ```\n */\nexport const parsePriceResponseStructOutput = (\n response: PriceResponseStructOutput,\n baseDenom: string,\n quoteDenom: string\n): InvertiblePrice => {\n if (!response.pair_data) {\n throw new InvalidObjectError(\"Can't find pair data price\");\n }\n\n return parsePriceDataStructOutput(response.pair_data, baseDenom, quoteDenom);\n};\n\n/**\n * Parses a paginated response containing multiple asset pairs from the oracle contract.\n *\n * This function is similar to parseAssetPairsResponseStructOutput but handles\n * paginated responses which may be used for larger datasets or API endpoints\n * that support pagination.\n *\n * @param output - The paginated response containing asset pairs\n * @param output.asset_pairs - Array of raw asset pair data\n *\n * @returns An array of parsed OracleAssetPair objects\n *\n * @example\n * ```typescript\n * const paginatedResponse = {\n * asset_pairs: [\n * { base_symbol: \"SUI\", base_precision: 9, quote_symbol: \"USDC\", quote_precision: 6 },\n * { base_symbol: \"ETH\", base_precision: 18, quote_symbol: \"USDC\", quote_precision: 6 }\n * ],\n * // Additional pagination fields would be here in a real response\n * };\n *\n * const pairs = parseAssetPairsResponsePaginatedStructOutput(paginatedResponse);\n * console.log(pairs.length); // 2\n * ```\n */\nexport const parseAssetPairsResponsePaginatedStructOutput = (\n output: AssetPairsResponsePaginatedStructOutput\n): OracleAssetPair[] => {\n return output.asset_pairs.map((item) => parseAssetPairStructOutput(item));\n};\n\n/**\n * Parses a paginated response containing multiple prices from the oracle contract.\n *\n * This function processes bulk price data that may be returned from queries\n * for all available prices in the oracle. Note that the current implementation\n * has a TODO indicating that asset denominations are not included in the response\n * and should be added when the contract is updated.\n *\n * @param output - The paginated response containing price data\n * @param output.prices - Array of raw price data objects\n *\n * @returns An array of parsed Price objects\n *\n * @example\n * ```typescript\n * const paginatedPrices = {\n * prices: [\n * { price: \"2.5\", expiry_time_ms: \"1700000000000\" },\n * { price: \"1800\", expiry_time_ms: \"1700000000000\" }\n * ],\n * // Additional pagination fields would be here\n * };\n *\n * const prices = parsePricesResponsePaginatedStructOutput(paginatedPrices);\n * console.log(prices.length); // 2\n * console.log(prices[0].price); // \"2.5\"\n * ```\n *\n * @remarks\n * - Currently, the base and quote denoms are set to empty strings due to\n * limitations in the contract response format\n * - This will be updated once the contract includes denom information in the response\n */\nexport const parsePricesResponsePaginatedStructOutput = (\n output: PricesResponsePaginatedStructOutput\n): Price[] => {\n // TODO: fix denoms if contract is updated to include them\n return output.prices.map((item) => parsePriceDataStructOutput(item, '', ''));\n};\n","import { bcs, BcsType } from '@mysten/bcs';\n\nexport const PaginationStruct = {\n total_count: bcs.u64(),\n has_next_page: bcs.bool(),\n next_cursor: bcs.option(bcs.string()),\n};\n\nexport const BcsAddressType = new BcsType({\n name: 'address',\n\n read(reader) {\n const bytes = new Uint8Array(32);\n for (let i = 0; i < 32; i++) {\n bytes[i] = reader.read8();\n }\n return (\n '0x' +\n Array.from(bytes)\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('')\n );\n },\n\n write(value, writer) {\n // Remove 0x prefix if present\n const hex = value.startsWith('0x') ? value.slice(2) : value;\n // Pad to 64 characters (32 bytes)\n const paddedHex = hex.padStart(64, '0');\n\n for (let i = 0; i < 32; i++) {\n const byte = parseInt(paddedHex.substr(i * 2, 2), 16);\n writer.write8(byte);\n }\n },\n});\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type BcsParsed<T extends BcsType<any, any>> = ReturnType<T['parse']>;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type BcsParsedMultiple<T extends readonly BcsType<any>[]> = {\n [K in keyof T]: BcsParsed<T[K]>;\n};\n","import { bcs } from '@mysten/bcs';\n\nimport { BcsAddressType, PaginationStruct, type BcsParsed } from './bcs';\n\nexport const OracleConfigStruct = bcs.struct('Config', {\n admin: BcsAddressType,\n price_threshold_ratio: bcs.u64(),\n default_price_expiry_seconds: bcs.u64(),\n});\nexport type OracleConfigStructOutput = BcsParsed<typeof OracleConfigStruct>;\n\nexport const AssetPairStruct = bcs.struct('AssetPair', {\n base_symbol: bcs.string(),\n quote_symbol: bcs.string(),\n base_precision: bcs.u8(),\n quote_precision: bcs.u8(),\n});\nexport type AssetPairStructOutput = BcsParsed<typeof AssetPairStruct>;\n\nexport const AssetPairsResponseStruct = bcs.struct('AssetPairsResponse', {\n asset_pairs: bcs.vector(AssetPairStruct),\n});\nexport type AssetPairsResponseStructOutput = BcsParsed<typeof AssetPairsResponseStruct>;\n\nexport const AssetPairsResponsePaginatedStruct = bcs.struct('AssetPairsResponsePaginated', {\n asset_pairs: bcs.vector(AssetPairStruct),\n ...PaginationStruct,\n});\nexport type AssetPairsResponsePaginatedStructOutput = BcsParsed<\n typeof AssetPairsResponsePaginatedStruct\n>;\n\nexport const PriceDataStruct = bcs.struct('PriceData', {\n price: bcs.u128(),\n expiry_time_ms: bcs.u64(),\n last_updated_ms: bcs.u64(),\n updater: BcsAddressType,\n});\nexport type PriceDataStructOutput = BcsParsed<typeof PriceDataStruct>;\n\nexport const PriceResponseStruct = bcs.struct('PriceResponse', {\n pair_data: bcs.option(PriceDataStruct),\n});\nexport type PriceResponseStructOutput = BcsParsed<typeof PriceResponseStruct>;\n\nexport const PricesResponsePaginatedStruct = bcs.struct('PricesResponsePaginated', {\n prices: bcs.vector(PriceDataStruct),\n ...PaginationStruct,\n});\nexport type PricesResponsePaginatedStructOutput = BcsParsed<typeof PricesResponsePaginatedStruct>;\n","import { bcs } from '@mysten/bcs';\n\nimport { BcsAddressType, type BcsParsed, PaginationStruct } from './bcs';\n\nexport const RouterConfigStruct = bcs.struct('Config', {\n admin: BcsAddressType,\n default_price_oracle_contract: BcsAddressType,\n default_protocol_fee_recipient: BcsAddressType,\n default_protocol_fee: bcs.u64(),\n default_lp_fee: bcs.u64(),\n});\nexport type RouterConfigStructOutput = BcsParsed<typeof RouterConfigStruct>;\n\nexport const MarketStruct = bcs.struct('Market', {\n base_asset_symbol: bcs.string(),\n quote_assets_symbols: bcs.vector(bcs.string()),\n market_address: bcs.string(),\n is_permissioned: bcs.bool(),\n created_at_ms: bcs.u64(),\n});\nexport type MarketStructOutput = BcsParsed<typeof MarketStruct>;\n\nexport const MarketResponseStruct = bcs.struct('MarketResponse', {\n market: bcs.option(MarketStruct),\n});\nexport type MarketResponseStructOutput = BcsParsed<typeof MarketResponseStruct>;\n\nexport const MarketsResponseStruct = bcs.struct('MarketsResponse', {\n markets: bcs.vector(MarketStruct),\n});\nexport type MarketsResponseStructOutput = BcsParsed<typeof MarketsResponseStruct>;\n\nexport const MarketsResponsePaginatedStruct = bcs.struct('MarketsResponsePaginated', {\n markets: bcs.vector(MarketStruct),\n ...PaginationStruct,\n});\nexport type MarketsResponsePaginatedStructOutput = BcsParsed<typeof MarketsResponsePaginatedStruct>;\n\nexport const BaseLiquidityResponseStruct = bcs.struct('BaseLiquidityResponse', {\n base_assets: bcs.vector(bcs.string()),\n ...PaginationStruct,\n});\nexport type BaseLiquidityResponseStructOutput = BcsParsed<typeof BaseLiquidityResponseStruct>;\n","import { bcs } from '@mysten/bcs';\n\nimport { BcsAddressType, type BcsParsedMultiple } from './bcs';\n\nexport const GetPoolInfoResponseStruct = [\n bcs.u64(),\n bcs.u128(),\n BcsAddressType,\n bcs.bool(),\n] as const;\nexport type GetPoolInfoResponseStructOutput = BcsParsedMultiple<typeof GetPoolInfoResponseStruct>;\n\nexport const GetFeesResponseStruct = [bcs.u64(), bcs.u64(), bcs.u64()] as const;\nexport type GetFeesResponseStructOutput = BcsParsedMultiple<typeof GetFeesResponseStruct>;\n","import type { Asset, OracleAsset } from '@bolt-liquidity-hq/core';\n\nimport type { BoltSuiClient } from '../client';\n\n/**\n * Retrieves all unique assets available in the Bolt protocol by querying oracle asset pairs\n * and enriching them with additional metadata from the client's asset configuration.\n *\n * This function performs the following operations:\n * 1. Fetches all oracle asset pairs from the blockchain\n * 2. Extracts unique assets from both base and quote positions\n * 3. Maps oracle assets to full Asset objects using client configuration\n * 4. Provides fallback values for assets not found in the configuration\n *\n * @param client - The BoltSuiClient instance used to query the blockchain\n * and access asset configuration.\n *\n * @returns A promise that resolves to an array of Asset objects, each containing:\n * - symbol: The asset's trading symbol (e.g., \"SUI\", \"USDC\")\n * - name: The full name of the asset (e.g., \"Sui\", \"USD Coin\")\n * - chainId: The blockchain network identifier (e.g., \"sui-mainnet\")\n * - denom: The chain-specific denomination (e.g., \"0x2::sui::SUI\")\n * - decimals: The number of decimal places for precision\n * - logo: Optional URL to the asset's logo image\n * - coingeckoId: Optional CoinGecko identifier for market data integration\n *\n * @throws {TransactionFailedError} When the oracle contract query fails\n * @throws {ParseError} When the oracle response cannot be properly parsed\n * @throws {UnexpectedError} When network issues prevent the query from completing\n */\nexport const getAssets = async (client: BoltSuiClient): Promise<Asset[]> => {\n // Fetch all trading pairs from the oracle to discover available assets\n const assetPairs = await client.getAllOracleAssetPairs();\n\n /**\n * Map to store unique assets by symbol.\n * This ensures each asset appears only once in the final result,\n * even if it appears in multiple trading pairs.\n */\n const uniqueOracleAssets: Record<string, OracleAsset> = {};\n\n // Extract unique assets from all trading pairs\n for (const item of assetPairs) {\n uniqueOracleAssets[item.base.symbol] = item.base;\n uniqueOracleAssets[item.quote.symbol] = item.quote;\n }\n\n return Object.values(uniqueOracleAssets).map(\n (item) =>\n client.assetsConfig[item.symbol] ??\n // Fallback to minimal asset data from oracle\n {\n symbol: item.name,\n name: item.name,\n chainId: client.chainConfig.id,\n denom: item.symbol,\n decimals: item.precision,\n logo: undefined,\n coingeckoId: undefined,\n }\n );\n};\n","import type { OracleConfig } from '@bolt-liquidity-hq/core';\n\nimport type { BoltSuiClient } from '../client';\nimport { PRICE_ORACLE_MODULE } from '../constants';\nimport { parseDevInspectResult, queryDevInspect } from '../helpers';\nimport { parseOracleConfigStructOutput } from './parsers';\nimport { OracleConfigStruct } from '../../types';\n\n/**\n * Queries the oracle smart contract to retrieve its current configuration settings.\n *\n * This function fetches the oracle's configuration parameters which govern how\n * price feeds are managed, including expiration times, update thresholds, and\n * administrative settings. The configuration is essential for understanding\n * oracle behavior and constraints when working with price feeds.\n *\n * @param client - The BoltSuiClient instance\n *\n * @returns A promise that resolves to an OracleConfig object containing:\n * - admin: The Sui address authorized to update oracle settings and prices\n * - priceThresholdRatio: The minimum price change ratio required for updates\n * (e.g., \"0.01\" means 1% minimum change required)\n * - priceExpireTime: Object with time duration for price validity:\n * - secs: Number of seconds before a price is considered stale\n * - nanos: Additional nanoseconds (always 0 in current implementation)\n *\n * @throws {TransactionFailedError} When the oracle contract query fails, possibly due to:\n * - Invalid oracle contract address\n * - Oracle contract not initialized\n * - Network connectivity issues\n * @throws {ParseError} When the response cannot be parsed, indicating:\n * - Unexpected response format from the contract\n * - BCS deserialization failure\n * - Contract ABI mismatch\n * @throws {InvalidObjectError} When required data is missing from the response\n */\nexport const getOracleConfig = async (client: BoltSuiClient): Promise<OracleConfig> => {\n /**\n * The Move function name in the oracle module that returns configuration.\n * This function signature in Move:\n * public fun config(oracle: &Oracle): OracleConfig\n */\n const CONFIG_FUNCTION = 'config';\n\n const response = await queryDevInspect(\n client.suiClient,\n [client.packageId, PRICE_ORACLE_MODULE, CONFIG_FUNCTION],\n [client.contracts.oracle]\n );\n\n const output = parseDevInspectResult(response, OracleConfigStruct);\n\n return parseOracleConfigStructOutput(output);\n};\n","import type { InvertiblePrice } from '@bolt-liquidity-hq/core';\nimport { bcs } from '@mysten/bcs';\nimport { SUI_CLOCK_OBJECT_ID } from '@mysten/sui/utils';\n\nimport type { BoltSuiClient } from '../client';\nimport { PRICE_ORACLE_MODULE } from '../constants';\nimport { parseDevInspectResult, queryDevInspect } from '../helpers';\nimport { parsePriceResponseStructOutput } from './parsers';\nimport { PriceResponseStruct } from '../../types';\n\n/**\n * Queries the oracle smart contract to retrieve the current price for a specific asset pair.\n *\n * This function fetches the latest price feed for a given base/quote asset combination\n * from the Bolt oracle. The oracle maintains price feeds that are updated by authorized\n * price feeders and validated against configured thresholds. Prices have expiration times\n * to ensure stale data is not used for trading.\n *\n * @param client - The BoltSuiClient instance\n * @param baseDenom - The denomination/type of the base asset in Sui format\n * (e.g., \"0x2::sui::SUI\", \"0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN\")\n * @param quoteDenom - The denomination/type of the quote asset in Sui format\n * Price will be expressed as: 1 base = X quote\n *\n * @returns A promise that resolves to an InvertiblePrice object containing:\n * - assetPair: The trading pair in format \"baseDenom:quoteDenom\"\n * - price: The current price as a decimal string (e.g., \"2.5\" means 1 base = 2.5 quote)\n * - expiryTime: Unix timestamp in nanoseconds when this price becomes stale\n * - isInverse: Always false in current implementation (price is not inverted)\n *\n * @throws {InvalidObjectError} When the requested asset pair has no price data available,\n * which can occur if:\n * - The pair is not registered in the oracle\n * - The price has expired and not been updated\n * - The oracle has never received a price for this pair\n * @throws {TransactionFailedError} When the oracle contract query fails due to:\n * - Invalid oracle contract address\n * - Network connectivity issues\n * - Contract execution errors\n * @throws {ParseError} When the response cannot be parsed, indicating:\n * - Unexpected response format\n * - BCS deserialization failure\n */\nexport const getPrice = async (\n client: BoltSuiClient,\n baseDenom: string,\n quoteDenom: string\n): Promise<InvertiblePrice> => {\n /**\n * The Move function name in the oracle module that returns price for a pair.\n * This function signature in Move:\n * public fun get_price(\n * oracle: &Oracle,\n * base_denom: String,\n * quote_denom: String,\n * clock: &Clock\n * ): PriceResponse\n */\n const GET_PRICE_FUNCTION = 'get_price';\n\n const response = await queryDevInspect(\n client.suiClient,\n [client.packageId, PRICE_ORACLE_MODULE, GET_PRICE_FUNCTION],\n [\n client.contracts.oracle,\n bcs.string().serialize(baseDenom),\n bcs.string().serialize(quoteDenom),\n SUI_CLOCK_OBJECT_ID,\n ]\n );\n\n const output = parseDevInspectResult(response, PriceResponseStruct);\n\n return parsePriceResponseStructOutput(output, baseDenom, quoteDenom);\n};\n","import type { Price } from '@bolt-liquidity-hq/core';\nimport { bcs } from '@mysten/bcs';\n\nimport type { BoltSuiClient } from '../client';\nimport { DEFAULT_PAGINATION_LIMIT, PRICE_ORACLE_MODULE } from '../constants';\nimport { parseDevInspectResult, queryDevInspect } from '../helpers';\nimport { parsePricesResponsePaginatedStructOutput } from './parsers';\nimport { PricesResponsePaginatedStruct } from '../../types';\n\n/**\n * Queries the oracle smart contract to retrieve all available price feeds with automatic pagination.\n *\n * This function fetches the current prices for all asset pairs supported by the oracle\n * in a paginated manner. It's more efficient than making multiple individual price\n * queries when you need prices for multiple pairs. The function automatically handles\n * pagination to ensure all prices are retrieved, regardless of the total number.\n *\n * @param client - The BoltSuiClient instance\n *\n * @returns A promise that resolves to an array of Price objects, each containing:\n * - assetPair: Currently empty string due to contract limitations (see remarks)\n * - price: The current price as a decimal string\n * - expiryTime: Unix timestamp in nanoseconds when this price becomes stale\n *\n * @throws {TransactionFailedError} When the oracle contract query fails due to:\n * - Invalid oracle contract address\n * - Oracle not properly initialized\n * - Network connectivity issues\n * @throws {ParseError} When the response cannot be parsed, indicating:\n * - Unexpected response format from the contract\n * - BCS deserialization failure\n * - Contract ABI mismatch\n */\nexport const getPrices = async (client: BoltSuiClient): Promise<Price[]> => {\n /**\n * The Move function name in the oracle module that returns paginated prices.\n * This function signature in Move:\n * public fun get_prices_paginated(\n * oracle: &Oracle,\n * limit: Option<u64>,\n * cursor: Option<String>\n * ): PricesResponsePaginated\n */\n const GET_PRICES_PAGINATED_FUNCTION = 'get_prices_paginated';\n\n const result: Price[] = [];\n\n let currentCursor = null;\n\n let hasNextPage = true;\n\n while (hasNextPage) {\n const response = await queryDevInspect(\n client.suiClient,\n [client.packageId, PRICE_ORACLE_MODULE, GET_PRICES_PAGINATED_FUNCTION],\n [\n client.contracts.oracle,\n bcs.option(bcs.u64()).serialize(DEFAULT_PAGINATION_LIMIT),\n bcs.option(bcs.string()).serialize(currentCursor),\n ]\n );\n\n const output = parseDevInspectResult(response, PricesResponsePaginatedStruct);\n\n const assetPairs = parsePricesResponsePaginatedStructOutput(output);\n\n result.push(...assetPairs);\n\n currentCursor = output.next_cursor;\n hasNextPage = output.has_next_page;\n }\n\n return result;\n};\n","import type { Address, BaseLiquidityDetails } from '@bolt-liquidity-hq/core';\nimport { bcs } from '@mysten/bcs';\n\nimport type { BoltSuiClient } from '../client';\nimport { DEFAULT_PAGINATION_LIMIT, ROUTER_MODULE } from '../constants';\nimport { parseDevInspectResult, queryDevInspect } from '../helpers';\nimport { parseBaseLiquidityResponseStructOutput } from './parsers';\nimport { BaseLiquidityResponseStruct } from '../../types';\n\n/**\n * Queries the router smart contract to retrieve the total base asset liquidity across all pools with automatic pagination.\n *\n * This function fetches the current liquidity levels for all base assets in their respective\n * pools. Each pool in the Bolt protocol handles swaps for a specific base asset against\n * multiple quote assets, and this query returns how much of each base asset is currently\n * available in its pool for trading, along with the total shares for each pool. The function\n * automatically handles pagination to ensure all pools are retrieved.\n *\n * @param client - The BoltSuiClient instance\n *\n * @returns A promise that resolves to a Record mapping pool addresses to BaseLiquidityDetails objects.\n * Each entry represents:\n * - Key: Currently using base asset denom as key (see TODO in remarks)\n * - Value: A BaseLiquidityDetails object containing:\n * - baseLiquidity: A Coin object with:\n * - amount: The quantity of base asset liquidity (currently hardcoded to \"10\")\n * - denom: The type of the base asset (e.g., \"0x2::sui::SUI\")\n * - totalShares: The total number of liquidity shares (currently hardcoded to \"10\")\n *\n * @throws {TransactionFailedError} When the router contract query fails due to:\n * - Invalid router contract address\n * - Router not properly initialized\n * - Network connectivity issues\n * @throws {ParseError} When the response cannot be parsed, indicating:\n * - Unexpected response format\n * - BCS deserialization failure\n */\nexport const getAllBaseLiquidity = async (\n client: BoltSuiClient\n): Promise<Record<Address, BaseLiquidityDetails>> => {\n /**\n * The Move function name in the router module that returns paginated base liquidity.\n * This function signature in Move:\n * public fun base_liquidity_all_paginated(\n * router: &Router,\n * limit: Option<u64>,\n * cursor: Option<String>\n * ): BaseLiquidityResponse\n */\n const BASE_LIQUIDITY_ALL_PAGINATED_FUNCTION = 'base_liquidity_all_paginated';\n\n const result: Record<Address, BaseLiquidityDetails> = {};\n\n let currentCursor = null;\n\n let hasNextPage = true;\n\n while (hasNextPage) {\n const response = await queryDevInspect(\n client.suiClient,\n [client.packageId, ROUTER_MODULE, BASE_LIQUIDITY_ALL_PAGINATED_FUNCTION],\n [\n client.contracts.router,\n bcs.option(bcs.u64()).serialize(DEFAULT_PAGINATION_LIMIT),\n bcs.option(bcs.string()).serialize(currentCursor),\n ]\n );\n\n const output = parseDevInspectResult(response, BaseLiquidityResponseStruct);\n\n const baseLiquidities = parseBaseLiquidityResponseStructOutput(output);\n\n for (const item of baseLiquidities) {\n // TODO: fix when we get the correct values\n // Currently using base asset denom as key instead of pool address\n // This should be changed to use actual pool addresses when available\n result[item.baseLiquidity.denom] = item;\n }\n\n // Update pagination state for the next iteration\n currentCursor = output.next_cursor;\n hasNextPage = output.has_next_page;\n }\n\n return result;\n};\n","import type { Pool, RouterConfig, BaseLiquidityDetails } from '@bolt-liquidity-hq/core';\nimport { NotFoundError } from '@bolt-liquidity-hq/core';\n\nimport type {\n BaseLiquidityResponseStructOutput,\n MarketResponseStructOutput,\n MarketsResponsePaginatedStructOutput,\n MarketsResponseStructOutput,\n MarketStructOutput,\n RouterConfigStructOutput,\n} from '../../types';\n\n/**\n * Parses a raw market structure from the Sui blockchain into a structured Pool object.\n *\n * This function transforms the raw market data returned by the Sui router contract\n * into a standardized Pool format. In the Sui implementation, markets and pools\n * are conceptually the same, representing liquidity pools for base/quote asset pairs.\n *\n * @param output - The raw market data from the Sui contract\n * @param output.market_address - The Sui object ID of the market/pool\n * @param output.base_asset_symbol - The type/symbol of the base asset\n * @param output.quote_assets_symbols - Array of quote asset types/symbols\n *\n * @returns A parsed Pool object containing:\n * - poolAddress: The Sui object ID of the pool\n * - baseDenom: The type of the base asset (e.g., \"0x2::sui::SUI\")\n * - quoteDenoms: Array of available quote asset types\n *\n * @example\n * ```typescript\n * const rawMarket = {\n * market_address: \"0x1234...\",\n * base_asset_symbol: \"0x2::sui::SUI\",\n * quote_assets_symbols: [\"0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN\"]\n * };\n *\n * const pool = parseMarketStructOutput(rawMarket);\n * console.log(pool.poolAddress); // \"0x1234...\"\n * console.log(pool.baseDenom); // \"0x2::sui::SUI\"\n * console.log(pool.quoteDenoms); // [\"0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN\"]\n * ```\n *\n * @remarks\n * - In Sui, asset symbols are full type paths (e.g., \"0x2::sui::SUI\")\n * - A market can have multiple quote assets paired with one base asset\n * - The market_address is a unique Sui object ID\n */\nexport const parseMarketStructOutput = (output: MarketStructOutput): Pool => {\n return {\n poolAddress: output.market_address,\n baseDenom: output.base_asset_symbol,\n quoteDenoms: output.quote_assets_symbols,\n };\n};\n\n/**\n * Parses a market response that may or may not contain market data.\n *\n * This function handles responses from queries for specific markets, which include\n * an optional market field. If no market is found, it throws an appropriate error.\n *\n * @param response - The market query response from the Sui contract\n * @param response.market - Optional market data if found\n *\n * @returns A parsed Pool object representing the market\n *\n * @throws {NotFoundError} When the market field is null or undefined,\n * indicating the requested market doesn't exist\n *\n * @example\n * ```typescript\n * // Successful response with market data\n * const response = {\n * market: {\n * market_address: \"0x1234...\",\n * base_asset_symbol: \"0x2::sui::SUI\",\n * quote_assets_symbols: [\"0x5d4b...::coin::COIN\"]\n * }\n * };\n * const pool = parseMarketResponseStructOutput(response);\n *\n * // Response without market (will throw)\n * const emptyResponse = { market: null };\n * // Throws NotFoundError\n * ```\n */\nexport const parseMarketResponseStructOutput = (response: MarketResponseStructOutput): Pool => {\n if (!response.market) {\n throw new NotFoundError('Market', undefined, { response });\n }\n\n return parseMarketStructOutput(response.market);\n};\n\n/**\n * Parses a response containing all available markets/pools into an array of Pool objects.\n *\n * This function processes the response from the router's markets query, which returns\n * all active liquidity pools in the Bolt protocol on Sui.\n *\n * @param response - The raw response from the router's markets query\n * @param response.markets - Array of market structures\n *\n * @returns An array of parsed Pool objects, each representing a liquidity pool\n *\n * @example\n * ```typescript\n * const response = {\n * markets: [\n * {\n * market_address: \"0xabc...\",\n * base_asset_symbol: \"0x2::sui::SUI\",\n * quote_assets_symbols: [\"0x5d4b...::coin::COIN\"]\n * },\n * {\n * market_address: \"0xdef...\",\n * base_asset_symbol: \"0xaf8...::coin::COIN\",\n * quote_assets_symbols: [\"0x5d4b...::coin::COIN\", \"0x2::sui::SUI\"]\n * }\n * ]\n * };\n *\n * const pools = parseMarketsResponseStructOutput(response);\n * console.log(pools.length); // 2\n * pools.forEach(pool => {\n * console.log(`Pool for ${pool.baseDenom} at ${pool.poolAddress}`);\n * console.log(`Quote assets: ${pool.quoteDenoms.join(', ')}`);\n * });\n * ```\n *\n * @remarks\n * - Each market represents a pool with one base asset and one or more quote assets\n * - Markets are returned in the order they exist on-chain\n * - Empty markets array is valid and returns an empty array\n */\nexport const parseMarketsResponseStructOutput = (response: MarketsResponseStructOutput): Pool[] => {\n return response.markets.map((item) => parseMarketStructOutput(item));\n};\n\n/**\n * Parses a paginated response containing markets/pools into an array of Pool objects.\n *\n * This function handles paginated market responses, which are used when there are\n * too many markets to return in a single query. It extracts just the market data,\n * leaving pagination handling to the calling function.\n *\n * @param response - The paginated response from the router's markets query\n * @param response.markets - Array of market structures for this page\n * @param response.has_next_page - Whether more pages exist (not used in parser)\n * @param response.next_cursor - Cursor for next page (not used in parser)\n *\n * @returns An array of parsed Pool objects for this page of results\n *\n * @example\n * ```typescript\n * const paginatedResponse = {\n * markets: [\n * {\n * market_address: \"0xabc...\",\n * base_asset_symbol: \"0x2::sui::SUI\",\n * quote_assets_symbols: [\"0x5d4b...::coin::COIN\"]\n * }\n * ],\n * has_next_page: true,\n * next_cursor: \"0xabc...\"\n * };\n *\n * const pools = parseMarketsResponsePaginatedStructOutput(paginatedResponse);\n * console.log(pools.length); // 1 (just this page)\n * ```\n *\n * @see {@link parseMarketsResponseStructOutput} for non-paginated version\n */\nexport const parseMarketsResponsePaginatedStructOutput = (\n response: MarketsResponsePaginatedStructOutput\n): Pool[] => {\n return response.markets.map((item) => parseMarketStructOutput(item));\n};\n\n/**\n * Parses a raw router configuration response from the Sui blockchain into a structured RouterConfig object.\n *\n * This function transforms the snake_case properties from the Sui router contract response\n * into camelCase properties following TypeScript conventions. The router configuration\n * controls global settings for the Bolt protocol on Sui.\n *\n * @param output - The raw router configuration response from the contract query\n * @param output.admin - The Sui address with admin privileges\n * @param output.default_price_oracle_contract - Default oracle object ID for price feeds\n * @param output.default_protocol_fee_recipient - Address that receives protocol fees\n * @param output.default_protocol_fee - Protocol fee as decimal string (e.g., \"0.003\" = 0.3%)\n * @param output.default_lp_fee - LP fee as decimal string (e.g., \"0.002\" = 0.2%)\n *\n * @returns A parsed RouterConfig object with:\n * - admin: The admin address of the router contract\n * - defaultPriceOracleContract: Object ID of the default price oracle\n * - defaultProtocolFeeRecipient: Address that receives protocol fees\n * - defaultProtocolFee: The default protocol fee percentage (as decimal string)\n * - defaultLpFee: The default liquidity provider fee percentage (as decimal string)\n *\n * @example\n * ```typescript\n * const rawResponse = {\n * admin: \"0xadmin...\",\n * default_price_oracle_contract: \"0xoracle...\",\n * default_protocol_fee_recipient: \"0xtreasury...\",\n * default_protocol_fee: \"0.003\",\n * default_lp_fee: \"0.002\"\n * };\n *\n * const config = parseRouterConfigStructOutput(rawResponse);\n * console.log(config.admin); // \"0xadmin...\"\n * console.log(config.defaultProtocolFee); // \"0.003\" (0.3%)\n * console.log(config.defaultLpFee); // \"0.002\" (0.2%)\n *\n * // Calculate total fees\n * const totalFeePercent = (parseFloat(config.defaultProtocolFee) +\n * parseFloat(config.defaultLpFee)) * 100;\n * console.log(`Total fees: ${totalFeePercent}%`); // \"Total fees: 0.5%\"\n * ```\n *\n * @remarks\n * - Fees are represented as decimal strings (0.003 = 0.3%)\n * - The router configuration applies globally unless overridden at the pool level\n * - Admin can update these default values\n * - Protocol fees go to the specified recipient address\n * - LP fees are distributed to liquidity providers\n */\nexport const parseRouterConfigStructOutput = (output: RouterConfigStructOutput): RouterConfig => {\n return {\n admin: output.admin,\n defaultPriceOracleContract: output.default_price_oracle_contract,\n defaultProtocolFeeRecipient: output.default_protocol_fee_recipient,\n defaultProtocolFee: output.default_protocol_fee,\n defaultLpFee: output.default_lp_fee,\n };\n};\n\n/**\n * Parses a base liquidity response into a structured format.\n *\n * This function processes the response from base liquidity queries, which provide\n * information about the base assets locked in pools. Note that the current Sui\n * implementation has limitations in the returned data.\n *\n * @param output - The raw response from a base liquidity query\n * @param output.base_assets - Array of base asset types (currently missing amounts)\n *\n * @returns An array of BaseLiquidityDetails objects, each containing:\n * - baseLiquidity: Object with denom and amount (currently hardcoded to \"10\")\n * - totalShares: The total LP shares (currently hardcoded to \"10\")\n *\n * @example\n * ```typescript\n * const response = {\n * base_assets: [\"0x2::sui::SUI\", \"0xaf8...::coin::COIN\"]\n * };\n * const details = parseBaseLiquidityResponseStructOutput(response);\n * // Result: [\n * // {\n * // baseLiquidity: { denom: \"0x2::sui::SUI\", amount: \"10\" },\n * // totalShares: \"10\"\n * // },\n * // {\n * // baseLiquidity: { denom: \"0xaf8...::coin::COIN\", amount: \"10\" },\n * // totalShares: \"10\"\n * // }\n * // ]\n * ```\n *\n * @remarks\n * - **TODO**: The current Sui contract only returns asset types without amounts or shares\n * - Amounts and shares are temporarily hardcoded to \"10\" until contract is updated\n * - This limitation will be fixed in a future contract upgrade\n * - The hardcoded values should not be used for any calculations\n */\nexport const parseBaseLiquidityResponseStructOutput = (\n output: BaseLiquidityResponseStructOutput\n): BaseLiquidityDetails[] => {\n // TODO: fix when smart contract returns all needed fields\n return output.base_assets.map((item) => ({\n baseLiquidity: {\n denom: item,\n amount: '10',\n },\n totalShares: '10',\n }));\n};\n\n/**\n * Parses a query response containing liquidity data for all pools.\n *\n * @param response - The raw response containing liquidity data for multiple pools\n * @returns A record mapping pool addresses to their respective base liquidity details\n *\n * @example\n * ```typescript\n * const response = {\n * liquidity: {\n * \"pool1\": { base_liquidity: { amount: \"1000\", denom: \"uatom\" }, total_shares: \"5000\" },\n * \"pool2\": { base_liquidity: { amount: \"2000\", denom: \"uosmo\" }, total_shares: \"8000\" }\n * }\n * };\n * const allLiquidity = parseQueryBaseLiquidityAllResponse(response);\n * // Result: {\n * // \"pool1\": { baseLiquidity: { amount: \"1000\", denom: \"uatom\" }, totalShares: \"5000\" },\n * // \"pool2\": { baseLiquidity: { amount: \"2000\", denom: \"uosmo\" }, totalShares: \"8000\" }\n * // }\n * ```\n */\n// export const parseQueryBaseLiquidityAllResponse = (\n// response: QueryBaseLiquidityAllResponse\n// ): Record<Address, BaseLiquidityDetails> => {\n// const newMapping: Record<Address, BaseLiquidityDetails> = {};\n\n// for (const [key, value] of Object.entries(response.liquidity)) {\n// newMapping[key] = parseQueryBaseLiquidityResponse(value);\n// }\n\n// return newMapping;\n// };\n","import type { Address, Coin } from '@bolt-liquidity-hq/core';\nimport { bcs } from '@mysten/bcs';\n\nimport type { BoltSuiClient } from '../client';\nimport { ROUTER_MODULE } from '../constants';\nimport { queryDevInspect } from '../helpers';\n\n/**\n * Queries the router smart contract to retrieve all quote asset positions for a specific liquidity provider.\n *\n * This function fetches all withdrawable quote assets that a liquidity provider (LP) has\n * deposited across all pools in the Bolt protocol. LPs provide quote assets (like USDC)\n * to pools, enabling traders to swap base assets for these quote assets. This query\n * returns the current balance of quote assets the LP can withdraw from each pool.\n *\n * @param client - The BoltSuiClient instance\n * @param lpAddress - The Sui address of the liquidity provider to query\n * Must be a valid Sui address format (e.g., \"0x1234...\")\n *\n * @returns A promise that resolves to a Record mapping pool addresses to arrays of Coin objects.\n * Each entry represents:\n * - Key: The pool object ID where the LP has deposits\n * - Value: An array of Coin objects, each containing:\n * - amount: The withdrawable quantity of quote asset (as string)\n * - denom: The type of the quote asset (e.g., \"0x5d4b...::coin::COIN\")\n *\n * @throws {TransactionFailedError} When the router contract query fails due to:\n * - Invalid router contract address\n * - Invalid LP address format\n * - Router not properly initialized\n * - Network connectivity issues\n * @throws {ParseError} When the response cannot be parsed, indicating:\n * - Unexpected response format\n * - BCS deserialization failure\n */\nexport const getAllQuotesForUser = async (\n client: BoltSuiClient,\n lpAddress: Address\n): Promise<Record<Address, Coin[]>> => {\n /**\n * The Move function name in the router module that returns all quote positions for a user.\n * This function signature in Move:\n * public fun quotes_for_user_all(\n * router: &Router,\n * lp_address: String\n * ): QuotesForUserResponse\n */\n const QUOTES_FOR_USER_ALL_FUNCTION = 'quotes_for_user_all';\n\n // Query the router contract for all quote positions of the specified LP\n const response = await queryDevInspect(\n client.suiClient,\n [client.packageId, ROUTER_MODULE, QUOTES_FOR_USER_ALL_FUNCTION],\n [client.contracts.router, bcs.string().serialize(lpAddress)]\n );\n\n console.log(response);\n\n // TODO: contract doesn't have this implemented yet\n // When implemented, this will parse the response into the expected format:\n // const output = parseDevInspectResult(response, QuotesForUserResponseStruct);\n // return parseQuotesForUserResponse(output);\n\n // TODO: contract doesn't have this implemented yet\n // Returning empty object until contract implementation is complete\n return {};\n};\n","import type { Pool } from '@bolt-liquidity-hq/core';\nimport { bcs } from '@mysten/bcs';\n\nimport type { BoltSuiClient } from '../client';\nimport { ROUTER_MODULE } from '../constants';\nimport { parseDevInspectResult, queryDevInspect } from '../helpers';\nimport { parseMarketResponseStructOutput } from './parsers';\nimport { MarketResponseStruct } from '../../types';\n\n/**\n * Queries the router smart contract to retrieve pool information for a specific base asset.\n *\n * This function fetches the market/pool details for a given base asset type. In the Bolt protocol\n * on Sui, each market (pool) is dedicated to trading one base asset against multiple quote assets.\n * This query returns the pool's object ID and available quote assets for the specified base asset.\n * Markets and pools are used interchangeably in the Sui implementation.\n *\n * @param client - The BoltSuiClient instance\n * @param baseDenom - The type of the base asset in Sui format\n * (e.g., \"0x2::sui::SUI\", \"0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5::coin::COIN\")\n *\n * @returns A promise that resolves to a Pool object containing:\n * - poolAddress: The Sui object ID of the market/pool\n * - baseDenom: The type of the base asset (echoes the input)\n * - quoteDenoms: Array of types for available quote assets that can be traded against the base\n *\n * @throws {NotFoundError} When no pool exists for the specified base asset, which occurs if:\n * - The base asset has no market created yet\n * - The base asset type is not recognized by the router\n * - The market was removed or not initialized\n * @throws {TransactionFailedError} When the router contract query fails due to:\n * - Invalid router contract address\n * - Network connectivity issues\n * - Invalid base asset type format\n * @throws {ParseError} When the response cannot be parsed, indicating:\n * - Unexpected response format\n * - BCS deserialization failure\n */\nexport const getPoolForBase = async (client: BoltSuiClient, baseDenom: string): Promise<Pool> => {\n /**\n * The Move function name in the router module that returns market info for a base asset.\n * This function signature in Move:\n * public fun market_for_base(\n * router: &Router,\n * base_denom: String\n * ): MarketResponse\n */\n const MARKET_FOR_BASE_FUNCTION = 'market_for_base';\n\n const response = await queryDevInspect(\n client.suiClient,\n [client.packageId, ROUTER_MODULE, MARKET_FOR_BASE_FUNCTION],\n [client.contracts.router, bcs.string().serialize(baseDenom)]\n );\n\n const output = parseDevInspectResult(response, MarketResponseStruct);\n\n return parseMarketResponseStructOutput(output);\n};\n","import type { Pool } from '@bolt-liquidity-hq/core';\nimport { bcs } from '@mysten/bcs';\n\nimport type { BoltSuiClient } from '../client';\nimport { DEFAULT_PAGINATION_LIMIT, ROUTER_MODULE } from '../constants';\nimport { parseDevInspectResult, queryDevInspect } from '../helpers';\nimport { parseMarketsResponsePaginatedStructOutput } from './parsers';\nimport { MarketsResponsePaginatedStruct } from '../../types';\n\n/**\n * Queries the router smart contract to retrieve information about all deployed pools with automatic pagination.\n *\n * This function fetches a comprehensive list of all markets/pools in the Bolt protocol on Sui,\n * including their object IDs, base assets, and available quote assets. It automatically handles\n * pagination to ensure all pools are retrieved, regardless of the total number. This provides\n * a complete overview of all trading possibilities within the protocol at once, making it more\n * efficient than querying individual pools.\n *\n * @param client - The BoltSuiClient instance that must be configured with:\n * - packageId: The Sui package ID containing the router module\n * - contracts.router: The router contract object ID\n * - suiClient: An active SuiClient for network communication\n *\n * @returns A promise that resolves to an array of Pool objects, each containing:\n * - poolAddress: The Sui object ID of the market/pool\n * - baseDenom: The type of the base asset for this pool (e.g., \"0x2::sui::SUI\")\n * - quoteDenoms: Array of types for available quote assets that can be traded\n *\n * @throws {TransactionFailedError} When the router contract query fails due to:\n * - Invalid router contract address\n * - Router not properly initialized\n * - Network connectivity issues\n * @throws {ParseError} When the response cannot be parsed, indicating:\n * - Unexpected response format from the contract\n * - BCS deserialization failure\n * - Contract ABI mismatch\n *\n * @example\n * ```typescript\n * const client = new BoltSuiClient({\n * environment: 'mainnet'\n * });\n *\n * try {\n * const allPools = await getPools(client);\n *\n * console.log(`Total pools available: ${allPools.length}`);\n *\n * // Display all pools and their trading pairs\n * allPools.forEach((pool, index) => {\n * console.log(`\\nPool ${index + 1}: ${pool.poolAddress}`);\n * console.log(` Base asset: ${pool.baseDenom}`);\n * console.log(` Quote assets: ${pool.quoteDenoms.length}`);\n * pool.quoteDenoms.forEach(quote => {\n * console.log(` - ${quote}`);\n * });\n * });\n *\n * // Find all pools that support USDC as quote\n * const usdcType = \"0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN\";\n * const poolsWithUsdc = allPools.filter(pool =>\n * pool.quoteDenoms.includes(usdcType)\n * );\n * console.log(`\\nPools supporting USDC: ${poolsWithUsdc.length}`);\n *\n * // Find pools for specific base asset\n * const suiPools = allPools.filter(pool =>\n * pool.baseDenom === \"0x2::sui::SUI\"\n * );\n * if (suiPools.length > 0) {\n * console.log(`\\nSUI pool found at: ${suiPools[0].poolAddress}`);\n * }\n *\n * // Count total unique trading pairs\n * const totalPairs = allPools.reduce((sum, pool) =>\n * sum + pool.quoteDenoms.length, 0\n * );\n * console.log(`\\nTotal trading pairs: ${totalPairs}`);\n *\n * } catch (error) {\n * console.error('Failed to fetch pools:', error);\n * }\n * ```\n *\n * @remarks\n * - In Sui, \"markets\" and \"pools\" are used interchangeably\n * - Each pool handles one base asset but can have multiple quote assets\n * - The function uses pagination internally to handle large numbers of pools\n * - DEFAULT_PAGINATION_LIMIT controls how many pools are fetched per query\n * - All queries are performed using devInspect, so no gas is consumed\n * - Pool addresses are Sui object IDs\n * - This function is useful for:\n * - Building a complete list of trading options\n * - Discovering all supported assets\n * - Creating market overview dashboards\n * - Finding pools for specific asset pairs\n * - Analyzing protocol liquidity distribution\n * - Results are returned in the order they exist on-chain\n *\n * @see {@link Pool} for the structure of pool objects\n * @see {@link getPoolForBase} to query a specific pool by base asset\n * @see {@link getPoolConfig} for detailed configuration of individual pools\n * @see {@link getAllBaseAssetsLiquidity} for liquidity information across pools\n */\nexport const getPools = async (client: BoltSuiClient): Promise<Pool[]> => {\n /**\n * The Move function name in the router module that returns paginated markets.\n * This function signature in Move:\n * public fun markets_paginated(\n * router: &Router,\n * limit: Option<u64>,\n * cursor: Option<String>\n * ): MarketsResponsePaginated\n */\n const MARKETS_PAGINATED_FUNCTION = 'markets_paginated';\n\n const result: Pool[] = [];\n\n let currentCursor = null;\n\n let hasNextPage = true;\n\n while (hasNextPage) {\n const response = await queryDevInspect(\n client.suiClient,\n [client.packageId, ROUTER_MODULE, MARKETS_PAGINATED_FUNCTION],\n [\n client.contracts.router,\n bcs.option(bcs.u64()).serialize(DEFAULT_PAGINATION_LIMIT),\n bcs.option(bcs.string()).serialize(currentCursor),\n ]\n );\n\n const output = parseDevInspectResult(response, MarketsResponsePaginatedStruct);\n\n const pools = parseMarketsResponsePaginatedStructOutput(output);\n\n result.push(...pools);\n\n currentCursor = output.next_cursor;\n hasNextPage = output.has_next_page;\n }\n\n return result;\n};\n","import type { RouterConfig } from '@bolt-liquidity-hq/core';\n\nimport type { BoltSuiClient } from '../client';\nimport { ROUTER_MODULE } from '../constants';\nimport { parseDevInspectResult, queryDevInspect } from '../helpers';\nimport { parseRouterConfigStructOutput } from './parsers';\nimport { RouterConfigStruct } from '../../types';\n\n/**\n * Queries the router smart contract to retrieve its current configuration settings.\n *\n * This function fetches the router's configuration parameters which govern how\n * swaps are executed, fees are collected, and new pools are deployed. The router\n * is the central contract that coordinates all trading activities in the Bolt protocol\n * on Sui, managing markets and ensuring consistent behavior across all pools.\n *\n * @param client - The BoltSuiClient instance\n *\n * @returns A promise that resolves to a RouterConfig object containing:\n * - admin: The Sui address with administrative privileges over the router\n * - defaultPriceOracleContract: Object ID of the default price oracle used by pools\n * - defaultProtocolFeeRecipient: Sui address that receives protocol fees\n * - defaultProtocolFee: Protocol fee percentage as a decimal string (e.g., \"0.003\" = 0.3%)\n * - defaultLpFee: Liquidity provider fee percentage as a decimal string (e.g., \"0.002\" = 0.2%)\n *\n * @throws {TransactionFailedError} When the router contract query fails due to:\n * - Invalid router contract address\n * - Router not properly initialized\n * - Network connectivity issues\n * @throws {ParseError} When the response cannot be parsed, indicating:\n * - Unexpected response format from the contract\n * - BCS deserialization failure\n * - Contract ABI mismatch\n * @throws {InvalidObjectError} When required configuration data is missing\n */\nexport const getRouterConfig = async (client: BoltSuiClient): Promise<RouterConfig> => {\n /**\n * The Move function name in the router module that returns configuration.\n * This function signature in Move:\n * public fun config(router: &Router): RouterConfig\n */\n const CONFIG_FUNCTION = 'config';\n\n const response = await queryDevInspect(\n client.suiClient,\n [client.packageId, ROUTER_MODULE, CONFIG_FUNCTION],\n [client.contracts.router]\n );\n\n const output = parseDevInspectResult(response, RouterConfigStruct);\n\n return parseRouterConfigStructOutput(output);\n};\n","import { type SwapParams, type SwapResult } from '@bolt-liquidity-hq/core';\nimport type { SuiTransactionBlockResponse } from '@mysten/sui/client';\nimport type { Signer } from '@mysten/sui/cryptography';\n\nimport type { BoltSuiClient } from '../client';\n\n/**\n * Executes a token swap transaction on the Bolt protocol through the router contract.\n *\n * This function performs a \"swap exact in\" operation, where the user specifies exactly\n * how much of the input asset they want to swap, and receives a variable amount of the\n * output asset based on current pool conditions. The function handles transaction\n * signing, execution, and parsing of the results to return the actual amount received.\n *\n * @param client - The BoltSuiClient instance configured with the router contract address\n * @param signer - The offline signer that will authorize the swap transaction.\n * Must have sufficient balance of the input asset\n * @param params - The swap configuration parameters\n * @param params.assetIn - The denomination of the asset being sold (e.g., \"aarch\", \"ibc/...\")\n * @param params.amountIn - The exact amount of input asset to swap (as string, in minimal units)\n * @param params.assetOut - The denomination of the asset being bought (e.g., \"aarch\", \"ibc/...\")\n * @param params.minimumAmountOut - Optional minimum acceptable amount of output asset.\n * Transaction will revert if actual output is less\n * @param params.receiver - Optional recipient address for the swapped assets.\n * If not provided, defaults to the signer's address\n *\n * @returns A promise that resolves to a SwapResult containing:\n * - txOutput: The complete ExecuteResult from Sui\n * - txHash: The transaction hash for tracking\n * - amountOut: The actual amount of output asset received (as string)\n * - assetOut: The output asset denomination (echoes the input parameter)\n *\n * @throws {TransactionEventNotFoundError} Thrown when:\n * - No BOLT_SWAP_EVENT is found in transaction events (swap failed)\n * - No COIN_RECEIVED_EVENT is found after the swap event (output not received)\n * @throws Will also throw if:\n * - Signer has insufficient balance of the input asset\n * - Slippage exceeds minimumAmountOut (transaction reverts)\n * - Pool doesn't exist for the asset pair\n * - Network or contract execution errors occur\n */\nexport const swapExactIn = async (\n client: BoltSuiClient,\n signer: Signer,\n { assetIn, amountIn, assetOut, minimumAmountOut, receiver }: SwapParams\n): Promise<SwapResult<SuiTransactionBlockResponse>> => {\n // TODO: implement once we know we can successfully swap from the contracts\n console.log(client, signer, assetIn, amountIn, assetOut, minimumAmountOut, receiver);\n await new Promise((resolve) => setTimeout(resolve, 1000));\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-explicit-any\n return {} as any;\n // const signingSuiClient = await client.getSigningSuiClient(signer);\n\n // const address = await getSignerAddress(signer);\n\n // const txOutput = await signingSuiClient.execute(\n // address,\n // client.contracts.router,\n // {\n // swap_exact_in: {\n // want_out: assetOut,\n // minimum_base_out: minimumAmountOut,\n // receiver,\n // },\n // },\n // 'auto',\n // 'Swap using Bolt Typescript SDK',\n // [{ amount: amountIn, denom: assetIn }]\n // );\n\n // const boltSwapEventIndex = txOutput.events.findIndex(\n // (item) => item.type === BOLT_SWAP_EVENT_TYPE\n // );\n\n // if (boltSwapEventIndex === -1) {\n // throw new TransactionEventNotFoundError(\n // BOLT_SWAP_EVENT_TYPE,\n // 'After the transaction was executed, no successful swap event was emitted, the transaction may have failed'\n // );\n // }\n\n // let amountOut;\n\n // for (let i = boltSwapEventIndex + 1; i < txOutput.events.length; i++)\n // if (txOutput.events[i]?.type === BOLT_COIN_RECEIVED_EVENT_TYPE) {\n // const amountWithDenomOut = txOutput.events[i]?.attributes.find(\n // (attr) => attr.key === BOLT_COIN_RECEIVED_EVENT_AMOUNT_KEY\n // )?.value;\n\n // if (amountWithDenomOut) {\n // try {\n // amountOut = getCoinFromAmountWithDenomString(amountWithDenomOut).amount;\n // break;\n // } catch {\n // /* empty */\n // }\n // }\n // }\n\n // if (!amountOut) {\n // throw new TransactionEventNotFoundError(\n // BOLT_COIN_RECEIVED_EVENT_TYPE,\n // 'After the transaction was executed, no coin received event was emitted, the transaction may have failed'\n // );\n // }\n\n // return {\n // txOutput,\n // txHash: txOutput.transactionHash,\n // amountOut,\n // assetOut,\n // };\n};\n","import type { Address, PoolConfig } from '@bolt-liquidity-hq/core';\nimport { SUI_TYPE_ARG } from '@mysten/sui/utils';\n\nimport type { BoltSuiClient } from '../client';\nimport { POOL_MODULE } from '../constants';\nimport { parseMultipleResults, queryDevInspect } from '../helpers';\nimport { parseSettlementConfigStructOutput } from './parsers';\nimport { GetFeesResponseStruct, GetPoolInfoResponseStruct } from '../../types';\n\n/**\n * Retrieves the configuration settings for a settlement contract (liquidity pool).\n *\n * This function queries a settlement contract on the Sui blockchain to fetch its\n * current configuration parameters. Settlement contracts in Sui manage the actual\n * liquidity pool operations including swaps, fees, liquidity provider management,\n * and price oracle integration. This function combines two queries to get complete\n * pool information and fee structure.\n *\n * @param client - The BoltSuiClient instance\n * @param contractAddress - The Sui object ID of the settlement/pool contract to query\n * Must be a valid pool address obtained from router queries\n *\n * @returns A promise that resolves to a PoolConfig object containing:\n * - priceOracleContract: Object ID of the price oracle used by this pool\n * - protocolFeeRecipient: Sui address that receives protocol fees\n * - protocolFee: The protocol fee percentage (as decimal string, e.g., \"0.003\" = 0.3%)\n * - lpFee: The liquidity provider fee percentage (as decimal string, e.g., \"0.002\" = 0.2%)\n * - allowanceMode: The allowance mode for LP operations (\"public\" or \"restricted\")\n * - lps: Array of authorized liquidity provider Sui addresses\n * - minBaseOut: Minimum base asset output amount for trades (prevents dust)\n *\n * @throws {TransactionFailedError} When the settlement contract queries fail due to:\n * - Invalid settlement contract address\n * - Contract not properly initialized\n * - Network connectivity issues\n * - Incorrect type arguments for the pool\n * @throws {ParseError} When the responses cannot be parsed, indicating:\n * - Unexpected response format from either query\n * - BCS deserialization failure\n * - Missing required fields in the response\n */\nexport const getPoolInfo = async (\n client: BoltSuiClient,\n contractAddress: Address\n): Promise<PoolConfig> => {\n /**\n * Move function to get pool information including LP settings.\n * Function signature in Move:\n * public fun get_pool_info<T>(pool: &Pool<T>): GetPoolInfoResponse\n */\n const GET_POOL_INFO = 'get_pool_info';\n\n const GET_FEES_FUNCTION = 'get_fees';\n\n // Execute both queries in parallel for efficiency\n const [info, fees] = await Promise.all([\n // Query pool information (LP configuration, allowance mode)\n queryDevInspect(\n client.suiClient,\n [client.packageId, POOL_MODULE, GET_POOL_INFO],\n [contractAddress],\n // TODO: get the base token of the pool to pass it here instead of hardcoded SUI token\n [SUI_TYPE_ARG]\n ),\n // Query fee structure (protocol fee, LP fee, recipients)\n queryDevInspect(\n client.suiClient,\n [client.packageId, POOL_MODULE, GET_FEES_FUNCTION],\n [contractAddress],\n // TODO: get the base token of the pool to pass it here instead of hardcoded SUI token\n [SUI_TYPE_ARG]\n ),\n ]);\n\n const infoOutput = parseMultipleResults(info, GetPoolInfoResponseStruct);\n const feesOutput = parseMultipleResults(fees, GetFeesResponseStruct);\n\n return parseSettlementConfigStructOutput(infoOutput, feesOutput);\n};\n","import type { PoolConfig } from '@bolt-liquidity-hq/core';\n\nimport type { GetFeesResponseStructOutput, GetPoolInfoResponseStructOutput } from '../../types';\n\n/**\n * Parses raw pool information and fee responses from the Sui blockchain into a structured PoolConfig object.\n *\n * This function combines the responses from two separate Move function calls (`get_pool_info` and `get_fees`)\n * into a single PoolConfig object. It transforms the data from the Sui contract responses\n * into the standardized format used throughout the SDK. Currently, this function includes\n * hardcoded values as the Sui contracts are still being finalized.\n *\n * @param poolInfoOutput - The response from the `get_pool_info` Move function containing:\n * - LP configuration and allowance settings (currently not fully implemented)\n * @param feesOutput - The response from the `get_fees` Move function containing fee data as a tuple:\n * - [0]: Protocol fee as decimal string\n * - [1]: Protocol fee recipient (not currently used)\n * - [2]: LP fee as decimal string\n *\n * @returns A parsed PoolConfig object with:\n * - priceOracleContract: Object ID of the price oracle (currently hardcoded to \"0x\")\n * - protocolFeeRecipient: Address that receives protocol fees (currently hardcoded to \"0x\")\n * - protocolFee: The protocol fee percentage from feesOutput[0] (e.g., \"0.003\" = 0.3%)\n * - lpFee: The liquidity provider fee percentage from feesOutput[2] (e.g., \"0.002\" = 0.2%)\n * - allowanceMode: The allowance mode for pool operations (currently hardcoded to \"allow\")\n * - lps: Array of authorized LP addresses (currently hardcoded to [\"0x\"])\n * - minBaseOut: Minimum base asset output amount (currently hardcoded to \"1\")\n *\n * @example\n * ```typescript\n * // Example with actual data once contracts are complete\n * const poolInfoResponse: GetPoolInfoResponseStructOutput = [\n * \"restricted\", // allowance mode\n * [\"0xlp1...\", \"0xlp2...\"], // authorized LPs\n * \"0xoracle...\", // oracle address\n * \"1000000\" // min base out\n * ];\n *\n * const feesResponse: GetFeesResponseStructOutput = [\n * \"0.003\", // protocol fee (0.3%)\n * \"0xtreasury...\", // protocol fee recipient\n * \"0.002\" // LP fee (0.2%)\n * ];\n *\n * const config = parseSettlementConfigStructOutput(poolInfoResponse, feesResponse);\n * console.log(config.protocolFee); // \"0.003\" (0.3%)\n * console.log(config.lpFee); // \"0.002\" (0.2%)\n *\n * // Current implementation with hardcoded values\n * const currentConfig = parseSettlementConfigStructOutput([], [\"0.003\", \"0x\", \"0.002\"]);\n * console.log(currentConfig.priceOracleContract); // \"0x\" (hardcoded)\n * console.log(currentConfig.protocolFee); // \"0.003\" (from feesOutput)\n * console.log(currentConfig.lpFee); // \"0.002\" (from feesOutput)\n * ```\n *\n * @remarks\n * - **TODO**: This parser currently contains hardcoded values for several fields:\n * - `priceOracleContract`: Hardcoded to \"0x\" (should come from poolInfoOutput)\n * - `protocolFeeRecipient`: Hardcoded to \"0x\" (should come from feesOutput[1])\n * - `allowanceMode`: Hardcoded to \"allow\" (should come from poolInfoOutput)\n * - `lps`: Hardcoded to [\"0x\"] (should come from poolInfoOutput)\n * - `minBaseOut`: Hardcoded to \"1\" (should come from poolInfoOutput)\n * - The function currently only uses the fee data from the responses\n * - Once the Sui contracts are finalized, this parser will be updated to use all fields\n * - The hardcoded values are placeholders and should not be relied upon for production use\n * - Fee values are the only accurate data in the current implementation\n *\n * @see {@link PoolConfig} for the complete structure of pool configuration\n * @see {@link getPoolInfo} which calls this parser\n * @see {@link GetPoolInfoResponseStructOutput} for the expected pool info structure\n * @see {@link GetFeesResponseStructOutput} for the expected fees structure\n */\nexport const parseSettlementConfigStructOutput = (\n _poolInfoOutput: GetPoolInfoResponseStructOutput,\n feesOutput: GetFeesResponseStructOutput\n): PoolConfig => {\n // TODO: update when contracts are completed\n // Currently using hardcoded values for most fields except fees\n return {\n priceOracleContract: '0x', // Should come from poolInfoOutput\n protocolFeeRecipient: '0x', // Should be feesOutput[1]\n protocolFee: feesOutput[0], // Protocol fee percentage\n lpFee: feesOutput[2], // LP fee percentage\n allowanceMode: 'allow', // Should come from poolInfoOutput\n lps: ['0x'], // Should come from poolInfoOutput\n minBaseOut: '1', // Should come from poolInfoOutput\n };\n};\n","export const TEST_USDT =\n '0xda2075ce382224b79131a753483bee667a7cec24024c5f8cfc80887362be280f::test_usdt::TEST_USDT';\nexport const TEST_POOL = '0xdd05c1caea7b6725da3f67e30e99872033fc5d3a610a4f72ac1c434bc81c3c0d';\n","import type { PoolConfig } from '@bolt-liquidity-hq/core';\n\nimport type { BoltSuiClient } from '../client';\nimport { getPoolInfo } from './get-pool-info';\nimport { getPoolForBase } from '../router';\nimport { TEST_POOL } from '../../tests/constants';\n\n/**\n * Retrieves the configuration settings for a settlement contract (liquidity pool)\n * identified by its base asset type.\n *\n * This is a convenience function that combines pool lookup and configuration retrieval.\n * It first finds the pool/market associated with the given base asset, then fetches that\n * pool's configuration parameters from its settlement contract. In Sui, settlement\n * contracts manage the actual liquidity and trading logic for each pool.\n *\n * @param client - The BoltSuiClient instance\n * @param baseDenom - The type of the base asset in Sui format\n * (e.g., \"0x2::sui::SUI\", \"0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5::coin::COIN\")\n *\n * @returns A promise that resolves to a PoolConfig object containing:\n * - priceOracleContract: Object ID of the price oracle used by this pool\n * - protocolFeeRecipient: Sui address that receives protocol fees\n * - protocolFee: The protocol fee percentage (as decimal string, e.g., \"0.003\" = 0.3%)\n * - lpFee: The liquidity provider fee percentage (as decimal string, e.g., \"0.002\" = 0.2%)\n * - allowanceMode: The allowance mode for pool operations (controls LP permissions)\n * - lps: Array of authorized liquidity provider Sui addresses\n * - minBaseOut: Minimum base asset output amount for trades (prevents dust trades)\n *\n * @throws {NotFoundError} When no pool exists for the specified base asset\n * @throws {TransactionFailedError} When the contract queries fail due to:\n * - Invalid router or settlement contract addresses\n * - Network connectivity issues\n * - Contract not properly initialized\n * @throws {ParseError} When the configuration response cannot be parsed\n */\nexport const getPoolInfoForBase = async (\n client: BoltSuiClient,\n baseDenom: string\n): Promise<PoolConfig> => {\n // TODO: use only baseDenom from arguments when the pool has baseDenom instead of symbol as id\n // Currently hardcoding 'SUI' due to contract limitations\n const pool = await getPoolForBase(client, baseDenom && 'SUI');\n\n // TODO: remove fallback when pool has address value\n // Using TEST_POOL as fallback until pool addresses are properly returned\n return await getPoolInfo(client, pool.poolAddress || TEST_POOL);\n};\n"],"mappings":";;;;;AAiBA,SAAS,kBAAkB;AAC3B,SAAS,iBAAmD;;;ACfrD,IAAM,qBAAqC;AAAA,EAChD,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,aAAa;AACf;AAEO,IAAM,mBAA8B;AAAA,EACzC,QAAQ;AAAA,EACR,QAAQ;AACV;AAEO,IAAM,mBAA2B;AAEjC,IAAM,gBAA8B;AAAA,EACzC,iBAAiB;AAAA,IACf,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,SAAS;AAAA,IACT,OAAO;AAAA,IACP,UAAU;AAAA,IACV,MAAM;AAAA,IACN,aAAa;AAAA,EACf;AAAA,EACA,kFAAkF;AAAA,IAChF,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,SAAS;AAAA,IACT,OAAO;AAAA,IACP,UAAU;AAAA,IACV,MAAM;AAAA,IACN,aAAa;AAAA,EACf;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MAAM,eAAiC;AACrC,WAAO,MAAM,UAAgB,IAAI;AAAA,EACnC;AAAA;AAAA,EAGA,MAAM,kBAAyC;AAC7C,WAAO,MAAM,gBAAgB,IAAI;AAAA,EACnC;AAAA;AAAA,EAGA,MAAM,4BAA4E;AAChF,WAAO,MAAM,oBAAoB,IAAI;AAAA,EACvC;AAAA;AAAA,EAGA,MAAM,mBAAmB,SAAoD;AAC3E,WAAO,MAAM,oBAAoB,MAAM,OAAO;AAAA,EAChD;AAAA;AAAA,EAGA,MAAM,mBAAmB,WAAkC;AACzD,WAAO,MAAM,eAAe,MAAM,SAAS;AAAA,EAC7C;AAAA;AAAA,EAGA,MAAM,cAA+B;AACnC,WAAO,MAAM,SAAS,IAAI;AAAA,EAC5B;AAAA;AAAA,EAGA,MAAM,cAAc,qBAAkD;AACpE,WAAO,MAAM,YAAY,MAAM,mBAAmB;AAAA,EACpD;AAAA;AAAA,EAGA,MAAM,YAA8B;AAClC,WAAO,MAAM,UAAU,IAAI;AAAA,EAC7B;AAAA;AAAA,EAGA,MAAM,yBAAyB,WAAwC;AACrE,WAAO,MAAM,mBAAmB,MAAM,SAAS;AAAA,EACjD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA8BA,MAAM,KAAK,QAAgB,QAAsE;AAC/F,WAAO,MAAM,YAAY,MAAM,QAAQ,MAAM;AAAA,EAC/C;AACF;","names":["bcs","InvalidObjectError","InvalidObjectError","bcs","bcs","bcs","bcs","bcs","bcs","bcs","bcs","bcs","bcs","bcs","bcs","bcs","bcs","bcs","bcs","bcs","bcs","bcs","bcs"]}
package/package.json ADDED
@@ -0,0 +1,85 @@
1
+ {
2
+ "name": "@bolt-liquidity-hq/sui-client",
3
+ "version": "0.1.0-beta.10",
4
+ "description": "Typescript SDK to interact with Bolt Liquidity on Sui.",
5
+ "homepage": "",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/phi-labs-ltd/bolt-ts-sdk.git",
9
+ "directory": "packages/sui-client"
10
+ },
11
+ "keywords": [
12
+ "bolt-liquidity",
13
+ "blockchain",
14
+ "sui",
15
+ "defi",
16
+ "tooling",
17
+ "web3"
18
+ ],
19
+ "author": "Phi Labs (https://philabs.xyz)",
20
+ "contributors": [
21
+ "Elias Poroma (https://github.com/eliasmpw)"
22
+ ],
23
+ "license": "Apache-2.0",
24
+ "type": "module",
25
+ "main": "./dist/index.cjs",
26
+ "module": "./dist/index.js",
27
+ "types": "./dist/index.d.ts",
28
+ "exports": {
29
+ ".": {
30
+ "import": {
31
+ "types": "./dist/index.d.ts",
32
+ "default": "./dist/index.js"
33
+ },
34
+ "require": {
35
+ "types": "./dist/index.d.cts",
36
+ "default": "./dist/index.cjs"
37
+ }
38
+ }
39
+ },
40
+ "engines": {
41
+ "node": ">=18"
42
+ },
43
+ "publishConfig": {
44
+ "access": "public",
45
+ "registry": "https://registry.npmjs.org",
46
+ "provenance": true
47
+ },
48
+ "files": [
49
+ "dist",
50
+ "LICENSE",
51
+ "README.md"
52
+ ],
53
+ "dependencies": {
54
+ "@mysten/bcs": "^1.7.0",
55
+ "@mysten/sui": "^1.37.1",
56
+ "bignumber.js": "^9.3.1",
57
+ "@bolt-liquidity-hq/core": "0.1.0-beta.10"
58
+ },
59
+ "devDependencies": {},
60
+ "peerDependencies": {},
61
+ "peerDependenciesMeta": {},
62
+ "sideEffects": false,
63
+ "scripts": {
64
+ "build": "tsup",
65
+ "dev": "tsup --watch",
66
+ "test": "pnpm test:queries",
67
+ "test:watch": "pnpm test:queries:watch",
68
+ "test:all": "vitest run",
69
+ "test:all:watch": "vitest",
70
+ "test:queries": "vitest run src/tests/*.query.*.test.ts",
71
+ "test:queries:watch": "vitest src/tests/*.query.*.test.ts",
72
+ "test:txs": "vitest run src/tests/*.tx.*.test.ts",
73
+ "test:txs:watch": "vitest src/tests/*.tx.*.test.ts",
74
+ "test:coverage": "vitest run --coverage",
75
+ "lint": "eslint .",
76
+ "lint:fix": "eslint . --fix",
77
+ "format": "prettier --write . --ignore-path ../../.prettierignore",
78
+ "format:check": "prettier --check . --ignore-path ../../.prettierignore",
79
+ "typecheck": "tsc --noEmit",
80
+ "check-exports": "attw --pack .",
81
+ "size": "size-limit",
82
+ "docs:api": "typedoc",
83
+ "ci": "pnpm run lint && pnpm run format:check && pnpm run typecheck && pnpm run test && pnpm run build && pnpm run check-exports && pnpm run size"
84
+ }
85
+ }