Skip to content

Commit

Permalink
RELEASE: Releasing 1 package(s)
Browse files Browse the repository at this point in the history
Releases:
  @galacticcouncil/[email protected]
  • Loading branch information
nohaapav committed Mar 14, 2024
1 parent e8072aa commit b2b6d55
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions packages/sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @galacticcouncil/sdk

## 1.1.12

### Patch Changes

- Fix asset client (runtime dyn reg. upgrade)

## 1.1.11

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@galacticcouncil/sdk",
"version": "1.1.11",
"version": "1.1.12",
"description": "Galactic off-chain routing & optimization of orders across pools for best price execution",
"author": "GalacticCouncil",
"repository": {
Expand Down
52 changes: 40 additions & 12 deletions packages/sdk/test/script/examples/router/setMultipaymentRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,48 @@ class MultiCurrencyPaymentRoutes extends PolkadotExecutor {
const poolService = new PoolService(api);
const router = new TradeRouter(poolService);
const [acceptedCurrencies, onchain] = await Promise.all([
api.query.multiTransactionPayment.acceptedCurrencies.keys().then(c => c.map(({ args: [currencyId] }) => currencyId.toString())),
api.query.router.routes.entries().then(r => r.map(([{args: [{assetIn, assetOut}]}, route]) => ([[assetIn.toString(), assetOut.toString()], route]))
.filter(([[asset_in]]) => asset_in.toString() === HDX)
.reduce((a, [[,asset_out], route]) => ({...a, [asset_out]: route.toHuman()}), {}))
api.query.multiTransactionPayment.acceptedCurrencies
.keys()
.then((c) => c.map(({ args: [currencyId] }) => currencyId.toString())),
api.query.router.routes.entries().then((r) =>
r
.map(
([
{
args: [{ assetIn, assetOut }],
},
route,
]) => [[assetIn.toString(), assetOut.toString()], route]
)
.filter(([[asset_in]]) => asset_in.toString() === HDX)
.reduce(
(a, [[, asset_out], route]) => ({
...a,
[asset_out]: route.toHuman(),
}),
{}
)
),
]);
console.log(acceptedCurrencies, onchain);
const {amountOut: hdxAmount} = await router.getBestSell('10', HDX, 2000);
const routes = (await Promise.all(acceptedCurrencies.map(currencyId => router.getBestSell(HDX, currencyId, hdxAmount / 10 ** 12).catch(() => null))))
.filter(i => i)
.map(route => route.toTx(ZERO).get().toHuman().method)
.filter(({section}) => section === 'router')
.map(({args}) => args)
.map(({asset_in, asset_out, route}) => api.tx.router.setRoute([asset_in, asset_out], route))
console.log(routes.map(route => route.toHex()));
const { amountOut: hdxAmount } = await router.getBestSell('10', HDX, 2000);
const routes = (
await Promise.all(
acceptedCurrencies.map((currencyId) =>
router
.getBestSell(HDX, currencyId, hdxAmount / 10 ** 12)
.catch(() => null)
)
)
)
.filter((i) => i)
.map((route) => route.toTx(ZERO).get().toHuman().method)
.filter(({ section }) => section === 'router')
.map(({ args }) => args)
.map(({ asset_in, asset_out, route }) =>
api.tx.router.setRoute([asset_in, asset_out], route)
);
console.log(routes.map((route) => route.toHex()));
return api.tx.utility.forceBatch(routes);
}
}
Expand Down

0 comments on commit b2b6d55

Please sign in to comment.