wait to test
This commit is contained in:
@@ -62,7 +62,6 @@ contract DODOIncentive is InitializableOwnable {
|
||||
emit SetBoost(_token, _boostRate);
|
||||
}
|
||||
|
||||
//switch
|
||||
function changePerReward(uint256 _dodoPerBlock) public onlyOwner {
|
||||
_updateTotalReward();
|
||||
dodoPerBlock = _dodoPerBlock;
|
||||
@@ -97,7 +96,8 @@ contract DODOIncentive is InitializableOwnable {
|
||||
uint256 fromRate = boosts[fromToken];
|
||||
uint256 toRate = boosts[toToken];
|
||||
uint256 rate = (fromRate >= toRate ? fromRate : toRate) + defaultRate;
|
||||
|
||||
require(rate <= 1000, "RATE_INVALID");
|
||||
|
||||
uint256 _totalReward = _getTotalReward();
|
||||
uint256 reward = ((_totalReward - curTotalDistribution) * rate) / 1000;
|
||||
uint256 _totalDistribution = curTotalDistribution + reward;
|
||||
|
||||
@@ -8,45 +8,26 @@
|
||||
pragma solidity 0.6.9;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import {ReentrancyGuard} from "../lib/ReentrancyGuard.sol";
|
||||
import {InitializableOwnable} from "../lib/InitializableOwnable.sol";
|
||||
|
||||
interface IFeeRateImpl {
|
||||
function getFeeRate(address pool, address trader) external view returns (uint256);
|
||||
}
|
||||
|
||||
interface IFeeRateModel {
|
||||
function getFeeRate(address trader) external view returns (uint256);
|
||||
function init(address owner, uint256 feeRate) external;
|
||||
function setFeeRate(uint256 newFeeRate) external;
|
||||
}
|
||||
|
||||
contract FeeRateModel is ReentrancyGuard,InitializableOwnable {
|
||||
//DEFAULT
|
||||
uint256 public _FEE_RATE_;
|
||||
mapping(address => uint256) feeMapping;
|
||||
event SetSpecificFeeRate(bool result);
|
||||
event SetFeeRate(bool result);
|
||||
contract FeeRateModel is InitializableOwnable {
|
||||
address public feeRateImpl;
|
||||
|
||||
function setFeeProxy(address _feeRateImpl) public onlyOwner {
|
||||
feeRateImpl = _feeRateImpl;
|
||||
}
|
||||
|
||||
|
||||
function init(address owner, uint256 feeRate) external {
|
||||
initOwner(owner);
|
||||
_FEE_RATE_ = feeRate;
|
||||
}
|
||||
|
||||
function setSpecificFeeRate(address trader, uint256 feeRate, address logicContractAddr) external onlyOwner {
|
||||
bool r;
|
||||
(r, ) = logicContractAddr.delegatecall(abi.encodeWithSignature("setSpecificFeeRate(address,uint256)", trader,feeRate));
|
||||
emit SetSpecificFeeRate(r);
|
||||
}
|
||||
|
||||
function setFeeRate(uint256 newFeeRate, address logicContractAddr) external onlyOwner {
|
||||
bool r;
|
||||
(r, ) = logicContractAddr.delegatecall(abi.encodeWithSignature("setFeeRate(uint256)", newFeeRate));
|
||||
emit SetFeeRate(r);
|
||||
|
||||
}
|
||||
|
||||
function getFeeRate(address trader) external view returns (uint256) {
|
||||
uint256 feeRate = feeMapping[trader];
|
||||
if(feeRate == 0)
|
||||
return _FEE_RATE_;
|
||||
return feeRate;
|
||||
if(feeRateImpl == address(0))
|
||||
return 0;
|
||||
return IFeeRateImpl(feeRateImpl).getFeeRate(msg.sender,trader);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
|
||||
Copyright 2020 DODO ZOO.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity 0.6.9;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import {ReentrancyGuard} from "../lib/ReentrancyGuard.sol";
|
||||
import {InitializableOwnable} from "../lib/InitializableOwnable.sol";
|
||||
|
||||
contract FeeRateModelLogic is ReentrancyGuard,InitializableOwnable {
|
||||
//DEFAULT
|
||||
uint256 public _FEE_RATE_;
|
||||
mapping(address => uint256) feeMapping;
|
||||
|
||||
function setSpecificFeeRate(address trader, uint256 feeRate) external onlyOwner {
|
||||
require(trader != address(0), "INVALID ADDRESS!");
|
||||
feeMapping[trader] = feeRate;
|
||||
}
|
||||
|
||||
function setFeeRate(uint256 newFeeRate) external onlyOwner {
|
||||
_FEE_RATE_ = newFeeRate;
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
/*
|
||||
|
||||
Copyright 2020 DODO ZOO.
|
||||
SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
*/
|
||||
|
||||
// import * as assert from 'assert';
|
||||
|
||||
import { decimalStr, gweiStr } from '../utils/Converter';
|
||||
import { logGas } from '../utils/Log';
|
||||
import { DVMContext, getDVMContext } from '../utils/DVMContext';
|
||||
import { assert } from 'chai';
|
||||
import { EXTERNAL_VALUE_NAME, getContractWithAddress } from '../utils/Contracts';
|
||||
const truffleAssert = require('truffle-assertions');
|
||||
|
||||
let lp: string;
|
||||
let trader: string;
|
||||
|
||||
async function init(ctx: DVMContext): Promise<void> {
|
||||
lp = ctx.SpareAccounts[0];
|
||||
trader = ctx.SpareAccounts[1];
|
||||
|
||||
// await ctx.mintTestToken(lp, decimalStr("10"), decimalStr("1000"));
|
||||
// await ctx.mintTestToken(trader, decimalStr("10"), decimalStr("1000"));
|
||||
|
||||
// await ctx.transferBaseToDVM(lp, decimalStr("10"))
|
||||
// await ctx.DVM.methods.buyShares(lp).send(ctx.sendParam(lp))
|
||||
}
|
||||
|
||||
describe("FeeratemodelUpdate", () => {
|
||||
let snapshotId: string;
|
||||
let ctx: DVMContext;
|
||||
|
||||
before(async () => {
|
||||
ctx = await getDVMContext();
|
||||
await init(ctx);
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
snapshotId = await ctx.EVM.snapshot();
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await ctx.EVM.reset(snapshotId);
|
||||
});
|
||||
|
||||
describe("Feeratemodel", () => {
|
||||
|
||||
it("feeRateUpdate", async () => {
|
||||
var feeRate = await ctx.DVM.methods.getUserFeeRate(lp).call()
|
||||
console.log(feeRate[1])//1000000000000000
|
||||
assert.equal(
|
||||
feeRate[1],
|
||||
"1000000000000000"
|
||||
);
|
||||
|
||||
console.log('~~~~~~~~~~~~~~~~~start set new feerate~~~~~~~~~~~~~~~~~')
|
||||
var feerateLogicAddress = ctx.MtFeeRateModelLogic.options.address;
|
||||
|
||||
await ctx.mtFeeRateModel.methods.setFeeRate(decimalStr("0.003"),feerateLogicAddress).send(ctx.sendParam(ctx.Deployer))
|
||||
var feeRateSet = await ctx.DVM.methods.getUserFeeRate(lp).call()
|
||||
console.log(feeRateSet[1])
|
||||
assert.equal(
|
||||
feeRateSet[1],
|
||||
"3000000000000000"
|
||||
);
|
||||
console.log('~~~~~~~~~~~~~~~~~start update feerateModel~~~~~~~~~~~~~~~~~')
|
||||
//no updatefile.sol found
|
||||
// var feerateLogicUpdateAddress = ctx.MtFeeRateModelLogicUpdate.options.address;
|
||||
// await ctx.mtFeeRateModel.methods.setFeeRate(decimalStr("0.001"),feerateLogicUpdateAddress).send(ctx.sendParam(ctx.Deployer))
|
||||
// var feeRateUpdate = await ctx.DVM.methods.getUserFeeRate(lp).call()
|
||||
// console.log(feeRateUpdate[1])
|
||||
// assert.equal(
|
||||
// feeRateUpdate[1],
|
||||
// "4000000000000000"
|
||||
// );
|
||||
// console.log('~~~~~~~~~~~~~~~~~set feeMapping[trader] ==0 ~~~~~~~~~~~~~~~~~')
|
||||
// await ctx.mtFeeRateModel.methods.setSpecificFeeRate(trader,decimalStr("0.001"),feerateLogicUpdateAddress).send(ctx.sendParam(ctx.Deployer))
|
||||
// var feeRateTrader = await ctx.DVM.methods.getUserFeeRate(trader).call()
|
||||
// console.log(feeRateTrader[1])
|
||||
// assert.equal(// if(feeMapping[trader] == 0) return _FEE_RATE_;
|
||||
// feeRateUpdate[1],
|
||||
// "4000000000000000"
|
||||
// );
|
||||
|
||||
|
||||
})
|
||||
});
|
||||
});
|
||||
@@ -131,35 +131,7 @@ describe("DODOProxyV2.0", () => {
|
||||
|
||||
|
||||
});
|
||||
it("updateFeeRateModel", async () => {
|
||||
var feeRate = await DVM_DODO_USDT.methods.getUserFeeRate(project).call()
|
||||
assert.equal(
|
||||
feeRate[1], //mtFee
|
||||
"0"
|
||||
);
|
||||
var mtFeeResult0 = await DVM_DODO_USDT.methods.querySellQuote(ctx.Deployer, decimalStr("10")).call()
|
||||
assert.equal(
|
||||
mtFeeResult0[1],
|
||||
"0"
|
||||
);
|
||||
|
||||
var feerateLogicAddress = ctx.MtFeeRateModelLogic.options.address;
|
||||
await logGas(await ctx.mtFeeRateModel.methods.setFeeRate(
|
||||
decimalStr("0.03"),
|
||||
feerateLogicAddress
|
||||
), ctx.sendParam(ctx.Deployer), "setFeeRate");
|
||||
var feeRateSet = await DVM_DODO_USDT.methods.getUserFeeRate(project).call()
|
||||
assert.equal(
|
||||
feeRateSet[1],
|
||||
"30000000000000000"
|
||||
);
|
||||
var mtFeeResult1 = await DVM_DODO_USDT.methods.querySellQuote(ctx.Deployer, decimalStr("10")).call()
|
||||
assert.equal(
|
||||
mtFeeResult1[1],
|
||||
"2999999997797182956530"
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
// it("createDVM - ETH", async () => {
|
||||
// var baseToken = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';
|
||||
// var quoteToken = ctx.USDT.options.address;
|
||||
|
||||
@@ -37,8 +37,6 @@ export const PERMISSION_MANAGER_NAME = "PermissionManager"
|
||||
export const EXTERNAL_VALUE_NAME = "ExternalValue"
|
||||
export const DODO_PROXY_NAME = "DODOV2Proxy01"
|
||||
export const FEE_RATE_MODEL_NAME = "FeeRateModel"
|
||||
export const FEE_RATE_MODEL_LOGIC_NAME = "FeeRateModelLogic"
|
||||
export const FEE_RATE_MODEL_LOGIC_UPDATE_NAME = "FeeRateModelLogicUpdate"
|
||||
export const DPP_NAME = "DPP"
|
||||
export const DPP_FACTORY_NAME = "DPPFactory"
|
||||
export const SMART_APPROVE = "DODOApprove"
|
||||
|
||||
@@ -130,7 +130,6 @@ export class CPContext {
|
||||
).send(this.sendParam(this.Deployer))
|
||||
|
||||
await defaultGasSource.methods.init(this.Deployer, MAX_UINT256).send(this.sendParam(this.Deployer));
|
||||
await feeRateModel.methods.init(this.Deployer, decimalStr("0.001")).send(this.sendParam(this.Deployer));
|
||||
|
||||
console.log(log.blueText("[Init CrowdPooling context]"));
|
||||
}
|
||||
|
||||
@@ -59,7 +59,6 @@ export class DVMContext {
|
||||
|
||||
mtFeeRateModel: Contract;
|
||||
|
||||
MtFeeRateModelLogic: Contract;
|
||||
|
||||
constructor() { }
|
||||
|
||||
@@ -106,12 +105,8 @@ export class DVMContext {
|
||||
|
||||
await gasPriceSource.methods.initOwner(this.Deployer).send(this.sendParam(this.Deployer))
|
||||
await gasPriceSource.methods.set(MAX_UINT256).send(this.sendParam(this.Deployer))
|
||||
await lpFeeRateModel.methods.init(this.Deployer, config.lpFeeRate).send(this.sendParam(this.Deployer))
|
||||
await mtFeeRateModel.methods.init(this.Deployer, config.mtFeeRate).send(this.sendParam(this.Deployer))
|
||||
|
||||
|
||||
this.MtFeeRateModelLogic = await contracts.newContract(contracts.FEE_RATE_MODEL_LOGIC_NAME)
|
||||
|
||||
console.log(log.blueText("[Init DVM context]"));
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,6 @@ export class ProxyContext {
|
||||
//Functions
|
||||
DODOIncentive: Contract;
|
||||
mtFeeRateModel: Contract;
|
||||
MtFeeRateModelLogic: Contract;
|
||||
|
||||
Deployer: string;
|
||||
Maintainer: string;
|
||||
@@ -81,8 +80,6 @@ export class ProxyContext {
|
||||
var permissionManagerTemplate = await contracts.newContract(contracts.PERMISSION_MANAGER_NAME)
|
||||
var mtFeeRateModelTemplate = await contracts.newContract(contracts.FEE_RATE_MODEL_NAME)
|
||||
this.mtFeeRateModel = mtFeeRateModelTemplate;
|
||||
// await mtFeeRateModelTemplate.methods.init(this.Deployer,decimalStr("0.01")).send(this.sendParam(this.Deployer));
|
||||
await mtFeeRateModelTemplate.methods.init(this.Deployer,decimalStr("0")).send(this.sendParam(this.Deployer));
|
||||
|
||||
|
||||
this.DVMFactory = await contracts.newContract(contracts.DVM_FACTORY_NAME,
|
||||
@@ -155,10 +152,6 @@ export class ProxyContext {
|
||||
[this.WETH.options.address]
|
||||
)
|
||||
|
||||
|
||||
this.MtFeeRateModelLogic = await contracts.newContract(contracts.FEE_RATE_MODEL_LOGIC_NAME)
|
||||
|
||||
|
||||
console.log(log.blueText("[Init DVM context]"));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user