Skip to content

Commit

Permalink
Merge pull request #110 from geniusyield/conway-update
Browse files Browse the repository at this point in the history
feat: conway update
  • Loading branch information
sourabhxyz authored Aug 30, 2024
2 parents ffa64b4 + 34f8ab8 commit c4ce9a5
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 53 deletions.
94 changes: 55 additions & 39 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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/
Expand All @@ -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

Expand Down Expand Up @@ -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
--------------------------------------------------------------------------------
Expand All @@ -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. --------
Expand Down
4 changes: 4 additions & 0 deletions geniusyield-orderbot-framework/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
25 changes: 14 additions & 11 deletions geniusyield-orderbot-framework/src/GeniusYield/OrderBot.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c4ce9a5

Please sign in to comment.