Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
TrustlessSidechain.Reserve
Description
Synopsis
- mkReserveValidator :: VersionOracleConfig -> BuiltinData -> ReserveRedeemer -> ScriptContext -> Bool
- mkReserveValidatorUntyped :: BuiltinData -> BuiltinData -> BuiltinData -> BuiltinData -> BuiltinUnit
- compiledValidator :: CompiledCode (BuiltinData -> BuiltinData -> BuiltinData -> BuiltinData -> BuiltinUnit)
- serialisableReserveValidator :: SerialisedScript
- mkReserveAuthPolicy :: VersionOracleConfig -> BuiltinData -> ScriptContext -> Bool
- mkReserveAuthPolicyUntyped :: BuiltinData -> BuiltinData -> BuiltinData -> BuiltinUnit
- compiledReserveAuthPolicy :: CompiledCode (BuiltinData -> BuiltinData -> BuiltinData -> BuiltinUnit)
- serialisableReserveAuthPolicy :: SerialisedScript
- reserveAuthTokenTokenName :: TokenName
Reserve validator
- All redeemers require a Reserve UTXO input carrying a Reserve Auth token.
- All redeemers except
Handover
require a Reserve UTXO output carrying a Reserve Auth token. - The Reserve UTXO must have `VersionedGenericDatum ReserveDatum` as its datum.
- The Reserve UTXO carries native tokens, the
AssetClass
of which is specified inImmutableReserveSettings
in the datum.
Redeemers:
DepositToReserve
allows depositing native tokens into the Reserve.- It is a governance action (see
approvedByGovernance
). - Requires the output Reserve UTXO to carry the datum from the input Reserve UTXO unaltered.
- Requires the output Reserve UTXO to carry more native tokens than the input Reserve UTXO.
Required reference inputs:
- It is a governance action (see
TransferToIlliquidCirculationSupply
allows transferring native tokens from the Reserve to the Illiquid Circulation Supply (ICS).- Total amount of tokens that can be released at any given time is determined by the so called V-function. This function is encoded as a minting policy. A transaction transferring native tokens to the ICS should mint V-function tokens with this minting policy. The validator requires that \(pcTokensTransferred = pcTokensTransferredUntilNow - numOfVtTokensMinted\).
Required reference inputs:
VersionOracle
UTXO forreserveAuthPolicyId
VersionOracle
UTXO forilliquidCirculationSupplyValidatorId
- V-function minting policy referenced by
tokenKind
in the Reserve UTXO datum
UpdateReserve
allows updatingMutableReserveSettings
in the Reserve UTXO.- It is a governance action (see
approvedByGovernance
). - Assets may not change in the Reserve UTXO.
- Only
MutableReserveSettings
portion of the Reserve datum may change. Required reference inputs:
VersionOracle
UTXO forreserveAuthPolicyId
- It is a governance action (see
Handover
allows transferring all remaining native tokens to the ICS, essentially ending the Reserve.- It is a governance action (see
approvedByGovernance
). - Reserve Auth token must be burned.
- All native tokens must be transferred to ICS.
Required reference inputs:
- It is a governance action (see
Error codes:
- ERROR-RESERVE-01: Governance approval is not present
- ERROR-RESERVE-02: Datum of the propagated reserve utxo changes
- ERROR-RESERVE-03: Assets of the propagated reserve utxo don't increase by native tokens
- ERROR-RESERVE-04: No unique input utxo carrying authentication token
- ERROR-RESERVE-05: No unique output utxo at the reserve address and carrying authentication token
- ERROR-RESERVE-06: Datum of input reserve utxo malformed
- ERROR-RESERVE-07: Datum of output reserve utxo malformed
- ERROR-RESERVE-08: Governance approval is not present
- ERROR-RESERVE-09: Datum of the propagated reserve utxo changes not only by immutable settings
- ERROR-RESERVE-10: Assets of the propagated reserve utxo change
- ERROR-RESERVE-11: Assets of the propagated reserve utxo don't decrease by native tokens in desired way
- ERROR-RESERVE-12: Datum of the propagated reserve utxo changes not only by stats in desired way
- ERROR-RESERVE-13: Incorrect amount of native tokens goes into an illiquid circulation supply
- ERROR-RESERVE-14: No unique output utxo at the illiquid circulation supply address
- ERROR-RESERVE-15: Governance approval is not present
- ERROR-RESERVE-16: An authentication token is not burnt
- ERROR-RESERVE-17: Not all native tokens are transferred to illiquid circulation supply
- ERROR-RESERVE-18: Continuing output exists without an authentication token
mkReserveValidator :: VersionOracleConfig -> BuiltinData -> ReserveRedeemer -> ScriptContext -> Bool #
mkReserveValidatorUntyped :: BuiltinData -> BuiltinData -> BuiltinData -> BuiltinData -> BuiltinUnit #
compiledValidator :: CompiledCode (BuiltinData -> BuiltinData -> BuiltinData -> BuiltinData -> BuiltinUnit) #
Reserve Auth token minting policy
Minting a Reserve Auth token initializes the Reserve.
- It is a governance action (see
approvedByGovernance
). - Only a single token may be minted at once.
- Minted token must go to an UTXO at the Reserve validator address, the Reserve UTXO.
- The Reserve UTXO must be unique at the address and carry correct initial datum (where
ReserveStats
is 0). Required reference inputs:
VersionOracle
UTXO forreserveValidatorId
Burning Reserve Auth token is always allowed by the minting policy.
In practice this can only happen in the Reserve validator Handover
redeemer.
The burning of the Reserve Auth token signifies the end of life for the Reserve.
Error codes:
- ERROR-RESERVE-AUTH-01: Governance approval is not present
- ERROR-RESERVE-AUTH-02: Single reserve authentication token is not minted
- ERROR-RESERVE-AUTH-03: Output reserve UTxO doesn't carry auth token
- ERROR-RESERVE-AUTH-04: Output reserve UTxO doesn't carry correct initial datum
- ERROR-RESERVE-AUTH-05: No unique output UTxO at the reserve address
- ERROR-RESERVE-AUTH-06: Output reserve UTxO carries no inline datum or malformed datum
mkReserveAuthPolicy :: VersionOracleConfig -> BuiltinData -> ScriptContext -> Bool #