audit fix
This commit is contained in:
@@ -124,13 +124,14 @@ contract FeeDistributor {
|
||||
function _claim(address sender, address to) internal {
|
||||
uint256 allBase = _USER_BASE_REWARDS_[sender];
|
||||
uint256 allQuote = _USER_QUOTE_REWARDS_[sender];
|
||||
IERC20(_BASE_TOKEN_).safeTransfer(to, allBase);
|
||||
IERC20(_QUOTE_TOKEN_).safeTransfer(to, allQuote);
|
||||
|
||||
_BASE_RESERVE_ = _BASE_RESERVE_.sub(allBase);
|
||||
_QUOTE_RESERVE_ = _QUOTE_RESERVE_.sub(allQuote);
|
||||
_USER_BASE_REWARDS_[sender] = 0;
|
||||
_USER_QUOTE_REWARDS_[sender] = 0;
|
||||
|
||||
IERC20(_BASE_TOKEN_).safeTransfer(to, allBase);
|
||||
IERC20(_QUOTE_TOKEN_).safeTransfer(to, allQuote);
|
||||
|
||||
emit Claim(sender, allBase, allQuote);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ pragma solidity 0.6.9;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import {InitializableOwnable} from "../../lib/InitializableOwnable.sol";
|
||||
import {IDVM} from "../../DODOVendingMachine/intf/IDVM.sol";
|
||||
|
||||
interface IDODONFTRegistry {
|
||||
function addRegistry(
|
||||
@@ -26,7 +27,7 @@ interface IDODONFTRegistry {
|
||||
*
|
||||
* @notice Register DODONFT Pools
|
||||
*/
|
||||
contract DODONFTRegistry is InitializableOwnable {
|
||||
contract DODONFTRegistry is InitializableOwnable, IDODONFTRegistry {
|
||||
|
||||
mapping (address => bool) public isAdminListed;
|
||||
|
||||
@@ -62,7 +63,7 @@ contract DODONFTRegistry is InitializableOwnable {
|
||||
address quoteToken,
|
||||
address feeDistributor,
|
||||
address dvm
|
||||
) external {
|
||||
) override external {
|
||||
require(isAdminListed[msg.sender], "ACCESS_DENIED");
|
||||
_FRAG_FEE_REGISTRY_[fragment] = feeDistributor;
|
||||
_DVM_FEE_REGISTRY_[dvm] = feeDistributor;
|
||||
@@ -79,14 +80,27 @@ contract DODONFTRegistry is InitializableOwnable {
|
||||
_FRAG_FEE_REGISTRY_[fragment] = address(0);
|
||||
_DVM_FEE_REGISTRY_[dvm] = address(0);
|
||||
_VAULT_FRAG_REGISTRY_[vault] = address(0);
|
||||
|
||||
address quoteToken = IDVM(dvm)._QUOTE_TOKEN_();
|
||||
address[] memory registryList = _REGISTRY_[fragment][quoteToken];
|
||||
for (uint256 i = 0; i < registryList.length; i++) {
|
||||
if (registryList[i] == dvm) {
|
||||
if(i != registryList.length - 1) {
|
||||
_REGISTRY_[fragment][quoteToken][i] = _REGISTRY_[fragment][quoteToken][registryList.length - 1];
|
||||
}
|
||||
_REGISTRY_[fragment][quoteToken].pop();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
emit RemoveRegistry(fragment);
|
||||
}
|
||||
|
||||
function addAmindList (address contractAddr) public onlyOwner {
|
||||
function addAdminList (address contractAddr) external onlyOwner {
|
||||
isAdminListed[contractAddr] = true;
|
||||
}
|
||||
|
||||
function removeWhiteList (address contractAddr) public onlyOwner {
|
||||
function removeAdminList (address contractAddr) external onlyOwner {
|
||||
isAdminListed[contractAddr] = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ contract Fragment is InitializableERC20 {
|
||||
address dvm,
|
||||
address vaultPreOwner,
|
||||
address collateralVault,
|
||||
uint256 totalSupply,
|
||||
uint256 _totalSupply,
|
||||
uint256 ownerRatio,
|
||||
uint256 buyoutTimestamp
|
||||
) external {
|
||||
@@ -66,12 +66,12 @@ contract Fragment is InitializableERC20 {
|
||||
name = string(abi.encodePacked(prefix, IDVM(_DVM_).addressToShortString(_COLLATERAL_VAULT_)));
|
||||
symbol = "FRAG";
|
||||
decimals = 18;
|
||||
super.init(address(this), totalSupply, name, symbol, decimals);
|
||||
super.init(address(this), _totalSupply, name, symbol, decimals);
|
||||
|
||||
// init FRAG distribution
|
||||
uint256 vaultPreOwnerBalance = DecimalMath.mulFloor(totalSupply, ownerRatio);
|
||||
uint256 vaultPreOwnerBalance = DecimalMath.mulFloor(_totalSupply, ownerRatio);
|
||||
_transfer(address(this), _VAULT_PRE_OWNER_, vaultPreOwnerBalance);
|
||||
_transfer(address(this), _DVM_, totalSupply.sub(vaultPreOwnerBalance));
|
||||
_transfer(address(this), _DVM_, _totalSupply.sub(vaultPreOwnerBalance));
|
||||
|
||||
// init DVM liquidity
|
||||
IDVM(_DVM_).buyShares(address(this));
|
||||
@@ -100,12 +100,12 @@ contract Fragment is InitializableERC20 {
|
||||
_clearBalance(address(this));
|
||||
|
||||
uint256 preOwnerQuote = DecimalMath.mulFloor(_BUYOUT_PRICE_, balances[_VAULT_PRE_OWNER_]);
|
||||
IERC20(_QUOTE_).safeTransfer(_VAULT_PRE_OWNER_, preOwnerQuote);
|
||||
_clearBalance(_VAULT_PRE_OWNER_);
|
||||
IERC20(_QUOTE_).safeTransfer(_VAULT_PRE_OWNER_, preOwnerQuote);
|
||||
|
||||
uint256 newOwnerQuote = DecimalMath.mulFloor(_BUYOUT_PRICE_, balances[newVaultOwner]);
|
||||
IERC20(_QUOTE_).safeTransfer(newVaultOwner, newOwnerQuote);
|
||||
_clearBalance(newVaultOwner);
|
||||
IERC20(_QUOTE_).safeTransfer(newVaultOwner, newOwnerQuote);
|
||||
|
||||
ICollateralVault(_COLLATERAL_VAULT_).directTransferOwnership(newVaultOwner);
|
||||
|
||||
@@ -118,8 +118,8 @@ contract Fragment is InitializableERC20 {
|
||||
|
||||
uint256 baseAmount = balances[msg.sender];
|
||||
uint256 quoteAmount = DecimalMath.mulFloor(_BUYOUT_PRICE_, baseAmount);
|
||||
IERC20(_QUOTE_).safeTransfer(to, quoteAmount);
|
||||
_clearBalance(msg.sender);
|
||||
IERC20(_QUOTE_).safeTransfer(to, quoteAmount);
|
||||
|
||||
if (data.length > 0) {
|
||||
IDODOCallee(to).NFTRedeemCall(
|
||||
@@ -142,7 +142,7 @@ contract Fragment is InitializableERC20 {
|
||||
function _clearBalance(address account) internal {
|
||||
uint256 clearBalance = balances[account];
|
||||
balances[account] = 0;
|
||||
balances[address(0)] = clearBalance;
|
||||
balances[address(0)] = balances[address(0)].add(clearBalance);
|
||||
emit Transfer(account, address(0), clearBalance);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ module.exports = async (deployer, network, accounts) => {
|
||||
logger.log("DODOApproveProxy addDODOProxy tx: ", tx.tx);
|
||||
|
||||
const DODONFTRegistrynstance = await DODONFTRegistry.at(DODONFTRegistryAddress);
|
||||
var tx = await DODONFTRegistrynstance.addAmindList(DODONFTProxyAddress);
|
||||
var tx = await DODONFTRegistrynstance.addAdminList(DODONFTProxyAddress);
|
||||
logger.log("Add AdminList on DODONFTRegistry Tx:", tx.tx);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ export class NFTContext {
|
||||
|
||||
await this.NFTProxy.methods.initOwner(this.Deployer).send(this.sendParam(this.Deployer));
|
||||
|
||||
await this.NFTRegister.methods.addAmindList(this.NFTProxy.options.address).send(this.sendParam(this.Deployer));
|
||||
await this.NFTRegister.methods.addAdminList(this.NFTProxy.options.address).send(this.sendParam(this.Deployer));
|
||||
|
||||
|
||||
await this.DODOApprove.methods.init(this.Deployer, this.DODOApproveProxy.options.address).send(this.sendParam(this.Deployer));
|
||||
|
||||
Reference in New Issue
Block a user