From 34f8ab8a833f0e45b6fbccaa8e47d444f441d8b8 Mon Sep 17 00:00:00 2001 From: sourabhxyz Date: Fri, 30 Aug 2024 18:28:34 +0530 Subject: [PATCH] feat: conway update --- cabal.project | 94 +++++++++++-------- geniusyield-orderbot-framework/CHANGELOG.md | 4 + .../geniusyield-orderbot-framework.cabal | 2 +- .../src/GeniusYield/OrderBot.hs | 25 ++--- .../OrderBot/DataSource/Providers.hs | 4 +- 5 files changed, 76 insertions(+), 53 deletions(-) diff --git a/cabal.project b/cabal.project index c7590c0..d83186b 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-orderbot-framework @@ -25,21 +25,21 @@ test-show-details: direct 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= 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 @@ -49,32 +49,36 @@ source-repository-package 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/ @@ -97,15 +101,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 @@ -146,21 +150,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 -------------------------------------------------------------------------------- @@ -182,6 +195,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-orderbot-framework/CHANGELOG.md b/geniusyield-orderbot-framework/CHANGELOG.md index 26748d5..078f451 100644 --- a/geniusyield-orderbot-framework/CHANGELOG.md +++ b/geniusyield-orderbot-framework/CHANGELOG.md @@ -1,5 +1,9 @@ # Revision history for geniusyield-orderbot-framework +## 0.4.0 + +Conway era support. Note that this update is not compatible with Babbage era and so must be employed on Mainnet after Chang HF. + ## 0.3.0 Update Maestro SDK to not make use of deprecated endpoints. diff --git a/geniusyield-orderbot-framework/geniusyield-orderbot-framework.cabal b/geniusyield-orderbot-framework/geniusyield-orderbot-framework.cabal index dc521d6..e986ba1 100644 --- a/geniusyield-orderbot-framework/geniusyield-orderbot-framework.cabal +++ b/geniusyield-orderbot-framework/geniusyield-orderbot-framework.cabal @@ -1,7 +1,7 @@ cabal-version: 3.4 name: geniusyield-orderbot-framework synopsis: Smart Order Router framework -version: 0.3.0 +version: 0.4.0 build-type: Simple license: Apache-2.0 copyright: (c) 2023 GYELD GMBH diff --git a/geniusyield-orderbot-framework/src/GeniusYield/OrderBot.hs b/geniusyield-orderbot-framework/src/GeniusYield/OrderBot.hs index dfb7ae8..cd62a87 100644 --- a/geniusyield-orderbot-framework/src/GeniusYield/OrderBot.hs +++ b/geniusyield-orderbot-framework/src/GeniusYield/OrderBot.hs @@ -22,7 +22,6 @@ import Control.Monad.Reader (runReaderT) import Data.Aeson (ToJSON, encode) import Data.Foldable (foldl', toList) import Data.Functor ((<&>)) -import Data.Functor.Identity (runIdentity) import Data.List (find) import Data.Maybe (mapMaybe) @@ -52,16 +51,17 @@ import GeniusYield.OrderBot.Types (OrderAssetPair (..), assetInfo) import GeniusYield.Providers.Common (SubmitTxException) import GeniusYield.TxBuilder (GYTxBuildResult (..), - GYTxMonadNode, + GYTxBuilderMonadIO, GYTxSkeleton, - runGYTxQueryMonadNode, + buildTxBodyParallelWithStrategy, + runGYTxBuilderMonadIO, + runGYTxQueryMonadIO, utxosAtTxOutRefs) -import GeniusYield.TxBuilder.Node (runGYTxMonadNodeParallelWithStrategy) import GeniusYield.Types import GeniusYield.Api.Dex.Constants (DEXInfo (..)) -import GeniusYield.Transaction (BuildTxException, - GYCoinSelectionStrategy (GYLegacy)) +import GeniusYield.Transaction (GYCoinSelectionStrategy (GYLegacy)) +import GeniusYield.TxBuilder.Errors (GYTxMonadException) -- | The order bot is product type between bot info and "execution strategies". data OrderBot = OrderBot @@ -266,13 +266,13 @@ buildTransactions matchesToExecute di netId findBody bs mr = let ref = matchExecutionInfoUtxoRef $ head mr in find (elem ref . txBodyTxIns) bs <&> (,mr) - getBodies = NE.toList . runIdentity . sequence + getBodies = NE.toList - resultToSkeleton :: MatchResult -> GYTxMonadNode (GYTxSkeleton 'PlutusV2) + resultToSkeleton :: MatchResult -> GYTxBuilderMonadIO (GYTxSkeleton 'PlutusV2) resultToSkeleton mResult = runReaderT (executionSkeleton (dexPORefs di) mResult) di - handlerBuildTx :: BuildTxException -> IO [(GYTxBody, MatchResult)] - handlerBuildTx ex = logWarn (unwords ["BuildTxException:", show ex]) + handlerBuildTx :: GYTxMonadException -> IO [(GYTxBody, MatchResult)] + handlerBuildTx ex = logWarn (unwords ["GYTxMonadException:", show ex]) >> return [] notLosingTokensCheck @@ -288,7 +288,7 @@ notLosingTokensCheck netId providers botAddrs oapFilter (txBody, matchesToExecut matchesRefs = map matchExecutionInfoUtxoRef matchesToExecute botInputs = filter (`notElem` matchesRefs) $ txBodyTxIns txBody - inputs <- runGYTxQueryMonadNode netId providers $ utxosAtTxOutRefs botInputs + inputs <- runGYTxQueryMonadIO netId providers $ utxosAtTxOutRefs botInputs let (inputLovelace, filteredACInput) = utxosLovelaceAndFilteredValueAtAddr inputs @@ -366,3 +366,6 @@ matchingsPerOrderAssetPair oaps = foldl' succOAP (M.fromList $ map (, 0) oaps) succOAP :: M.Map OrderAssetPair Int -> MatchResult -> M.Map OrderAssetPair Int succOAP m (OrderExecutionInfo _ oi : _) = M.insertWith (+) (assetInfo oi) 1 m succOAP m _ = m + +runGYTxMonadNodeParallelWithStrategy :: GYCoinSelectionStrategy -> GYNetworkId -> GYProviders -> [GYAddress] -> GYAddress -> Maybe (GYTxOutRef, Bool) -> GYTxBuilderMonadIO [GYTxSkeleton v] -> IO GYTxBuildResult +runGYTxMonadNodeParallelWithStrategy strat nid providers addrs change collateral act = runGYTxBuilderMonadIO nid providers addrs change collateral $ act >>= buildTxBodyParallelWithStrategy strat diff --git a/impl/datasource-providers/GeniusYield/OrderBot/DataSource/Providers.hs b/impl/datasource-providers/GeniusYield/OrderBot/DataSource/Providers.hs index ab3f3c7..c55b985 100644 --- a/impl/datasource-providers/GeniusYield/OrderBot/DataSource/Providers.hs +++ b/impl/datasource-providers/GeniusYield/OrderBot/DataSource/Providers.hs @@ -59,8 +59,8 @@ withEachAssetOrders c dex 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 :: Connection