Safe Haskell | None |
---|---|
Language | Haskell2010 |
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 {
- bsReserves :: BC Integer
- bsStablecoins :: SC Integer
- bsReservecoins :: RC Integer
- bsMintingPolicyScript :: MintingPolicyHash
- data Stablecoin = Stablecoin {
- scOracle :: PaymentPubKey
- scFee :: Rational
- scMinReserveRatio :: Rational
- scMaxReserveRatio :: Rational
- scReservecoinDefaultPrice :: BC Integer
- scBaseCurrency :: AssetClass
- scStablecoinTokenName :: TokenName
- scReservecoinTokenName :: TokenName
- data Input = Input {
- inpSCAction :: SCAction
- inpConversionRate :: SignedMessage (Observation ConversionRate)
- 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
Functor SC Source # | |
Defined in Plutus.Contracts.Stablecoin | |
Lift DefaultUni a => Lift DefaultUni (SC a) Source # | |
Defined in Plutus.Contracts.Stablecoin | |
Eq a => Eq (SC a) Source # | |
Num a => Num (SC a) Source # | |
Show a => Show (SC a) Source # | |
Generic (SC a) Source # | |
FromJSON a => FromJSON (SC a) Source # | |
Defined in Plutus.Contracts.Stablecoin parseJSON :: Value -> Parser (SC a) parseJSONList :: Value -> Parser [SC a] | |
ToJSON a => ToJSON (SC a) Source # | |
Defined in Plutus.Contracts.Stablecoin | |
ToData a => ToData (SC a) Source # | |
Defined in Plutus.Contracts.Stablecoin toBuiltinData :: SC a -> BuiltinData | |
FromData a => FromData (SC a) Source # | |
Defined in Plutus.Contracts.Stablecoin fromBuiltinData :: BuiltinData -> Maybe (SC a) | |
AdditiveGroup a => AdditiveGroup (SC a) Source # | |
Defined in Plutus.Contracts.Stablecoin | |
AdditiveMonoid a => AdditiveMonoid (SC a) Source # | |
Defined in Plutus.Contracts.Stablecoin | |
AdditiveSemigroup a => AdditiveSemigroup (SC a) Source # | |
Defined in Plutus.Contracts.Stablecoin | |
Eq a => Eq (SC a) Source # | |
Defined in Plutus.Contracts.Stablecoin | |
MultiplicativeSemigroup a => MultiplicativeSemigroup (SC a) Source # | |
Defined in Plutus.Contracts.Stablecoin | |
Ord a => Ord (SC a) Source # | |
UnsafeFromData a => UnsafeFromData (SC a) Source # | |
Defined in Plutus.Contracts.Stablecoin unsafeFromBuiltinData :: BuiltinData -> SC a | |
Typeable DefaultUni SC Source # | |
Defined in Plutus.Contracts.Stablecoin | |
type Rep (SC a) Source # | |
Defined in Plutus.Contracts.Stablecoin |
An amount of reservecoins
Instances
Functor RC Source # | |
Defined in Plutus.Contracts.Stablecoin | |
Lift DefaultUni a => Lift DefaultUni (RC a) Source # | |
Defined in Plutus.Contracts.Stablecoin | |
Eq a => Eq (RC a) Source # | |
Num a => Num (RC a) Source # | |
Show a => Show (RC a) Source # | |
Generic (RC a) Source # | |
FromJSON a => FromJSON (RC a) Source # | |
Defined in Plutus.Contracts.Stablecoin parseJSON :: Value -> Parser (RC a) parseJSONList :: Value -> Parser [RC a] | |
ToJSON a => ToJSON (RC a) Source # | |
Defined in Plutus.Contracts.Stablecoin | |
ToData a => ToData (RC a) Source # | |
Defined in Plutus.Contracts.Stablecoin toBuiltinData :: RC a -> BuiltinData | |
FromData a => FromData (RC a) Source # | |
Defined in Plutus.Contracts.Stablecoin fromBuiltinData :: BuiltinData -> Maybe (RC a) | |
AdditiveGroup a => AdditiveGroup (RC a) Source # | |
Defined in Plutus.Contracts.Stablecoin | |
AdditiveMonoid a => AdditiveMonoid (RC a) Source # | |
Defined in Plutus.Contracts.Stablecoin | |
AdditiveSemigroup a => AdditiveSemigroup (RC a) Source # | |
Defined in Plutus.Contracts.Stablecoin | |
Eq a => Eq (RC a) Source # | |
Defined in Plutus.Contracts.Stablecoin | |
MultiplicativeSemigroup a => MultiplicativeSemigroup (RC a) Source # | |
Defined in Plutus.Contracts.Stablecoin | |
Ord a => Ord (RC a) Source # | |
UnsafeFromData a => UnsafeFromData (RC a) Source # | |
Defined in Plutus.Contracts.Stablecoin unsafeFromBuiltinData :: BuiltinData -> RC a | |
Typeable DefaultUni RC Source # | |
Defined in Plutus.Contracts.Stablecoin | |
type Rep (RC a) Source # | |
Defined in Plutus.Contracts.Stablecoin |
An amount of base currency coins (eg. Ada or some native currency)
Instances
Functor BC Source # | |
Defined in Plutus.Contracts.Stablecoin | |
Lift DefaultUni a => Lift DefaultUni (BC a) Source # | |
Defined in Plutus.Contracts.Stablecoin | |
Eq a => Eq (BC a) Source # | |
Num a => Num (BC a) Source # | |
Show a => Show (BC a) Source # | |
Generic (BC a) Source # | |
FromJSON a => FromJSON (BC a) Source # | |
Defined in Plutus.Contracts.Stablecoin parseJSON :: Value -> Parser (BC a) parseJSONList :: Value -> Parser [BC a] | |
ToJSON a => ToJSON (BC a) Source # | |
Defined in Plutus.Contracts.Stablecoin | |
ToData a => ToData (BC a) Source # | |
Defined in Plutus.Contracts.Stablecoin toBuiltinData :: BC a -> BuiltinData | |
FromData a => FromData (BC a) Source # | |
Defined in Plutus.Contracts.Stablecoin fromBuiltinData :: BuiltinData -> Maybe (BC a) | |
AdditiveGroup a => AdditiveGroup (BC a) Source # | |
Defined in Plutus.Contracts.Stablecoin | |
AdditiveMonoid a => AdditiveMonoid (BC a) Source # | |
Defined in Plutus.Contracts.Stablecoin | |
AdditiveSemigroup a => AdditiveSemigroup (BC a) Source # | |
Defined in Plutus.Contracts.Stablecoin | |
Eq a => Eq (BC a) Source # | |
Defined in Plutus.Contracts.Stablecoin | |
MultiplicativeSemigroup a => MultiplicativeSemigroup (BC a) Source # | |
Defined in Plutus.Contracts.Stablecoin | |
Ord a => Ord (BC a) Source # | |
UnsafeFromData a => UnsafeFromData (BC a) Source # | |
Defined in Plutus.Contracts.Stablecoin unsafeFromBuiltinData :: BuiltinData -> BC a | |
Typeable DefaultUni BC Source # | |
Defined in Plutus.Contracts.Stablecoin | |
type Rep (BC a) Source # | |
Defined in Plutus.Contracts.Stablecoin |
An amount of peg currency (eg. USD)
Instances
Functor PC Source # | |
Defined in Plutus.Contracts.Stablecoin | |
Lift DefaultUni a => Lift DefaultUni (PC a) Source # | |
Defined in Plutus.Contracts.Stablecoin | |
Eq a => Eq (PC a) Source # | |
Num a => Num (PC a) Source # | |
Show a => Show (PC a) Source # | |
Generic (PC a) Source # | |
FromJSON a => FromJSON (PC a) Source # | |
Defined in Plutus.Contracts.Stablecoin parseJSON :: Value -> Parser (PC a) parseJSONList :: Value -> Parser [PC a] | |
ToJSON a => ToJSON (PC a) Source # | |
Defined in Plutus.Contracts.Stablecoin | |
ToData a => ToData (PC a) Source # | |
Defined in Plutus.Contracts.Stablecoin toBuiltinData :: PC a -> BuiltinData | |
FromData a => FromData (PC a) Source # | |
Defined in Plutus.Contracts.Stablecoin fromBuiltinData :: BuiltinData -> Maybe (PC a) | |
AdditiveGroup a => AdditiveGroup (PC a) Source # | |
Defined in Plutus.Contracts.Stablecoin | |
AdditiveMonoid a => AdditiveMonoid (PC a) Source # | |
Defined in Plutus.Contracts.Stablecoin | |
AdditiveSemigroup a => AdditiveSemigroup (PC a) Source # | |
Defined in Plutus.Contracts.Stablecoin | |
Eq a => Eq (PC a) Source # | |
Defined in Plutus.Contracts.Stablecoin | |
MultiplicativeSemigroup a => MultiplicativeSemigroup (PC a) Source # | |
Defined in Plutus.Contracts.Stablecoin | |
Ord a => Ord (PC a) Source # | |
UnsafeFromData a => UnsafeFromData (PC a) Source # | |
Defined in Plutus.Contracts.Stablecoin unsafeFromBuiltinData :: BuiltinData -> PC a | |
Typeable DefaultUni PC Source # | |
Defined in Plutus.Contracts.Stablecoin | |
type Rep (PC a) Source # | |
Defined in Plutus.Contracts.Stablecoin |
The bank's state
BankState | |
|
Instances
data Stablecoin Source #
Stablecoin parameters.
Stablecoin | |
|
Instances
Input to the stablecoin state machine
Input | |
|
Instances
Action that can be performed on the stablecoin contract.
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
type ConversionRate = Rational Source #
Conversion rate from peg currency (eg. USD) to base currency (eg. Ada)
State machine client
typedValidator :: Stablecoin -> TypedValidator (StateMachine BankState Input) Source #
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 #
A Contract
that initialises the state machine and then accepts Input
transitions.
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 #