DODO Mine reward vault & reader
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
pragma solidity 0.6.9;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
|
||||
interface IDODO {
|
||||
function init(
|
||||
address owner,
|
||||
@@ -42,6 +43,8 @@ interface IDODO {
|
||||
|
||||
function queryBuyBaseToken(uint256 amount) external view returns (uint256 payQuote);
|
||||
|
||||
function getExpectedTarget() external view returns (uint256 baseTarget, uint256 quoteTarget);
|
||||
|
||||
function depositBaseTo(address to, uint256 amount) external returns (uint256);
|
||||
|
||||
function withdrawBase(uint256 amount) external returns (uint256);
|
||||
@@ -54,9 +57,9 @@ interface IDODO {
|
||||
|
||||
function withdrawAllQuote() external returns (uint256);
|
||||
|
||||
function _BASE_CAPITAL_TOKEN_() external returns (address);
|
||||
function _BASE_CAPITAL_TOKEN_() external view returns (address);
|
||||
|
||||
function _QUOTE_CAPITAL_TOKEN_() external returns (address);
|
||||
function _QUOTE_CAPITAL_TOKEN_() external view returns (address);
|
||||
|
||||
function _BASE_TOKEN_() external returns (address);
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import {DecimalMath} from "../lib/DecimalMath.sol";
|
||||
import {SafeERC20} from "../lib/SafeERC20.sol";
|
||||
import {SafeMath} from "../lib/SafeMath.sol";
|
||||
import {IERC20} from "../intf/IERC20.sol";
|
||||
import {IDODORewardVault, DODORewardVault} from "./DODORewardVault.sol";
|
||||
|
||||
|
||||
contract DODOMine is Ownable {
|
||||
@@ -44,7 +45,7 @@ contract DODOMine is Ownable {
|
||||
uint256 accDODOPerShare; // Accumulated DODOs per share, times 1e12. See below.
|
||||
}
|
||||
|
||||
address public dodoToken;
|
||||
address public dodoRewardVault;
|
||||
uint256 public dodoPerBlock;
|
||||
|
||||
// Info of each pool.
|
||||
@@ -65,7 +66,7 @@ contract DODOMine is Ownable {
|
||||
event Claim(address indexed user, uint256 amount);
|
||||
|
||||
constructor(address _dodoToken, uint256 _startBlock) public {
|
||||
dodoToken = _dodoToken;
|
||||
dodoRewardVault = address(new DODORewardVault(_dodoToken));
|
||||
startBlock = _startBlock;
|
||||
}
|
||||
|
||||
@@ -307,9 +308,9 @@ contract DODOMine is Ownable {
|
||||
safeDODOTransfer(msg.sender, pending);
|
||||
}
|
||||
|
||||
// Safe DODO transfer function, just in case if rounding error causes pool to not have enough DODOs.
|
||||
// Safe DODO transfer function
|
||||
function safeDODOTransfer(address _to, uint256 _amount) internal {
|
||||
IERC20(dodoToken).safeTransfer(_to, _amount);
|
||||
IDODORewardVault(dodoRewardVault).reward(_to, _amount);
|
||||
realizedReward[_to] = realizedReward[_to].add(_amount);
|
||||
emit Claim(_to, _amount);
|
||||
}
|
||||
|
||||
44
contracts/token/DODOMineReader.sol
Normal file
44
contracts/token/DODOMineReader.sol
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
|
||||
Copyright 2020 DODO ZOO.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity 0.6.9;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import {IDODO} from "../intf/IDODO.sol";
|
||||
import {IERC20} from "../intf/IERC20.sol";
|
||||
import {SafeMath} from "../lib/SafeMath.sol";
|
||||
|
||||
|
||||
interface IDODOMine {
|
||||
function getUserLpBalance(address _lpToken, address _user) external view returns (uint256);
|
||||
}
|
||||
|
||||
|
||||
contract DODOMineReader {
|
||||
using SafeMath for uint256;
|
||||
|
||||
function getUserStakedBalance(
|
||||
address _dodoMine,
|
||||
address _dodo,
|
||||
address _user
|
||||
) external view returns (uint256 baseBalance, uint256 quoteBalance) {
|
||||
address baseLpToken = IDODO(_dodo)._BASE_CAPITAL_TOKEN_();
|
||||
address quoteLpToken = IDODO(_dodo)._QUOTE_CAPITAL_TOKEN_();
|
||||
|
||||
uint256 baseLpBalance = IDODOMine(_dodoMine).getUserLpBalance(baseLpToken, _user);
|
||||
uint256 quoteLpBalance = IDODOMine(_dodoMine).getUserLpBalance(quoteLpToken, _user);
|
||||
|
||||
uint256 baseLpTotalSupply = IERC20(baseLpToken).totalSupply();
|
||||
uint256 quoteLpTotalSupply = IERC20(quoteLpToken).totalSupply();
|
||||
|
||||
(uint256 baseTarget, uint256 quoteTarget) = IDODO(_dodo).getExpectedTarget();
|
||||
baseBalance = baseTarget.mul(baseLpBalance).div(baseLpTotalSupply);
|
||||
quoteBalance = quoteTarget.mul(quoteLpBalance).div(quoteLpTotalSupply);
|
||||
|
||||
return (baseBalance, quoteBalance);
|
||||
}
|
||||
}
|
||||
33
contracts/token/DODORewardVault.sol
Normal file
33
contracts/token/DODORewardVault.sol
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
|
||||
Copyright 2020 DODO ZOO.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity 0.6.9;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import {Ownable} from "../lib/Ownable.sol";
|
||||
import {SafeERC20} from "../lib/SafeERC20.sol";
|
||||
import {IERC20} from "../intf/IERC20.sol";
|
||||
|
||||
|
||||
interface IDODORewardVault {
|
||||
function reward(address to, uint256 amount) external;
|
||||
}
|
||||
|
||||
|
||||
contract DODORewardVault is Ownable {
|
||||
using SafeERC20 for IERC20;
|
||||
|
||||
address public dodoToken;
|
||||
|
||||
constructor(address _dodoToken) public {
|
||||
dodoToken = _dodoToken;
|
||||
}
|
||||
|
||||
function reward(address to, uint256 amount) external onlyOwner {
|
||||
IERC20(dodoToken).safeTransfer(to, amount);
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ contract DODOToken {
|
||||
using SafeMath for uint256;
|
||||
|
||||
string public symbol = "DODO";
|
||||
string public name = "DODO bird food";
|
||||
string public name = "DODO bird";
|
||||
|
||||
uint256 public decimals = 18;
|
||||
uint256 public totalSupply = 1000000000 * 10**18; // 1 Billion
|
||||
|
||||
Reference in New Issue
Block a user