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

Feat: Add USDC and more initial routes #174

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@interlay/bridge",
"version": "0.4.5",
"version": "0.5.0",
"description": "polkawallet bridge sdk",
"main": "build/index.js",
"typings": "build/index.d.ts",
Expand Down
10 changes: 10 additions & 0 deletions scripts/configs/hydradx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,13 @@ import-storage:
- 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY # Alice
- 17 # INTR
- free: '100000000000000000000'
-
-
- 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY # Alice
- 22 # USDC
- free: '1000000000'
-
-
- 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY # Alice
- 10 # USDT
- free: '1000000000'
5 changes: 5 additions & 0 deletions scripts/configs/interlay.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@ import-storage:
- 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY # Alice, vdot
- foreignAsset: 3
- free: '100000000000000000'
-
-
- 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY # Alice, usdc
- foreignAsset: 12
- free: '1000000000'
37 changes: 37 additions & 0 deletions scripts/configs/statemint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,47 @@ import-storage:
- providers: 1
data:
free: 1000000000000000
-
-
- 13cKp89UHns9eDQQV3CZ1seFH6QQ6bnVeLHe4SpsekeJse1r # Sibling:2032 (Interlay), dot
- providers: 1
data:
free: 1000000000000000
-
-
- 13cKp89Uh2yWgTG28JA1QEvPUMjEPKejqkjHKf9zqLiFKjH6 # Sibling:2034 (HydraDX), dot
- providers: 1
data:
free: 1000000000000000
Assets:
Account:
-
-
- 1337 # Alice, USDC
- 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
- balance: 10000000000
-
-
- 1984 # Alice, usdt
- 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
- balance: 10000000000
-
-
- 1337 # Sibling:2032 (Interlay), USDC
- 13cKp89UHns9eDQQV3CZ1seFH6QQ6bnVeLHe4SpsekeJse1r
- balance: 100000000000
-
-
- 1984 # Sibling:2032 (Interlay), usdt
- 13cKp89UHns9eDQQV3CZ1seFH6QQ6bnVeLHe4SpsekeJse1r
- balance: 100000000000
-
-
- 1337 # Sibling:2034 (HydraDX), USDC
- 13cKp89Uh2yWgTG28JA1QEvPUMjEPKejqkjHKf9zqLiFKjH6
- balance: 100000000000
-
-
- 1984 # Sibling:2034 (HydraDX), usdt
- 13cKp89Uh2yWgTG28JA1QEvPUMjEPKejqkjHKf9zqLiFKjH6
- balance: 100000000000
32 changes: 32 additions & 0 deletions src/adapters/hydradx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,24 @@ export const hydraRoutersConfig: Omit<CrossChainRouterConfigs, "from">[] = [
weightLimit: DEST_WEIGHT,
},
},
{
to: "interlay",
token: "USDC",
// currently unknown until registered, assume similar to USDT for now
xcm: {
fee: { token: "USDC", amount: "25000" },
weightLimit: DEST_WEIGHT,
},
},
{
to: "interlay",
token: "USDT",
// recent xcm dest fees: 11_888 - use minimum of 2x margin in estimate
xcm: {
fee: { token: "USDT", amount: "25000" },
weightLimit: DEST_WEIGHT,
},
},
];

export const hydraTokensConfig: Record<string, ExtendedToken> = {
Expand All @@ -63,6 +81,20 @@ export const hydraTokensConfig: Record<string, ExtendedToken> = {
ed: "6164274209",
toRaw: () => 17,
},
USDC: {
name: "USDC",
symbol: "USDC",
decimals: 6,
ed: "10000",
toRaw: () => 22,
},
USDT: {
name: "USDT",
symbol: "USDT",
decimals: 6,
ed: "10000",
toRaw: () => 10,
},
};

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
Expand Down
29 changes: 29 additions & 0 deletions src/adapters/interlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ export const interlayRoutersConfig: Omit<CrossChainRouterConfigs, "from">[] = [
weightLimit: DEST_WEIGHT,
},
},
{
to: "statemint",
token: "USDC",
xcm: {
// seen on subscan: 70_000 atomic units, need a minimum of 2x as buffer
fee: { token: "USDC", amount: "150000" },
weightLimit: DEST_WEIGHT,
},
},
{
to: "statemint",
token: "USDT",
Expand All @@ -97,6 +106,24 @@ export const interlayRoutersConfig: Omit<CrossChainRouterConfigs, "from">[] = [
weightLimit: DEST_WEIGHT,
},
},
{
to: "hydra",
token: "USDC",
xcm: {
// seen on subscan: 2_732 atomic units, need a minimum of 2x as buffer
fee: { token: "USDC", amount: "10000" },
weightLimit: DEST_WEIGHT,
},
},
{
to: "hydra",
token: "USDT",
xcm: {
// seen on subscan: 9_118 atomic units, need a minimum of 2x as buffer
fee: { token: "USDT", amount: "25000" },
weightLimit: DEST_WEIGHT,
},
},
{
to: "bifrost_polkadot",
token: "VDOT",
Expand Down Expand Up @@ -191,6 +218,7 @@ export const interlayTokensConfig: Record<
DOT: { name: "DOT", symbol: "DOT", decimals: 10, ed: "0" },
IBTC: { name: "IBTC", symbol: "IBTC", decimals: 8, ed: "0" },
INTR: { name: "INTR", symbol: "INTR", decimals: 10, ed: "0" },
USDC: { name: "USDC", symbol: "USDC", decimals: 6, ed: "0" },
USDT: { name: "USDT", symbol: "USDT", decimals: 6, ed: "0" },
VDOT: { name: "VDOT", symbol: "VDOT", decimals: 10, ed: "0" },
},
Expand Down Expand Up @@ -219,6 +247,7 @@ const INTERLAY_SUPPORTED_TOKENS: Record<string, unknown> = {
INTR: { Token: "INTR" },
USDT: { ForeignAsset: 2 },
VDOT: { ForeignAsset: 3 },
USDC: { ForeignAsset: 12 },
};

const getSupportedTokens = (chainname: string): Record<string, unknown> => {
Expand Down
11 changes: 10 additions & 1 deletion src/adapters/statemint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ export const statemintRoutersConfig: Omit<CrossChainRouterConfigs, "from">[] = [
// from recent tests: 11_888 atomic units, use a minimum of 2x buffer
xcm: { fee: { token: "USDT", amount: "25000" }, weightLimit: "Unlimited" },
},
{
to: "interlay",
token: "USDC",
// currently unknown until registered, assume similar to USDT for now
xcm: { fee: { token: "USDC", amount: "25000" }, weightLimit: "Unlimited" },
},
];

export const statemineRoutersConfig: Omit<CrossChainRouterConfigs, "from">[] = [
Expand Down Expand Up @@ -70,14 +76,17 @@ export const statemineTokensConfig: Record<
},
statemint: {
DOT: { name: "DOT", symbol: "DOT", decimals: 10, ed: "1000000000" },
// ED set according to minBalance value of assets.asset(1337)
USDC: { name: "USDC", symbol: "USDC", decimals: 6, ed: "70000" },
// ED set according to minBalance value of assets.asset(1984)
USDT: { name: "USDT", symbol: "USDT", decimals: 6, ed: "700000" },
USDT: { name: "USDT", symbol: "USDT", decimals: 6, ed: "70000" },
},
};

const SUPPORTED_TOKENS: Record<string, BN> = {
RMRK: new BN(8),
ARIS: new BN(16),
USDC: new BN(1337),
USDT: new BN(1984),
};

Expand Down
Loading