> ## Documentation Index
> Fetch the complete documentation index at: https://docs.canton.network/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> If you are building a Canton Network application, start from https://docs.canton.network/appdev/quickstart.md. To run only a local network for your own Daml code, without building the QuickStart demo, see https://docs.canton.network/sdks-tools/development-tools/localnet.md.

# Splice.Fees

> Documentation for Splice.Fees

Utility functions for different kinds of fees.

## Data Types

**data** ExpiringAmount

> ExpiringAmount
>
> > | Field | Type | Description |
> > | - | - | - |
> > | initialAmount | [Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135) | |
> > | createdAt | Round | |
> > | ratePerRound | RatePerRound | |
>
> **instance** [Eq](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#class-ghc-classes-eq-22713) ExpiringAmount
>
> **instance** [Ord](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#class-ghc-classes-ord-6395) ExpiringAmount
>
> **instance** [Show](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#class-ghc-show-show-65360) ExpiringAmount
>
> **instance** GetField "amount" Amulet ExpiringAmount
>
> **instance** GetField "createdAt" ExpiringAmount Round
>
> **instance** GetField "initialAmount" ExpiringAmount [Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135)
>
> **instance** GetField "ratePerRound" ExpiringAmount RatePerRound
>
> **instance** SetField "amount" Amulet ExpiringAmount
>
> **instance** SetField "createdAt" ExpiringAmount Round
>
> **instance** SetField "initialAmount" ExpiringAmount [Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135)
>
> **instance** SetField "ratePerRound" ExpiringAmount RatePerRound

**data** FixedFee

> A fixed fee independent of the action being taken. TODO(M3-90): check whether this name matches usage in financial terms, it probably isn't. Should it be 'flat-fee', 'constantfee', ... ???
>
> FixedFee
>
> > | Field | Type | Description |
> > | - | - | - |
> > | fee | [Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135) | |
>
> **instance** [Eq](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#class-ghc-classes-eq-22713) FixedFee
>
> **instance** [Ord](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#class-ghc-classes-ord-6395) FixedFee
>
> **instance** [Show](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#class-ghc-show-show-65360) FixedFee
>
> **instance** GetField "createFee" (TransferConfig unit) FixedFee
>
> **instance** GetField "fee" FixedFee [Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135)
>
> **instance** GetField "lockHolderFee" (TransferConfig unit) FixedFee
>
> **instance** SetField "createFee" (TransferConfig unit) FixedFee
>
> **instance** SetField "fee" FixedFee [Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135)
>
> **instance** SetField "lockHolderFee" (TransferConfig unit) FixedFee
>
> **instance** Patchable FixedFee

**data** RatePerDay

> RatePerDay
>
> > | Field | Type | Description |
> > | - | - | - |
> > | rate | [Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135) | |
>
> **instance** [Eq](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#class-ghc-classes-eq-22713) RatePerDay
>
> **instance** [Ord](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#class-ghc-classes-ord-6395) RatePerDay
>
> **instance** [Show](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#class-ghc-show-show-65360) RatePerDay
>
> **instance** GetField "rate" RatePerDay [Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135)
>
> **instance** SetField "rate" RatePerDay [Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135)

**data** RatePerRound

> RatePerRound
>
> > | Field | Type | Description |
> > | - | - | - |
> > | rate | [Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135) | |
>
> **instance** [Eq](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#class-ghc-classes-eq-22713) RatePerRound
>
> **instance** [Ord](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#class-ghc-classes-ord-6395) RatePerRound
>
> **instance** [Show](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#class-ghc-show-show-65360) RatePerRound
>
> **instance** GetField "holdingFee" (TransferConfig unit) RatePerRound
>
> **instance** GetField "holdingFee" (TransferConfigV2 unit) RatePerRound
>
> **instance** GetField "rate" RatePerRound [Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135)
>
> **instance** GetField "ratePerRound" ExpiringAmount RatePerRound
>
> **instance** SetField "holdingFee" (TransferConfig unit) RatePerRound
>
> **instance** SetField "holdingFee" (TransferConfigV2 unit) RatePerRound
>
> **instance** SetField "rate" RatePerRound [Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135)
>
> **instance** SetField "ratePerRound" ExpiringAmount RatePerRound
>
> **instance** Patchable RatePerRound

**data** SteppedRate

> A rate defined as a piecewise linear function, e.g., \`SteppedRate 0.01 \[(100.0, 0.001), (1000.0, 0.0001), (1000000, 0.00001)] corresponds to 1% of the first 100, 0.1% between 100 and 1000, 0.01% between 1000 and 1000000 and 0.001% for everything above that.
>
> SteppedRate
>
> > | Field | Type | Description |
> > | - | - | - |
> > | initialRate | [Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135) | |
> > | steps | \[([Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135), [Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135))] | |
>
> **instance** [Eq](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#class-ghc-classes-eq-22713) SteppedRate
>
> **instance** [Ord](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#class-ghc-classes-ord-6395) SteppedRate
>
> **instance** [Show](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#class-ghc-show-show-65360) SteppedRate
>
> **instance** GetField "initialRate" SteppedRate [Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135)
>
> **instance** GetField "steps" SteppedRate \[([Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135), [Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135))]
>
> **instance** GetField "transferFee" (TransferConfig unit) SteppedRate
>
> **instance** SetField "initialRate" SteppedRate [Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135)
>
> **instance** SetField "steps" SteppedRate \[([Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135), [Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135))]
>
> **instance** SetField "transferFee" (TransferConfig unit) SteppedRate
>
> **instance** Patchable SteppedRate

## Functions

relTimeToMicros
: [RelTime](https://docs.canton.network/appdev/reference/daml-standard-library/da-time.md#type-da-time-types-reltime-23082) -> [Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135)

microsPerDay
: [Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135)

relTimeToDays
: [RelTime](https://docs.canton.network/appdev/reference/daml-standard-library/da-time.md#type-da-time-types-reltime-23082) -> [Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135)

daysToRelTime
: [Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135) -> [RelTime](https://docs.canton.network/appdev/reference/daml-standard-library/da-time.md#type-da-time-types-reltime-23082)

relTimeToSeconds
: [RelTime](https://docs.canton.network/appdev/reference/daml-standard-library/da-time.md#type-da-time-types-reltime-23082) -> [Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135)

chargeRatePerRound
: RatePerRound -> RelRound -> [Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135)

scaleRatePerRound
: [Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135) -> RatePerRound -> RatePerRound

Scale a round rate such that

ALL s r dt. s \* chargeRatePerRound r dt = chargeRatePerRound (s `scaleRatePerRound` r) dt

positiveRatePerRound
: RatePerRound -> [Bool](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-bool-66265)

scaleFixedFee
: [Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135) -> FixedFee -> FixedFee

positiveFixedFee
: FixedFee -> [Bool](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-bool-66265)

validSteppedRate
: SteppedRate -> [Bool](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-bool-66265)

chargeSteppedRate
: SteppedRate -> [Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135) -> [Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135)

goChargeSteppedRate
: ([Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135), [Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135), [Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135)) -> \[([Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135), [Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135))] -> [Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135)

scaleSteppedRate
: [Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135) -> SteppedRate -> SteppedRate

Scale a fixed-plus-variable rate such that

ALL s r q. s \* chargeSteppedRate r (q/s) = chargeSteppedRate (s `scaleSteppedRate` r) q

validExpiringAmount
: ExpiringAmount -> [Bool](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-bool-66265)

expiringAmount
: RatePerRound -> [Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135) -> Round -> ExpiringAmount

Smart constructor for an expiring amount.

getValueAsOfRound0
: ExpiringAmount -> [Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135)

chargeRatePerDay
: RatePerDay -> [RelTime](https://docs.canton.network/appdev/reference/daml-standard-library/da-time.md#type-da-time-types-reltime-23082) -> [Decimal](https://docs.canton.network/appdev/reference/daml-standard-library/prelude.md#type-ghc-types-decimal-18135)

ratePerRoundToRatePerDay
: RatePerRound -> [RelTime](https://docs.canton.network/appdev/reference/daml-standard-library/da-time.md#type-da-time-types-reltime-23082) -> RatePerDay
