Skip to content

Commit

Permalink
Merge pull request #69 from makerdao/develop
Browse files Browse the repository at this point in the history
dev -> master
  • Loading branch information
tyler17 committed May 11, 2022
2 parents 3ccb416 + 38c5dff commit 0ebf871
Show file tree
Hide file tree
Showing 24 changed files with 5,175 additions and 1,962 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Expand Up @@ -26,10 +26,10 @@ jobs:
keys:
- dependency-cache-{{ checksum "package.json" }}
- run:
name: Run tests
name: Run mcd tests with hardhat
command: |
source /home/circleci/setup-env.sh
yarn test --coverage
yarn test:mcd
npm i --no-save codecov
./node_modules/.bin/codecov
deploy_staging:
Expand Down
36 changes: 35 additions & 1 deletion README.md
@@ -1,4 +1,38 @@
# migrate-dashboard
Migration dashboard

The `develop` branch is auto-deployed to https://migration-dashboard-git-develop.mkr-js-prod.now.sh.
The migrate dashboard provides a user interface for these migrations in Emergency Shutdown:

- Redeem SCD Sai for underlying collateral
- Claim excess collateral in SCD CDP
- Redeem MCD Dai for underlying collateral
- Claim excess collateral in MCD Vault

The migration portal no longer supports the scd → mcd migrations that took advantage of the migration contract, since that contract has been decommissioned

In addition to Emergency Shutdown, the migration portal checks for:

