mirror of
https://github.com/Instadapp/InstaContract.git
synced 2024-07-29 22:47:45 +00:00
Removed fees.
This commit is contained in:
parent
61d4b6ee44
commit
6557ac8290
|
@ -28,7 +28,6 @@ interface Kyber {
|
||||||
|
|
||||||
|
|
||||||
contract Registry {
|
contract Registry {
|
||||||
|
|
||||||
address public addressRegistry;
|
address public addressRegistry;
|
||||||
modifier onlyAdmin() {
|
modifier onlyAdmin() {
|
||||||
require(
|
require(
|
||||||
|
@ -37,7 +36,6 @@ contract Registry {
|
||||||
);
|
);
|
||||||
_;
|
_;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAddress(string name) internal view returns(address) {
|
function getAddress(string name) internal view returns(address) {
|
||||||
AddressRegistry addrReg = AddressRegistry(addressRegistry);
|
AddressRegistry addrReg = AddressRegistry(addressRegistry);
|
||||||
return addrReg.getAddr(name);
|
return addrReg.getAddr(name);
|
||||||
|
@ -51,15 +49,12 @@ contract Trade is Registry {
|
||||||
using SafeMath for uint;
|
using SafeMath for uint;
|
||||||
using SafeMath for uint256;
|
using SafeMath for uint256;
|
||||||
|
|
||||||
uint public fees;
|
|
||||||
|
|
||||||
event KyberTrade(
|
event KyberTrade(
|
||||||
address src,
|
address src,
|
||||||
uint srcAmt,
|
uint srcAmt,
|
||||||
address dest,
|
address dest,
|
||||||
uint destAmt,
|
uint destAmt,
|
||||||
address beneficiary,
|
address beneficiary,
|
||||||
uint feecut,
|
|
||||||
uint minConversionRate,
|
uint minConversionRate,
|
||||||
address affiliate
|
address affiliate
|
||||||
);
|
);
|
||||||
|
@ -72,29 +67,21 @@ contract Trade is Registry {
|
||||||
) public payable returns (uint destAmt)
|
) public payable returns (uint destAmt)
|
||||||
{
|
{
|
||||||
address protocolAdmin = getAddress("admin");
|
address protocolAdmin = getAddress("admin");
|
||||||
uint sellQty = srcAmt;
|
|
||||||
uint ethQty;
|
uint ethQty;
|
||||||
uint feecut;
|
|
||||||
if (fees > 0) {
|
|
||||||
feecut = srcAmt.div(fees);
|
|
||||||
sellQty = srcAmt.sub(feecut);
|
|
||||||
}
|
|
||||||
|
|
||||||
// fetch token & deduct fees
|
// fetch token & deduct fees
|
||||||
IERC20 tokenFunctions = IERC20(src);
|
IERC20 tokenFunctions = IERC20(src);
|
||||||
if (src == getAddress("eth")) {
|
if (src == getAddress("eth")) {
|
||||||
require(msg.value == srcAmt, "Invalid Operation");
|
require(msg.value == srcAmt, "Invalid Operation");
|
||||||
if (feecut > 0) {protocolAdmin.transfer(feecut);}
|
ethQty = srcAmt;
|
||||||
ethQty = sellQty;
|
|
||||||
} else {
|
} else {
|
||||||
tokenFunctions.transferFrom(msg.sender, address(this), srcAmt);
|
tokenFunctions.transferFrom(msg.sender, address(this), srcAmt);
|
||||||
if (feecut > 0) {tokenFunctions.transfer(protocolAdmin, feecut);}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Kyber kyberFunctions = Kyber(getAddress("kyber"));
|
Kyber kyberFunctions = Kyber(getAddress("kyber"));
|
||||||
destAmt = kyberFunctions.trade.value(ethQty)(
|
destAmt = kyberFunctions.trade.value(ethQty)(
|
||||||
src,
|
src,
|
||||||
sellQty,
|
srcAmt,
|
||||||
dest,
|
dest,
|
||||||
msg.sender,
|
msg.sender,
|
||||||
2**256 - 1,
|
2**256 - 1,
|
||||||
|
@ -108,7 +95,6 @@ contract Trade is Registry {
|
||||||
dest,
|
dest,
|
||||||
destAmt,
|
destAmt,
|
||||||
msg.sender,
|
msg.sender,
|
||||||
feecut,
|
|
||||||
minConversionRate,
|
minConversionRate,
|
||||||
protocolAdmin
|
protocolAdmin
|
||||||
);
|
);
|
||||||
|
@ -141,6 +127,8 @@ contract Trade is Registry {
|
||||||
|
|
||||||
contract MoatKyber is Trade {
|
contract MoatKyber is Trade {
|
||||||
|
|
||||||
|
event AssetsCollected(address name, uint addr);
|
||||||
|
|
||||||
constructor(address rAddr) public {
|
constructor(address rAddr) public {
|
||||||
addressRegistry = rAddr;
|
addressRegistry = rAddr;
|
||||||
}
|
}
|
||||||
|
@ -154,10 +142,7 @@ contract MoatKyber is Trade {
|
||||||
IERC20 tokenFunctions = IERC20(tokenAddress);
|
IERC20 tokenFunctions = IERC20(tokenAddress);
|
||||||
tokenFunctions.transfer(msg.sender, amount);
|
tokenFunctions.transfer(msg.sender, amount);
|
||||||
}
|
}
|
||||||
}
|
emit AssetsCollected(tokenAddress, amount);
|
||||||
|
|
||||||
function setFees(uint cut) public onlyAdmin { // 200 means 0.5%
|
|
||||||
fees = cut;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -79,14 +79,13 @@ contract GlobalVar is Registry {
|
||||||
bytes32 public blankCDP = 0x0000000000000000000000000000000000000000000000000000000000000000;
|
bytes32 public blankCDP = 0x0000000000000000000000000000000000000000000000000000000000000000;
|
||||||
mapping (address => bytes32) public cdps; // borrower >>> CDP Bytes
|
mapping (address => bytes32) public cdps; // borrower >>> CDP Bytes
|
||||||
bool public freezed;
|
bool public freezed;
|
||||||
uint public fees;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
contract IssueLoan is GlobalVar {
|
contract IssueLoan is GlobalVar {
|
||||||
|
|
||||||
event LockedETH(address borrower, uint lockETH, uint lockPETH);
|
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);
|
event OpenedNewCDP(address borrower, bytes32 cdpBytes);
|
||||||
|
|
||||||
function pethPEReth(uint ethNum) public view returns (uint rPETH) {
|
function pethPEReth(uint ethNum) public view returns (uint rPETH) {
|
||||||
|
@ -114,18 +113,9 @@ contract IssueLoan is GlobalVar {
|
||||||
function drawDAI(uint daiDraw) public {
|
function drawDAI(uint daiDraw) public {
|
||||||
require(!freezed, "Operation Disabled");
|
require(!freezed, "Operation Disabled");
|
||||||
loanMaster.draw(cdps[msg.sender], daiDraw);
|
loanMaster.draw(cdps[msg.sender], daiDraw);
|
||||||
uint feecut = deductFees(daiDraw);
|
|
||||||
IERC20 daiTkn = IERC20(getAddress("dai"));
|
IERC20 daiTkn = IERC20(getAddress("dai"));
|
||||||
daiTkn.transfer(msg.sender, daiDraw.sub(feecut));
|
daiTkn.transfer(msg.sender, daiDraw);
|
||||||
emit LoanedDAI(msg.sender, daiDraw, feecut);
|
emit LoanedDAI(msg.sender, daiDraw);
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -173,11 +163,12 @@ contract RepayLoan is IssueLoan {
|
||||||
msg.value,
|
msg.value,
|
||||||
feeMinConRate
|
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");
|
require(mkrTkn.balanceOf(address(this)) == nowBal, "MKR balance not reimbursed");
|
||||||
|
|
||||||
emit WipedDAI(msg.sender, daiWipe, mkrCharged);
|
emit WipedDAI(msg.sender, daiWipe, mkrCharged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,8 +245,4 @@ contract MoatMaker is BorrowTasks {
|
||||||
freezed = stop;
|
freezed = stop;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setFees(uint cut) public onlyAdmin { // 200 means 0.5%
|
|
||||||
fees = cut;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user