init funding test
This commit is contained in:
@@ -23,27 +23,27 @@ contract DVMFunding is DVMStorage {
|
||||
if (baseReserve == 0 && quoteReserve == 0) {
|
||||
mintAmount = baseInput;
|
||||
}
|
||||
// // case 2. supply when quote reserve is 0
|
||||
// if (baseReserve > 0 && quoteReserve == 0) {
|
||||
// uint256 mintRatio = DecimalMath.divFloor(baseInput, baseReserve);
|
||||
// mintAmount = DecimalMath.mulFloor(_VAULT_.totalSupply(), mintRatio);
|
||||
// }
|
||||
// // case 3. normal case
|
||||
// if (baseReserve > 0 && quoteReserve > 0) {
|
||||
// uint256 baseInputRatio = DecimalMath.divFloor(baseInput, baseReserve);
|
||||
// uint256 quoteInputRatio = DecimalMath.divFloor(quoteInput, quoteReserve);
|
||||
// uint256 mintRatio = baseInputRatio > quoteInputRatio ? quoteInputRatio : baseInputRatio;
|
||||
// // 在提币的时候向下取整。因此永远不会出现,balance为0但totalsupply不为0的情况
|
||||
// // 但有可能出现,reserve>0但totalSupply=0的场景
|
||||
// uint256 totalShare = _VAULT_.totalSupply();
|
||||
// if (totalShare > 0) {
|
||||
// mintAmount = DecimalMath.mulFloor(totalShare, mintRatio);
|
||||
// } else {
|
||||
// mintAmount = baseInput;
|
||||
// }
|
||||
// }
|
||||
// _VAULT_.mint(account, mintAmount);
|
||||
// _VAULT_.sync();
|
||||
// case 2. supply when quote reserve is 0
|
||||
if (baseReserve > 0 && quoteReserve == 0) {
|
||||
uint256 mintRatio = DecimalMath.divFloor(baseInput, baseReserve);
|
||||
mintAmount = DecimalMath.mulFloor(_VAULT_.totalSupply(), mintRatio);
|
||||
}
|
||||
// case 3. normal case
|
||||
if (baseReserve > 0 && quoteReserve > 0) {
|
||||
uint256 baseInputRatio = DecimalMath.divFloor(baseInput, baseReserve);
|
||||
uint256 quoteInputRatio = DecimalMath.divFloor(quoteInput, quoteReserve);
|
||||
uint256 mintRatio = baseInputRatio > quoteInputRatio ? quoteInputRatio : baseInputRatio;
|
||||
// 在提币的时候向下取整。因此永远不会出现,balance为0但totalsupply不为0的情况
|
||||
// 但有可能出现,reserve>0但totalSupply=0的场景
|
||||
uint256 totalShare = _VAULT_.totalSupply();
|
||||
if (totalShare > 0) {
|
||||
mintAmount = DecimalMath.mulFloor(totalShare, mintRatio);
|
||||
} else {
|
||||
mintAmount = baseInput;
|
||||
}
|
||||
}
|
||||
_VAULT_.mint(account, mintAmount);
|
||||
_VAULT_.sync();
|
||||
}
|
||||
|
||||
function sellShares(
|
||||
|
||||
Reference in New Issue
Block a user