cp audit-fix && update event

This commit is contained in:
owen05
2020-12-18 01:11:33 +08:00
parent 610baa6d0e
commit 83c8bbaa85
15 changed files with 116 additions and 62 deletions

View File

@@ -15,11 +15,11 @@ import {IDODOCallee} from "../../intf/IDODOCallee.sol";
contract DVMFunding is DVMVault {
// ============ Events ============
event BuyShares(address indexed to, uint256 increaseShares, uint256 totalShares);
event BuyShares(address to, uint256 increaseShares, uint256 totalShares);
event SellShares(
address indexed payer,
address indexed to,
address payer,
address to,
uint256 decreaseShares,
uint256 totalShares
);

View File

@@ -28,6 +28,13 @@ contract DVMTrader is DVMVault {
address trader
);
event DODOFlashLoan(
address borrower,
address assetTo,
uint256 baseAmount,
uint256 quoteAmount
);
// ============ Modifiers ============
modifier isBuyAllow(address trader) {
@@ -70,7 +77,7 @@ contract DVMTrader is DVMVault {
address(_QUOTE_TOKEN_),
baseInput,
receiveQuoteAmount,
tx.origin
msg.sender
);
}
@@ -94,7 +101,7 @@ contract DVMTrader is DVMVault {
address(_BASE_TOKEN_),
quoteInput,
receiveBaseAmount,
tx.origin
msg.sender
);
}
@@ -112,7 +119,7 @@ contract DVMTrader is DVMVault {
uint256 baseBalance = _BASE_TOKEN_.balanceOf(address(this));
uint256 quoteBalance = _QUOTE_TOKEN_.balanceOf(address(this));
// no input -> pure loss
require(
baseBalance >= _BASE_RESERVE_ || quoteBalance >= _QUOTE_RESERVE_,
@@ -147,11 +154,13 @@ contract DVMTrader is DVMVault {
address(_QUOTE_TOKEN_),
baseInput,
receiveQuoteAmount,
tx.origin
msg.sender
);
}
_sync();
emit DODOFlashLoan(msg.sender, assetTo, baseAmount, quoteAmount);
}
// ============ Query Functions ============

View File

@@ -35,6 +35,16 @@ contract DVMVault is DVMStorage {
quoteReserve = _QUOTE_RESERVE_;
}
function getUserFeeRate(address user) external view returns (uint256 lpFeeRate, uint256 mtFeeRate) {
lpFeeRate = _LP_FEE_RATE_MODEL_.getFeeRate(user);
mtFeeRate = _MT_FEE_RATE_MODEL_.getFeeRate(user);
}
function getUserTradePermission(address user) external view returns (bool isBuyAllow, bool isSellAllow) {
isBuyAllow = (!_BUYING_CLOSE_ && _TRADE_PERMISSION_.isAllowed(user));
isSellAllow = (!_SELLING_CLOSE_ && _TRADE_PERMISSION_.isAllowed(user));
}
// ============ Asset In ============
function getBaseInput() public view returns (uint256 input) {