Add buying, selling and capital limit controls

These advanced controls are disabled by default.

Also disable depositing and trading when creating a new DODO.
This commit is contained in:
Michael Zhou
2020-09-08 19:45:17 +08:00
parent 8a5cca991f
commit 30040834f6
9 changed files with 651 additions and 266 deletions

View File

@@ -44,6 +44,9 @@ async function init(ctx: DODOContext): Promise<void> {
.getDODO(WETH.options.address, ctx.QUOTE.options.address)
.call()
);
await ctx.DODO.methods.enableBaseDeposit().send(ctx.sendParam(ctx.Deployer));
await ctx.DODO.methods.enableQuoteDeposit().send(ctx.sendParam(ctx.Deployer));
await ctx.DODO.methods.enableTrading().send(ctx.sendParam(ctx.Deployer));
ctx.BASE = WETH;
@@ -102,12 +105,11 @@ describe("DODO ETH PROXY", () => {
it("buy", async () => {
const buyAmount = "1";
await logGas(
DODOEthProxy.methods
.buyEthWithToken(
ctx.QUOTE.options.address,
decimalStr(buyAmount),
decimalStr("200")
),
DODOEthProxy.methods.buyEthWithToken(
ctx.QUOTE.options.address,
decimalStr(buyAmount),
decimalStr("200")
),
ctx.sendParam(trader),
"buy ETH with token directly"
);
@@ -123,12 +125,11 @@ describe("DODO ETH PROXY", () => {
it("sell", async () => {
const sellAmount = "1";
await logGas(
DODOEthProxy.methods
.sellEthToToken(
ctx.QUOTE.options.address,
decimalStr(sellAmount),
decimalStr("50")
),
DODOEthProxy.methods.sellEthToToken(
ctx.QUOTE.options.address,
decimalStr(sellAmount),
decimalStr("50")
),
ctx.sendParam(trader, sellAmount),
"sell ETH to token directly"
);