Skip to content

Commit

Permalink
Merge pull request #66 from Augmint/token_migration
Browse files Browse the repository at this point in the history
legacy token addresses in migration scripts + conversion event
  • Loading branch information
Peter Petrovics committed Apr 3, 2018
2 parents aa4d678 + e38b6dd commit 15a15fb
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 5 deletions.
13 changes: 8 additions & 5 deletions contracts/MonetarySupervisor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ contract MonetarySupervisor is Restricted, TokenReceiver { // solhint-disable-li

event AcceptedLegacyAugmintTokenChanged(address augmintTokenAddress, bool newAcceptedState);

event LegacyTokenConverted(address oldTokenAddress, address account, uint amount);

function MonetarySupervisor(AugmintTokenInterface _augmintToken, AugmintReserves _augmintReserves,
InterestEarnedAccount _interestEarnedAccount,
uint _ltdDifferenceLimit, uint _allowedLtdDifferenceAmount) public {
Expand Down Expand Up @@ -117,11 +119,6 @@ contract MonetarySupervisor is Restricted, TokenReceiver { // solhint-disable-li
emit ParamsChanged(ltdDifferenceLimit, allowedLtdDifferenceAmount);
}

// helper function for FrontEnd to reduce calls
function getParams() external view returns(uint[2]) {
return [ltdDifferenceLimit, allowedLtdDifferenceAmount];
}

/* User can request to convert their tokens from older AugmintToken versions in 1:1
transferNotification is called from AugmintToken's transferAndNotify
Flow for converting old tokens:
Expand All @@ -139,6 +136,12 @@ contract MonetarySupervisor is Restricted, TokenReceiver { // solhint-disable-li

legacyToken.burn(amount);
augmintToken.issueTo(from, amount);
emit LegacyTokenConverted(msg.sender, from, amount);
}

// helper function for FrontEnd to reduce calls
function getParams() external view returns(uint[2]) {
return [ltdDifferenceLimit, allowedLtdDifferenceAmount];
}

}
35 changes: 35 additions & 0 deletions migrations/98_add_legacyTokens.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const FeeAccount = artifacts.require("./FeeAccount.sol");
const TokenAEur = artifacts.require("./TokenAEur.sol");
const MonetarySupervisor = artifacts.require("./MonetarySupervisor.sol");

module.exports = async function(deployer, network, accounts) {
const monetarySupervisor = MonetarySupervisor.at(MonetarySupervisor.address);

if (web3.version.network == 999) {
const oldToken = await TokenAEur.new(
FeeAccount.address,
2000, // transferFeePt in parts per million = 0.2%
2, // min: 0.02 A-EUR
500 // max fee: 5 A-EUR
);

await Promise.all([
oldToken.grantPermission(accounts[0], "MonetarySupervisorContract"), // "hack" for test to issue
oldToken.grantPermission(monetarySupervisor.address, "NoFeeTransferContracts"),
monetarySupervisor.setAcceptedLegacyAugmintToken(oldToken.address, true)
]);

await oldToken.issueTo(accounts[0], 20000); // issue some to account 0
console.log(
"On local ganache - deployed a mock legacy token contract for manual testing at " + oldToken.address
);
} else if (web3.version.network === 4) {
// on rinkeby
const oldToken = TokenAEur.at("0xa35d9de06895a3a2e7ecae26654b88fe71c179ea");
await monetarySupervisor.setAcceptedLegacyAugmintToken(oldToken.address, true);
await Promise.all([
oldToken.grantPermission(monetarySupervisor.address, "NoFeeTransferContracts"),
monetarySupervisor.setAcceptedLegacyAugmintToken(oldToken.address, true)
]);
}
};
5 changes: 5 additions & 0 deletions test/tokenConversion.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ contract("token conversion tests", accounts => {
from: "0x0000000000000000000000000000000000000000",
to: account,
amount: amount
}),
testHelpers.assertEvent(newMS, "LegacyTokenConverted", {
oldTokenAddress: augmintToken.address,
account,
amount
})
]);

Expand Down

0 comments on commit 15a15fb

Please sign in to comment.