diff --git a/src/Orion/index.ts b/src/Orion/index.ts index b05cf36..8cc94b0 100644 --- a/src/Orion/index.ts +++ b/src/Orion/index.ts @@ -1,12 +1,13 @@ import { merge } from 'merge-anything'; -import { chains, envs } from '../config/index.js'; +import { chains, envs } from '../config'; import type { networkCodes } from '../constants/index.js'; import Unit from '../Unit/index.js'; -import { ReferralSystem } from '../services/ReferralSystem/index.js'; +import { ReferralSystem } from '../services/ReferralSystem'; import type { SupportedChainId, DeepPartial, VerboseUnitConfig, KnownEnv, EnvConfig, AggregatedAssets } from '../types.js'; import { isValidChainId } from '../utils/index.js'; import { simpleFetch } from 'simple-typed-fetch'; import Bridge from './bridge/index.js'; +import { Frontage } from '../services/Frontage'; export default class Orion { public readonly env?: string; @@ -17,6 +18,8 @@ export default class Orion { public readonly bridge: Bridge; + public readonly frontage: Frontage; + // TODO: get tradable assets (aggregated) // TODO: get tradable pairs (aggregated) @@ -35,6 +38,7 @@ export default class Orion { config = { analyticsAPI: envConfig?.analyticsAPI, referralAPI: envConfig.referralAPI, + frontageAPI: envConfig.frontageAPI, networks: Object.entries(envConfig.networks).map(([chainId, networkConfig]) => { if (!isValidChainId(chainId)) throw new Error(`Invalid chainId: ${chainId}`); const chainConfig = chains[chainId]; @@ -60,10 +64,7 @@ export default class Orion { }, indexer: { api: networkConfig.api + networkConfig.services.indexer?.http, - }, - frontage: { - http: networkConfig.api + networkConfig.services.frontage.http, - }, + } }, }; }) @@ -105,6 +106,8 @@ export default class Orion { this.bridge = new Bridge( this.unitsArray, ); + + this.frontage = new Frontage(config.frontageAPI); } get unitsArray() { diff --git a/src/Unit/index.ts b/src/Unit/index.ts index 69d781f..38f8e0e 100644 --- a/src/Unit/index.ts +++ b/src/Unit/index.ts @@ -2,7 +2,6 @@ import { JsonRpcProvider } from 'ethers'; import { Aggregator } from '../services/Aggregator'; import { BlockchainService } from '../services/BlockchainService'; import { PriceFeed } from '../services/PriceFeed'; -import { Frontage } from '../services/Frontage'; import type { KnownEnv, SupportedChainId, @@ -36,8 +35,6 @@ export default class Unit { public readonly priceFeed: PriceFeed; - public readonly frontage: Frontage; - public readonly exchange: Exchange; public readonly config: VerboseUnitConfig; @@ -90,10 +87,7 @@ export default class Unit { }, indexer: { api: networkConfig.api + networkConfig.services.indexer?.http, - }, - frontage: { - http: networkConfig.api + networkConfig.services.frontage.http, - }, + } }, }; } else { @@ -130,9 +124,6 @@ export default class Unit { this.config.services.priceFeed.api, this.config.basicAuth ); - this.frontage = new Frontage( - this.config.services.frontage.http - ); this.exchange = new Exchange(this); this.pmm = new Pmm(this); } diff --git a/src/config/envs.json b/src/config/envs.json index 0787b96..a2a180e 100644 --- a/src/config/envs.json +++ b/src/config/envs.json @@ -1,6 +1,7 @@ { "production": { "referralAPI": "https://trade.orion.xyz/referral-api", + "frontageAPI": "https://trade.orion.xyz/frontage", "networks": { "1": { "api": "https://trade.orion.xyz/eth-mainnet", @@ -17,9 +18,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage" } }, "liquidityMigratorAddress": "0x23a1820a47BcD022E29f6058a5FD224242F50D1A" @@ -39,9 +37,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage" } } }, @@ -60,9 +55,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage" } } }, @@ -81,9 +73,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage" } } }, @@ -102,9 +91,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage" } } }, @@ -123,9 +109,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage" } } }, @@ -144,9 +127,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage" } } }, @@ -165,9 +145,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage" } } }, @@ -186,9 +163,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage" } } }, @@ -207,9 +181,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage" } } } @@ -217,6 +188,7 @@ }, "testing": { "referralAPI": "https://testing.orion.xyz/referral-api", + "frontageAPI": "https://testing.orion.xyz/frontage", "networks": { "97": { "api": "https://testing.orion.xyz/bsc-testnet", @@ -233,9 +205,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage" } }, "liquidityMigratorAddress": "0x01b10dds12478C88A5E18e2707E729906bC25CfF6" @@ -255,9 +224,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage" } } }, @@ -276,9 +242,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage" } } }, @@ -297,9 +260,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage" } } }, @@ -318,9 +278,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage" } } }, @@ -339,9 +296,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage" } } } @@ -349,6 +303,7 @@ }, "staging": { "referralAPI": "https://staging.orion.xyz/referral-api", + "frontageAPI": "https://staging.orion.xyz/frontage", "networks": { "1": { "api": "https://staging.orion.xyz/eth-mainnet", @@ -365,9 +320,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage" } } }, @@ -386,9 +338,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage" } } }, @@ -407,9 +356,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage" } } }, @@ -428,9 +374,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage" } } }, @@ -449,9 +392,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage" } } }, @@ -470,9 +410,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage" } } }, @@ -491,9 +428,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage" } } }, @@ -512,9 +446,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage" } } }, @@ -533,9 +464,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage" } } }, @@ -554,9 +482,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage" } } } @@ -564,6 +489,7 @@ }, "experimental": { "referralAPI": "https://testing.orion.xyz/referral-api", + "frontageAPI": "https://testing.orion.xyz/frontage", "networks": { "97": { "api": "https://dn-dev.orion.xyz/bsc-testnet", @@ -580,9 +506,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage" } } }, @@ -601,9 +524,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage" } } } @@ -611,6 +531,7 @@ }, "kucoin-production": { "referralAPI": "https://trade.orion.xyz/referral-api", + "frontageAPI": "https://trade.orion.xyz/frontage", "networks": { "1": { "api": "https://trade.orion.xyz/eth-mainnet", @@ -627,9 +548,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage" } }, "liquidityMigratorAddress": "0x23a1820a47BcD022E29f6058a5FD224242F50D1A" @@ -649,9 +567,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage" } } }, @@ -670,9 +585,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage" } } }, @@ -691,9 +603,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage" } } }, @@ -712,9 +621,6 @@ }, "indexer": { "http": "/orion-indexer/" - }, - "frontage": { - "http": "/frontage" } } } diff --git a/src/config/schemas/pureEnvSchema.ts b/src/config/schemas/pureEnvSchema.ts index 31f503c..8f414be 100644 --- a/src/config/schemas/pureEnvSchema.ts +++ b/src/config/schemas/pureEnvSchema.ts @@ -16,10 +16,7 @@ export const pureEnvNetworksSchema = z.object({ }), indexer: z.object({ http: z.string(), - }).optional(), - frontage: z.object({ - http: z.string(), - }), + }).optional() }), rpc: z.string().optional(), liquidityMigratorAddress: z.string().optional(), @@ -28,6 +25,7 @@ export const pureEnvNetworksSchema = z.object({ export const pureEnvPayloadSchema = z.object({ analyticsAPI: z.string().url().optional(), referralAPI: z.string().url(), + frontageAPI: z.string().url(), networks: z.record( z.nativeEnum(SupportedChainId), pureEnvNetworksSchema diff --git a/src/types.ts b/src/types.ts index f5cc59d..7cf26f1 100644 --- a/src/types.ts +++ b/src/types.ts @@ -272,12 +272,6 @@ export type VerboseUnitConfig = { // http://localhost:3004/, // http:// } | undefined - frontage: { - http: string - // For example: - // http://localhost:3004/, - // http:// - } } basicAuth?: BasicAuthCredentials } @@ -289,6 +283,7 @@ export type Json = string | number | boolean | null | Json[] | { [key: string]: export type EnvConfig = { analyticsAPI: string | undefined referralAPI: string + frontageAPI: string networks: Partial< Record< SupportedChainId,