diff --git a/packages/dai-plugin-liquidations/contracts/addresses/kovan.json b/packages/dai-plugin-liquidations/contracts/addresses/kovan.json index ffb5957c3..c75f11029 100644 --- a/packages/dai-plugin-liquidations/contracts/addresses/kovan.json +++ b/packages/dai-plugin-liquidations/contracts/addresses/kovan.json @@ -7,5 +7,6 @@ "MCD_END": "0x24728acf2e2c403f5d2db4df6834b8998e56aa5f", "GOV": "0xaaf64bfcc32d0f15873a02163e7e500671a4ffcd", "MCD_IOU": "0x41f0b6ecaebfbf85c4eb857116caeeb0bdc212f0", - "PAUSE": "0x8754e6ecb4fe68daa5132c2886ab39297a5c7189" + "PAUSE": "0x8754e6ecb4fe68daa5132c2886ab39297a5c7189", + "MCD_CLIP_LINK_A": "0x1eB71cC879960606F8ab0E02b3668EEf92CE6D98" } diff --git a/packages/dai-plugin-liquidations/src/LiquidationService.js b/packages/dai-plugin-liquidations/src/LiquidationService.js index 0bef4dd58..381e863f4 100644 --- a/packages/dai-plugin-liquidations/src/LiquidationService.js +++ b/packages/dai-plugin-liquidations/src/LiquidationService.js @@ -1,4 +1,5 @@ import { PublicService } from '@makerdao/services-core'; +import { numberToBytes32 } from '@makerdao/dai/dist/src/utils/conversion'; import assert from 'assert'; import tracksTransactions from './utils/tracksTransactions'; //const MAINNET_SERVER_URL = 'https://api.makerdao.com/graphql'; @@ -172,7 +173,9 @@ export default class LiquidationService extends PublicService { bytes calldata data // Data to pass in external call; if length 0, no call is done */ @tracksTransactions - async take(id, amount, maxPrice, address, { promise }) { + async take(auctionId, amount, maxPrice, address, { promise }) { + const id = numberToBytes32(auctionId); + const amt = BigNumber(amount) .times(WAD) .toFixed(); @@ -181,15 +184,24 @@ export default class LiquidationService extends PublicService { .times(RAY) .toFixed(); - return await this._clipperContract().take(id, amt, max, address, '0x', { - promise - }); + return await this._clipperContract().take( + id, + amt, + max, + address, + nullBytes, + { + promise + } + ); } + // Returns the total number of kicks, active or inactive async kicks() { return await this._clipperContract().kicks(); } + // Returns the ID of the auction at the index async active(index) { return await this._clipperContract().active(index); } @@ -202,11 +214,12 @@ export default class LiquidationService extends PublicService { uint96 tic; // Auction start time uint256 top; // Starting price [ray] } - */ + */ async sales(id) { return await this._clipperContract().sales(id); } + // Returns the total number of active auctions async count() { return await this._clipperContract().count(); } diff --git a/packages/dai-plugin-liquidations/test/LiquidationService.test.js b/packages/dai-plugin-liquidations/test/LiquidationService.test.js index d70f53dde..395b6dd08 100644 --- a/packages/dai-plugin-liquidations/test/LiquidationService.test.js +++ b/packages/dai-plugin-liquidations/test/LiquidationService.test.js @@ -3,6 +3,7 @@ import McdPlugin from '@makerdao/dai-plugin-mcd'; // import BigNumber from 'bignumber.js'; import liquidationPlugin from '../src'; import LiquidationService from '../src/LiquidationService'; +// import { createVaults, liquidateVaults } from './utils'; // const infuraProjectId = 'c3f0f26a4c1742e0949d8eedfc47be67'; @@ -125,35 +126,47 @@ xtest('can create risky vaults', async () => { // const amt = '1'; // const max = '3.99999999999999999999'; // const max = '20'; - // try { - // const kicks = await service.kicks(); - // console.log('KICKS:', kicks.toString()); - - // const active = await service.active(2); - // console.log('ACTIVE', active.toNumber()); - - // const list = await service.list(); - // console.log('LIST', list); - - // const txo = await service.take(id, amt, max, me); - // console.log('called take', txo.receipt.logs); - // } catch (e) { - // console.error('take error:', e); - // } + try { + const kicks = await service.kicks(); + console.log('KICKS:', kicks.toString()); + + // const active = await service.active(0); + // console.log('ACTIVE', active.toString()); + + // const sales = await service.sales(id); + // console.log( + // 'SALES', + // sales.pos.toString(), + // sales.tab.toString(), + // sales.lot.toString(), + // sales.usr.toString(), + // sales.tic.toString(), + // sales.top.toString() + // ); + + const count = await service.count(); + console.log('COUNT', count.toString()); + + const list = await service.list(); + console.log('LIST', list); + + // const status = await service.getStatus(id); + // console.log( + // 'STATUS', + // status.needsRedo, + // status.price.toString(), + // status.lot.toString(), + // status.tab.toString() + // ); + + // const txo = await service.take(id, amt, max, me); + // console.log('called take', txo.receipt.logs); + } catch (e) { + console.error('take error:', e); + } // await mineBlocks(maker.service('web3'), 10); - // const sales = await service.sales(id); - // console.log( - // 'SALES (after "take"):', - // sales.pos.toString(), - // sales.tab.toString(), - // sales.lot.toString(), - // sales.usr.toString(), - // sales.tic.toString(), - // sales.top.toString() - // ); - // verify collateral was successfully moved to me after 'take' const usrVatGemBal = await maker .service('smartContract') diff --git a/packages/dai-plugin-liquidations/test/utils.js b/packages/dai-plugin-liquidations/test/utils.js index 3c0b7c71a..6a4b64a6b 100644 --- a/packages/dai-plugin-liquidations/test/utils.js +++ b/packages/dai-plugin-liquidations/test/utils.js @@ -13,9 +13,9 @@ let urns = []; // const dogAddress = '0x795f65578081AA750d874E1a3A6c434D1D98E118'; //99800418305638316473488226407242625739110630383877768873912206733733181632051 -const linkAmt = '10xCB4AA4daBD333B240F61c3F830bc397E857A28eD'; +const linkAmt = '1'; // let vaultId; -let vaultId = 3519; //todo change this back +let vaultId = 3529; //todo change this back when starting fresh const urnAdd = '0xB95fFDe0C48F23Df7401b1566C4DA0EDeEF604AC';