Skip to content

Commit

Permalink
update contracts to last version
Browse files Browse the repository at this point in the history
  • Loading branch information
Bromel777 committed Jul 19, 2023
1 parent ea5a810 commit ef7b53a
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 57 deletions.
2 changes: 1 addition & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
85 changes: 43 additions & 42 deletions dex-core/src/ErgoDex/Amm/Pool.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand Down
26 changes: 13 additions & 13 deletions dex-core/test/Spec/Pool.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion nix/pkgs/haskell/haskell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
};
Expand Down
1 change: 1 addition & 0 deletions submit-api/src/SubmitAPI/Service.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions submit-api/submit-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit ef7b53a

Please sign in to comment.