From 6557ac8290b2f9defe7a9e4f7b8e808df346d1d3 Mon Sep 17 00:00:00 2001 From: Sowmayjain Date: Tue, 20 Nov 2018 01:35:10 +0530 Subject: [PATCH] Removed fees. --- contracts/protocols/MoatKyber.sol | 25 +++++-------------------- contracts/protocols/MoatMaker.sol | 25 ++++++------------------- 2 files changed, 11 insertions(+), 39 deletions(-) diff --git a/contracts/protocols/MoatKyber.sol b/contracts/protocols/MoatKyber.sol index 10475e9..be5e847 100644 --- a/contracts/protocols/MoatKyber.sol +++ b/contracts/protocols/MoatKyber.sol @@ -28,7 +28,6 @@ interface Kyber { contract Registry { - address public addressRegistry; modifier onlyAdmin() { require( @@ -37,7 +36,6 @@ contract Registry { ); _; } - function getAddress(string name) internal view returns(address) { AddressRegistry addrReg = AddressRegistry(addressRegistry); return addrReg.getAddr(name); @@ -51,15 +49,12 @@ contract Trade is Registry { using SafeMath for uint; using SafeMath for uint256; - uint public fees; - event KyberTrade( address src, uint srcAmt, address dest, uint destAmt, address beneficiary, - uint feecut, uint minConversionRate, address affiliate ); @@ -72,29 +67,21 @@ contract Trade is Registry { ) public payable returns (uint destAmt) { address protocolAdmin = getAddress("admin"); - uint sellQty = srcAmt; uint ethQty; - uint feecut; - if (fees > 0) { - feecut = srcAmt.div(fees); - sellQty = srcAmt.sub(feecut); - } // fetch token & deduct fees IERC20 tokenFunctions = IERC20(src); if (src == getAddress("eth")) { require(msg.value == srcAmt, "Invalid Operation"); - if (feecut > 0) {protocolAdmin.transfer(feecut);} - ethQty = sellQty; + ethQty = srcAmt; } else { tokenFunctions.transferFrom(msg.sender, address(this), srcAmt); - if (feecut > 0) {tokenFunctions.transfer(protocolAdmin, feecut);} } Kyber kyberFunctions = Kyber(getAddress("kyber")); destAmt = kyberFunctions.trade.value(ethQty)( src, - sellQty, + srcAmt, dest, msg.sender, 2**256 - 1, @@ -108,7 +95,6 @@ contract Trade is Registry { dest, destAmt, msg.sender, - feecut, minConversionRate, protocolAdmin ); @@ -141,6 +127,8 @@ contract Trade is Registry { contract MoatKyber is Trade { + event AssetsCollected(address name, uint addr); + constructor(address rAddr) public { addressRegistry = rAddr; } @@ -154,10 +142,7 @@ contract MoatKyber is Trade { IERC20 tokenFunctions = IERC20(tokenAddress); tokenFunctions.transfer(msg.sender, amount); } - } - - function setFees(uint cut) public onlyAdmin { // 200 means 0.5% - fees = cut; + emit AssetsCollected(tokenAddress, amount); } } \ No newline at end of file diff --git a/contracts/protocols/MoatMaker.sol b/contracts/protocols/MoatMaker.sol index 517c1e8..bfac644 100644 --- a/contracts/protocols/MoatMaker.sol +++ b/contracts/protocols/MoatMaker.sol @@ -79,14 +79,13 @@ contract GlobalVar is Registry { bytes32 public blankCDP = 0x0000000000000000000000000000000000000000000000000000000000000000; mapping (address => bytes32) public cdps; // borrower >>> CDP Bytes bool public freezed; - uint public fees; } contract IssueLoan is GlobalVar { event LockedETH(address borrower, uint lockETH, uint lockPETH); - event LoanedDAI(address borrower, uint loanDAI, uint fees); + event LoanedDAI(address borrower, uint loanDAI); event OpenedNewCDP(address borrower, bytes32 cdpBytes); function pethPEReth(uint ethNum) public view returns (uint rPETH) { @@ -114,18 +113,9 @@ contract IssueLoan is GlobalVar { function drawDAI(uint daiDraw) public { require(!freezed, "Operation Disabled"); loanMaster.draw(cdps[msg.sender], daiDraw); - uint feecut = deductFees(daiDraw); IERC20 daiTkn = IERC20(getAddress("dai")); - daiTkn.transfer(msg.sender, daiDraw.sub(feecut)); - emit LoanedDAI(msg.sender, daiDraw, feecut); - } - - function deductFees(uint volume) internal returns(uint brokerage) { - if (fees > 0) { - brokerage = volume.div(fees); - IERC20 daiTkn = IERC20(getAddress("dai")); - daiTkn.transfer(getAddress("admin"), brokerage); - } + daiTkn.transfer(msg.sender, daiDraw); + emit LoanedDAI(msg.sender, daiDraw); } } @@ -173,11 +163,12 @@ contract RepayLoan is IssueLoan { msg.value, feeMinConRate ); - mkrTkn.transfer(msg.sender, mkrBought - mkrCharged); // pay back balanced MKR tokens + if (mkrBought > mkrCharged) { + mkrTkn.transfer(msg.sender, mkrBought - mkrCharged); // pay back balanced MKR tokens + } } require(mkrTkn.balanceOf(address(this)) == nowBal, "MKR balance not reimbursed"); - emit WipedDAI(msg.sender, daiWipe, mkrCharged); } @@ -254,8 +245,4 @@ contract MoatMaker is BorrowTasks { freezed = stop; } - function setFees(uint cut) public onlyAdmin { // 200 means 0.5% - fees = cut; - } - }