{-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE NoImplicitPrelude #-} module BtcLsp.Yesod.Handler.About where import qualified BtcLsp.Class.Env import qualified BtcLsp.Math.OnChain as Math import qualified BtcLsp.Math.Swap as Math import BtcLsp.Yesod.Data.Widget import BtcLsp.Yesod.Import getAboutR :: Handler Html getAboutR :: Handler Html getAboutR = do App {appMRunner :: () appMRunner = UnliftIO forall a. m a -> IO a run} <- HandlerFor App App forall (m :: * -> *). MonadHandler m => m (HandlerSite m) getYesod Money 'Usr 'OnChain 'Fund minAmt <- IO (Money 'Usr 'OnChain 'Fund) -> HandlerFor App (Money 'Usr 'OnChain 'Fund) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO (Money 'Usr 'OnChain 'Fund) -> HandlerFor App (Money 'Usr 'OnChain 'Fund)) -> IO (Money 'Usr 'OnChain 'Fund) -> HandlerFor App (Money 'Usr 'OnChain 'Fund) forall a b. (a -> b) -> a -> b $ m (Money 'Usr 'OnChain 'Fund) -> IO (Money 'Usr 'OnChain 'Fund) forall a. m a -> IO a run m (Money 'Usr 'OnChain 'Fund) forall (m :: * -> *). Env m => m (Money 'Usr 'OnChain 'Fund) getSwapIntoLnMinAmt Maybe Widget mExamplesWidget <- IO (Maybe Widget) -> HandlerFor App (Maybe Widget) forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (IO (Maybe Widget) -> HandlerFor App (Maybe Widget)) -> (m (Maybe Widget) -> IO (Maybe Widget)) -> m (Maybe Widget) -> HandlerFor App (Maybe Widget) forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c . m (Maybe Widget) -> IO (Maybe Widget) forall a. m a -> IO a run (m (Maybe Widget) -> HandlerFor App (Maybe Widget)) -> m (Maybe Widget) -> HandlerFor App (Maybe Widget) forall a b. (a -> b) -> a -> b $ Money 'Usr 'OnChain 'Fund -> m (Maybe Widget) forall (m :: * -> *). Env m => Money 'Usr 'OnChain 'Fund -> m (Maybe Widget) newExamplesWidget Money 'Usr 'OnChain 'Fund minAmt Widget -> Handler Html forall site. Yesod site => WidgetFor site () -> HandlerFor site Html defaultLayout (Widget -> Handler Html) -> Widget -> Handler Html forall a b. (a -> b) -> a -> b $ do AppMessage -> Widget forall (m :: * -> *) msg. (MonadWidget m, RenderMessage (HandlerSite m) msg) => msg -> m () setTitleI AppMessage MsgAboutRTitle $(widgetFile "about") newExamplesWidget :: ( BtcLsp.Class.Env.Env m ) => Money 'Usr 'OnChain 'Fund -> m (Maybe Widget) newExamplesWidget :: forall (m :: * -> *). Env m => Money 'Usr 'OnChain 'Fund -> m (Maybe Widget) newExamplesWidget Money 'Usr 'OnChain 'Fund minAmt = do [Maybe (Money 'Usr 'OnChain 'Fund, SwapCap)] caps <- (Money 'Usr 'OnChain 'Fund -> m (Maybe (Money 'Usr 'OnChain 'Fund, SwapCap))) -> [Money 'Usr 'OnChain 'Fund] -> m [Maybe (Money 'Usr 'OnChain 'Fund, SwapCap)] forall (t :: * -> *) (m :: * -> *) a b. (Traversable t, Monad m) => (a -> m b) -> t a -> m (t b) mapM ( \Money 'Usr 'OnChain 'Fund amt -> do Maybe SwapCap mcap <- Money 'Usr 'OnChain 'Fund -> m (Maybe SwapCap) forall (m :: * -> *). Env m => Money 'Usr 'OnChain 'Fund -> m (Maybe SwapCap) Math.newSwapCapM Money 'Usr 'OnChain 'Fund amt Maybe (Money 'Usr 'OnChain 'Fund, SwapCap) -> m (Maybe (Money 'Usr 'OnChain 'Fund, SwapCap)) forall (f :: * -> *) a. Applicative f => a -> f a pure (Maybe (Money 'Usr 'OnChain 'Fund, SwapCap) -> m (Maybe (Money 'Usr 'OnChain 'Fund, SwapCap))) -> Maybe (Money 'Usr 'OnChain 'Fund, SwapCap) -> m (Maybe (Money 'Usr 'OnChain 'Fund, SwapCap)) forall a b. (a -> b) -> a -> b $ (Money 'Usr 'OnChain 'Fund amt,) (SwapCap -> (Money 'Usr 'OnChain 'Fund, SwapCap)) -> Maybe SwapCap -> Maybe (Money 'Usr 'OnChain 'Fund, SwapCap) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Maybe SwapCap mcap ) [ Money 'Usr 'OnChain 'Fund minAmt, Money 'Usr 'OnChain 'Fund minAmt Money 'Usr 'OnChain 'Fund -> Money 'Usr 'OnChain 'Fund -> Money 'Usr 'OnChain 'Fund forall a. Num a => a -> a -> a * Money 'Usr 'OnChain 'Fund 5, Money 'Usr 'OnChain 'Fund minAmt Money 'Usr 'OnChain 'Fund -> Money 'Usr 'OnChain 'Fund -> Money 'Usr 'OnChain 'Fund forall a. Num a => a -> a -> a * Money 'Usr 'OnChain 'Fund 100 ] Maybe Widget -> m (Maybe Widget) forall (f :: * -> *) a. Applicative f => a -> f a pure (Maybe Widget -> m (Maybe Widget)) -> ([[(AppMessage, AppMessage)]] -> Maybe Widget) -> [[(AppMessage, AppMessage)]] -> m (Maybe Widget) forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c . [[(AppMessage, AppMessage)]] -> Maybe Widget newListWidget ([[(AppMessage, AppMessage)]] -> m (Maybe Widget)) -> [[(AppMessage, AppMessage)]] -> m (Maybe Widget) forall a b. (a -> b) -> a -> b $ ( \(Money 'Usr 'OnChain 'Fund fundAmt, Math.SwapCap {Money 'Lsp 'OnChain 'Gain Money 'Lsp 'Ln 'Fund Money 'Usr 'Ln 'Fund swapCapFee :: SwapCap -> Money 'Lsp 'OnChain 'Gain swapCapLsp :: SwapCap -> Money 'Lsp 'Ln 'Fund swapCapUsr :: SwapCap -> Money 'Usr 'Ln 'Fund swapCapFee :: Money 'Lsp 'OnChain 'Gain swapCapLsp :: Money 'Lsp 'Ln 'Fund swapCapUsr :: Money 'Usr 'Ln 'Fund ..}) -> [ ( AppMessage MsgAboutExamplesUserOnChainFunding, MSat -> AppMessage MsgSatoshi (MSat -> AppMessage) -> MSat -> AppMessage forall a b. (a -> b) -> a -> b $ Money 'Usr 'OnChain 'Fund -> MSat forall source target. (From source target, 'False ~ (source == target)) => source -> target from Money 'Usr 'OnChain 'Fund fundAmt ), ( AppMessage MsgAboutExamplesLspSwapFee, MSat -> AppMessage MsgSatoshi (MSat -> AppMessage) -> MSat -> AppMessage forall a b. (a -> b) -> a -> b $ Money 'Lsp 'OnChain 'Gain -> MSat forall source target. (From source target, 'False ~ (source == target)) => source -> target from Money 'Lsp 'OnChain 'Gain swapCapFee ), ( AppMessage MsgAboutExamplesUserOutgoingCap, MSat -> AppMessage MsgSatoshi (MSat -> AppMessage) -> MSat -> AppMessage forall a b. (a -> b) -> a -> b $ Money 'Usr 'Ln 'Fund -> MSat forall source target. (From source target, 'False ~ (source == target)) => source -> target from Money 'Usr 'Ln 'Fund swapCapUsr ), ( AppMessage MsgAboutExamplesUserIncomingCap, MSat -> AppMessage MsgSatoshi (MSat -> AppMessage) -> MSat -> AppMessage forall a b. (a -> b) -> a -> b $ Money 'Lsp 'Ln 'Fund -> MSat forall source target. (From source target, 'False ~ (source == target)) => source -> target from Money 'Lsp 'Ln 'Fund swapCapLsp ), ( AppMessage MsgAboutExamplesTotalChanCap, MSat -> AppMessage MsgSatoshi (MSat -> AppMessage) -> MSat -> AppMessage forall a b. (a -> b) -> a -> b $ Money 'Usr 'Ln 'Fund -> MSat forall source target. (From source target, 'False ~ (source == target)) => source -> target from Money 'Usr 'Ln 'Fund swapCapUsr MSat -> MSat -> MSat forall a. Num a => a -> a -> a + Money 'Lsp 'Ln 'Fund -> MSat forall source target. (From source target, 'False ~ (source == target)) => source -> target from Money 'Lsp 'Ln 'Fund swapCapLsp ) ] ) ((Money 'Usr 'OnChain 'Fund, SwapCap) -> [(AppMessage, AppMessage)]) -> [(Money 'Usr 'OnChain 'Fund, SwapCap)] -> [[(AppMessage, AppMessage)]] forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> [Maybe (Money 'Usr 'OnChain 'Fund, SwapCap)] -> [(Money 'Usr 'OnChain 'Fund, SwapCap)] forall (f :: * -> *) t. (IsSequence (f (Maybe t)), Functor f, Element (f (Maybe t)) ~ Maybe t) => f (Maybe t) -> f t catMaybes [Maybe (Money 'Usr 'OnChain 'Fund, SwapCap)] caps