diff --git a/package-lock.json b/package-lock.json index 66f5474f..4fcabae6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@orionprotocol/sdk", - "version": "0.19.91", + "version": "0.19.92-rc121", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@orionprotocol/sdk", - "version": "0.19.91", + "version": "0.19.92-rc121", "hasInstallScript": true, "license": "ISC", "dependencies": { diff --git a/package.json b/package.json index 6f7421eb..75882f54 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@orionprotocol/sdk", - "version": "0.19.92-rc105", + "version": "0.19.92-rc123", "description": "Orion Protocol SDK", "main": "./lib/index.cjs", "module": "./lib/index.js", diff --git a/src/config/chains.json b/src/config/chains.json index 33b77242..f807ce15 100644 --- a/src/config/chains.json +++ b/src/config/chains.json @@ -18,7 +18,7 @@ "label": "BNB Chain", "shortName": "BSC", "code": "bsc", - "rpc": "https://bsc-dataseed.binance.org/", + "rpc": "https://bsc-dataseed.bnbchain.org/", "baseCurrencyName": "BNB", "contracts": { "WETH": "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c", @@ -35,7 +35,19 @@ "baseCurrencyName": "BNB", "contracts": { "WETH": "0x23eE96bEaAB62abE126AA192e677c52bB7d274F0", - "curveRegistry": "0x8845b36C3DE93379F468590FFa102D4aF8C49A6c" + "curveRegistry": "0x93461072c00b2740c474a3d52c70be6249c802d8" + } + }, + "204": { + "chainId": "204", + "explorer": "http://opbnbscan.com/", + "label": "opBNB Chain", + "shortName": "opBNB", + "code": "opbnb", + "rpc": "https://opbnb-mainnet-rpc.bnbchain.org", + "baseCurrencyName": "BNB", + "contracts": { + "WETH": "0x4200000000000000000000000000000000000006" } }, "3": { @@ -64,19 +76,71 @@ "curveRegistry": "" } }, - "421613": { - "chainId": "421613", - "explorer": "https://goerli.arbiscan.io/", - "label": "Arbitrum Goerli", - "shortName": "Arbitrum Goerli", - "code": "arb", - "rpc": "https://goerli-rollup.arbitrum.io/rpc", + "11155111": { + "chainId": "11155111", + "explorer": "https://sepolia.etherscan.io/", + "label": "Sepolia", + "shortName": "ETH-Sepolia", + "code": "eth", + "rpc": "https://gateway.tenderly.co/public/sepolia", "baseCurrencyName": "ETH", "contracts": { "WETH": "", "curveRegistry": "" } }, + "123420000034": { + "chainId": "123420000034", + "explorer": "https://blockscout-123420000034.raas-testnet.gelato.digital/", + "label": "Event Horizon Testnet", + "shortName": "EH-Testnet", + "code": "eth", + "rpc": "https://rpc-123420000034.raas-testnet.gelato.digital/", + "baseCurrencyName": "ETH", + "contracts": { + "WETH": "0x4200000000000000000000000000000000000006", + "curveRegistry": "" + } + }, + "1952959480": { + "chainId": "1952959480", + "explorer": "https://testnet-explorer.lumia.org/", + "label": "Lumia Testnet", + "shortName": "Lumia Testnet", + "code": "lumia", + "rpc": "https://testnet-rpc.lumia.org", + "baseCurrencyName": "LUMIA", + "contracts": { + "WETH": "0x1a1aF9C78704D3a0Ab9e031C92E7bd808711A582", + "curveRegistry": "" + } + }, + "994873017": { + "chainId": "994873017", + "explorer": "https://explorer.lumia.org/", + "label": "Lumia", + "shortName": "Lumia", + "code": "lumia", + "rpc": "https://mainnet-rpc.lumia.org/", + "baseCurrencyName": "LUMIA", + "contracts": { + "WETH": "0xE891B5EE2F52E312038710b761EC165792AD25B1", + "curveRegistry": "" + } + }, + "42161": { + "chainId": "42161", + "explorer": "https://arbiscan.io/", + "label": "Arbitrum", + "shortName": "Arbitrum", + "code": "arb", + "rpc": "https://arb1.arbitrum.io/rpc", + "baseCurrencyName": "ARB", + "contracts": { + "WETH": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1", + "curveRegistiry": "0x445FE580eF8d70FF569aB36e80c647af338db351" + } + }, "4002": { "chainId": "4002", "explorer": "https://testnet.ftmscan.com/", @@ -99,8 +163,8 @@ "rpc": "https://rpcapi.fantom.network/", "baseCurrencyName": "FTM", "contracts": { - "WETH": "", - "curveRegistry": "" + "WETH": "0x21be370D5312f44cB42ce377BC9b8a0cEF1A4C83", + "curveRegistry": "0x0f854EA9F38ceA4B1c2FC79047E9D0134419D5d6" } }, "137": { @@ -112,8 +176,8 @@ "rpc": "https://polygon-rpc.com/", "explorer": "https://polygonscan.com/", "contracts": { - "WETH": "", - "curveRegistry": "" + "WETH": "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270", + "curveRegistry": "0x094d12e5b541784701FD8d65F11fc0598FBC6332" } }, "80001": { @@ -138,7 +202,7 @@ "rpc": "https://exchainrpc.okex.org/", "baseCurrencyName": "OKT", "contracts": { - "WETH": "", + "WETH": "0x843340759bFCa4a3776F401cD2E03fE9bc0d838f", "curveRegistry": "" } }, @@ -161,11 +225,83 @@ "shortName": "DRIP Chain", "code": "drip", "baseCurrencyName": "DRIP", - "rpc": "testnet.1d.rip", + "rpc": "https://testnet.1d.rip/", "explorer": "https://explorer-testnet.1d.rip/", "contracts": { "WETH": "", "curveRegistry": "" } + }, + "2525": { + "chainId": "2525", + "label": "inEVM", + "shortName": "inEVM", + "code": "inevm", + "baseCurrencyName": "INJ", + "rpc": "https://inevm.calderachain.xyz/http/", + "explorer": "https://explorer.injective.network/", + "contracts": { + "WETH": "0x4C3A213bd5e8c4BD70a8396d6F3C8302571598Cd", + "curveRegistry": "" + } + }, + "59144": { + "chainId": "59144", + "label": "Linea", + "shortName": "Linea", + "code": "linea", + "baseCurrencyName": "ETH", + "rpc": "https://rpc.linea.build/", + "explorer": "https://lineascan.build/", + "contracts": { + "WETH": "0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f", + "curveRegistry": "" + } + }, + "43114": { + "chainId": "43114", + "label": "Avalanche Network", + "shortName": "Avax", + "code": "avax", + "baseCurrencyName": "AVAX", + "rpc": "https://api.avax.network/ext/bc/C/rpc/", + "explorer": "https://snowtrace.io/", + "contracts": { + "WETH": "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7", + "curveRegistry": "" + } + }, + "8453": { + "chainId": "8453", + "label": "Base", + "shortName": "BASE", + "code": "base", + "baseCurrencyName": "ETH", + "rpc": "https://mainnet.base.org/", + "explorer": "https://basescan.org/", + "contracts": { + "WETH": "0x4200000000000000000000000000000000000006", + "curveRegistry": "" + } + }, + "4398026970692": { + "chainId": "4398026970692", + "explorer": "https://testnet.tonscan.org/", + "label": "TON Testnet", + "shortName": "TON Testnet", + "code": "tonTestnet", + "rpc": "https://testnet-v4.tonhubapi.com", + "baseCurrencyName": "TON", + "contracts": {} + }, + "4398026970693": { + "chainId": "4398026970693", + "explorer": "https://tonscan.org/", + "label": "TON Mainnet", + "shortName": "TON Mainnet", + "code": "ton", + "rpc": "https://mainnet-v4.tonhubapi.com", + "baseCurrencyName": "TON", + "contracts": {} } } diff --git a/src/config/envs.json b/src/config/envs.json index 1c193bfb..36ea4b34 100644 --- a/src/config/envs.json +++ b/src/config/envs.json @@ -15,6 +15,9 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } }, "liquidityMigratorAddress": "0x23a1820a47BcD022E29f6058a5FD224242F50D1A" @@ -31,6 +34,9 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } } }, @@ -46,6 +52,9 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } } }, @@ -61,6 +70,9 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } } }, @@ -76,17 +88,14 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } } - } - } - }, - "testing": { - "analyticsAPI": "https://trade.orion.xyz/api/stats", - "referralAPI": "https://testing.orion.xyz/referral-api", - "networks": { - "97": { - "api": "https://testing.orion.xyz/bsc-testnet", + }, + "42161": { + "api": "https://trade.orion.xyz/arbitrum-one", "services": { "aggregator": { "http": "/backend", @@ -97,12 +106,14 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } - }, - "liquidityMigratorAddress": "0x01b10dds12478C88A5E18e2707E729906bC25CfF6" + } }, - "5": { - "api": "https://testing.orion.xyz/eth-goerli", + "204": { + "api": "https://trade.orion.xyz/opbnb-mainnet", "services": { "aggregator": { "http": "/backend", @@ -113,11 +124,14 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } } }, - "421613": { - "api": "https://testing.orion.xyz/arbitrum-goerli", + "2525": { + "api": "https://trade.orion.xyz/inevm-mainnet", "services": { "aggregator": { "http": "/backend", @@ -128,11 +142,14 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } } }, - "4002": { - "api": "https://testing.orion.xyz/ftm-testnet", + "59144": { + "api": "https://trade.orion.xyz/linea-mainnet", "services": { "aggregator": { "http": "/backend", @@ -143,11 +160,14 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } } }, - "80001": { - "api": "https://testing.orion.xyz/polygon-mumbai", + "43114": { + "api": "https://trade.orion.xyz/avalanche-c-chain", "services": { "aggregator": { "http": "/backend", @@ -158,11 +178,14 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } } }, - "56303": { - "api": "https://testing.orion.xyz/drip-testnet", + "8453": { + "api": "https://trade.orion.xyz/base-mainnet", "services": { "aggregator": { "http": "/backend", @@ -173,6 +196,144 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" + } + } + }, + "994873017": { + "api": "https://staging.electra.finance/lumia-mainnet", + "services": { + "aggregator": { + "http": "/backend", + "ws": "/v1" + }, + "blockchain": { + "http": "" + }, + "priceFeed": { + "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" + } + } + }, + "4398026970693": { + "api": "https://app.electra.trade/lumia-mainnet", + "rpc": "https://mainnet-v4.tonhubapi.com", + "services": { + "aggregator": { + "http": "/backend", + "ws": "/v1" + }, + "blockchain": { + "http": "" + }, + "priceFeed": { + "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" + } + } + } + } + }, + "testing": { + "analyticsAPI": "https://trade.orion.xyz/api/stats", + "referralAPI": "https://testing.orion.xyz/referral-api", + "networks": { + "97": { + "api": "https://testing.orion.xyz/bsc-testnet", + "services": { + "aggregator": { + "http": "/backend", + "ws": "/v1" + }, + "blockchain": { + "http": "" + }, + "priceFeed": { + "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" + } + }, + "liquidityMigratorAddress": "0x01b10dds12478C88A5E18e2707E729906bC25CfF6" + }, + "11155111": { + "api": "https://testing.orion.xyz/eth-sepolia", + "services": { + "aggregator": { + "http": "/backend", + "ws": "/v1" + }, + "blockchain": { + "http": "" + }, + "priceFeed": { + "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" + } + } + }, + "123420000034": { + "api": "https://testing.orion.xyz/event-horizon-testnet", + "services": { + "aggregator": { + "http": "/backend", + "ws": "/v1" + }, + "blockchain": { + "http": "" + }, + "priceFeed": { + "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" + } + } + }, + "1952959480": { + "api": "https://testing.orion.xyz/lumia-testnet", + "services": { + "aggregator": { + "http": "/backend", + "ws": "/v1" + }, + "blockchain": { + "http": "" + }, + "priceFeed": { + "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" + } + } + }, + "4398026970692": { + "api": "https://app.electra.trade/lumia-testnet", + "rpc": "https://testnet-v4.tonhubapi.com", + "services": { + "aggregator": { + "http": "/backend", + "ws": "/v1" + }, + "blockchain": { + "http": "" + }, + "priceFeed": { + "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } } } @@ -194,6 +355,9 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } } }, @@ -209,6 +373,9 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } } }, @@ -224,6 +391,9 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } } }, @@ -239,6 +409,9 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } } }, @@ -254,6 +427,135 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" + } + } + }, + "42161": { + "api": "https://staging.orion.xyz/arbitrum-one", + "services": { + "aggregator": { + "http": "/backend", + "ws": "/v1" + }, + "blockchain": { + "http": "" + }, + "priceFeed": { + "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" + } + } + }, + "204": { + "api": "https://staging.orion.xyz/opbnb-mainnet", + "services": { + "aggregator": { + "http": "/backend", + "ws": "/v1" + }, + "blockchain": { + "http": "" + }, + "priceFeed": { + "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" + } + } + }, + "2525": { + "api": "https://staging.orion.xyz/inevm-mainnet", + "services": { + "aggregator": { + "http": "/backend", + "ws": "/v1" + }, + "blockchain": { + "http": "" + }, + "priceFeed": { + "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" + } + } + }, + "59144": { + "api": "https://staging.orion.xyz/linea-mainnet", + "services": { + "aggregator": { + "http": "/backend", + "ws": "/v1" + }, + "blockchain": { + "http": "" + }, + "priceFeed": { + "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" + } + } + }, + "43114": { + "api": "https://staging.orion.xyz/avalanche-c-chain", + "services": { + "aggregator": { + "http": "/backend", + "ws": "/v1" + }, + "blockchain": { + "http": "" + }, + "priceFeed": { + "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" + } + } + }, + "8453": { + "api": "https://staging.orion.xyz/base-mainnet", + "services": { + "aggregator": { + "http": "/backend", + "ws": "/v1" + }, + "blockchain": { + "http": "" + }, + "priceFeed": { + "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" + } + } + }, + "994873017": { + "api": "https://staging.electra.finance/lumia-mainnet", + "services": { + "aggregator": { + "http": "/backend", + "ws": "/v1" + }, + "blockchain": { + "http": "" + }, + "priceFeed": { + "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } } } @@ -275,6 +577,9 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } } }, @@ -290,6 +595,9 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } } } @@ -311,6 +619,9 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } }, "liquidityMigratorAddress": "0x23a1820a47BcD022E29f6058a5FD224242F50D1A" @@ -327,6 +638,9 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } } }, @@ -342,6 +656,9 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } } }, @@ -357,6 +674,9 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } } }, @@ -372,6 +692,9 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } } } diff --git a/src/constants/chains.ts b/src/constants/chains.ts index 790a42da..5b716545 100644 --- a/src/constants/chains.ts +++ b/src/constants/chains.ts @@ -4,10 +4,14 @@ export const developmentChains = [ SupportedChainId.BSC_TESTNET, SupportedChainId.ROPSTEN, SupportedChainId.GOERLI, + SupportedChainId.SEPOLIA, SupportedChainId.ARBITRUM_GOERLI, SupportedChainId.FANTOM_TESTNET, SupportedChainId.POLYGON_TESTNET, SupportedChainId.OKC_TESTNET, + SupportedChainId.EVENT_HORIZON_TESTNET, + SupportedChainId.LUMIA_TESTNET, + SupportedChainId.TON_TESTNET, ]; export const productionChains = [ SupportedChainId.MAINNET, @@ -15,4 +19,12 @@ export const productionChains = [ SupportedChainId.FANTOM_OPERA, SupportedChainId.POLYGON, SupportedChainId.OKC, + SupportedChainId.ARBITRUM, + SupportedChainId.OPBNB, + SupportedChainId.INEVM, + SupportedChainId.LINEA, + SupportedChainId.AVAX, + SupportedChainId.BASE, + SupportedChainId.LUMIA, + SupportedChainId.TON, ]; diff --git a/src/constants/networkCodes.ts b/src/constants/networkCodes.ts index 75fe8ee4..bfc36a58 100644 --- a/src/constants/networkCodes.ts +++ b/src/constants/networkCodes.ts @@ -1 +1,17 @@ -export default ['ftm', 'bsc', 'eth', 'polygon', 'okc', 'arb', 'drip'] as const; +export default [ + 'ftm', + 'bsc', + 'eth', + 'polygon', + 'okc', + 'arb', + 'drip', + 'opbnb', + 'inevm', + 'linea', + 'avax', + 'base', + 'lumia', + 'ton', + 'tonTestnet', +] as const; diff --git a/src/constants/uppercasedNetworkCodes.ts b/src/constants/uppercasedNetworkCodes.ts index 8dc00e31..506cbf0c 100644 --- a/src/constants/uppercasedNetworkCodes.ts +++ b/src/constants/uppercasedNetworkCodes.ts @@ -1 +1,16 @@ -export default ['FTM', 'BSC', 'ETH', 'POLYGON', 'OKC', 'ARB'] as const; +export default [ + 'FTM', + 'BSC', + 'ETH', + 'POLYGON', + 'OKC', + 'ARB', + 'OPBNB', + 'INEVM', + 'LINEA', + 'AVAX', + 'BASE', + 'LUMIA', + 'TON', + 'TON_TESTNET', +] as const; diff --git a/src/types.ts b/src/types.ts index 6f3afc4a..cce91b71 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,101 +1,116 @@ /* eslint-disable @typescript-eslint/consistent-type-definitions */ -import factories from './constants/factories.js'; +import type factories from './constants/factories.js'; import type { BigNumber } from 'bignumber.js'; import type subOrderStatuses from './constants/subOrderStatuses.js'; import type positionStatuses from './constants/positionStatuses.js'; import type { knownEnvs } from './config/schemas/index.js'; import type getHistory from './Orion/bridge/getHistory.js'; -export type DeepPartial = T extends object ? { - [P in keyof T]?: DeepPartial; -} : T; +export type DeepPartial = T extends object + ? { + [P in keyof T]?: DeepPartial; + } + : T; export type AssetPairUpdate = { - minQty: number - pricePrecision: number -} + minQty: number; + pricePrecision: number; +}; export type SubOrder = { - pair: string - exchange: string - id: number - amount: number - settledAmount: number - price: number - status: typeof subOrderStatuses[number] - side: 'BUY' | 'SELL' - subOrdQty: number -} + pair: string; + exchange: string; + id: number; + amount: number; + settledAmount: number; + price: number; + status: (typeof subOrderStatuses)[number]; + side: 'BUY' | 'SELL'; + subOrdQty: number; +}; export type Balance = { - tradable: string - reserved: string - contract: string - wallet: string - allowance: string -} + tradable: string; + reserved: string; + contract: string; + wallet: string; + allowance: string; +}; -export type PositionStatus = typeof positionStatuses[number]; +export type PositionStatus = (typeof positionStatuses)[number]; export type Order = { - senderAddress: string // address - matcherAddress: string // address - baseAsset: string // address - quoteAsset: string // address - matcherFeeAsset: string // address - amount: number // uint64 - price: number // uint64 - matcherFee: number // uint64 - nonce: number // uint64 - expiration: number // uint64 - buySide: 0 | 1 // uint8, 1=buy, 0=sell - isPersonalSign: boolean // bool -} + senderAddress: string; // address + matcherAddress: string; // address + baseAsset: string; // address + quoteAsset: string; // address + matcherFeeAsset: string; // address + amount: number; // uint64 + price: number; // uint64 + matcherFee: number; // uint64 + nonce: number; // uint64 + expiration: number; // uint64 + buySide: 0 | 1; // uint8, 1=buy, 0=sell + isPersonalSign: boolean; // bool +}; export type SignedOrder = { - id: string // hash of Order (it's not part of order structure in smart-contract) - signature: string // bytes - needWithdraw?: boolean // bool (not supported yet by smart-contract) -} & Order + id: string; // hash of Order (it's not part of order structure in smart-contract) + signature: string; // bytes + needWithdraw?: boolean; // bool (not supported yet by smart-contract) +} & Order; export type CancelOrderRequest = { - id: number | string - senderAddress: string - isPersonalSign: boolean -} + id: number | string; + senderAddress: string; + isPersonalSign: boolean; +}; export type SignedCancelOrderRequest = { - id: number | string - senderAddress: string - signature: string -} & CancelOrderRequest + id: number | string; + senderAddress: string; + signature: string; +} & CancelOrderRequest; export type Pair = { - name: string - baseCurrency: string - quoteCurrency: string - lastPrice: string - openPrice: string - change24h: string - high: string - low: string - vol24h: string -} + name: string; + baseCurrency: string; + quoteCurrency: string; + lastPrice: string; + openPrice: string; + change24h: string; + high: string; + low: string; + vol24h: string; +}; export enum SupportedChainId { MAINNET = '1', - ROPSTEN = '3', - GOERLI = '5', - ARBITRUM_GOERLI = '421613', + ARBITRUM = '42161', FANTOM_OPERA = '250', POLYGON = '137', OKC = '66', + OPBNB = '204', + INEVM = '2525', + LINEA = '59144', + AVAX = '43114', + BASE = '8453', + LUMIA = '994873017', + ROPSTEN = '3', + GOERLI = '5', + SEPOLIA = '11155111', POLYGON_TESTNET = '80001', FANTOM_TESTNET = '4002', BSC = '56', BSC_TESTNET = '97', OKC_TESTNET = '65', DRIP_TESTNET = '56303', + ARBITRUM_GOERLI = '421613', + EVENT_HORIZON_TESTNET = '123420000034', + LUMIA_TESTNET = '1952959480', + + TON = '4398026970693', + TON_TESTNET = '4398026970692', // For testing and debug purpose // BROKEN = '0', @@ -103,115 +118,117 @@ export enum SupportedChainId { const balanceTypes = ['exchange', 'wallet'] as const; -export type Source = typeof balanceTypes[number]; +export type Source = (typeof balanceTypes)[number]; export type Asset = { - name: string - address: string -} + name: string; + address: string; +}; export type BalanceRequirement = { - readonly reason: string - readonly asset: Asset - readonly amount: string - readonly sources: Source[] - readonly spenderAddress?: string | undefined -} + readonly reason: string; + readonly asset: Asset; + readonly amount: string; + readonly sources: Source[]; + readonly spenderAddress?: string | undefined; +}; export type AggregatedBalanceRequirement = { - readonly asset: Asset - readonly sources: Source[] - readonly spenderAddress?: string | undefined - items: Partial> -} + readonly asset: Asset; + readonly sources: Source[]; + readonly spenderAddress?: string | undefined; + items: Partial>; +}; export type ApproveFix = { - readonly type: 'byApprove' - readonly targetAmount: BigNumber.Value - readonly spenderAddress: string -} + readonly type: 'byApprove'; + readonly targetAmount: BigNumber.Value; + readonly spenderAddress: string; +}; export type DepositFix = { - readonly type: 'byDeposit' - readonly amount: BigNumber.Value - readonly asset: string -} + readonly type: 'byDeposit'; + readonly amount: BigNumber.Value; + readonly asset: string; +}; type Fix = ApproveFix | DepositFix; export type BalanceIssue = { - readonly asset: Asset - readonly message: string - readonly sources: Source[] - readonly fixes?: Fix[] -} + readonly asset: Asset; + readonly message: string; + readonly sources: Source[]; + readonly fixes?: Fix[]; +}; // export type Exchange = typeof exchanges[number]; export type OrderbookItem = { - price: string - amount: string - exchanges: string[] + price: string; + amount: string; + exchanges: string[]; vob: Array<{ - side: 'BUY' | 'SELL' - pairName: string - }> -} + side: 'BUY' | 'SELL'; + pairName: string; + }>; +}; export type SwapInfoAlternative = { - exchanges: string[] - path: string[] - marketAmountOut?: number | undefined - marketAmountIn?: number | undefined - marketPrice: number - availableAmountIn?: number | undefined - availableAmountOut?: number | undefined -} + exchanges: string[]; + path: string[]; + marketAmountOut?: number | undefined; + marketAmountIn?: number | undefined; + marketPrice: number; + availableAmountIn?: number | undefined; + availableAmountOut?: number | undefined; +}; -export type Factory = typeof factories[number] +export type Factory = (typeof factories)[number]; export type SingleSwap = { - pool: string - assetIn: string - assetOut: string - factory: Factory -} + pool: string; + assetIn: string; + assetOut: string; + factory: Factory; +}; export type SwapInfoBase = { - swapRequestId: string - assetIn: string - assetOut: string - amountIn: number - amountOut: number - minAmountIn: number - minAmountOut: number - - path: string[] - exchangeContractPath: SingleSwap[] - exchanges?: string[] | undefined - poolOptimal: boolean - - price?: number | undefined - marketPrice?: number | undefined - orderInfo?: { - pair: string - side: 'BUY' | 'SELL' - amount: number - safePrice: number - } | undefined - alternatives: SwapInfoAlternative[] - assetsNameMapping?: Partial> | undefined -} + swapRequestId: string; + assetIn: string; + assetOut: string; + amountIn: number; + amountOut: number; + minAmountIn: number; + minAmountOut: number; + + path: string[]; + exchangeContractPath: SingleSwap[]; + exchanges?: string[] | undefined; + poolOptimal: boolean; + + price?: number | undefined; + marketPrice?: number | undefined; + orderInfo?: + | { + pair: string; + side: 'BUY' | 'SELL'; + amount: number; + safePrice: number; + } + | undefined; + alternatives: SwapInfoAlternative[]; + assetsNameMapping?: Partial> | undefined; +}; export type SwapInfoByAmountIn = SwapInfoBase & { - kind: 'exactSpend' - availableAmountIn?: number | undefined - marketAmountOut?: number | undefined -} + kind: 'exactSpend'; + availableAmountIn?: number | undefined; + marketAmountOut?: number | undefined; +}; export type SwapInfoByAmountOut = SwapInfoBase & { - kind: 'exactReceive' - marketAmountIn?: number | undefined - availableAmountOut?: number | undefined -} + kind: 'exactReceive'; + marketAmountIn?: number | undefined; + availableAmountOut?: number | undefined; +}; export type SwapInfo = SwapInfoByAmountIn | SwapInfoByAmountOut; @@ -223,107 +240,114 @@ export enum HistoryTransactionStatus { } export type BasicAuthCredentials = { - username: string - password: string -} + username: string; + password: string; +}; export type VerboseUnitConfig = { // env?: string; // api: string; - chainId: SupportedChainId - nodeJsonRpc: string + chainId: SupportedChainId; + nodeJsonRpc: string; services: { blockchainService: { - http: string + http: string; // For example: // http://localhost:3001/, // http://10.123.34.23:3001/, // https://blockchain:3001/ - } + }; aggregator: { - http: string - ws: string + http: string; + ws: string; // For example: // http://localhost:3002/, // http://10.34.23.5:3002/, // https://aggregator:3002/ - } + }; priceFeed: { - api: string + api: string; // For example: // http://localhost:3003/, // http://10.23.5.11:3003/, // https://price-feed:3003/ - } - } - basicAuth?: BasicAuthCredentials -} + }; + }; + basicAuth?: BasicAuthCredentials; +}; -export type KnownEnv = typeof knownEnvs[number]; +export type KnownEnv = (typeof knownEnvs)[number]; -export type Json = string | number | boolean | null | Json[] | { [key: string]: Json }; +export type Json = + | string + | number + | boolean + | null + | Json[] + | { [key: string]: Json }; export type EnvConfig = { - analyticsAPI: string - referralAPI: string - networks: Partial< - Record< - SupportedChainId, - VerboseUnitConfig - > - > -} + analyticsAPI: string; + referralAPI: string; + networks: Partial>; +}; export type AggregatedAssets = Partial< Record< string, Partial< - Record + Record< + SupportedChainId, + { + address: string; + } + > > > - >; +>; export type RedeemOrder = { - sender: string - receiver: string - asset: string - amount: number - expiration: number - secretHash: string - signature: string - claimReceiver: string -} + sender: string; + receiver: string; + asset: string; + amount: number; + expiration: number; + secretHash: string; + signature: string; + claimReceiver: string; +}; export interface AtomicSwapLocal { - secret: string - secretHash: string - walletAddress: string - env?: string | undefined - - sourceChainId?: SupportedChainId | undefined - targetChainId?: SupportedChainId | undefined - - amount?: string | undefined - assetName?: string | undefined - - liquidityMigrationTxHash?: string | undefined - lockTransactionHash?: string | undefined - refundTransactionHash?: string | undefined - - creationDate?: number | undefined - lockExpiration?: number | undefined - placingOrderError?: string | undefined - redeemSettlement?: { - type: 'own_tx' - } | { - type: 'orion_tx' - requestedAt?: number - result?: { - timestamp: number - value: 'success' | 'failed' - } - } | undefined + secret: string; + secretHash: string; + walletAddress: string; + env?: string | undefined; + + sourceChainId?: SupportedChainId | undefined; + targetChainId?: SupportedChainId | undefined; + + amount?: string | undefined; + assetName?: string | undefined; + + liquidityMigrationTxHash?: string | undefined; + lockTransactionHash?: string | undefined; + refundTransactionHash?: string | undefined; + + creationDate?: number | undefined; + lockExpiration?: number | undefined; + placingOrderError?: string | undefined; + redeemSettlement?: + | { + type: 'own_tx'; + } + | { + type: 'orion_tx'; + requestedAt?: number; + result?: { + timestamp: number; + value: 'success' | 'failed'; + }; + } + | undefined; } export enum TxStatus { @@ -351,71 +375,72 @@ export enum TxType { } export type TxDepositOrWithdrawPayload = { - type: TxType.DEPOSIT | TxType.WITHDRAW + type: TxType.DEPOSIT | TxType.WITHDRAW; data: { - asset: string - amount: string - } + asset: string; + amount: string; + }; }; export type TxSwapThroughOrionPoolPayload = { - type: TxType.SWAP_THROUGH_ORION_POOL + type: TxType.SWAP_THROUGH_ORION_POOL; data: { - side: 'buy' | 'sell' - assetIn: string - assetOut: string - amount: string - price: string - } + side: 'buy' | 'sell'; + assetIn: string; + assetOut: string; + amount: string; + price: string; + }; }; export type TxBridgePayload = { - type: TxType.BRIDGE_LOCK | TxType.BRIDGE_REDEEM | TxType.BRIDGE_REFUND + type: TxType.BRIDGE_LOCK | TxType.BRIDGE_REDEEM | TxType.BRIDGE_REFUND; data: { - secretHash: string - } -} + secretHash: string; + }; +}; export type TxLiquidityMigrationPayload = { - type: TxType.LIQUIDITY_MIGRATION + type: TxType.LIQUIDITY_MIGRATION; data: { - source: SupportedChainId - target: SupportedChainId - pair: string - pairAddress: string + source: SupportedChainId; + target: SupportedChainId; + pair: string; + pairAddress: string; assetA: { - amount: string - secretHash: string - secret: string - } + amount: string; + secretHash: string; + secret: string; + }; assetB: { - amount: string - secretHash: string - secret: string - } - expiration: number - env?: string - } -} + amount: string; + secretHash: string; + secret: string; + }; + expiration: number; + env?: string; + }; +}; export type TxRedeemTwoAtomicsPayload = { - type: TxType.REDEEM_TWO_ATOMICS + type: TxType.REDEEM_TWO_ATOMICS; data: { - secretHash1: string - secretHash2: string - } -} + secretHash1: string; + secretHash2: string; + }; +}; export type TransactionInfo = { - id?: string - status?: TxStatus - hash?: string - payload?: TxDepositOrWithdrawPayload - | TxSwapThroughOrionPoolPayload - | TxBridgePayload - | TxLiquidityMigrationPayload - | TxRedeemTwoAtomicsPayload -} + id?: string; + status?: TxStatus; + hash?: string; + payload?: + | TxDepositOrWithdrawPayload + | TxSwapThroughOrionPoolPayload + | TxBridgePayload + | TxLiquidityMigrationPayload + | TxRedeemTwoAtomicsPayload; +}; type BridgeHistory = Awaited>; @@ -423,21 +448,20 @@ type BridgeHistoryItem = NonNullable; export type AtomicSwap = Partial< Omit -> & Partial< - Omit -> & { - sourceChainId: SupportedChainId - targetChainId: SupportedChainId - lockExpiration: number - secretHash: string - walletAddress: string - secret?: string | undefined - - creationDate?: number | undefined - redeemExpired?: boolean | undefined - - lockTx?: TransactionInfo | undefined - redeemTx?: TransactionInfo | undefined - refundTx?: TransactionInfo | undefined - liquidityMigrationTx?: TransactionInfo | undefined -} +> & + Partial> & { + sourceChainId: SupportedChainId; + targetChainId: SupportedChainId; + lockExpiration: number; + secretHash: string; + walletAddress: string; + secret?: string | undefined; + + creationDate?: number | undefined; + redeemExpired?: boolean | undefined; + + lockTx?: TransactionInfo | undefined; + redeemTx?: TransactionInfo | undefined; + refundTx?: TransactionInfo | undefined; + liquidityMigrationTx?: TransactionInfo | undefined; + };