Skip to content

Commit

Permalink
time spot price calc on mainnet
Browse files Browse the repository at this point in the history
  • Loading branch information
mrq1911 committed Oct 24, 2023
1 parent 57ff407 commit 09a1bf2
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/sdk/test/script/examples/router/timeSpotPrice.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {ApiPromise} from '@polkadot/api';
import {ApiUrl, PolkadotExecutor} from '../../executor';
import {PoolService} from '../../../../src/pool';
import {TradeRouter} from '../../../../src/api';
import {PoolType} from '../../../../src/types';

class GetBestSpotPriceExample extends PolkadotExecutor {
async script(api: ApiPromise): Promise<any> {
const poolService = new PoolService(api);
const router = new TradeRouter(poolService, { includeOnly: [PoolType.Omni, PoolType.Stable] });
let result;
console.time('Get best spot price with LBP 10x')
for (let i = 0; i < 10; i++) {
result = await router.getBestSpotPrice('5', '2');
}
console.timeEnd('Get best spot price with LBP 10x')
return result;
}
}

new GetBestSpotPriceExample(ApiUrl.HydraDx, 'Get best spot price', true).run();

0 comments on commit 09a1bf2

Please sign in to comment.