@@ -25,23 +25,32 @@ import HydraAuctionOnchain.Helpers
25
25
, pvaluePaidTo
26
26
, pvaluePaidToScript
27
27
)
28
+ import HydraAuctionOnchain.MintingPolicies.Auction (allAuctionTokensBurned )
28
29
import HydraAuctionOnchain.Types.AuctionEscrowState
29
- ( PAuctionEscrowState
30
+ ( PAuctionEscrowState ( AuctionConcluded )
30
31
, pvalidateAuctionEscrowTransitionToAuctionConcluded
31
32
, pvalidateAuctionEscrowTransitionToBiddingStarted
32
33
)
33
34
import HydraAuctionOnchain.Types.AuctionTerms
34
35
( PAuctionTerms
35
36
, pbiddingPeriod
37
+ , pcleanupPeriod
36
38
, ppenaltyPeriod
37
39
, ppurchasePeriod
38
40
, ptotalAuctionFees
39
41
)
40
42
import HydraAuctionOnchain.Types.BidTerms (psellerPayout , pvalidateBidTerms )
41
43
import HydraAuctionOnchain.Types.Error (errCode , passert , passertMaybe , passertMaybeData )
42
44
import HydraAuctionOnchain.Types.StandingBidState (PStandingBidState (PStandingBidState ))
43
- import Plutarch.Api.V1.Value (plovelaceValueOf )
44
- import Plutarch.Api.V2 (PAddress , PCurrencySymbol , PScriptContext , PScriptHash , PTxInfo )
45
+ import Plutarch.Api.V1.Value (plovelaceValueOf , pnormalize )
46
+ import Plutarch.Api.V2
47
+ ( PAddress
48
+ , PCurrencySymbol
49
+ , PScriptContext
50
+ , PScriptHash
51
+ , PTxInInfo
52
+ , PTxInfo
53
+ )
45
54
import Plutarch.Extra.Interval (pcontains )
46
55
import Plutarch.Extra.Maybe (pdnothing )
47
56
import Plutarch.Extra.ScriptContext (ptxSignedBy )
@@ -136,7 +145,12 @@ auctionEscrowValidator = phoistAcyclic $
136
145
# oldAuctionState
137
146
# ownAddress
138
147
CleanupAuctionRedeemer _ ->
139
- undefined
148
+ pcheckCleanupAuction
149
+ # txInfo
150
+ # auctionCs
151
+ # auctionTerms
152
+ # oldAuctionState
153
+ # ownInput
140
154
141
155
--------------------------------------------------------------------------------
142
156
-- StartBidding
@@ -456,3 +470,47 @@ pcheckSellerReclaims = phoistAcyclic $
456
470
#<= (plovelaceValueOf #$ pvaluePaidToScript # txInfo # feeEscrowSh)
457
471
458
472
pcon PUnit
473
+
474
+ --------------------------------------------------------------------------------
475
+ -- CleanupAuction
476
+ --------------------------------------------------------------------------------
477
+
478
+ pcheckCleanupAuction
479
+ :: Term
480
+ s
481
+ ( PTxInfo
482
+ :--> PCurrencySymbol
483
+ :--> PAuctionTerms
484
+ :--> PAuctionEscrowState
485
+ :--> PTxInInfo
486
+ :--> PUnit
487
+ )
488
+ pcheckCleanupAuction = phoistAcyclic $
489
+ plam $ \ txInfo auctionCs auctionTerms auctionState ownInput -> P. do
490
+ txInfoFields <- pletFields @ [" mint" , " signatories" , " validRange" ] txInfo
491
+
492
+ -- (AUES39) The auction state, auction metadata,and standing bid
493
+ -- tokens of the auction should all be burned. No other tokens
494
+ -- should be minted or burned.
495
+ passert $ (errCode AuctionEscrow'CleanupAuction'Error'AuctionTokensNotBurnedExactly ) $
496
+ pnormalize # txInfoFields. mint #== allAuctionTokensBurned # auctionCs
497
+
498
+ -- (AUES40) This redeemer can only be used during the cleanup period.
499
+ passert $ (errCode AuctionEscrow'CleanupAuction'Error'IncorrectValidityInterval ) $
500
+ pcontains # (pcleanupPeriod # auctionTerms) # txInfoFields. validRange
501
+
502
+ -- (AUES41) The seller signed the transaction.
503
+ sellerPkh <- plet $ pfield @ " sellerPkh" # auctionTerms
504
+ passert $ (errCode AuctionEscrow'CleanupAuction'Error'NoSellerConsent ) $
505
+ ptxSignedBy # txInfoFields. signatories # pdata sellerPkh
506
+
507
+ -- (AUES42) The auction is concluded.
508
+ passert $ (errCode AuctionEscrow'CleanupAuction'Error'AuctionIsNotConcluded ) $
509
+ auctionState #== pcon (AuctionConcluded pdnil)
510
+
511
+ -- (AUES43) The auction escrow input contains the standing bid
512
+ -- token in addition to the auction token.
513
+ passert $ (errCode AuctionEscrow'CleanupAuction'Error'AuctionEscrowInputMissingStandingBidToken ) $
514
+ ptxOutContainsStandingBidToken # auctionCs #$ pfield @ " resolved" # ownInput
515
+
516
+ pcon PUnit
0 commit comments