Module

Ctl.Internal.Testnet.DistributeFunds

#DistrFundsError

data DistrFundsError wallet amount

Constructors

Instances

#DistrFundsParams

type DistrFundsParams wallet amount = { feePerTx :: amount, getUtxoMinAdaForWallet :: wallet -> amount, maxRounds :: Int, maxUtxosPerTx :: Int }

#SourceState

type SourceState wallet amount = { currentTx :: Tx wallet amount, leftover :: amount, srcWallet :: wallet }

#Tx

newtype Tx wallet amount

Constructors

  • Tx { numUtxos :: Int, srcWallet :: wallet, utxos :: List { amount :: amount, wallet :: wallet } }

Instances

#explainDistrFundsError

explainDistrFundsError :: forall wallet amount. Show wallet => Show amount => DistrFundsError wallet amount -> String

#makeDistributionPlan

makeDistributionPlan :: forall wallet amount. Ord amount => Ring amount => DistrFundsParams wallet amount -> Array (wallet /\ amount) -> Array (wallet /\ amount) -> Either (DistrFundsError wallet amount) (Array (Array (Tx wallet amount)))

#AssignUtxoResult

data AssignUtxoResult wallet amount

Constructors

Instances

#assignUtxoToSource

assignUtxoToSource :: forall wallet amount. Ord amount => Ring amount => DistrFundsParams wallet amount -> SourceState wallet amount -> wallet /\ amount -> AssignUtxoResult wallet amount

Attempts to assign the specified target utxo to the given source. ADA value of the target utxo is expected to be normalized, i.e. utxo min-ada requirement should be taken into account.

#initSourceState

initSourceState :: forall wallet amount. wallet -> amount -> SourceState wallet amount

#runDistrFundsRound

runDistrFundsRound :: forall wallet amount. Ord amount => Ring amount => DistrFundsParams wallet amount -> List (SourceState wallet amount) -> List (wallet /\ amount) -> Either (DistrFundsError wallet amount) (DistrFundsRoundResult wallet amount)

Executes a single round of funds distribution, assigning the provided target utxos to the sources.

Some utxo may be deferred until the next round if they cannot be immediately covered by the sources due to the algorithm's parameters, even though the sources are sufficient.

If some of the target utxos cannot be covered by any source, a DistrFunds_AssignUtxoError will be returned.

Modules