singular-registry
LicenseApache-2.0
Safe HaskellNone
LanguageGHC2021

Singular.Registry.TxBuilder.Request

Description

Builds the request transaction for one seven-admitted-edges edge (#183). No script execution occurs -- the transaction simply pays to the per-cage request address with an inline RequestDatum naming the edge.

The locked ADA includes the token's tip plus a fee buffer for the oracle's update transaction, and the datum's deposit is exactly that lovelace less the tip, which is what the fold checks.

Synopsis
  • requestEdgeImpl :: CageConfig -> Session NoWitness IO -> Coin -> TokenId -> ByteString -> Edge -> Addr -> IO ConwayTx
  • requestLockedAda :: PParams ConwayEra -> TxOut ConwayEra -> TxOut ConwayEra -> Integer -> Coin
  • settleRequestOutput :: PParams ConwayEra -> Integer -> (Integer -> Integer -> TxOut ConwayEra) -> Integer -> TxOut ConwayEra

Documentation

requestEdgeImpl Source #

Arguments

:: CageConfig 
-> Session NoWitness IO 
-> Coin

Token tip (lovelace)

-> TokenId 
-> ByteString

Key the edge moves

-> Edge

The seven-admitted-edges row index (0-6)

-> Addr 
-> IO ConwayTx 

Build the request transaction for one seven-admitted-edges edge (#183).

The edge is the whole shape of the request: it names the trie move and its leaf bytes, so no value travels here. The datum's deposit is the output's lovelace less the tip, settled with the sizing below because the deposit is itself a datum field.

requestLockedAda :: PParams ConwayEra -> TxOut ConwayEra -> TxOut ConwayEra -> Integer -> Coin Source #

Compute the ADA to lock in a request output.

settleRequestOutput Source #

Arguments

:: PParams ConwayEra 
-> Integer

Token tip (lovelace)

-> (Integer -> Integer -> TxOut ConwayEra)

Output for a given (locked lovelace, deposit)

-> Integer

Starting locked lovelace

-> TxOut ConwayEra 

Settle a request output against the invariant the fold checks: the datum's deposit is exactly the output's lovelace less the tip.

Writing the deposit into the datum can itself raise the output's minimum ada, so the two are a fixpoint rather than one computation. Each round rebuilds the output at the minimum the previous round demanded; the minimum is monotone in the lovelace and the datum grows by at most a few bytes, so it settles in one or two rounds. The bound is there so that a ledger whose minimum never stabilises fails loudly instead of looping.