dvm proxy test ing
This commit is contained in:
@@ -30,7 +30,6 @@ contract DVM is DVMTrader, DVMFunding {
|
||||
uint256 k
|
||||
) external {
|
||||
initOwner(owner);
|
||||
_ADMIN_ = owner;
|
||||
_BASE_TOKEN_ = IERC20(baseTokenAddress);
|
||||
_QUOTE_TOKEN_ = IERC20(quoteTokenAddress);
|
||||
_LP_FEE_RATE_MODEL_ = IFeeRateModel(lpFeeRateModel);
|
||||
|
||||
@@ -28,26 +28,25 @@ contract DVMFunding is DVMVault {
|
||||
require(baseInput > 0, "NO_BASE_INPUT");
|
||||
uint256 baseReserve = _BASE_RESERVE_;
|
||||
uint256 quoteReserve = _QUOTE_RESERVE_;
|
||||
uint256 mintAmount;
|
||||
// case 1. initial supply
|
||||
// 包含了 baseReserve == 0 && quoteReserve == 0 的情况
|
||||
// 在提币的时候向下取整。因此永远不会出现,balance为0但totalsupply不为0的情况
|
||||
// 但有可能出现,reserve>0但totalSupply=0的场景
|
||||
if (totalSupply == 0) {
|
||||
mintAmount = getBaseBalance(); // 以免出现balance很大但shares很小的情况
|
||||
shares = getBaseBalance(); // 以免出现balance很大但shares很小的情况
|
||||
} else if (baseReserve > 0 && quoteReserve == 0) {
|
||||
// case 2. supply when quote reserve is 0
|
||||
mintAmount = baseInput.mul(totalSupply).div(baseReserve);
|
||||
shares = baseInput.mul(totalSupply).div(baseReserve);
|
||||
} else if (baseReserve > 0 && quoteReserve > 0) {
|
||||
// case 3. normal case
|
||||
uint256 baseInputRatio = DecimalMath.divFloor(baseInput, baseReserve);
|
||||
uint256 quoteInputRatio = DecimalMath.divFloor(quoteInput, quoteReserve);
|
||||
uint256 mintRatio = quoteInputRatio < baseInputRatio ? quoteInputRatio : baseInputRatio;
|
||||
mintAmount = DecimalMath.mulFloor(totalSupply, mintRatio);
|
||||
shares = DecimalMath.mulFloor(totalSupply, mintRatio);
|
||||
}
|
||||
_mint(to, mintAmount);
|
||||
_mint(to, shares);
|
||||
_sync();
|
||||
return (mintAmount, baseInput, quoteInput);
|
||||
return (shares, baseInput, quoteInput);
|
||||
}
|
||||
|
||||
// withdraw amount [round down]
|
||||
|
||||
@@ -21,8 +21,6 @@ import {IERC20} from "../../intf/IERC20.sol";
|
||||
contract DVMStorage is InitializableOwnable, ReentrancyGuard {
|
||||
using SafeMath for uint256;
|
||||
|
||||
address public _ADMIN_;
|
||||
|
||||
// ============ Variables for Control ============
|
||||
|
||||
IExternalValue public _GAS_PRICE_LIMIT_;
|
||||
|
||||
Reference in New Issue
Block a user