Skip to content

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
nohaapav committed Sep 23, 2023
1 parent 98d3b55 commit 39af2fd
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 17 deletions.
4 changes: 2 additions & 2 deletions packages/sdk/test/script/examples/router/getAllAssets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { PoolType } from '../../../../src/types';
class GetAllAssetsExample extends PolkadotExecutor {
async script(api: ApiPromise): Promise<any> {
const poolService = new PoolService(api);
const router = new TradeRouter(poolService, { includeOnly: [PoolType.XYK] });
const router = new TradeRouter(poolService, { includeOnly: [PoolType.Omni, PoolType.Stable, PoolType.LBP] });
return router.getAllAssets();
}
}

new GetAllAssetsExample(ApiUrl.Basilisk, 'Get all assets').run();
new GetAllAssetsExample(ApiUrl.HydraDx_Rococo, 'Get all assets').run();
4 changes: 2 additions & 2 deletions packages/sdk/test/script/examples/router/getAllPaths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { PoolType } from '../../../../src/types';
class GetAllPathsExample extends PolkadotExecutor {
async script(api: ApiPromise): Promise<any> {
const poolService = new PoolService(api);
const router = new TradeRouter(poolService, { includeOnly: [PoolType.XYK] });
const router = new TradeRouter(poolService, { includeOnly: [PoolType.Omni] });
return router.getAllPaths('1', '2');
}
}

new GetAllPathsExample(ApiUrl.Basilisk, 'Get all paths').run();
new GetAllPathsExample(ApiUrl.HydraDx_Rococo, 'Get all paths').run();
4 changes: 2 additions & 2 deletions packages/sdk/test/script/examples/router/getAssetPairs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { PoolType } from '../../../../src/types';
class GetAssetPairsExample extends PolkadotExecutor {
async script(api: ApiPromise): Promise<any> {
const poolService = new PoolService(api);
const router = new TradeRouter(poolService, { includeOnly: [PoolType.XYK] });
const router = new TradeRouter(poolService, { includeOnly: [PoolType.Omni] });
return router.getAssetPairs('1');
}
}

new GetAssetPairsExample(ApiUrl.Basilisk, 'Get asset pairs').run();
new GetAssetPairsExample(ApiUrl.HydraDx_Rococo, 'Get asset pairs').run();
4 changes: 2 additions & 2 deletions packages/sdk/test/script/examples/router/getBestBuy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import { PoolType } from '../../../../src/types';
class GetBestBuyPriceExample extends PolkadotExecutor {
async script(api: ApiPromise): Promise<any> {
const poolService = new PoolService(api);
const router = new TradeRouter(poolService, { includeOnly: [PoolType.XYK] });
const router = new TradeRouter(poolService, { includeOnly: [PoolType.Omni] });
const bestBuy = await router.getBestBuy('1', '2', 10);
const transaction = bestBuy.toTx(ZERO);
console.log('Transaction hash: ' + transaction.hex);
return bestBuy;
}
}

new GetBestBuyPriceExample(ApiUrl.Basilisk, 'Get best buy price', true).run();
new GetBestBuyPriceExample(ApiUrl.HydraDx_Rococo, 'Get best buy price', true).run();
4 changes: 2 additions & 2 deletions packages/sdk/test/script/examples/router/getBestSell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import { PoolType } from '../../../../src/types';
class GetBestSellPriceExample extends PolkadotExecutor {
async script(api: ApiPromise): Promise<any> {
const poolService = new PoolService(api);
const router = new TradeRouter(poolService, { includeOnly: [PoolType.XYK] });
const router = new TradeRouter(poolService, { includeOnly: [PoolType.Omni] });
const bestSell = await router.getBestSell('1', '14', 1);
const transaction = bestSell.toTx(ZERO);
console.log('Transaction hash: ' + transaction.hex);
return bestSell;
}
}

new GetBestSellPriceExample(ApiUrl.Basilisk, 'Get best sell price', true).run();
new GetBestSellPriceExample(ApiUrl.HydraDx_Rococo, 'Get best sell price', true).run();
6 changes: 3 additions & 3 deletions packages/sdk/test/script/examples/router/getBestSellOmni.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import { PoolType } from '../../../../src/types';
class GetBestSellPriceExample extends PolkadotExecutor {
async script(api: ApiPromise): Promise<any> {
const poolService = new PoolService(api);
const router = new TradeRouter(poolService, { includeOnly: [PoolType.Omni] });
const bestSell = await router.getBestSell('2', '5', '1');
const router = new TradeRouter(poolService, { includeOnly: [PoolType.Omni, PoolType.Stable] });
const bestSell = await router.getBestSell('15', '0', '1');
const transaction = bestSell.toTx(ZERO);
console.log('Transaction hash: ' + transaction.hex);
return bestSell;
}
}

new GetBestSellPriceExample(ApiUrl.HydraDx, 'Get best sell price (Omni)', true).run();
new GetBestSellPriceExample(ApiUrl.HydraDx_Rococo, 'Get best sell price (Omni)', true).run();
4 changes: 2 additions & 2 deletions packages/sdk/test/script/examples/router/getBestSpotPrice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ 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.XYK] });
const router = new TradeRouter(poolService, { includeOnly: [PoolType.Omni] });
return router.getBestSpotPrice('1', '14');
}
}

new GetBestSpotPriceExample(ApiUrl.Basilisk, 'Get best spot price', true).run();
new GetBestSpotPriceExample(ApiUrl.HydraDx_Rococo, 'Get best spot price', true).run();
6 changes: 4 additions & 2 deletions packages/sdk/test/script/examples/router/getPools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import { PoolType } from '../../../../src/types';
class GetAllAssetsExample extends PolkadotExecutor {
async script(api: ApiPromise): Promise<any> {
const poolService = new PoolService(api);
const router = new TradeRouter(poolService, { includeOnly: [PoolType.XYK] });
const router = new TradeRouter(poolService, { includeOnly: [PoolType.Omni, PoolType.LBP, PoolType.Stable] });
await router.getPools();

return router.getPools();
}
}

new GetAllAssetsExample(ApiUrl.Basilisk, 'Get pools', true).run();
new GetAllAssetsExample(ApiUrl.HydraDx_Rococo, 'Get pools', true).run();

0 comments on commit 39af2fd

Please sign in to comment.