Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new routes #85

Merged
merged 12 commits into from
Dec 4, 2024
5 changes: 5 additions & 0 deletions .changeset/poor-lemons-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@galacticcouncil/xcm-cfg': patch
---

add ASTR and GLMR to bifrost
5 changes: 5 additions & 0 deletions .changeset/swift-insects-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@galacticcouncil/xcm-cfg': minor
---

ASTR Hydration<>Bifrost
6 changes: 5 additions & 1 deletion examples/xcm-transfer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,9 @@
"@galacticcouncil/xcm-cfg": "^5.4.0",
"@galacticcouncil/xcm-sdk": "^6.3.0",
"@talismn/connect-wallets": "^1.2.5"
}
},
"version": "1.0.0",
"author": "",
"license": "ISC",
"description": ""
}
8 changes: 4 additions & 4 deletions examples/xcm-transfer/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ const wallet = new Wallet({
configureExternal(externals, configService);

// Define transfer
const srcChain = configService.getChain('ethereum');
const srcChain = configService.getChain('bifrost');
const destChain = configService.getChain('hydration');
const asset = configService.getAsset('eth');
const asset = configService.getAsset('astr');

const configBuilder = ConfigBuilder(configService);
const { sourceChains } = configBuilder.assets().asset(asset);
Expand All @@ -71,8 +71,8 @@ logDestChains(asset.key, destinationChains);
logSrcChains(asset.key, sourceChains);

// Define source & dest accounts
const srcAddr = 'INSERT_ADDRESS';
const destAddr = 'INSERT_ADDRESS';
const srcAddr = '7NPoMQbiA6trJKkjB35uk96MeJD4PGWkLQLH7k7hXEkZpiba';
const destAddr = '7NPoMQbiA6trJKkjB35uk96MeJD4PGWkLQLH7k7hXEkZpiba';

// Subscribe source chain token balance
const balanceObserver = (balances: AssetAmount[]) => console.log(balances);
Expand Down
2 changes: 2 additions & 0 deletions package-lock.json

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

89 changes: 89 additions & 0 deletions packages/xcm-cfg/src/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,55 @@ export const astar = new Parachain({
id: '4294969280',
metadataId: 0,
},
{
asset: bnc,
decimals: 12,
id: '18446744073709551623',
metadataId: 0,
min: 0.01,
},
{
asset: glmr,
decimals: 18,
id: '18446744073709551619',
metadataId: 0,
min: 0.01,
},
{
asset: ibtc,
decimals: 8,
id: '18446744073709551620',
metadataId: 0,
min: 0.000001,
},
{
asset: intr,
decimals: 10,
id: '18446744073709551621',
metadataId: 0,
min: 0.01,
},
{
asset: pha,
decimals: 12,
id: '18446744073709551622',
metadataId: 0,
min: 0.01,
},
{
asset: vdot,
decimals: 10,
id: '18446744073709551624',
metadataId: 0,
min: 0.01,
},
{
asset: vastr,
decimals: 18,
id: '18446744073709551632',
metadataId: 0,
min: 0.01,
},
],
ecosystem: Ecosystem.Polkadot,
explorer: 'https://astar.subscan.io',
Expand Down Expand Up @@ -346,6 +395,27 @@ export const bifrost = new Parachain({
metadataId: 23,
palletInstance: 50,
},
{
asset: astr,
decimals: 18,
id: { Token2: 3 },
metadataId: { Token2: 3 },
min: 0.01,
},
{
asset: glmr,
decimals: 18,
id: { Token2: 1 },
metadataId: { Token2: 1 },
min: 0.00001,
},
{
asset: ibtc,
decimals: 8,
id: { Token2: 6 },
metadataId: { Token2: 6 },
min: 0.000001,
},
],
ecosystem: Ecosystem.Polkadot,
explorer: 'https://bifrost.subscan.io',
Expand All @@ -364,6 +434,20 @@ export const centrifuge = new Parachain({
asset: cfg,
id: 'Native',
},
{
asset: dot,
decimals: 10,
id: { ForeignAsset: 5 },
metadataId: { ForeignAsset: 5 },
min: 0.0001,
},
{
asset: glmr,
decimals: 18,
id: { ForeignAsset: 4 },
metadataId: { ForeignAsset: 4 },
min: 0.001,
},
],
ecosystem: Ecosystem.Polkadot,
explorer: 'https://centrifuge.subscan.io',
Expand Down Expand Up @@ -725,6 +809,11 @@ export const interlay = new Parachain({
decimals: 12,
id: { ForeignAsset: 13 },
},
{
asset: vdot,
decimals: 10,
id: { ForeignAsset: 3 },
},
],
ecosystem: Ecosystem.Polkadot,
explorer: 'https://interlay.subscan.io',
Expand Down
156 changes: 155 additions & 1 deletion packages/xcm-cfg/src/configs/polkadot/astar.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AssetRoute, ChainRoutes } from '@galacticcouncil/xcm-core';

import { astr, dot } from '../../assets';
import { astr, bnc, dot, glmr, ibtc, intr, pha, vastr, vdot } from '../../assets';
import { astar, hydration } from '../../chains';
import { BalanceBuilder, ExtrinsicBuilder } from '../../builders';

Expand Down Expand Up @@ -45,6 +45,160 @@ const toHydration: AssetRoute[] = [
},
extrinsic: ExtrinsicBuilder().xTokens().transfer(),
}),
new AssetRoute({
source: {
asset: bnc,
balance: BalanceBuilder().substrate().assets().account(),
fee: {
asset: astr,
balance: BalanceBuilder().substrate().system().account(),
},
destinationFee: {
balance: BalanceBuilder().substrate().assets().account(),
},
},
destination: {
chain: hydration,
asset: bnc,
fee: {
amount: 0.1,
asset: bnc,
},
},
extrinsic: ExtrinsicBuilder().xTokens().transfer(),
}),
new AssetRoute({
source: {
asset: glmr,
balance: BalanceBuilder().substrate().assets().account(),
fee: {
asset: astr,
balance: BalanceBuilder().substrate().system().account(),
},
destinationFee: {
balance: BalanceBuilder().substrate().assets().account(),
},
},
destination: {
chain: hydration,
asset: glmr,
fee: {
amount: 0.04,
asset: glmr,
},
},
extrinsic: ExtrinsicBuilder().xTokens().transfer(),
}),
new AssetRoute({
source: {
asset: ibtc,
balance: BalanceBuilder().substrate().assets().account(),
fee: {
asset: astr,
balance: BalanceBuilder().substrate().system().account(),
},
destinationFee: {
balance: BalanceBuilder().substrate().assets().account(),
},
},
destination: {
chain: hydration,
asset: ibtc,
fee: {
amount: 0.04,
asset: ibtc,
},
},
extrinsic: ExtrinsicBuilder().xTokens().transfer(),
}),
new AssetRoute({
source: {
asset: intr,
balance: BalanceBuilder().substrate().assets().account(),
fee: {
asset: astr,
balance: BalanceBuilder().substrate().system().account(),
},
destinationFee: {
balance: BalanceBuilder().substrate().assets().account(),
},
},
destination: {
chain: hydration,
asset: intr,
fee: {
amount: 0.2,
asset: intr,
},
},
extrinsic: ExtrinsicBuilder().xTokens().transfer(),
}),
new AssetRoute({
source: {
asset: pha,
balance: BalanceBuilder().substrate().assets().account(),
fee: {
asset: astr,
balance: BalanceBuilder().substrate().system().account(),
},
destinationFee: {
balance: BalanceBuilder().substrate().assets().account(),
},
},
destination: {
chain: hydration,
asset: pha,
fee: {
amount: 0.3,
asset: pha,
},
},
extrinsic: ExtrinsicBuilder().xTokens().transfer(),
}),
new AssetRoute({
source: {
asset: vdot,
balance: BalanceBuilder().substrate().assets().account(),
fee: {
asset: astr,
balance: BalanceBuilder().substrate().system().account(),
},
destinationFee: {
balance: BalanceBuilder().substrate().assets().account(),
},
},
destination: {
chain: hydration,
asset: vdot,
fee: {
amount: 0.0004,
asset: vdot,
},
},
extrinsic: ExtrinsicBuilder().xTokens().transfer(),
}),
new AssetRoute({
source: {
asset: vastr,
balance: BalanceBuilder().substrate().assets().account(),
fee: {
asset: astr,
balance: BalanceBuilder().substrate().system().account(),
},
destinationFee: {
balance: BalanceBuilder().substrate().assets().account(),
},
},
destination: {
chain: hydration,
asset: vastr,
fee: {
amount: 0.025,
asset: vastr,
},
},
extrinsic: ExtrinsicBuilder().xTokens().transfer(),
}),
];

export const astarConfig = new ChainRoutes({
Expand Down
Loading