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

Commit

Permalink
do int to hex conversion of ID in take function
Browse files Browse the repository at this point in the history
  • Loading branch information
b-pmcg committed Apr 14, 2021
1 parent 6e5e041 commit af22836
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"MCD_END": "0x24728acf2e2c403f5d2db4df6834b8998e56aa5f",
"GOV": "0xaaf64bfcc32d0f15873a02163e7e500671a4ffcd",
"MCD_IOU": "0x41f0b6ecaebfbf85c4eb857116caeeb0bdc212f0",
"PAUSE": "0x8754e6ecb4fe68daa5132c2886ab39297a5c7189"
"PAUSE": "0x8754e6ecb4fe68daa5132c2886ab39297a5c7189",
"MCD_CLIP_LINK_A": "0x1eB71cC879960606F8ab0E02b3668EEf92CE6D98"
}
23 changes: 18 additions & 5 deletions packages/dai-plugin-liquidations/src/LiquidationService.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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();
Expand All @@ -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);
}
Expand All @@ -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();
}
Expand Down
65 changes: 39 additions & 26 deletions packages/dai-plugin-liquidations/test/LiquidationService.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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')
Expand Down
4 changes: 2 additions & 2 deletions packages/dai-plugin-liquidations/test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down

0 comments on commit af22836

Please sign in to comment.