diff --git a/federator-env/mainnet-BSC-RSK/bmainnet.json b/federator-env/mainnet-BSC-RSK/bmainnet.json index eba8cafa..58c0265f 100644 --- a/federator-env/mainnet-BSC-RSK/bmainnet.json +++ b/federator-env/mainnet-BSC-RSK/bmainnet.json @@ -2,7 +2,7 @@ "bridge": "0xdfc7127593c8af1a17146893f10e08528f4c2aa7", "federation": "0x33f8743d5AFa519Dd373a75E7AA5C255e2c82468", "multiSig": "0xec3fabc3517e64e07669dd1d2d673f466f93a328", - "allowTokens": "0x05b68e70168e876b2025f837bc8e0b2312d5327d", + "allowTokens": "0xc4b5178Cc086E764568AdfB2dacCBB0d973e8132", "erc777Converter": "0x9D46B33171eA7124aEE472bFe61B5B7084B55069", "host": "https://bsc-dataseed1.defibit.io/", "fromBlock": 7912333 diff --git a/federator-env/mainnet-BSC-RSK/bmainnet_v5.json b/federator-env/mainnet-BSC-RSK/bmainnet_v5.json new file mode 100644 index 00000000..eba8cafa --- /dev/null +++ b/federator-env/mainnet-BSC-RSK/bmainnet_v5.json @@ -0,0 +1,9 @@ +{ + "bridge": "0xdfc7127593c8af1a17146893f10e08528f4c2aa7", + "federation": "0x33f8743d5AFa519Dd373a75E7AA5C255e2c82468", + "multiSig": "0xec3fabc3517e64e07669dd1d2d673f466f93a328", + "allowTokens": "0x05b68e70168e876b2025f837bc8e0b2312d5327d", + "erc777Converter": "0x9D46B33171eA7124aEE472bFe61B5B7084B55069", + "host": "https://bsc-dataseed1.defibit.io/", + "fromBlock": 7912333 +} diff --git a/federator-env/mainnet-BSC-RSK/rskmainnet.json b/federator-env/mainnet-BSC-RSK/rskmainnet.json index d9fef684..122da7b1 100644 --- a/federator-env/mainnet-BSC-RSK/rskmainnet.json +++ b/federator-env/mainnet-BSC-RSK/rskmainnet.json @@ -2,7 +2,7 @@ "bridge": "0x971b97c8cc82e7d27bc467c2dc3f219c6ee2e350", "federation": "0xA7938270C2bF99A9cF033c9d35156d2dDb097B12", "multiSig": "0xee9ea57555d9533d71f6f77e0e480961f068a6c5", - "allowTokens": "0xa2f50a2c699c1aa3b9089f6b565d4999d45d8983", + "allowTokens": "0x200FD7a1cCEa4651F15008cC99bF82d7461EFd3F", "erc777Converter": "0xc8149b1F15794D135Dfe2924955cb90709Ac7070", "host": "http://18.221.155.102:4444/", "fromBlock": 3398643 diff --git a/federator-env/mainnet-BSC-RSK/rskmainnet_v5.json b/federator-env/mainnet-BSC-RSK/rskmainnet_v5.json new file mode 100644 index 00000000..d9fef684 --- /dev/null +++ b/federator-env/mainnet-BSC-RSK/rskmainnet_v5.json @@ -0,0 +1,9 @@ +{ + "bridge": "0x971b97c8cc82e7d27bc467c2dc3f219c6ee2e350", + "federation": "0xA7938270C2bF99A9cF033c9d35156d2dDb097B12", + "multiSig": "0xee9ea57555d9533d71f6f77e0e480961f068a6c5", + "allowTokens": "0xa2f50a2c699c1aa3b9089f6b565d4999d45d8983", + "erc777Converter": "0xc8149b1F15794D135Dfe2924955cb90709Ac7070", + "host": "http://18.221.155.102:4444/", + "fromBlock": 3398643 +} diff --git a/federator-env/mainnet-ETH-RSK/mainnet.json b/federator-env/mainnet-ETH-RSK/mainnet.json index 4cd58ccb..66001fd7 100644 --- a/federator-env/mainnet-ETH-RSK/mainnet.json +++ b/federator-env/mainnet-ETH-RSK/mainnet.json @@ -2,7 +2,7 @@ "bridge": "0x33c0d33a0d4312562ad622f91d12b0ac47366ee1", "federation": "0x74aa9b461CAd174cA066fc80AF2151c96Bd4D45f", "multiSig": "0x062c74f9d27b1178bb76186c1756128ccb3ccd2e", - "allowTokens": "0x8df20c2c85bee0c3da250da96d892598c70aa1be", + "allowTokens": "0xf9A59a649859A27d664C8bDb51fA53bCb268545C", "erc777Converter": "0xC0b2A9E31f69e4F0bC24584C678C582714a4fA1b", "host": "https://mainnet.infura.io/v3/f02caaf003d14ad7bee83f33eeda2f5a", "fromBlock": 12110034 diff --git a/federator-env/mainnet-ETH-RSK/mainnet_v5.json b/federator-env/mainnet-ETH-RSK/mainnet_v5.json new file mode 100644 index 00000000..4cd58ccb --- /dev/null +++ b/federator-env/mainnet-ETH-RSK/mainnet_v5.json @@ -0,0 +1,9 @@ +{ + "bridge": "0x33c0d33a0d4312562ad622f91d12b0ac47366ee1", + "federation": "0x74aa9b461CAd174cA066fc80AF2151c96Bd4D45f", + "multiSig": "0x062c74f9d27b1178bb76186c1756128ccb3ccd2e", + "allowTokens": "0x8df20c2c85bee0c3da250da96d892598c70aa1be", + "erc777Converter": "0xC0b2A9E31f69e4F0bC24584C678C582714a4fA1b", + "host": "https://mainnet.infura.io/v3/f02caaf003d14ad7bee83f33eeda2f5a", + "fromBlock": 12110034 +} diff --git a/federator-env/mainnet-ETH-RSK/rskmainnet.json b/federator-env/mainnet-ETH-RSK/rskmainnet.json index acbfb1c1..836f4ba9 100644 --- a/federator-env/mainnet-ETH-RSK/rskmainnet.json +++ b/federator-env/mainnet-ETH-RSK/rskmainnet.json @@ -2,7 +2,7 @@ "bridge": "0x1ccad820b6d031b41c54f1f3da11c0d48b399581", "federation": "0x5e2ee3cd18421838d066bd1dc02fb1f767d834dd", "multiSig": "0xb64322e10b5ae1be121b8bb0dead560c53d9dbc3", - "allowTokens": "0xd2090fe759613c3a3e2962c6bb2ad046f62d32ff", + "allowTokens": "0x7DC1D73C620cF8eB167eDD32942DA0d01B70adC0", "erc777Converter": "0xb86623c103843ccf75c6f0073d84bcfc0e34536c", "host": "http://18.221.155.102:4444/", "fromBlock": 3258718 diff --git a/federator-env/mainnet-ETH-RSK/rskmainnet_v5.json b/federator-env/mainnet-ETH-RSK/rskmainnet_v5.json new file mode 100644 index 00000000..acbfb1c1 --- /dev/null +++ b/federator-env/mainnet-ETH-RSK/rskmainnet_v5.json @@ -0,0 +1,9 @@ +{ + "bridge": "0x1ccad820b6d031b41c54f1f3da11c0d48b399581", + "federation": "0x5e2ee3cd18421838d066bd1dc02fb1f767d834dd", + "multiSig": "0xb64322e10b5ae1be121b8bb0dead560c53d9dbc3", + "allowTokens": "0xd2090fe759613c3a3e2962c6bb2ad046f62d32ff", + "erc777Converter": "0xb86623c103843ccf75c6f0073d84bcfc0e34536c", + "host": "http://18.221.155.102:4444/", + "fromBlock": 3258718 +} \ No newline at end of file diff --git a/federator-env/testnet-BSC-RSK/btestnet.json b/federator-env/testnet-BSC-RSK/btestnet.json index 00bad1ca..1507b76d 100644 --- a/federator-env/testnet-BSC-RSK/btestnet.json +++ b/federator-env/testnet-BSC-RSK/btestnet.json @@ -2,8 +2,8 @@ "bridge": "0x862e8aff917319594cc7faaae5350d21196c086f", "federation": "0x6E28bB6dbBAc8bBC11F5780E39f9Aca9F9737182", "multiSig": "0x1d8cb60d35fcd42a8bd18d027386be9c0f9c509b", - "allowTokens": "0xeb23e848ceca88b7d0c019c7186bb86cefadd0bd", + "allowTokens": "0xC5681BE5d054167660cfF2d69c6f80521f249060", "erc777Converter": "0x573CAF2cA648e22fE9721EDB5DdfBdF5645ffd18", - "host": "https://data-seed-prebsc-1-s1.binance.org:8545/", + "host": "http://bsctestnet1.sovryn.app:8575/", "fromBlock": 16600000 } diff --git a/federator-env/testnet-BSC-RSK/btestnet_v5.json b/federator-env/testnet-BSC-RSK/btestnet_v5.json new file mode 100644 index 00000000..00bad1ca --- /dev/null +++ b/federator-env/testnet-BSC-RSK/btestnet_v5.json @@ -0,0 +1,9 @@ +{ + "bridge": "0x862e8aff917319594cc7faaae5350d21196c086f", + "federation": "0x6E28bB6dbBAc8bBC11F5780E39f9Aca9F9737182", + "multiSig": "0x1d8cb60d35fcd42a8bd18d027386be9c0f9c509b", + "allowTokens": "0xeb23e848ceca88b7d0c019c7186bb86cefadd0bd", + "erc777Converter": "0x573CAF2cA648e22fE9721EDB5DdfBdF5645ffd18", + "host": "https://data-seed-prebsc-1-s1.binance.org:8545/", + "fromBlock": 16600000 +} diff --git a/sovryn-token-bridge/abis/AllowTokens.json b/sovryn-token-bridge/abis/AllowTokens.json index 66b55f51..25d1f7a3 100644 --- a/sovryn-token-bridge/abis/AllowTokens.json +++ b/sovryn-token-bridge/abis/AllowTokens.json @@ -1 +1 @@ -[{"inputs":[{"internalType":"address","name":"_manager","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_tokenAddress","type":"address"}],"name":"AllowedTokenAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_tokenAddress","type":"address"}],"name":"AllowedTokenRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"_enabled","type":"bool"}],"name":"AllowedTokenValidation","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"dailyLimit","type":"uint256"}],"name":"DailyLimitChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_token","type":"address"},{"indexed":false,"internalType":"uint256","name":"_feeConst","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_minAmount","type":"uint256"}],"name":"FeeAndMinPerTokenChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_maxTokens","type":"uint256"}],"name":"MaxTokensAllowedChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_minTokens","type":"uint256"}],"name":"MinTokensAllowedChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"allowedTokens","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"dailyLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"feeConstToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"minAllowedToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"isValidatingAllowedTokens","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getMaxTokensAllowed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getMinTokensAllowed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"isTokenAllowed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"addAllowedToken","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"removeAllowedToken","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"enableAllowedTokensValidation","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"disableAllowedTokensValidation","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"maxTokens","type":"uint256"}],"name":"setMaxTokensAllowed","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"minTokens","type":"uint256"}],"name":"setMinTokensAllowed","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_dailyLimit","type":"uint256"}],"name":"changeDailyLimit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"tokenToUse","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"spentToday","type":"uint256"},{"internalType":"bool","name":"isSideToken","type":"bool"}],"name":"isValidTokenTransfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"spentToday","type":"uint256"}],"name":"calcMaxWithdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getMinPerToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getFeePerToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"_feeConst","type":"uint256"},{"internalType":"uint256","name":"_minAmount","type":"uint256"}],"name":"setFeeAndMinPerToken","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] \ No newline at end of file +[{"inputs":[{"internalType":"address","name":"_manager","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_tokenAddress","type":"address"}],"name":"AllowedTokenAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_tokenAddress","type":"address"}],"name":"AllowedTokenRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"_enabled","type":"bool"}],"name":"AllowedTokenValidation","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"dailyLimit","type":"uint256"}],"name":"DailyLimitChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_token","type":"address"},{"indexed":false,"internalType":"uint256","name":"_feeConst","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_minAmount","type":"uint256"}],"name":"FeeAndMinPerTokenChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_token","type":"address"},{"indexed":false,"internalType":"uint256","name":"_maxAmount","type":"uint256"}],"name":"MaxPerTokenChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_maxTokens","type":"uint256"}],"name":"MaxTokensAllowedChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_minTokens","type":"uint256"}],"name":"MinTokensAllowedChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"allowedTokens","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"dailyLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"feeConstToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"maxAllowedToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"minAllowedToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"isValidatingAllowedTokens","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getMaxTokensAllowed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getMinTokensAllowed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"isTokenAllowed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"addAllowedToken","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"removeAllowedToken","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"enableAllowedTokensValidation","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"disableAllowedTokensValidation","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"maxTokens","type":"uint256"}],"name":"setMaxTokensAllowed","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"minTokens","type":"uint256"}],"name":"setMinTokensAllowed","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_dailyLimit","type":"uint256"}],"name":"changeDailyLimit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"tokenToUse","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"spentToday","type":"uint256"},{"internalType":"bool","name":"isSideToken","type":"bool"}],"name":"isValidTokenTransfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"spentToday","type":"uint256"}],"name":"calcMaxWithdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getMinPerToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getFeePerToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"_feeConst","type":"uint256"},{"internalType":"uint256","name":"_minAmount","type":"uint256"}],"name":"setFeeAndMinPerToken","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"_maxAmount","type":"uint256"}],"name":"setMaxPerToken","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getMaxPerToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}] \ No newline at end of file diff --git a/sovryn-token-bridge/bridge/.openzeppelin/.session b/sovryn-token-bridge/bridge/.openzeppelin/.session index ee1dda7e..6d59c13f 100644 --- a/sovryn-token-bridge/bridge/.openzeppelin/.session +++ b/sovryn-token-bridge/bridge/.openzeppelin/.session @@ -1,4 +1,4 @@ { - "network": "rinkeby", - "expires": "2021-11-11T08:07:12.664Z" + "network": "development", + "expires": "2022-05-02T15:52:29.232Z" } diff --git a/sovryn-token-bridge/bridge/.openzeppelin/dev-5777.json b/sovryn-token-bridge/bridge/.openzeppelin/dev-5777.json index 39f5a1dd..d3b6b479 100644 --- a/sovryn-token-bridge/bridge/.openzeppelin/dev-5777.json +++ b/sovryn-token-bridge/bridge/.openzeppelin/dev-5777.json @@ -1,11 +1,11 @@ { "contracts": { "Bridge": { - "address": "0xaa09dae096eA21b09684AE5b6Bd48911447f910c", - "constructorCode": "6080604052614b2e806100136000396000f3fe", - "bodyBytecodeHash": "19f339b27577150ff5f003fb484eb1121309368d76cc660cf6637f3a562513bb", - "localBytecodeHash": "d16eb678c9d2568844d1dc7bc07613ee02fe1963be9e0a61b2c8170a32515092", - "deployedBytecodeHash": "ef7c604533e2659b9d65f0e03710b3ddc52aab2fc0ca22eafe40e7f062e7e2f6", + "address": "0x18A2CE3371609E94e68828fefE0d618031DAF2db", + "constructorCode": "6080604052614de9806100136000396000f3fe", + "bodyBytecodeHash": "6f8f2d0cf6ee9e758fb2a47aa56763b64149e263c7832c6e53acd9d9598af555", + "localBytecodeHash": "3d9e3caebf3321e057b01d6aa454eb0081b5162cc633846636c66600ca38faf5", + "deployedBytecodeHash": "b9054969ce88118f3cb3cd78f2f8199b9b002ddf55af230adabe69e561d7c5c4", "types": { "t_bool": { "id": "t_bool", @@ -31,9 +31,9 @@ "members": [ { "label": "bearer", - "astId": 15168, + "astId": 8113, "type": "t_mapping", - "src": "150:32:42" + "src": "150:32:33" } ] }, @@ -65,217 +65,225 @@ "contract": "Initializable", "path": "contracts/zeppelin/upgradable/Initializable.sol", "label": "initialized", - "astId": 18589, + "astId": 11534, "type": "t_bool", - "src": "757:24:61" + "src": "757:24:52" }, { "contract": "Initializable", "path": "contracts/zeppelin/upgradable/Initializable.sol", "label": "initializing", - "astId": 18591, + "astId": 11536, "type": "t_bool", - "src": "876:25:61" + "src": "876:25:52" }, { "contract": "Initializable", "path": "contracts/zeppelin/upgradable/Initializable.sol", "label": "______gap", - "astId": 18647, + "astId": 11592, "type": "t_array:50", - "src": "1945:29:61" + "src": "1945:29:52" }, { "contract": "UpgradablePauserRole", "path": "contracts/zeppelin/upgradable/access/roles/UpgradablePauserRole.sol", "label": "_pausers", - "astId": 18670, + "astId": 11615, "type": "t_struct", - "src": "326:27:62" + "src": "326:27:53" }, { "contract": "UpgradablePausable", "path": "contracts/zeppelin/upgradable/lifecycle/UpgradablePausable.sol", "label": "_paused", - "astId": 18788, + "astId": 11733, "type": "t_bool", - "src": "912:20:63" + "src": "912:20:54" }, { "contract": "UpgradableOwnable", "path": "contracts/zeppelin/upgradable/ownership/UpgradableOwnable.sol", "label": "_owner", - "astId": 18878, + "astId": 11823, "type": "t_address", - "src": "509:22:64" + "src": "509:22:55" }, { "contract": "ReentrancyGuard", "path": "contracts/zeppelin/upgradable/utils/ReentrancyGuard.sol", "label": "_guardCounter", - "astId": 18995, + "astId": 11940, "type": "t_uint256", - "src": "400:29:65" + "src": "400:29:56" }, { "contract": "Bridge", "path": "contracts/Bridge.sol", "label": "federation", - "astId": 916, + "astId": 992, "type": "t_address", - "src": "1217:26:2" + "src": "1249:26:2" }, { "contract": "Bridge", "path": "contracts/Bridge.sol", "label": "feePercentage", - "astId": 918, + "astId": 994, "type": "t_uint256", - "src": "1249:29:2" + "src": "1281:29:2" }, { "contract": "Bridge", "path": "contracts/Bridge.sol", "label": "symbolPrefix", - "astId": 920, + "astId": 996, "type": "t_string", - "src": "1284:26:2" + "src": "1316:26:2" }, { "contract": "Bridge", "path": "contracts/Bridge.sol", "label": "lastDay", - "astId": 922, + "astId": 998, "type": "t_uint256", - "src": "1316:22:2" + "src": "1348:22:2" }, { "contract": "Bridge", "path": "contracts/Bridge.sol", "label": "spentToday", - "astId": 924, + "astId": 1000, "type": "t_uint256", - "src": "1344:25:2" + "src": "1376:25:2" }, { "contract": "Bridge", "path": "contracts/Bridge.sol", "label": "mappedTokens", - "astId": 928, + "astId": 1004, "type": "t_mapping", - "src": "1376:51:2" + "src": "1408:51:2" }, { "contract": "Bridge", "path": "contracts/Bridge.sol", "label": "originalTokens", - "astId": 932, + "astId": 1008, "type": "t_mapping", - "src": "1463:50:2" + "src": "1495:50:2" }, { "contract": "Bridge", "path": "contracts/Bridge.sol", "label": "knownTokens", - "astId": 936, + "astId": 1012, "type": "t_mapping", - "src": "1549:44:2" + "src": "1581:44:2" }, { "contract": "Bridge", "path": "contracts/Bridge.sol", "label": "processed", - "astId": 940, + "astId": 1016, "type": "t_mapping", - "src": "1624:41:2" + "src": "1656:41:2" }, { "contract": "Bridge", "path": "contracts/Bridge.sol", "label": "allowTokens", - "astId": 942, + "astId": 1018, "type": "t_address", - "src": "1696:31:2" + "src": "1728:31:2" }, { "contract": "Bridge", "path": "contracts/Bridge.sol", "label": "sideTokenFactory", - "astId": 944, + "astId": 1020, "type": "t_address", - "src": "1733:41:2" + "src": "1765:41:2" }, { "contract": "Bridge", "path": "contracts/Bridge.sol", "label": "isUpgrading", - "astId": 946, + "astId": 1022, "type": "t_bool", - "src": "1806:23:2" + "src": "1838:23:2" }, { "contract": "Bridge", "path": "contracts/Bridge.sol", "label": "alreadyRun", - "astId": 951, + "astId": 1027, "type": "t_bool", - "src": "1929:23:2" + "src": "1961:23:2" }, { "contract": "Bridge", "path": "contracts/Bridge.sol", "label": "initialPrefixSetup", - "astId": 953, + "astId": 1029, "type": "t_bool", - "src": "1984:30:2" + "src": "2016:30:2" }, { "contract": "Bridge", "path": "contracts/Bridge.sol", "label": "isSuffix", - "astId": 955, + "astId": 1031, "type": "t_bool", - "src": "2020:20:2" + "src": "2052:20:2" }, { "contract": "Bridge", "path": "contracts/Bridge.sol", "label": "ethFirstTransfer", - "astId": 957, + "astId": 1033, "type": "t_bool", - "src": "2046:29:2" + "src": "2078:29:2" }, { "contract": "Bridge", "path": "contracts/Bridge.sol", "label": "ethFeeCollected", - "astId": 959, + "astId": 1035, "type": "t_uint256", - "src": "2081:30:2" + "src": "2113:30:2" }, { "contract": "Bridge", "path": "contracts/Bridge.sol", "label": "WETHAddr", - "astId": 961, + "astId": 1037, "type": "t_address", - "src": "2117:24:2" + "src": "2149:24:2" }, { "contract": "Bridge", "path": "contracts/Bridge.sol", "label": "nativeTokenSymbol", - "astId": 963, + "astId": 1039, "type": "t_string", - "src": "2147:32:2" + "src": "2179:32:2" }, { "contract": "Bridge", "path": "contracts/Bridge.sol", "label": "erc777ConverterAddr", - "astId": 965, + "astId": 1041, "type": "t_address", - "src": "2211:34:2" + "src": "2243:34:2" + }, + { + "contract": "Bridge", + "path": "contracts/Bridge.sol", + "label": "isBridgeReceiver", + "astId": 1045, + "type": "t_mapping", + "src": "2309:48:2" } ], "warnings": { @@ -287,7 +295,7 @@ } }, "Bridge_v0": { - "address": "0x14B24dF5eB138953Ba64E065aFD1c48858235415", + "address": "0x2D000B4a07b70d6BA2A86Cc3a94486a57aA7c1c0", "constructorCode": "60806040526134fc806100136000396000f3fe", "bodyBytecodeHash": "e59c8aebf19a090251c3edf9c7a046a973603db40d15bcefa75f7d4182303171", "localBytecodeHash": "c3b1253a7386a4bbcf6b1c7259f99be9ed5d134c13dca552cbe0e4f0f0df11c7", @@ -317,9 +325,9 @@ "members": [ { "label": "bearer", - "astId": 15168, + "astId": 8113, "type": "t_mapping", - "src": "150:32:42" + "src": "150:32:33" } ] }, @@ -351,63 +359,63 @@ "contract": "Initializable", "path": "contracts/zeppelin/upgradable/Initializable.sol", "label": "initialized", - "astId": 18589, + "astId": 11534, "type": "t_bool", - "src": "757:24:61" + "src": "757:24:52" }, { "contract": "Initializable", "path": "contracts/zeppelin/upgradable/Initializable.sol", "label": "initializing", - "astId": 18591, + "astId": 11536, "type": "t_bool", - "src": "876:25:61" + "src": "876:25:52" }, { "contract": "Initializable", "path": "contracts/zeppelin/upgradable/Initializable.sol", "label": "______gap", - "astId": 18647, + "astId": 11592, "type": "t_array:50", - "src": "1945:29:61" + "src": "1945:29:52" }, { "contract": "UpgradablePauserRole", "path": "contracts/zeppelin/upgradable/access/roles/UpgradablePauserRole.sol", "label": "_pausers", - "astId": 18670, + "astId": 11615, "type": "t_struct", - "src": "326:27:62" + "src": "326:27:53" }, { "contract": "UpgradablePausable", "path": "contracts/zeppelin/upgradable/lifecycle/UpgradablePausable.sol", "label": "_paused", - "astId": 18788, + "astId": 11733, "type": "t_bool", - "src": "912:20:63" + "src": "912:20:54" }, { "contract": "UpgradableOwnable", "path": "contracts/zeppelin/upgradable/ownership/UpgradableOwnable.sol", "label": "_owner", - "astId": 18878, + "astId": 11823, "type": "t_address", - "src": "509:22:64" + "src": "509:22:55" }, { "contract": "ReentrancyGuard", "path": "contracts/zeppelin/upgradable/utils/ReentrancyGuard.sol", "label": "_guardCounter", - "astId": 18995, + "astId": 11940, "type": "t_uint256", - "src": "400:29:65" + "src": "400:29:56" }, { "contract": "Bridge_v0", "path": "contracts/Bridge_v0.sol", "label": "federation", - "astId": 2438, + "astId": 2570, "type": "t_address", "src": "1169:26:3" }, @@ -415,7 +423,7 @@ "contract": "Bridge_v0", "path": "contracts/Bridge_v0.sol", "label": "crossingPayment", - "astId": 2440, + "astId": 2572, "type": "t_uint256", "src": "1201:31:3" }, @@ -423,7 +431,7 @@ "contract": "Bridge_v0", "path": "contracts/Bridge_v0.sol", "label": "symbolPrefix", - "astId": 2442, + "astId": 2574, "type": "t_string", "src": "1238:26:3" }, @@ -431,7 +439,7 @@ "contract": "Bridge_v0", "path": "contracts/Bridge_v0.sol", "label": "lastDay", - "astId": 2444, + "astId": 2576, "type": "t_uint256", "src": "1270:22:3" }, @@ -439,7 +447,7 @@ "contract": "Bridge_v0", "path": "contracts/Bridge_v0.sol", "label": "spentToday", - "astId": 2446, + "astId": 2578, "type": "t_uint256", "src": "1298:25:3" }, @@ -447,7 +455,7 @@ "contract": "Bridge_v0", "path": "contracts/Bridge_v0.sol", "label": "mappedTokens", - "astId": 2450, + "astId": 2582, "type": "t_mapping", "src": "1330:53:3" }, @@ -455,7 +463,7 @@ "contract": "Bridge_v0", "path": "contracts/Bridge_v0.sol", "label": "originalTokens", - "astId": 2454, + "astId": 2586, "type": "t_mapping", "src": "1419:50:3" }, @@ -463,7 +471,7 @@ "contract": "Bridge_v0", "path": "contracts/Bridge_v0.sol", "label": "knownTokens", - "astId": 2458, + "astId": 2590, "type": "t_mapping", "src": "1505:44:3" }, @@ -471,7 +479,7 @@ "contract": "Bridge_v0", "path": "contracts/Bridge_v0.sol", "label": "processed", - "astId": 2462, + "astId": 2594, "type": "t_mapping", "src": "1580:34:3" }, @@ -479,7 +487,7 @@ "contract": "Bridge_v0", "path": "contracts/Bridge_v0.sol", "label": "allowTokens", - "astId": 2464, + "astId": 2596, "type": "t_address", "src": "1645:33:3" }, @@ -487,7 +495,7 @@ "contract": "Bridge_v0", "path": "contracts/Bridge_v0.sol", "label": "sideTokenFactory", - "astId": 2466, + "astId": 2598, "type": "t_address", "src": "1684:43:3" } @@ -503,7 +511,7 @@ }, "solidityLibs": { "Utils": { - "address": "0xcff9826B1D94069D5fBAB59e12dED2ED1e89215F", + "address": "0x3f987474a17127A46C18270a142B60464Fda4121", "constructorCode": "610eaf610026600b82828239805160001a60731461001957fe5b30600052607381538281f3fe", "bodyBytecodeHash": "7b92c727771bd2be69e9ad2c2f1fe8eaae2fb49b79dc8791cdac574a46bd4e7d", "localBytecodeHash": "881acbaf40d56245f74ff09fb9da845e7dfc0f3a921b497072202c66312781f8", @@ -513,10 +521,10 @@ "proxies": { "bridge/Bridge_v0": [ { - "address": "0x08BC3354a441A498134c1E7e5BA8348Ab1d79609", + "address": "0xc30D0Dc9a12866E67EDAB41BC67026EB24D0D9e5", "version": "1.0.0", - "implementation": "0x14B24dF5eB138953Ba64E065aFD1c48858235415", - "admin": "0x3712776637EAa5763bd06E113d9935F0D283236C", + "implementation": "0x2D000B4a07b70d6BA2A86Cc3a94486a57aA7c1c0", + "admin": "0x1738DDE13D91805535882a7595d247B2f9340AE7", "kind": "Upgradeable" } ] @@ -524,6 +532,6 @@ "manifestVersion": "2.2", "version": "1.0.0", "proxyAdmin": { - "address": "0x3712776637EAa5763bd06E113d9935F0D283236C" + "address": "0x1738DDE13D91805535882a7595d247B2f9340AE7" } } diff --git a/sovryn-token-bridge/bridge/Old_Contracts/AllowTokens_v1.sol b/sovryn-token-bridge/bridge/Old_Contracts/AllowTokens_v1.sol new file mode 100644 index 00000000..54fd0063 --- /dev/null +++ b/sovryn-token-bridge/bridge/Old_Contracts/AllowTokens_v1.sol @@ -0,0 +1,167 @@ +pragma solidity >=0.4.21 <0.6.0; + +import "./zeppelin/math/SafeMath.sol"; +import "./zeppelin/ownership/Ownable.sol"; +import "./IAllowTokens.sol"; + +contract AllowTokens_v1 is IAllowTokens, Ownable { + using SafeMath for uint256; + + address constant private NULL_ADDRESS = address(0); + + mapping (address => bool) public allowedTokens; + bool private validateAllowedTokens; + uint256 private maxTokensAllowed; + uint256 private minTokensAllowed; + uint256 public dailyLimit; + +// Bridge v3 upgrade variables +// minimum amount allowed per token + mapping (address => uint) public minAllowedToken; +// constant fee per token + mapping (address => uint) public feeConstToken; + + event AllowedTokenAdded(address indexed _tokenAddress); + event AllowedTokenRemoved(address indexed _tokenAddress); + event AllowedTokenValidation(bool _enabled); + event MaxTokensAllowedChanged(uint256 _maxTokens); + event MinTokensAllowedChanged(uint256 _minTokens); + event DailyLimitChanged(uint256 dailyLimit); + +// Bridge v3 upgrade events + event FeeAndMinPerTokenChanged(address _token, uint256 _feeConst, uint256 _minAmount); + + modifier notNull(address _address) { + require(_address != NULL_ADDRESS, "AllowTokens: Address cannot be empty"); + _; + } + + constructor(address _manager) public { + transferOwnership(_manager); + validateAllowedTokens = true; + maxTokensAllowed = 100000 ether; + minTokensAllowed = 1 ether; + dailyLimit = 1000000 ether; + } + + function isValidatingAllowedTokens() external view returns(bool) { + return validateAllowedTokens; + } + + function getMaxTokensAllowed() external view returns(uint256) { + return maxTokensAllowed; + } + + function getMinTokensAllowed() external view returns(uint256) { + return minTokensAllowed; + } + + function allowedTokenExist(address token) private view notNull(token) returns (bool) { + return allowedTokens[token]; + } + + function isTokenAllowed(address token) public view notNull(token) returns (bool) { + if (validateAllowedTokens) { + return allowedTokenExist(token); + } + return true; + } + + function addAllowedToken(address token) external onlyOwner { + require(!allowedTokenExist(token), "AllowTokens: Token already exists in allowedTokens"); + allowedTokens[token] = true; + emit AllowedTokenAdded(token); + } + + function removeAllowedToken(address token) external onlyOwner { + require(allowedTokenExist(token), "AllowTokens: Token does not exis in allowedTokenst"); + allowedTokens[token] = false; + emit AllowedTokenRemoved(token); + } + + function enableAllowedTokensValidation() external onlyOwner { + validateAllowedTokens = true; + emit AllowedTokenValidation(validateAllowedTokens); + } + + function disableAllowedTokensValidation() external onlyOwner { + // Before disabling Allowed Tokens Validations some kind of contract validation system + // should be implemented on the Bridge for the methods receiveTokens, tokenFallback and tokensReceived + validateAllowedTokens = false; + emit AllowedTokenValidation(validateAllowedTokens); + } + + function setMaxTokensAllowed(uint256 maxTokens) external onlyOwner { + require(maxTokens >= minTokensAllowed, "AllowTokens: Max Tokens should be equal or bigger than Min Tokens"); + maxTokensAllowed = maxTokens; + emit MaxTokensAllowedChanged(maxTokensAllowed); + } + + function setMinTokensAllowed(uint256 minTokens) external onlyOwner { + require(maxTokensAllowed >= minTokens, "AllowTokens: Min Tokens should be equal or smaller than Max Tokens"); + minTokensAllowed = minTokens; + emit MinTokensAllowedChanged(minTokensAllowed); + } + + function changeDailyLimit(uint256 _dailyLimit) external onlyOwner { + require(_dailyLimit >= maxTokensAllowed, "AllowTokens: Daily Limit should be equal or bigger than Max Tokens"); + dailyLimit = _dailyLimit; + emit DailyLimitChanged(_dailyLimit); + } + + // solium-disable-next-line max-len + function isValidTokenTransfer(address tokenToUse, uint amount, uint spentToday, bool isSideToken) external view returns (bool) { + if(amount > maxTokensAllowed) + return false; + if(amount < minAllowedToken[tokenToUse]) + return false; + if (spentToday + amount > dailyLimit || spentToday + amount < spentToday) + return false; + if(!isSideToken && !isTokenAllowed(tokenToUse)) + return false; + if(feeConstToken[tokenToUse] == 0 ) + return false; + return true; + } + + function calcMaxWithdraw(uint spentToday) external view returns (uint) { + uint maxWithrow = dailyLimit - spentToday; + if (dailyLimit < spentToday) + return 0; + if(maxWithrow > maxTokensAllowed) + maxWithrow = maxTokensAllowed; + return maxWithrow; + } + +// Bridge v3 upgrade functions + function getMinPerToken(address token) external view returns(uint256) { + return minAllowedToken[token]; + } + + function getFeePerToken(address token) public view returns(uint256) { + return feeConstToken[token]; + } + + //function setMinPerToken(address token, uint256 minAmount) external onlyOwner { + // require(minAmount <= maxTokensAllowed, "AllowTokens: Min Tokens should be equal or smaller than Max Tokens"); + // require(minAmount >= feeConstToken[token], "AllowTokens: Min Tokens should be equal bigger than fee"); + // minAllowedToken[token] = minAmount; + // emit MinPerTokenChanged(token, minAmount); + // } + + //function setFeePerToken(address token, uint256 feeConst) external onlyOwner { + // require(feeConst >= minAllowedToken[token], "AllowTokens: Fee per Token should be equal or bigger than Min allowed"); + // feeConstToken[token] = feeConst; + // emit FeePerTokenChanged(token, feeConst); + //} + + function setFeeAndMinPerToken(address token, uint256 _feeConst, uint256 _minAmount) external onlyOwner { + require(_minAmount <= maxTokensAllowed, "AllowTokens: Min Tokens should be equal or smaller than Max Tokens"); + require(_minAmount >= _feeConst, "AllowTokens: Min Tokens should be equal bigger than fee"); + require(_feeConst > 0, "AllowTokens: Fee Should be> 0"); + feeConstToken[token] = _feeConst; + minAllowedToken[token] = _minAmount; + emit FeeAndMinPerTokenChanged(token, _feeConst, _minAmount); + } + +} diff --git a/sovryn-token-bridge/bridge/contracts/Bridge_v1.sol b/sovryn-token-bridge/bridge/Old_Contracts/Bridge_v1.sol similarity index 100% rename from sovryn-token-bridge/bridge/contracts/Bridge_v1.sol rename to sovryn-token-bridge/bridge/Old_Contracts/Bridge_v1.sol diff --git a/sovryn-token-bridge/bridge/contracts/Bridge_v2.sol b/sovryn-token-bridge/bridge/Old_Contracts/Bridge_v2.sol similarity index 100% rename from sovryn-token-bridge/bridge/contracts/Bridge_v2.sol rename to sovryn-token-bridge/bridge/Old_Contracts/Bridge_v2.sol diff --git a/sovryn-token-bridge/bridge/contracts/Bridge_v3.sol b/sovryn-token-bridge/bridge/Old_Contracts/Bridge_v3.sol similarity index 100% rename from sovryn-token-bridge/bridge/contracts/Bridge_v3.sol rename to sovryn-token-bridge/bridge/Old_Contracts/Bridge_v3.sol diff --git a/sovryn-token-bridge/bridge/contracts/Bridge_v4.sol b/sovryn-token-bridge/bridge/Old_Contracts/Bridge_v4.sol similarity index 100% rename from sovryn-token-bridge/bridge/contracts/Bridge_v4.sol rename to sovryn-token-bridge/bridge/Old_Contracts/Bridge_v4.sol diff --git a/sovryn-token-bridge/bridge/contracts/Federation_v1.sol b/sovryn-token-bridge/bridge/Old_Contracts/Federation_v1.sol similarity index 100% rename from sovryn-token-bridge/bridge/contracts/Federation_v1.sol rename to sovryn-token-bridge/bridge/Old_Contracts/Federation_v1.sol diff --git a/sovryn-token-bridge/bridge/contracts/Federation_v2.sol b/sovryn-token-bridge/bridge/Old_Contracts/Federation_v2.sol similarity index 100% rename from sovryn-token-bridge/bridge/contracts/Federation_v2.sol rename to sovryn-token-bridge/bridge/Old_Contracts/Federation_v2.sol diff --git a/sovryn-token-bridge/bridge/contracts/IBridge_v1.sol b/sovryn-token-bridge/bridge/Old_Contracts/IBridge_v1.sol similarity index 100% rename from sovryn-token-bridge/bridge/contracts/IBridge_v1.sol rename to sovryn-token-bridge/bridge/Old_Contracts/IBridge_v1.sol diff --git a/sovryn-token-bridge/bridge/contracts/IBridge_v2.sol b/sovryn-token-bridge/bridge/Old_Contracts/IBridge_v2.sol similarity index 100% rename from sovryn-token-bridge/bridge/contracts/IBridge_v2.sol rename to sovryn-token-bridge/bridge/Old_Contracts/IBridge_v2.sol diff --git a/sovryn-token-bridge/bridge/contracts/IBridge_v3.sol b/sovryn-token-bridge/bridge/Old_Contracts/IBridge_v3.sol similarity index 100% rename from sovryn-token-bridge/bridge/contracts/IBridge_v3.sol rename to sovryn-token-bridge/bridge/Old_Contracts/IBridge_v3.sol diff --git a/sovryn-token-bridge/bridge/contracts/IBridge_v4.sol b/sovryn-token-bridge/bridge/Old_Contracts/IBridge_v4.sol similarity index 100% rename from sovryn-token-bridge/bridge/contracts/IBridge_v4.sol rename to sovryn-token-bridge/bridge/Old_Contracts/IBridge_v4.sol diff --git a/sovryn-token-bridge/bridge/contracts/SideToken_v1.sol b/sovryn-token-bridge/bridge/Old_Contracts/SideToken_v1.sol similarity index 100% rename from sovryn-token-bridge/bridge/contracts/SideToken_v1.sol rename to sovryn-token-bridge/bridge/Old_Contracts/SideToken_v1.sol diff --git a/sovryn-token-bridge/bridge/migrations/12_deploy_federation_v1.js b/sovryn-token-bridge/bridge/Old_Migrations/12_deploy_federation_v1.js similarity index 100% rename from sovryn-token-bridge/bridge/migrations/12_deploy_federation_v1.js rename to sovryn-token-bridge/bridge/Old_Migrations/12_deploy_federation_v1.js diff --git a/sovryn-token-bridge/bridge/migrations/13_deploy_bridge_v1.js b/sovryn-token-bridge/bridge/Old_Migrations/13_deploy_bridge_v1.js similarity index 100% rename from sovryn-token-bridge/bridge/migrations/13_deploy_bridge_v1.js rename to sovryn-token-bridge/bridge/Old_Migrations/13_deploy_bridge_v1.js diff --git a/sovryn-token-bridge/bridge/migrations/14_set_federation.js b/sovryn-token-bridge/bridge/Old_Migrations/14_set_federation.js similarity index 100% rename from sovryn-token-bridge/bridge/migrations/14_set_federation.js rename to sovryn-token-bridge/bridge/Old_Migrations/14_set_federation.js diff --git a/sovryn-token-bridge/bridge/migrations/15_set_sideTokenFactory_v1.js b/sovryn-token-bridge/bridge/Old_Migrations/15_set_sideTokenFactory_v1.js similarity index 100% rename from sovryn-token-bridge/bridge/migrations/15_set_sideTokenFactory_v1.js rename to sovryn-token-bridge/bridge/Old_Migrations/15_set_sideTokenFactory_v1.js diff --git a/sovryn-token-bridge/bridge/migrations/16_deploy_bridge_v2.js b/sovryn-token-bridge/bridge/Old_Migrations/16_deploy_bridge_v2.js similarity index 100% rename from sovryn-token-bridge/bridge/migrations/16_deploy_bridge_v2.js rename to sovryn-token-bridge/bridge/Old_Migrations/16_deploy_bridge_v2.js diff --git a/sovryn-token-bridge/bridge/migrations/17_deploy_federation_v2.js b/sovryn-token-bridge/bridge/Old_Migrations/17_deploy_federation_v2.js similarity index 100% rename from sovryn-token-bridge/bridge/migrations/17_deploy_federation_v2.js rename to sovryn-token-bridge/bridge/Old_Migrations/17_deploy_federation_v2.js diff --git a/sovryn-token-bridge/bridge/migrations/18_deploy_allowTokens_v3.js b/sovryn-token-bridge/bridge/Old_Migrations/18_deploy_allowTokens_v3.js similarity index 100% rename from sovryn-token-bridge/bridge/migrations/18_deploy_allowTokens_v3.js rename to sovryn-token-bridge/bridge/Old_Migrations/18_deploy_allowTokens_v3.js diff --git a/sovryn-token-bridge/bridge/migrations/19_deploy_bridge_v3.js b/sovryn-token-bridge/bridge/Old_Migrations/19_deploy_bridge_v3.js similarity index 100% rename from sovryn-token-bridge/bridge/migrations/19_deploy_bridge_v3.js rename to sovryn-token-bridge/bridge/Old_Migrations/19_deploy_bridge_v3.js diff --git a/sovryn-token-bridge/bridge/migrations/21_deploy_bridge_v4.js b/sovryn-token-bridge/bridge/Old_Migrations/21_deploy_bridge_v4.js similarity index 100% rename from sovryn-token-bridge/bridge/migrations/21_deploy_bridge_v4.js rename to sovryn-token-bridge/bridge/Old_Migrations/21_deploy_bridge_v4.js diff --git a/sovryn-token-bridge/bridge/Upgrade_Migrations_v5MaxToken/12_deploy_allowToken.js b/sovryn-token-bridge/bridge/Upgrade_Migrations_v5MaxToken/12_deploy_allowToken.js new file mode 100644 index 00000000..950fe810 --- /dev/null +++ b/sovryn-token-bridge/bridge/Upgrade_Migrations_v5MaxToken/12_deploy_allowToken.js @@ -0,0 +1,21 @@ +// const MultiSigWallet = artifacts.require("MultiSigWallet"); +const AllowTokens = artifacts.require("AllowTokens"); +// const Bridge = artifacts.require("Bridge_v0"); +// const BridgeImpl = artifacts.require("Bridge"); + +module.exports = function(deployer, networkName, accounts) { + deployer + .then(async () => { + // const multiSig = await MultiSigWallet.deployed(); + //return deployer.deploy(AllowTokens, multiSig.address); + const allowToken = await deployer.deploy(AllowTokens, accounts[0] ); + + //Moved to upgrade script + // const bridge = await Bridge.deployed(); + + // const bridgeImpl = new web3.eth.Contract(BridgeImpl.abi, bridge.address); + // let data = bridgeImpl.methods.changeAllowTokens(allowToken.address).encodeABI(); + // await multiSig.submitTransaction(bridge.address, 0, data, { from: accounts[0] }); + + }); +}; \ No newline at end of file diff --git a/sovryn-token-bridge/bridge/Upgrade_Migrations_v5MaxToken/1_initial_migration.js b/sovryn-token-bridge/bridge/Upgrade_Migrations_v5MaxToken/1_initial_migration.js new file mode 100644 index 00000000..4d5f3f9b --- /dev/null +++ b/sovryn-token-bridge/bridge/Upgrade_Migrations_v5MaxToken/1_initial_migration.js @@ -0,0 +1,5 @@ +var Migrations = artifacts.require("./Migrations.sol"); + +module.exports = function(deployer) { + deployer.deploy(Migrations); +}; diff --git a/sovryn-token-bridge/bridge/contracts/AllowTokens.sol b/sovryn-token-bridge/bridge/contracts/AllowTokens.sol index aaed8e6b..53491554 100644 --- a/sovryn-token-bridge/bridge/contracts/AllowTokens.sol +++ b/sovryn-token-bridge/bridge/contracts/AllowTokens.sol @@ -20,6 +20,9 @@ contract AllowTokens is IAllowTokens, Ownable { mapping (address => uint) public minAllowedToken; // constant fee per token mapping (address => uint) public feeConstToken; +// maximum amount allowed per token + mapping (address => uint) public maxAllowedToken; + event AllowedTokenAdded(address indexed _tokenAddress); event AllowedTokenRemoved(address indexed _tokenAddress); @@ -30,6 +33,7 @@ contract AllowTokens is IAllowTokens, Ownable { // Bridge v3 upgrade events event FeeAndMinPerTokenChanged(address _token, uint256 _feeConst, uint256 _minAmount); + event MaxPerTokenChanged(address _token, uint256 _maxAmount); modifier notNull(address _address) { require(_address != NULL_ADDRESS, "AllowTokens: Address cannot be empty"); @@ -121,6 +125,11 @@ contract AllowTokens is IAllowTokens, Ownable { return false; if(feeConstToken[tokenToUse] == 0 ) return false; + if(maxAllowedToken[tokenToUse] > 0) { + if(amount > maxAllowedToken[tokenToUse]) { + return false; + } + } return true; } @@ -142,26 +151,27 @@ contract AllowTokens is IAllowTokens, Ownable { return feeConstToken[token]; } - //function setMinPerToken(address token, uint256 minAmount) external onlyOwner { - // require(minAmount <= maxTokensAllowed, "AllowTokens: Min Tokens should be equal or smaller than Max Tokens"); - // require(minAmount >= feeConstToken[token], "AllowTokens: Min Tokens should be equal bigger than fee"); - // minAllowedToken[token] = minAmount; - // emit MinPerTokenChanged(token, minAmount); - // } - - //function setFeePerToken(address token, uint256 feeConst) external onlyOwner { - // require(feeConst >= minAllowedToken[token], "AllowTokens: Fee per Token should be equal or bigger than Min allowed"); - // feeConstToken[token] = feeConst; - // emit FeePerTokenChanged(token, feeConst); - //} - function setFeeAndMinPerToken(address token, uint256 _feeConst, uint256 _minAmount) external onlyOwner { require(_minAmount <= maxTokensAllowed, "AllowTokens: Min Tokens should be equal or smaller than Max Tokens"); require(_minAmount >= _feeConst, "AllowTokens: Min Tokens should be equal bigger than fee"); require(_feeConst > 0, "AllowTokens: Fee Should be> 0"); + if (maxAllowedToken[token] != 0 ) { + require(_minAmount <= maxAllowedToken[token], "AllowTokens: Min Tokens should be equal or smaller than maxAllowedToken"); + } feeConstToken[token] = _feeConst; minAllowedToken[token] = _minAmount; emit FeeAndMinPerTokenChanged(token, _feeConst, _minAmount); } + function setMaxPerToken(address token, uint256 _maxAmount) external onlyOwner { + require(_maxAmount <= maxTokensAllowed, "AllowTokens: Max Tokens should be equal or smaller than Max Tokens"); + require(minAllowedToken[token] <= _maxAmount, "AllowTokens: maxAllowedToken[] should be equal or bigger than minAllowedToken[]"); + maxAllowedToken[token] = _maxAmount; + emit MaxPerTokenChanged(token, _maxAmount); + } + + function getMaxPerToken(address token) external view returns(uint256) { + return maxAllowedToken[token]; + } + } diff --git a/sovryn-token-bridge/bridge/migrations/24_deploy_bridge_v5.js b/sovryn-token-bridge/bridge/migrations/10_deploy_bridge_v5.js similarity index 100% rename from sovryn-token-bridge/bridge/migrations/24_deploy_bridge_v5.js rename to sovryn-token-bridge/bridge/migrations/10_deploy_bridge_v5.js diff --git a/sovryn-token-bridge/bridge/migrations/20_set_allowToken.js b/sovryn-token-bridge/bridge/migrations/12_deploy_allowToken.js similarity index 64% rename from sovryn-token-bridge/bridge/migrations/20_set_allowToken.js rename to sovryn-token-bridge/bridge/migrations/12_deploy_allowToken.js index 993cbb4b..41f63900 100644 --- a/sovryn-token-bridge/bridge/migrations/20_set_allowToken.js +++ b/sovryn-token-bridge/bridge/migrations/12_deploy_allowToken.js @@ -1,21 +1,20 @@ -//We are actually gona use Bridge_v1 but truffle only knows the address of the proxy by using Bridge_v0 +const MultiSigWallet = artifacts.require("MultiSigWallet"); +const AllowTokens = artifacts.require("AllowTokens"); const Bridge = artifacts.require("Bridge_v0"); const BridgeImpl = artifacts.require("Bridge"); -const AllowTokens = artifacts.require('AllowTokens'); -const MultiSigWallet = artifacts.require("MultiSigWallet"); module.exports = function(deployer, networkName, accounts) { deployer - .then(async ()=> { - if (networkName === 'soliditycoverage') { - return; - } + .then(async () => { const multiSig = await MultiSigWallet.deployed(); - const allowToken = await AllowTokens.deployed(); + //return deployer.deploy(AllowTokens, multiSig.address); + const allowToken = await deployer.deploy(AllowTokens, multiSig.address); + const bridge = await Bridge.deployed(); const bridgeImpl = new web3.eth.Contract(BridgeImpl.abi, bridge.address); let data = bridgeImpl.methods.changeAllowTokens(allowToken.address).encodeABI(); await multiSig.submitTransaction(bridge.address, 0, data, { from: accounts[0] }); + }); -} +}; \ No newline at end of file diff --git a/sovryn-token-bridge/bridge/migrations/22_deploy_federation_v3.js b/sovryn-token-bridge/bridge/migrations/13_deploy_federation.js similarity index 100% rename from sovryn-token-bridge/bridge/migrations/22_deploy_federation_v3.js rename to sovryn-token-bridge/bridge/migrations/13_deploy_federation.js diff --git a/sovryn-token-bridge/bridge/migrations/23_deploy_erc777Converter_v4.js b/sovryn-token-bridge/bridge/migrations/14_deploy_erc777Converter.js similarity index 100% rename from sovryn-token-bridge/bridge/migrations/23_deploy_erc777Converter_v4.js rename to sovryn-token-bridge/bridge/migrations/14_deploy_erc777Converter.js diff --git a/sovryn-token-bridge/bridge/migrations/25_create_config_file.js b/sovryn-token-bridge/bridge/migrations/15_create_config_file.js similarity index 100% rename from sovryn-token-bridge/bridge/migrations/25_create_config_file.js rename to sovryn-token-bridge/bridge/migrations/15_create_config_file.js diff --git a/sovryn-token-bridge/bridge/migrations/10_conditional_deploy_mainToken.js b/sovryn-token-bridge/bridge/migrations/4_conditional_deploy_mainToken.js similarity index 100% rename from sovryn-token-bridge/bridge/migrations/10_conditional_deploy_mainToken.js rename to sovryn-token-bridge/bridge/migrations/4_conditional_deploy_mainToken.js diff --git a/sovryn-token-bridge/bridge/migrations/4_deploy_erc1820.js b/sovryn-token-bridge/bridge/migrations/5_deploy_erc1820.js similarity index 100% rename from sovryn-token-bridge/bridge/migrations/4_deploy_erc1820.js rename to sovryn-token-bridge/bridge/migrations/5_deploy_erc1820.js diff --git a/sovryn-token-bridge/bridge/migrations/5_deploy_sideTokenFactory_v0.js b/sovryn-token-bridge/bridge/migrations/6_deploy_sideTokenFactory_v0.js similarity index 100% rename from sovryn-token-bridge/bridge/migrations/5_deploy_sideTokenFactory_v0.js rename to sovryn-token-bridge/bridge/migrations/6_deploy_sideTokenFactory_v0.js diff --git a/sovryn-token-bridge/bridge/scripts/BridgeAddresses.js b/sovryn-token-bridge/bridge/scripts/BridgeAddresses.js index 453087a3..f93de5f0 100644 --- a/sovryn-token-bridge/bridge/scripts/BridgeAddresses.js +++ b/sovryn-token-bridge/bridge/scripts/BridgeAddresses.js @@ -263,7 +263,7 @@ const RBTC_BscBSCMainnet = { name: "bRBTC", 56: { symbol: "bRBTC", - address: "", + address: "0x68e75416a99f61a8ef3186b3bee41dbf2a3fd4e8", decimals: 18, }, }; diff --git a/sovryn-token-bridge/bridge/scripts/BridgeMainnetAddresses_v5MaxToken.js b/sovryn-token-bridge/bridge/scripts/BridgeMainnetAddresses_v5MaxToken.js new file mode 100644 index 00000000..6e90b1c0 --- /dev/null +++ b/sovryn-token-bridge/bridge/scripts/BridgeMainnetAddresses_v5MaxToken.js @@ -0,0 +1,451 @@ +// Bring all the addresses deployed in rsk +const bscBSCBridge = require("../../../federator-env/mainnet-BSC-RSK/bmainnet.json"); +const rskBSCBridge = require("../../../federator-env/mainnet-BSC-RSK/rskmainnet.json"); +const rskETHBridge = require("../../../federator-env/mainnet-ETH-RSK/rskmainnet.json"); +const ethETHBridge = require("../../../federator-env/mainnet-ETH-RSK/mainnet.json"); + +const bscBSCBridgeV5 = require("../../../federator-env/mainnet-BSC-RSK/bmainnet_v5.json"); +const rskBSCBridgeV5 = require("../../../federator-env/mainnet-BSC-RSK/rskmainnet_v5.json"); +const ethETHBridgeV5 = require("../../../federator-env/mainnet-ETH-RSK/mainnet_v5.json"); +const rskETHBridgeV5 = require("../../../federator-env/mainnet-ETH-RSK/rskmainnet_v5.json"); + +// Bring all the addresses deployed in kovan +//const kovanAddresses = require("../../../federator/config/kovan.json"); + +// Asign ABIs to each variable from the JSON +const bridgeABI = require("../../abis/Bridge.json"); +const federationABI = require("../../abis/Federation.json"); +const multiSigABI = require("../../abis/MultiSigWallet.json"); +const allowTokensABI = require("../../abis/AllowTokens.json"); +const erc777ConverterABI = require("../../abis/Erc777Converter.json"); +const tokenABI = require("../build/contracts/AlternativeERC20Detailed.json").abi; + +const allowTokensV5ABI = require("./OldAbis/AllowTokensV5.json"); + +const abisObject = { + bridgeABI, + federationABI, + multiSigABI, + allowTokensABI, + erc777ConverterABI, + tokenABI, +}; + +const abisObjectV5 = { + bridgeABI, + federationABI, + multiSigABI, + allowTokensV5ABI, + erc777ConverterABI, + tokenABI, +}; + +// Build an object with all the rsk addresses +const rskBSCConfig = { + bridge: rskBSCBridge.bridge, + federation: rskBSCBridge.federation, + multiSig: rskBSCBridge.multiSig, + allowTokens: rskBSCBridge.allowTokens, + erc777Converter: rskBSCBridge.erc777Converter, +}; +const bscBSCConfig = { + bridge: bscBSCBridge.bridge, + federation: bscBSCBridge.federation, + multiSig: bscBSCBridge.multiSig, + allowTokens: bscBSCBridge.allowTokens, + erc777Converter: bscBSCBridge.erc777Converter, +}; + +const bscBSCV5Config = { + allowTokens: bscBSCBridgeV5.allowTokens, +}; +const rskBSCV5Config = { + allowTokens: rskBSCBridgeV5.allowTokens, +}; +const ethETHV5Config = { + allowTokens: ethETHBridgeV5.allowTokens, +}; +const rskETHV5Config = { + allowTokens: rskETHBridgeV5.allowTokens, +}; + + +const rskETHConfig = { + bridge: rskETHBridge.bridge, + federation: rskETHBridge.federation, + multiSig: rskETHBridge.multiSig, + allowTokens: rskETHBridge.allowTokens, + erc777Converter: rskETHBridge.erc777Converter, +}; +const ethETHConfig = { + bridge: ethETHBridge.bridge, + federation: ethETHBridge.federation, + multiSig: ethETHBridge.multiSig, + allowTokens: ethETHBridge.allowTokens, + erc777Converter: ethETHBridge.erc777Converter, +}; + +const DAI_Mainnet = { + token: "DAI", + name: "Dai Stablecoin", + 1: { + symbol: "DAI", + address: "0x6b175474e89094c44da98b954eedeac495271d0f", + decimals: 18, + }, +}; +const USDC_Mainnet = { + token: "USDC", + name: "USD Coin", + 1: { + symbol: "USDC", + address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", + decimals: 6, + }, +}; +const USDT_Mainnet = { + token: "USDT", + name: "Tether USD", + 1: { + symbol: "USDT", + address: "0xdac17f958d2ee523a2206206994597c13d831ec7", + decimals: 6, + }, +}; + + +// bmainnet stable coins +const DAI_BMainnet = { + token: "DAI", + name: "Dai Stablecoin", + 56: { + symbol: "DAI", + address: "0x1af3f329e8be154074d8769d1ffa4ee058b1dbc3", + decimals: 18, + }, +}; +const USDC_BMainnet = { + token: "USDC", + name: "USD Coin", + 56: { + symbol: "USDC", + address: "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d", + decimals: 18, + }, +}; +const USDT_BMainnet = { + token: "USDT", + name: "Tether USD", + 56: { + symbol: "USDT", + address: "0x55d398326f99059ff775485246999027b3197955", + decimals: 18, + }, +}; +const BUSD_BMainnet = { + token: "BUSD", + name: "Binance USD", + 56: { + symbol: "BUSD", + address: "0xe9e7cea3dedca5984780bafc599bd69add087d56", + decimals: 18, + }, +}; + +// bmainnet eth token +const ETH_BMainnet = { + token: "ETH", + name: "ETH Binance pegged", + 56: { + symbol: "ETH", + address: "0x2170ed0880ac9a755fd29b2688956bd959f933f8", + decimals: 18, + }, +}; + +// bmainnet bnb token +const BNB_BMainnet = { + token: "WBNB", + name: "BNB", + 56: { + symbol: "BNB", + address: "0xB6C313a427fa911A4C9a119e80Feea0fe20E69F0", + decimals: 18, + }, +}; + +// bmainnet sov +const SOV_BMainnet = { + token: "bSOV", + name: "Sovryn Token", + 56: { + symbol: "bSOV", + address: "0x8753ede1b3a36358e4d7780f384f3f7a2d9e4359", + decimals: 18, + }, +}; + +// mainnet sov +const SOV_Mainnet = { + token: "eSOV", + name: "Sovryn Token", + 1: { + symbol: "eSOV", + address: "0xbdab72602e9ad40fc6a6852caf43258113b8f7a5", + decimals: 18, + }, +}; + +// mainnet Weth +const ETH_Mainnet = { + token: "WETH", + name: "WETH", + 1: { + symbol: "WETH", + address: "0xd412acd34a832a09c80c8a4895ff46d733f09538", + decimals: 18, + }, +}; + + +// RSK mainnet Tokens +const SOV_RskMainnet = { + token: "SOV", + name: "Sovryn Token", + 30: { + symbol: "SOV", + address: "0xefc78fc7d48b64958315949279ba181c2114abbd", + decimals: 18, + }, +}; + +const RBTC_RskMainnet = { + token: "WRBTC", + name: "RBTC", + 30: { + symbol: "WRBTC", + address: "0xa233108b33dc77f1eee9d183ee1dc9725e76d475", + decimals: 18, + }, +}; + +// rskETHmainnet eth token +const ETH_RskMainnet = { + token: "ETH", + name: "ETHes", + 30: { + symbol: "ETHes", + address: "0xfe878227c8f334038dab20a99fc3b373ffe0a755", + decimals: 18, + }, +}; + +// rskBSCbmainnet stable coins +const DAI_RskBSCMainnet = { + token: "DAIbs", + name: "Dai Stablecoin", + 30: { + symbol: "DAIbs", + address: "0x6A42Ff12215a90f50866A5cE43A9c9C870116e76", + decimals: 18, + }, +}; +const USDC_RskBSCMainnet = { + token: "USDCbs", + name: "USD Coin", + 30: { + symbol: "USDCbs", + address: "0x91EDceE9567cd5612c9DEDeaAE24D5e574820af1", + decimals: 18, + }, +}; +const USDT_RskBSCMainnet = { + token: "USDTbs", + name: "Tether USD", + 30: { + symbol: "USDTbs", + address: "0xFf4299bCA0313C20A61dc5eD597739743BEf3f6d", + decimals: 18, + }, +}; +const BUSD_RskBSCMainnet = { + token: "BUSDbs", + name: "Binance USD", + 30: { + symbol: "BUSDbs", + address: "0x61e9604e31a736129d7f5C58964c75935b2d80D6", + decimals: 18, + }, +}; + +// rskBSCbmainnet eth token +const ETH_RskBSCMainnet = { + token: "ETH", + name: "ETHbs", + 30: { + symbol: "ETHbs", + address: "0x30d1B36924c2c0CD1c03EC257D7FFf31bD8c3007", + decimals: 18, + }, +}; + +// rskBSCbmainnet bnb token +const BNB_RskBSCMainnet = { + token: "BNBbs", + name: "BNBbs", + 30: { + symbol: "BNBbs", + address: "0xd2a826b78200c8434b957913ce4067e6e3169385", + decimals: 18, + }, +}; + +// bscBSCbmainnet bRBTC token +const RBTC_BscBSCMainnet = { + token: "bRBTC", + name: "bRBTC", + 56: { + symbol: "bRBTC", + address: "0x68e75416a99f61a8ef3186b3bee41dbf2a3fd4e8", + decimals: 18, + }, +}; +// rskETHbmainnet stable coins +const DAI_RskETHMainnet = { + token: "DAIes", + name: "Dai Stablecoin", + 30: { + symbol: "DAIes", + address: "0x1A37c482465e78E6DAbE1Ec77B9a24D4236D2A11", + decimals: 18, + }, +}; +const USDC_RskETHMainnet = { + token: "USDCes", + name: "USD Coin", + 30: { + symbol: "USDCes", + address: "0x8D1f7CbC6391D95E2774380e80A666FEbf655D6b", + decimals: 18, + }, +}; +const USDT_RskETHMainnet = { + token: "USDTes", + name: "Tether USD", + 30: { + symbol: "USDTes", + address: "0xD9665EA8F5fF70Cf97E1b1Cd1B4Cd0317b0976e8", + decimals: 18, + }, +}; + +// mainnet stable coins +const mainnetStableCoins = { + DAI_Mainnet, + USDT_Mainnet, + USDC_Mainnet, +}; + +// bmainnet stable coins +const bmainnetStableCoins = { + DAI_BMainnet, + USDT_BMainnet, + USDC_BMainnet, + BUSD_BMainnet, +}; + +// bmainnet ETH Token +const bmainnetETHToken = { + ETH_BMainnet +}; + +// bmainnet BNB +const bmainnetBNB = { + BNB_BMainnet +}; + +// rskmainnet sov +const rskmainnetTokens = { + SOV_RskMainnet +}; + +const rskmainnetRBTC = { + RBTC_RskMainnet +}; + +// rskmainnet ETHes +const rskmainnetTokensETH = { + ETH_RskMainnet +}; + +// mainnet ETH +const mainnetETH = { + ETH_Mainnet +}; + +// mainnet sov +const mainnetSOV = { + SOV_Mainnet +}; +// bmainnet sov +const bmainnetSOV = { + SOV_BMainnet +}; + +// rskBSCmainnet stable coins +const rskbscmainnetStableCoins = { + DAI_RskBSCMainnet, + USDT_RskBSCMainnet, + USDC_RskBSCMainnet, + BUSD_RskBSCMainnet, +}; + +// rskBSCmainnet wth token +const rskbscmainnetETHToken = { + ETH_RskBSCMainnet +}; + +// rskBSCmainnet bnb token +const rskbscmainnetBNB = { + BNB_RskBSCMainnet +}; + +// bscBSCbmainnet brbtc token +const bscbscbmainnetRBTC = { + RBTC_BscBSCMainnet +}; + +// rskETHmainnet stable coins +const rskethmainnetStableCoins = { + DAI_RskETHMainnet, + USDT_RskETHMainnet, + USDC_RskETHMainnet +}; + +module.exports = { + abisObject, + abisObjectV5, + rskBSCConfig, + bscBSCConfig, + bscBSCV5Config, + rskBSCV5Config, + ethETHV5Config, + rskETHV5Config, + rskETHConfig, + ethETHConfig, + mainnetStableCoins, + bmainnetStableCoins, + rskmainnetTokens, + rskbscmainnetStableCoins, + rskethmainnetStableCoins, + rskmainnetTokensETH, + bmainnetETHToken, + rskbscmainnetETHToken, + bmainnetBNB, + rskmainnetRBTC, + rskbscmainnetBNB, + bscbscbmainnetRBTC, + mainnetSOV, + bmainnetSOV, + mainnetETH, +}; diff --git a/sovryn-token-bridge/bridge/scripts/BridgeMainnetControl_v5MaxToken.js b/sovryn-token-bridge/bridge/scripts/BridgeMainnetControl_v5MaxToken.js new file mode 100755 index 00000000..1e3a57de --- /dev/null +++ b/sovryn-token-bridge/bridge/scripts/BridgeMainnetControl_v5MaxToken.js @@ -0,0 +1,485 @@ +const fs = require('fs'); +const AbisObject = require("./BridgeMainnetAddresses_v5MaxToken").abisObject; + +const BscBSCV5Config = require("./BridgeMainnetAddresses_v5MaxToken").bscBSCV5Config; +const BscBSCConfig = require("./BridgeMainnetAddresses_v5MaxToken").bscBSCConfig; +const RskBSCConfig = require("./BridgeMainnetAddresses_v5MaxToken").rskBSCConfig; +const EthETHConfig = require("./BridgeMainnetAddresses_v5MaxToken").ethETHConfig; +const RskETHConfig = require("./BridgeMainnetAddresses_v5MaxToken").rskETHConfig; +const BmainnetStableCoins = require("./BridgeMainnetAddresses_v5MaxToken").bmainnetStableCoins; +const MainnetStableCoins = require("./BridgeMainnetAddresses_v5MaxToken").mainnetStableCoins; +const RskbscmainnetStableCoins = require("./BridgeMainnetAddresses_v5MaxToken").rskbscmainnetStableCoins; +const RskethmainnetStableCoins = require("./BridgeMainnetAddresses_v5MaxToken").rskethmainnetStableCoins; +const RskmainnetTokens = require("./BridgeMainnetAddresses_v5MaxToken").rskmainnetTokens; +const BmainnetETHToken = require("./BridgeMainnetAddresses_v5MaxToken").bmainnetETHToken; +const RskbscmainnetETHToken = require("./BridgeMainnetAddresses_v5MaxToken").rskbscmainnetETHToken; +const BmainnetBNB = require("./BridgeMainnetAddresses_v5MaxToken").bmainnetBNB; +const RskmainnetRBTC = require("./BridgeMainnetAddresses_v5MaxToken").rskmainnetRBTC; +const RskbscmainnetBNB = require("./BridgeMainnetAddresses_v5MaxToken").rskbscmainnetBNB; +const BscbscbmainnetRBTC = require("./BridgeMainnetAddresses_v5MaxToken").bscbscbmainnetRBTC; +const MainnetSOV = require("./BridgeMainnetAddresses_v5MaxToken").mainnetSOV; +const BmainnetSOV = require("./BridgeMainnetAddresses_v5MaxToken").bmainnetSOV; + + +const deployer= "0x12D90403733b6DD1f88240C773a6613331e60bCF"; + +module.exports = async callback => { + try { + + const netType = process.argv[5]; + const bridgeType = process.argv[6]; + const tokenType = process.argv[7]; + const enableMethod = process.argv[8]; + const input0 = process.argv[9]; + const input1 = process.argv[10]; + const input2 = process.argv[11]; + + + if( bridgeType == "h" || bridgeType == "help" ) { + throw new Error('npx truffle exec ./scripts/BridgeControl.js --network \n' + + 'net: mainnet, bmainnet, rskmainnet, ropsten, bmainnet, rskmainnet\n' + + 'bridgeType: bsc, eth\n'+ + 'tokenType: "", sov, stable, eth, bnb, rbtc\n'+ + 'enableMethod: name of the function to call\n'+ + 'input0: first input to function\n'+ + 'input1: second input to function\n'+ + 'input2: third input to function\n' + + 'enableMethod list:\n' + + 'Bridge: pause changeAllowTokens setNativeTokenSymbol initialSymbolPrefixSetup setWETHAddress setRevokeTransaction setBridgeReceiverStatus\n' + + 'MultiSig: changeRequirement removeOwner addOwner\n' + + 'AllowTokens: addAllowedToken removeAllowedToken setFeeAndMinPerToken setMaxTokensAllowed changeDailyLimit setMaxPerToken\n' + + 'Federation: removeMember addMember setRevokeTransactionAndVote\n\n' + + 'Example: \n' + + 'npx truffle exec ./scripts/BridgeControl.js --network rskmainnet bsc bnb "setFeeAndMinPerToken" "" 10000000000000000 100000000000000000\n' + + 'npx truffle exec ./scripts/BridgeControl.js --network rskmainnet bsc "" "removeOwner" "0xdc83580abf622ec75f69b56ddf945dd6cdbf53d2" "" ""'); + } + + const gasPrice = await web3.eth.getGasPrice(); + console.log("gas price is: " + gasPrice); + let gasPriceNow = gasPrice; + if (netType == "mainnet") { + gasPriceNow = Number.parseInt(gasPrice * 1.5); + } + console.log("gas price now is: " + gasPriceNow); + + const bridgeAbi = AbisObject.bridgeABI; + const federationAbi = AbisObject.federationABI; + const multisigAbi = AbisObject.multiSigABI; + const AllowTokensAbi = AbisObject.allowTokensABI; + const erc777ConverterAbi = AbisObject.erc777ConverterABI; + + let bridgeAddress; + let federationAddress; + let multiSigAddress; + let allowTokensAddress; + let erc777ConverterAddress; + + let allowTokensV5Address; + + let tokens; + let decimals; + + let smartContract; + if(tokenType == "") { + tokens = [ + RskmainnetTokens.SOV_RskMainnet[31].address, + ]; + }; + if(netType == "bmainnet") { + if(tokenType == "stable") { + tokens = [ + BmainnetStableCoins.DAI_BMainnet[97].address, + BmainnetStableCoins.USDT_BMainnet[97].address, + BmainnetStableCoins.USDC_BMainnet[97].address, + BmainnetStableCoins.BUSD_BMainnet[97].address, + ]; + decimals = [ + BmainnetStableCoins.DAI_BMainnet[97].decimals, + BmainnetStableCoins.USDT_BMainnet[97].decimals, + BmainnetStableCoins.USDC_BMainnet[97].decimals, + BmainnetStableCoins.BUSD_BMainnet[97].decimals, + ]; + } + else if(tokenType == "eth") { + tokens = [ + BmainnetETHToken.ETH_BMainnet[97].address + ]; + decimals = [ + BmainnetETHToken.ETH_BMainnet[97].decimals + ]; + } + else if(tokenType == "bnb") { + tokens = [ + BmainnetBNB.BNB_BMainnet[97].address + ]; + decimals = [ + BmainnetBNB.BNB_BMainnet[97].decimals + ]; + } + else if(tokenType == "rbtc") { + tokens = [ + BscbscbmainnetRBTC.RBTC_BscBSCMainnet[97].address + ]; + decimals = [ + BscbscbmainnetRBTC.RBTC_BscBSCMainnet[97].decimals + ]; + } + else if(tokenType == "sov") { + tokens = [ + BmainnetSOV.SOV_BMainnet[97].address + ]; + decimals = [ + BmainnetSOV.SOV_BMainnet[97].decimals + ]; + }; + + bridgeAddress = BscBSCConfig.bridge; + federationAddress = BscBSCConfig.federation; + multiSigAddress= BscBSCConfig.multiSig; + allowTokensAddress= BscBSCConfig.allowTokens; + erc777ConverterAddress= BscBSCConfig.erc777Converter; + + allowTokensV5Address= BscBSCV5Config.allowTokens; + } + else if(netType == "ropsten") { + if(tokenType == "stable") { + tokens = [ + MainnetStableCoins.DAI_Mainnet[3].address, + MainnetStableCoins.USDT_Mainnet[3].address, + MainnetStableCoins.USDC_Mainnet[3].address, + ]; + decimals = [ + MainnetStableCoins.DAI_Mainnet[3].decimals, + MainnetStableCoins.USDT_Mainnet[3].decimals, + MainnetStableCoins.USDC_Mainnet[3].decimals, + ]; + } + else if(tokenType == "sov") { + tokens = [ + MainnetSOV.SOV_Mainnet[3].address + ]; + decimals = [ + MainnetSOV.SOV_Mainnet[3].decimals + ]; + }; + bridgeAddress = EthETHConfig.bridge; + federationAddress = EthETHConfig.federation; + multiSigAddress= EthETHConfig.multiSig; + allowTokensAddress= EthETHConfig.allowTokens; + erc777ConverterAddress= EthETHConfig.erc777Converter; + + } + else if(netType == "rskmainnet"){ + if(tokenType == "sov") { + tokens = [ + RskmainnetTokens.SOV_RskMainnet[31].address.toLowerCase() + ]; + decimals = [ + RskmainnetTokens.SOV_RskMainnet[31].decimals + ]; + + }; + if(tokenType == "rbtc") { + tokens = [ + RskmainnetRBTC.RBTC_RskMainnet[31].address.toLowerCase() + ]; + decimals = [ + RskmainnetRBTC.RBTC_RskMainnet[31].decimals + ]; + }; + if(bridgeType == "bsc"){ + bridgeAddress = RskBSCConfig.bridge; + federationAddress = RskBSCConfig.federation; + multiSigAddress= RskBSCConfig.multiSig; + allowTokensAddress= RskBSCConfig.allowTokens; + erc777ConverterAddress= RskBSCConfig.erc777Converter; + + if(tokenType == "stable") { + tokens = [ + RskbscmainnetStableCoins.DAI_RskBSCMainnet[31].address.toLowerCase(), + RskbscmainnetStableCoins.USDT_RskBSCMainnet[31].address.toLowerCase(), + RskbscmainnetStableCoins.USDC_RskBSCMainnet[31].address.toLowerCase(), + RskbscmainnetStableCoins.BUSD_RskBSCMainnet[31].address.toLowerCase() + ]; + decimals = [ + RskbscmainnetStableCoins.DAI_RskBSCMainnet[31].decimals, + RskbscmainnetStableCoins.USDT_RskBSCMainnet[31].decimals, + RskbscmainnetStableCoins.USDC_RskBSCMainnet[31].decimals, + RskbscmainnetStableCoins.BUSD_RskBSCMainnet[31].decimals, + ]; + } + else if(tokenType == "eth") { + tokens = [ + RskbscmainnetETHToken.ETH_RskBSCMainnet[31].address.toLowerCase() + ]; + decimals = [ + RskbscmainnetETHToken.ETH_RskBSCMainnet[31].decimals + ]; + + } + else if(tokenType == "bnb") { + tokens = [ + RskbscmainnetBNB.BNB_RskBSCMainnet[31].address.toLowerCase() + ]; + decimals = [ + RskbscmainnetBNB.BNB_RskBSCMainnet[31].decimals + ]; + }; + + } + else if(bridgeType == "eth") { + bridgeAddress = RskETHConfig.bridge; + federationAddress = RskETHConfig.federation; + multiSigAddress= RskETHConfig.multiSig; + allowTokensAddress= RskETHConfig.allowTokens; + erc777ConverterAddress= RskETHConfig.erc777Converter; + + if(tokenType == "stable") { + tokens = [ + RskethmainnetStableCoins.DAI_RskETHMainnet[31].address.toLowerCase(), + RskethmainnetStableCoins.USDT_RskETHMainnet[31].address.toLowerCase(), + RskethmainnetStableCoins.USDC_RskETHMainnet[31].address.toLowerCase() + ]; + decimals = [ + RskethmainnetStableCoins.DAI_RskETHMainnet[31].decimals, + RskethmainnetStableCoins.USDT_RskETHMainnet[31].decimals, + RskethmainnetStableCoins.USDC_RskETHMainnet[31].decimals + ]; + }; + }; + }; + + console.log("bridgeAddress: "+ bridgeAddress); + console.log("federationAddress: "+ federationAddress); + console.log("multiSigAddress: "+ multiSigAddress); + console.log("allowTokensAddress: "+ allowTokensAddress); + console.log("erc777ConverterAddress: "+ erc777ConverterAddress); + const multiSig = new web3.eth.Contract(multisigAbi, multiSigAddress, {from: deployer}); + const bridge = new web3.eth.Contract(bridgeAbi, bridgeAddress, {from: deployer}); + const allowTokens = new web3.eth.Contract(AllowTokensAbi, allowTokensAddress, {from: deployer}); + const federation = new web3.eth.Contract(federationAbi, federationAddress, {from: deployer}); + const erc777Converter = new web3.eth.Contract(erc777ConverterAbi, erc777ConverterAddress, {from: deployer}); + + let functionData; + let adjustedFee; + let adjustedMin; + + let exeFunctionsPromises = tokens.map(async (token, index) => { + // Bridge control + if(enableMethod == "pause") { + smartContract = "bridge"; + functionData = bridge.methods + .pause() + .encodeABI(); + } + else if(enableMethod == "changeAllowTokens") { + smartContract = "bridge"; + functionData = bridge.methods + .changeAllowTokens(input0) + .encodeABI(); + } + else if(enableMethod == "setNativeTokenSymbol") { + smartContract = "bridge"; + functionData = bridge.methods + .setNativeTokenSymbol(input0) + .encodeABI(); + } + else if(enableMethod == "initialSymbolPrefixSetup") { + smartContract = "bridge"; + functionData = bridge.methods + .initialSymbolPrefixSetup(input0, input1) + .encodeABI(); + } + else if(enableMethod == "setWETHAddress") { + smartContract = "bridge"; + functionData = bridge.methods + .setWETHAddress(input0) + .encodeABI(); + } + else if(enableMethod == "setRevokeTransaction") { + smartContract = "bridge"; + functionData = bridge.methods + .setRevokeTransaction(input0) + .encodeABI(); + } + else if(enableMethod == "setBridgeReceiverStatus") { + smartContract = "bridge"; + functionData = bridge.methods + .setBridgeReceiverStatus(input0, input1) + .encodeABI(); + } + // MultiSig control + if(enableMethod == "changeRequirement") { + smartContract = "multiSig"; + functionData = multiSig.methods + .changeRequirement(input0) + .encodeABI(); + } + else if(enableMethod == "removeOwner") { + smartContract = "multiSig"; + functionData = multiSig.methods + .removeOwner(input0) + .encodeABI(); + } + else if(enableMethod == "addOwner") { + smartContract = "multiSig"; + functionData = multiSig.methods + .addOwner(input0) + .encodeABI(); + } + // AllowTokens control + else if(enableMethod == "addAllowedToken") { + smartContract = "allowTokens"; + functionData = allowTokens.methods + .addAllowedToken(token) + .encodeABI(); + } + else if(enableMethod == "removeAllowedToken") { + smartContract = "allowTokens"; + functionData = allowTokens.methods + .removeAllowedToken(token) + .encodeABI(); + } + else if(enableMethod == "setFeeAndMinPerToken") { + smartContract = "allowTokens"; + adjustedFee = input1/(10**(18-decimals[index])); + adjustedMin = input2/(10**(18-decimals[index])); + console.log("adjustedFee, adjustedMin "+ adjustedFee + " , " + adjustedMin); + if(decimals[index]== 18){ + adjustedFee =input1; + adjustedMin = input2; + } + functionData = allowTokens.methods + .setFeeAndMinPerToken(token, adjustedFee, adjustedMin) + .encodeABI(); + } + else if(enableMethod == "setMaxPerToken") { + smartContract = "allowTokens"; + adjustedMax = input1/(10**(18-decimals[index])); + console.log("adjustedMax "+ adjustedMax); + if(decimals[index]== 18){ + adjustedMax =input1; + } + functionData = allowTokens.methods + .setMaxPerToken(token, adjustedMax) + .encodeABI(); + } + else if(enableMethod == "setMaxTokensAllowed") { + smartContract = "allowTokens"; + functionData = allowTokens.methods + .setMaxTokensAllowed(input0) + .encodeABI(); + } + else if(enableMethod == "changeDailyLimit") { + smartContract = "allowTokens"; + functionData = allowTokens.methods + .changeDailyLimit(input0) + .encodeABI(); + } + // Federation control + else if(enableMethod == "removeMember") { + smartContract = "federation"; + functionData = federation.methods + .removeMember(input0) + .encodeABI(); + } + else if(enableMethod == "addMember") { + smartContract = "federation"; + functionData = federation.methods + .addMember(input0) + .encodeABI(); + } + else if(enableMethod == "setRevokeTransactionAndVote") { + smartContract = "federation"; + functionData = federation.methods + .setRevokeTransactionAndVote(input0) + .encodeABI(); + } + // erc777Converter control + // else if(enableMethod == "removeMember") { + // smartContract = "federation"; + // functionData = federation.methods + // .removeMember(input0) + // .encodeABI(); + // } + // else if(enableMethod == "addMember") { + // smartContract = "federation"; + // functionData = federation.methods + // .addMember(input0) + // .encodeABI(); + // } + console.log(`${functionData}`); + let result; + if(smartContract == "bridge") { + result = await multiSig.methods + .submitTransaction(bridgeAddress, 0, functionData) + .send({ from: deployer ,gas: 300000, gasPrice: gasPriceNow }); + } + else if(smartContract == "multiSig") { + result = await multiSig.methods + .submitTransaction(multiSigAddress, 0, functionData) + .send({ from: deployer ,gas: 300000, gasPrice: gasPriceNow }); + } + else if(smartContract == "allowTokens") { + result = await multiSig.methods + .submitTransaction(allowTokensAddress, 0, functionData) + .send({ from: deployer ,gas: 300000, gasPrice: gasPriceNow }); + } + else if(smartContract == "federation") { + result = await multiSig.methods + .submitTransaction(federationAddress, 0, functionData) + .send({ from: deployer ,gas: 300000, gasPrice: gasPriceNow }); + }; + + + + // if(enableMethod == "changeRequirement") { + // result = await multiSig.methods + // .submitTransaction(multiSigAddress, 0, functionData) + // .send({ from: deployer ,gas: 300000, gasPrice: gasPriceNow }); + // } + // else if(enableMethod == "removeOwner") { + // result = await multiSig.methods + // .submitTransaction(multiSigAddress, 0, functionData) + // .send({ from: deployer ,gas: 300000, gasPrice: gasPriceNow }); + // } + // else if(enableMethod == "addOwner") { + // result = await multiSig.methods + // .submitTransaction(multiSigAddress, 0, functionData) + // .send({ from: deployer ,gas: 300000, gasPrice: gasPriceNow }); + // } + // else if(enableMethod == "addAllowedToken") { + // result = await multiSig.methods + // .submitTransaction(allowTokensAddress, 0, functionData) + // .send({ from: deployer ,gas: 300000, gasPrice: gasPriceNow }); + // } + // else if(enableMethod == "removeAllowedToken") { + // result = await multiSig.methods + // .submitTransaction(allowTokensAddress, 0, functionData) + // .send({ from: deployer ,gas: 300000, gasPrice: gasPriceNow }); + // } + // else if(enableMethod == "setFeeAndMinPerToken"){ + // result = await multiSig.methods + // .submitTransaction(allowTokensAddress, 0, functionData) + // .send({ from: deployer ,gas: 300000, gasPrice: gasPriceNow }); + // } + // else if(enableMethod == "removeMember"){ + // result = await multiSig.methods + // .submitTransaction(federationAddress, 0, functionData) + // .send({ from: deployer ,gas: 300000, gasPrice: gasPriceNow }); + // } + // else if(enableMethod == "addMember"){ + // result = await multiSig.methods + // .submitTransaction(federationAddress, 0, functionData) + // .send({ from: deployer ,gas: 300000, gasPrice: gasPriceNow }); + // } + console.log(result); + }); + + await Promise.all(exeFunctionsPromises); + } catch (e) { + callback(e); + } + callback(); + console.log('All done.') +}; \ No newline at end of file diff --git a/sovryn-token-bridge/bridge/scripts/BridgeTestnetAddresses_v5MaxToken.js b/sovryn-token-bridge/bridge/scripts/BridgeTestnetAddresses_v5MaxToken.js new file mode 100644 index 00000000..c3d47ec8 --- /dev/null +++ b/sovryn-token-bridge/bridge/scripts/BridgeTestnetAddresses_v5MaxToken.js @@ -0,0 +1,402 @@ +// Bring all the addresses deployed in rsk +const bscBSCBridge = require("../../../federator-env/testnet-BSC-RSK/btestnet.json"); +const rskBSCBridge = require("../../../federator-env/testnet-BSC-RSK/rsktestnet.json"); +const rskETHBridge = require("../../../federator-env/testnet-ETH-RSK/rsktestnet.json"); +const ethETHBridge = require("../../../federator-env/testnet-ETH-RSK/ropsten.json"); + +const bscBSCBridgeV5 = require("../../../federator-env/testnet-BSC-RSK/btestnet_v5.json"); + +// Bring all the addresses deployed in kovan +//const kovanAddresses = require("../../../federator/config/kovan.json"); + +// Asign ABIs to each variable from the JSON +const bridgeABI = require("../../abis/Bridge.json"); +const federationABI = require("../../abis/Federation.json"); +const multiSigABI = require("../../abis/MultiSigWallet.json"); +const allowTokensABI = require("../../abis/AllowTokens.json"); +const erc777ConverterABI = require("../../abis/Erc777Converter.json"); +const tokenABI = require("../build/contracts/AlternativeERC20Detailed.json").abi; + +const allowTokensV5ABI = require("./OldAbis/AllowTokensV5.json"); + +const abisObject = { + bridgeABI, + federationABI, + multiSigABI, + allowTokensABI, + erc777ConverterABI, + tokenABI, +}; + +const abisObjectV5 = { + bridgeABI, + federationABI, + multiSigABI, + allowTokensV5ABI, + erc777ConverterABI, + tokenABI, +}; + +// Build an object with all the rsk addresses +const rskBSCConfig = { + bridge: rskBSCBridge.bridge, + federation: rskBSCBridge.federation, + multiSig: rskBSCBridge.multiSig, + allowTokens: rskBSCBridge.allowTokens, + erc777Converter: rskBSCBridge.erc777Converter, +}; +const bscBSCConfig = { + bridge: bscBSCBridge.bridge, + federation: bscBSCBridge.federation, + multiSig: bscBSCBridge.multiSig, + allowTokens: bscBSCBridge.allowTokens, + erc777Converter: bscBSCBridge.erc777Converter, +}; + +const bscBSCV5Config = { + allowTokens: bscBSCBridgeV5.allowTokens, +}; + + +const rskETHConfig = { + bridge: rskETHBridge.bridge, + federation: rskETHBridge.federation, + multiSig: rskETHBridge.multiSig, + allowTokens: rskETHBridge.allowTokens, + erc777Converter: rskETHBridge.erc777Converter, +}; +const ethETHConfig = { + bridge: ethETHBridge.bridge, + federation: ethETHBridge.federation, + multiSig: ethETHBridge.multiSig, + allowTokens: ethETHBridge.allowTokens, + erc777Converter: ethETHBridge.erc777Converter, +}; + +const DAI_Testnet = { + token: "DAI", + name: "Dai Stablecoin", + 3: { + symbol: "DAI", + address: "0x974cf21396D4D29F8e63Ac07eCfcbaB51a739bc9", + decimals: 18, + }, +}; +const USDC_Testnet = { + token: "USDC", + name: "USD Coin", + 3: { + symbol: "USDC", + address: "0x4C68058992b8aD1243eE23A5923023C0e15Cf43F", + decimals: 6, + }, +}; +const USDT_Testnet = { + token: "USDT", + name: "Tether USD", + 3: { + symbol: "USDT", + address: "0xff364ffa4962cb172203a5be01d17cf3fef02419", + decimals: 6, + }, +}; + + +// btestnet stable coins +const DAI_BTestnet = { + token: "DAI", + name: "Dai Stablecoin", + 97: { + symbol: "DAI", + address: "0x83241490517384cb28382bdd4d1534ee54d9350f", + decimals: 18, + }, +}; +const USDC_BTestnet = { + token: "USDC", + name: "USD Coin", + 97: { + symbol: "USDC", + address: "0x0b654c687dc8b828139406c070e0a34486e5072b", + decimals: 18, + }, +}; +const USDT_BTestnet = { + token: "USDT", + name: "Tether USD", + 97: { + symbol: "USDT", + address: "0x268e3bf855cbcdf8fe31ba3557a554ab2283351f", + decimals: 18, + }, +}; +const BUSD_BTestnet = { + token: "BUSD", + name: "Binance USD", + 97: { + symbol: "BUSD", + address: "0x137BEc8c83740920ebc4f29f51C7B65b75Beec83", + decimals: 18, + }, +}; + +// btestnet eth token +const ETH_BTestnet = { + token: "ETH", + name: "ETH Binance pegged", + 97: { + symbol: "ETH", + address: "0x7d1FE4FdB0Afaf26ada5083A688139EbA10d3e1B", + decimals: 18, + }, +}; + +// btestnet bnb token +const BNB_BTestnet = { + token: "WBNB", + name: "BNB", + 97: { + symbol: "BNB", + address: "0x68bD35422b457f315AA176743325a9F7C9830c68", + decimals: 18, + }, +}; + +// btestnet sov +const SOV_BTestnet = { + token: "bSOV", + name: "Sovryn Token", + 97: { + symbol: "bSOV", + address: "0x6b8daa42b8ac9a0d826981a9990248bef60e2d4c", + decimals: 18, + }, +}; + +// ropsten sov +const SOV_Testnet = { + token: "eSOV", + name: "Sovryn Token", + 3: { + symbol: "eSOV", + address: "0xce887e72f26b61c3ddf45bd6e65abbd58437ab04", + decimals: 18, + }, +}; + +// RSK testnet Tokens +const SOV_RskTestnet = { + token: "SOV", + name: "Sovryn Token", + 31: { + symbol: "SOV", + address: "0x6a9A07972D07E58f0daF5122D11e069288A375fB", + decimals: 18, + }, +}; + +const RBTC_RskTestnet = { + token: "WRBTC", + name: "RBTC", + 31: { + symbol: "RBTC", + address: "0xf629e5C7527aC7Bc9ce26Bdd6D66F0eb955ef3B2", + decimals: 18, + }, +}; + +// rskBSCbtestnet stable coins +const DAI_RskBSCTestnet = { + token: "bsDAI", + name: "Dai Stablecoin", + 31: { + symbol: "bsDAI", + address: "0x407ff7d4760d3a81b4740d268eb04490c7dfe7f2", + decimals: 18, + }, +}; +const USDC_RskBSCTestnet = { + token: "bsUSDC", + name: "USD Coin", + 31: { + symbol: "bsUSDC", + address: "0x3e2cf87e7ff4048a57f9cdde9368c9f4bfb43adf", + decimals: 18, + }, +}; +const USDT_RskBSCTestnet = { + token: "bsUSDT", + name: "Tether USD", + 31: { + symbol: "bsUSDT", + address: "0x43bc3f0ffff6c9bbf3c2eafe464c314d43f561de", + decimals: 18, + }, +}; +const BUSD_RskBSCTestnet = { + token: "bsBUSD", + name: "Binance USD", + 31: { + symbol: "bsBUSD", + address: "0x8c9abb6c9d8d15ddb7ada2e50086e1050ab32688", + decimals: 18, + }, +}; + +// rskBSCbtestnet eth token +const ETH_RskBSCTestnet = { + token: "ETH", + name: "bsETH", + 31: { + symbol: "bsETH", + address: "0x793CE6F95912D5b43532c2116e1b68993d902272", + decimals: 18, + }, +}; + +// rskBSCbtestnet bnb token +const BNB_RskBSCTestnet = { + token: "bsBNB", + name: "bsBNB", + 31: { + symbol: "bsBNB", + address: "0xafa6A1eb7E2282E8854822d2bB412b6db2cabA4E", + decimals: 18, + }, +}; + +// bscBSCbtestnet bRBTC token +const RBTC_BscBSCTestnet = { + token: "bRBTC", + name: "bRBTC", + 97: { + symbol: "bRBTC", + address: "0xc41d41cb7a31c80662ac2d8ab7a7e5f5841eebc3", + decimals: 18, + }, +}; +// rskETHbtestnet stable coins +const DAI_RskETHTestnet = { + token: "DAIes", + name: "Dai Stablecoin", + 31: { + symbol: "DAIes", + address: "0xcb92C8D49Ec01b92F2A766C7c3C9C501C45271E0", + decimals: 18, + }, +}; +const USDC_RskETHTestnet = { + token: "USDCes", + name: "USD Coin", + 31: { + symbol: "USDCes", + address: "0xcc8Eec21ae75F1A2dE4aC7b32A7de888a45cF859", + decimals: 18, + }, +}; +const USDT_RskETHTestnet = { + token: "USDTes", + name: "Tether USD", + 31: { + symbol: "USDTes", + address: "0x10C5A7930fC417e728574E334b1488b7895c4B81", + decimals: 18, + }, +}; + +// testnet stable coins +const testnetStableCoins = { + DAI_Testnet, + USDT_Testnet, + USDC_Testnet, +}; + +// btestnet stable coins +const btestnetStableCoins = { + DAI_BTestnet, + USDT_BTestnet, + USDC_BTestnet, + BUSD_BTestnet, +}; + +// btestnet ETH Token +const btestnetETHToken = { + ETH_BTestnet +}; + +// btestnet BNB +const btestnetBNB = { + BNB_BTestnet +}; + +// rsktestnet sov +const rsktestnetTokens = { + SOV_RskTestnet +}; + +const rsktestnetRBTC = { + RBTC_RskTestnet +}; + + +// ropsten sov +const testnetSOV = { + SOV_Testnet +}; +// btestnet sov +const btestnetSOV = { + SOV_BTestnet +}; + +// rskBSCtestnet stable coins +const rskbsctestnetStableCoins = { + DAI_RskBSCTestnet, + USDT_RskBSCTestnet, + USDC_RskBSCTestnet, + BUSD_RskBSCTestnet, +}; + +// rskBSCtestnet wth token +const rskbsctestnetETHToken = { + ETH_RskBSCTestnet +}; + +// rskBSCtestnet bnb token +const rskbsctestnetBNB = { + BNB_RskBSCTestnet +}; + +// bscBSCbtestnet brbtc token +const bscbscbtestnetRBTC = { + RBTC_BscBSCTestnet +}; + +// rskETHtestnet stable coins +const rskethtestnetStableCoins = { + DAI_RskETHTestnet, + USDT_RskETHTestnet, + USDC_RskETHTestnet +}; + +module.exports = { + abisObject, + abisObjectV5, + rskBSCConfig, + bscBSCConfig, + bscBSCV5Config, + rskETHConfig, + ethETHConfig, + testnetStableCoins, + btestnetStableCoins, + rsktestnetTokens, + rskbsctestnetStableCoins, + rskethtestnetStableCoins, + btestnetETHToken, + rskbsctestnetETHToken, + btestnetBNB, + rsktestnetRBTC, + rskbsctestnetBNB, + bscbscbtestnetRBTC, + testnetSOV, + btestnetSOV +}; diff --git a/sovryn-token-bridge/bridge/scripts/BridgeTestnetControl_v5MaxToken.js b/sovryn-token-bridge/bridge/scripts/BridgeTestnetControl_v5MaxToken.js new file mode 100755 index 00000000..36d50cf7 --- /dev/null +++ b/sovryn-token-bridge/bridge/scripts/BridgeTestnetControl_v5MaxToken.js @@ -0,0 +1,485 @@ +const fs = require('fs'); +const AbisObject = require("./BridgeTestnetAddresses_v5MaxToken").abisObject; + +const BscBSCV5Config = require("./BridgeTestnetAddresses_v5MaxToken").bscBSCV5Config; +const BscBSCConfig = require("./BridgeTestnetAddresses_v5MaxToken").bscBSCConfig; +const RskBSCConfig = require("./BridgeTestnetAddresses_v5MaxToken").rskBSCConfig; +const EthETHConfig = require("./BridgeTestnetAddresses_v5MaxToken").ethETHConfig; +const RskETHConfig = require("./BridgeTestnetAddresses_v5MaxToken").rskETHConfig; +const BtestnetStableCoins = require("./BridgeTestnetAddresses_v5MaxToken").btestnetStableCoins; +const TestnetStableCoins = require("./BridgeTestnetAddresses_v5MaxToken").testnetStableCoins; +const RskbsctestnetStableCoins = require("./BridgeTestnetAddresses_v5MaxToken").rskbsctestnetStableCoins; +const RskethtestnetStableCoins = require("./BridgeTestnetAddresses_v5MaxToken").rskethtestnetStableCoins; +const RsktestnetTokens = require("./BridgeTestnetAddresses_v5MaxToken").rsktestnetTokens; +const BtestnetETHToken = require("./BridgeTestnetAddresses_v5MaxToken").btestnetETHToken; +const RskbsctestnetETHToken = require("./BridgeTestnetAddresses_v5MaxToken").rskbsctestnetETHToken; +const BtestnetBNB = require("./BridgeTestnetAddresses_v5MaxToken").btestnetBNB; +const RsktestnetRBTC = require("./BridgeTestnetAddresses_v5MaxToken").rsktestnetRBTC; +const RskbsctestnetBNB = require("./BridgeTestnetAddresses_v5MaxToken").rskbsctestnetBNB; +const BscbscbtestnetRBTC = require("./BridgeTestnetAddresses_v5MaxToken").bscbscbtestnetRBTC; +const TestnetSOV = require("./BridgeTestnetAddresses_v5MaxToken").testnetSOV; +const BtestnetSOV = require("./BridgeTestnetAddresses_v5MaxToken").btestnetSOV; + + +const deployer= "0x12D90403733b6DD1f88240C773a6613331e60bCF"; + +module.exports = async callback => { + try { + + const netType = process.argv[5]; + const bridgeType = process.argv[6]; + const tokenType = process.argv[7]; + const enableMethod = process.argv[8]; + const input0 = process.argv[9]; + const input1 = process.argv[10]; + const input2 = process.argv[11]; + + + if( bridgeType == "h" || bridgeType == "help" ) { + throw new Error('npx truffle exec ./scripts/BridgeControl.js --network \n' + + 'net: testnet, btestnet, rsktestnet, ropsten, btestnet, rsktestnet\n' + + 'bridgeType: bsc, eth\n'+ + 'tokenType: "", sov, stable, eth, bnb, rbtc\n'+ + 'enableMethod: name of the function to call\n'+ + 'input0: first input to function\n'+ + 'input1: second input to function\n'+ + 'input2: third input to function\n' + + 'enableMethod list:\n' + + 'Bridge: pause changeAllowTokens setNativeTokenSymbol initialSymbolPrefixSetup setWETHAddress setRevokeTransaction setBridgeReceiverStatus\n' + + 'MultiSig: changeRequirement removeOwner addOwner\n' + + 'AllowTokens: addAllowedToken removeAllowedToken setFeeAndMinPerToken setMaxTokensAllowed changeDailyLimit setMaxPerToken\n' + + 'Federation: removeMember addMember setRevokeTransactionAndVote\n\n' + + 'Example: \n' + + 'npx truffle exec ./scripts/BridgeControl.js --network rsktestnet bsc bnb "setFeeAndMinPerToken" "" 10000000000000000 100000000000000000\n' + + 'npx truffle exec ./scripts/BridgeControl.js --network rsktestnet bsc "" "removeOwner" "0xdc83580abf622ec75f69b56ddf945dd6cdbf53d2" "" ""'); + } + + const gasPrice = await web3.eth.getGasPrice(); + console.log("gas price is: " + gasPrice); + let gasPriceNow = gasPrice; + if (netType == "testnet") { + gasPriceNow = Number.parseInt(gasPrice * 1.5); + } + console.log("gas price now is: " + gasPriceNow); + + const bridgeAbi = AbisObject.bridgeABI; + const federationAbi = AbisObject.federationABI; + const multisigAbi = AbisObject.multiSigABI; + const AllowTokensAbi = AbisObject.allowTokensABI; + const erc777ConverterAbi = AbisObject.erc777ConverterABI; + + let bridgeAddress; + let federationAddress; + let multiSigAddress; + let allowTokensAddress; + let erc777ConverterAddress; + + let allowTokensV5Address; + + let tokens; + let decimals; + + let smartContract; + if(tokenType == "") { + tokens = [ + RsktestnetTokens.SOV_RskTestnet[31].address, + ]; + }; + if(netType == "btestnet") { + if(tokenType == "stable") { + tokens = [ + BtestnetStableCoins.DAI_BTestnet[97].address, + BtestnetStableCoins.USDT_BTestnet[97].address, + BtestnetStableCoins.USDC_BTestnet[97].address, + BtestnetStableCoins.BUSD_BTestnet[97].address, + ]; + decimals = [ + BtestnetStableCoins.DAI_BTestnet[97].decimals, + BtestnetStableCoins.USDT_BTestnet[97].decimals, + BtestnetStableCoins.USDC_BTestnet[97].decimals, + BtestnetStableCoins.BUSD_BTestnet[97].decimals, + ]; + } + else if(tokenType == "eth") { + tokens = [ + BtestnetETHToken.ETH_BTestnet[97].address + ]; + decimals = [ + BtestnetETHToken.ETH_BTestnet[97].decimals + ]; + } + else if(tokenType == "bnb") { + tokens = [ + BtestnetBNB.BNB_BTestnet[97].address + ]; + decimals = [ + BtestnetBNB.BNB_BTestnet[97].decimals + ]; + } + else if(tokenType == "rbtc") { + tokens = [ + BscbscbtestnetRBTC.RBTC_BscBSCTestnet[97].address + ]; + decimals = [ + BscbscbtestnetRBTC.RBTC_BscBSCTestnet[97].decimals + ]; + } + else if(tokenType == "sov") { + tokens = [ + BtestnetSOV.SOV_BTestnet[97].address + ]; + decimals = [ + BtestnetSOV.SOV_BTestnet[97].decimals + ]; + }; + + bridgeAddress = BscBSCConfig.bridge; + federationAddress = BscBSCConfig.federation; + multiSigAddress= BscBSCConfig.multiSig; + allowTokensAddress= BscBSCConfig.allowTokens; + erc777ConverterAddress= BscBSCConfig.erc777Converter; + + allowTokensV5Address= BscBSCV5Config.allowTokens; + } + else if(netType == "ropsten") { + if(tokenType == "stable") { + tokens = [ + TestnetStableCoins.DAI_Testnet[3].address, + TestnetStableCoins.USDT_Testnet[3].address, + TestnetStableCoins.USDC_Testnet[3].address, + ]; + decimals = [ + TestnetStableCoins.DAI_Testnet[3].decimals, + TestnetStableCoins.USDT_Testnet[3].decimals, + TestnetStableCoins.USDC_Testnet[3].decimals, + ]; + } + else if(tokenType == "sov") { + tokens = [ + TestnetSOV.SOV_Testnet[3].address + ]; + decimals = [ + TestnetSOV.SOV_Testnet[3].decimals + ]; + }; + bridgeAddress = EthETHConfig.bridge; + federationAddress = EthETHConfig.federation; + multiSigAddress= EthETHConfig.multiSig; + allowTokensAddress= EthETHConfig.allowTokens; + erc777ConverterAddress= EthETHConfig.erc777Converter; + + } + else if(netType == "rsktestnet"){ + if(tokenType == "sov") { + tokens = [ + RsktestnetTokens.SOV_RskTestnet[31].address.toLowerCase() + ]; + decimals = [ + RsktestnetTokens.SOV_RskTestnet[31].decimals + ]; + + }; + if(tokenType == "rbtc") { + tokens = [ + RsktestnetRBTC.RBTC_RskTestnet[31].address.toLowerCase() + ]; + decimals = [ + RsktestnetRBTC.RBTC_RskTestnet[31].decimals + ]; + }; + if(bridgeType == "bsc"){ + bridgeAddress = RskBSCConfig.bridge; + federationAddress = RskBSCConfig.federation; + multiSigAddress= RskBSCConfig.multiSig; + allowTokensAddress= RskBSCConfig.allowTokens; + erc777ConverterAddress= RskBSCConfig.erc777Converter; + + if(tokenType == "stable") { + tokens = [ + RskbsctestnetStableCoins.DAI_RskBSCTestnet[31].address.toLowerCase(), + RskbsctestnetStableCoins.USDT_RskBSCTestnet[31].address.toLowerCase(), + RskbsctestnetStableCoins.USDC_RskBSCTestnet[31].address.toLowerCase(), + RskbsctestnetStableCoins.BUSD_RskBSCTestnet[31].address.toLowerCase() + ]; + decimals = [ + RskbsctestnetStableCoins.DAI_RskBSCTestnet[31].decimals, + RskbsctestnetStableCoins.USDT_RskBSCTestnet[31].decimals, + RskbsctestnetStableCoins.USDC_RskBSCTestnet[31].decimals, + RskbsctestnetStableCoins.BUSD_RskBSCTestnet[31].decimals, + ]; + } + else if(tokenType == "eth") { + tokens = [ + RskbsctestnetETHToken.ETH_RskBSCTestnet[31].address.toLowerCase() + ]; + decimals = [ + RskbsctestnetETHToken.ETH_RskBSCTestnet[31].decimals + ]; + + } + else if(tokenType == "bnb") { + tokens = [ + RskbsctestnetBNB.BNB_RskBSCTestnet[31].address.toLowerCase() + ]; + decimals = [ + RskbsctestnetBNB.BNB_RskBSCTestnet[31].decimals + ]; + }; + + } + else if(bridgeType == "eth") { + bridgeAddress = RskETHConfig.bridge; + federationAddress = RskETHConfig.federation; + multiSigAddress= RskETHConfig.multiSig; + allowTokensAddress= RskETHConfig.allowTokens; + erc777ConverterAddress= RskETHConfig.erc777Converter; + + if(tokenType == "stable") { + tokens = [ + RskethtestnetStableCoins.DAI_RskETHTestnet[31].address.toLowerCase(), + RskethtestnetStableCoins.USDT_RskETHTestnet[31].address.toLowerCase(), + RskethtestnetStableCoins.USDC_RskETHTestnet[31].address.toLowerCase() + ]; + decimals = [ + RskethtestnetStableCoins.DAI_RskETHTestnet[31].decimals, + RskethtestnetStableCoins.USDT_RskETHTestnet[31].decimals, + RskethtestnetStableCoins.USDC_RskETHTestnet[31].decimals + ]; + }; + }; + }; + + console.log("bridgeAddress: "+ bridgeAddress); + console.log("federationAddress: "+ federationAddress); + console.log("multiSigAddress: "+ multiSigAddress); + console.log("allowTokensAddress: "+ allowTokensAddress); + console.log("erc777ConverterAddress: "+ erc777ConverterAddress); + const multiSig = new web3.eth.Contract(multisigAbi, multiSigAddress, {from: deployer}); + const bridge = new web3.eth.Contract(bridgeAbi, bridgeAddress, {from: deployer}); + const allowTokens = new web3.eth.Contract(AllowTokensAbi, allowTokensAddress, {from: deployer}); + const federation = new web3.eth.Contract(federationAbi, federationAddress, {from: deployer}); + const erc777Converter = new web3.eth.Contract(erc777ConverterAbi, erc777ConverterAddress, {from: deployer}); + + let functionData; + let adjustedFee; + let adjustedMin; + + let exeFunctionsPromises = tokens.map(async (token, index) => { + // Bridge control + if(enableMethod == "pause") { + smartContract = "bridge"; + functionData = bridge.methods + .pause() + .encodeABI(); + } + else if(enableMethod == "changeAllowTokens") { + smartContract = "bridge"; + functionData = bridge.methods + .changeAllowTokens(input0) + .encodeABI(); + } + else if(enableMethod == "setNativeTokenSymbol") { + smartContract = "bridge"; + functionData = bridge.methods + .setNativeTokenSymbol(input0) + .encodeABI(); + } + else if(enableMethod == "initialSymbolPrefixSetup") { + smartContract = "bridge"; + functionData = bridge.methods + .initialSymbolPrefixSetup(input0, input1) + .encodeABI(); + } + else if(enableMethod == "setWETHAddress") { + smartContract = "bridge"; + functionData = bridge.methods + .setWETHAddress(input0) + .encodeABI(); + } + else if(enableMethod == "setRevokeTransaction") { + smartContract = "bridge"; + functionData = bridge.methods + .setRevokeTransaction(input0) + .encodeABI(); + } + else if(enableMethod == "setBridgeReceiverStatus") { + smartContract = "bridge"; + functionData = bridge.methods + .setBridgeReceiverStatus(input0, input1) + .encodeABI(); + } + // MultiSig control + if(enableMethod == "changeRequirement") { + smartContract = "multiSig"; + functionData = multiSig.methods + .changeRequirement(input0) + .encodeABI(); + } + else if(enableMethod == "removeOwner") { + smartContract = "multiSig"; + functionData = multiSig.methods + .removeOwner(input0) + .encodeABI(); + } + else if(enableMethod == "addOwner") { + smartContract = "multiSig"; + functionData = multiSig.methods + .addOwner(input0) + .encodeABI(); + } + // AllowTokens control + else if(enableMethod == "addAllowedToken") { + smartContract = "allowTokens"; + functionData = allowTokens.methods + .addAllowedToken(token) + .encodeABI(); + } + else if(enableMethod == "removeAllowedToken") { + smartContract = "allowTokens"; + functionData = allowTokens.methods + .removeAllowedToken(token) + .encodeABI(); + } + else if(enableMethod == "setFeeAndMinPerToken") { + smartContract = "allowTokens"; + adjustedFee = input1/(10**(18-decimals[index])); + adjustedMin = input2/(10**(18-decimals[index])); + console.log("adjustedFee, adjustedMin "+ adjustedFee + " , " + adjustedMin); + if(decimals[index]== 18){ + adjustedFee =input1; + adjustedMin = input2; + } + functionData = allowTokens.methods + .setFeeAndMinPerToken(token, adjustedFee, adjustedMin) + .encodeABI(); + } + else if(enableMethod == "setMaxPerToken") { + smartContract = "allowTokens"; + adjustedMax = input1/(10**(18-decimals[index])); + console.log("adjustedMax "+ adjustedMax); + if(decimals[index]== 18){ + adjustedMax =input1; + } + functionData = allowTokens.methods + .setMaxPerToken(token, adjustedMax) + .encodeABI(); + } + else if(enableMethod == "setMaxTokensAllowed") { + smartContract = "allowTokens"; + functionData = allowTokens.methods + .setMaxTokensAllowed(input0) + .encodeABI(); + } + else if(enableMethod == "changeDailyLimit") { + smartContract = "allowTokens"; + functionData = allowTokens.methods + .changeDailyLimit(input0) + .encodeABI(); + } + // Federation control + else if(enableMethod == "removeMember") { + smartContract = "federation"; + functionData = federation.methods + .removeMember(input0) + .encodeABI(); + } + else if(enableMethod == "addMember") { + smartContract = "federation"; + functionData = federation.methods + .addMember(input0) + .encodeABI(); + } + else if(enableMethod == "setRevokeTransactionAndVote") { + smartContract = "federation"; + functionData = federation.methods + .setRevokeTransactionAndVote(input0) + .encodeABI(); + } + // erc777Converter control + // else if(enableMethod == "removeMember") { + // smartContract = "federation"; + // functionData = federation.methods + // .removeMember(input0) + // .encodeABI(); + // } + // else if(enableMethod == "addMember") { + // smartContract = "federation"; + // functionData = federation.methods + // .addMember(input0) + // .encodeABI(); + // } + console.log(`${functionData}`); + let result; + if(smartContract == "bridge") { + result = await multiSig.methods + .submitTransaction(bridgeAddress, 0, functionData) + .send({ from: deployer ,gas: 300000, gasPrice: gasPriceNow }); + } + else if(smartContract == "multiSig") { + result = await multiSig.methods + .submitTransaction(multiSigAddress, 0, functionData) + .send({ from: deployer ,gas: 300000, gasPrice: gasPriceNow }); + } + else if(smartContract == "allowTokens") { + result = await multiSig.methods + .submitTransaction(allowTokensAddress, 0, functionData) + .send({ from: deployer ,gas: 300000, gasPrice: gasPriceNow }); + } + else if(smartContract == "federation") { + result = await multiSig.methods + .submitTransaction(federationAddress, 0, functionData) + .send({ from: deployer ,gas: 300000, gasPrice: gasPriceNow }); + }; + + + + // if(enableMethod == "changeRequirement") { + // result = await multiSig.methods + // .submitTransaction(multiSigAddress, 0, functionData) + // .send({ from: deployer ,gas: 300000, gasPrice: gasPriceNow }); + // } + // else if(enableMethod == "removeOwner") { + // result = await multiSig.methods + // .submitTransaction(multiSigAddress, 0, functionData) + // .send({ from: deployer ,gas: 300000, gasPrice: gasPriceNow }); + // } + // else if(enableMethod == "addOwner") { + // result = await multiSig.methods + // .submitTransaction(multiSigAddress, 0, functionData) + // .send({ from: deployer ,gas: 300000, gasPrice: gasPriceNow }); + // } + // else if(enableMethod == "addAllowedToken") { + // result = await multiSig.methods + // .submitTransaction(allowTokensAddress, 0, functionData) + // .send({ from: deployer ,gas: 300000, gasPrice: gasPriceNow }); + // } + // else if(enableMethod == "removeAllowedToken") { + // result = await multiSig.methods + // .submitTransaction(allowTokensAddress, 0, functionData) + // .send({ from: deployer ,gas: 300000, gasPrice: gasPriceNow }); + // } + // else if(enableMethod == "setFeeAndMinPerToken"){ + // result = await multiSig.methods + // .submitTransaction(allowTokensAddress, 0, functionData) + // .send({ from: deployer ,gas: 300000, gasPrice: gasPriceNow }); + // } + // else if(enableMethod == "removeMember"){ + // result = await multiSig.methods + // .submitTransaction(federationAddress, 0, functionData) + // .send({ from: deployer ,gas: 300000, gasPrice: gasPriceNow }); + // } + // else if(enableMethod == "addMember"){ + // result = await multiSig.methods + // .submitTransaction(federationAddress, 0, functionData) + // .send({ from: deployer ,gas: 300000, gasPrice: gasPriceNow }); + // } + console.log(result); + }); + + await Promise.all(exeFunctionsPromises); + } catch (e) { + callback(e); + } + callback(); + console.log('All done.') +}; \ No newline at end of file diff --git a/sovryn-token-bridge/bridge/scripts/CopyAllowTokens_mainnet_v5MaxToken.js b/sovryn-token-bridge/bridge/scripts/CopyAllowTokens_mainnet_v5MaxToken.js new file mode 100755 index 00000000..20b58aa2 --- /dev/null +++ b/sovryn-token-bridge/bridge/scripts/CopyAllowTokens_mainnet_v5MaxToken.js @@ -0,0 +1,340 @@ +const fs = require('fs'); +const AbisObject = require("./BridgeMainnetAddresses_v5MaxToken").abisObject; +const AbisObjectV5 = require("./BridgeMainnetAddresses_v5MaxToken").abisObjectV5; + +const BscBSCV5Config = require("./BridgeMainnetAddresses_v5MaxToken").bscBSCV5Config; +const RskBSCV5Config = require("./BridgeMainnetAddresses_v5MaxToken").rskBSCV5Config; +const EthETHV5Config = require("./BridgeMainnetAddresses_v5MaxToken").ethETHV5Config; +const RskETHV5Config = require("./BridgeMainnetAddresses_v5MaxToken").rskETHV5Config; + +const BscBSCConfig = require("./BridgeMainnetAddresses_v5MaxToken").bscBSCConfig; +const RskBSCConfig = require("./BridgeMainnetAddresses_v5MaxToken").rskBSCConfig; +const EthETHConfig = require("./BridgeMainnetAddresses_v5MaxToken").ethETHConfig; +const RskETHConfig = require("./BridgeMainnetAddresses_v5MaxToken").rskETHConfig; +const BmainnetStableCoins = require("./BridgeMainnetAddresses_v5MaxToken").bmainnetStableCoins; +const MainnetStableCoins = require("./BridgeMainnetAddresses_v5MaxToken").mainnetStableCoins; +const RskbscmainnetStableCoins = require("./BridgeMainnetAddresses_v5MaxToken").rskbscmainnetStableCoins; +const RskethmainnetStableCoins = require("./BridgeMainnetAddresses_v5MaxToken").rskethmainnetStableCoins; +const RskmainnetTokens = require("./BridgeMainnetAddresses_v5MaxToken").rskmainnetTokens; +const BmainnetETHToken = require("./BridgeMainnetAddresses_v5MaxToken").bmainnetETHToken; +const RskbscmainnetETHToken = require("./BridgeMainnetAddresses_v5MaxToken").rskbscmainnetETHToken; +const RskethmainnetETHToken = require("./BridgeMainnetAddresses_v5MaxToken").rskmainnetTokensETH; +const BmainnetBNB = require("./BridgeMainnetAddresses_v5MaxToken").bmainnetBNB; +const RskmainnetRBTC = require("./BridgeMainnetAddresses_v5MaxToken").rskmainnetRBTC; +const RskbscmainnetBNB = require("./BridgeMainnetAddresses_v5MaxToken").rskbscmainnetBNB; +const BscbscbmainnetRBTC = require("./BridgeMainnetAddresses_v5MaxToken").bscbscbmainnetRBTC; +const MainnetSOV = require("./BridgeMainnetAddresses_v5MaxToken").mainnetSOV; +const BmainnetSOV = require("./BridgeMainnetAddresses_v5MaxToken").bmainnetSOV; +const MainnetETH = require("./BridgeMainnetAddresses_v5MaxToken").mainnetETH; + + +//const deployer= "0x12D90403733b6DD1f88240C773a6613331e60bCF"; +const deployer= "0xdc83580AbF622Ec75f69B56DDF945Dd6CDBF53D2"; + +module.exports = async callback => { + try { + + const netType = process.argv[5]; + const bridgeType = process.argv[6]; + const tokenType = process.argv[7]; + const enableMethod = process.argv[8]; + const input0 = process.argv[9]; + const input1 = process.argv[10]; + const input2 = process.argv[11]; + +console.log(netType + " " +bridgeType ); + + if( bridgeType == "h" || bridgeType == "help" ) { + throw new Error('npx truffle exec ./scripts/BridgeControl.js --network \n' + + 'net: mainnet, bmainnet, rskmainnet, ropsten, btestnet, rsktestnet\n' + + 'bridgeType: bsc, eth\n'+ + 'tokenType: "", sov, stable, eth, bnb, rbtc\n'+ + 'enableMethod: name of the function to call\n'+ + 'input0: first input to function\n'+ + 'input1: second input to function\n'+ + 'input2: third input to function\n' + + 'enableMethod list:\n' + + 'Bridge: pause changeAllowTokens setNativeTokenSymbol initialSymbolPrefixSetup setWETHAddress setRevokeTransaction setBridgeReceiverStatus\n' + + 'MultiSig: changeRequirement removeOwner addOwner\n' + + 'AllowTokens: addAllowedToken removeAllowedToken setFeeAndMinPerToken setMaxTokensAllowed changeDailyLimit setMaxPerToken\n' + + 'Federation: removeMember addMember setRevokeTransactionAndVote\n\n' + + 'Example: \n' + + 'npx truffle exec ./scripts/BridgeControl.js --network rskmainnet bsc bnb "setFeeAndMinPerToken" "" 10000000000000000 100000000000000000\n' + + 'npx truffle exec ./scripts/BridgeControl.js --network rskmainnet bsc "" "removeOwner" "0xdc83580abf622ec75f69b56ddf945dd6cdbf53d2" "" ""'); + } + + const gasPrice = await web3.eth.getGasPrice(); + console.log("gas price is: " + gasPrice); + let gasPriceNow = gasPrice; + if (netType == "mainnet") { + gasPriceNow = Number.parseInt(gasPrice * 1.5); + } + console.log("gas price now is: " + gasPriceNow); + + const bridgeAbi = AbisObject.bridgeABI; + const federationAbi = AbisObject.federationABI; + const multisigAbi = AbisObject.multiSigABI; + const AllowTokensAbi = AbisObject.allowTokensABI; + const erc777ConverterAbi = AbisObject.erc777ConverterABI; + + const AllowTokensV5Abi = AbisObjectV5.allowTokensV5ABI; + + let bridgeAddress; + let federationAddress; + let multiSigAddress; + let allowTokensAddress; + let erc777ConverterAddress; + + let allowTokensV5Address; + + let tokens; + let decimals; + + let smartContract; + if(tokenType == "") { + tokens = [ + RskmainnetTokens.SOV_RskMainnet[30].address, + ]; + }; + if(netType == "bmainnet") { + if(tokenType == "stable") { + tokens = [ + BmainnetStableCoins.DAI_BMainnet[56].address, + BmainnetStableCoins.USDT_BMainnet[56].address, + BmainnetStableCoins.USDC_BMainnet[56].address, + BmainnetStableCoins.BUSD_BMainnet[56].address, + ]; + decimals = [ + BmainnetStableCoins.DAI_BMainnet[56].decimals, + BmainnetStableCoins.USDT_BMainnet[56].decimals, + BmainnetStableCoins.USDC_BMainnet[56].decimals, + BmainnetStableCoins.BUSD_BMainnet[56].decimals, + ]; + } + else if(tokenType == "eth") { + tokens = [ + BmainnetETHToken.ETH_BMainnet[56].address + ]; + decimals = [ + BmainnetETHToken.ETH_BMainnet[56].decimals + ]; + } + else if(tokenType == "bnb") { + tokens = [ + BmainnetBNB.BNB_BMainnet[56].address + ]; + decimals = [ + BmainnetBNB.BNB_BMainnet[56].decimals + ]; + } + else if(tokenType == "rbtc") { + tokens = [ + BscbscbmainnetRBTC.RBTC_BscBSCMainnet[56].address + ]; + decimals = [ + BscbscbmainnetRBTC.RBTC_BscBSCMainnet[56].decimals + ]; + } + else if(tokenType == "sov") { + tokens = [ + BmainnetSOV.SOV_BMainnet[56].address + ]; + decimals = [ + BmainnetSOV.SOV_BMainnet[56].decimals + ]; + }; + + bridgeAddress = BscBSCConfig.bridge; + federationAddress = BscBSCConfig.federation; + multiSigAddress= BscBSCConfig.multiSig; + allowTokensAddress= BscBSCConfig.allowTokens; + erc777ConverterAddress= BscBSCConfig.erc777Converter; + + allowTokensV5Address= BscBSCV5Config.allowTokens; + } + else if(netType == "mainnet") { + if(tokenType == "stable") { + tokens = [ + MainnetStableCoins.DAI_Mainnet[1].address, + MainnetStableCoins.USDT_Mainnet[1].address, + MainnetStableCoins.USDC_Mainnet[1].address, + ]; + decimals = [ + MainnetStableCoins.DAI_Mainnet[1].decimals, + MainnetStableCoins.USDT_Mainnet[1].decimals, + MainnetStableCoins.USDC_Mainnet[1].decimals, + ]; + } + else if(tokenType == "sov") { + tokens = [ + MainnetSOV.SOV_Mainnet[1].address + ]; + decimals = [ + MainnetSOV.SOV_Mainnet[1].decimals + ]; + } + else if(tokenType == "eth") { + tokens = [ + MainnetETH.ETH_Mainnet[1].address + ]; + decimals = [ + MainnetETH.ETH_Mainnet[1].decimals + ]; + }; + bridgeAddress = EthETHConfig.bridge; + federationAddress = EthETHConfig.federation; + multiSigAddress= EthETHConfig.multiSig; + allowTokensAddress= EthETHConfig.allowTokens; + erc777ConverterAddress= EthETHConfig.erc777Converter; + allowTokensV5Address= EthETHV5Config.allowTokens; + + } + else if(netType == "rskmainnet"){ + if(tokenType == "sov") { + tokens = [ + RskmainnetTokens.SOV_RskMainnet[30].address.toLowerCase() + ]; + decimals = [ + RskmainnetTokens.SOV_RskMainnet[30].decimals + ]; + + }; + if(tokenType == "rbtc") { + tokens = [ + RskmainnetRBTC.RBTC_RskMainnet[30].address.toLowerCase() + ]; + decimals = [ + RskmainnetRBTC.RBTC_RskMainnet[30].decimals + ]; + }; + if(bridgeType == "BSC"){ + console.log(netType + " " +bridgeType ); + + bridgeAddress = RskBSCConfig.bridge; + federationAddress = RskBSCConfig.federation; + multiSigAddress= RskBSCConfig.multiSig; + allowTokensAddress= RskBSCConfig.allowTokens; + erc777ConverterAddress= RskBSCConfig.erc777Converter; + allowTokensV5Address= RskBSCV5Config.allowTokens; + + if(tokenType == "stable") { + tokens = [ + RskbscmainnetStableCoins.DAI_RskBSCMainnet[30].address.toLowerCase(), + RskbscmainnetStableCoins.USDT_RskBSCMainnet[30].address.toLowerCase(), + RskbscmainnetStableCoins.USDC_RskBSCMainnet[30].address.toLowerCase(), + RskbscmainnetStableCoins.BUSD_RskBSCMainnet[30].address.toLowerCase() + ]; + decimals = [ + RskbscmainnetStableCoins.DAI_RskBSCMainnet[30].decimals, + RskbscmainnetStableCoins.USDT_RskBSCMainnet[30].decimals, + RskbscmainnetStableCoins.USDC_RskBSCMainnet[30].decimals, + RskbscmainnetStableCoins.BUSD_RskBSCMainnet[30].decimals, + ]; + } + else if(tokenType == "eth") { + tokens = [ + RskbscmainnetETHToken.ETH_RskBSCMainnet[30].address.toLowerCase() + ]; + decimals = [ + RskbscmainnetETHToken.ETH_RskBSCMainnet[30].decimals + ]; + + } + else if(tokenType == "bnb") { + tokens = [ + RskbscmainnetBNB.BNB_RskBSCMainnet[30].address.toLowerCase() + ]; + decimals = [ + RskbscmainnetBNB.BNB_RskBSCMainnet[30].decimals + ]; + }; + + } + else if(bridgeType == "ETH") { + bridgeAddress = RskETHConfig.bridge; + federationAddress = RskETHConfig.federation; + multiSigAddress= RskETHConfig.multiSig; + allowTokensAddress= RskETHConfig.allowTokens; + erc777ConverterAddress= RskETHConfig.erc777Converter; + allowTokensV5Address= RskETHV5Config.allowTokens; + + if(tokenType == "stable") { + tokens = [ + RskethmainnetStableCoins.DAI_RskETHMainnet[30].address.toLowerCase(), + RskethmainnetStableCoins.USDT_RskETHMainnet[30].address.toLowerCase(), + RskethmainnetStableCoins.USDC_RskETHMainnet[30].address.toLowerCase() + ]; + decimals = [ + RskethmainnetStableCoins.DAI_RskETHMainnet[30].decimals, + RskethmainnetStableCoins.USDT_RskETHMainnet[30].decimals, + RskethmainnetStableCoins.USDC_RskETHMainnet[30].decimals + ]; + } + else if(tokenType == "eth") { + tokens = [ + RskethmainnetETHToken.ETH_RskMainnet[30].address.toLowerCase() + ]; + decimals = [ + RskethmainnetETHToken.ETH_RskMainnet[30].decimals + ]; + + }; + }; + }; + + console.log("bridgeAddress: "+ bridgeAddress); + console.log("federationAddress: "+ federationAddress); + console.log("multiSigAddress: "+ multiSigAddress); + console.log("allowTokensAddress: "+ allowTokensAddress); + console.log("allowTokensV5Address: "+ allowTokensV5Address); + console.log("erc777ConverterAddress: "+ erc777ConverterAddress); + const multiSig = new web3.eth.Contract(multisigAbi, multiSigAddress, {from: deployer}); + const bridge = new web3.eth.Contract(bridgeAbi, bridgeAddress, {from: deployer}); + const allowTokens = new web3.eth.Contract(AllowTokensAbi, allowTokensAddress, {from: deployer}); + const federation = new web3.eth.Contract(federationAbi, federationAddress, {from: deployer}); + const erc777Converter = new web3.eth.Contract(erc777ConverterAbi, erc777ConverterAddress, {from: deployer}); + + const allowTokensV5 = new web3.eth.Contract(AllowTokensV5Abi, allowTokensV5Address, {from: deployer}); + + let functionData; + let adjustedFee; + let adjustedMin; + + // let MaxAllowed = await allowTokensV5.methods.getMaxTokensAllowed().call(); + // let MinAllowed = await allowTokensV5.methods.getMinTokensAllowed().call(); + // let dailyLimit = await allowTokensV5.methods.dailyLimit().call(); + + // console.log("MaxAllowed: " + MaxAllowed + " MinAllowed: " + MinAllowed + " dailyLimit: " + dailyLimit); + + // let resultG = await allowTokens.methods.setMaxTokensAllowed(MaxAllowed).send({ + // from: deployer}); + // console.log(resultG); + // resultG = await allowTokens.methods.setMinTokensAllowed(MinAllowed).send({ + // from: deployer}); + // console.log(resultG); + // resultG = await allowTokens.methods.changeDailyLimit(dailyLimit).send({ + // from: deployer}); + // console.log(resultG); + + const exeFunctionsPromises = tokens.map(async (token, index) => { + let Tfee = await allowTokensV5.methods.getFeePerToken(token).call(); + let Tmin = await allowTokensV5.methods.getMinPerToken(token).call(); + console.log(tokenType + " " + token + " Fee: " + Tfee + " Min: " + Tmin); + + const result = await allowTokens.methods.setFeeAndMinPerToken(token, Tfee, Tmin).send({ + from: deployer}); + const result1 = await allowTokens.methods.addAllowedToken(token).send({ + from: deployer}); + + console.log(result); + console.log(result1); + + }); + + await Promise.all(exeFunctionsPromises); + } catch (e) { + callback(e); + } + callback(); + console.log('All done.') +}; \ No newline at end of file diff --git a/sovryn-token-bridge/bridge/scripts/CopyAllowTokens_testnet_v5MaxToken.js b/sovryn-token-bridge/bridge/scripts/CopyAllowTokens_testnet_v5MaxToken.js new file mode 100755 index 00000000..a4aabecd --- /dev/null +++ b/sovryn-token-bridge/bridge/scripts/CopyAllowTokens_testnet_v5MaxToken.js @@ -0,0 +1,310 @@ +const fs = require('fs'); +const AbisObject = require("./BridgeTestnetAddresses_v5MaxToken").abisObject; +const AbisObjectV5 = require("./BridgeTestnetAddresses_v5MaxToken").abisObjectV5; + +const BscBSCV5Config = require("./BridgeTestnetAddresses_v5MaxToken").bscBSCV5Config; +const BscBSCConfig = require("./BridgeTestnetAddresses_v5MaxToken").bscBSCConfig; +const RskBSCConfig = require("./BridgeTestnetAddresses_v5MaxToken").rskBSCConfig; +const EthETHConfig = require("./BridgeTestnetAddresses_v5MaxToken").ethETHConfig; +const RskETHConfig = require("./BridgeTestnetAddresses_v5MaxToken").rskETHConfig; +const BtestnetStableCoins = require("./BridgeTestnetAddresses_v5MaxToken").btestnetStableCoins; +const TestnetStableCoins = require("./BridgeTestnetAddresses_v5MaxToken").testnetStableCoins; +const RskbsctestnetStableCoins = require("./BridgeTestnetAddresses_v5MaxToken").rskbsctestnetStableCoins; +const RskethtestnetStableCoins = require("./BridgeTestnetAddresses_v5MaxToken").rskethtestnetStableCoins; +const RsktestnetTokens = require("./BridgeTestnetAddresses_v5MaxToken").rsktestnetTokens; +const BtestnetETHToken = require("./BridgeTestnetAddresses_v5MaxToken").btestnetETHToken; +const RskbsctestnetETHToken = require("./BridgeTestnetAddresses_v5MaxToken").rskbsctestnetETHToken; +const BtestnetBNB = require("./BridgeTestnetAddresses_v5MaxToken").btestnetBNB; +const RsktestnetRBTC = require("./BridgeTestnetAddresses_v5MaxToken").rsktestnetRBTC; +const RskbsctestnetBNB = require("./BridgeTestnetAddresses_v5MaxToken").rskbsctestnetBNB; +const BscbscbtestnetRBTC = require("./BridgeTestnetAddresses_v5MaxToken").bscbscbtestnetRBTC; +const TestnetSOV = require("./BridgeTestnetAddresses_v5MaxToken").testnetSOV; +const BtestnetSOV = require("./BridgeTestnetAddresses_v5MaxToken").btestnetSOV; + + +const deployer= "0x12D90403733b6DD1f88240C773a6613331e60bCF"; + +module.exports = async callback => { + try { + + const netType = process.argv[5]; + const bridgeType = process.argv[6]; + const tokenType = process.argv[7]; + const enableMethod = process.argv[8]; + const input0 = process.argv[9]; + const input1 = process.argv[10]; + const input2 = process.argv[11]; + + + if( bridgeType == "h" || bridgeType == "help" ) { + throw new Error('npx truffle exec ./scripts/BridgeControl.js --network \n' + + 'net: testnet, btestnet, rsktestnet, ropsten, btestnet, rsktestnet\n' + + 'bridgeType: bsc, eth\n'+ + 'tokenType: "", sov, stable, eth, bnb, rbtc\n'+ + 'enableMethod: name of the function to call\n'+ + 'input0: first input to function\n'+ + 'input1: second input to function\n'+ + 'input2: third input to function\n' + + 'enableMethod list:\n' + + 'Bridge: pause changeAllowTokens setNativeTokenSymbol initialSymbolPrefixSetup setWETHAddress setRevokeTransaction setBridgeReceiverStatus\n' + + 'MultiSig: changeRequirement removeOwner addOwner\n' + + 'AllowTokens: addAllowedToken removeAllowedToken setFeeAndMinPerToken setMaxTokensAllowed changeDailyLimit setMaxPerToken\n' + + 'Federation: removeMember addMember setRevokeTransactionAndVote\n\n' + + 'Example: \n' + + 'npx truffle exec ./scripts/BridgeControl.js --network rsktestnet bsc bnb "setFeeAndMinPerToken" "" 10000000000000000 100000000000000000\n' + + 'npx truffle exec ./scripts/BridgeControl.js --network rsktestnet bsc "" "removeOwner" "0xdc83580abf622ec75f69b56ddf945dd6cdbf53d2" "" ""'); + } + + const gasPrice = await web3.eth.getGasPrice(); + console.log("gas price is: " + gasPrice); + let gasPriceNow = gasPrice; + if (netType == "testnet") { + gasPriceNow = Number.parseInt(gasPrice * 1.5); + } + console.log("gas price now is: " + gasPriceNow); + + const bridgeAbi = AbisObject.bridgeABI; + const federationAbi = AbisObject.federationABI; + const multisigAbi = AbisObject.multiSigABI; + const AllowTokensAbi = AbisObject.allowTokensABI; + const erc777ConverterAbi = AbisObject.erc777ConverterABI; + + const AllowTokensV5Abi = AbisObjectV5.allowTokensV5ABI; + + let bridgeAddress; + let federationAddress; + let multiSigAddress; + let allowTokensAddress; + let erc777ConverterAddress; + + let allowTokensV5Address; + + let tokens; + let decimals; + + let smartContract; + if(tokenType == "") { + tokens = [ + RsktestnetTokens.SOV_RskTestnet[31].address, + ]; + }; + if(netType == "btestnet") { + if(tokenType == "stable") { + tokens = [ + BtestnetStableCoins.DAI_BTestnet[97].address, + BtestnetStableCoins.USDT_BTestnet[97].address, + BtestnetStableCoins.USDC_BTestnet[97].address, + BtestnetStableCoins.BUSD_BTestnet[97].address, + ]; + decimals = [ + BtestnetStableCoins.DAI_BTestnet[97].decimals, + BtestnetStableCoins.USDT_BTestnet[97].decimals, + BtestnetStableCoins.USDC_BTestnet[97].decimals, + BtestnetStableCoins.BUSD_BTestnet[97].decimals, + ]; + } + else if(tokenType == "eth") { + tokens = [ + BtestnetETHToken.ETH_BTestnet[97].address + ]; + decimals = [ + BtestnetETHToken.ETH_BTestnet[97].decimals + ]; + } + else if(tokenType == "bnb") { + tokens = [ + BtestnetBNB.BNB_BTestnet[97].address + ]; + decimals = [ + BtestnetBNB.BNB_BTestnet[97].decimals + ]; + } + else if(tokenType == "rbtc") { + tokens = [ + BscbscbtestnetRBTC.RBTC_BscBSCTestnet[97].address + ]; + decimals = [ + BscbscbtestnetRBTC.RBTC_BscBSCTestnet[97].decimals + ]; + } + else if(tokenType == "sov") { + tokens = [ + BtestnetSOV.SOV_BTestnet[97].address + ]; + decimals = [ + BtestnetSOV.SOV_BTestnet[97].decimals + ]; + }; + + bridgeAddress = BscBSCConfig.bridge; + federationAddress = BscBSCConfig.federation; + multiSigAddress= BscBSCConfig.multiSig; + allowTokensAddress= BscBSCConfig.allowTokens; + erc777ConverterAddress= BscBSCConfig.erc777Converter; + + allowTokensV5Address= BscBSCV5Config.allowTokens; + } + else if(netType == "ropsten") { + if(tokenType == "stable") { + tokens = [ + TestnetStableCoins.DAI_Testnet[3].address, + TestnetStableCoins.USDT_Testnet[3].address, + TestnetStableCoins.USDC_Testnet[3].address, + ]; + decimals = [ + TestnetStableCoins.DAI_Testnet[3].decimals, + TestnetStableCoins.USDT_Testnet[3].decimals, + TestnetStableCoins.USDC_Testnet[3].decimals, + ]; + } + else if(tokenType == "sov") { + tokens = [ + TestnetSOV.SOV_Testnet[3].address + ]; + decimals = [ + TestnetSOV.SOV_Testnet[3].decimals + ]; + }; + bridgeAddress = EthETHConfig.bridge; + federationAddress = EthETHConfig.federation; + multiSigAddress= EthETHConfig.multiSig; + allowTokensAddress= EthETHConfig.allowTokens; + erc777ConverterAddress= EthETHConfig.erc777Converter; + + } + else if(netType == "rsktestnet"){ + if(tokenType == "sov") { + tokens = [ + RsktestnetTokens.SOV_RskTestnet[31].address.toLowerCase() + ]; + decimals = [ + RsktestnetTokens.SOV_RskTestnet[31].decimals + ]; + + }; + if(tokenType == "rbtc") { + tokens = [ + RsktestnetRBTC.RBTC_RskTestnet[31].address.toLowerCase() + ]; + decimals = [ + RsktestnetRBTC.RBTC_RskTestnet[31].decimals + ]; + }; + if(bridgeType == "bsc"){ + bridgeAddress = RskBSCConfig.bridge; + federationAddress = RskBSCConfig.federation; + multiSigAddress= RskBSCConfig.multiSig; + allowTokensAddress= RskBSCConfig.allowTokens; + erc777ConverterAddress= RskBSCConfig.erc777Converter; + + if(tokenType == "stable") { + tokens = [ + RskbsctestnetStableCoins.DAI_RskBSCTestnet[31].address.toLowerCase(), + RskbsctestnetStableCoins.USDT_RskBSCTestnet[31].address.toLowerCase(), + RskbsctestnetStableCoins.USDC_RskBSCTestnet[31].address.toLowerCase(), + RskbsctestnetStableCoins.BUSD_RskBSCTestnet[31].address.toLowerCase() + ]; + decimals = [ + RskbsctestnetStableCoins.DAI_RskBSCTestnet[31].decimals, + RskbsctestnetStableCoins.USDT_RskBSCTestnet[31].decimals, + RskbsctestnetStableCoins.USDC_RskBSCTestnet[31].decimals, + RskbsctestnetStableCoins.BUSD_RskBSCTestnet[31].decimals, + ]; + } + else if(tokenType == "eth") { + tokens = [ + RskbsctestnetETHToken.ETH_RskBSCTestnet[31].address.toLowerCase() + ]; + decimals = [ + RskbsctestnetETHToken.ETH_RskBSCTestnet[31].decimals + ]; + + } + else if(tokenType == "bnb") { + tokens = [ + RskbsctestnetBNB.BNB_RskBSCTestnet[31].address.toLowerCase() + ]; + decimals = [ + RskbsctestnetBNB.BNB_RskBSCTestnet[31].decimals + ]; + }; + + } + else if(bridgeType == "eth") { + bridgeAddress = RskETHConfig.bridge; + federationAddress = RskETHConfig.federation; + multiSigAddress= RskETHConfig.multiSig; + allowTokensAddress= RskETHConfig.allowTokens; + erc777ConverterAddress= RskETHConfig.erc777Converter; + + if(tokenType == "stable") { + tokens = [ + RskethtestnetStableCoins.DAI_RskETHTestnet[31].address.toLowerCase(), + RskethtestnetStableCoins.USDT_RskETHTestnet[31].address.toLowerCase(), + RskethtestnetStableCoins.USDC_RskETHTestnet[31].address.toLowerCase() + ]; + decimals = [ + RskethtestnetStableCoins.DAI_RskETHTestnet[31].decimals, + RskethtestnetStableCoins.USDT_RskETHTestnet[31].decimals, + RskethtestnetStableCoins.USDC_RskETHTestnet[31].decimals + ]; + }; + }; + }; + + console.log("bridgeAddress: "+ bridgeAddress); + console.log("federationAddress: "+ federationAddress); + console.log("multiSigAddress: "+ multiSigAddress); + console.log("allowTokensAddress: "+ allowTokensAddress); + console.log("allowTokensV5Address: "+ allowTokensV5Address); + console.log("erc777ConverterAddress: "+ erc777ConverterAddress); + const multiSig = new web3.eth.Contract(multisigAbi, multiSigAddress, {from: deployer}); + const bridge = new web3.eth.Contract(bridgeAbi, bridgeAddress, {from: deployer}); + const allowTokens = new web3.eth.Contract(AllowTokensAbi, allowTokensAddress, {from: deployer}); + const federation = new web3.eth.Contract(federationAbi, federationAddress, {from: deployer}); + const erc777Converter = new web3.eth.Contract(erc777ConverterAbi, erc777ConverterAddress, {from: deployer}); + + const allowTokensV5 = new web3.eth.Contract(AllowTokensV5Abi, allowTokensV5Address, {from: deployer}); + + let functionData; + let adjustedFee; + let adjustedMin; + + // let MaxAllowed = await allowTokensV5.methods.getMaxTokensAllowed().call(); + // let MinAllowed = await allowTokensV5.methods.getMinTokensAllowed().call(); + // let dailyLimit = await allowTokensV5.methods.dailyLimit().call(); + + // console.log("MaxAllowed: " + MaxAllowed + " MinAllowed: " + MinAllowed + " dailyLimit: " + dailyLimit); + + // let resultG = await allowTokens.methods.setMaxTokensAllowed(MaxAllowed).send({ + // from: deployer}); + // console.log(resultG); + // resultG = await allowTokens.methods.setMinTokensAllowed(MinAllowed).send({ + // from: deployer}); + // console.log(resultG); + // resultG = await allowTokens.methods.changeDailyLimit(dailyLimit).send({ + // from: deployer}); + // console.log(resultG); + + const exeFunctionsPromises = tokens.map(async (token, index) => { + let Tfee = await allowTokensV5.methods.getFeePerToken(token).call(); + let Tmin = await allowTokensV5.methods.getMinPerToken(token).call(); + console.log(tokenType + " " + token + " Fee: " + Tfee + " Min: " + Tmin); + + const result = await allowTokens.methods.setFeeAndMinPerToken(token, Tfee, Tmin).send({ + from: deployer}); + const result1 = await allowTokens.methods.addAllowedToken(token).send({ + from: deployer}); + + console.log(result); + console.log(result1); + + }); + + await Promise.all(exeFunctionsPromises); + } catch (e) { + callback(e); + } + callback(); + console.log('All done.') +}; \ No newline at end of file diff --git a/sovryn-token-bridge/bridge/scripts/OldAbis/AllowTokensV5.json b/sovryn-token-bridge/bridge/scripts/OldAbis/AllowTokensV5.json new file mode 100644 index 00000000..66b55f51 --- /dev/null +++ b/sovryn-token-bridge/bridge/scripts/OldAbis/AllowTokensV5.json @@ -0,0 +1 @@ +[{"inputs":[{"internalType":"address","name":"_manager","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_tokenAddress","type":"address"}],"name":"AllowedTokenAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_tokenAddress","type":"address"}],"name":"AllowedTokenRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"_enabled","type":"bool"}],"name":"AllowedTokenValidation","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"dailyLimit","type":"uint256"}],"name":"DailyLimitChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_token","type":"address"},{"indexed":false,"internalType":"uint256","name":"_feeConst","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_minAmount","type":"uint256"}],"name":"FeeAndMinPerTokenChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_maxTokens","type":"uint256"}],"name":"MaxTokensAllowedChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_minTokens","type":"uint256"}],"name":"MinTokensAllowedChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"allowedTokens","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"dailyLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"feeConstToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"minAllowedToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"isValidatingAllowedTokens","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getMaxTokensAllowed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getMinTokensAllowed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"isTokenAllowed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"addAllowedToken","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"removeAllowedToken","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"enableAllowedTokensValidation","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"disableAllowedTokensValidation","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"maxTokens","type":"uint256"}],"name":"setMaxTokensAllowed","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"minTokens","type":"uint256"}],"name":"setMinTokensAllowed","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_dailyLimit","type":"uint256"}],"name":"changeDailyLimit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"tokenToUse","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"spentToday","type":"uint256"},{"internalType":"bool","name":"isSideToken","type":"bool"}],"name":"isValidTokenTransfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"spentToday","type":"uint256"}],"name":"calcMaxWithdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getMinPerToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"getFeePerToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"_feeConst","type":"uint256"},{"internalType":"uint256","name":"_minAmount","type":"uint256"}],"name":"setFeeAndMinPerToken","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] \ No newline at end of file diff --git a/sovryn-token-bridge/bridge/scripts/Upgrade_v5MaxToken_Configs/UpgradeMainnet_BscBridge_Bmainnet_Config.json b/sovryn-token-bridge/bridge/scripts/Upgrade_v5MaxToken_Configs/UpgradeMainnet_BscBridge_Bmainnet_Config.json new file mode 100644 index 00000000..e220b598 --- /dev/null +++ b/sovryn-token-bridge/bridge/scripts/Upgrade_v5MaxToken_Configs/UpgradeMainnet_BscBridge_Bmainnet_Config.json @@ -0,0 +1,12 @@ +{ + "bridgeProxyAddress": "0xdfc7127593c8af1a17146893f10e08528f4c2aa7", + "newBridgeAddress": "0x4736E384991Ea267483D42524e61738295495752", + "deployerAddress": "0xdc83580AbF622Ec75f69B56DDF945Dd6CDBF53D2", + "ownerAddress": "0x4844B0C25b1208602604939cFCae68EC4Ddc5D77", + "multiSigAddress": "0xec3fabc3517e64e07669dd1d2d673f466f93a328", + "proxyAdminAddress": "0xF3Fa3FE72EfAD000Febd5f7460C505224A08012F", + "allowTokensAddress": "0xc4b5178Cc086E764568AdfB2dacCBB0d973e8132", + "federationAddress": "0x33f8743d5AFa519Dd373a75E7AA5C255e2c82468", + "erc777ConverterAddress": "0x9D46B33171eA7124aEE472bFe61B5B7084B55069", + "pauseAllowTokensAddress": "0x05b68e70168e876b2025f837bc8e0b2312d5327d" +} \ No newline at end of file diff --git a/sovryn-token-bridge/bridge/scripts/Upgrade_v5MaxToken_Configs/UpgradeMainnet_BscBridge_Rskmainnet_Config.json b/sovryn-token-bridge/bridge/scripts/Upgrade_v5MaxToken_Configs/UpgradeMainnet_BscBridge_Rskmainnet_Config.json new file mode 100644 index 00000000..b6b25026 --- /dev/null +++ b/sovryn-token-bridge/bridge/scripts/Upgrade_v5MaxToken_Configs/UpgradeMainnet_BscBridge_Rskmainnet_Config.json @@ -0,0 +1,12 @@ +{ + "bridgeProxyAddress": "0x971b97c8cc82e7d27bc467c2dc3f219c6ee2e350", + "newBridgeAddress": "0x648BAA4169e22438e86d8E4e04a782Dadf69CB22", + "deployerAddress": "0xdc83580AbF622Ec75f69B56DDF945Dd6CDBF53D2", + "ownerAddress": "0x4844B0C25b1208602604939cFCae68EC4Ddc5D77", + "multiSigAddress": "0xee9ea57555d9533d71f6f77e0e480961f068a6c5", + "proxyAdminAddress": "0x68558A6cD89b4E93C9a01d7519a2d6C6568a3700", + "allowTokensAddress": "0x200FD7a1cCEa4651F15008cC99bF82d7461EFd3F", + "federationAddress": "0xA7938270C2bF99A9cF033c9d35156d2dDb097B12", + "erc777ConverterAddress": "0xc8149b1F15794D135Dfe2924955cb90709Ac7070", + "pauseAllowTokensAddress": "0xa2f50a2c699c1aa3b9089f6b565d4999d45d8983" +} \ No newline at end of file diff --git a/sovryn-token-bridge/bridge/scripts/Upgrade_v5MaxToken_Configs/UpgradeMainnet_EthBridge_Mainnet_Config.json b/sovryn-token-bridge/bridge/scripts/Upgrade_v5MaxToken_Configs/UpgradeMainnet_EthBridge_Mainnet_Config.json new file mode 100644 index 00000000..08932938 --- /dev/null +++ b/sovryn-token-bridge/bridge/scripts/Upgrade_v5MaxToken_Configs/UpgradeMainnet_EthBridge_Mainnet_Config.json @@ -0,0 +1,12 @@ +{ + "bridgeProxyAddress": "0x33c0d33a0d4312562ad622f91d12b0ac47366ee1", + "newBridgeAddress": "0x882619AF8AA0f1946d9F375E64994e1246F9b52f", + "deployerAddress": "0xdc83580AbF622Ec75f69B56DDF945Dd6CDBF53D2", + "ownerAddress": "0x4844B0C25b1208602604939cFCae68EC4Ddc5D77", + "multiSigAddress": "0x062c74f9d27b1178bb76186c1756128ccb3ccd2e", + "proxyAdminAddress": "0xd6001073Ef1BA973e53719766780B95667512C07", + "allowTokensAddress": "0xf9A59a649859A27d664C8bDb51fA53bCb268545C", + "federationAddress": "0x74aa9b461CAd174cA066fc80AF2151c96Bd4D45f", + "erc777ConverterAddress": "0xC0b2A9E31f69e4F0bC24584C678C582714a4fA1b", + "pauseAllowTokensAddress": "0xaD95D2857F6a657B0B3Ff538DF028b0E2E806453" +} \ No newline at end of file diff --git a/sovryn-token-bridge/bridge/scripts/Upgrade_v5MaxToken_Configs/UpgradeMainnet_EthBridge_Rskmainnet_Config.json b/sovryn-token-bridge/bridge/scripts/Upgrade_v5MaxToken_Configs/UpgradeMainnet_EthBridge_Rskmainnet_Config.json new file mode 100644 index 00000000..9a964590 --- /dev/null +++ b/sovryn-token-bridge/bridge/scripts/Upgrade_v5MaxToken_Configs/UpgradeMainnet_EthBridge_Rskmainnet_Config.json @@ -0,0 +1,12 @@ +{ + "bridgeProxyAddress": "0x1ccad820b6d031b41c54f1f3da11c0d48b399581", + "newBridgeAddress": "0x9d77367DFf391305C49c059461EfC20b3a548B56", + "deployerAddress": "0xdc83580AbF622Ec75f69B56DDF945Dd6CDBF53D2", + "ownerAddress": "0x4844B0C25b1208602604939cFCae68EC4Ddc5D77", + "multiSigAddress": "0xb64322e10b5ae1be121b8bb0dead560c53d9dbc3", + "proxyAdminAddress": "0x7e1d65e22a6e05f3b4253c4ef29e6b96ca3121a4", + "allowTokensAddress": "0x7DC1D73C620cF8eB167eDD32942DA0d01B70adC0", + "federationAddress": "0x5e2ee3cd18421838d066bd1dc02fb1f767d834dd", + "erc777ConverterAddress": "0xb86623c103843ccf75c6f0073d84bcfc0e34536c", + "pauseAllowTokensAddress": "0xd2090fe759613c3a3e2962c6bb2ad046f62d32ff" +} \ No newline at end of file diff --git a/sovryn-token-bridge/bridge/scripts/Upgrade_v5MaxToken_Configs/UpgradeRopstenDEVConfig.json b/sovryn-token-bridge/bridge/scripts/Upgrade_v5MaxToken_Configs/UpgradeRopstenDEVConfig.json new file mode 100644 index 00000000..322c2705 --- /dev/null +++ b/sovryn-token-bridge/bridge/scripts/Upgrade_v5MaxToken_Configs/UpgradeRopstenDEVConfig.json @@ -0,0 +1,12 @@ +{ + "bridgeProxyAddress": "0x4Ff0E83e443467a1723FC2F0B74C91f31CEacB83", + "newBridgeAddress": "0xEe695AcCecc1AEbE0a411E558454d786b972ee47", + "deployerAddress": "0x12D90403733b6DD1f88240C773a6613331e60bCF", + "ownerAddress": "0x12D90403733b6DD1f88240C773a6613331e60bCF", + "multiSigAddress": "0x314d9163Dd122368b3c6329b081d2400a9f238d1", + "proxyAdminAddress": "0x9b9F87e4B9F3f93c920eEAd01593573bEb21F737", + "allowTokensAddress": "0x95e0733f924f8f423fc87a201e56e56d9634efd2", + "federationAddress": "0xd2624d1fa09F077aFe1d0C694600693A1d8A0a75", + "erc777ConverterAddress": "0x735b0Fc930884c8f2928f1009c1b9Bd883d48312", + "pauseAllowTokensAddress": "0xe69c4e33Fc72abab4a61f6e245e12cB25DC4D8A1" +} \ No newline at end of file diff --git a/sovryn-token-bridge/bridge/scripts/Upgrade_v5MaxToken_Configs/UpgradeTestnet_BscBridge_Btestnet_Config.json b/sovryn-token-bridge/bridge/scripts/Upgrade_v5MaxToken_Configs/UpgradeTestnet_BscBridge_Btestnet_Config.json new file mode 100644 index 00000000..2a2f5b70 --- /dev/null +++ b/sovryn-token-bridge/bridge/scripts/Upgrade_v5MaxToken_Configs/UpgradeTestnet_BscBridge_Btestnet_Config.json @@ -0,0 +1,12 @@ +{ + "bridgeProxyAddress": "0x862e8aff917319594cc7faaae5350d21196c086f", + "newBridgeAddress": "0xAc4cBB32fc4e01932A4C736be9946649f308f958", + "deployerAddress": "0x12D90403733b6DD1f88240C773a6613331e60bCF", + "ownerAddress": "0x12D90403733b6DD1f88240C773a6613331e60bCF", + "multiSigAddress": "0x1d8cb60d35fcd42a8bd18d027386be9c0f9c509b", + "proxyAdminAddress": "0x06E34f21CDAe74d0BB7Ad47c3F59Fb05400d4f7B", + "allowTokensAddress": "0xC5681BE5d054167660cfF2d69c6f80521f249060", + "federationAddress": "0x6E28bB6dbBAc8bBC11F5780E39f9Aca9F9737182", + "erc777ConverterAddress": "0x573CAF2cA648e22fE9721EDB5DdfBdF5645ffd18", + "pauseAllowTokensAddress": "0xC5681BE5d054167660cfF2d69c6f80521f249060" +} \ No newline at end of file diff --git a/sovryn-token-bridge/bridge/scripts/Upgrade_v5MaxToken_Configs/UpgradeTestnet_BscBridge_Rsktestnet_Config.json b/sovryn-token-bridge/bridge/scripts/Upgrade_v5MaxToken_Configs/UpgradeTestnet_BscBridge_Rsktestnet_Config.json new file mode 100644 index 00000000..9078e9b9 --- /dev/null +++ b/sovryn-token-bridge/bridge/scripts/Upgrade_v5MaxToken_Configs/UpgradeTestnet_BscBridge_Rsktestnet_Config.json @@ -0,0 +1,12 @@ +{ + "bridgeProxyAddress": "0x2b2bcad081fa773dc655361d1bb30577caa556f8", + "newBridgeAddress": "0x1CE3cFe23CE2C0b62E22B4bA60Cfc50a35fcc33A", + "deployerAddress": "0x12D90403733b6DD1f88240C773a6613331e60bCF", + "ownerAddress": "0x12D90403733b6DD1f88240C773a6613331e60bCF", + "multiSigAddress": "0x7db96fcc37b652ceefa2523c3d25f55d9b9e9973", + "proxyAdminAddress": "0x28c984B5AB6ebD31E757CE3EE49afD11CDFC23aF", + "allowTokensAddress": "0xa9f2ccb27fe01479a1f21f3a236989c614f801bc", + "federationAddress": "0x07081144a97b58f08AB8bAaf8b05D87f5d31e5dF", + "erc777ConverterAddress": "0x15694581d442cfE30A48cacc3D347A4af4932830", + "pauseAllowTokensAddress": "0xa9f2ccb27fe01479a1f21f3a236989c614f801bc" +} \ No newline at end of file diff --git a/sovryn-token-bridge/bridge/scripts/Upgrade_v5MaxToken_Configs/UpgradeTestnet_EthBridge_Ropsten_Config.json b/sovryn-token-bridge/bridge/scripts/Upgrade_v5MaxToken_Configs/UpgradeTestnet_EthBridge_Ropsten_Config.json new file mode 100644 index 00000000..72482005 --- /dev/null +++ b/sovryn-token-bridge/bridge/scripts/Upgrade_v5MaxToken_Configs/UpgradeTestnet_EthBridge_Ropsten_Config.json @@ -0,0 +1,12 @@ +{ + "bridgeProxyAddress": "0x2b456e230225c4670fbf10b9da506c019a24cac7", + "newBridgeAddress": "0xA2355CE855716d6dcfa6b4298E8C42c7621e31A5", + "deployerAddress": "0x12D90403733b6DD1f88240C773a6613331e60bCF", + "ownerAddress": "0x12D90403733b6DD1f88240C773a6613331e60bCF", + "multiSigAddress": "0x75ea52ac8219a8f16a2dc6778874943ef2c24c45", + "proxyAdminAddress": "0xe947d5D0Bf3A695AA6d1E97D5b8593e57301D8E2", + "allowTokensAddress": "0x9bc4243880730a9bca69addb0f971700d39d1646", + "federationAddress": "0x6646d7d59044254B148b3d7c8F693c59b5b9eC79", + "erc777ConverterAddress": "0x8F3bbD7673485Cf4c43EF008e125575028fD43F1", + "pauseAllowTokensAddress": "0xD83Aa69961b71a34D4923fC820A8707c6631A5bE" +} \ No newline at end of file diff --git a/sovryn-token-bridge/bridge/scripts/Upgrade_v5MaxToken_Configs/UpgradeTestnet_EthBridge_Rsktestnet_Config.json b/sovryn-token-bridge/bridge/scripts/Upgrade_v5MaxToken_Configs/UpgradeTestnet_EthBridge_Rsktestnet_Config.json new file mode 100644 index 00000000..1287c9e7 --- /dev/null +++ b/sovryn-token-bridge/bridge/scripts/Upgrade_v5MaxToken_Configs/UpgradeTestnet_EthBridge_Rsktestnet_Config.json @@ -0,0 +1,12 @@ +{ + "bridgeProxyAddress": "0xc0e7a7fff4aba5e7286d5d67dd016b719dcc9156", + "newBridgeAddress": "0x878979A77a842B10Ab4407Eaf6Ff9948C4A5Cd0d", + "deployerAddress": "0x12D90403733b6DD1f88240C773a6613331e60bCF", + "ownerAddress": "0x12D90403733b6DD1f88240C773a6613331e60bCF", + "multiSigAddress": "0x34055c3f23bfe1d8a45c9aba53b66ffca4353600", + "proxyAdminAddress": "0x29E07FEdF8353Ec8A1448129673B42eF7dDb4D79", + "allowTokensAddress": "0x918b9fd8c2e9cf5625ea00ca6cfa270a44050d01", + "federationAddress": "0x6285DaDd35BA18F671cd1b73D708cE00d5B9cfEa", + "erc777ConverterAddress": "0x621d9Ce70Db000273Ddb3d50fa85732960a9E934", + "pauseAllowTokensAddress": "0xbBE419dc34d69DD0b74Add149241BFc89d7D3B7A" +} \ No newline at end of file diff --git a/sovryn-token-bridge/bridge/scripts/upgradeBridge_v5MaxToken.js b/sovryn-token-bridge/bridge/scripts/upgradeBridge_v5MaxToken.js new file mode 100644 index 00000000..a908ba81 --- /dev/null +++ b/sovryn-token-bridge/bridge/scripts/upgradeBridge_v5MaxToken.js @@ -0,0 +1,267 @@ +/* + * Upgrade the bridge contract. + * Run like this: npx truffle exec scripts/upgradeBridge_v5.js --network rsktestnet scripts/Upgrade_v5_Configs/UpgradeTestnet_BscBridge_Rsktestnet_Config.json + */ +const fs = require('fs'); +const bridgeAbi = require("../../abis/Bridge.json"); +const proxyAdminAbi = require("../../abis/ProxyAdmin.json"); +const multisigAbi = require("../../abis/MultiSigWallet.json"); +const allowTokensAbi = require("../../abis/AllowTokens.json"); +const federationAbi = require("../../abis/Federation.json"); +const erc777ConverterAbi = require("../../abis/Erc777Converter.json"); +const netType = process.argv[5]; + +module.exports = async callback => { + try { + const config = readConfig(); + console.log('Config:', config); + + await upgradeBridge(config); + } catch (e) { + callback(e); + return; + } + callback(); +} + +function readConfig() { + const configJsonPath = process.argv[6]; + if(!configJsonPath) { + throw new Error('specify path to config.json, eg. `npx truffle exec scripts/upgradeBridge_v4.js --network ropsten scripts/Upgrade_Configs/UpgradeTestnet_EthBridge_Rsktestnet_Config.json`'); + } + if(!fs.existsSync(configJsonPath)) { + throw new Error(`file ${configJsonPath} does not exists`); + } + return JSON.parse(fs.readFileSync(configJsonPath)); +} + +async function upgradeBridge({ + bridgeProxyAddress, + newBridgeAddress, + deployerAddress, + ownerAddress, + multiSigAddress, + proxyAdminAddress, + allowTokensAddress, + federationAddress, + erc777ConverterAddress, + pauseAllowTokensAddress +}) { + if(!bridgeProxyAddress || !newBridgeAddress || !deployerAddress || !ownerAddress || !multiSigAddress || + !proxyAdminAddress || !allowTokensAddress || !federationAddress || !erc777ConverterAddress || + !pauseAllowTokensAddress + ) { + throw new Error( + 'the following config values must be given: bridgeProxyAddress, newBridgeAddress, deployerAddress, ownerAddress, ' + + 'multiSigAddress, proxyAdminAddress, allowTokensAddress, federationAddress, erc777ConverterAddress, pauseAllowTokensAddress' + ); + } + + let gasPrice = await web3.eth.getGasPrice(); + const net = process.argv[5]; + console.log("net is:"+ net); + + if (net == "mainnet") { + gasPrice = 2*gasPrice; + } + + console.log(`Gas price is: ${gasPrice}`); + console.log(`Deployer is: ${deployerAddress}`); + console.log(`Owner is: ${ownerAddress}`); + console.log(`MultiSig address is: ${multiSigAddress}`); + console.log(`AllowTokens address is: ${allowTokensAddress}`); + console.log(`Pause Bridge with Unset AllowTkens is: ${pauseAllowTokensAddress}`) + console.log(`Federation address is: ${federationAddress}`); + console.log('Bridge proxy is:', bridgeProxyAddress); + console.log('Proxy admin is:', proxyAdminAddress); + console.log('New bridge address is:', newBridgeAddress); + console.log('erc777Converter address is:', erc777ConverterAddress); + + const multiSig = new web3.eth.Contract(multisigAbi, multiSigAddress); + const allowTokens = new web3.eth.Contract(allowTokensAbi, allowTokensAddress); + const pauseAllowTokens = new web3.eth.Contract(allowTokensAbi, pauseAllowTokensAddress); + const federation = new web3.eth.Contract(federationAbi, federationAddress); + const erc777Converter = new web3.eth.Contract(erc777ConverterAbi, erc777ConverterAddress); + const bridgeProxy = new web3.eth.Contract(bridgeAbi, bridgeProxyAddress); + const proxyAdmin = new web3.eth.Contract(proxyAdminAbi, proxyAdminAddress); + + console.log('Owner is multisig owner?', await multiSig.methods.isOwner(ownerAddress).call()); + console.log('Bridge owner:', await bridgeProxy.methods.owner().call()); + console.log('Current Bridge implementation:', await proxyAdmin.methods.getProxyImplementation(bridgeProxyAddress).call()); + console.log('Bridge proxy admin:', await proxyAdmin.methods.getProxyAdmin(bridgeProxyAddress).call()); + + const startUpgradeData = bridgeProxy.methods.startUpgrade().encodeABI(); + const pauseAllowTokensData = bridgeProxy.methods.changeAllowTokens(pauseAllowTokensAddress).encodeABI(); + const pauseData = bridgeProxy.methods.pause().encodeABI(); + const changeFederationData = bridgeProxy.methods.changeFederation(federationAddress).encodeABI(); + const changeAllowTokensData = bridgeProxy.methods.changeAllowTokens(allowTokensAddress).encodeABI(); + //const setBridgeFederationData = federation.methods.setBridge(bridgeProxyAddress).encodeABI(); + const setErc777ConverterData = bridgeProxy.methods.setErc777Converter(erc777ConverterAddress).encodeABI(); + //const setBridgeErc777ConverterData = erc777Converter.methods.setBridgeContract(bridgeProxyAddress).encodeABI(); + const unPauseData = bridgeProxy.methods.unpause().encodeABI(); + const upgradeData = proxyAdmin.methods.upgrade(bridgeProxyAddress, newBridgeAddress).encodeABI(); + const endUpgradeData = bridgeProxy.methods.endUpgrade().encodeABI(); + const unpauseAllowTokensData = bridgeProxy.methods.changeAllowTokens(allowTokensAddress).encodeABI(); + + const txXpts = { from: deployerAddress, gas: 300000, gasPrice: gasPrice }; + const txOpts = { from: ownerAddress, gas: 300000, gasPrice: gasPrice }; +/////////////////// +// Upgrade Stages +/////////////////// + +// Non multiSig calls +///////////////////// + +// Stage 0 +// Should be executed only after former federation state was copied with storeFederationState.js + +// //Set bridge address on federation +// //0.1 +// console.log('set Bridge address on Federation') +// const setBridgeFederationResult = await federation.methods.setBridge(bridgeProxyAddress).send( +// txXpts +// // { +// // from: deployerAddress, +// // } +// ); +// console.log('Result:', setBridgeFederationResult); +// // Finish initStage on federation +// // 0.2 +// console.log('Finish initStage on federation') +// const finishInitStageFederationResult = await federation.methods.endDeploymentSetup().send( +// txXpts +// // { +// // from: deployerAddress, +// // } +// ); +// console.log('Result:', finishInitStageFederationResult); +// //Transfer federation ownership to multisig +// //0.3 +// console.log('Transfer federation ownership to multisig') +// const transferFederationToMultiSigResult = await federation.methods.transferOwnership(multiSigAddress).send( +// txXpts +// // { +// // from: deployerAddress, +// // } +// ); +// console.log('Result:', transferFederationToMultiSigResult); + +// //Set bridge address on erc777Converter +// //0.4 +// console.log('set Bridge address on erc777Converter') +// const setBridgeErc777ConverterResult = await erc777Converter.methods.setBridgeContract(bridgeProxyAddress).send( +// txXpts +// // { +// // from: deployerAddress, +// // } +// ); +// console.log('Result:', setBridgeErc777ConverterResult); + +// //Transfer erc777Converter ownership to multisig +// //0.5 +// console.log('Transfer erc777Converter ownership to multisig') +// const transferERC777ConverterToMultiSigResult = await erc777Converter.methods.transferOwnership(multiSigAddress).send( +// txXpts +// // { +// // from: deployerAddress, +// // } +// ); +// console.log('Result:', transferERC777ConverterToMultiSigResult); + +//Transfer allowTokens ownership to multisig +//0.6 + console.log('Transfer allowTokens ownership to multisig') + const transerAllowTokensToMultiSigResult = await allowTokens.methods.transferOwnership(multiSigAddress).send( + txXpts + // { + // from: deployerAddress, + // } + ); + console.log('Result:', transerAllowTokensToMultiSigResult); + +// MultiSig calls +///////////////////// + +// Stage A +// Should be executed for both main-chain and side-chain +// StartUpgrade +// set AllowTokens (only for upgrading v3 to v4, starting from v4 we don't need pauseAllowTokensData step) + +//1 + // console.log('Calling startUpgrade with multisig') + // console.log(startUpgradeData) + // const startUpgradeResult = await multiSig.methods.submitTransaction(bridgeProxyAddress, 0, startUpgradeData).send(txOpts); + // console.log('Result:', startUpgradeResult); +// //2 +// if( netType== "mainnet" || netType== "ropsten" ) { +// console.log('Pause the bridge Calling changeAllowTokens with multisig') +// console.log(pauseAllowTokensData) +// const pauseAllowtokensResult = await multiSig.methods.submitTransaction(bridgeProxyAddress, 0, pauseAllowTokensData).send(txOpts); +// console.log('Result:', pauseAllowtokensResult); +// } + +// Stage B +// Should be executed for both main-chain and side-chain +// After 40 minutes, after all blocks till the stageA execution block were processed + +//3 +// PauseBridge - to disable _acceptTransfer + // console.log('Calling pause with multisig') + // console.log(pauseData) + // const pauseResult = await multiSig.methods.submitTransaction(bridgeProxyAddress, 0, pauseData).send(txOpts); + // console.log('Result:', pauseResult); + +// Stage C +// Should be executed for both main-chain and side-chain +// Upgrade brigde +// Change federation address on the Bridge +// Set erc777Converter address on the Bridge + +//4 + // console.log('Calling upgrade with multisig') + // console.log(upgradeData); + // const upgradeResult = await multiSig.methods.submitTransaction(proxyAdminAddress, 0, upgradeData).send(txOpts); + // console.log('Result:', upgradeResult); +// //5 +// console.log('change Federation address on the bridge') +// console.log(changeFederationData); +// const changeFedAddressResult = await multiSig.methods.submitTransaction(bridgeProxyAddress, 0, changeFederationData).send(txOpts); +// console.log('Result:', changeFedAddressResult); +// //6 +// console.log('set erc777Converter address on the bridge') +// console.log(setErc777ConverterData); +// const setErc777ConverterResult = await multiSig.methods.submitTransaction(bridgeProxyAddress, 0, setErc777ConverterData).send(txOpts); +// console.log('Result:', setErc777ConverterResult); + +// //7 + console.log('change AllowTokens address on the bridge') + console.log(changeAllowTokensData); + const changeAllowTokensAddressResult = await multiSig.methods.submitTransaction(bridgeProxyAddress, 0, changeAllowTokensData).send(txOpts); + console.log('Result:', changeAllowTokensAddressResult); + +// Stage D +// Should be executed for both main-chain and side-chain +// EndUpgrade +// Set original AllowTokens (only for upgrading v3 to v4, starting from v4 we don't need this set AlloTokens) +// UnPause + +//7 + // console.log('Calling endUpgrade with multisig') + // console.log(endUpgradeData); + // const endUpgradeResult = await multiSig.methods.submitTransaction(bridgeProxyAddress, 0, endUpgradeData).send(txOpts); + // console.log('Result:', endUpgradeResult); +// //8 +// if( netType== "mainnet" || netType== "ropsten" ) { +// console.log('UnPause the bridge Calling changeAllowTokens with multisig') +// console.log(unpauseAllowTokensData); +// const unpauseAllowtokensResult = await multiSig.methods.submitTransaction(bridgeProxyAddress, 0, unpauseAllowTokensData).send(txOpts); +// console.log('Result:', unpauseAllowtokensResult); +// } +//9 + // console.log('Calling unpause with multisig') + // console.log(unPauseData); + // const unPauseResult = await multiSig.methods.submitTransaction(bridgeProxyAddress, 0, unPauseData).send(txOpts); + // console.log('Result:', unPauseResult); + + console.log('All done.') +} \ No newline at end of file diff --git a/sovryn-token-bridge/bridge/test/AllowTokens_test.js b/sovryn-token-bridge/bridge/test/AllowTokens_test.js index 1fbbfdda..bcbfa420 100644 --- a/sovryn-token-bridge/bridge/test/AllowTokens_test.js +++ b/sovryn-token-bridge/bridge/test/AllowTokens_test.js @@ -226,7 +226,64 @@ contract('AllowTokens', async function (accounts) { utils.expectThrow(this.allowTokens.setFeeAndMinPerToken(this.token.address, 0, web3.utils.toWei('1'), { from: manager })); }); + it('fail if (maxPerToken > 0 ) & (minAmount > maxPerToken)', async function() { + let newMax = web3.utils.toWei('2'); + let newFee = web3.utils.toWei('3') + let newMin = web3.utils.toWei('3'); + await this.allowTokens.setMaxPerToken(this.token.address, newMax, { from: manager }); + utils.expectThrow(this.allowTokens.setFeeAndMinPerToken(this.token.address, newFee, newMin), { from: manager }); + + await this.allowTokens.setMaxPerToken(this.token.address, 0, { from: manager }); + await this.allowTokens.setFeeAndMinPerToken(this.token.address, newFee, newMin, { from: manager }); + + let feeToken = await this.allowTokens.getFeePerToken(this.token.address); + let minToken = await this.allowTokens.getMinPerToken(this.token.address); + + assert.equal(newFee.toString(), feeToken.toString()); + assert.equal(newMin.toString(), minToken.toString()); + }); + }); + + describe('Max Per token', async function() { + + it ('sets a new amount of max per token', async function() { + let newMax = web3.utils.toWei('2'); + await this.allowTokens.setMaxPerToken(this.token.address, newMax, { from: manager }); + + let maxToken = await this.allowTokens.getMaxPerToken(this.token.address); + + assert.equal(newMax.toString(), maxToken.toString()); + }); + + it('fail if not the owner', async function() { + let newMax = web3.utils.toWei('2'); + await this.allowTokens.setMaxPerToken(this.token.address, newMax, { from: manager }); + + let maxToken = await this.allowTokens.getMaxPerToken(this.token.address); + + assert.equal(newMax.toString(), maxToken.toString()); + + let newMax1 = web3.utils.toWei('5'); + + utils.expectThrow(this.allowTokens.setFeeAndMinPerToken(this.token.address, newMax1, { from: tokenDeployer })); + + minToken = await this.allowTokens.getMaxPerToken(this.token.address); + + assert.equal(newMax.toString(), maxToken.toString()); + }); + + it('fail if maxPerToken is bigger than maxTokensAllowed', async function() { + await this.allowTokens.setMaxTokensAllowed(web3.utils.toWei('10'), { from: manager }); + utils.expectThrow(this.allowTokens.setMaxPerToken(this.token.address, web3.utils.toWei('11'), { from: manager })); + }); + + it('fail if maxPerToken is smaller than min', async function() { + let newFee = web3.utils.toWei('2'); + let newMin = web3.utils.toWei('3'); + await this.allowTokens.setFeeAndMinPerToken(this.token.address, newFee, newMin, { from: manager }); + utils.expectThrow(this.allowTokens.setMaxPerToken(this.token.address, web3.utils.toWei('2'), { from: manager })); + }); }); describe('Max Daily Limit tokens', async function() { @@ -360,8 +417,23 @@ contract('AllowTokens', async function (accounts) { assert.equal(result, true); }); + it('should check if amount is smaller or equal to maxPerToken only if maxPerToken is set', async function() { + let newMax = web3.utils.toWei('2'); + + await this.allowTokens.setFeeAndMinPerToken(this.token.address, web3.utils.toWei('0.5'), web3.utils.toWei('0.5'),{ from: manager }) ; + result = await this.allowTokens.isValidTokenTransfer(this.token.address, web3.utils.toWei('3'), 0, true); + assert.equal(result, true); + await this.allowTokens.setMaxPerToken(this.token.address, newMax ,{ from: manager }); + result = await this.allowTokens.isValidTokenTransfer(this.token.address, web3.utils.toWei('3'), 0, true); + assert.equal(result, false); + result = await this.allowTokens.isValidTokenTransfer(this.token.address, web3.utils.toWei('1') , 0, true); + assert.equal(result, true); + + result = await this.allowTokens.isValidTokenTransfer(this.token.address, web3.utils.toWei('2'), 0, true); + assert.equal(result, true); + }); }); describe('Calls from MultiSig', async function() { diff --git a/sovryn-token-bridge/bridge/test/Bridge_test.js b/sovryn-token-bridge/bridge/test/Bridge_test.js index a84d5fd5..d2638fd7 100644 --- a/sovryn-token-bridge/bridge/test/Bridge_test.js +++ b/sovryn-token-bridge/bridge/test/Bridge_test.js @@ -5,7 +5,7 @@ const truffleAssert = require('truffle-assertions'); ZWeb3.initialize(web3.currentProvider); //Upgradable Contracts -const Bridge_v1 = Contracts.getFromLocal('Bridge_v1'); +const Bridge_v0 = Contracts.getFromLocal('Bridge_v0'); const Bridge = Contracts.getFromLocal('Bridge'); const BridgeArtifact = artifacts.require('./Bridge'); @@ -53,10 +53,10 @@ contract('Bridge', async function (accounts) { this.utilsContract = await UtilsContract.deployed(); this.project = await TestHelper(); - Bridge_v1.link({ "Utils": this.utilsContract.address }); + Bridge_v0.link({ "Utils": this.utilsContract.address }); Bridge.link({ "Utils": this.utilsContract.address }); - const proxy = await this.project.createProxy(Bridge_v1, { + const proxy = await this.project.createProxy(Bridge_v0, { initMethod: 'initialize', initArgs: [bridgeManager, federation, this.allowTokens.address, this.sideTokenFactory.address, 'e'] }); @@ -1594,7 +1594,7 @@ contract('Bridge', async function (accounts) { this.mirrorSideTokenFactory = await SideTokenFactory.new(); this.mirrormockERC20Receiver= await mockERC20Receiver.new(); - const proxy = await this.project.createProxy(Bridge_v1, { + const proxy = await this.project.createProxy(Bridge_v0, { initMethod: 'initialize', initArgs: [bridgeManager, federation, this.mirrorAllowTokens.address, this.mirrorSideTokenFactory.address, 'r'] }); @@ -2480,7 +2480,7 @@ contract('Bridge', async function (accounts) { // this.mirrorSideTokenFactory = await SideTokenFactory.new(); -// const proxy = await this.project.createProxy(Bridge_v1, { +// const proxy = await this.project.createProxy(Bridge_v0, { // initMethod: 'initialize', // initArgs: [this.multiSig.address, this.mirrorFed.address, this.mirrorAllowTokens.address, this.mirrorSideTokenFactory.address, 'r'] // }); @@ -2490,7 +2490,7 @@ contract('Bridge', async function (accounts) { // await this.mirrorSideTokenFactory.transferPrimary(this.mirrorBridge.address); -// // this.mirrorBridge = await Bridge_v1.new(); +// // this.mirrorBridge = await Bridge_v0.new(); // this.decimals = "18"; // // let data = this.mirrorBridge.methods['initialize(address,address,address,address,string)']( diff --git a/sovryn-token-bridge/bridge/test/Federation_test.js b/sovryn-token-bridge/bridge/test/Federation_test.js index 53d40ff2..7e3b6eca 100644 --- a/sovryn-token-bridge/bridge/test/Federation_test.js +++ b/sovryn-token-bridge/bridge/test/Federation_test.js @@ -5,7 +5,7 @@ const abiDecoder = require('abi-decoder'); ZWeb3.initialize(web3.currentProvider); //Upgradable Contracts -const Bridge_v1 = Contracts.getFromLocal('Bridge_v1'); +const Bridge_v0 = Contracts.getFromLocal('Bridge_v0'); const Bridge = Contracts.getFromLocal('Bridge'); const Federation = artifacts.require('./Federation'); @@ -285,9 +285,9 @@ contract('Federation', async function (accounts) { this.utilsContract = await UtilsContract.deployed(); this.project = await TestHelper(); - Bridge_v1.link({ "Utils": this.utilsContract.address }); + Bridge_v0.link({ "Utils": this.utilsContract.address }); Bridge.link({ "Utils": this.utilsContract.address }); - this.proxy = await this.project.createProxy(Bridge_v1, + this.proxy = await this.project.createProxy(Bridge_v0, { initMethod: 'initialize', initArgs: [deployer, this.federation.address, this.allowTokens.address, this.sideTokenFactory.address, 'e'] }); this.proxy = await this.project.upgradeProxy(this.proxy.address, Bridge); this.bridge = await BridgeArtifact.at(this.proxy.address); @@ -404,9 +404,9 @@ contract('Federation', async function (accounts) { this.utilsContract = await UtilsContract.deployed(); this.project = await TestHelper(); - Bridge_v1.link({ "Utils": this.utilsContract.address }); + Bridge_v0.link({ "Utils": this.utilsContract.address }); Bridge.link({ "Utils": this.utilsContract.address }); - this.proxy = await this.project.createProxy(Bridge_v1, + this.proxy = await this.project.createProxy(Bridge_v0, { initMethod: 'initialize', initArgs: [deployer, this.federation.address, this.allowTokens.address, this.sideTokenFactory.address, 'e'] }); this.proxy = await this.project.upgradeProxy(this.proxy.address, Bridge); this.bridge = await BridgeArtifact.at(this.proxy.address); diff --git a/sovryn-token-bridge/bridge/truffle-config.js b/sovryn-token-bridge/bridge/truffle-config.js index ad4d80e2..7df293d6 100644 --- a/sovryn-token-bridge/bridge/truffle-config.js +++ b/sovryn-token-bridge/bridge/truffle-config.js @@ -102,8 +102,8 @@ module.exports = { network_id: 1, networkCheckTimeout: 1e9, timeoutBlocks: 500000, - gas: 6700000, - gasPrice: 50000000000, //50 GWei + gas: 1400000, + gasPrice: 30000000000, //50 GWei skipDryRun: true }, //Binance @@ -119,7 +119,7 @@ module.exports = { bmainnet: { //provider: () => new HDWalletProvider(secrets.seed, `https://bsc-dataseed1.binance.org`), //provider: () => new HDWalletProvider(secrets.seed, `https://bsc-dataseed1.defibit.io/`), - provider: () => new HDWalletProvider(secrets.seed, `https://bsc-dataseed.binance.org/`), + provider: () => new HDWalletProvider(secrets.seed, `http://bscmainnet1.sovryn.app:8545/`), network_id: 56, gas: 6300000, confirmations: 6,