mirror of
https://github.com/FiloSpaTeam/plutus-pioneer-program.git
synced 2024-11-22 06:42:00 +01:00
pool formatting
This commit is contained in:
parent
30d6b92ac8
commit
c77890da1f
1 changed files with 17 additions and 5 deletions
|
@ -62,7 +62,7 @@ data Command =
|
||||||
|
|
||||||
readCommandIO :: IO Command
|
readCommandIO :: IO Command
|
||||||
readCommandIO = do
|
readCommandIO = do
|
||||||
putStrLn "Enter a command: Funds, Pools, Create amtA tnA amtB tnB"
|
putStrLn "Enter a command: Funds, Pools, Create amtA tnA amtB tnB, Swap amtA tnA tnB"
|
||||||
s <- getLine
|
s <- getLine
|
||||||
maybe readCommandIO return $ readMaybe s
|
maybe readCommandIO return $ readMaybe s
|
||||||
|
|
||||||
|
@ -75,6 +75,12 @@ toCreateParams cs amtA tnA amtB tnB = US.CreateParams (toCoin cs tnA) (toCoin cs
|
||||||
toSwapParams :: CurrencySymbol -> Integer -> Char -> Char -> US.SwapParams
|
toSwapParams :: CurrencySymbol -> Integer -> Char -> Char -> US.SwapParams
|
||||||
toSwapParams cs amtA tnA tnB = US.SwapParams (toCoin cs tnA) (toCoin cs tnB) (US.Amount amtA) (US.Amount 0)
|
toSwapParams cs amtA tnA tnB = US.SwapParams (toCoin cs tnA) (toCoin cs tnB) (US.Amount amtA) (US.Amount 0)
|
||||||
|
|
||||||
|
showCoinHeader :: IO ()
|
||||||
|
showCoinHeader = printf "\n currency symbol token name amount\n\n"
|
||||||
|
|
||||||
|
showCoin :: CurrencySymbol -> TokenName -> Integer -> IO ()
|
||||||
|
showCoin cs tn amt = printf "%64s %66s %15d\n" (show cs) (show tn) amt
|
||||||
|
|
||||||
getFunds :: UUID -> IO ()
|
getFunds :: UUID -> IO ()
|
||||||
getFunds cid = do
|
getFunds cid = do
|
||||||
callEndpoint cid "funds" ()
|
callEndpoint cid "funds" ()
|
||||||
|
@ -89,9 +95,8 @@ getFunds cid = do
|
||||||
|
|
||||||
showFunds :: Value -> IO ()
|
showFunds :: Value -> IO ()
|
||||||
showFunds v = do
|
showFunds v = do
|
||||||
printf "\n currency symbol token name amount\n\n"
|
showCoinHeader
|
||||||
forM_ (flattenValue v) $ \(cs, tn, amt) ->
|
forM_ (flattenValue v) $ \(cs, tn, amt) -> showCoin cs tn amt
|
||||||
printf "%64s %66s %15d\n" (show cs) (show tn) amt
|
|
||||||
printf "\n"
|
printf "\n"
|
||||||
|
|
||||||
getPools :: UUID -> IO ()
|
getPools :: UUID -> IO ()
|
||||||
|
@ -103,9 +108,16 @@ getPools cid = do
|
||||||
go = do
|
go = do
|
||||||
e <- getStatus cid
|
e <- getStatus cid
|
||||||
case e of
|
case e of
|
||||||
Right (US.Pools ps) -> putStrLn $ "pools: " ++ show ps
|
Right (US.Pools ps) -> showPools ps
|
||||||
_ -> go
|
_ -> go
|
||||||
|
|
||||||
|
showPools :: [((US.Coin US.A, US.Amount US.A), (US.Coin US.B, US.Amount US.B))] -> IO ()
|
||||||
|
showPools ps = do
|
||||||
|
forM_ ps $ \((US.Coin (AssetClass (csA, tnA)), amtA), (US.Coin (AssetClass (csB, tnB)), amtB)) -> do
|
||||||
|
showCoinHeader
|
||||||
|
showCoin csA tnA (US.unAmount amtA)
|
||||||
|
showCoin csB tnB (US.unAmount amtB)
|
||||||
|
|
||||||
createPool :: UUID -> US.CreateParams -> IO ()
|
createPool :: UUID -> US.CreateParams -> IO ()
|
||||||
createPool cid cp = do
|
createPool cid cp = do
|
||||||
callEndpoint cid "create" cp
|
callEndpoint cid "create" cp
|
||||||
|
|
Loading…
Reference in a new issue