From fc643a1326ae31ab0ffda7dbe4950c47fb563e4e Mon Sep 17 00:00:00 2001 From: Brendon Votteler Date: Thu, 22 Feb 2024 15:00:16 +1100 Subject: [PATCH 1/6] feat: first cut at adding USDC and routes from interlay to/from asset hub and hydradx --- scripts/configs/hydradx.yml | 5 +++++ scripts/configs/interlay.yml | 5 +++++ scripts/configs/statemint.yml | 5 +++++ src/adapters/hydradx.ts | 16 ++++++++++++++++ src/adapters/interlay.ts | 20 ++++++++++++++++++++ src/adapters/statemint.ts | 11 ++++++++++- 6 files changed, 61 insertions(+), 1 deletion(-) diff --git a/scripts/configs/hydradx.yml b/scripts/configs/hydradx.yml index ea272ad..00192ed 100644 --- a/scripts/configs/hydradx.yml +++ b/scripts/configs/hydradx.yml @@ -34,3 +34,8 @@ import-storage: - 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY # Alice - 17 # INTR - free: '100000000000000000000' + - + - + - 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY # Alice + - 22 # USDC + - free: '1000000000' diff --git a/scripts/configs/interlay.yml b/scripts/configs/interlay.yml index 163d1a5..db293e1 100644 --- a/scripts/configs/interlay.yml +++ b/scripts/configs/interlay.yml @@ -34,3 +34,8 @@ import-storage: - 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY # Alice, vdot - foreignAsset: 3 - free: '100000000000000000' + - + - + - 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY # Alice, usdc + - foreignAsset: 12 + - free: '1000000000' diff --git a/scripts/configs/statemint.yml b/scripts/configs/statemint.yml index 69871a8..6ed775c 100644 --- a/scripts/configs/statemint.yml +++ b/scripts/configs/statemint.yml @@ -16,6 +16,11 @@ import-storage: free: 1000000000000000 Assets: Account: + - + - + - 1337 # Alice, USDC + - 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY + - balance: 10000000000 - - - 1984 # Alice, usdt diff --git a/src/adapters/hydradx.ts b/src/adapters/hydradx.ts index b8a3d1d..332a80b 100644 --- a/src/adapters/hydradx.ts +++ b/src/adapters/hydradx.ts @@ -39,6 +39,15 @@ export const hydraRoutersConfig: Omit[] = [ 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, + }, + }, ]; export const hydraTokensConfig: Record = { @@ -63,6 +72,13 @@ export const hydraTokensConfig: Record = { ed: "6164274209", toRaw: () => 17, }, + USDC: { + name: "USDC", + symbol: "USDC", + decimals: 6, + ed: "10000", + toRaw: () => 22, + }, }; // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types diff --git a/src/adapters/interlay.ts b/src/adapters/interlay.ts index 5d2ccdf..de8e558 100644 --- a/src/adapters/interlay.ts +++ b/src/adapters/interlay.ts @@ -73,6 +73,15 @@ export const interlayRoutersConfig: Omit[] = [ 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", @@ -97,6 +106,15 @@ export const interlayRoutersConfig: Omit[] = [ 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: "bifrost_polkadot", token: "VDOT", @@ -191,6 +209,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" }, }, @@ -219,6 +238,7 @@ const INTERLAY_SUPPORTED_TOKENS: Record = { INTR: { Token: "INTR" }, USDT: { ForeignAsset: 2 }, VDOT: { ForeignAsset: 3 }, + USDC: { ForeignAsset: 12 }, }; const getSupportedTokens = (chainname: string): Record => { diff --git a/src/adapters/statemint.ts b/src/adapters/statemint.ts index 5a98a69..88601e9 100644 --- a/src/adapters/statemint.ts +++ b/src/adapters/statemint.ts @@ -39,6 +39,12 @@ export const statemintRoutersConfig: Omit[] = [ // 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[] = [ @@ -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 = { RMRK: new BN(8), ARIS: new BN(16), + USDC: new BN(1337), USDT: new BN(1984), }; From 7e1d9c08868d4011daa81c178d967cfa77b81f12 Mon Sep 17 00:00:00 2001 From: Brendon Votteler Date: Thu, 22 Feb 2024 15:00:38 +1100 Subject: [PATCH 2/6] chore: bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3e051c7..ce23abd 100644 --- a/package.json +++ b/package.json @@ -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", From 8ac98b0849ed0366987226160e84b913ad3bfd2c Mon Sep 17 00:00:00 2001 From: Brendon Votteler Date: Thu, 22 Feb 2024 20:38:46 +1100 Subject: [PATCH 3/6] chore: comment out USDC route between interlay and hydradx for the time being --- src/adapters/hydradx.ts | 32 ++++++++++++++++---------------- src/adapters/interlay.ts | 18 +++++++++--------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/adapters/hydradx.ts b/src/adapters/hydradx.ts index 332a80b..04ef984 100644 --- a/src/adapters/hydradx.ts +++ b/src/adapters/hydradx.ts @@ -39,15 +39,15 @@ export const hydraRoutersConfig: Omit[] = [ 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: "USDC", + // // currently unknown until registered, assume similar to USDT for now + // xcm: { + // fee: { token: "USDC", amount: "25000" }, + // weightLimit: DEST_WEIGHT, + // }, + // }, ]; export const hydraTokensConfig: Record = { @@ -72,13 +72,13 @@ export const hydraTokensConfig: Record = { ed: "6164274209", toRaw: () => 17, }, - USDC: { - name: "USDC", - symbol: "USDC", - decimals: 6, - ed: "10000", - toRaw: () => 22, - }, + // USDC: { + // name: "USDC", + // symbol: "USDC", + // decimals: 6, + // ed: "10000", + // toRaw: () => 22, + // }, }; // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types diff --git a/src/adapters/interlay.ts b/src/adapters/interlay.ts index de8e558..730e7eb 100644 --- a/src/adapters/interlay.ts +++ b/src/adapters/interlay.ts @@ -106,15 +106,15 @@ export const interlayRoutersConfig: Omit[] = [ 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: "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: "bifrost_polkadot", token: "VDOT", From 1ebcea62e29d59082ce876c8dfea11cb839ba960 Mon Sep 17 00:00:00 2001 From: Brendon Votteler Date: Tue, 27 Feb 2024 15:54:28 +1100 Subject: [PATCH 4/6] feat: enable USDC and USDT xcm transfers between interlay and hydradx --- src/adapters/hydradx.ts | 48 ++++++++++++++++++++++++++-------------- src/adapters/interlay.ts | 27 ++++++++++++++-------- 2 files changed, 50 insertions(+), 25 deletions(-) diff --git a/src/adapters/hydradx.ts b/src/adapters/hydradx.ts index 04ef984..c486812 100644 --- a/src/adapters/hydradx.ts +++ b/src/adapters/hydradx.ts @@ -39,15 +39,24 @@ export const hydraRoutersConfig: Omit[] = [ 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: "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 = { @@ -72,13 +81,20 @@ export const hydraTokensConfig: Record = { ed: "6164274209", toRaw: () => 17, }, - // USDC: { - // name: "USDC", - // symbol: "USDC", - // decimals: 6, - // ed: "10000", - // toRaw: () => 22, - // }, + 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 diff --git a/src/adapters/interlay.ts b/src/adapters/interlay.ts index 730e7eb..3148818 100644 --- a/src/adapters/interlay.ts +++ b/src/adapters/interlay.ts @@ -106,15 +106,24 @@ export const interlayRoutersConfig: Omit[] = [ 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: "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", From c889ad905d1104126b2954db86046be4ad0c90e6 Mon Sep 17 00:00:00 2001 From: Brendon Votteler Date: Tue, 27 Feb 2024 16:19:58 +1100 Subject: [PATCH 5/6] chore: add initial USDT balance for Alice in hydradx chopsticks config --- scripts/configs/hydradx.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/configs/hydradx.yml b/scripts/configs/hydradx.yml index 00192ed..6d6d276 100644 --- a/scripts/configs/hydradx.yml +++ b/scripts/configs/hydradx.yml @@ -39,3 +39,8 @@ import-storage: - 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY # Alice - 22 # USDC - free: '1000000000' + - + - + - 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY # Alice + - 10 # USDT + - free: '1000000000' From 3de97f871a4fed56cced65bc3260b0ae105692bd Mon Sep 17 00:00:00 2001 From: Brendon Votteler Date: Tue, 27 Feb 2024 17:11:11 +1100 Subject: [PATCH 6/6] testing: additional funding added for sibling accounts on assethub --- scripts/configs/statemint.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/scripts/configs/statemint.yml b/scripts/configs/statemint.yml index 6ed775c..56ae2f9 100644 --- a/scripts/configs/statemint.yml +++ b/scripts/configs/statemint.yml @@ -14,6 +14,18 @@ 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: - @@ -26,3 +38,23 @@ import-storage: - 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