Skip to content

Commit

Permalink
update scripts how they should have been ran
Browse files Browse the repository at this point in the history
  • Loading branch information
szerintedmi committed May 12, 2018
1 parent 3620d07 commit b5f6106
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 32 deletions.
34 changes: 2 additions & 32 deletions rinkeby_migrations/17_new_TokenAEur.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ module.exports = function(deployer, network, accounts) {
const feeAccount = FeeAccount.at("0xc26667132b0B798ab87864f7c29c0819c887aADB");
const augmintReserves = AugmintReserves.at("0xc70b65e40f877cdC6d8D2ebFd44d63EfBeb7fc6D");
const interestEarnedAccount = InterestEarnedAccount.at("0x3a414d7636defb9d3dfb7342984fe3f7b5125df6");
const oldMonetarySupervisor = MonetarySupervisor.at("0xa00a5d1882C3F690E3d0D975ebE378120b70ae87");

const oldToken1 = TokenAEur.at("0x95aa79d7410eb60f49bfd570b445836d402bd7b1");
const oldToken2 = TokenAEur.at("0xa35d9de06895a3a2e7ecae26654b88fe71c179ea");
Expand Down Expand Up @@ -119,7 +118,7 @@ module.exports = function(deployer, network, accounts) {
Promise.all(grantMonetaryBoardTxs);

/*************************************************************
* Switch new MonetarySupervisor to live
* Grant permissions to new MonetarySupervisor
**************************************************************/
console.log(" granting permissions for new MS");
await Promise.all([
Expand All @@ -145,36 +144,7 @@ module.exports = function(deployer, network, accounts) {
feeAccount.grantPermission(oldToken3.address, "NoFeeTransferContracts")
]);

console.log(" switching new MS to live");
await Promise.all([
oldLocker1.setMonetarySupervisor(newMonetarySupervisor.address),
oldLoanManager1.setSystemContracts(ratesAddress, newMonetarySupervisor.address)
]);

// 3. migrate totals from previous MS (using MS.adjustKPIs)
const [oldTotalLoan, oldTotalLock] = await Promise.all([
oldMonetarySupervisor.totalLoanAmount(),
oldMonetarySupervisor.totalLockedAmount()
]);
console.log(
"Migrating KPIs to new MonetarySupervisor contract. totalLoanAmount:",
oldTotalLoan.toString(),
"totalLockedAmount",
oldTotalLock.toString()
);
await newMonetarySupervisor.adjustKPIs(oldTotalLoan, oldTotalLock);

console.log("Revoking permission from old MS");
await Promise.all([
feeAccount.revokePermission(oldMonetarySupervisor.address, "NoFeeTransferContracts"),
interestEarnedAccount.revokePermission(oldMonetarySupervisor.address, "MonetarySupervisorContract"),
oldToken3.revokePermission(oldMonetarySupervisor.address, "MonetarySupervisorContract"),
augmintReserves.revokePermission(oldMonetarySupervisor.address, "MonetarySupervisorContract"),

oldMonetarySupervisor.revokePermission(oldLocker1.address, "LockerContracts"),
oldMonetarySupervisor.revokePermission(oldLoanManager1.address, "LoanManagerContracts")
]);

// NB: don't forget to top up earned interest account with new tokens
console.log(" Done with all migration steps. Updating truffle Migrations step manually");
await Migrations.at("0xb96f7e79a6b3faf4162e274ff764ca9de598b0c5").setCompleted(17);
});
Expand Down
58 changes: 58 additions & 0 deletions rinkeby_migrations/18_set_new_MonetarySupervisor_live.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/* switch over to new MonetSupervisor version in legacy contracts */
const Migrations = artifacts.require("./Migrations.sol");
const TokenAEur = artifacts.require("./TokenAEur.sol");
const FeeAccount = artifacts.require("./FeeAccount.sol");
const MonetarySupervisor = artifacts.require("./MonetarySupervisor.sol");
const InterestEarnedAccount = artifacts.require("./InterestEarnedAccount.sol");
const AugmintReserves = artifacts.require("./AugmintReserves.sol");
const Locker = artifacts.require("./Locker.sol");
const LoanManager = artifacts.require("./LoanManager.sol");

module.exports = function(deployer, network, accounts) {
const ratesAddress = "0xcA8100FCcb479516A5b30f8Bc5dAeA09Fb7a7473";
const feeAccount = FeeAccount.at("0xc26667132b0B798ab87864f7c29c0819c887aADB");
const augmintReserves = AugmintReserves.at("0xc70b65e40f877cdC6d8D2ebFd44d63EfBeb7fc6D");
const interestEarnedAccount = InterestEarnedAccount.at("0x3a414d7636defb9d3dfb7342984fe3f7b5125df6");
const oldMonetarySupervisor = MonetarySupervisor.at("0xa00a5d1882C3F690E3d0D975ebE378120b70ae87");
const newMonetarySupervisor = MonetarySupervisor.at("0xC19a45F5CbfA93Be512ef07177feB3f7b3ae4518");

const oldToken3 = TokenAEur.at("0x135893F1A6B3037BB45182841f18F69327366992");

const oldLocker1 = Locker.at("0xf98AE1fb568B267A7632BF54579A153C892E2ec2");
const oldLoanManager1 = LoanManager.at("0xBdb02f82d7Ad574f9F549895caf41E23a8981b07");

deployer.then(async () => {
console.log(" switching new MS to live");
await Promise.all([
oldLocker1.setMonetarySupervisor(newMonetarySupervisor.address),
oldLoanManager1.setSystemContracts(ratesAddress, newMonetarySupervisor.address)
]);

// 3. migrate totals from previous MS (using MS.adjustKPIs)
const [oldTotalLoan, oldTotalLock] = await Promise.all([
oldMonetarySupervisor.totalLoanAmount(),
oldMonetarySupervisor.totalLockedAmount()
]);
console.log(
"Migrating KPIs to new MonetarySupervisor contract. totalLoanAmount:",
oldTotalLoan.toString(),
"totalLockedAmount",
oldTotalLock.toString()
);
await newMonetarySupervisor.adjustKPIs(oldTotalLoan, oldTotalLock);

console.log("Revoking permission from old MS");
await Promise.all([
feeAccount.revokePermission(oldMonetarySupervisor.address, "NoFeeTransferContracts"),
interestEarnedAccount.revokePermission(oldMonetarySupervisor.address, "MonetarySupervisorContract"),
oldToken3.revokePermission(oldMonetarySupervisor.address, "MonetarySupervisorContract"),
augmintReserves.revokePermission(oldMonetarySupervisor.address, "MonetarySupervisorContract"),

oldMonetarySupervisor.revokePermission(oldLocker1.address, "LockerContracts"),
oldMonetarySupervisor.revokePermission(oldLoanManager1.address, "LoanManagerContracts")
]);

console.log(" Done with all migration steps. Updating truffle Migrations step manually");
await Migrations.at("0xb96f7e79a6b3faf4162e274ff764ca9de598b0c5").setCompleted(18);
});
};

0 comments on commit b5f6106

Please sign in to comment.