@@ -25,7 +25,7 @@ import Splice.Api.Token.MetadataV1 as Api.Token.MetadataV1
2525import Splice.Api.Token.HoldingV1 qualified as Api.Token.HoldingV1
2626import Splice.Amulet
2727import Splice.Amulet.TokenApiUtils
28- import Splice.AmuletConfig (AmuletConfig(..), DevelopmentFundConfig(..), TransferConfig(..), validAmuletConfig, defaultTransferPreapprovalFee)
28+ import Splice.AmuletConfig (AmuletConfig(..), TransferConfig(..), validAmuletConfig, defaultTransferPreapprovalFee)
2929import qualified Splice.AmuletConfig as Unit
3030import Splice.Schedule
3131import Splice.Expiry
@@ -132,13 +132,11 @@ template AmuletRules
132132 -- one under their control.
133133 controller Set.toList (transferControllers transfer)
134134 do
135- now <- getTime
136135 checkExpectedDso dso expectedDso
137136 let rewardsConfig = RewardsIssuanceConfig with
138137 issueAppRewards = True
139138 issueValidatorRewards = True
140- configUsd = getValueAsOf now configSchedule
141- executeTransfer rewardsConfig context dso configUsd.developmentFundConfig transfer
139+ executeTransfer rewardsConfig context dso transfer
142140
143141 nonconsuming choice AmuletRules_CreateExternalPartySetupProposal : AmuletRules_CreateExternalPartySetupProposalResult
144142 -- ^ Propose to host an external party
@@ -161,8 +159,7 @@ template AmuletRules
161159 require "preapprovalExpiresAt is not in the past" (preapprovalExpiresAt > now)
162160 let configUsd = getValueAsOf now configSchedule
163161 (amuletPaid, _) <- computeTransferPreapprovalFee (preapprovalExpiresAt `subTime` now) configUsd context.context dso
164- (transferResult, meta) <-
165- splitAndBurn validator amuletPaid inputs context.context dso "create ExternalPartySetupProposal" configUsd.developmentFundConfig
162+ (transferResult, meta) <- splitAndBurn validator amuletPaid inputs context.context dso "create ExternalPartySetupProposal"
166163 proposalCid <- create ExternalPartySetupProposal with
167164 user
168165 validator
@@ -190,8 +187,7 @@ template AmuletRules
190187 require "expiresAt is not in the past" (expiresAt > now)
191188 let configUsd = getValueAsOf now configSchedule
192189 (amuletPaid, _) <- computeTransferPreapprovalFee (expiresAt `subTime` now) configUsd context.context dso
193- (transferResult, meta) <-
194- splitAndBurn provider amuletPaid inputs context.context dso "create TransferPreapproval" configUsd.developmentFundConfig
190+ (transferResult, meta) <- splitAndBurn provider amuletPaid inputs context.context dso "create TransferPreapproval"
195191 transferPreapprovalCid <- create TransferPreapproval with
196192 receiver
197193 provider
@@ -230,8 +226,7 @@ template AmuletRules
230226 let transferConfigAmulet = scaleFees (1.0 / openRound.amuletPrice) openRound.transferConfigUsd
231227 (trafficCostAmulet, trafficCostUsd) <- computeSynchronizerFees dso provider trafficAmount this context
232228 -- We want to burn exactly trafficCostAmulet, and createFee is already burnt by the self-transfer itself, so we subtract the createFee from the amount we split off and burn explicitly.
233- (transferResult, meta) <-
234- splitAndBurn provider (trafficCostAmulet - transferConfigAmulet.createFee.fee) inputs context dso "traffic purchase" configUsd.developmentFundConfig
229+ (transferResult, meta) <- splitAndBurn provider (trafficCostAmulet - transferConfigAmulet.createFee.fee) inputs context dso "traffic purchase"
235230 -- create a new MemberTraffic contract for the purchased traffic
236231 purchasedTraffic <- create MemberTraffic with
237232 dso
@@ -446,14 +441,11 @@ template AmuletRules
446441 summary : OpenMiningRoundSummary
447442 controller dso
448443 do
449- now <- getTime
450444 miningRound <- fetchAndArchive (ForDso with dso) miningRoundCid
451445 validateOpenMiningRoundSummary summary
452446
453- let
454- optDevelopmentFundPercentage = (.percentage) <$> (getValueAsOf now configSchedule).developmentFundConfig
455- params = computeIssuingRoundParameters
456- miningRound.tickDuration miningRound.amuletPrice miningRound.issuanceConfig summary optDevelopmentFundPercentage
447+ let params = computeIssuingRoundParameters
448+ miningRound.tickDuration miningRound.amuletPrice miningRound.issuanceConfig summary
457449
458450 -- record unclaimed reward contract
459451 let totalUnclaimedRewards = params.unclaimedValidatorRewards + params.unclaimedAppRewards + params.unclaimedSvRewards
@@ -472,6 +464,7 @@ template AmuletRules
472464 else pure None
473465
474466 -- create issuing round
467+ now <- getTime
475468 let tickDuration = miningRound.tickDuration
476469 let opensAt = addRelTime now tickDuration
477470 let targetClosesAt = addRelTime opensAt (tickDuration + tickDuration)
@@ -756,13 +749,11 @@ data RewardsIssuanceConfig = RewardsIssuanceConfig with
756749 issueValidatorRewards : Bool
757750
758751-- | Execute a transfer.
759- executeTransfer
760- : RewardsIssuanceConfig -> TransferContext -> Party -> Optional DevelopmentFundConfig -> Transfer
761- -> Update TransferResult
762- executeTransfer config context dso optFundConfig t = do
752+ executeTransfer : RewardsIssuanceConfig -> TransferContext -> Party -> Transfer -> Update TransferResult
753+ executeTransfer config context dso t = do
763754 -- compute summaries
764755 csum <- summarizeAndValidateContext context dso t
765- isum <- summarizeAndConsumeInputs csum dso t.sender t.inputs optFundConfig
756+ isum <- summarizeAndConsumeInputs csum dso t.sender t.inputs
766757 osum <- preprocessOutputs csum.config t.sender t.outputs
767758 summary <- summarizeTransfer t.sender csum.openRound csum.config isum osum
768759 -- check that overall transfer constraints are satisfied
@@ -877,8 +868,8 @@ getIssuingMiningRound csum round = do
877868 Some issuingRound -> pure issuingRound
878869
879870summarizeAndConsumeInputs
880- : TransferContextSummary -> Party -> Party -> [TransferInput] -> Optional DevelopmentFundConfig -> Update TransferInputsSummary
881- summarizeAndConsumeInputs csum dso sender inps optFundConfig = do
871+ : TransferContextSummary -> Party -> Party -> [TransferInput] -> Update TransferInputsSummary
872+ summarizeAndConsumeInputs csum dso sender inps = do
882873 foldlA (summarizeAndConsumeInput csum.openRound.round) initialSummary inps
883874 where
884875 forOwner = ForOwner with dso; owner = sender
@@ -1010,13 +1001,9 @@ summarizeAndConsumeInputs csum dso sender inps optFundConfig = do
10101001 totalDevelopmentFundAmount = s.totalDevelopmentFundAmount
10111002
10121003 summarizeAndConsumeInput _round s (InputDevelopmentFundCoupon couponCid) = do
1013- let abortWithBeneficiaryNotConfigured =
1014- abort "DevelopmentFundCoupon cannot be consumed without a beneficiary in the development fund configuration"
1015- case optFundConfig of
1016- None -> abortWithBeneficiaryNotConfigured
1017- Some (DevelopmentFundConfig { beneficiary = None }) -> abortWithBeneficiaryNotConfigured
1018- Some (DevelopmentFundConfig { beneficiary = Some beneficiary }) ->
1019- require "sender matches development fund beneficiary" $ sender == beneficiary
1004+ case csum.config.optDevelopmentFundBeneficiary of
1005+ None -> abort "DevelopmentFundCoupon cannot be consumed without the Development Fund beneficiary configured"
1006+ Some developmentFundBeneficiary -> require "sender matches development fund beneficiary" $ sender == developmentFundBeneficiary
10201007 coupon <- fetchAndArchive forDso couponCid
10211008 return TransferInputsSummary with
10221009 totalAmuletAmount = s.totalAmuletAmount
@@ -1210,6 +1197,7 @@ scaleFees s c = TransferConfig with
12101197 maxNumInputs = c.maxNumInputs
12111198 maxNumOutputs = c.maxNumOutputs
12121199 maxNumLockHolders = c.maxNumLockHolders
1200+ optDevelopmentFundBeneficiary = c.optDevelopmentFundBeneficiary
12131201
12141202transferConfigAmuletFromOpenRound : OpenMiningRound -> TransferConfig Amulet
12151203transferConfigAmuletFromOpenRound openRound = scaleFees (1.0 / openRound.amuletPrice) openRound.transferConfigUsd
@@ -1592,8 +1580,7 @@ template TransferPreapproval
15921580 amuletRules <- fetchPublicReferenceData (ForDso dso) context.amuletRules (AmuletRules_Fetch dso)
15931581 let configUsd = getValueAsOf now amuletRules.configSchedule
15941582 (amuletPaid, _) <- computeTransferPreapprovalFee extension configUsd context.context dso
1595- (transferResult, meta) <-
1596- splitAndBurn provider amuletPaid inputs context.context dso "renew TransferPreapproval" configUsd.developmentFundConfig
1583+ (transferResult, meta) <- splitAndBurn provider amuletPaid inputs context.context dso "renew TransferPreapproval"
15971584 transferPreapprovalCid <- create this with
15981585 lastRenewedAt = now
15991586 expiresAt = newExpiresAt
@@ -1651,15 +1638,13 @@ computeTransferPreapprovalFee duration amuletConfig context dso = do
16511638 let feeAmulet = feeUsd / contextMiningRound.amuletPrice
16521639 pure (feeAmulet, feeUsd)
16531640
1654- splitAndBurn
1655- : Party -> Decimal -> [TransferInput] -> TransferContext -> Party -> Text -> Optional DevelopmentFundConfig
1656- -> Update (TransferResult, Metadata)
1657- splitAndBurn sender amount inputs context dso usage optFundConfig = do
1641+ splitAndBurn : Party -> Decimal -> [TransferInput] -> TransferContext -> Party -> Text -> Update (TransferResult, Metadata)
1642+ splitAndBurn sender amount inputs context dso usage = do
16581643-- do not create activity records as part of the transfer. We create a validator activity record for the full burn below.
16591644 let rewardsConfig = RewardsIssuanceConfig with
16601645 issueAppRewards = False
16611646 issueValidatorRewards = False
1662- transferResult <- executeTransfer rewardsConfig context dso optFundConfig Transfer with
1647+ transferResult <- executeTransfer rewardsConfig context dso Transfer with
16631648 sender
16641649 provider = sender
16651650 inputs
0 commit comments