Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Commit

Permalink
Merge branch 'migrate-updates' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
tyler17 committed Sep 14, 2020
2 parents 031a83f + 25fad52 commit 64393ef
Show file tree
Hide file tree
Showing 18 changed files with 43 additions and 311 deletions.
2 changes: 1 addition & 1 deletion packages/dai-plugin-migrations/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@makerdao/dai-plugin-migrations",
"description": "Plugin to add migrations to dai.js",
"version": "1.3.4",
"version": "1.3.8",
"license": "MIT",
"main": "dist/index.js",
"unpkg": "umd/index.js",
Expand Down
14 changes: 1 addition & 13 deletions packages/dai-plugin-migrations/src/MigrationService.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,15 @@ import SingleToMultiCdp from './migrations/SingleToMultiCdp';
import GlobalSettlementSavingsDai from './migrations/GlobalSettlementSavingsDai';
import GlobalSettlementCollateralClaims from './migrations/GlobalSettlementCollateralClaims';
import GlobalSettlementDaiRedeemer from './migrations/GlobalSettlementDaiRedeemer';
import SaiToDai from './migrations/SaiToDai';
import MkrRedeemer from './migrations/MkrRedeemer';
import DaiToSai from './migrations/DaiToSai';
import ChiefMigrate from './migrations/ChiefMigrate';
import RedeemSai from './migrations/RedeemSai';
import RedeemCollateral from './migrations/RedeemCollateral';

const {
SINGLE_TO_MULTI_CDP,
SAI_TO_DAI,
DAI_TO_SAI,
MKR_REDEEMER,
CHIEF_MIGRATE
} = Migrations;
const { SINGLE_TO_MULTI_CDP, MKR_REDEEMER, CHIEF_MIGRATE } = Migrations;

