Skip to content

Commit 6569272

Browse files
cip-82: replace DevelomentFundConfig with IssuanceConfig.optDevelopmentFundPercentage and TransferConfig.optDevelopmentFundBeneficiary
1 parent 410d61e commit 6569272

File tree

8 files changed

+47
-78
lines changed

8 files changed

+47
-78
lines changed

daml/splice-amulet-test/daml/Splice/Scripts/TestLockAndAmuletExpiry.daml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ scaleAmuletConfig amuletPrice config = AmuletConfig with
3333
packageConfig = config.packageConfig
3434
transferPreapprovalFee = fmap (/ amuletPrice) config.transferPreapprovalFee
3535
featuredAppActivityMarkerAmount = fmap (/ amuletPrice) config.featuredAppActivityMarkerAmount
36-
developmentFundConfig = config.developmentFundConfig
3736

3837
test : Script ()
3938
test = script do

daml/splice-amulet-test/daml/Splice/Scripts/UnitTests/Issuance.daml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,11 @@ testE1 : Script ()
120120
testE1 = script do
121121
validateOpenMiningRoundSummary summaryExample1
122122

123-
expectedParameters_E1_0_0p5 === computeIssuingRoundParameters tickDuration amuletPrice issuanceConfig_0_0p5 summaryExample1 None
124-
expectedParameters_E1_0p5_1p5 === computeIssuingRoundParameters tickDuration amuletPrice issuanceConfig_0p5_1p5 summaryExample1 None
125-
expectedParameters_E1_1p5_5 === computeIssuingRoundParameters tickDuration amuletPrice issuanceConfig_1p5_5 summaryExample1 None
126-
expectedParameters_E1_5_10 === computeIssuingRoundParameters tickDuration amuletPrice issuanceConfig_5_10 summaryExample1 None
127-
expectedParameters_E1_10plus === computeIssuingRoundParameters tickDuration amuletPrice issuanceConfig_10plus summaryExample1 None
123+
expectedParameters_E1_0_0p5 === computeIssuingRoundParameters tickDuration amuletPrice issuanceConfig_0_0p5 summaryExample1
124+
expectedParameters_E1_0p5_1p5 === computeIssuingRoundParameters tickDuration amuletPrice issuanceConfig_0p5_1p5 summaryExample1
125+
expectedParameters_E1_1p5_5 === computeIssuingRoundParameters tickDuration amuletPrice issuanceConfig_1p5_5 summaryExample1
126+
expectedParameters_E1_5_10 === computeIssuingRoundParameters tickDuration amuletPrice issuanceConfig_5_10 summaryExample1
127+
expectedParameters_E1_10plus === computeIssuingRoundParameters tickDuration amuletPrice issuanceConfig_10plus summaryExample1
128128

129129

130130
-- Example 2: all zeros
@@ -154,7 +154,7 @@ testNoActivity : Script ()
154154
testNoActivity = script do
155155
validateOpenMiningRoundSummary summaryExamplNoActivity
156156

157-
expectedParameters_NoActivity_0_0p5 === computeIssuingRoundParameters tickDuration amuletPrice issuanceConfig_0_0p5 summaryExamplNoActivity None
157+
expectedParameters_NoActivity_0_0p5 === computeIssuingRoundParameters tickDuration amuletPrice issuanceConfig_0_0p5 summaryExamplNoActivity
158158

159159

160160
-- Example 3: low activity
@@ -185,7 +185,7 @@ testE4 : Script ()
185185
testE4 = script do
186186
validateOpenMiningRoundSummary summaryExample3
187187

188-
expectedParameters_E3_0_0p5 === computeIssuingRoundParameters tickDuration amuletPrice issuanceConfig_0_0p5 summaryExample3 None
188+
expectedParameters_E3_0_0p5 === computeIssuingRoundParameters tickDuration amuletPrice issuanceConfig_0_0p5 summaryExample3
189189

190190

191191
-- Example 4: millions of SV reward weight
@@ -216,7 +216,7 @@ testLargeSvRewardWeight : Script ()
216216
testLargeSvRewardWeight = script do
217217
validateOpenMiningRoundSummary summaryExamplNoActivity
218218

219-
let actual = computeIssuingRoundParameters tickDuration amuletPrice issuanceConfig_10plus summaryExampleLargeSvRewardWeight None
219+
let actual = computeIssuingRoundParameters tickDuration amuletPrice issuanceConfig_10plus summaryExampleLargeSvRewardWeight
220220
expectedParameters_LargeSvRewardWeight_10plus === actual
221221

222222

