@@ -142,6 +142,14 @@ record HasDepositsChange {a} (A : Type a) : Type a where
142142 field DepositsChangeOf : A → DepositsChange
143143open HasDepositsChange ⦃...⦄ public
144144
145+ record HasDepositsChangeTop {a} (A : Type a) : Type a where
146+ field DepositsChangeTopOf : A → ℤ
147+ open HasDepositsChangeTop ⦃...⦄ public
148+
149+ record HasDepositsChangeSub {a} (A : Type a) : Type a where
150+ field DepositsChangeSubOf : A → ℤ
151+ open HasDepositsChangeSub ⦃...⦄ public
152+
145153record HasScriptPool {a} (A : Type a) : Type a where
146154 field ScriptPoolOf : A → ℙ Script
147155open HasScriptPool ⦃...⦄ public
@@ -210,6 +218,18 @@ instance
210218 HasDonations-UTxOState : HasDonations UTxOState
211219 HasDonations-UTxOState .DonationsOf = UTxOState.donations
212220
221+ HasDepositsChangeTop-DepositsChange : HasDepositsChangeTop DepositsChange
222+ HasDepositsChangeTop-DepositsChange .DepositsChangeTopOf = DepositsChange.depositsChangeTop
223+
224+ HasDepositsChangeSub-DepositsChange : HasDepositsChangeSub DepositsChange
225+ HasDepositsChangeSub-DepositsChange .DepositsChangeSubOf = DepositsChange.depositsChangeSub
226+
227+ HasDepositsChangeTop-UTxOEnv : HasDepositsChangeTop UTxOEnv
228+ HasDepositsChangeTop-UTxOEnv .DepositsChangeTopOf = DepositsChangeTopOf ∘ DepositsChangeOf
229+
230+ HasDepositsChangeSub-UTxOEnv : HasDepositsChangeSub UTxOEnv
231+ HasDepositsChangeSub-UTxOEnv .DepositsChangeSubOf = DepositsChangeSubOf ∘ DepositsChangeOf
232+
213233 unquoteDecl HasCast-DepositsChange
214234 HasCast-UTxOEnv
215235 HasCast-SubUTxOEnv
@@ -257,6 +277,9 @@ minfee pp txTop utxo = pp .a * (SizeOf txTop) + pp .b
257277instance
258278 HasCoin-UTxO : HasCoin UTxO
259279 HasCoin-UTxO .getCoin = cbalance
280+
281+ HasCoin-UTxOState : HasCoin UTxOState
282+ HasCoin-UTxOState .getCoin s = getCoin (UTxOOf s) + FeesOf s + DonationsOf s
260283```
261284-->
262285
@@ -301,6 +324,16 @@ collateralCheck pp txTop utxo =
301324 × coin (balance (utxo ∣ CollateralInputsOf txTop)) * 100 ≥ (TxFeesOf txTop) * pp .collateralPercentage
302325 × (CollateralInputsOf txTop) ≢ ∅
303326
327+ producedTx : Tx ℓ → Value
328+ producedTx tx = balance (outs tx)
329+ + inject (DonationsOf tx)
330+ + inject (getCoin (DirectDepositsOf tx))
331+
332+ consumedTx : Tx ℓ → UTxO → Value
333+ consumedTx tx utxo = balance (utxo ∣ SpendInputsOf tx)
334+ + MintedValueOf tx
335+ + inject (getCoin (WithdrawalsOf tx))
336+
304337module _ (depositsChange : DepositsChange) where
305338
306339 open DepositsChange depositsChange
@@ -317,11 +350,6 @@ module _ (depositsChange : DepositsChange) where
317350 depositRefundsTop : Coin
318351 depositRefundsTop = negPart depositsChangeTop
319352
320- consumedTx : Tx ℓ → UTxO → Value
321- consumedTx tx utxo = balance (utxo ∣ SpendInputsOf tx)
322- + MintedValueOf tx
323- + inject (getCoin (WithdrawalsOf tx))
324-
325353 consumed : TopLevelTx → UTxO → Value
326354 consumed txTop utxo = consumedTx txTop utxo
327355 + inject depositRefundsTop
@@ -338,11 +366,6 @@ In the preservation-of-value equation, direct deposits appear on the
338366the transaction and that amount is deposited into accounts.
339367
340368``` agda
341- producedTx : Tx ℓ → Value
342- producedTx tx = balance (outs tx)
343- + inject (DonationsOf tx)
344- + inject (getCoin (DirectDepositsOf tx))
345-
346369 produced : TopLevelTx → Value
347370 produced txTop = producedTx txTop
348371 + inject (TxFeesOf txTop)
0 commit comments