Skip to content

Commit baa29cf

Browse files
committed
add frontage service and getAggregatedMetrics request
1 parent cf2fd88 commit baa29cf

File tree

11 files changed

+198
-14
lines changed

11 files changed

+198
-14
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@orionprotocol/sdk",
3-
"version": "0.20.73",
3+
"version": "0.20.74-rc100",
44
"description": "Orion Protocol SDK",
55
"main": "./lib/index.cjs",
66
"module": "./lib/index.js",

src/Orion/index.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@ import { chains, envs } from '../config/index.js';
33
import type { networkCodes } from '../constants/index.js';
44
import Unit from '../Unit/index.js';
55
import { ReferralSystem } from '../services/ReferralSystem/index.js';
6-
import type { SupportedChainId, DeepPartial, VerboseUnitConfig, KnownEnv, EnvConfig, AggregatedAssets } from '../types.js';
6+
import type {
7+
SupportedChainId,
8+
DeepPartial,
9+
VerboseUnitConfig,
10+
KnownEnv,
11+
EnvConfig,
12+
AggregatedAssets
13+
} from '../types.js';
714
import { isValidChainId } from '../utils/index.js';
815
import { simpleFetch } from 'simple-typed-fetch';
916
import Bridge from './bridge/index.js';
@@ -60,6 +67,9 @@ export default class Orion {
6067
},
6168
indexer: {
6269
api: networkConfig.api + networkConfig.services.indexer?.http,
70+
},
71+
frontage: {
72+
api: networkConfig.api + networkConfig.services.frontage.http,
6373
}
6474
},
6575
};
@@ -118,7 +128,7 @@ export default class Orion {
118128
if (!unit) {
119129
throw new Error(
120130
`Invalid network code: ${networkCodeOrChainId}. ` +
121-
`Available network codes: ${this.unitsArray.map((u) => u.networkCode).join(', ')}`);
131+
`Available network codes: ${this.unitsArray.map((u) => u.networkCode).join(', ')}`);
122132
}
123133
return unit;
124134
}
@@ -156,7 +166,7 @@ export default class Orion {
156166
const networks = chainIds.map((chainId) => chains[chainId]?.label).join(', ');
157167
console.error(
158168
`Asset found in Aggregator, but not in BlockchainService (base): ${baseAsset} (${pair}).` +
159-
` Networks: ${networks}`
169+
` Networks: ${networks}`
160170
);
161171
} else {
162172
tradableAggregatedAssets[baseAsset] = aggregatedBaseAsset;
@@ -166,7 +176,7 @@ export default class Orion {
166176
const networks = chainIds.map((chainId) => chains[chainId]?.label).join(', ');
167177
console.error(
168178
`Asset found in Aggregator, but not in BlockchainService (quote): ${quoteAsset} (${pair}).` +
169-
` Networks: ${networks}`
179+
` Networks: ${networks}`
170180
);
171181
} else {
172182
tradableAggregatedAssets[quoteAsset] = aggregatedQuoteAsset;
@@ -178,11 +188,11 @@ export default class Orion {
178188

179189
async getPairs(...params: Parameters<Unit['aggregator']['getPairsList']>) {
180190
const result: Partial<
181-
Record<
182-
string,
183-
SupportedChainId[]
184-
>
185-
> = {};
191+
Record<
192+
string,
193+
SupportedChainId[]
194+
>
195+
> = {};
186196

187197
await Promise.all(this.unitsArray.map(async (unit) => {
188198
const pairs = await simpleFetch(unit.aggregator.getPairsList)(...params);

src/Unit/index.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { JsonRpcProvider } from 'ethers';
22
import { Aggregator } from '../services/Aggregator';
33
import { BlockchainService } from '../services/BlockchainService';
44
import { PriceFeed } from '../services/PriceFeed';
5+
import { IndexerService } from '../services/Indexer';
6+
import { FrontageService } from '../services/Frontage';
57
import type {
68
KnownEnv,
79
SupportedChainId,
@@ -10,8 +12,7 @@ import type {
1012
import Exchange from './Exchange/index.js';
1113
import { chains, envs } from '../config';
1214
import type { networkCodes } from '../constants/index.js';
13-
import { IndexerService } from '../services/Indexer';
14-
import Pmm from "./Pmm";
15+
import Pmm from './Pmm';
1516

1617
type KnownConfig = {
1718
env: KnownEnv
@@ -29,6 +30,8 @@ export default class Unit {
2930

3031
public readonly indexer: IndexerService | undefined;
3132

33+
public readonly frontage: FrontageService | undefined;
34+
3235
public readonly aggregator: Aggregator;
3336

3437
public readonly pmm: Pmm;
@@ -88,6 +91,9 @@ export default class Unit {
8891
indexer: {
8992
api: networkConfig.api + networkConfig.services.indexer?.http,
9093
},
94+
frontage: {
95+
api: networkConfig.api + networkConfig.services.frontage?.http,
96+
},
9197
},
9298
};
9399
} else {
@@ -115,6 +121,9 @@ export default class Unit {
115121
intNetwork
116122
)
117123
: undefined;
124+
this.frontage = new FrontageService(
125+
this.config.services.frontage.api,
126+
);
118127
this.aggregator = new Aggregator(
119128
this.config.services.aggregator.http,
120129
this.config.services.aggregator.ws,

0 commit comments

Comments
 (0)