From f4f2d0ba3c2f807e470571ed8f9dc456d23ed8c5 Mon Sep 17 00:00:00 2001 From: Mikhail Gladchenko Date: Tue, 16 Jan 2024 08:30:44 +0000 Subject: [PATCH] feat: added chains for old SDK for OB --- package.json | 2 +- src/config/chains.json | 41 ++++++++++--- src/config/envs.json | 105 ++++++++++++++++++++++++++++++++++ src/constants/chains.ts | 2 + src/constants/networkCodes.ts | 2 +- src/types.ts | 21 +++++-- 6 files changed, 159 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 6f7421e..74f16d3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@orionprotocol/sdk", - "version": "0.19.92-rc105", + "version": "0.19.92-rc106", "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 33b7724..ea887a8 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": { @@ -77,6 +89,19 @@ "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 +124,8 @@ "rpc": "https://rpcapi.fantom.network/", "baseCurrencyName": "FTM", "contracts": { - "WETH": "", - "curveRegistry": "" + "WETH": "0x21be370D5312f44cB42ce377BC9b8a0cEF1A4C83", + "curveRegistry": "0x0f854EA9F38ceA4B1c2FC79047E9D0134419D5d6" } }, "137": { @@ -112,8 +137,8 @@ "rpc": "https://polygon-rpc.com/", "explorer": "https://polygonscan.com/", "contracts": { - "WETH": "", - "curveRegistry": "" + "WETH": "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270", + "curveRegistry": "0x094d12e5b541784701FD8d65F11fc0598FBC6332" } }, "80001": { @@ -138,7 +163,7 @@ "rpc": "https://exchainrpc.okex.org/", "baseCurrencyName": "OKT", "contracts": { - "WETH": "", + "WETH": "0x843340759bFCa4a3776F401cD2E03fE9bc0d838f", "curveRegistry": "" } }, @@ -161,7 +186,7 @@ "shortName": "DRIP Chain", "code": "drip", "baseCurrencyName": "DRIP", - "rpc": "testnet.1d.rip", + "rpc": "https://testnet.1d.rip/", "explorer": "https://explorer-testnet.1d.rip/", "contracts": { "WETH": "", diff --git a/src/config/envs.json b/src/config/envs.json index 1c193bf..8672516 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,6 +88,45 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" + } + } + }, + "42161": { + "api": "https://trade.orion.xyz/arbitrum-mainnet", + "services": { + "aggregator": { + "http": "/backend", + "ws": "/v1" + }, + "blockchain": { + "http": "" + }, + "priceFeed": { + "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" + } + } + }, + "204": { + "api": "https://trade.orion.xyz/opbnb-mainnet", + "services": { + "aggregator": { + "http": "/backend", + "ws": "/v1" + }, + "blockchain": { + "http": "" + }, + "priceFeed": { + "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } } } @@ -97,6 +148,9 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } }, "liquidityMigratorAddress": "0x01b10dds12478C88A5E18e2707E729906bC25CfF6" @@ -113,6 +167,9 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } } }, @@ -128,6 +185,9 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } } }, @@ -143,6 +203,9 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } } }, @@ -158,6 +221,9 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } } }, @@ -173,6 +239,9 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } } } @@ -194,6 +263,9 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } } }, @@ -209,6 +281,9 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } } }, @@ -224,6 +299,9 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } } }, @@ -239,6 +317,9 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } } }, @@ -254,6 +335,9 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } } } @@ -275,6 +359,9 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } } }, @@ -290,6 +377,9 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } } } @@ -311,6 +401,9 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } }, "liquidityMigratorAddress": "0x23a1820a47BcD022E29f6058a5FD224242F50D1A" @@ -327,6 +420,9 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } } }, @@ -342,6 +438,9 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } } }, @@ -357,6 +456,9 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } } }, @@ -372,6 +474,9 @@ }, "priceFeed": { "all": "/price-feed" + }, + "indexer": { + "http": "/orion-indexer/" } } } diff --git a/src/constants/chains.ts b/src/constants/chains.ts index 790a42d..74135ed 100644 --- a/src/constants/chains.ts +++ b/src/constants/chains.ts @@ -15,4 +15,6 @@ export const productionChains = [ SupportedChainId.FANTOM_OPERA, SupportedChainId.POLYGON, SupportedChainId.OKC, + SupportedChainId.ARBITRUM, + SupportedChainId.OPBNB, ]; diff --git a/src/constants/networkCodes.ts b/src/constants/networkCodes.ts index 75fe8ee..d04ac04 100644 --- a/src/constants/networkCodes.ts +++ b/src/constants/networkCodes.ts @@ -1 +1 @@ -export default ['ftm', 'bsc', 'eth', 'polygon', 'okc', 'arb', 'drip'] as const; +export default ['ftm', 'bsc', 'eth', 'polygon', 'okc', 'arb', 'drip', 'opbnb'] as const; diff --git a/src/types.ts b/src/types.ts index 6f3afc4..4685276 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,5 +1,5 @@ /* 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'; @@ -48,7 +48,6 @@ export type Order = { nonce: number // uint64 expiration: number // uint64 buySide: 0 | 1 // uint8, 1=buy, 0=sell - isPersonalSign: boolean // bool } export type SignedOrder = { @@ -60,7 +59,6 @@ export type SignedOrder = { export type CancelOrderRequest = { id: number | string senderAddress: string - isPersonalSign: boolean } export type SignedCancelOrderRequest = { @@ -85,10 +83,11 @@ export enum SupportedChainId { MAINNET = '1', ROPSTEN = '3', GOERLI = '5', - ARBITRUM_GOERLI = '421613', + ARBITRUM = '42161', FANTOM_OPERA = '250', POLYGON = '137', OKC = '66', + OPBNB = '204', POLYGON_TESTNET = '80001', FANTOM_TESTNET = '4002', @@ -96,6 +95,7 @@ export enum SupportedChainId { BSC_TESTNET = '97', OKC_TESTNET = '65', DRIP_TESTNET = '56303', + ARBITRUM_GOERLI = '421613', // For testing and debug purpose // BROKEN = '0', @@ -199,6 +199,13 @@ export type SwapInfoBase = { } | undefined alternatives: SwapInfoAlternative[] assetsNameMapping?: Partial> | undefined + usdInfo: { + availableAmountIn: number | undefined + availableAmountOut: number | undefined + marketAmountOut: number | undefined + marketAmountIn: number | undefined + difference: string | undefined + } | undefined } export type SwapInfoByAmountIn = SwapInfoBase & { @@ -255,6 +262,12 @@ export type VerboseUnitConfig = { // http://10.23.5.11:3003/, // https://price-feed:3003/ } + indexer: { + api: string + // For example: + // http://localhost:3004/, + // http:// + } } basicAuth?: BasicAuthCredentials }