daml/splice-amulet/daml/Splice/AmuletConfig.daml

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ data TransferConfig unit = TransferConfig with
2929
maxNumInputs : Int -- ^ Maximum number of batch inputs for a transfer.
3030
maxNumOutputs : Int -- ^ Maximum number of batch outputs for a transfer.
3131
maxNumLockHolders : Int -- ^ Maximum number of lock holders allowed for a locked amulet.
32+
optDevelopmentFundBeneficiary : Optional Party -- ^ Beneficiary for the Development Fund under CIP-0082.
3233
deriving (Eq, Show)
3334

3435
-- | Configuration includes TransferConfig, issuance curve and tickDuration
@@ -45,8 +46,6 @@ data AmuletConfig unit = AmuletConfig with
4546
-- that should be used for command submissions.
4647
transferPreapprovalFee : Optional Decimal -- ^ Fee for keeping a transfer pre-approval around.
4748
featuredAppActivityMarkerAmount : Optional Decimal -- ^ $-amount used for the conversion from FeaturedAppActivityMarker -> AppRewardCoupon
48-
developmentFundConfig : Optional DevelopmentFundConfig
49-
-- ^ Configuration for the development fund mechanics from CIP-0082.
5049
deriving (Eq, Show)
5150

5251
-- $1/year specified as a daily rate
@@ -63,17 +62,15 @@ validAmuletConfig AmuletConfig
6362
, tickDuration
6463
, packageConfig
6564
, transferPreapprovalFee
66-
, featuredAppActivityMarkerAmount
67-
, developmentFundConfig }
65+
, featuredAppActivityMarkerAmount}
6866
=
6967
validTransferConfig transferConfig &&
7068
validIssuanceCurve issuanceCurve &&
7169
validAmuletDecentralizedSynchronizerConfig decentralizedSynchronizer &&
7270
tickDuration > days 0 &&
7371
validPackageConfig packageConfig &&
7472
optional True (>= 0.0) transferPreapprovalFee &&
75-
optional True (>= 0.0) featuredAppActivityMarkerAmount &&
76-
optional True validDevelopmentFundConfig developmentFundConfig
73+
optional True (>= 0.0) featuredAppActivityMarkerAmount
7774

7875
validTransferConfig : TransferConfig unit -> Bool
7976
validTransferConfig TransferConfig
@@ -115,19 +112,6 @@ data PackageConfig = PackageConfig
115112
validPackageConfig : PackageConfig -> Bool
116113
validPackageConfig _ = True
117114

118-
-- | Configuration for the Development Fund established under CIP-0082.
119-
--
120-
-- See Splice.Scripts.Parameters for concrete values.
121-
data DevelopmentFundConfig = DevelopmentFundConfig
122-
with
123-
beneficiary : Optional Party
124-
percentage : Decimal
125-
deriving (Show, Eq)
126-
127-
validDevelopmentFundConfig : DevelopmentFundConfig -> Bool
128-
validDevelopmentFundConfig DevelopmentFundConfig { percentage } =
129-
percentage >= 0.0 && percentage <= 1.0
130-
131115
instance Patchable (AmuletConfig USD) where
132116
patch new base current = AmuletConfig with
133117
transferConfig = patch new.transferConfig base.transferConfig current.transferConfig
@@ -137,7 +121,6 @@ instance Patchable (AmuletConfig USD) where
137121
packageConfig = patch new.packageConfig base.packageConfig current.packageConfig
138122
transferPreapprovalFee = patch new.transferPreapprovalFee base.transferPreapprovalFee current.transferPreapprovalFee
139123
featuredAppActivityMarkerAmount = patch new.featuredAppActivityMarkerAmount base.featuredAppActivityMarkerAmount current.featuredAppActivityMarkerAmount
140-
developmentFundConfig = patch new.developmentFundConfig base.developmentFundConfig current.developmentFundConfig
141124

142125
instance Patchable (TransferConfig USD) where
143126
patch new base current = TransferConfig with
@@ -149,6 +132,7 @@ instance Patchable (TransferConfig USD) where
149132
maxNumInputs = patch new.maxNumInputs base.maxNumInputs current.maxNumInputs
150133
maxNumOutputs = patch new.maxNumOutputs base.maxNumOutputs current.maxNumOutputs
151134
maxNumLockHolders = patch new.maxNumLockHolders base.maxNumLockHolders current.maxNumLockHolders
135+
optDevelopmentFundBeneficiary = patch new.optDevelopmentFundBeneficiary base.optDevelopmentFundBeneficiary current.optDevelopmentFundBeneficiary
152136

153137
instance Patchable PackageConfig where
154138
patch new base current = PackageConfig with
@@ -158,8 +142,3 @@ instance Patchable PackageConfig where
158142
validatorLifecycle = patch new.validatorLifecycle base.validatorLifecycle current.validatorLifecycle
159143
wallet = patch new.wallet base.wallet current.wallet
160144
walletPayments = patch new.walletPayments base.walletPayments current.walletPayments
161-
162-
instance Patchable DevelopmentFundConfig where
163-
patch new base current = DevelopmentFundConfig with
164-
beneficiary = patch new.beneficiary base.beneficiary current.beneficiary
165-
percentage = patch new.percentage base.percentage current.percentage

