Skip to content

Commit

Permalink
Merge pull request #85 from galacticcouncil/add-new-routes
Browse files Browse the repository at this point in the history
Add new routes
  • Loading branch information
nohaapav authored Dec 4, 2024
2 parents b609df7 + b099d86 commit 20307bd
Show file tree
Hide file tree
Showing 11 changed files with 648 additions and 10 deletions.
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.6.0",
"@galacticcouncil/xcm-sdk": "^7.0.0",
"@talismn/connect-wallets": "^1.2.5"
}
},
"version": "1.0.0",
"author": "",
"license": "ISC",
"description": ""
}
10 changes: 5 additions & 5 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('hydration');
const destChain = configService.getChain('ethereum');
const asset = configService.getAsset('aave');
const srcChain = configService.getChain('ethereum');
const destChain = configService.getChain('hydration');
const asset = configService.getAsset('eth');

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 = '5HbftW2XCP77ypjeBEkL2iXHKw5rnRJoqKd3ySZCgxvxbxYj';
const destAddr = '0x26f5C2370e563e9f4dDA435f03A63D7C109D8D04';
const srcAddr = 'INSERT_ADDRESS';
const destAddr = 'INSERT_ADDRESS';

// 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 @@ -299,6 +299,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 @@ -364,6 +413,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 @@ -382,6 +452,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 @@ -1328,6 +1412,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

0 comments on commit 20307bd

Please sign in to comment.