Skip to content

Commit

Permalink
Feat: Add/update Interlay and Kintsugi routes (#121)
Browse files Browse the repository at this point in the history
* feat: add new and update existing routes from interlay

* chore: add .vscode to .gitignore

* feat: add/update xcm route configs from parachains toward interlay and kintsugi

* chore: revert bifrost kusama  adapter name change back to what it was previously

* feat: add fallback mode to search for wss nodes by parachain id definition instead of ChainId if necessary

* feat: add DOT token to interlay adapter, and add KSM route from kintsugi to kusama

* test: add interlay and kintsugi specific xcm test cases
  • Loading branch information
bvotteler authored Mar 14, 2024
1 parent 7a8fe30 commit 2407e10
Show file tree
Hide file tree
Showing 12 changed files with 582 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,6 @@ dist

# TernJS port file
.tern-port

# VSCode
.vscode
2 changes: 1 addition & 1 deletion src/adapters/acala/acala-configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export const acalaRouteConfigs = createRouteConfigs("acala", [
to: "interlay",
token: "INTR",
xcm: {
fee: { token: "INTR", amount: "19000000" },
fee: { token: "INTR", amount: "20000000" },
},
},
{
Expand Down
18 changes: 17 additions & 1 deletion src/adapters/assethub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,15 @@ export const assetHubPolkadotRouteConfigs = createRouteConfigs(
to: "interlay",
token: "USDT",
xcm: {
fee: { token: "USDT", amount: "808" },
fee: { token: "USDT", amount: "25000" },
weightLimit: "Unlimited",
},
},
{
to: "interlay",
token: "USDC",
xcm: {
fee: { token: "USDC", amount: "25000" },
weightLimit: "Unlimited",
},
},
Expand Down Expand Up @@ -126,6 +134,14 @@ export const assetHubKusamaRouteConfigs = createRouteConfigs("assetHubKusama", [
token: "USDT",
xcm: { fee: { token: "USDT", amount: "808" }, weightLimit: "Unlimited" },
},
{
to: "kintsugi",
token: "USDT",
xcm: {
fee: { token: "USDT", amount: "20000" },
weightLimit: "Unlimited",
},
},
]);

export const assetHubPolkadotTokensConfig: Record<string, ExtendedToken> = {
Expand Down
34 changes: 34 additions & 0 deletions src/adapters/astar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,22 @@ export const astarRouteConfigs = createRouteConfigs("astar", [
weightLimit: "Unlimited",
},
},
{
to: "interlay",
token: "IBTC",
xcm: {
fee: { token: "IBTC", amount: "75" },
weightLimit: "Unlimited",
},
},
{
to: "interlay",
token: "INTR",
xcm: {
fee: { token: "INTR", amount: "20000000" },
weightLimit: "Unlimited",
},
},
]);

export const shidenRouteConfigs = createRouteConfigs("shiden", [
Expand Down Expand Up @@ -135,6 +151,24 @@ export const astarTokensConfig: Record<string, Record<string, TokenData>> = {
"0x0003000000000000000000000000000000000000000000000000000000000000",
toQuery: () => "18446744073709551618",
},
IBTC: {
name: "IBTC",
symbol: "IBTC",
decimals: 8,
ed: "1",
toRaw: () =>
"0x0001000000000000000000000000000000000000000000000000000000000000",
toQuery: () => "18446744073709551620",
},
INTR: {
name: "INTR",
symbol: "INTR",
decimals: 10,
ed: "1",
toRaw: () =>
"0x0002000000000000000000000000000000000000000000000000000000000000",
toQuery: () => "18446744073709551621",
},
},
shiden: {
SDN: {
Expand Down
62 changes: 58 additions & 4 deletions src/adapters/bifrost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { ApiNotFound, InvalidAddress, TokenNotFound } from "../errors";
import { BalanceData, ExtendedToken, TransferParams } from "../types";
import { createRouteConfigs, validateAddress } from "../utils";

export const bifrostRouteConfigs = createRouteConfigs("bifrost", [
export const bifrostKusamaRouteConfigs = createRouteConfigs("bifrost", [
{
to: "karura",
token: "BNC",
Expand Down Expand Up @@ -48,9 +48,29 @@ export const bifrostRouteConfigs = createRouteConfigs("bifrost", [
fee: { token: "KUSD", amount: "10011896008" },
},
},
{
to: "kintsugi",
token: "VKSM",
xcm: {
fee: { token: "VKSM", amount: "175000000" },
},
},
]);

export const bifrostTokensConfig: Record<string, ExtendedToken> = {
export const bifrostPolkadotRoutersConfig = createRouteConfigs(
"bifrostPolkadot",
[
{
to: "interlay",
token: "VDOT",
xcm: {
fee: { token: "VDOT", amount: "20000000" },
},
},
]
);

export const bifrostKusamaTokensConfig: Record<string, ExtendedToken> = {
BNC: {
name: "BNC",
symbol: "BNC",
Expand Down Expand Up @@ -86,6 +106,30 @@ export const bifrostTokensConfig: Record<string, ExtendedToken> = {
ed: "100000000",
toRaw: () => ({ Stable: "KUSD" }),
},
VKSM: {
name: "VKSM",
symbol: "VKSM",
decimals: 12,
ed: "100000000",
toRaw: () => ({ VToken: "KSM" }),
},
};

export const bifrostPolkadotTokensConfig: Record<string, ExtendedToken> = {
BNC: {
name: "BNC",
symbol: "BNC",
decimals: 12,
ed: "10000000000",
toRaw: () => ({ Native: "BNC" }),
},
VDOT: {
name: "VDOT",
symbol: "VDOT",
decimals: 10,
ed: "1000000",
toRaw: () => ({ VToken2: 0 }),
},
};

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
Expand Down Expand Up @@ -168,7 +212,7 @@ class BaseBifrostAdapter extends BaseCrossChainAdapter {
this.balanceAdapter = new BifrostBalanceAdapter({
chain: this.chain.id as ChainId,
api,
tokens: bifrostTokensConfig,
tokens: bifrostKusamaTokensConfig,
});
}

Expand Down Expand Up @@ -233,6 +277,16 @@ class BaseBifrostAdapter extends BaseCrossChainAdapter {

export class BifrostAdapter extends BaseBifrostAdapter {
constructor() {
super(chains.bifrost, bifrostRouteConfigs, bifrostTokensConfig);
super(chains.bifrost, bifrostKusamaRouteConfigs, bifrostKusamaTokensConfig);
}
}

export class BifrostPolkadotAdapter extends BaseBifrostAdapter {
constructor() {
super(
chains.bifrostPolkadot,
bifrostPolkadotRoutersConfig,
bifrostPolkadotTokensConfig
);
}
}
14 changes: 14 additions & 0 deletions src/adapters/hydradx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,13 @@ export const hydradxRoutersConfig = createRouteConfigs("hydradx", [
token: "IBTC",
xcm: { fee: { token: "IBTC", amount: "62" } },
},
{
to: "interlay",
token: "INTR",
xcm: {
fee: { token: "INTR", amount: "20000000" },
},
},
{
to: "assetHubPolkadot",
token: "USDT",
Expand Down Expand Up @@ -280,6 +287,13 @@ export const hydradxTokensConfig: Record<string, ExtendedToken> = {
ed: "36",
toRaw: () => 11,
},
INTR: {
name: "INTR",
symbol: "INTR",
decimals: 10,
ed: "6164274209",
toRaw: () => 17,
},
SUB: {
name: "SUB",
symbol: "SUB",
Expand Down
Loading

0 comments on commit 2407e10

Please sign in to comment.