daml/splice-amulet/daml/Splice/AmuletRules.daml

Lines changed: 21 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import Splice.Api.Token.MetadataV1 as Api.Token.MetadataV1
2525
import Splice.Api.Token.HoldingV1 qualified as Api.Token.HoldingV1
2626
import Splice.Amulet
2727
import Splice.Amulet.TokenApiUtils
28-
import Splice.AmuletConfig (AmuletConfig(..), DevelopmentFundConfig(..), TransferConfig(..), validAmuletConfig, defaultTransferPreapprovalFee)
28+
import Splice.AmuletConfig (AmuletConfig(..), TransferConfig(..), validAmuletConfig, defaultTransferPreapprovalFee)
2929
import qualified Splice.AmuletConfig as Unit
3030
import Splice.Schedule
3131
import 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

879870
summarizeAndConsumeInputs
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

12141202
transferConfigAmuletFromOpenRound : OpenMiningRound -> TransferConfig Amulet
12151203
transferConfigAmuletFromOpenRound 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

daml/splice-amulet/daml/Splice/Issuance.daml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ data IssuanceConfig = IssuanceConfig with
2525
optValidatorFaucetCap : Optional Decimal
2626
-- ^ Maximal amount in $ for the per-validator issuance of validator faucet coupons;
2727
-- Introduced as part of CIP-3. Defaults to 2.85 USD.
28+
optDevelopmentFundPercentage : Optional Decimal
29+
-- ^ Percentage of each mint emission allocated to the Development Fund under CIP-0082.
2830
deriving (Eq, Show)
2931

3032
-- | Getter with the right default value for the validator faucet cap.
@@ -44,7 +46,8 @@ validIssuanceConfig this@IssuanceConfig{..} =
4446
&& validatorRewardCap >= 0.0
4547
&& featuredAppRewardCap >= 0.0
4648
&& unfeaturedAppRewardCap >= 0.0
47-
&& getValidatorFaucetCap this >= 0.0
49+
&& getValidatorFaucetCap this >= 0.0 &&
50+
optional True (\pct -> pct >= 0.0 && pct <= 1.0) optDevelopmentFundPercentage
4851

4952

5053
-- computation of issuance per round
@@ -83,10 +86,8 @@ validateOpenMiningRoundSummary summary = do
8386
require "totalUnfeaturedAppRewardCoupons >= 0.0" (summary.totalUnfeaturedAppRewardCoupons >= 0.0)
8487
require "totalValidatorFaucetCoupons >= 0" (getTotalValidatorFaucetCoupons summary >= 0)
8588

86-
computeIssuingRoundParameters
87-
: RelTime -> Decimal -> IssuanceConfig -> OpenMiningRoundSummary -> Optional Decimal
88-
-> IssuingRoundParameters
89-
computeIssuingRoundParameters tickDuration amuletPrice config summary optDevelopmentFundPercentage =
89+
computeIssuingRoundParameters : RelTime -> Decimal -> IssuanceConfig -> OpenMiningRoundSummary -> IssuingRoundParameters
90+
computeIssuingRoundParameters tickDuration amuletPrice config summary =
9091
IssuingRoundParameters with
9192
issuancePerValidatorRewardCoupon = validatorRewardIssuance.issuancePerCoupon
9293
issuancePerUnfeaturedAppRewardCoupon = unfeaturedAppIssuance.issuancePerCoupon
@@ -99,7 +100,7 @@ computeIssuingRoundParameters tickDuration amuletPrice config summary optDevelop
99100
issuancePerValidatorFaucetCoupon = validatorFaucetIssuance.issuancePerCoupon
100101
amuletsToIssueToDevelopmentFund
101102
where
102-
developmentFundPercentage = fromOptional 0.0 optDevelopmentFundPercentage
103+
developmentFundPercentage = fromOptional 0.0 config.optDevelopmentFundPercentage
103104

104105
amuletsToIssueToSvs =
105106
adjustedAmuletsToIssueInRound
@@ -190,3 +191,4 @@ instance Patchable IssuanceConfig where
190191
featuredAppRewardCap = patch new.featuredAppRewardCap base.featuredAppRewardCap current.featuredAppRewardCap
191192
unfeaturedAppRewardCap = patch new.unfeaturedAppRewardCap base.unfeaturedAppRewardCap current.unfeaturedAppRewardCap
192193
optValidatorFaucetCap = patch new.optValidatorFaucetCap base.optValidatorFaucetCap current.optValidatorFaucetCap
194+
optDevelopmentFundPercentage = patch new.optDevelopmentFundPercentage base.optDevelopmentFundPercentage current.optDevelopmentFundPercentage

0 commit comments

Comments
 (0)