From 8d8e75b672e5b18599ad5adf4af1b45323e922b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Treer=20Zolt=C3=A1n?= Date: Mon, 20 May 2019 17:57:08 +0200 Subject: [PATCH 1/5] script: migrate ETH from old reserve to new reserve --- .../SB_scripts/mainnet/Main0027_migrate.sol | 28 +++++++++++++++++++ .../39_deploy_Main0027_migrate.js | 7 +++++ 2 files changed, 35 insertions(+) create mode 100644 contracts/SB_scripts/mainnet/Main0027_migrate.sol create mode 100644 mainnet_migrations/39_deploy_Main0027_migrate.js diff --git a/contracts/SB_scripts/mainnet/Main0027_migrate.sol b/contracts/SB_scripts/mainnet/Main0027_migrate.sol new file mode 100644 index 00000000..bcabc957 --- /dev/null +++ b/contracts/SB_scripts/mainnet/Main0027_migrate.sol @@ -0,0 +1,28 @@ +/* Migrate stuff */ + +pragma solidity 0.4.24; + +import "../../StabilityBoardProxy.sol"; +import "../../TokenAEur.sol"; +import "../../AugmintReserves.sol"; +import "../../generic/SystemAccount.sol"; + +contract Main0027_migrate { + + StabilityBoardProxy public constant STABILITY_BOARD_PROXY = StabilityBoardProxy(0xde36a8773531406dCBefFdfd3C7b89fCed7A9F84); + + TokenAEur public constant OLD_TOKEN_AEUR = TokenAEur(0x86A635EccEFFfA70Ff8A6DB29DA9C8DB288E40D0); + TokenAEur public constant NEW_TOKEN_AEUR = TokenAEur(0xc994a2dEb02543Db1f48688438b9903c4b305ce3); + + SystemAccount public constant OLD_AUGMINT_RESERVES = SystemAccount(0x633cb544b2EF1bd9269B2111fD2B66fC05cd3477); + AugmintReserves public constant NEW_AUGMINT_RESERVES = AugmintReserves(0x65F30f8DD20c707C1938CcAd7416c7381E6eB9C8); + + function execute(Main0027_migrate /* self, not used */) external { + // called via StabilityBoardProxy + require(address(this) == address(STABILITY_BOARD_PROXY), "only execute via StabilityBoardProxy"); + + // migrate ETH to new reserve + // function withdraw(AugmintToken tokenAddress, address to, uint tokenAmount, uint weiAmount, string narrative) + OLD_AUGMINT_RESERVES.withdraw(NEW_TOKEN_AEUR, address(NEW_AUGMINT_RESERVES), 0, address(OLD_AUGMINT_RESERVES).balance, "migration"); + } +} \ No newline at end of file diff --git a/mainnet_migrations/39_deploy_Main0027_migrate.js b/mainnet_migrations/39_deploy_Main0027_migrate.js new file mode 100644 index 00000000..213adf5e --- /dev/null +++ b/mainnet_migrations/39_deploy_Main0027_migrate.js @@ -0,0 +1,7 @@ +const Main0027 = artifacts.require("./Main0027_migrate.sol"); + +module.exports = function(deployer) { + deployer.then(async () => { + await deployer.deploy(Main0027); + }); +}; \ No newline at end of file From b24ae03e4640b2705cc568496697df6acc32aa59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Treer=20Zolt=C3=A1n?= Date: Tue, 21 May 2019 13:00:40 +0200 Subject: [PATCH 2/5] migrate old tokens from new interestearnedaccount --- .../SB_scripts/mainnet/Main0027_migrate.sol | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/contracts/SB_scripts/mainnet/Main0027_migrate.sol b/contracts/SB_scripts/mainnet/Main0027_migrate.sol index bcabc957..f7145256 100644 --- a/contracts/SB_scripts/mainnet/Main0027_migrate.sol +++ b/contracts/SB_scripts/mainnet/Main0027_migrate.sol @@ -5,6 +5,8 @@ pragma solidity 0.4.24; import "../../StabilityBoardProxy.sol"; import "../../TokenAEur.sol"; import "../../AugmintReserves.sol"; +import "../../InterestEarnedAccount.sol"; +import "../../FeeAccount.sol"; import "../../generic/SystemAccount.sol"; contract Main0027_migrate { @@ -17,6 +19,14 @@ contract Main0027_migrate { SystemAccount public constant OLD_AUGMINT_RESERVES = SystemAccount(0x633cb544b2EF1bd9269B2111fD2B66fC05cd3477); AugmintReserves public constant NEW_AUGMINT_RESERVES = AugmintReserves(0x65F30f8DD20c707C1938CcAd7416c7381E6eB9C8); + InterestEarnedAccount public constant OLD_INTEREST_EARNED_ACCOUNT = InterestEarnedAccount(0x5C1a44E07541203474D92BDD03f803ea74f6947c); + InterestEarnedAccount public constant NEW_INTEREST_EARNED_ACCOUNT = InterestEarnedAccount(0xf23e0AF0e41341127Bb4e7b203aebCA0185f9EbD); + + FeeAccount public constant OLD_FEE_ACCOUNT = FeeAccount(0xF6B541E1B5e001DCc11827C1A16232759aeA730a); + FeeAccount public constant NEW_FEE_ACCOUNT = FeeAccount(0xE3ED84A163b9EeaF4f69B4890ae45cC52171Aa7E); + + address public constant ADDRESS = 0xd97500098672F2636902E41D3928706C27470DF7; + function execute(Main0027_migrate /* self, not used */) external { // called via StabilityBoardProxy require(address(this) == address(STABILITY_BOARD_PROXY), "only execute via StabilityBoardProxy"); @@ -24,5 +34,15 @@ contract Main0027_migrate { // migrate ETH to new reserve // function withdraw(AugmintToken tokenAddress, address to, uint tokenAmount, uint weiAmount, string narrative) OLD_AUGMINT_RESERVES.withdraw(NEW_TOKEN_AEUR, address(NEW_AUGMINT_RESERVES), 0, address(OLD_AUGMINT_RESERVES).balance, "migration"); + + // migrate old token from new interestearnedaccount + OLD_TOKEN_AEUR.grantPermission(STABILITY_BOARD_PROXY, "MonetarySupervisor"); + OLD_FEE_ACCOUNT.grantPermission(NEW_INTEREST_EARNED_ACCOUNT, "NoTransferFee"); + + // function transferInterest(AugmintTokenInterface augmintToken, address locker, uint interestAmount) + NEW_INTEREST_EARNED_ACCOUNT.transferInterest(OLD_TOKEN_AEUR, ADDRESS, OLD_TOKEN_AEUR.balanceOf(NEW_INTEREST_EARNED_ACCOUNT)); + + OLD_FEE_ACCOUNT.revokePermission(NEW_INTEREST_EARNED_ACCOUNT, "NoTransferFee"); + OLD_TOKEN_AEUR.revokePermission(STABILITY_BOARD_PROXY, "MonetarySupervisor"); } } \ No newline at end of file From 59babc6806aeb9d77aee257310488ae367f96af1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Treer=20Zolt=C3=A1n?= Date: Tue, 21 May 2019 13:25:56 +0200 Subject: [PATCH 3/5] convert old tokens in sb proxy and transfer the new tokens back --- .../SB_scripts/mainnet/Main0027_migrate.sol | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/contracts/SB_scripts/mainnet/Main0027_migrate.sol b/contracts/SB_scripts/mainnet/Main0027_migrate.sol index f7145256..534e1376 100644 --- a/contracts/SB_scripts/mainnet/Main0027_migrate.sol +++ b/contracts/SB_scripts/mainnet/Main0027_migrate.sol @@ -7,6 +7,7 @@ import "../../TokenAEur.sol"; import "../../AugmintReserves.sol"; import "../../InterestEarnedAccount.sol"; import "../../FeeAccount.sol"; +import "../../MonetarySupervisor.sol"; import "../../generic/SystemAccount.sol"; contract Main0027_migrate { @@ -25,22 +26,34 @@ contract Main0027_migrate { FeeAccount public constant OLD_FEE_ACCOUNT = FeeAccount(0xF6B541E1B5e001DCc11827C1A16232759aeA730a); FeeAccount public constant NEW_FEE_ACCOUNT = FeeAccount(0xE3ED84A163b9EeaF4f69B4890ae45cC52171Aa7E); - address public constant ADDRESS = 0xd97500098672F2636902E41D3928706C27470DF7; + MonetarySupervisor public constant OLD_MONETARY_SUPERVISOR = MonetarySupervisor(0x1Ca4F9d261707aF8A856020a4909B777da218868); + MonetarySupervisor public constant NEW_MONETARY_SUPERVISOR = MonetarySupervisor(0x27484AFe9e6c332fB07F21Fac82d442EBe1D22c3); function execute(Main0027_migrate /* self, not used */) external { // called via StabilityBoardProxy require(address(this) == address(STABILITY_BOARD_PROXY), "only execute via StabilityBoardProxy"); + // =========================== // migrate ETH to new reserve + // =========================== + // function withdraw(AugmintToken tokenAddress, address to, uint tokenAmount, uint weiAmount, string narrative) OLD_AUGMINT_RESERVES.withdraw(NEW_TOKEN_AEUR, address(NEW_AUGMINT_RESERVES), 0, address(OLD_AUGMINT_RESERVES).balance, "migration"); - // migrate old token from new interestearnedaccount + // ================================================== + // convert old tokens in new interestearnedaccount + // ================================================== + OLD_TOKEN_AEUR.grantPermission(STABILITY_BOARD_PROXY, "MonetarySupervisor"); OLD_FEE_ACCOUNT.grantPermission(NEW_INTEREST_EARNED_ACCOUNT, "NoTransferFee"); + uint amount = OLD_TOKEN_AEUR.balanceOf(NEW_INTEREST_EARNED_ACCOUNT); // function transferInterest(AugmintTokenInterface augmintToken, address locker, uint interestAmount) - NEW_INTEREST_EARNED_ACCOUNT.transferInterest(OLD_TOKEN_AEUR, ADDRESS, OLD_TOKEN_AEUR.balanceOf(NEW_INTEREST_EARNED_ACCOUNT)); + NEW_INTEREST_EARNED_ACCOUNT.transferInterest(OLD_TOKEN_AEUR, STABILITY_BOARD_PROXY, amount); + //function transferAndNotify(TokenReceiver target, uint amount, uint data) external { + OLD_TOKEN_AEUR.transferAndNotify(NEW_MONETARY_SUPERVISOR, amount, 0); + // function transfer(address to, uint256 amount) external returns (bool) { + NEW_TOKEN_AEUR.transfer(NEW_INTEREST_EARNED_ACCOUNT, amount); OLD_FEE_ACCOUNT.revokePermission(NEW_INTEREST_EARNED_ACCOUNT, "NoTransferFee"); OLD_TOKEN_AEUR.revokePermission(STABILITY_BOARD_PROXY, "MonetarySupervisor"); From 3137a1093b78957629af966abc820f39e7999d65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Treer=20Zolt=C3=A1n?= Date: Tue, 21 May 2019 16:23:18 +0200 Subject: [PATCH 4/5] otc buyback script --- .../mainnet/Main0028_OtcBuyback.sol | 32 +++++++++++++++++++ .../40_deploy_Main0028_OtcBuyback.js | 7 ++++ 2 files changed, 39 insertions(+) create mode 100644 contracts/SB_scripts/mainnet/Main0028_OtcBuyback.sol create mode 100644 mainnet_migrations/40_deploy_Main0028_OtcBuyback.js diff --git a/contracts/SB_scripts/mainnet/Main0028_OtcBuyback.sol b/contracts/SB_scripts/mainnet/Main0028_OtcBuyback.sol new file mode 100644 index 00000000..d7bcee0a --- /dev/null +++ b/contracts/SB_scripts/mainnet/Main0028_OtcBuyback.sol @@ -0,0 +1,32 @@ +/* OTC A-EUR buyback using Reserve ETH. Defaulted loans of 2002 A-EUR + monetary board issued of 352.69 A-EUR. */ + +pragma solidity 0.4.24; + +import "../../StabilityBoardProxy.sol"; +import "../../TokenAEur.sol"; +import "../../AugmintReserves.sol"; +import "../../Rates.sol"; + +contract Main0028_OtcBuyback { + + StabilityBoardProxy public constant STABILITY_BOARD_PROXY = StabilityBoardProxy(0xde36a8773531406dCBefFdfd3C7b89fCed7A9F84); + + TokenAEur public constant NEW_TOKEN_AEUR = TokenAEur(0xc994a2dEb02543Db1f48688438b9903c4b305ce3); + AugmintReserves public constant NEW_AUGMINT_RESERVES = AugmintReserves(0x65F30f8DD20c707C1938CcAd7416c7381E6eB9C8); + Rates public constant RATES = Rates(0x4272dB2EB82068E898588C3D6e4B5D55c3848793); + + address public constant T8_ADDRESS = 0x7C8bc54446C55E3A10F5F1467D30b0Fd8b9d3e9A; + + uint public constant tokenAmount = 235469; + + function execute(Main0028_OtcBuyback /* self, not used */) external { + // called via StabilityBoardProxy + require(address(this) == address(STABILITY_BOARD_PROXY), "only execute via StabilityBoardProxy"); + + // function convertToWei(bytes32 bSymbol, uint value) external view returns(uint weiValue) { + uint weiAmount = RATES.convertToWei(NEW_TOKEN_AEUR.peggedSymbol(), tokenAmount); + + // function migrate(address to, uint weiAmount) + NEW_AUGMINT_RESERVES.migrate(T8_ADDRESS, weiAmount); + } +} \ No newline at end of file diff --git a/mainnet_migrations/40_deploy_Main0028_OtcBuyback.js b/mainnet_migrations/40_deploy_Main0028_OtcBuyback.js new file mode 100644 index 00000000..a03ecb00 --- /dev/null +++ b/mainnet_migrations/40_deploy_Main0028_OtcBuyback.js @@ -0,0 +1,7 @@ +const Main0028_OtcBuyback = artifacts.require("./Main0028_OtcBuyback.sol"); + +module.exports = function(deployer) { + deployer.then(async () => { + await deployer.deploy(Main0028_OtcBuyback); + }); +}; \ No newline at end of file From b2cd022879904ceef99b4503fd3bef6c2d02e886 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Treer=20Zolt=C3=A1n?= Date: Tue, 21 May 2019 17:02:40 +0200 Subject: [PATCH 5/5] fix: use withdraw instead of transferInterest --- contracts/SB_scripts/mainnet/Main0027_migrate.sol | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/contracts/SB_scripts/mainnet/Main0027_migrate.sol b/contracts/SB_scripts/mainnet/Main0027_migrate.sol index 534e1376..28db8392 100644 --- a/contracts/SB_scripts/mainnet/Main0027_migrate.sol +++ b/contracts/SB_scripts/mainnet/Main0027_migrate.sol @@ -44,18 +44,19 @@ contract Main0027_migrate { // convert old tokens in new interestearnedaccount // ================================================== - OLD_TOKEN_AEUR.grantPermission(STABILITY_BOARD_PROXY, "MonetarySupervisor"); OLD_FEE_ACCOUNT.grantPermission(NEW_INTEREST_EARNED_ACCOUNT, "NoTransferFee"); uint amount = OLD_TOKEN_AEUR.balanceOf(NEW_INTEREST_EARNED_ACCOUNT); - // function transferInterest(AugmintTokenInterface augmintToken, address locker, uint interestAmount) - NEW_INTEREST_EARNED_ACCOUNT.transferInterest(OLD_TOKEN_AEUR, STABILITY_BOARD_PROXY, amount); + + // function withdraw(AugmintToken tokenAddress, address to, uint tokenAmount, uint weiAmount, string narrative) + NEW_INTEREST_EARNED_ACCOUNT.withdraw(OLD_TOKEN_AEUR, STABILITY_BOARD_PROXY, amount, 0, "migrate"); + //function transferAndNotify(TokenReceiver target, uint amount, uint data) external { OLD_TOKEN_AEUR.transferAndNotify(NEW_MONETARY_SUPERVISOR, amount, 0); + // function transfer(address to, uint256 amount) external returns (bool) { NEW_TOKEN_AEUR.transfer(NEW_INTEREST_EARNED_ACCOUNT, amount); OLD_FEE_ACCOUNT.revokePermission(NEW_INTEREST_EARNED_ACCOUNT, "NoTransferFee"); - OLD_TOKEN_AEUR.revokePermission(STABILITY_BOARD_PROXY, "MonetarySupervisor"); } } \ No newline at end of file