Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing minimum UTxO value computation (node-1.35.4) #106

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Deleted spurious `runQuery'` log messages
- The constraints for most of the functions in `Convex.CoinSelection` have changed from `MonadFail m` to `MonadError BalanceTxError m`, allowing for better error handling
- Relaxed the `MonadError` instance of `MonadBlockchainCardanoNodeT` by removing the `MonadError e m` constraint; fixed the implementation of `catchError`
- `Convex.BuildTx`: Ensure that at least 3 Ada is present when computing minimum UTxO value in `minAdaDeposit`.

### Added

Expand Down
9 changes: 5 additions & 4 deletions src/base/lib/Convex/BuildTx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,11 @@ setMinAdaDeposit params txOut =

minAdaDeposit :: CLedger.PParams (C.ShelleyLedgerEra C.BabbageEra) -> C.TxOut C.CtxTx C.BabbageEra -> C.Quantity
minAdaDeposit params txOut =
let txo = txOut
-- set the Ada value to a dummy amount to ensure that it is not 0 (if it was 0, the size of the output
-- would be smaller, causing 'calculateMinimumUTxO' to compute an amount that is a little too small)
& over (L._TxOut . _2 . L._TxOutValue . L._Value . at C.AdaAssetId) (maybe (Just $ C.Quantity 3_000_000) Just)
let minAdaValue = C.Quantity 3_000_000
txo = txOut
-- set the Ada value to a dummy amount to ensure that it is not 0 (if it was 0, the size of the output
-- would be smaller, causing 'calculateMinimumUTxO' to compute an amount that is a little too small)
& over (L._TxOut . _2 . L._TxOutValue . L._Value . at C.AdaAssetId) (maybe (Just minAdaValue) (Just . max minAdaValue))
in fromMaybe (C.Quantity 0) $ do
k <- either (const Nothing) pure (CC.calculateMinimumUTxO txo params)
C.Lovelace l <- C.valueToLovelace k
Expand Down
Loading