- old MKR tokens that can be redeemed to the current MKR, and directs holders to [redeem.makerdao.com/](https://redeem.makerdao.com/)
- MKR locked in the old Chief, and directs holders to [chief-migration.makerdao.com/](https://chief-migration.makerdao.com/). Note that this is for the v1.0 chief, migration for the v1.1 chief is handled in the [governance portal](https://vote.makerdao.com/).

# testing

```
yarn test
```
or

```
yarn test:mcd //run the mcd dai and mcd vault tests
```

The mcd dai and mcd vault tests were updated to test against a fork of mainnet using hardhat (instead of the old local ganache testchain). For now, the other tests do not work.

The UI can also be used with the local testchain, with these steps:
(note: this needs to be updated to work with the recent hardhat changes)

- add the query string `testnet` to the url, e.g.`localhost:3000?testnet`

This comment has been minimized.

Copy link
@Ozkabgundogan

Ozkabgundogan May 15, 2022

Add single

- switch metamask to point to the testchain (should be localhost:2000)
- import the default account for the testchain to your metamask. Private key can be found [here](https://github.com/makerdao/testchain/issues/31#issuecomment-616816206)
- Get the testchain into the state you want it by running the relevant test until the point you want it to pause (see commented out setTimeouts in code). This is a bit hacky, and can probably be improved with snapshots.
- To test the scd cdp flow, you'll want to include `scdes` in the query string to tell dai.js to use mock data when getting the cdps. e.g. `localhost:3000?scdestestnet`
284 changes: 284 additions & 0 deletions addresses-goerli.json

Large diffs are not rendered by default.

298 changes: 298 additions & 0 deletions addresses-mainnet.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion components/redeemscdvaults/Confirmation.js
Expand Up @@ -77,7 +77,7 @@ export default ({

// re-fetch the ratio because it could have changed a tiny amount
freshRatio = BigNumber(
await maker.service('smartContract').getContract('SAI_TUB').per()
(await maker.service('smartContract').getContract('SAI_TUB').per())._hex
);
// avoid a revert due to dust check in tub.free by avoiding the
// default rounding behavior of the currency lib
Expand Down
10 changes: 10 additions & 0 deletions customSequencer.js
@@ -0,0 +1,10 @@
const TestSequencer = require('@jest/test-sequencer').default;

class CustomSequencer extends TestSequencer {
sort(tests) {
console.log('tests', tests);
return tests.sort((testA, testB) => testA.path.localeCompare(testB.path));
}
}

module.exports = CustomSequencer;
33 changes: 33 additions & 0 deletions hardhat.config.js
@@ -0,0 +1,33 @@
// @ts-nocheck

require('dotenv').config();

// You need to export an object to set up your config
// Go to https://hardhat.org/config/ to learn more
require('@nomiclabs/hardhat-ethers');


/**
* @type import('hardhat/config').HardhatUserConfig
*/
module.exports = {

networks: {
localhost: {
url: 'http://127.0.0.1:8545',
timeout: 2000000,
chainId: 31337,
},

//mainnet config
hardhat: {
forking: {
url: `https://eth-mainnet.alchemyapi.io/v2/${process.env.ALCHEMY_MAINNET_API_KEY}`,
blockNumber: 14732359,
chainId: 31338
},
timeout: 2000000
}
},

};
4 changes: 3 additions & 1 deletion jest.config.js
Expand Up @@ -11,5 +11,7 @@ module.exports = {
testPathIgnorePatterns: ['<rootDir>/node_modules/', '<rootDir>/.yalc/'],
modulePathIgnorePatterns: [
'<rootDir>/.yalc/@makerdao/dai-plugin-(mcd|migrations|scd)/test'
]
],
testEnvironment: 'jsdom',
testSequencer: './customSequencer.js'
};
80 changes: 43 additions & 37 deletions maker.js
Expand Up @@ -48,53 +48,63 @@ export async function instantiateMaker(network) {
const url =
network === 'test' || network === 'testnet'
? 'http://localhost:2000'
: network === 'mainnetfork' ? 'http://localhost:8545'
: `https://${network}.infura.io/v3/${INFURA_KEY}`;

// this is required here instead of being imported normally because it runs
// code that will break if run server-side
const trezorPlugin = require('@makerdao/dai-plugin-trezor-web').default;

const mcdPluginConfig = {
cdpTypes: [
{ currency: SAI, ilk: 'SAI' },
//FIXME: the mcd plugin should be changed so that we're not required to add the default cdp types again here
...ilkList.map(i => {
...ilkList.filter(i => i.symbol !== 'PSM-USDC-A').map(i => {
return {
currency: i.currency,
ilk: i.key,
decimals: i.decimals
};
})
}),
]
};

const migrationPluginConfig = {};
const scdPluginConfig = {};

let migrationPluginConfig = {};
let scdPluginConfig = {};
let daiAddressOverrides = {};

if (network === 'kovan' && global.mcdESTest) {
const addresses = require('./addresses-kovan-mcd-es.json');
mcdPluginConfig.addressOverrides = addresses;
migrationPluginConfig.addressOverrides = addresses;
daiAddressOverrides = {...addresses,
CDP_MANAGER: addresses.CDP_MANAGER_1,
MCD_VAT: addresses.MCD_VAT_1,
MCD_END: addresses.MCD_END_1,
GET_CDPS_1: addresses.GET_CDPS_1
};
}

if (network === 'testnet') {
const addresses = require('./addresses-testnet.json');
mcdPluginConfig.addressOverrides = addresses;
migrationPluginConfig.addressOverrides = addresses;
daiAddressOverrides = {...addresses,
CDP_MANAGER: addresses.CDP_MANAGER_1,
MCD_VAT: addresses.MCD_VAT_1,
MCD_END: addresses.MCD_END_1,
GET_CDPS_1: addresses.GET_CDPS_1
};
// if (network === 'kovan' && global.mcdESTest) {
// const addresses = require('./addresses-kovan-mcd-es.json');
// mcdPluginConfig.addressOverrides = addresses;
// migrationPluginConfig.addressOverrides = addresses;
// daiAddressOverrides = {...addresses,
// CDP_MANAGER: addresses.CDP_MANAGER_1,
// MCD_VAT: addresses.MCD_VAT_1,
// MCD_END: addresses.MCD_END_1,
// GET_CDPS_1: addresses.GET_CDPS_1
// };
// }

// if (network === 'testnet') {
// const addresses = require('./addresses-testnet.json');
// mcdPluginConfig.addressOverrides = addresses;
// migrationPluginConfig.addressOverrides = addresses;
// daiAddressOverrides = {...addresses,
// CDP_MANAGER: addresses.CDP_MANAGER_1,
// MCD_VAT: addresses.MCD_VAT_1,
// MCD_END: addresses.MCD_END_1,
// GET_CDPS_1: addresses.GET_CDPS_1
// };
// }

if (network === 'mainnetfork' || network === 'mainnet') {
const addressesMainnet = require('./addresses-mainnet.json');
mcdPluginConfig.addressOverrides = addressesMainnet;
migrationPluginConfig.addressOverrides = addressesMainnet;
daiAddressOverrides = {...addressesMainnet,
CDP_MANAGER_1: addressesMainnet.CDP_MANAGER,
MCD_VAT_1: addressesMainnet.MCD_VAT,
MCD_END_1: addressesMainnet.MCD_END,
GET_CDPS_1: addressesMainnet.GET_CDPS
};
}

const config = {
Expand All @@ -111,15 +121,11 @@ export async function instantiateMaker(network) {
[scdPlugin, scdPluginConfig]
],
smartContract: {
addressOverrides: {
...daiAddressOverrides,
MAKER_OTC: {
mainnet: '0x794e6e91555438afc3ccf1c5076a74f42133d08d',
kovan: '0xe325acb9765b02b8b418199bf9650972299235f4'
}
}
addressOverrides: daiAddressOverrides
},
token: { addressOverrides: {} }
gas: {
price: 73474656578
}
};

if (global.scdESTest && !global.testnet) {
Expand Down
30 changes: 20 additions & 10 deletions package.json
Expand Up @@ -10,18 +10,21 @@
"https": "yarn dev & dev-proxy -p 3000:3003",
"build": "next build && next export",
"start": "next start",
"test": "yarn testchain --ci jest --runInBand",
"testchain": "./node_modules/@makerdao/testchain/scripts/launch -s default --fast"
"test": "yarn hardhat & (sleep 5 && npm run fund && yarn testchain --ci jest --runInBand)",
"test:mcd": "yarn hardhat & (sleep 5 && npm run fund && yarn testchain --ci jest --runInBand mcd-es --coverage)",
"testchain": "./node_modules/@makerdao/testchain/scripts/launch -s default --fast",
"hardhat": "npx hardhat node --network hardhat",
"fund": "npx hardhat run scripts/setup.js --network localhost"
},
"dependencies": {
"@babel/plugin-proposal-decorators": "^7.8.3",
"@babel/runtime-corejs2": "^7.9.2",
"@makerdao/currency": "^0.9.8",
"@makerdao/dai": "^0.32.11",
"@makerdao/currency": "0.9.10",
"@makerdao/dai": "0.42.5-alpha.0",
"@makerdao/dai-plugin-ledger-web": "^0.9.7",
"@makerdao/dai-plugin-mcd": "1.6.21",
"@makerdao/dai-plugin-migrations": "1.3.17",
"@makerdao/dai-plugin-scd": "1.2.13",
"@makerdao/dai-plugin-mcd": "1.8.6-alpha.2",
"@makerdao/dai-plugin-migrations": "1.5.5-alpha.1",
"@makerdao/dai-plugin-scd": "1.4.3-alpha.2",
"@makerdao/dai-plugin-trezor-web": "^0.9.6",
"@makerdao/dai-plugin-walletconnect": "^0.0.8",
"@makerdao/dai-plugin-walletlink": "^0.0.1",
Expand All @@ -31,7 +34,10 @@
"@walletconnect/browser": "^1.0.0-beta.39",
"@walletconnect/qrcode-modal": "^1.0.0-beta.39",
"@zeit/next-css": "^1.0.1",
"add": "^2.0.6",
"body-scroll-lock": "^2.6.4",
"dotenv": "^14.2.0",
"jest": "^27.3.1",
"lodash": "^4.17.15",
"next": "^9.3.2",
"next-images": "^1.2.0",
Expand All @@ -44,22 +50,26 @@
"react-spring": "^8.0.27",
"react-transition-group": "^4.3.0",
"styled-components": "^4.4.1",
"trezor-connect": "^7.0.5"
"trezor-connect": "^7.0.5",
"yarn": "^1.22.17"
},
"devDependencies": {
"@makerdao/test-helpers": "^0.2.1",
"@makerdao/testchain": "^1.1.27",
"@makerdao/testchain": "1.1.33-beta5",
"@nomiclabs/hardhat-ethers": "^2.0.4",
"@testing-library/react": "^9.3.2",
"babel-eslint": "^10.0.3",
"babel-plugin-styled-components": "^1.10.6",
"cypress": "^9.3.1",
"dev-proxy": "^2.1.2",
"eslint": "^6.6.0",
"eslint-plugin-react": "^7.16.0",
"eslint-plugin-react-hooks": "^2.2.0",
"hardhat": "^2.9.3",
"husky": "^3.0.9",
"jest": "^24.9.0",
"lint-staged": "^9.4.3",
"prettier": "^2.0.4",
"start-server-and-test": "^1.14.0",
"wait-for-expect": "^3.0.1"
},
"engines": {
Expand Down
5 changes: 0 additions & 5 deletions pages/index.js
Expand Up @@ -72,11 +72,6 @@ function Index() {
>
<WalletManager providerName={providerName} />
</Grid>
{!!saiAvailable && (
<Text m="0 auto" mb="m">
Sai available for CDP migration: {prettifyNumber(saiAvailable)}
</Text>
)}
<Box width="100%" height="75px" />
<Footer />
</Flex>
Expand Down
5 changes: 2 additions & 3 deletions pages/migration/scd-es-cdp.js
Expand Up @@ -25,8 +25,7 @@ import Failed from '../../components/Failed';
import FadeInFromSide from '../../components/FadeInFromSide';
import InProgressImage from '../../assets/icons/daiRedeem.svg';
import BigNumber from 'bignumber.js';
import { ETH } from '@makerdao/dai/dist/src/eth/Currency';
import { PETH } from '../../maker';
import { ETH, PETH } from '../../maker';
import assert from 'assert';

const CompleteBody = () => {
Expand Down Expand Up @@ -161,7 +160,7 @@ export default function () {
.service('smartContract')
.getContract('SAI_TUB')
.per();
setRatio(BigNumber(per).div('1e27'));
setRatio(BigNumber(per._hex).div('1e27'));
})();
}, [maker]);

Expand Down
9 changes: 5 additions & 4 deletions pages/overview.js
Expand Up @@ -309,7 +309,7 @@ function OverviewDataFetch() {
const scs = maker.service('smartContract');
const tub = scs.getContract('SAI_TUB');
const top = scs.getContract('SAI_TOP');
const scd = { off: await tub.off() }; // SCD is shut down
const scd = { off: true }; // SCD is shut down - can hardcode this now

if (scd.off && countCdps(cdpMigrationCheck) > 0) {
Object.assign(scd, {
Expand Down Expand Up @@ -350,7 +350,8 @@ function OverviewDataFetch() {
daiDsrEndBalance,
vaultsToRedeem: { claims: validClaims, parsedVaultsData },
minEndVatBalance,
proxyDaiAllowance
proxyDaiAllowance,
daiBalance
}
});
})();
Expand Down Expand Up @@ -440,8 +441,8 @@ function Overview({ fetching }) {
}}
>
<Text.p t="body">
Due to the recent discovery of a potential exploit in the Maker
Governance Contract (DSChief), all users are requested to
Due to the discovery of a potential exploit in the Maker
Governance Contract (DSChief v1.0) in 2019, all users are requested to
withdraw any MKR deposited into one of the voting contracts back
to their wallet.
</Text.p>
Expand Down

0 comments on commit 0ebf871

Please sign in to comment.