From 021dc24c6c24bee44be09e47b1817f8e8887dead Mon Sep 17 00:00:00 2001 From: sourabhxyz Date: Fri, 30 Aug 2024 13:39:46 +0530 Subject: [PATCH] feat: conway era support --- cabal.project | 94 +++++++++++-------- geniusyield-market-maker/CHANGELOG.md | 4 + .../geniusyield-market-maker.cabal | 2 +- .../OrderBot/DataSource/Providers.hs | 4 +- .../src/GeniusYield/MarketMaker/MakerBot.hs | 18 ++-- .../src/GeniusYield/MarketMaker/Strategies.hs | 4 +- 6 files changed, 73 insertions(+), 53 deletions(-) diff --git a/cabal.project b/cabal.project index 7dc19cb..ed8c980 100644 --- a/cabal.project +++ b/cabal.project @@ -10,11 +10,11 @@ repository cardano-haskell-packages d4a35cd3121aa00d18544bb0ac01c3e1691d618f462c46129271bccf39f7e8ee -- repeating the index-state for hackage to work around hackage.nix parsing limitation -index-state: 2024-03-19T15:29:53Z +index-state: 2024-08-27T16:28:01Z index-state: - , hackage.haskell.org 2024-03-19T15:29:53Z - , cardano-haskell-packages 2024-03-15T17:07:52Z + , hackage.haskell.org 2024-08-27T16:28:01Z + , cardano-haskell-packages 2024-07-24T14:16:32Z packages: . packages: geniusyield-annset @@ -27,8 +27,8 @@ test-show-details: direct source-repository-package type: git location: https://github.com/geniusyield/dex-contracts-api - tag: 5d21453d7b99491b5e40ddcdb500685bcd00f862 - --sha256: sha256-s8xPPW4zbcYdJvZsxZfBAOCvaheSqI01k1SUhMRrXTA= + tag: v0.11.0 + --sha256: sha256-fV6jQVxoPfv1DdssmuHDmyvKcFpFCReiSeZ3n76zC9M= subdir: geniusyield-dex-api geniusyield-onchain/geniusyield-common @@ -36,47 +36,51 @@ source-repository-package source-repository-package type: git location: https://github.com/geniusyield/ply - tag: b13674633771f572a5eedfb47276c0ac3993ab85 - --sha256: sha256-a63OdFAbo0sWOXxceI2bW/ZMrS8wo1t7aPFrfXvVhvE= + tag: 4a61941b3287782d2c11f9ab1cae0889d0a57385 + --sha256: sha256-24WKaBs6qiJzi++wTyqIh61Dc1QeCzeo0YqLE4wsEbg= subdir: ply-core source-repository-package type: git location: https://github.com/geniusyield/atlas - tag: 97f3ca97bda997533d17274689daa69c5fdcbcd6 - --sha256: sha256-NKUrxa3f6tlywWNWwdw5bWQ974ziOG9MXmY9GNZTdu8= + tag: v0.6.0 + --sha256: sha256-v+tTCIz8uyaQfsMJRc5F36TNK9ZPfrBxwXLYaXqZrZA= -------- Begin contents from @atlas@'s @cabal.project@ file. -------- package cardano-crypto-praos flags: -external-libsodium-vrf --- TODO: This is fixed for in their later version, omit this when we update to it. -package strict-containers - ghc-options: -Wwarn=noncanonical-monad-instances - source-repository-package type: git location: https://github.com/maestro-org/haskell-sdk tag: v1.7.2 --sha256: sha256-nXnelHH4a+V0nguP8oUDlyEz/fLQ/i1fs/flyZTmvAc= +-- TODO: Temporary, until proposed changes are in upstream (track https://github.com/mlabs-haskell/clb/pull/44) source-repository-package type: git - location: https://github.com/mlabs-haskell/clb - tag: 18e781b5b53adc1aa1d8c057c1b606b536a80350 - --sha256: sha256-PDmrXYTBHPcY0x+JnF21uupLMBwURLSiNMqNmwwapkc= - -constraints: - , cardano-api ^>= 8.38.0.0 + location: https://github.com/sourabhxyz/clb + tag: 09414a93047b4c7f6e03e20d1730c9c0f88e1d46 + --sha256: sha256-y5fF8IDywt/pQ3HsRE6CpAlqK4uiU/SRuDIqSHxBED0= --- Everything below is essentially copied from cardano-wallet's cabal.project. +-- Obtaining cardano-node stuff for 9.1.0. These aren't published on CHaP yet. +source-repository-package + type: git + location: https://github.com/IntersectMBO/cardano-node + tag: 9.1.0 + --sha256: sha256-F5wgRA820x16f+8c/LlEEBG0rMJIA1XWw6X0ZwX5UWs= + subdir: + cardano-node + cardano-testnet + trace-dispatcher +-- TODO: Make changes upstream source-repository-package type: git - location: https://github.com/input-output-hk/cardano-wallet - tag: v2024-03-27 - --sha256: sha256-rxMPopa3nxQaM0yOxUCq5oj3+XSL68jkuuFVhj/SY+w= + location: https://github.com/geniusyield/cardano-wallet + tag: 3413fdf74fd25b100662abf2a49c1afc892f1b79 + --sha256: sha256-V5DNUzraaDJo6cXc1eeVVIJNWqC8JayQrJeNNLg/Els= subdir: lib/address-derivation-discovery lib/balance-tx/ @@ -99,15 +103,15 @@ source-repository-package lib/wallet-benchmarks/ lib/wallet/ ------- Begin contents from @cardano-wallet@'s @cabal.project@ file. -------- +------ Following is mostly from @cardano-wallet@'s @cabal.project@ file. ------- -------------------------------------------------------------------------------- source-repository-package type: git location: https://github.com/IntersectMBO/cardano-addresses - tag: 126964483d188c2362393d2a6eea8c65dfc43097 - --sha256: 1w152imj28ap5dfdc8x9ly0cy7dn500v7k63vw11f70gvgg6x7my + tag: 2bca06deaa60e54a5322ac757387d744bf043367 + --sha256: 1y1mzfly7jac40b9g4xc078rcm5zqhc3xxv77kwxi10yph1jwq7z subdir: command-line core @@ -148,21 +152,30 @@ source-repository-package -------------------------------------------------------------------------------- -- BEGIN Constraints tweaking section --- cardano-addresses unit tests bring in some version constraint conflicts. --- --- 1. hjsonschema and hjsonpointer deps have overly strict bounds. --- 2. it has strict aeson < 1.5 dep - this will be fixed in the next release. allow-newer: - hjsonschema:* - , hjsonpointer:* - , *:aeson - , *:hashable - , async-timer:unliftio-core - , ekg:* - , ntp-client:* - , libsystemd-journal:base - , cardano-addresses-cli:mtl + async-timer:unliftio-core , servant-openapi3:* + , katip:Win32 + , raven-haskell:aeson + +constraints: + base >= 4.18.2.0 && < 5 + , openapi3 >= 3.2.0 + , persistent ^>= 2.14.6.0 + , cardano-node ^>= 9.1.0 + , bech32 >= 1.1.7 + + -- lower versions of katip won't build with the Win32-2.12.0.1 + -- which is shipped with the ghc-9.2.8 + , katip >= 0.8.7.4 + + + -- Cardano Node dependencies: + , io-classes >= 1.4 + , io-classes -asserts + , ouroboros-consensus-cardano ^>= 0.18 + , ouroboros-network ^>= 0.16.1 + , ouroboros-network-protocols ^>= 0.9 -- END Constraints tweaking section -------------------------------------------------------------------------------- @@ -184,6 +197,9 @@ package cardano-config package cardano-node flags: -systemd +package bitvec + flags: -simd + -- ------------------------------------------------------------------------- -------- End contents from @cardano-wallet@'s @cabal.project@ file. -------- diff --git a/geniusyield-market-maker/CHANGELOG.md b/geniusyield-market-maker/CHANGELOG.md index 010916e..1716d17 100644 --- a/geniusyield-market-maker/CHANGELOG.md +++ b/geniusyield-market-maker/CHANGELOG.md @@ -1,5 +1,9 @@ # Revision history for geniusyield-market-maker +## 0.8.0 -- 2024-08-30 + +* Conway era support. Note that this update is not compatible with Babbage era and so must be employed on Mainnet after Chang HF. + ## 0.7.0 -- 2024-08-30 * Updated Atlas & Maestro SDK version to not make use Maestro's recently deprecated protocol parameters & era summaries endpoint. diff --git a/geniusyield-market-maker/geniusyield-market-maker.cabal b/geniusyield-market-maker/geniusyield-market-maker.cabal index 7d0db12..062d811 100644 --- a/geniusyield-market-maker/geniusyield-market-maker.cabal +++ b/geniusyield-market-maker/geniusyield-market-maker.cabal @@ -1,6 +1,6 @@ cabal-version: 3.4 name: geniusyield-market-maker -version: 0.7.0 +version: 0.8.0 build-type: Simple extra-doc-files: CHANGELOG.md synopsis: diff --git a/geniusyield-market-maker/impl/datasource-providers/GeniusYield/OrderBot/DataSource/Providers.hs b/geniusyield-market-maker/impl/datasource-providers/GeniusYield/OrderBot/DataSource/Providers.hs index b6dc7be..3a98288 100644 --- a/geniusyield-market-maker/impl/datasource-providers/GeniusYield/OrderBot/DataSource/Providers.hs +++ b/geniusyield-market-maker/impl/datasource-providers/GeniusYield/OrderBot/DataSource/Providers.hs @@ -54,8 +54,8 @@ withEachAssetOrders c dex poRefs assetFilter f acc = do acc infoMap -runQuery :: Connection -> GYTxQueryMonadNode a -> IO a -runQuery (Connection nid providers) = runGYTxQueryMonadNode nid providers +runQuery :: Connection -> GYTxQueryMonadIO a -> IO a +runQuery (Connection nid providers) = runGYTxQueryMonadIO nid providers allOrderInfos :: HasDexScripts a diff --git a/geniusyield-market-maker/src/GeniusYield/MarketMaker/MakerBot.hs b/geniusyield-market-maker/src/GeniusYield/MarketMaker/MakerBot.hs index 9869550..febabbe 100644 --- a/geniusyield-market-maker/src/GeniusYield/MarketMaker/MakerBot.hs +++ b/geniusyield-market-maker/src/GeniusYield/MarketMaker/MakerBot.hs @@ -5,7 +5,8 @@ import Control.Exception (Exception (displayException Handler (Handler), catches) import Control.Monad (forM_, forever) import Control.Monad.Reader (runReaderT) -import Control.Monad.State (StateT (..), get, put, lift) +import Control.Monad.State (StateT (..), get, lift, + put) import Data.List.Split (chunksOf) import qualified Data.Map.Strict as M import GeniusYield.Api.Dex.Constants (DEXInfo (..)) @@ -13,15 +14,14 @@ import GeniusYield.Api.Dex.PartialOrder (PartialOrderInfo (poiOwnerK cancelMultiplePartialOrders', partialOrders, placePartialOrder) -import GeniusYield.Imports (printf, (&), fromMaybe) +import GeniusYield.Imports (fromMaybe, printf, (&)) import GeniusYield.MarketMaker.Constants (awaitTxParams, logNS) import GeniusYield.MarketMaker.Prices import GeniusYield.MarketMaker.Strategies import GeniusYield.MarketMaker.User import GeniusYield.MarketMaker.Utils (addrUser, pkhUser) import GeniusYield.Providers.Common (SubmitTxException) -import GeniusYield.Transaction (BuildTxException) -import GeniusYield.TxBuilder +import GeniusYield.TxBuilder hiding (User) import GeniusYield.Types import System.Exit @@ -72,7 +72,7 @@ cancelAllOrders' MakerBot {mbUser} netId providers di = do gyLogInfo providers logNS "---------- Done for the block! -----------" gyAwaitTxConfirmed providers awaitTxParams tid go rest - partialOrderInfos ← runGYTxQueryMonadNode netId providers $ runReaderT (partialOrders (dexPORefs di)) di + partialOrderInfos ← runGYTxQueryMonadIO netId providers $ runReaderT (partialOrders (dexPORefs di)) di let userPkh = pkhUser mbUser & toPubKeyHash userPOIs = filter (\o → poiOwnerKey o == userPkh) $ M.elems partialOrderInfos go userPOIs @@ -111,15 +111,12 @@ buildAndSubmitActions user@User {uColl, uStakeCred} providers netId ua di = flip let handlerCommon ∷ Exception e => e → IO () handlerCommon = logWarn . displayException - be ∷ BuildTxException → IO () - be = handlerCommon - se ∷ SubmitTxException → IO () se = handlerCommon me ∷ GYTxMonadException → IO () me = handlerCommon - in [Handler be, Handler se, Handler me] + in [Handler se, Handler me] buildCommon txBody = do logInfo $ "Successfully built body for above action, tx id: " <> show (txBodyTxId txBody) @@ -255,3 +252,6 @@ executeStrategy runStrategy mb netId providers pp di = do (evolveStrategy runStrategy mb netId providers pp di) MBReady return () + +runGYTxMonadNode :: GYNetworkId -> GYProviders -> [GYAddress] -> GYAddress -> Maybe (GYTxOutRef, Bool) -> GYTxBuilderMonadIO (GYTxSkeleton v) -> IO GYTxBody +runGYTxMonadNode nid providers addrs change collateral act = runGYTxBuilderMonadIO nid providers addrs change collateral $ act >>= buildTxBody diff --git a/geniusyield-market-maker/src/GeniusYield/MarketMaker/Strategies.hs b/geniusyield-market-maker/src/GeniusYield/MarketMaker/Strategies.hs index 02782c2..5248ccf 100644 --- a/geniusyield-market-maker/src/GeniusYield/MarketMaker/Strategies.hs +++ b/geniusyield-market-maker/src/GeniusYield/MarketMaker/Strategies.hs @@ -51,7 +51,7 @@ import GeniusYield.OrderBot.OrderBook.AnnSet (MultiAssetOrderBook, withEachAsset) import GeniusYield.OrderBot.Types import GeniusYield.TxBuilder (GYTxQueryMonad (utxosAtAddress), - runGYTxQueryMonadNode) + runGYTxQueryMonadIO) import GeniusYield.Types import GHC.Natural (naturalFromInteger) @@ -224,7 +224,7 @@ fixedSpreadVsMarketPriceStrategy (bp, maob) ← getOrderBookPrices pp [mmTokenPair] mp priceCheckThreshold - ownUtxos ← runGYTxQueryMonadNode nid providers $ utxosAtAddress userAddr Nothing -- Assumption: User addresses does not include order validator's address. + ownUtxos ← runGYTxQueryMonadIO nid providers $ utxosAtAddress userAddr Nothing -- Assumption: User addresses does not include order validator's address. let ownOrdersPerUser = getOwnOrders [mmTokenPair] [user] maob allOwnOrders = M.foldr (++) [] ownOrdersPerUser equityInOrders = foldMap' getEquityFromOrder allOwnOrders