This commit is contained in:
owen05
2021-01-21 19:22:56 +08:00
parent 13bd041af7
commit 1c8d393ae1
2 changed files with 7 additions and 4 deletions

View File

@@ -53,8 +53,7 @@ contract DPPTrader is DPPVault {
_transferQuoteOut(to, receiveQuoteAmount); _transferQuoteOut(to, receiveQuoteAmount);
_transferQuoteOut(_MAINTAINER_, mtFee); _transferQuoteOut(_MAINTAINER_, mtFee);
_setReserve(baseBalance, _QUOTE_TOKEN_.balanceOf(address(this)));
// update TARGET // update TARGET
if (_RState_ != uint32(newRState)) { if (_RState_ != uint32(newRState)) {
require(newBaseTarget <= uint112(-1),"OVERFLOW"); require(newBaseTarget <= uint112(-1),"OVERFLOW");
@@ -63,6 +62,8 @@ contract DPPTrader is DPPVault {
emit RChange(newRState); emit RChange(newRState);
} }
_setReserve(baseBalance, _QUOTE_TOKEN_.balanceOf(address(this)));
emit DODOSwap( emit DODOSwap(
address(_BASE_TOKEN_), address(_BASE_TOKEN_),
address(_QUOTE_TOKEN_), address(_QUOTE_TOKEN_),
@@ -90,7 +91,6 @@ contract DPPTrader is DPPVault {
_transferBaseOut(to, receiveBaseAmount); _transferBaseOut(to, receiveBaseAmount);
_transferBaseOut(_MAINTAINER_, mtFee); _transferBaseOut(_MAINTAINER_, mtFee);
_setReserve(_BASE_TOKEN_.balanceOf(address(this)), quoteBalance);
// update TARGET // update TARGET
if (_RState_ != uint32(newRState)) { if (_RState_ != uint32(newRState)) {
@@ -100,6 +100,8 @@ contract DPPTrader is DPPVault {
emit RChange(newRState); emit RChange(newRState);
} }
_setReserve(_BASE_TOKEN_.balanceOf(address(this)), quoteBalance);
emit DODOSwap( emit DODOSwap(
address(_QUOTE_TOKEN_), address(_QUOTE_TOKEN_),
address(_BASE_TOKEN_), address(_BASE_TOKEN_),

View File

@@ -78,6 +78,7 @@ describe("DPP Trader", () => {
// sell at R>1 and R not change state // sell at R>1 and R not change state
await ctx.transferBaseToDPP(trader, decimalStr("1")) await ctx.transferBaseToDPP(trader, decimalStr("1"))
await logGas(ctx.DPP.methods.sellBase(trader), ctx.sendParam(trader), "sellBase - sell at R>1 and R not change state") await logGas(ctx.DPP.methods.sellBase(trader), ctx.sendParam(trader), "sellBase - sell at R>1 and R not change state")
balances = await ctx.getBalances(trader)
assert.equal(balances.traderBase, "10946772292527553373") assert.equal(balances.traderBase, "10946772292527553373")
assert.equal(balances.traderQuote, "903421814651005338950") assert.equal(balances.traderQuote, "903421814651005338950")
@@ -90,7 +91,7 @@ describe("DPP Trader", () => {
// sell at R>1 and R change state // sell at R>1 and R change state
await ctx.transferBaseToDPP(trader, decimalStr("2")) await ctx.transferBaseToDPP(trader, decimalStr("2"))
let resp = await ctx.DPP.methods.querySellBase(trader,decimalStr("2")).call(); let resp = await ctx.DPP.methods.querySellBase(trader, decimalStr("2")).call();
let bs = await ctx.getBalances(trader); let bs = await ctx.getBalances(trader);
let lpFeeRate = await ctx.DPP.methods._LP_FEE_RATE_().call(); let lpFeeRate = await ctx.DPP.methods._LP_FEE_RATE_().call();