From ef7b53af1b488e4459ce47d91707d3a84175fa91 Mon Sep 17 00:00:00 2001 From: Bromel777 Date: Wed, 19 Jul 2023 20:35:29 +0200 Subject: [PATCH] update contracts to last version --- cabal.project | 2 +- dex-core/src/ErgoDex/Amm/Pool.hs | 85 +++++++++++++++-------------- dex-core/test/Spec/Pool.hs | 26 ++++----- nix/pkgs/haskell/haskell.nix | 2 +- submit-api/src/SubmitAPI/Service.hs | 1 + submit-api/submit-api.cabal | 1 + 6 files changed, 60 insertions(+), 57 deletions(-) diff --git a/cabal.project b/cabal.project index 33723ae5..ef1d1ff6 100644 --- a/cabal.project +++ b/cabal.project @@ -313,7 +313,7 @@ source-repository-package source-repository-package type: git location: https://github.com/ergolabs/cardano-dex-contracts - tag: 0f53e485b2310cb83a946bbd29a5c5454a757b22 + tag: 7850574a9b7f3e33cd7fc16f5fcdbbf0c8de68df subdir: cardano-dex-contracts-offchain diff --git a/dex-core/src/ErgoDex/Amm/Pool.hs b/dex-core/src/ErgoDex/Amm/Pool.hs index 23ba70df..c7bce0d0 100644 --- a/dex-core/src/ErgoDex/Amm/Pool.hs +++ b/dex-core/src/ErgoDex/Amm/Pool.hs @@ -43,18 +43,18 @@ data PoolFee = PoolFee } deriving (Show, Eq, Generic, FromJSON, ToJSON) data Pool = Pool - { poolId :: PoolId - , poolReservesX :: Amount X - , poolReservesY :: Amount Y - , poolLiquidity :: Amount Liquidity - , poolCoinX :: Coin X - , poolCoinY :: Coin Y - , poolCoinLq :: Coin Liquidity - , poolFee :: PoolFee - , outCollateral :: Amount Lovelace - , stakeAdmins :: [PubKeyHash] - , lqBound :: Amount X - , stakeCred :: Maybe StakingCredential + { poolId :: PoolId + , poolReservesX :: Amount X + , poolReservesY :: Amount Y + , poolLiquidity :: Amount Liquidity + , poolCoinX :: Coin X + , poolCoinY :: Coin Y + , poolCoinLq :: Coin Liquidity + , poolFee :: PoolFee + , outCollateral :: Amount Lovelace + , stakeAdminPolicy :: [CurrencySymbol] + , lqBound :: Amount X + , stakeCred :: Maybe StakingCredential } deriving (Show, Eq, Generic, FromJSON, ToJSON) feeDen :: Integer @@ -74,18 +74,18 @@ instance FromLedger Pool where collateral = if W.isAda poolX || W.isAda poolY then zero else minSafeOutputAmount when (rx == 0 || ry == 0 || rlq == 0 || nft /= 1) Nothing Just $ OnChain fout Pool - { poolId = PoolId $ Coin poolNft - , poolReservesX = rx - , poolReservesY = ry - , poolLiquidity = lq - , poolCoinX = Coin poolX - , poolCoinY = Coin poolY - , poolCoinLq = Coin poolLq - , poolFee = PoolFee poolFeeNum feeDen - , outCollateral = collateral - , stakeAdmins = stakeAdmins - , lqBound = lqBoundAmount - , stakeCred = addressStakingCredential + { poolId = PoolId $ Coin poolNft + , poolReservesX = rx + , poolReservesY = ry + , poolLiquidity = lq + , poolCoinX = Coin poolX + , poolCoinY = Coin poolY + , poolCoinLq = Coin poolLq + , poolFee = PoolFee poolFeeNum feeDen + , outCollateral = collateral + , stakeAdminPolicy = stakeAdminPolicy + , lqBound = lqBoundAmount + , stakeCred = addressStakingCredential } _ -> Nothing parseFromLedger _ = Nothing @@ -111,13 +111,13 @@ instance ToLedger PoolValidatorV1 Pool where lovelaceValueOf (unAmount outCollateral) poolConf = PoolConfig - { poolNft = unCoin nft - , poolX = unCoin poolCoinX - , poolY = unCoin poolCoinY - , poolLq = unCoin poolCoinLq - , poolFeeNum = poolFeeNum' poolFee - , stakeAdmins = stakeAdmins - , lqBound = unAmount lqBound + { poolNft = unCoin nft + , poolX = unCoin poolCoinX + , poolY = unCoin poolCoinY + , poolLq = unCoin poolCoinLq + , poolFeeNum = poolFeeNum' poolFee + , stakeAdminPolicy = stakeAdminPolicy + , lqBound = unAmount lqBound } data PoolInitError @@ -142,17 +142,18 @@ initPool poolValidator S.PoolConfig{..} burnLq (inX, inY) = do then zero else minSafeOutputAmount pool = Pool - { poolId = PoolId poolNft - , poolReservesX = inX - , poolReservesY = inY - , poolLiquidity = releasedLq - , poolCoinX = poolX - , poolCoinY = poolY - , poolCoinLq = poolLq - , poolFee = PoolFee poolFeeNum feeDen - , stakeAdmins = [] - , lqBound = 10000 - , outCollateral = outCollateral + { poolId = PoolId poolNft + , poolReservesX = inX + , poolReservesY = inY + , poolLiquidity = releasedLq + , poolCoinX = poolX + , poolCoinY = poolY + , poolCoinLq = poolLq + , poolFee = PoolFee poolFeeNum feeDen + , stakeAdminPolicy = [] + , lqBound = 10000 + , outCollateral = outCollateral + , stakeCred = Nothing } poolOut = toLedger poolValidator pool pure (Predicted poolOut pool, releasedLq) diff --git a/dex-core/test/Spec/Pool.hs b/dex-core/test/Spec/Pool.hs index 75c15f8f..be4592f5 100644 --- a/dex-core/test/Spec/Pool.hs +++ b/dex-core/test/Spec/Pool.hs @@ -80,7 +80,7 @@ initialLiquidityTests = testGroup "InitialLiquidity" initialLiquidityAmount poolLq (Amount 10, Amount 11) @?= Right (AssetAmount poolLq 11) ] -poolConf = S.PoolConfig poolNft poolX poolY poolLq poolFeeNum +poolConf = S.PoolConfig poolNft poolX poolY poolLq poolFeeNum [] 0 sufficientInitDepositX = Amount 800 @@ -91,18 +91,18 @@ initDepositY = Amount 2000 releasedLq = Amount 265 nativePool = Pool - { poolId = PoolId poolNft - , poolReservesX = sufficientInitDepositX - , poolReservesY = initDepositY - , poolLiquidity = releasedLq - , poolCoinX = poolX - , poolCoinY = poolY - , poolCoinLq = poolLq - , poolFee = PoolFee poolFeeNum feeDen - , outCollateral = minSafeOutputAmount - , stakeAdmins = [] - , lqBound = Amount 0 - , stakeCred = Nothing + { poolId = PoolId poolNft + , poolReservesX = sufficientInitDepositX + , poolReservesY = initDepositY + , poolLiquidity = releasedLq + , poolCoinX = poolX + , poolCoinY = poolY + , poolCoinLq = poolLq + , poolFee = PoolFee poolFeeNum feeDen + , outCollateral = minSafeOutputAmount + , stakeAdminPolicy = [] + , lqBound = Amount 0 + , stakeCred = Nothing } -- todo: remove me diff --git a/nix/pkgs/haskell/haskell.nix b/nix/pkgs/haskell/haskell.nix index a27db67b..e5424271 100644 --- a/nix/pkgs/haskell/haskell.nix +++ b/nix/pkgs/haskell/haskell.nix @@ -43,7 +43,7 @@ let "https://github.com/input-output-hk/cardano-ledger"."c7c63dabdb215ebdaed8b63274965966f2bf408f" = "zTQbMOGPD1Oodv6VUsfF6NUiXkbN8SWI98W3Atv4wbI="; "https://github.com/input-output-hk/plutus-apps"."593ffafa59dd30ad28cfaf144c526c66328595d2" = "CIuI/Nz7O67ljOHDg7UBbXgWuIE7VPRdPX4VK0/DI3A="; "https://github.com/input-output-hk/hedgehog-extras"."714ee03a5a786a05fc57ac5d2f1c2edce4660d85" = "6KQFEzb9g2a0soVvwLKESEbA+a8ygpROcMr6bkatROE="; - "https://github.com/ergolabs/cardano-dex-contracts"."0f53e485b2310cb83a946bbd29a5c5454a757b22" = "ksJ0ni8bFUbmoVyG4USSPzNu4+oasa84ijeY/pRDYew="; + "https://github.com/ergolabs/cardano-dex-contracts"."7850574a9b7f3e33cd7fc16f5fcdbbf0c8de68df" = "1jzh8o3SdkZflVLLglT45iCcmgDSAg6b1P7fTwwmgPM="; "https://github.com/ergolabs/hlog"."19dfa3a6e696a3f63fc3539cd6b7a3fc4d999853" = "Lvmj1oLuXmktrboXh/BrXqLPf8FxSCXIf99GnBXu0Bk="; "https://github.com/daleiz/rocksdb-haskell"."109af08f95b40f458d4933e3725ecb3e59337c39" = "1i1ya491fapa0g96527krarv0w0iybizqcz518741iw06hhpikiy"; }; diff --git a/submit-api/src/SubmitAPI/Service.hs b/submit-api/src/SubmitAPI/Service.hs index 4db0c728..513febad 100644 --- a/submit-api/src/SubmitAPI/Service.hs +++ b/submit-api/src/SubmitAPI/Service.hs @@ -19,6 +19,7 @@ import qualified NetworkAPI.Service as Network import NetworkAPI.Types import WalletAPI.Utxos import WalletAPI.Vault +import Cardano.Crypto.DSIGN.SchnorrSecp256k1 data Transactions f era = Transactions { estimateTxFee :: Set.Set Sdk.FullCollateralTxIn -> Sdk.TxCandidate -> f C.Lovelace diff --git a/submit-api/submit-api.cabal b/submit-api/submit-api.cabal index e2555f14..feaf36ec 100644 --- a/submit-api/submit-api.cabal +++ b/submit-api/submit-api.cabal @@ -111,6 +111,7 @@ library cardano-ledger-shelley, cardano-ledger-core, cardano-ledger-shelley-ma, + cardano-crypto-class, cardano-ledger-byron, cardano-ledger-babbage, ouroboros-consensus,