@@ -141,6 +141,14 @@ record HasDepositsChange {a} (A : Type a) : Type a where
141141 field DepositsChangeOf : A → DepositsChange
142142open HasDepositsChange ⦃...⦄ public
143143
144+ record HasDepositsChangeTop {a} (A : Type a) : Type a where
145+ field DepositsChangeTopOf : A → ℤ
146+ open HasDepositsChangeTop ⦃...⦄ public
147+
148+ record HasDepositsChangeSub {a} (A : Type a) : Type a where
149+ field DepositsChangeSubOf : A → ℤ
150+ open HasDepositsChangeSub ⦃...⦄ public
151+
144152record HasScriptPool {a} (A : Type a) : Type a where
145153 field ScriptPoolOf : A → ℙ Script
146154open HasScriptPool ⦃...⦄ public
@@ -209,6 +217,18 @@ instance
209217 HasDonations-UTxOState : HasDonations UTxOState
210218 HasDonations-UTxOState .DonationsOf = UTxOState.donations
211219
220+ HasDepositsChangeTop-DepositsChange : HasDepositsChangeTop DepositsChange
221+ HasDepositsChangeTop-DepositsChange .DepositsChangeTopOf = DepositsChange.depositsChangeTop
222+
223+ HasDepositsChangeSub-DepositsChange : HasDepositsChangeSub DepositsChange
224+ HasDepositsChangeSub-DepositsChange .DepositsChangeSubOf = DepositsChange.depositsChangeSub
225+
226+ HasDepositsChangeTop-UTxOEnv : HasDepositsChangeTop UTxOEnv
227+ HasDepositsChangeTop-UTxOEnv .DepositsChangeTopOf = DepositsChangeTopOf ∘ DepositsChangeOf
228+
229+ HasDepositsChangeSub-UTxOEnv : HasDepositsChangeSub UTxOEnv
230+ HasDepositsChangeSub-UTxOEnv .DepositsChangeSubOf = DepositsChangeSubOf ∘ DepositsChangeOf
231+
212232 unquoteDecl HasCast-DepositsChange
213233 HasCast-UTxOEnv
214234 HasCast-SubUTxOEnv
@@ -256,6 +276,9 @@ minfee pp txTop utxo = pp .a * (SizeOf txTop) + pp .b
256276instance
257277 HasCoin-UTxO : HasCoin UTxO
258278 HasCoin-UTxO .getCoin = cbalance
279+
280+ HasCoin-UTxOState : HasCoin UTxOState
281+ HasCoin-UTxOState .getCoin s = getCoin (UTxOOf s) + FeesOf s + DonationsOf s
259282```
260283-->
261284
@@ -300,6 +323,16 @@ collateralCheck pp txTop utxo =
300323 × coin (balance (utxo ∣ CollateralInputsOf txTop)) * 100 ≥ (TxFeesOf txTop) * pp .collateralPercentage
301324 × (CollateralInputsOf txTop) ≢ ∅
302325
326+ producedTx : Tx ℓ → Value
327+ producedTx tx = balance (outs tx)
328+ + inject (DonationsOf tx)
329+ + inject (getCoin (DirectDepositsOf tx))
330+
331+ consumedTx : Tx ℓ → UTxO → Value
332+ consumedTx tx utxo = balance (utxo ∣ SpendInputsOf tx)
333+ + MintedValueOf tx
334+ + inject (getCoin (WithdrawalsOf tx))
335+
303336module _ (depositsChange : DepositsChange) where
304337
305338 open DepositsChange depositsChange
@@ -316,11 +349,6 @@ module _ (depositsChange : DepositsChange) where
316349 depositRefundsTop : Coin
317350 depositRefundsTop = negPart depositsChangeTop
318351
319- consumedTx : Tx ℓ → UTxO → Value
320- consumedTx tx utxo = balance (utxo ∣ SpendInputsOf tx)
321- + MintedValueOf tx
322- + inject (getCoin (WithdrawalsOf tx))
323-
324352 consumed : TopLevelTx → UTxO → Value
325353 consumed txTop utxo = consumedTx txTop utxo
326354 + inject depositRefundsTop
@@ -337,11 +365,6 @@ In the preservation-of-value equation, direct deposits appear on the
337365the transaction and that amount is deposited into accounts.
338366
339367``` agda
340- producedTx : Tx ℓ → Value
341- producedTx tx = balance (outs tx)
342- + inject (DonationsOf tx)
343- + inject (getCoin (DirectDepositsOf tx))
344-
345368 produced : TopLevelTx → Value
346369 produced txTop = producedTx txTop
347370 + inject (TxFeesOf txTop)
0 commit comments