const migrations = {
[SINGLE_TO_MULTI_CDP]: SingleToMultiCdp,
[SAI_TO_DAI]: SaiToDai,
[DAI_TO_SAI]: DaiToSai,
[CHIEF_MIGRATE]: ChiefMigrate,
[Migrations.GLOBAL_SETTLEMENT_SAVINGS_DAI]: GlobalSettlementSavingsDai,
[Migrations.GLOBAL_SETTLEMENT_COLLATERAL_CLAIMS]: GlobalSettlementCollateralClaims,
Expand Down Expand Up @@ -60,8 +50,6 @@ export default class MigrationService extends PublicService {
[SINGLE_TO_MULTI_CDP]: await this.getMigration(
SINGLE_TO_MULTI_CDP
).check(),
[SAI_TO_DAI]: await this.getMigration(SAI_TO_DAI).check(),
[DAI_TO_SAI]: await this.getMigration(DAI_TO_SAI).check(),
[CHIEF_MIGRATE]: await this.getMigration(CHIEF_MIGRATE).check(),
[MKR_REDEEMER]: await this.getMigration(MKR_REDEEMER).check(),
[Migrations.GLOBAL_SETTLEMENT_COLLATERAL_CLAIMS]: await this.getMigration(
Expand Down
2 changes: 0 additions & 2 deletions packages/dai-plugin-migrations/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ export const ServiceRoles = {

export const Migrations = {
SINGLE_TO_MULTI_CDP: 'single-to-multi-cdp',
SAI_TO_DAI: 'sai-to-dai',
DAI_TO_SAI: 'dai-to-sai',
GLOBAL_SETTLEMENT_SAVINGS_DAI: 'global-settlement-savings-dai',
GLOBAL_SETTLEMENT_COLLATERAL_CLAIMS: 'global-settlement-collateral-claims',
GLOBAL_SETTLEMENT_DAI_REDEEMER: 'global-settlement-dai-redeemer',
Expand Down
34 changes: 0 additions & 34 deletions packages/dai-plugin-migrations/src/migrations/DaiToSai.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -47,56 +47,25 @@ export default class GlobalSettlementCollateralClaims {
return freeCollateral;
}

freeEth(cdpId) {
const cdpManagerAddress = this._container
.get('smartContract')
.getContractAddress('CDP_MANAGER_1');
const endAddress = this._container
.get('smartContract')
.getContractAddress('MCD_END_1');
const ethJoinAddress = this._container
.get('smartContract')
.getContractAddress('MCD_JOIN_ETH_A');
return this._container
.get('smartContract')
.getContract('PROXY_ACTIONS_END')
.freeETH(cdpManagerAddress, ethJoinAddress, endAddress, cdpId, {
dsProxy: true
});
}

freeBat(cdpId) {
const cdpManagerAddress = this._container
.get('smartContract')
.getContractAddress('CDP_MANAGER_1');
const endAddress = this._container
.get('smartContract')
.getContractAddress('MCD_END_1');
const gemJoinAddress = this._container
.get('smartContract')
.getContractAddress('MCD_JOIN_BAT_A');
return this._container
.get('smartContract')
.getContract('PROXY_ACTIONS_END')
.freeGem(cdpManagerAddress, gemJoinAddress, endAddress, cdpId, {
dsProxy: true
});
_ilkToAdapter(ilk) {
return 'MCD_JOIN_' + ilk.replace(/-/g, '_');
}

freeUsdc(cdpId) {
free(cdpId, ilk) {
const cdpManagerAddress = this._container
.get('smartContract')
.getContractAddress('CDP_MANAGER_1');
const endAddress = this._container
.get('smartContract')
.getContractAddress('MCD_END_1');
const gemJoinAddress = this._container
const joinAddress = this._container
.get('smartContract')
.getContractAddress('MCD_JOIN_USDC_A');
.getContractAddress(this._ilkToAdapter(ilk));
const methodName = ilk.substring(0, 3) === 'ETH' ? 'freeETH' : 'freeGem';
return this._container
.get('smartContract')
.getContract('PROXY_ACTIONS_END')
.freeGem(cdpManagerAddress, gemJoinAddress, endAddress, cdpId, {
.getContract('PROXY_ACTIONS_END')[methodName](
cdpManagerAddress, joinAddress, endAddress, cdpId, {
dsProxy: true
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,53 +71,24 @@ export default class GlobalSettlementDaiRedeemer {
.pack(daiJoinAddress, endAddress, formattedAmount, { dsProxy: true });
}

async cashEth(daiAmount) {
const formattedAmount = DAI_1(daiAmount).toFixed('wei');
const joinAddress = this._container
.get('smartContract')
.getContractAddress('MCD_JOIN_ETH_A');
const endAddress = this._container
.get('smartContract')
.getContractAddress('MCD_END_1');
const ilkBytes = stringToBytes('ETH-A');
return this._container
.get('smartContract')
.getContract('PROXY_ACTIONS_END')
.cashETH(joinAddress, endAddress, ilkBytes, formattedAmount, {
dsProxy: true
});
_ilkToAdapter(ilk) {
return 'MCD_JOIN_' + ilk.replace(/-/g, '_');
}

async cashBat(daiAmount) {
async cash(daiAmount, ilk) {
const formattedAmount = DAI_1(daiAmount).toFixed('wei');
const joinAddress = this._container
.get('smartContract')
.getContractAddress('MCD_JOIN_BAT_A');
.getContractAddress(this._ilkToAdapter(ilk));
const endAddress = this._container
.get('smartContract')
.getContractAddress('MCD_END_1');
const ilkBytes = stringToBytes('BAT-A');
const ilkBytes = stringToBytes(ilk);
const methodName = ilk.substring(0, 3) === 'ETH' ? 'cashETH' : 'cashGem';
return this._container
.get('smartContract')
.getContract('PROXY_ACTIONS_END')
.cashGem(joinAddress, endAddress, ilkBytes, formattedAmount, {
dsProxy: true
});
}

async cashUsdc(daiAmount) {
const formattedAmount = DAI_1(daiAmount).toFixed('wei');
const joinAddress = this._container
.get('smartContract')
.getContractAddress('MCD_JOIN_USDC_A');
const endAddress = this._container
.get('smartContract')
.getContractAddress('MCD_END_1');
const ilkBytes = stringToBytes('USDC-A');
return this._container
.get('smartContract')
.getContract('PROXY_ACTIONS_END')
.cashGem(joinAddress, endAddress, ilkBytes, formattedAmount, {
.getContract('PROXY_ACTIONS_END')[methodName](
joinAddress, endAddress, ilkBytes, formattedAmount, {
dsProxy: true
});
}
Expand Down
34 changes: 0 additions & 34 deletions packages/dai-plugin-migrations/src/migrations/SaiToDai.js

This file was deleted.

8 changes: 1 addition & 7 deletions packages/dai-plugin-migrations/test/MigrationService.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { migrationMaker } from './helpers';
import { mockCdpIds } from './helpers/mocks';
import { ServiceRoles, Migrations } from '../src/constants';
import SingleToMultiCdp from '../src/migrations/SingleToMultiCdp';
import SaiToDai from '../src/migrations/SaiToDai';
import GlobalSettlementSavingsDai from '../src/migrations/GlobalSettlementSavingsDai';
import GlobalSettlementCollateralClaims from '../src/migrations/GlobalSettlementCollateralClaims';
import GlobalSettlementDaiRedeemer from '../src/migrations/GlobalSettlementDaiRedeemer';
Expand Down Expand Up @@ -38,7 +37,6 @@ test('can fetch a list of all migrations', () => {
expect(ids).toEqual(
expect.arrayContaining([
Migrations.SINGLE_TO_MULTI_CDP,
Migrations.SAI_TO_DAI,
Migrations.GLOBAL_SETTLEMENT_SAVINGS_DAI,
Migrations.GLOBAL_SETTLEMENT_COLLATERAL_CLAIMS,
Migrations.GLOBAL_SETTLEMENT_DAI_REDEEMER,
Expand All @@ -48,14 +46,13 @@ test('can fetch a list of all migrations', () => {
Migrations.REDEEM_COLLATERAL
])
);
expect(ids.length).toEqual(10);
expect(ids.length).toEqual(8);
});

test('getting each migration returns a valid migration', () => {
expect(service.getMigration(Migrations.SINGLE_TO_MULTI_CDP)).toBeInstanceOf(
SingleToMultiCdp
);
expect(service.getMigration(Migrations.SAI_TO_DAI)).toBeInstanceOf(SaiToDai);
expect(
service.getMigration(Migrations.GLOBAL_SETTLEMENT_SAVINGS_DAI)
).toBeInstanceOf(GlobalSettlementSavingsDai);
Expand All @@ -82,12 +79,9 @@ test('runAllChecks', async () => {
await mockCdpIds(maker);
const result = await service.runAllChecks();
expect(result).toEqual({
[Migrations.SAI_TO_DAI]: expect.anything(),
[Migrations.DAI_TO_SAI]: expect.anything(),
[Migrations.SINGLE_TO_MULTI_CDP]: {},
[Migrations.CHIEF_MIGRATE]: expect.anything(),
[Migrations.MKR_REDEEMER]: expect.anything(),
[Migrations.GLOBAL_SETTLEMENT_COLLATERAL_CLAIMS]: expect.anything()
});
expect(result[Migrations.SAI_TO_DAI].eq(0)).toBeTruthy();
});
67 changes: 0 additions & 67 deletions packages/dai-plugin-migrations/test/migrations/DaiToSai.spec.js

This file was deleted.

Loading

0 comments on commit 64393ef

Please sign in to comment.