dodoex / contractv2 Goto Github PK
View Code? Open in Web Editor NEWSmart contracts for DODOEX V2
Home Page: https://app.dodoex.io/
License: Apache License 2.0
Smart contracts for DODOEX V2
Home Page: https://app.dodoex.io/
License: Apache License 2.0
add -
Hi, we recently have conducted a systematic study about Solidity event usage, evolution, and impact, and we are attempting to build a tool to improve the practice of Solidity event use based on our findings. We have tried our prototype tool on some of the most popular GitHub Solidity repositories, and for your repository, we find a potential optimization of gas consumption arisen from event use.
The point is that when we use emit operation to store the value of a certain variable, local memory type variable would be preferable to global storage type (state) variable if they hold the same value. The reason is that an extra SLOAD operation would be needed to access the variable if it is storage type, and the SLOAD operation costs 800 gas.
For your repository, we find that the following event use can be improved:
function updateDODOFeeBurnRatio(uint256 dodoFeeBurnRatio) public onlyOwner {
_DODO_FEE_BURN_RATIO_ = dodoFeeBurnRatio;
emit UpdateDODOFeeBurnRatio(_DODO_FEE_BURN_RATIO_);
}
function changePerReward(uint256 _dodoPerBlock) public onlyOwner {
_updateTotalReward();
dodoPerBlock = _dodoPerBlock;
emit SetPerReward(dodoPerBlock);
}
function name: changeDefaultRate
event name: SetDefaultRate
variable: defaultRate->_defaultRate
function changeDefaultRate(uint256 _defaultRate) public onlyOwner {
defaultRate = _defaultRate;
emit SetDefaultRate(defaultRate);
}
function name: changeDODOProxy
event name: SetNewProxy
variable: DODO_PROXY->_dodoProxy
function changeDODOProxy(address _dodoProxy) public onlyOwner {
_DODO_PROXY_ = _dodoProxy;
emit SetNewProxy(_DODO_PROXY_);
}
function syncValue() external {
uint256 rewardBalance = IERC20(_REWARD_TOKEN_).balanceOf(address(this));
uint256 rewardInput = rewardBalance.sub(_REWARD_RESERVE_);
_TOTAL_REWARD_ = _TOTAL_REWARD_.add(rewardInput);
_REWARD_RESERVE_ = rewardBalance;
emit DepositReward(_TOTAL_REWARD_, rewardInput, _REWARD_RESERVE_);
}
Do you find our results useful? Your reply and invaluable suggestions would be greatly appreciated, and are vital for improving our tool. Thanks a lot for your time!
Hi,
How can I calculate in a contract the amount of Token 1, how much do I need to give to get 1000 Tokens 2 ?
For example, I want to buy in the pool WETH/USDC - 3 WETH, how can I calculate the exact amount USDC that I need to pay?
I looked through DODO v2 contracts and didn't find such a function... UniswapV2 has functions getAmountIn and getAmountOut for this, perhaps DODO v2 has similar functions?
Hi,
I'm not sure I am opening the issue on the right repo. Please let me know if I should open it elsewhere.
Several DODO Pool DVM contract return wrong values for querySellBase or querySellQuote functions. Let me give you one example.
I found the DODO Pool contract for the pair DAI/WBNB from the DVM Factory contract at the address 0x790B4A80Fb1094589A3c0eFC8740aA9b0C1733fB by calling the getDODOPool function with DAI address 0x1af3f329e8be154074d8769d1ffa4ee058b1dbc3 as base token and WBNB address 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c as quote token, it returns the following DVM contract address 0x0aB58740A864d4ffFdefFa39C24Bf2845CdE9a09.
On the pool DVM contract I run querySellBase with 1 GWEI and it returns 996999989, the querySellQuote returns the same value, this is obviously wrong and if I check on DODO app the exchange rate for DAI/WBNB should be around 0,003941 at time of writing.
Am I doing something wrong?
Edit:
After I checked the pair balance on these pools I see they're almost empty so I guess that explains why I get these rates. Am I correct ?
Is this contract the source code of the transaction aggregator contract?
i deploy this code,but i don't understand how to connect every DEX exchange platform?Is this done by contract or by front end?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.