Removed fees.

This commit is contained in:
Sowmayjain 2018-11-20 01:35:10 +05:30
parent 61d4b6ee44
commit 6557ac8290
2 changed files with 11 additions and 39 deletions

View File

@ -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);
}
}

View File

@ -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;
}
}