Skip to content

Commit

Permalink
allow only one native wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
SvineruS committed Apr 29, 2024
1 parent 28c4cf9 commit b60e4e5
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 42 deletions.
12 changes: 8 additions & 4 deletions contracts/sdk/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ export function getPairs(configFile: Config, sourceNetwork: Network, destination

const tokenPairs: [Token, Token][] = [];

// NOTE: only one of destination tokens can be the wrapper for native coin
// if there are multiple - we need to select the latest occurrence in config (it's restriction of a contracts implementation)
// NOTE: only one token can be the wrapper for native coin
// if there are multiple - we need to select the latest occurrence in config
// (for destination it's restriction of a contracts implementation, for source it's just dumb to have multiple wrappers for the same coin')
// and it's already a case with multiple tokens: SAMB and SAMB2 in eth->amb bridge
// so, reverse tokens array and store the `isAnyDestinationNativeWrapper` flag
// so, reverse tokens array and store the flags below

const tokens = Object.values(configFile.tokens).reverse()
let isAnySourceNativeWrapper = false;
let isAnyDestinationNativeWrapper = false;

for (const token of tokens) {
Expand All @@ -48,8 +50,10 @@ export function getPairs(configFile: Config, sourceNetwork: Network, destination
tokenPairs.push(createPair(false, false));

// create native -> erc20 if need
if (tokenSource.isPrimary && tokenSource.nativeCoin)
if (tokenSource.isPrimary && tokenSource.nativeCoin && !isAnySourceNativeWrapper) {
tokenPairs.push(createPair(true, false));
isAnySourceNativeWrapper = true;
}

// create erc20 -> native if need
if (tokenDest.isPrimary && tokenDest.nativeCoin && !isAnyDestinationNativeWrapper) {
Expand Down
73 changes: 35 additions & 38 deletions contracts/sdk/example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,78 +239,75 @@ async function main() {
example output:
eth->amb Tether USD -> Tether USD
Need to increase allowance to 1000000
bridge.withdraw(0xdAC17F958D2ee523a2206206994597C13D831ec7, 0x295C2707319ad4BecA6b5bb4086617fD6F240CfE, 1000000, false, 0x5a4fe32bc10384df40b73dd90478c2010118bdf66aa403631c1577b88835882845c7e3bab89345fb6d3ada9e22821825ca0dbca5fa0caf1d77b3288b238a05c700, 158020501059307, 0, { value: 158020501059307 })
Need to increase allowance to 10000000000
bridge.withdraw(0xdAC17F958D2ee523a2206206994597C13D831ec7, 0x295C2707319ad4BecA6b5bb4086617fD6F240CfE, 10000000000, false, 0x5e28685708ed585c5c2347095809399ba38f57e845841fb0cdc81e4a646e889b0fc5487946c16b0008d9e43f3379458c7cf1561f039649fd3609f6342302183f01, 157499455173400, 0, { value: 157499455173400 })
eth->amb USD Coin -> USD Coin
Need to increase allowance to 1000000
bridge.withdraw(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48, 0x295C2707319ad4BecA6b5bb4086617fD6F240CfE, 1000000, false, 0xbc14e2db76772e605cf3e23ae650b49b416f0f0ae812184d311e079d3e9784a70f6389597e8250555ea6d158fa8614f891ea63480327dc4e5e9c668e40d8393000, 158020501059307, 0, { value: 158020501059307 })
Need to increase allowance to 10000000000
bridge.withdraw(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48, 0x295C2707319ad4BecA6b5bb4086617fD6F240CfE, 10000000000, false, 0x263aee2f3de81268912c8d191eb0726d5640cc3c8ddc09f1ea2a317a598c91a908ab04e0493cf7f6c4c993420018743393a9de6068bd264465e6a941b6725e9000, 157499455173400, 0, { value: 157499455173400 })
eth->amb AirDAO -> AirDAO
Need to increase allowance to 1000000000000000000
bridge.withdraw(0xf4fB9BF10E489EA3Edb03E094939341399587b0C, 0x295C2707319ad4BecA6b5bb4086617fD6F240CfE, 1000000000000000000, false, 0x9e4a9bd978c04ca16a7c55901f49beddbfb12c571409b02272ed4da99549730c69aaa2ab35d154ff94ed9193e90ab50022c659815527af23d64a823b258b0c4501, 158020501059307, 0, { value: 158020501059307 })
Need to increase allowance to 10000000000000000000000
bridge.withdraw(0xf4fB9BF10E489EA3Edb03E094939341399587b0C, 0x295C2707319ad4BecA6b5bb4086617fD6F240CfE, 10000000000000000000000, false, 0x274bc5482ee3bbd04b9b9e0608980c661862d343e0d085af2402d9ac8ae072e75b83f6aa6f486bbb54fe0fc35235f948c208715726de281f28795f5da433b96800, 157499455173400, 0, { value: 157499455173400 })
eth->amb AirDAO -> AirDAO (NATIVE)
Need to increase allowance to 1000000000000000000
bridge.withdraw(0xf4fB9BF10E489EA3Edb03E094939341399587b0C, 0x295C2707319ad4BecA6b5bb4086617fD6F240CfE, 1000000000000000000, true, 0x9e4a9bd978c04ca16a7c55901f49beddbfb12c571409b02272ed4da99549730c69aaa2ab35d154ff94ed9193e90ab50022c659815527af23d64a823b258b0c4501, 158020501059307, 0, { value: 158020501059307 })
Need to increase allowance to 10000000000000000000000
bridge.withdraw(0xf4fB9BF10E489EA3Edb03E094939341399587b0C, 0x295C2707319ad4BecA6b5bb4086617fD6F240CfE, 10000000000000000000000, true, 0x274bc5482ee3bbd04b9b9e0608980c661862d343e0d085af2402d9ac8ae072e75b83f6aa6f486bbb54fe0fc35235f948c208715726de281f28795f5da433b96800, 157499455173400, 0, { value: 157499455173400 })
eth->amb Synthetic Amber -> Synthetic Amber
Need to increase allowance to 1000000000000000000
bridge.withdraw(0x683aae5cD37AC94943D05C19E9109D5876113562, 0x295C2707319ad4BecA6b5bb4086617fD6F240CfE, 1000000000000000000, false, 0xe95d03fa248a46d43c8e92ffb7377156943cc38bd5fd74a4ff318be945535cf160f171c803204db4458e0b2ecb218b10da0350f309c30e26264377436ec3f74a01, 158020501059307, 0, { value: 158020501059307 })
Need to increase allowance to 10000000000000000000000
bridge.withdraw(0x683aae5cD37AC94943D05C19E9109D5876113562, 0x295C2707319ad4BecA6b5bb4086617fD6F240CfE, 10000000000000000000000, false, 0x2fa60e7174e8e6d0d9112902923984e435934a064f2bc81de8e6e5e5717beed75a286ba22e0bf2397ff4b8cb8ac9f133346d34dd07fd3d47e48c422caf63656a00, 157499455173400, 0, { value: 157499455173400 })
amb->eth Tether USD -> Tether USD
Need to increase allowance to 1000000000000000000
bridge.withdraw(0xfEE01F2D120250A0a59bfbF9C144F8ECC4425fCc, 0x295C2707319ad4BecA6b5bb4086617fD6F240CfE, 1000000, false, 0xd2a89974fc1475cc7e09b69183cb8332543c6f1a4b7cbb2df0036b093d45cb045f8011e0a3fe63cc648f6321d91bcca5c701bd9850d1af72262a1cb5c1408bbb00, 4723877201423040465425, 0, { value: 4723877201423040465425 })
Need to increase allowance to 10000000000000000000000
bridge.withdraw(0xfEE01F2D120250A0a59bfbF9C144F8ECC4425fCc, 0x295C2707319ad4BecA6b5bb4086617fD6F240CfE, 10000000000, false, 0x3f1ebf8e5c861bd8e4d6f2a9f3b63e848b0e1b89875a794ec773de7e740160eb3887f9ebd76728e3127170ee024ea025d450fc6947afcb0086808f961e71930d01, 4699014836012654235617, 0, { value: 4699014836012654235617 })
amb->eth USD Coin -> USD Coin
Need to increase allowance to 1000000000000000000
bridge.withdraw(0xFF9F502976E7bD2b4901aD7Dd1131Bb81E5567de, 0x295C2707319ad4BecA6b5bb4086617fD6F240CfE, 1000000, false, 0xa1b326116eb5992e87bb2d769abbccedad896e07e93091f8afeebdd05b5b56c42f3be36fc65bf6857a891ea6b7e67b729aebd214ec6219e3a75c9f07488dc6da01, 4723877201423040465425, 0, { value: 4723877201423040465425 })
Need to increase allowance to 10000000000000000000000
bridge.withdraw(0xFF9F502976E7bD2b4901aD7Dd1131Bb81E5567de, 0x295C2707319ad4BecA6b5bb4086617fD6F240CfE, 10000000000, false, 0x16680b54c86f41990a398648cba17138f00b4a3bf4e47e457d19c79d9257ae6f2cf7dafaacfe29d38d7d0217be6d7cd63881c52f142b2345967cc697e92730af00, 4699014836012654235617, 0, { value: 4699014836012654235617 })
amb->eth AirDAO -> AirDAO
Need to increase allowance to 1000000000000000000
bridge.withdraw(0x2b2d892C3fe2b4113dd7aC0D2c1882AF202FB28F, 0x295C2707319ad4BecA6b5bb4086617fD6F240CfE, 1000000000000000000, false, 0xa378fe61fb70da4ecc01f7834f3cc0d0f4c2af32ea66829b8693bed05ff149fb533d46c407ec79eefceefe3637bfd9f0eed483f0c107d96f44db11e66ddfef8101, 4723877201423040465425, 0, { value: 4723877201423040465425 })
Need to increase allowance to 10000000000000000000000
bridge.withdraw(0x2b2d892C3fe2b4113dd7aC0D2c1882AF202FB28F, 0x295C2707319ad4BecA6b5bb4086617fD6F240CfE, 10000000000000000000000, false, 0xdbd43702a6d2de8e97c2359f66529be39976fb2f7f4ff0a7032b7dd5cacd3c7c50e308b4baac6dd5bdd6c35e2b18fc21b27159ef21adfbbee47e003babe02a8b00, 4699014836012654235617, 0, { value: 4699014836012654235617 })
amb->eth AirDAO (NATIVE) -> AirDAO
bridge.wrapWithdraw(0x295C2707319ad4BecA6b5bb4086617fD6F240CfE, 0xa378fe61fb70da4ecc01f7834f3cc0d0f4c2af32ea66829b8693bed05ff149fb533d46c407ec79eefceefe3637bfd9f0eed483f0c107d96f44db11e66ddfef8101, 4723877201423040465425, 0, { value: 4724877201423040465425 })
bridge.wrapWithdraw(0x295C2707319ad4BecA6b5bb4086617fD6F240CfE, 0xdbd43702a6d2de8e97c2359f66529be39976fb2f7f4ff0a7032b7dd5cacd3c7c50e308b4baac6dd5bdd6c35e2b18fc21b27159ef21adfbbee47e003babe02a8b00, 4699014836012654235617, 0, { value: 14699014836012654235617 })
amb->eth Synthetic Amber -> Synthetic Amber
Need to increase allowance to 1000000000000000000
bridge.withdraw(0x2b2d892C3fe2b4113dd7aC0D2c1882AF202FB28F, 0x295C2707319ad4BecA6b5bb4086617fD6F240CfE, 1000000000000000000, false, 0xa378fe61fb70da4ecc01f7834f3cc0d0f4c2af32ea66829b8693bed05ff149fb533d46c407ec79eefceefe3637bfd9f0eed483f0c107d96f44db11e66ddfef8101, 4723877201423040465425, 0, { value: 4723877201423040465425 })
amb->eth Synthetic Amber (NATIVE) -> Synthetic Amber
bridge.wrapWithdraw(0x295C2707319ad4BecA6b5bb4086617fD6F240CfE, 0xa378fe61fb70da4ecc01f7834f3cc0d0f4c2af32ea66829b8693bed05ff149fb533d46c407ec79eefceefe3637bfd9f0eed483f0c107d96f44db11e66ddfef8101, 4723877201423040465425, 0, { value: 4724877201423040465425 })
Need to increase allowance to 10000000000000000000000
bridge.withdraw(0x2b2d892C3fe2b4113dd7aC0D2c1882AF202FB28F, 0x295C2707319ad4BecA6b5bb4086617fD6F240CfE, 10000000000000000000000, false, 0xdbd43702a6d2de8e97c2359f66529be39976fb2f7f4ff0a7032b7dd5cacd3c7c50e308b4baac6dd5bdd6c35e2b18fc21b27159ef21adfbbee47e003babe02a8b00, 4699014836012654235617, 0, { value: 4699014836012654235617 })
bsc->amb Tether USD -> Tether USD
Need to increase allowance to 1000000000000000000
bridge.withdraw(0x55d398326f99059fF775485246999027B3197955, 0x295C2707319ad4BecA6b5bb4086617fD6F240CfE, 1000000000000000000, false, 0xb5a4c1a9e86f7fc0896eb9d7baaca93deb0e065fbe6f63344ac0bcd4ff1a76cb555d0d38828cb0e248b3f476806001dd9dbd335c0497cc08d9bf385ec5b2fa2701, 848777785990751, 0, { value: 848777785990751 })
Need to increase allowance to 10000000000000000000000
bridge.withdraw(0x55d398326f99059fF775485246999027B3197955, 0x295C2707319ad4BecA6b5bb4086617fD6F240CfE, 10000000000000000000000, false, 0x4d741171fe8130a32d1571f7a242683874a3e9ef77f07551117ed74312b582b651873ea4abfe35a21a9f8aed18a2ca03c44a7a2fd754e671580fef20b4f96f8300, 843537161377815, 0, { value: 843537161377815 })
bsc->amb USD Coin -> USD Coin
Need to increase allowance to 1000000000000000000
bridge.withdraw(0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d, 0x295C2707319ad4BecA6b5bb4086617fD6F240CfE, 1000000000000000000, false, 0x7ca1930d7ba742063c4967e742b111a6fcc26087e0a0ffb5a08b5012b83e1495186673f29d00d9fb36ba28b20c66794d2431c5e8811ab333f0377bf5c7469c9601, 848777785990751, 0, { value: 848777785990751 })
Need to increase allowance to 10000000000000000000000
bridge.withdraw(0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d, 0x295C2707319ad4BecA6b5bb4086617fD6F240CfE, 10000000000000000000000, false, 0xd2b0038e61ea64c623e3a5be99bcd217a2d9a6b003666a989aa4a8a243c085c122c0c5e346688346a76a18374e7d1e2c688920c37d944588eb6899f2572fd2b101, 843537161377815, 0, { value: 843537161377815 })
bsc->amb Synthetic Amber -> Synthetic Amber
Need to increase allowance to 1000000000000000000
bridge.withdraw(0x23c1C1cc14270B7Bd63677d1fe4790891b17A33d, 0x295C2707319ad4BecA6b5bb4086617fD6F240CfE, 1000000000000000000, false, 0x2a08d40d3191e3a930160179a36041ac9670793e10612e8e21ebe6bae8d6a148192d7bf195f978c7181a8048335ee5affc401f6f9c73d598baae6fae2ec55de400, 848777785990751, 0, { value: 848777785990751 })
Need to increase allowance to 10000000000000000000000
bridge.withdraw(0x23c1C1cc14270B7Bd63677d1fe4790891b17A33d, 0x295C2707319ad4BecA6b5bb4086617fD6F240CfE, 10000000000000000000000, false, 0x1ccb8a6e7fabd61970e69da899c0d619acdc614e90a5bcfcf1bc470fac9be8295f60ccc2111d391fe5eee5f902a2bdef50a7027bd5fbb75c6ea312cf1ae57a5701, 843537161377815, 0, { value: 843537161377815 })
bsc->amb Synthetic Amber -> Synthetic Amber (NATIVE)
Need to increase allowance to 1000000000000000000
bridge.withdraw(0x23c1C1cc14270B7Bd63677d1fe4790891b17A33d, 0x295C2707319ad4BecA6b5bb4086617fD6F240CfE, 1000000000000000000, true, 0x2a08d40d3191e3a930160179a36041ac9670793e10612e8e21ebe6bae8d6a148192d7bf195f978c7181a8048335ee5affc401f6f9c73d598baae6fae2ec55de400, 848777785990751, 0, { value: 848777785990751 })
Need to increase allowance to 10000000000000000000000
bridge.withdraw(0x23c1C1cc14270B7Bd63677d1fe4790891b17A33d, 0x295C2707319ad4BecA6b5bb4086617fD6F240CfE, 10000000000000000000000, true, 0x1ccb8a6e7fabd61970e69da899c0d619acdc614e90a5bcfcf1bc470fac9be8295f60ccc2111d391fe5eee5f902a2bdef50a7027bd5fbb75c6ea312cf1ae57a5701, 843537161377815, 0, { value: 843537161377815 })
amb->bsc Tether USD -> Tether USD
Need to increase allowance to 1000000000000000000
bridge.withdraw(0xfEE01F2D120250A0a59bfbF9C144F8ECC4425fCc, 0x295C2707319ad4BecA6b5bb4086617fD6F240CfE, 1000000000000000000, false, 0x0b022a34ce9ed0265e316ae48a216e793e35be2ca54d503e91adb6092a825ed343b96ae8f892b4ee14755b683561ca9048529eef47bd3e0230f65b7df90828e300, 121715358895993008670, 0, { value: 121715358895993008670 })
Need to increase allowance to 10000000000000000000000
bridge.withdraw(0xfEE01F2D120250A0a59bfbF9C144F8ECC4425fCc, 0x295C2707319ad4BecA6b5bb4086617fD6F240CfE, 10000000000000000000000, false, 0x66e1ac47eaab81b76c630c1d9b70015c63c0c57ff068f7186c28f2eb53e5a0de0521fc9af4d7227024a3b157b3a54ab4fbeb94d481d66baa12afc2d24fb2328a00, 120675531973947600754, 0, { value: 120675531973947600754 })
amb->bsc USD Coin -> USD Coin
Need to increase allowance to 1000000000000000000
bridge.withdraw(0xFF9F502976E7bD2b4901aD7Dd1131Bb81E5567de, 0x295C2707319ad4BecA6b5bb4086617fD6F240CfE, 1000000000000000000, false, 0x85fd72dbad530f74c5e5a5fab9e4860ddb380acb89976aaa117559b64132ca891d9ee64ed520570de9a552aa07dc3f14b78a9194671e7c42dbd9ce423b79bd3201, 121715358895993008670, 0, { value: 121715358895993008670 })
Need to increase allowance to 10000000000000000000000
bridge.withdraw(0xFF9F502976E7bD2b4901aD7Dd1131Bb81E5567de, 0x295C2707319ad4BecA6b5bb4086617fD6F240CfE, 10000000000000000000000, false, 0x7e4e9dac82189346575c4a7b0541812f899b3e638340448a34c294872782bcf04894d8d29a1fb0ed54745722aee1ad31850f5379b22e8e02e284fcc24d79a5d700, 120675531973947600754, 0, { value: 120675531973947600754 })
amb->bsc Synthetic Amber -> Synthetic Amber
Need to increase allowance to 1000000000000000000
bridge.withdraw(0x2b2d892C3fe2b4113dd7aC0D2c1882AF202FB28F, 0x295C2707319ad4BecA6b5bb4086617fD6F240CfE, 1000000000000000000, false, 0x33ba355e51585860a96292abda5de4e14c3369c7b538ec1c6a26bbb01637d8c31cf3eee7c1ebfdeddbd5885d58a60e89e9038a8cffe0cb83a78bdc57a88cf5a901, 121715358895993008670, 0, { value: 121715358895993008670 })
Need to increase allowance to 10000000000000000000000
bridge.withdraw(0x2b2d892C3fe2b4113dd7aC0D2c1882AF202FB28F, 0x295C2707319ad4BecA6b5bb4086617fD6F240CfE, 10000000000000000000000, false, 0x83be964d6c72871b8a590ac0df32d2c77c0eb7ea831edb6aa8716110a29ada7e65afb03723d7ef77b6f0ef11659fcf01678881f6c40dcad7dcc2f5f4b6c19d2001, 120675531973947600754, 0, { value: 120675531973947600754 })
amb->bsc Synthetic Amber (NATIVE) -> Synthetic Amber
bridge.wrapWithdraw(0x295C2707319ad4BecA6b5bb4086617fD6F240CfE, 0x33ba355e51585860a96292abda5de4e14c3369c7b538ec1c6a26bbb01637d8c31cf3eee7c1ebfdeddbd5885d58a60e89e9038a8cffe0cb83a78bdc57a88cf5a901, 121715358895993008670, 0, { value: 122715358895993008670 })
bridge.wrapWithdraw(0x295C2707319ad4BecA6b5bb4086617fD6F240CfE, 0x83be964d6c72871b8a590ac0df32d2c77c0eb7ea831edb6aa8716110a29ada7e65afb03723d7ef77b6f0ef11659fcf01678881f6c40dcad7dcc2f5f4b6c19d2001, 120675531973947600754, 0, { value: 10120675531973947600754 })
*/

Expand Down

0 comments on commit b60e4e5

Please sign in to comment.