Skip to content

Commit

Permalink
Merge pull request #82 from geniusyield/81-conway
Browse files Browse the repository at this point in the history
feat(#81): conway update
  • Loading branch information
sourabhxyz authored Aug 30, 2024
2 parents 1d7116e + 9800372 commit 3ec3448
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 104 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ cabal.project.local~
*.skey
secrets/
*.env
.vscode
90 changes: 47 additions & 43 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -10,74 +10,66 @@ repository cardano-haskell-packages
d4a35cd3121aa00d18544bb0ac01c3e1691d618f462c46129271bccf39f7e8ee

-- repeating the index-state for hackage to work around hackage.nix parsing limitation
index-state: 2024-06-15T17:35:54Z
index-state: 2024-08-27T16:28:01Z

index-state:
, hackage.haskell.org 2024-06-15T17:35:54Z
, cardano-haskell-packages 2024-06-13T23:12:13Z
, hackage.haskell.org 2024-08-27T16:28:01Z
, cardano-haskell-packages 2024-07-24T14:16:32Z

packages:
geniusyield-dex-api
geniusyield-orderbot-lib
geniusyield-server-lib
geniusyield-onchain/geniusyield-common

-- TODO: Default value should be @direct@ in upcoming 3.10 version of cabal, omit this line then.
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=

-------- 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=
location: https://github.com/sourabhxyz/clb
tag: 09414a93047b4c7f6e03e20d1730c9c0f88e1d46
--sha256: sha256-y5fF8IDywt/pQ3HsRE6CpAlqK4uiU/SRuDIqSHxBED0=

-- Obtaining cardano-node stuff for 8.9.*. These aren't published on CHaP yet.
-- 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: 8.9.2
--sha256: sha256-PxMlVzTLMuVeu04QcGOxjaSMnpWJG78J0Rul3423too=
tag: 9.1.0
--sha256: sha256-F5wgRA820x16f+8c/LlEEBG0rMJIA1XWw6X0ZwX5UWs=
subdir:
cardano-node
cardano-testnet
cardano-git-rev
trace-dispatcher

-- Everything below is essentially copied from cardano-wallet's cabal.project.

-- 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 @@ -100,15 +92,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 @@ -149,21 +141,31 @@ 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
, postgresql-libpq ^>= 0.10

-- 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 @@ -185,8 +187,10 @@ package cardano-config
package cardano-node
flags: -systemd

package bitvec
flags: -simd

-- -------------------------------------------------------------------------

-------- End contents from @cardano-wallet@'s @cabal.project@ file. --------

-------- End contents from @atlas@'s @cabal.project@ file. --------
6 changes: 5 additions & 1 deletion geniusyield-dex-api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Revision history for geniusyield-dex-api

## 0.4.0.0 -- 2024-27-06
## 0.5.0.0 -- 2024-08-30

* Update to Atlas v0.6.0.

## 0.4.0.0 -- 2024-06-27

* Updates definition of `fillMultiplePartialOrders'` to call `buildWithFeeOutput` even in case more than one order is being filled.

Expand Down
2 changes: 1 addition & 1 deletion geniusyield-dex-api/geniusyield-dex-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: geniusyield-dex-api
-- PVP summary: +-+------- breaking API changes
-- | | +----- non-breaking API additions
-- | | | +--- code changes with no API change
version: 0.4.0.0
version: 0.5.0.0
synopsis: API code to interact with GeniusYield DEX.
description:
API code to interact with GeniusYield DEX. Learn more about GeniusYield by visiting https://www.geniusyield.co/.
Expand Down
29 changes: 15 additions & 14 deletions geniusyield-dex-api/src/GeniusYield/Api/Dex/PartialOrder.hs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ module GeniusYield.Api.Dex.PartialOrder (
preferentiallySelectLatestPocd,
) where

import Control.Monad.Except (ExceptT (..), liftEither, runExceptT)
import Control.Monad.Reader (ask)
import Data.Bifunctor (Bifunctor)
import Data.Foldable (foldlM)
Expand Down Expand Up @@ -410,17 +409,11 @@ partialOrdersHavingAsset pors hasAsset = do
datumsV1_1 = utxosDatumsPureWithOriginalDatum utxosWithDatumsV1_1
m1
iwither
( \oref vod
either (const Nothing) Just
<$> runExceptT (makePartialOrderInfo policyIdV1 oref vod POCVersion1)
)
(\oref vod makePartialOrderInfo' policyIdV1 oref vod POCVersion1)
datumsV1
m1_1
iwither
( \oref vod
either (const Nothing) Just
<$> runExceptT (makePartialOrderInfo policyIdV1_1 oref vod POCVersion1_1)
)
(\oref vod makePartialOrderInfo' policyIdV1_1 oref vod POCVersion1_1)
datumsV1_1
pure $! m1 <> m1_1

Expand Down Expand Up @@ -468,8 +461,7 @@ getPartialOrderInfo pors orderRef = do
pocVersion getPartialOrderVersion pors (utxoAddress utxo :!: utxoRef utxo)
vod utxoDatumPureWithOriginalDatum' utxoWithDatum
policyId withSomePORef (selectPor pors pocVersion) partialOrderNftPolicyId

runExceptT (makePartialOrderInfo policyId orderRef vod pocVersion) >>= liftEither
makePartialOrderInfo policyId orderRef vod pocVersion

getPartialOrdersInfos
GYDexApiQueryMonad m a
Expand All @@ -481,11 +473,11 @@ getPartialOrdersInfos pors orderRefs = do
ps applyToBoth addressToPaymentCredential <$> partialOrderAddrTuple pors
let vod = utxosDatumsPureWithOriginalDatum utxosWithDatums
when (Map.size vod /= length orderRefs) $ throwAppError $ PodNotAllOrderRefsPresent $ Set.fromList orderRefs `Set.difference` Map.keysSet vod
let makePartialOrderInfo' oref v@(addr, _, _, _) = do
let makePartialOrderInfo'' oref v@(addr, _, _, _) = do
pocVersion getPartialOrderVersion' ps (addr :!: oref)
policyId withSomePORef (selectPor pors pocVersion) partialOrderNftPolicyId
makePartialOrderInfo policyId oref v pocVersion
runExceptT (Map.traverseWithKey makePartialOrderInfo' vod) >>= liftEither
Map.traverseWithKey makePartialOrderInfo'' vod

getPartialOrdersInfos' GYDexApiQueryMonad m a PORefs [(GYTxOutRef, Natural)] m [(PartialOrderInfo, Natural)]
getPartialOrdersInfos' por ordersWithTokenBuyAmount = do
Expand All @@ -494,13 +486,22 @@ getPartialOrdersInfos' por ordersWithTokenBuyAmount = do
-- Even though we use `dropMissing`, `getPartialOrdersInfos` verify that all entries are present.
pure $ Map.elems $ Map.merge Map.dropMissing Map.dropMissing (Map.zipWithMatched (\_ poi amt (poi, amt))) orders ordersWithTokenBuyAmount'

makePartialOrderInfo'
GYDexApiQueryMonad m a
GYMintingPolicyId
GYTxOutRef
(GYAddress, GYValue, PartialOrderDatum, GYDatum)
POCVersion
m (Maybe PartialOrderInfo)
makePartialOrderInfo' policyId orderRef tuple pocVersion = catchError (Just <$> makePartialOrderInfo policyId orderRef tuple pocVersion) $ \(_ GYTxMonadException) pure Nothing

makePartialOrderInfo
GYDexApiQueryMonad m a
GYMintingPolicyId
GYTxOutRef
(GYAddress, GYValue, PartialOrderDatum, GYDatum)
POCVersion
ExceptT GYTxMonadException m PartialOrderInfo
m PartialOrderInfo
makePartialOrderInfo policyId orderRef (utxoAddr, v, PartialOrderDatum {..}, origDatum) pocVersion = do
addr addressFromPlutus' podOwnerAddr

Expand Down
4 changes: 2 additions & 2 deletions geniusyield-dex-api/src/GeniusYield/Api/Dex/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ module GeniusYield.Api.Dex.Types (

import Control.Monad.Reader (MonadReader)
import GeniusYield.Scripts.Dex (HasPartialOrderConfigAddr, HasPartialOrderNftScript, HasPartialOrderScript)
import GeniusYield.TxBuilder.Class (GYTxMonad, GYTxQueryMonad)
import GeniusYield.TxBuilder.Class (GYTxQueryMonad, GYTxUserQueryMonad)

type HasDexScripts a = (HasPartialOrderConfigAddr a, HasPartialOrderScript a, HasPartialOrderNftScript a)

type GYDexApiQueryMonad m a = (HasDexScripts a, MonadReader a m, GYTxQueryMonad m)

type GYDexApiMonad m a = (GYDexApiQueryMonad m a, GYTxMonad m)
type GYDexApiMonad m a = (GYDexApiQueryMonad m a, GYTxUserQueryMonad m)
4 changes: 4 additions & 0 deletions geniusyield-server-lib/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Revision history for geniusyield-server-lib

## 0.11.0 -- 2024-08-30

* Update to Atlas v0.6.0.

## 0.10.1 -- 2024-08-29

* Updated Atlas & Maestro SDK version to not make use Maestro's recently deprecated protocol parameters & era summaries endpoint.
Expand Down
2 changes: 1 addition & 1 deletion geniusyield-server-lib/geniusyield-server-lib.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 3.6
name: geniusyield-server-lib
version: 0.10.1
version: 0.11.0
synopsis: GeniusYield server library
description: Library for GeniusYield server.
license: Apache-2.0
Expand Down
17 changes: 10 additions & 7 deletions geniusyield-server-lib/src/GeniusYield/Server/Ctx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ runSkeletonI
-- ^ User's change address.
Maybe GYTxOutRef
-- ^ User's collateral.
ReaderT DEXInfo GYTxMonadNode (GYTxSkeleton v)
ReaderT DEXInfo GYTxBuilderMonadIO (GYTxSkeleton v)
IO GYTxBody
runSkeletonI = coerce (runSkeletonF @Identity)

Expand All @@ -65,7 +65,7 @@ runSkeletonWithStrategyI
-- ^ User's change address.
Maybe GYTxOutRef
-- ^ User's collateral.
ReaderT DEXInfo GYTxMonadNode (GYTxSkeleton v)
ReaderT DEXInfo GYTxBuilderMonadIO (GYTxSkeleton v)
IO GYTxBody
runSkeletonWithStrategyI cstrat = coerce (runSkeletonWithStrategyF @Identity cstrat)

Expand All @@ -78,7 +78,7 @@ runSkeletonF
-- ^ User's change address.
Maybe GYTxOutRef
-- ^ User's collateral.
ReaderT DEXInfo GYTxMonadNode (t (GYTxSkeleton v))
ReaderT DEXInfo GYTxBuilderMonadIO (t (GYTxSkeleton v))
IO (t GYTxBody)
runSkeletonF = runSkeletonWithStrategyF GYRandomImproveMultiAsset

Expand All @@ -92,7 +92,7 @@ runSkeletonWithStrategyF
-- ^ User's change address.
Maybe GYTxOutRef
-- ^ User's collateral.
ReaderT DEXInfo GYTxMonadNode (t (GYTxSkeleton v))
ReaderT DEXInfo GYTxBuilderMonadIO (t (GYTxSkeleton v))
IO (t GYTxBody)
runSkeletonWithStrategyF cstrat ctx addrs addr mcollateral skeleton = do
let nid = ctxNetworkId ctx
Expand All @@ -104,11 +104,14 @@ runSkeletonWithStrategyF cstrat ctx addrs addr mcollateral skeleton = do

runGYTxMonadNodeF cstrat nid providers (addr : addrs) addr mcollateral' $ runReaderT skeleton di

runQuery Ctx ReaderT DEXInfo GYTxQueryMonadNode a IO a
runQuery Ctx ReaderT DEXInfo GYTxQueryMonadIO a IO a
runQuery ctx = runQueryWithReader ctx (ctxDexInfo ctx)

runQueryWithReader Ctx a ReaderT a GYTxQueryMonadNode b IO b
runQueryWithReader Ctx a ReaderT a GYTxQueryMonadIO b IO b
runQueryWithReader ctx a q = do
let nid = ctxNetworkId ctx
providers = ctxProviders ctx
runGYTxQueryMonadNode nid providers $ runReaderT q a
runGYTxQueryMonadIO nid providers $ runReaderT q a

runGYTxMonadNodeF t v. Traversable t GYCoinSelectionStrategy GYNetworkId GYProviders [GYAddress] GYAddress Maybe (GYTxOutRef, Bool) GYTxBuilderMonadIO (t (GYTxSkeleton v)) IO (t GYTxBody)
runGYTxMonadNodeF strat nid providers addrs change collateral act = runGYTxBuilderMonadIO nid providers addrs change collateral $ act >>= traverse (buildTxBodyWithStrategy strat)
Loading

0 comments on commit 3ec3448

Please sign in to comment.