Skip to content

Commit 5e3762a

Browse files
committed
wip
1 parent 4007c74 commit 5e3762a

File tree

13 files changed

+19
-187
lines changed

13 files changed

+19
-187
lines changed

pub/bfx/src/Bfx.hs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
{-# LANGUAGE TypeApplications #-}
21
{-# OPTIONS_HADDOCK show-extensions #-}
32

43
module Bfx
@@ -54,15 +53,15 @@ platformStatus ::
5453
) =>
5554
m PltStatus
5655
platformStatus =
57-
Generic.pub @'PlatformStatus [] ()
56+
Generic.pub @'PlatformStatus mempty emptyReq
5857

5958
symbolsDetails ::
6059
( MonadThrow m,
6160
MonadUnliftIO m
6261
) =>
6362
m (Map CurrencyPair CurrencyPairConf)
6463
symbolsDetails =
65-
Generic.pub @'SymbolsDetails [] ()
64+
Generic.pub @'SymbolsDetails mempty emptyReq
6665

6766
marketAveragePrice ::
6867
( MonadThrow m,
@@ -80,7 +79,6 @@ marketAveragePrice args =
8079
where
8180
amt =
8281
( MarketAveragePrice.buyOrSell args,
83-
Base,
8482
MarketAveragePrice.baseAmount args
8583
)
8684
sym =
@@ -93,10 +91,7 @@ feeSummary ::
9391
Env ->
9492
m FeeSummary.Response
9593
feeSummary env =
96-
Generic.prv
97-
@'FeeSummary
98-
env
99-
(mempty :: Map Int Int)
94+
Generic.prv @'FeeSummary env emptyReq
10095

10196
wallets ::
10297
( MonadThrow m,
@@ -109,10 +104,7 @@ wallets ::
109104
(Map Wallets.WalletType Wallets.Response)
110105
)
111106
wallets env =
112-
Generic.prv
113-
@'Wallets
114-
env
115-
(mempty :: Map Int Int)
107+
Generic.prv @'Wallets env emptyReq
116108

117109
spendableExchangeBalance ::
118110
( MonadThrow m,

pub/bfx/src/Bfx/Class/ToRequestParam.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ instance ToRequestParam Text where
5353
toTextParam =
5454
id
5555

56-
instance ToRequestParam (BuyOrSell, BaseOrQuote, MoneyAmount) where
57-
toTextParam (bos, boq, MoneyAmount amt) =
58-
if bos == Sell && boq == Base
56+
instance ToRequestParam (BuyOrSell, MoneyAmount) where
57+
toTextParam (bos, MoneyAmount amt) =
58+
if bos == Sell
5959
then toTextParam $ (-1) * rat amt
6060
else toTextParam $ rat amt
6161
where

pub/bfx/src/Bfx/Data/FeeSummary.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ data Response = Response
1616
{ makerCrypto2CryptoFee :: FeeRate,
1717
makerCrypto2StableFee :: FeeRate,
1818
makerCrypto2FiatFee :: FeeRate,
19-
makerDerivativeRebate :: RebateRate 'Maker,
19+
makerDerivativeRebate :: RebateRate,
2020
takerCrypto2CryptoFee :: FeeRate,
2121
takerCrypto2StableFee :: FeeRate,
2222
takerCrypto2FiatFee :: FeeRate,

pub/bfx/src/Bfx/Data/SubmitOrder.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ instance ToJSON Request where
7070
"amount"
7171
A..= toTextParam
7272
( buyOrSell req,
73-
Base,
7473
baseAmount req
7574
),
7675
"symbol"

pub/bfx/src/Bfx/Data/Type.hs

Lines changed: 11 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ module Bfx.Data.Type
3333
-- $misc
3434
PltStatus (..),
3535
Error (..),
36+
emptyReq,
3637
)
3738
where
3839

@@ -235,166 +236,18 @@ newOrderStatus = \case
235236
-- $trading
236237
-- Data related to trading and money.
237238

238-
-- newtype
239-
-- FeeRate
240-
-- (mrel :: MakerOrTaker)
241-
-- (crel :: CurrencyRelation) = FeeRate
242-
-- { unFeeRate :: Rational
243-
-- }
244-
-- deriving newtype
245-
-- ( Eq,
246-
-- Ord,
247-
-- Show
248-
-- )
249-
-- deriving stock
250-
-- ( Generic,
251-
-- TH.Lift
252-
-- )
253-
--
254-
-- instance From (FeeRate mrel crel) Rational
255-
--
256-
-- instance TryFrom Rational (FeeRate mrel crel) where
257-
-- tryFrom x
258-
-- | x >= 0 && x < 1 = Right $ FeeRate x
259-
-- | otherwise = Left $ TryFromException x Nothing
260-
--
261-
-- deriving via
262-
-- Rational
263-
-- instance
264-
-- ( Typeable mrel,
265-
-- Typeable crel
266-
-- ) =>
267-
-- PersistFieldSql (FeeRate mrel crel)
268-
--
269-
-- instance
270-
-- ( Typeable mrel,
271-
-- Typeable crel
272-
-- ) =>
273-
-- PersistField (FeeRate mrel crel)
274-
-- where
275-
-- toPersistValue =
276-
-- PersistRational . from
277-
-- fromPersistValue raw =
278-
-- case raw of
279-
-- PersistRational x ->
280-
-- first (const failure) $ tryFrom x
281-
-- _ ->
282-
-- Left failure
283-
-- where
284-
-- failure =
285-
-- showType @(FeeRate mrel crel)
286-
-- <> " PersistValue is invalid "
287-
-- <> show raw
288-
289-
newtype RebateRate (mrel :: MakerOrTaker)
290-
= RebateRate Rational
291-
deriving newtype
239+
newtype RebateRate = RebateRate
240+
{ unRebateRate :: Rational
241+
}
242+
deriving stock
292243
( Eq,
293244
Ord,
294245
Show,
295-
Num
296-
)
297-
deriving stock
298-
( Generic
246+
Read,
247+
Data,
248+
Generic
299249
)
300250

301-
instance From (RebateRate mrel) Rational
302-
303-
instance From Rational (RebateRate mrel)
304-
305-
-- newtype ProfitRate = ProfitRate
306-
-- { unProfitRate :: Rational
307-
-- }
308-
-- deriving newtype
309-
-- ( Eq,
310-
-- Ord,
311-
-- Show,
312-
-- NFData
313-
-- )
314-
-- deriving stock
315-
-- ( Generic,
316-
-- TH.Lift
317-
-- )
318-
--
319-
-- instance TryFrom Rational ProfitRate where
320-
-- tryFrom x
321-
-- | x > 0 = Right $ ProfitRate x
322-
-- | otherwise = Left $ TryFromException x Nothing
323-
--
324-
-- instance From ProfitRate Rational
325-
--
326-
-- instance FromJSON ProfitRate where
327-
-- parseJSON =
328-
-- withText (inspectType @ProfitRate)
329-
-- $ either (fail . inspect) (pure . ProfitRate)
330-
-- . parseRatio
331-
--
332-
-- newtype ProfitRateB (b :: MinOrMax) = ProfitRateB
333-
-- { unProfitRateB :: ProfitRate
334-
-- }
335-
-- deriving newtype
336-
-- ( Eq,
337-
-- Ord,
338-
-- Show,
339-
-- NFData,
340-
-- FromJSON
341-
-- )
342-
-- deriving stock
343-
-- ( Generic,
344-
-- TH.Lift
345-
-- )
346-
347-
-- newtype CurrencyCode (crel :: CurrencyRelation) = CurrencyCode
348-
-- { unCurrencyCode :: Text
349-
-- }
350-
-- deriving newtype
351-
-- ( Eq,
352-
-- Ord,
353-
-- Show,
354-
-- ToJSON,
355-
-- NFData
356-
-- )
357-
-- deriving stock
358-
-- ( Generic,
359-
-- TH.Lift
360-
-- )
361-
--
362-
-- instance From (CurrencyCode crel0) (CurrencyCode crel1)
363-
--
364-
-- instance (Typeable crel) => FromJSON (CurrencyCode crel) where
365-
-- parseJSON = withText
366-
-- (showType @(CurrencyCode crel))
367-
-- $ \raw -> do
368-
-- case newCurrencyCode raw of
369-
-- Left x -> fail $ show x
370-
-- Right x -> pure x
371-
--
372-
-- deriving via
373-
-- Text
374-
-- instance
375-
-- ( Typeable crel
376-
-- ) =>
377-
-- PersistFieldSql (CurrencyCode crel)
378-
--
379-
-- instance
380-
-- ( Typeable crel
381-
-- ) =>
382-
-- PersistField (CurrencyCode crel)
383-
-- where
384-
-- toPersistValue =
385-
-- PersistText . coerce
386-
-- fromPersistValue raw =
387-
-- case raw of
388-
-- PersistText x ->
389-
-- first (const failure) $ newCurrencyCode x
390-
-- _ ->
391-
-- Left failure
392-
-- where
393-
-- failure =
394-
-- showType @(CurrencyCode crel)
395-
-- <> " PersistValue is invalid "
396-
-- <> show raw
397-
398251
newCurrencyCode :: (MonadThrow m) => Text -> m CurrencyCode
399252
newCurrencyCode raw =
400253
case T.strip raw of
@@ -576,3 +429,6 @@ data Error
576429
)
577430

578431
instance Exception Error
432+
433+
emptyReq :: Map Int Int
434+
emptyReq = mempty

pub/bfx/src/Bfx/Math.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ module Bfx.Math
66
newCounterOrder,
77
CounterArgs (..),
88
CounterExit (..),
9-
-- newCounterOrderSimple,
109
)
1110
where
1211

pub/bfx/src/Bfx/Parser.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
{-# LANGUAGE TypeApplications #-}
21
{-# OPTIONS_HADDOCK show-extensions #-}
32

43
module Bfx.Parser

pub/bfx/src/Bfx/Rpc/Generic.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{-# LANGUAGE AllowAmbiguousTypes #-}
2-
{-# LANGUAGE TypeApplications #-}
32
{-# OPTIONS_HADDOCK show-extensions #-}
43

54
module Bfx.Rpc.Generic

pub/bfx/src/Bfx/Util.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{-# LANGUAGE AllowAmbiguousTypes #-}
2-
{-# LANGUAGE TypeApplications #-}
32
{-# OPTIONS_HADDOCK show-extensions #-}
43

54
module Bfx.Util

pub/bfx/test/Bfx/Data/SubmitOrderSpec.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
{-# LANGUAGE TypeApplications #-}
21
{-# OPTIONS_HADDOCK show-extensions #-}
32

43
module Bfx.Data.SubmitOrderSpec

0 commit comments

Comments
 (0)