From 9e0752aa9cc6da408f0a1ef2150a49b97037cc71 Mon Sep 17 00:00:00 2001 From: Sam Weinberg Date: Thu, 30 Jul 2020 15:02:34 -0700 Subject: [PATCH 1/3] weth-pusd constants --- dydx/constants.py | 14 +++++++++----- tests/test_client.py | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/dydx/constants.py b/dydx/constants.py index a68e0e0..dc379da 100644 --- a/dydx/constants.py +++ b/dydx/constants.py @@ -40,6 +40,7 @@ PAIR_WETH_USDC = 'WETH-USDC' PAIR_DAI_USDC = 'DAI-USDC' PAIR_PBTC_USDC = 'PBTC-USDC' +PAIR_WETH_PUSD = 'WETH_PUSD' DECIMALS_WETH = 18 DECIMALS_SAI = 18 @@ -57,12 +58,15 @@ SMALL_TRADE_SIZE_DAI = 10000 * (10 ** DECIMALS_DAI) SMALL_TRADE_SIZE_PBTC = 0.5 * (10 ** DECIMALS_PBTC) FEE_SMALL_WETH = Decimal(100) * FROM_BIPS -FEE_LARGE_WETH = Decimal(15) * FROM_BIPS +FEE_LARGE_WETH = Decimal(100) * FROM_BIPS FEE_SMALL_DAI = Decimal(100) * FROM_BIPS -FEE_LARGE_DAI = Decimal(5) * FROM_BIPS -FEE_LARGE_PBTC = Decimal(7.5) * FROM_BIPS -FEE_SMALL_PBTC = Decimal(50) * FROM_BIPS -FEE_MAKER_PBTC = Decimal(-2.5) * FROM_BIPS +FEE_LARGE_DAI = Decimal(100) * FROM_BIPS +FEE_LARGE_PBTC = Decimal(100) * FROM_BIPS +FEE_SMALL_PBTC = Decimal(100) * FROM_BIPS +FEE_MAKER_PBTC = Decimal(100) * FROM_BIPS +FEE_LARGE_WETH_PUSD = Decimal(100) * FROM_BIPS +FEE_SMALL_WETH_PUSD = Decimal(100) * FROM_BIPS +FEE_MAKER_WETH_PUSD = Decimal(100) * FROM_BIPS FEE_ZERO = Decimal(0) # ------------ Transaction Constants ------------ diff --git a/tests/test_client.py b/tests/test_client.py index a95d2fc..ea02249 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -94,7 +94,7 @@ def _additional_matcher(request): assert order['amount'] == str(args['amount']) assert order['limitPrice'] == str(args['limitPrice']) assert order['triggerPrice'] == '0' - assert order['limitFee'] == '0.00075' + assert order['limitFee'] == '0.01' assert order['maker'] == client.public_address assert order['taker'] == consts.TAKER_ACCOUNT_OWNER assert abs( From 27bed54720d37f8361708e4a18bbf89d98ace5fe Mon Sep 17 00:00:00 2001 From: Sam Weinberg Date: Thu, 30 Jul 2020 15:23:39 -0700 Subject: [PATCH 2/3] fix --- dydx/client.py | 4 ++-- dydx/constants.py | 4 ++-- dydx/util.py | 15 ++++++--------- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/dydx/client.py b/dydx/client.py index 90c4830..f71d890 100644 --- a/dydx/client.py +++ b/dydx/client.py @@ -105,7 +105,7 @@ def _make_solo_order( baseMarket, quoteMarket = utils.pair_to_base_quote_markets(market) isBuy = utils.get_is_buy(side) if limitFee is None: - limitFee = utils.get_limit_fee(baseMarket, amount, postOnly) + limitFee = utils.get_limit_fee(baseMarket, amount) order = { 'salt': random.randint(0, 2**256), @@ -167,7 +167,7 @@ def _make_perp_order( baseMarket, _ = utils.pair_to_base_quote_markets(market) isBuy = utils.get_is_buy(side) if limitFee is None: - limitFee = utils.get_limit_fee(baseMarket, amount, postOnly) + limitFee = utils.get_limit_fee(baseMarket, amount) order = { 'salt': random.randint(0, 2**256), diff --git a/dydx/constants.py b/dydx/constants.py index dc379da..42ae02e 100644 --- a/dydx/constants.py +++ b/dydx/constants.py @@ -33,6 +33,7 @@ MARKET_USDC = 2 MARKET_DAI = 3 MARKET_PBTC = 'PBTC' +MARKET_PUSD = 'PUSD' MARKET_INVALID = 4 # ------------ Pairs ------------ @@ -57,6 +58,7 @@ SMALL_TRADE_SIZE_WETH = 20 * (10 ** DECIMALS_WETH) SMALL_TRADE_SIZE_DAI = 10000 * (10 ** DECIMALS_DAI) SMALL_TRADE_SIZE_PBTC = 0.5 * (10 ** DECIMALS_PBTC) +SMALL_TRADE_SIZE_PUSD = 200 * (10 ** DECIMALS_USDC) FEE_SMALL_WETH = Decimal(100) * FROM_BIPS FEE_LARGE_WETH = Decimal(100) * FROM_BIPS FEE_SMALL_DAI = Decimal(100) * FROM_BIPS @@ -66,8 +68,6 @@ FEE_MAKER_PBTC = Decimal(100) * FROM_BIPS FEE_LARGE_WETH_PUSD = Decimal(100) * FROM_BIPS FEE_SMALL_WETH_PUSD = Decimal(100) * FROM_BIPS -FEE_MAKER_WETH_PUSD = Decimal(100) * FROM_BIPS -FEE_ZERO = Decimal(0) # ------------ Transaction Constants ------------ DEFAULT_GAS_AMOUNT = 250000 diff --git a/dydx/util.py b/dydx/util.py index 42b4faa..a510ed3 100644 --- a/dydx/util.py +++ b/dydx/util.py @@ -106,15 +106,7 @@ def get_is_buy(side): raise ValueError('Invalid side') -def get_limit_fee(base_market, amount, postOnly): - if postOnly: - if base_market == consts.MARKET_PBTC: - if (amount < consts.SMALL_TRADE_SIZE_PBTC): - return consts.FEE_ZERO - else: - return consts.FEE_MAKER_PBTC - else: - return consts.FEE_ZERO +def get_limit_fee(base_market, amount): if base_market == consts.MARKET_WETH: if (amount < consts.SMALL_TRADE_SIZE_WETH): return consts.FEE_SMALL_WETH @@ -130,6 +122,11 @@ def get_limit_fee(base_market, amount, postOnly): return consts.FEE_SMALL_PBTC else: return consts.FEE_LARGE_PBTC + elif base_market == consts.MARKET_PUSD: + if (amount < consts.SMALL_TRADE_SIZE_PUSD): + return consts.FEE_SMALL_WETH_PUSD + else: + return consts.FEE_LARGE_WETH_PUSD raise ValueError('Invalid base_market') From cd944cf5f433a2fc8ab2de625230044aab39c493 Mon Sep 17 00:00:00 2001 From: Sam Weinberg Date: Thu, 30 Jul 2020 15:35:34 -0700 Subject: [PATCH 3/3] fix2 --- dydx/constants.py | 14 +------------- dydx/util.py | 24 +++--------------------- 2 files changed, 4 insertions(+), 34 deletions(-) diff --git a/dydx/constants.py b/dydx/constants.py index 42ae02e..7a962f0 100644 --- a/dydx/constants.py +++ b/dydx/constants.py @@ -55,19 +55,7 @@ # ------------ Fees ------------ FROM_BIPS = Decimal('1e-4') -SMALL_TRADE_SIZE_WETH = 20 * (10 ** DECIMALS_WETH) -SMALL_TRADE_SIZE_DAI = 10000 * (10 ** DECIMALS_DAI) -SMALL_TRADE_SIZE_PBTC = 0.5 * (10 ** DECIMALS_PBTC) -SMALL_TRADE_SIZE_PUSD = 200 * (10 ** DECIMALS_USDC) -FEE_SMALL_WETH = Decimal(100) * FROM_BIPS -FEE_LARGE_WETH = Decimal(100) * FROM_BIPS -FEE_SMALL_DAI = Decimal(100) * FROM_BIPS -FEE_LARGE_DAI = Decimal(100) * FROM_BIPS -FEE_LARGE_PBTC = Decimal(100) * FROM_BIPS -FEE_SMALL_PBTC = Decimal(100) * FROM_BIPS -FEE_MAKER_PBTC = Decimal(100) * FROM_BIPS -FEE_LARGE_WETH_PUSD = Decimal(100) * FROM_BIPS -FEE_SMALL_WETH_PUSD = Decimal(100) * FROM_BIPS +LIMIT_FEE = Decimal(100) * FROM_BIPS # ------------ Transaction Constants ------------ DEFAULT_GAS_AMOUNT = 250000 diff --git a/dydx/util.py b/dydx/util.py index a510ed3..d820ca4 100644 --- a/dydx/util.py +++ b/dydx/util.py @@ -95,6 +95,8 @@ def pair_to_base_quote_markets(pair): return (consts.MARKET_DAI, consts.MARKET_USDC) elif pair == consts.PAIR_PBTC_USDC: return (consts.MARKET_PBTC, consts.MARKET_USDC) + elif pair == consts.PAIR_WETH_PUSD: + return (consts.MARKET_PUSD, consts.MARKET_WETH) raise ValueError('Invalid pair') @@ -107,27 +109,7 @@ def get_is_buy(side): def get_limit_fee(base_market, amount): - if base_market == consts.MARKET_WETH: - if (amount < consts.SMALL_TRADE_SIZE_WETH): - return consts.FEE_SMALL_WETH - else: - return consts.FEE_LARGE_WETH - elif base_market == consts.MARKET_DAI: - if (amount < consts.SMALL_TRADE_SIZE_DAI): - return consts.FEE_SMALL_DAI - else: - return consts.FEE_LARGE_DAI - elif base_market == consts.MARKET_PBTC: - if (amount < consts.SMALL_TRADE_SIZE_PBTC): - return consts.FEE_SMALL_PBTC - else: - return consts.FEE_LARGE_PBTC - elif base_market == consts.MARKET_PUSD: - if (amount < consts.SMALL_TRADE_SIZE_PUSD): - return consts.FEE_SMALL_WETH_PUSD - else: - return consts.FEE_LARGE_WETH_PUSD - raise ValueError('Invalid base_market') + return consts.LIMIT_FEE def decimalToStr(d):