add crowdpooling pmmstate
This commit is contained in:
@@ -70,61 +70,32 @@ contract CPFunding is CPStorage {
|
||||
function settle() external phaseSettlement preventReentrant {
|
||||
_settle();
|
||||
|
||||
(uint256 poolBase, uint256 poolQuote) = getSettleResult();
|
||||
_UNUSED_QUOTE_ = _QUOTE_TOKEN_.balanceOf(address(this)).sub(poolQuote);
|
||||
_UNUSED_BASE_ = _BASE_TOKEN_.balanceOf(address(this)).sub(poolBase);
|
||||
(uint256 poolBase, uint256 poolQuote, uint256 poolI, uint256 unUsedBase, uint256 unUsedQuote) = getSettleResult();
|
||||
_UNUSED_BASE_ = unUsedBase;
|
||||
_UNUSED_QUOTE_ = unUsedQuote;
|
||||
|
||||
// Try to make midPrice equal to avgPrice
|
||||
// k=1, If quote and base are not balanced, one side must be cut off
|
||||
// DVM truncated quote, but if more quote than base entering the pool, we need set the quote to the base
|
||||
address _poolBaseToken;
|
||||
address _poolQuoteToken;
|
||||
|
||||
// m = avgPrice
|
||||
// i = m (1-quote/(m*base))
|
||||
// if quote = m*base i = 1
|
||||
// if quote > m*base reverse
|
||||
{
|
||||
address _poolBaseToken;
|
||||
address _poolQuoteToken;
|
||||
uint256 _poolI;
|
||||
|
||||
uint256 avgPrice = _UNUSED_BASE_ == 0
|
||||
? _I_
|
||||
: DecimalMath.divCeil(poolQuote, _UNUSED_BASE_);
|
||||
uint256 baseDepth = DecimalMath.mulFloor(avgPrice, poolBase);
|
||||
|
||||
if (poolQuote == 0) {
|
||||
// ask side only DVM
|
||||
_poolBaseToken = address(_BASE_TOKEN_);
|
||||
_poolQuoteToken = address(_QUOTE_TOKEN_);
|
||||
_poolI = _I_;
|
||||
} else if (_UNUSED_BASE_== poolBase) {
|
||||
// standard bonding curve
|
||||
_poolBaseToken = address(_BASE_TOKEN_);
|
||||
_poolQuoteToken = address(_QUOTE_TOKEN_);
|
||||
_poolI = 1;
|
||||
} else if (_UNUSED_BASE_ < poolBase) {
|
||||
// poolI up round
|
||||
_poolBaseToken = address(_BASE_TOKEN_);
|
||||
_poolQuoteToken = address(_QUOTE_TOKEN_);
|
||||
uint256 ratio = DecimalMath.ONE.sub(DecimalMath.divFloor(poolQuote, baseDepth));
|
||||
_poolI = avgPrice.mul(ratio).mul(ratio).divCeil(DecimalMath.ONE2);
|
||||
} else if (_UNUSED_BASE_ > poolBase) {
|
||||
// poolI down round
|
||||
_poolBaseToken = address(_QUOTE_TOKEN_);
|
||||
_poolQuoteToken = address(_BASE_TOKEN_);
|
||||
uint256 ratio = DecimalMath.ONE.sub(DecimalMath.divCeil(baseDepth, poolQuote));
|
||||
_poolI = ratio.mul(ratio).div(avgPrice);
|
||||
}
|
||||
_POOL_ = IDVMFactory(_POOL_FACTORY_).createDODOVendingMachine(
|
||||
_poolBaseToken,
|
||||
_poolQuoteToken,
|
||||
3e15, // 0.3% lp feeRate
|
||||
_poolI,
|
||||
DecimalMath.ONE
|
||||
);
|
||||
_AVG_SETTLED_PRICE_ = avgPrice;
|
||||
if (_UNUSED_BASE_ > poolBase) {
|
||||
_poolBaseToken = address(_QUOTE_TOKEN_);
|
||||
_poolQuoteToken = address(_BASE_TOKEN_);
|
||||
} else {
|
||||
_poolBaseToken = address(_BASE_TOKEN_);
|
||||
_poolQuoteToken = address(_QUOTE_TOKEN_);
|
||||
}
|
||||
|
||||
_POOL_ = IDVMFactory(_POOL_FACTORY_).createDODOVendingMachine(
|
||||
_poolBaseToken,
|
||||
_poolQuoteToken,
|
||||
3e15, // 0.3% lp feeRate
|
||||
poolI,
|
||||
DecimalMath.ONE
|
||||
);
|
||||
|
||||
uint256 avgPrice = unUsedBase == 0 ? _I_ : DecimalMath.divCeil(poolQuote, unUsedBase);
|
||||
_AVG_SETTLED_PRICE_ = avgPrice;
|
||||
|
||||
_transferBaseOut(_POOL_, poolBase);
|
||||
_transferQuoteOut(_POOL_, poolQuote);
|
||||
|
||||
@@ -148,13 +119,43 @@ contract CPFunding is CPStorage {
|
||||
|
||||
// ============ Pricing ============
|
||||
|
||||
function getSettleResult() public view returns (uint256 poolBase, uint256 poolQuote) {
|
||||
function getSettleResult() public view returns (uint256 poolBase, uint256 poolQuote, uint256 poolI, uint256 unUsedBase, uint256 unUsedQuote) {
|
||||
poolQuote = _QUOTE_TOKEN_.balanceOf(address(this));
|
||||
if (poolQuote > _POOL_QUOTE_CAP_) {
|
||||
poolQuote = _POOL_QUOTE_CAP_;
|
||||
}
|
||||
(uint256 soldBase,) = PMMPricing.sellQuoteToken(_getPMMState(), poolQuote);
|
||||
poolBase = _TOTAL_BASE_.sub(soldBase);
|
||||
|
||||
unUsedQuote = _QUOTE_TOKEN_.balanceOf(address(this)).sub(poolQuote);
|
||||
unUsedBase = _BASE_TOKEN_.balanceOf(address(this)).sub(poolBase);
|
||||
|
||||
// Try to make midPrice equal to avgPrice
|
||||
// k=1, If quote and base are not balanced, one side must be cut off
|
||||
// DVM truncated quote, but if more quote than base entering the pool, we need set the quote to the base
|
||||
|
||||
// m = avgPrice
|
||||
// i = m (1-quote/(m*base))
|
||||
// if quote = m*base i = 1
|
||||
// if quote > m*base reverse
|
||||
uint256 avgPrice = unUsedBase == 0 ? _I_ : DecimalMath.divCeil(poolQuote, unUsedBase);
|
||||
uint256 baseDepth = DecimalMath.mulFloor(avgPrice, poolBase);
|
||||
|
||||
if (poolQuote == 0) {
|
||||
// ask side only DVM
|
||||
poolI = _I_;
|
||||
} else if (unUsedBase== poolBase) {
|
||||
// standard bonding curve
|
||||
poolI = 1;
|
||||
} else if (unUsedBase < poolBase) {
|
||||
// poolI up round
|
||||
uint256 ratio = DecimalMath.ONE.sub(DecimalMath.divFloor(poolQuote, baseDepth));
|
||||
poolI = avgPrice.mul(ratio).mul(ratio).divCeil(DecimalMath.ONE2);
|
||||
} else if (unUsedBase > poolBase) {
|
||||
// poolI down round
|
||||
uint256 ratio = DecimalMath.ONE.sub(DecimalMath.divCeil(baseDepth, poolQuote));
|
||||
poolI = ratio.mul(ratio).div(avgPrice);
|
||||
}
|
||||
}
|
||||
|
||||
function _getPMMState() internal view returns (PMMPricing.PMMState memory state) {
|
||||
@@ -169,7 +170,7 @@ contract CPFunding is CPStorage {
|
||||
|
||||
function getExpectedAvgPrice() external view returns (uint256) {
|
||||
require(!_SETTLED_, "ALREADY_SETTLED");
|
||||
(uint256 poolBase, uint256 poolQuote) = getSettleResult();
|
||||
(uint256 poolBase, uint256 poolQuote, , , ) = getSettleResult();
|
||||
return DecimalMath.divCeil(poolQuote, _BASE_TOKEN_.balanceOf(address(this)).sub(poolBase));
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,8 @@ contract DPPTrader is DPPVault {
|
||||
address toToken,
|
||||
uint256 fromAmount,
|
||||
uint256 toAmount,
|
||||
address trader
|
||||
address trader,
|
||||
address receiver
|
||||
);
|
||||
|
||||
event DODOFlashLoan(
|
||||
@@ -67,7 +68,8 @@ contract DPPTrader is DPPVault {
|
||||
address(_QUOTE_TOKEN_),
|
||||
baseInput,
|
||||
receiveQuoteAmount,
|
||||
msg.sender
|
||||
msg.sender,
|
||||
to
|
||||
);
|
||||
}
|
||||
|
||||
@@ -103,7 +105,8 @@ contract DPPTrader is DPPVault {
|
||||
address(_BASE_TOKEN_),
|
||||
quoteInput,
|
||||
receiveBaseAmount,
|
||||
msg.sender
|
||||
msg.sender,
|
||||
to
|
||||
);
|
||||
}
|
||||
|
||||
@@ -152,7 +155,8 @@ contract DPPTrader is DPPVault {
|
||||
address(_BASE_TOKEN_),
|
||||
quoteInput,
|
||||
receiveBaseAmount,
|
||||
msg.sender
|
||||
msg.sender,
|
||||
assetTo
|
||||
);
|
||||
}
|
||||
|
||||
@@ -180,7 +184,8 @@ contract DPPTrader is DPPVault {
|
||||
address(_QUOTE_TOKEN_),
|
||||
baseInput,
|
||||
receiveQuoteAmount,
|
||||
msg.sender
|
||||
msg.sender,
|
||||
assetTo
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,8 @@ contract DVMTrader is DVMVault {
|
||||
address toToken,
|
||||
uint256 fromAmount,
|
||||
uint256 toAmount,
|
||||
address trader
|
||||
address trader,
|
||||
address receiver
|
||||
);
|
||||
|
||||
event DODOFlashLoan(
|
||||
@@ -56,7 +57,8 @@ contract DVMTrader is DVMVault {
|
||||
address(_QUOTE_TOKEN_),
|
||||
baseInput,
|
||||
receiveQuoteAmount,
|
||||
msg.sender
|
||||
msg.sender,
|
||||
to
|
||||
);
|
||||
}
|
||||
|
||||
@@ -79,7 +81,8 @@ contract DVMTrader is DVMVault {
|
||||
address(_BASE_TOKEN_),
|
||||
quoteInput,
|
||||
receiveBaseAmount,
|
||||
msg.sender
|
||||
msg.sender,
|
||||
to
|
||||
);
|
||||
}
|
||||
|
||||
@@ -116,7 +119,8 @@ contract DVMTrader is DVMVault {
|
||||
address(_BASE_TOKEN_),
|
||||
quoteInput,
|
||||
receiveBaseAmount,
|
||||
msg.sender
|
||||
msg.sender,
|
||||
assetTo
|
||||
);
|
||||
}
|
||||
|
||||
@@ -132,7 +136,8 @@ contract DVMTrader is DVMVault {
|
||||
address(_QUOTE_TOKEN_),
|
||||
baseInput,
|
||||
receiveQuoteAmount,
|
||||
msg.sender
|
||||
msg.sender,
|
||||
assetTo
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -88,3 +88,9 @@ Deploy time: 2021/1/11 上午10:23:58
|
||||
Deploy type: Proxy
|
||||
DODOProxyV2 Address: 0x6ed3fd491F5B10384787B3fb162A72227FaFBf63
|
||||
Set DODOProxyV2 Owner tx: 0x438ba2bfcee92e641a3e48709de31bd0e2fcb9866d30f6d73be837e3b42bd551
|
||||
====================================================
|
||||
network type: bsclive
|
||||
Deploy time: 2021/1/15 上午12:16:50
|
||||
Deploy type: Proxy
|
||||
DODOProxyV2 Address: 0x66EEdd38f757d8F9A0b7B4f47d3f74A09C7a1F37
|
||||
Set DODOProxyV2 Owner tx: 0x832e2f880fc6798d87ea1aa8f56fd8f6cdd14a9dde62278fd5a1716c073dcb7a
|
||||
|
||||
@@ -257,3 +257,23 @@ DODOProxyV2 Address: 0x06B5D7590297F7b0DcEcC5E382938EB562D91e1a
|
||||
Init DODOProxyV2 Tx: 0x1951bece5f30c090c6e6cdd121ddb5cfa17a5ca610e30173ec2e12e8698a6c21
|
||||
DODOApprove Init tx: 0xf3a9ff215e335405086c44d11e377cddeef39cb8b028f011cb6ffc1362c03f6e
|
||||
DODOIncentive ChangeProxy tx: 0xc722cf182f24e03b6ccbc19f261452f1a6019f77b32c4350be8df26c069290f0
|
||||
====================================================
|
||||
network type: kovan
|
||||
Deploy time: 2021/1/15 上午11:29:53
|
||||
Deploy type: V2
|
||||
DvmTemplateAddress: 0xD47B0782EDdAc44Bd2B6a51C949feaE9Af382A51
|
||||
DppTemplateAddress: 0xA0C3C6Ad75fBfaCb490E315BA762A6D20084b5a8
|
||||
CpTemplateAddress: 0x782A2615b4fD7DA26C076eB9F33200510395C739
|
||||
DODOApprove Address: 0x5e56Db19C3f52594876E2A3e1a47d15acD8DC570
|
||||
DODOIncentiveAddress: 0xDcD1d44Bb885e8ce2dc66ffDE8868ABb642eA45a
|
||||
DODOIncentive Init tx: 0x983db721a440e582421d873c7c445844b3d271caccce92bf47e74442cc309d47
|
||||
DvmFactoryAddress: 0x01B7fCc1890Ab90Da33dE2F0dC54aDF3C7501F04
|
||||
Init DvmFactory Tx: 0xaeb84028d484b12594cb796fb8fdb93e48fb0458e0b853afc8589f3eb9cabd11
|
||||
DppFactoryAddress: 0x67c4765D04C3848FFa7967231fc7B7E58f67A887
|
||||
Init DppFactory Tx: 0x5b2ac8ff39586400a4d3f0fdbd1e6e26c0208559362899d018f1859ec5cd2576
|
||||
CpFactoryAddress: 0x671429f12243DE03BF9826ea6cB88c41CF2a2AAA
|
||||
DODOV2RouteHelper Address: 0x0546641b5288942675A36345E25210695d1d4d50
|
||||
DODOProxyV2 Address: 0xA730229607b710cd06AEAad1eDc644Dbb70A5E85
|
||||
Init DODOProxyV2 Tx: 0x70d3a11f506ca6bb54343ad9b92d40e799c146c4acb6c6b8104bac30e5909722
|
||||
DODOApprove Init tx: 0x60bdfcf5a37bcf3568d9e98e3d32acc9289515184305282dd035475c195e0d6e
|
||||
DODOIncentive ChangeProxy tx: 0xf34b766489b5833970e01a412c725ef0ae18043e5c421bdafacca2dfe7cb904a
|
||||
|
||||
@@ -316,3 +316,22 @@ Deploy time: 2021/1/13 下午9:51:04
|
||||
Mock POOL Tx: V2
|
||||
Create DVM: 0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE-0x5eca15b12d959dfcf9c71c59f8b467eb8c6efd0b Pool:0xec6675ba2B9f978EF5bFBEa391b1c42bA74E340A Tx: 0xd417e65c4e437a1e2ea2432c149393869d6d6b8d5de68cd361455395a2441e7b
|
||||
Create DVM: 0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA-0x5eca15b12d959dfcf9c71c59f8b467eb8c6efd0b Pool:0xF4833EDaEfdBf28e246ade2d82EA7087Bc106C8F Tx: 0xad1ce8f0fbd5b937055f62a0c4e6024ef32cdf40bcbb8033cbeccdbf314ce9c3
|
||||
====================================================
|
||||
network type: kovan
|
||||
Deploy time: 2021/1/15 上午11:38:46
|
||||
====================================================
|
||||
network type: kovan
|
||||
Deploy time: 2021/1/15 下午1:16:41
|
||||
Mock POOL Tx: V2
|
||||
Approve:0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE Tx: 0xe444614656997e88abc7f8a319cbd636b60802c0272233c4784b55de2b4bb8f0
|
||||
Approve:0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA Tx: 0x52bd6229a1202a75dab8f22169054d4d6ed1d661550e92eb4ca63fbcfb04c90f
|
||||
Approve:0x43688f367eb83697c3ca5d03c5055b6bd6f6ac4b Tx: 0xb621fd266c2adcb6362f631ceb193016e14dc55f13979ae854fddb19c5b3ad52
|
||||
Approve:0x156595bAF85D5C29E91d959889B022d952190A64 Tx: 0x263259a175711b1b8dad83fd72bbe3b7a6ca9f9eff0b53499e1394a47ada71db
|
||||
Create DVM: 0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE-0x43688f367eb83697c3ca5d03c5055b6bd6f6ac4b Pool:0x715f1aE436Db8AFB9Cb1B4fc94010479b80Ef852 Tx: 0x42bd2b2bb8b8cb09d8e115b4e1f289f8de024712caa5faa2189ab999b4accb76
|
||||
Create DVM: 0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE-0x156595bAF85D5C29E91d959889B022d952190A64 Pool:0x375981e1D3350ae0A30e53eD8C3aC004d4D89bDe Tx: 0xa293d0d532038b7ed0e30d7afbfdd3ba3464c8aee20a3f256baee5ed9c5bde66
|
||||
Create DVM: 0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA-0x43688f367eb83697c3ca5d03c5055b6bd6f6ac4b Pool:0x8dd53F0ba04C1e3f293D8a8a6a2143205EC4a34c Tx: 0x963cea093acc669f510a4123dbd03ab66a6cda6295e71e860e1c8ea89cdf1363
|
||||
Create DVM: 0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA-0x156595bAF85D5C29E91d959889B022d952190A64 Pool:0x773B12fdDbD3C41f479601F57DBca99E70f2e0bD Tx: 0xb08223246a75df541511ac9d765bfdc204748f1ee6467ebb8589ebc42c45f185
|
||||
Create DPP: 0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE-0x43688f367eb83697c3ca5d03c5055b6bd6f6ac4b Pool:0xeC0fe30c2028b28b90E5e7bfd7AF5B76E6Eed000 Tx: 0x245f55404c3636b40e4c86b0ee22c4bae3a95f908a3bb07409a0e88bc88304df
|
||||
Create DPP: 0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE-0x156595bAF85D5C29E91d959889B022d952190A64 Pool:0x14D4E63d050f235D8bf1Fd3dD3CDc484168FB246 Tx: 0xed71901c2c96d8b9d39839bf47f0efe8caf06fc0e8f6156a989c4d60c0dd927b
|
||||
Create DPP: 0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA-0x43688f367eb83697c3ca5d03c5055b6bd6f6ac4b Pool:0x82a777E65d14D462cdb8fE1886115Bbbc1F24039 Tx: 0x10360317368344c2e1519aba4fff57e6c247c0c4d95adeba1aac5c1e917acdbb
|
||||
Create DPP: 0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA-0x156595bAF85D5C29E91d959889B022d952190A64 Pool:0xBA9b148769BdF0D872439ac31Ff103D487e10f64 Tx: 0x912cf081eb7e8abeae94c3dbb45b745e926d0aec76387ba897dc0e49fc660378
|
||||
|
||||
@@ -32,7 +32,7 @@ module.exports = async (deployer, network, accounts) => {
|
||||
} else if (network == "bsclive") {
|
||||
DODOSellHelperAddress = "0x0F859706AeE7FcF61D5A8939E8CB9dBB6c1EDA33";
|
||||
WETHAddress = "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c";
|
||||
DODOApproveAddress = "";
|
||||
DODOApproveAddress = "0xa128Ba44B2738A558A1fdC06d6303d52D3Cef8c1";
|
||||
chiAddress = "0x0000000000000000000000000000000000000000";
|
||||
DODOSwapCalcHelperAddress = "0xb0199C2c8ADF1E6c1e41De60A62E993406Cb8C02";
|
||||
ownerAddress = "0x4073f2b9bB95774531b9e23d206a308c614A943a";
|
||||
|
||||
@@ -69,7 +69,7 @@ module.exports = async (deployer, network, accounts) => {
|
||||
WETHAddress = "0x5eca15b12d959dfcf9c71c59f8b467eb8c6efd0b";
|
||||
chiAddress = "0x0000000000004946c0e9f43f4dee607b0ef1fa1c";
|
||||
DODOCalleeHelperAddress = "0x507EBbb195CF54E0aF147A2b269C08a38EA36989";
|
||||
DODORouteV2HelperAddress = "0xcA79C9431aB16857f78f9F7EE56Ff698bD518533";
|
||||
DODORouteV2HelperAddress = "";
|
||||
//Template
|
||||
CloneFactoryAddress = "0xf7959fe661124C49F96CF30Da33729201aEE1b27";
|
||||
// FeeRateModelTemplateAddress = "0xEF3137780B387313c5889B999D03BdCf9aeEa892";
|
||||
@@ -81,14 +81,14 @@ module.exports = async (deployer, network, accounts) => {
|
||||
DefaultMtFeeRateAddress = "0xEfdE4225AC747136289979e29f1236527b2E4DB1";
|
||||
DefaultPermissionAddress = "0xACc7E23368261e1E02103c4e5ae672E7D01f5797";
|
||||
|
||||
DvmTemplateAddress = "0xC61dD1a8C0242785E290CA41bA84AB319c94FF55";
|
||||
DppTemplateAddress = "0xF89DBd5e716748A5C0d8a081bED1BF554B50dc59";
|
||||
DvmTemplateAddress = "";
|
||||
DppTemplateAddress = "";
|
||||
DppAdminTemplateAddress = "0xe39E02c4f269c4E235Ca8979a125608644c8924a";
|
||||
CpTemplateAddress = "0x55f940C2244Bb16735baCF7D090134fe636d47ea";
|
||||
CpTemplateAddress = "";
|
||||
//Factory
|
||||
DvmFactoryAddress = "0xdd3dDDaae565E7745b2cAcD980B8a98546bAb978";
|
||||
DppFactoryAddress = "0x36ab096ADBfd1491FE90F56a9C782dE7b1019f7c";
|
||||
CpFactoryAddress = "0xDaB9B619A78Fca5FC2f562C5b41Bf44f74c1c239";
|
||||
DvmFactoryAddress = "";
|
||||
DppFactoryAddress = "";
|
||||
CpFactoryAddress = "";
|
||||
//Approve
|
||||
DODOApproveAddress = "";
|
||||
DODOIncentiveAddress = "";
|
||||
@@ -367,14 +367,8 @@ module.exports = async (deployer, network, accounts) => {
|
||||
logger.log("DODOIncentive ChangeProxy tx: ", tx.tx);
|
||||
|
||||
//3. Open trade incentive
|
||||
// const provider = new Web3.providers.HttpProvider("https://kovan.infura.io/v3/22d4a3b2df0e47b78d458f43fe50a199");
|
||||
// if (!provider) {
|
||||
// throw new Error(`Unable to find provider for network: ${network}`)
|
||||
// }
|
||||
// const web3 = new Web3(provider)
|
||||
// const blockNum = await web3.eth.getBlockNumber();
|
||||
// var tx = await DODOIncentiveInstance.switchIncentive(blockNum + 1);
|
||||
// logger.log("DODOIncentive OpenSwitch tx: ", tx.tx);
|
||||
var tx = await DODOIncentiveInstance.changePerReward(10);
|
||||
logger.log("DODOIncentive OpenSwitch tx: ", tx.tx);
|
||||
|
||||
//4. Transfer DODO to Trade Incentive
|
||||
}
|
||||
|
||||
@@ -13,48 +13,48 @@ const DVMFactory = artifacts.require("DVMFactory");
|
||||
const DPPFactory = artifacts.require("DPPFactory");
|
||||
|
||||
const POOL_PARAM = [
|
||||
// {
|
||||
// baseAddr: "0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE", //ABC0
|
||||
// quoteAddr: "0x43688f367eb83697c3ca5d03c5055b6bd6f6ac4b", //USDC
|
||||
// lpFeeRate: "0", //0
|
||||
// i: "10000000", //10
|
||||
// k: "500000000000000000" //0.5
|
||||
// },
|
||||
// {
|
||||
// baseAddr: "0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE", //ABC0
|
||||
// quoteAddr: "0x156595bAF85D5C29E91d959889B022d952190A64", //USDT
|
||||
// lpFeeRate: "3000000000000000", //0.003
|
||||
// i: "10000000", //10
|
||||
// k: "0" //0
|
||||
// },
|
||||
// {
|
||||
// baseAddr: "0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA", //ABC1
|
||||
// quoteAddr: "0x43688f367eb83697c3ca5d03c5055b6bd6f6ac4b", //USDC
|
||||
// lpFeeRate: "0", //0
|
||||
// i: "5000000", //5
|
||||
// k: "700000000000000000" //1
|
||||
// },
|
||||
// {
|
||||
// baseAddr: "0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA", //ABC1
|
||||
// quoteAddr: "0x156595bAF85D5C29E91d959889B022d952190A64", //USDT
|
||||
// lpFeeRate: "3000000000000000", //0.003
|
||||
// i: "8000000", //8
|
||||
// k: "900000000000000000" //0.9
|
||||
// },
|
||||
{
|
||||
baseAddr: "0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE", //ABC0
|
||||
quoteAddr: "0x5eca15b12d959dfcf9c71c59f8b467eb8c6efd0b", //WETH
|
||||
quoteAddr: "0x43688f367eb83697c3ca5d03c5055b6bd6f6ac4b", //USDC
|
||||
lpFeeRate: "0", //0
|
||||
i: "10000000", //10
|
||||
k: "500000000000000000" //0.5
|
||||
},
|
||||
{
|
||||
baseAddr: "0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE", //ABC0
|
||||
quoteAddr: "0x156595bAF85D5C29E91d959889B022d952190A64", //USDT
|
||||
lpFeeRate: "3000000000000000", //0.003
|
||||
i: "45000000000000000000", //45
|
||||
k: "800000000000000000" //0.8
|
||||
i: "10000000", //10
|
||||
k: "0" //0
|
||||
},
|
||||
{
|
||||
baseAddr: "0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA", //ABC1
|
||||
quoteAddr: "0x5eca15b12d959dfcf9c71c59f8b467eb8c6efd0b", //WETH
|
||||
lpFeeRate: "0", //0.003
|
||||
i: "30000000000000000000", //30
|
||||
k: "300000000000000000" //0.3
|
||||
quoteAddr: "0x43688f367eb83697c3ca5d03c5055b6bd6f6ac4b", //USDC
|
||||
lpFeeRate: "0", //0
|
||||
i: "5000000", //5
|
||||
k: "700000000000000000" //1
|
||||
},
|
||||
{
|
||||
baseAddr: "0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA", //ABC1
|
||||
quoteAddr: "0x156595bAF85D5C29E91d959889B022d952190A64", //USDT
|
||||
lpFeeRate: "3000000000000000", //0.003
|
||||
i: "8000000", //8
|
||||
k: "900000000000000000" //0.9
|
||||
},
|
||||
// {
|
||||
// baseAddr: "0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE", //ABC0
|
||||
// quoteAddr: "0x5eca15b12d959dfcf9c71c59f8b467eb8c6efd0b", //WETH
|
||||
// lpFeeRate: "3000000000000000", //0.003
|
||||
// i: "45000000000000000000", //45
|
||||
// k: "800000000000000000" //0.8
|
||||
// },
|
||||
// {
|
||||
// baseAddr: "0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA", //ABC1
|
||||
// quoteAddr: "0x5eca15b12d959dfcf9c71c59f8b467eb8c6efd0b", //WETH
|
||||
// lpFeeRate: "0", //0.003
|
||||
// i: "30000000000000000000", //30
|
||||
// k: "300000000000000000" //0.3
|
||||
// },
|
||||
];
|
||||
|
||||
module.exports = async (deployer, network, accounts) => {
|
||||
@@ -64,10 +64,10 @@ module.exports = async (deployer, network, accounts) => {
|
||||
let MintableERC20TemplateAddress = "0xA45a64DAba80757432fA4d654Df12f65f020C13C";
|
||||
let ERC20FactoryAddress = "0xCb1A2f64EfB02803276BFB5a8D511C4D950282a0";
|
||||
|
||||
let DPPFactoryAddress = "0x36ab096ADBfd1491FE90F56a9C782dE7b1019f7c";
|
||||
let DVMFactoryAddress = "0xdd3dDDaae565E7745b2cAcD980B8a98546bAb978";
|
||||
let DODOApproveAddress = "0xFa3C805fDE678E93C3d0954F20471799f892F81d";
|
||||
let DODOProxyV2Address = "0x06B5D7590297F7b0DcEcC5E382938EB562D91e1a";
|
||||
let DPPFactoryAddress = "0x67c4765D04C3848FFa7967231fc7B7E58f67A887";
|
||||
let DVMFactoryAddress = "0x01B7fCc1890Ab90Da33dE2F0dC54aDF3C7501F04";
|
||||
let DODOApproveAddress = "0x5e56Db19C3f52594876E2A3e1a47d15acD8DC570";
|
||||
let DODOProxyV2Address = "0xA730229607b710cd06AEAad1eDc644Dbb70A5E85";
|
||||
|
||||
const provider = new Web3.providers.HttpProvider("https://kovan.infura.io/v3/22d4a3b2df0e47b78d458f43fe50a199");
|
||||
|
||||
@@ -112,49 +112,49 @@ module.exports = async (deployer, network, accounts) => {
|
||||
if (deploySwitch.MOCK_V2_POOL) {
|
||||
logger.log("Mock POOL Tx: V2");
|
||||
var tx;
|
||||
// {//Approve when change DODOApprove Address
|
||||
// const token0Addr = "0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE";
|
||||
// const token1Addr = "0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA";
|
||||
// // const token2Addr = "0xFE1133ea03d701C5006b7f065bBf987955E7A67C";
|
||||
// // const token3Addr = "0x123ee47BaE3F64d422F2FB18ac444B47c1880F4C";
|
||||
// // const token4Addr = "0x0ab8EF8B19655F32959c83e5fC5cD6536065D28f";
|
||||
// // const token5Addr = "0x6462794c19e6b4543BEC56200212c7c746bbB9eB";
|
||||
// const quote0Addr = "0x43688f367eb83697c3ca5d03c5055b6bd6f6ac4b";
|
||||
// const quote1Addr = "0x156595bAF85D5C29E91d959889B022d952190A64";
|
||||
// const token0 = await ERC20Template.at(token0Addr);
|
||||
// const token1 = await ERC20Template.at(token1Addr);
|
||||
// // const token2 = await ERC20Template.at(token2Addr);
|
||||
// // const token3 = await ERC20Template.at(token3Addr);
|
||||
// // const token4 = await ERC20Template.at(token4Addr);
|
||||
// // const token5 = await ERC20Template.at(token5Addr);
|
||||
// const quote0 = await ERC20Template.at(quote0Addr);
|
||||
// const quote1 = await ERC20Template.at(quote1Addr);
|
||||
{//Approve when change DODOApprove Address
|
||||
const token0Addr = "0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE";
|
||||
const token1Addr = "0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA";
|
||||
// const token2Addr = "0xFE1133ea03d701C5006b7f065bBf987955E7A67C";
|
||||
// const token3Addr = "0x123ee47BaE3F64d422F2FB18ac444B47c1880F4C";
|
||||
// const token4Addr = "0x0ab8EF8B19655F32959c83e5fC5cD6536065D28f";
|
||||
// const token5Addr = "0x6462794c19e6b4543BEC56200212c7c746bbB9eB";
|
||||
const quote0Addr = "0x43688f367eb83697c3ca5d03c5055b6bd6f6ac4b";
|
||||
const quote1Addr = "0x156595bAF85D5C29E91d959889B022d952190A64";
|
||||
const token0 = await ERC20Template.at(token0Addr);
|
||||
const token1 = await ERC20Template.at(token1Addr);
|
||||
// const token2 = await ERC20Template.at(token2Addr);
|
||||
// const token3 = await ERC20Template.at(token3Addr);
|
||||
// const token4 = await ERC20Template.at(token4Addr);
|
||||
// const token5 = await ERC20Template.at(token5Addr);
|
||||
const quote0 = await ERC20Template.at(quote0Addr);
|
||||
const quote1 = await ERC20Template.at(quote1Addr);
|
||||
|
||||
// tx = await token0.approve(DODOApproveAddress, "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
// logger.log("Approve:" + token0Addr + " Tx:", tx.tx);
|
||||
// tx = await token1.approve(DODOApproveAddress, "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
// logger.log("Approve:" + token1Addr + " Tx:", tx.tx);
|
||||
// // tx = await token2.approve(DODOApproveAddress, "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
// // logger.log("Approve:" + token2Addr + " Tx:", tx.tx);
|
||||
// // tx = await token3.approve(DODOApproveAddress, "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
// // logger.log("Approve:" + token3Addr + " Tx:", tx.tx);
|
||||
// // tx = await token4.approve(DODOApproveAddress, "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
// // logger.log("Approve:" + token4Addr + " Tx:", tx.tx);
|
||||
// // tx = await token5.approve(DODOApproveAddress, "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
// // logger.log("Approve:" + token5Addr + " Tx:", tx.tx);
|
||||
// tx = await quote0.approve(DODOApproveAddress, "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
// logger.log("Approve:" + quote0Addr + " Tx:", tx.tx);
|
||||
// tx = await quote1.approve(DODOApproveAddress, "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
// logger.log("Approve:" + quote1Addr + " Tx:", tx.tx);
|
||||
// }
|
||||
tx = await token0.approve(DODOApproveAddress, "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
logger.log("Approve:" + token0Addr + " Tx:", tx.tx);
|
||||
tx = await token1.approve(DODOApproveAddress, "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
logger.log("Approve:" + token1Addr + " Tx:", tx.tx);
|
||||
// tx = await token2.approve(DODOApproveAddress, "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
// logger.log("Approve:" + token2Addr + " Tx:", tx.tx);
|
||||
// tx = await token3.approve(DODOApproveAddress, "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
// logger.log("Approve:" + token3Addr + " Tx:", tx.tx);
|
||||
// tx = await token4.approve(DODOApproveAddress, "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
// logger.log("Approve:" + token4Addr + " Tx:", tx.tx);
|
||||
// tx = await token5.approve(DODOApproveAddress, "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
// logger.log("Approve:" + token5Addr + " Tx:", tx.tx);
|
||||
tx = await quote0.approve(DODOApproveAddress, "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
logger.log("Approve:" + quote0Addr + " Tx:", tx.tx);
|
||||
tx = await quote1.approve(DODOApproveAddress, "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
logger.log("Approve:" + quote1Addr + " Tx:", tx.tx);
|
||||
}
|
||||
const DODOProxyV2Instance = await DODOProxyV2.at(DODOProxyV2Address);
|
||||
const DVMFactoryInstance = await DVMFactory.at(DVMFactoryAddress);
|
||||
const DPPFactoryInstance = await DPPFactory.at(DPPFactoryAddress);
|
||||
|
||||
const assetTo = accounts[0];
|
||||
const baseInAmount = web3.utils.toWei("100000", 'ether');
|
||||
// const quoteInAmount = web3.utils.toWei("10000", 'mwei');
|
||||
const quoteInAmount = web3.utils.toWei("0.5", 'ether');
|
||||
const quoteInAmount = web3.utils.toWei("10000", 'mwei');
|
||||
// const quoteInAmount = web3.utils.toWei("0.5", 'ether');
|
||||
const deadline = Math.floor(new Date().getTime() / 1000 + 60 * 10);
|
||||
//DVM Pool
|
||||
for (var i = 0; i < POOL_PARAM.length; i++) {
|
||||
|
||||
@@ -39,9 +39,9 @@ module.exports = {
|
||||
*/
|
||||
deploySwitch: {
|
||||
DEPLOY_V1: false,
|
||||
DEPLOY_V2: true,
|
||||
DEPLOY_V2: false,
|
||||
MOCK_TOKEN: false,
|
||||
MOCK_V2_POOL: false,
|
||||
MOCK_V2_POOL: true,
|
||||
MOCK_V2_SWAP: false,
|
||||
MANUAL_ADD_POOL: false,
|
||||
ROUTER_HELPER: false
|
||||
|
||||
Reference in New Issue
Block a user