| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Plutus.Contracts.Stablecoin
Synopsis
- newtype SC a = SC {
- unSC :: a
- newtype RC a = RC {
- unRC :: a
- newtype BC a = BC {
- unBC :: a
- newtype PC a = PC {
- unPC :: a
- data BankState = BankState {}
- data Stablecoin = Stablecoin {}
- data Input = Input {}
- data SCAction
- = MintStablecoin (SC Integer)
- | MintReserveCoin (RC Integer)
- type ConversionRate = Rational
- typedValidator :: Stablecoin -> TypedValidator (StateMachine BankState Input)
- machineClient :: TypedValidator (StateMachine BankState Input) -> Stablecoin -> StateMachineClient BankState Input
- step :: forall i o. Stablecoin -> BankState -> Input -> Maybe (TxConstraints i o, BankState)
- contract :: Promise () StablecoinSchema StablecoinError ()
- data StablecoinError
- type StablecoinSchema = Endpoint "run step" Input .\/ Endpoint "initialise" Stablecoin
- stableCoins :: Stablecoin -> SC Integer -> Value
- reserveCoins :: Stablecoin -> RC Integer -> Value
- checkValidState :: Stablecoin -> BankState -> ConversionRate -> Either InvalidStateReason ()
Documentation
An amount of stablecoins
Instances
An amount of reservecoins
Instances
An amount of base currency coins (eg. Ada or some native currency)
Instances
An amount of peg currency (eg. USD)
Instances
The bank's state
Constructors
| BankState | |
Fields
| |
Instances
data Stablecoin Source #
Stablecoin parameters.
Constructors
| Stablecoin | |
Fields
| |
Instances
Input to the stablecoin state machine
Constructors
| Input | |
Fields
| |
Instances
| Eq Input Source # | |
| Show Input Source # | |
| Generic Input Source # | |
| ToJSON Input Source # | |
| FromJSON Input Source # | |
| UnsafeFromData Input Source # | |
Defined in Plutus.Contracts.Stablecoin Methods | |
| FromData Input Source # | |
Defined in Plutus.Contracts.Stablecoin Methods fromBuiltinData :: BuiltinData -> Maybe Input Source # | |
| ToData Input Source # | |
Defined in Plutus.Contracts.Stablecoin Methods toBuiltinData :: Input -> BuiltinData Source # | |
| type Rep Input Source # | |
Defined in Plutus.Contracts.Stablecoin type Rep Input = D1 ('MetaData "Input" "Plutus.Contracts.Stablecoin" "plutus-use-cases-1.1.0.0-9kk4ZO09YVFKU77qwQaRsf" 'False) (C1 ('MetaCons "Input" 'PrefixI 'True) (S1 ('MetaSel ('Just "inpSCAction") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SCAction) :*: S1 ('MetaSel ('Just "inpConversionRate") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (SignedMessage (Observation ConversionRate))))) | |
Action that can be performed on the stablecoin contract.
Constructors
| MintStablecoin (SC Integer) | Create a number stablecoins, depositing the matching amount of base currency |
| MintReserveCoin (RC Integer) | Create a number of reservecoins, depositing the matching amount of base currency |
Instances
| Eq SCAction Source # | |
| Show SCAction Source # | |
| Generic SCAction Source # | |
| ToJSON SCAction Source # | |
| FromJSON SCAction Source # | |
| UnsafeFromData SCAction Source # | |
Defined in Plutus.Contracts.Stablecoin Methods | |
| FromData SCAction Source # | |
Defined in Plutus.Contracts.Stablecoin Methods | |
| ToData SCAction Source # | |
Defined in Plutus.Contracts.Stablecoin Methods toBuiltinData :: SCAction -> BuiltinData Source # | |
| type Rep SCAction Source # | |
Defined in Plutus.Contracts.Stablecoin type Rep SCAction = D1 ('MetaData "SCAction" "Plutus.Contracts.Stablecoin" "plutus-use-cases-1.1.0.0-9kk4ZO09YVFKU77qwQaRsf" 'False) (C1 ('MetaCons "MintStablecoin" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (SC Integer))) :+: C1 ('MetaCons "MintReserveCoin" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (RC Integer)))) | |
type ConversionRate = Rational Source #
Conversion rate from peg currency (eg. USD) to base currency (eg. Ada)
State machine client
machineClient :: TypedValidator (StateMachine BankState Input) -> Stablecoin -> StateMachineClient BankState Input Source #
step :: forall i o. Stablecoin -> BankState -> Input -> Maybe (TxConstraints i o, BankState) Source #
Contract using the state machine
contract :: Promise () StablecoinSchema StablecoinError () Source #
data StablecoinError Source #
Instances
type StablecoinSchema = Endpoint "run step" Input .\/ Endpoint "initialise" Stablecoin Source #
Etc.
stableCoins :: Stablecoin -> SC Integer -> Value Source #
A Value with the given number of stablecoins
reserveCoins :: Stablecoin -> RC Integer -> Value Source #
A Value with the given number of reservecoins
checkValidState :: Stablecoin -> BankState -> ConversionRate -> Either InvalidStateReason () Source #