agora-0.1.0
Maintaineremi@haskell.fyi
Safe HaskellSafe-Inferred
LanguageHaskell2010

Agora.Stake

Description

Vote-lockable stake UTXOs holding GT.

Synopsis

Haskell-land

data StakeDatum Source #

Haskell-level datum for Stake scripts.

Since: 0.1.0

Constructors

StakeDatum 

Fields

Instances

Instances details
Generic StakeDatum Source # 
Instance details

Defined in Agora.Stake

Associated Types

type Rep StakeDatum :: Type -> Type Source #

Show StakeDatum Source # 
Instance details

Defined in Agora.Stake

PConstantDecl StakeDatum Source # 
Instance details

Defined in Agora.Stake

FromData StakeDatum Source # 
Instance details

Defined in Agora.Stake

ToData StakeDatum Source # 
Instance details

Defined in Agora.Stake

UnsafeFromData StakeDatum Source # 
Instance details

Defined in Agora.Stake

type Rep StakeDatum Source # 
Instance details

Defined in Agora.Stake

type Rep StakeDatum = D1 ('MetaData "StakeDatum" "Agora.Stake" "agora-0.1.0-C1o5klqsCO77ggIWQdJiNp" 'False) (C1 ('MetaCons "StakeDatum" 'PrefixI 'True) (S1 ('MetaSel ('Just "stakedAmount") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Tagged GTTag Integer)) :*: (S1 ('MetaSel ('Just "owner") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PubKeyHash) :*: S1 ('MetaSel ('Just "lockedBy") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [ProposalLock]))))
type PConstantRepr StakeDatum Source #

Since: 0.1.0

Instance details

Defined in Agora.Stake

type PConstanted StakeDatum Source # 
Instance details

Defined in Agora.Stake

data StakeRedeemer Source #

Haskell-level redeemer for Stake scripts.

Since: 0.1.0

Constructors

DepositWithdraw (Tagged GTTag Integer)

Deposit or withdraw a discrete amount of the staked governance token. Stake must be unlocked.

Destroy

Destroy a stake, retrieving its LQ, the minimum ADA and any other assets. Stake must be unlocked.

PermitVote ProposalLock

Permit a Vote to be added onto a Proposal. This also adds a lock to the lockedBy field. See ProposalLock. This needs to be done in sync with casting a vote, otherwise it's possible for a lock to be permanently placed on the stake, and then the funds are lost.

RetractVotes [ProposalLock]

Retract a vote, removing it from the lockedBy field. See ProposalLock. This action checks for permission of the Proposal. Finished proposals are always allowed to have votes retracted and won't affect the Proposal datum, allowing Stakes to be unlocked.

WitnessStake

The owner can consume stake if nothing is changed about it. If the proposal token moves, this is equivalent to the owner consuming it.

Instances

Instances details
Generic StakeRedeemer Source # 
Instance details

Defined in Agora.Stake

Associated Types

type Rep StakeRedeemer :: Type -> Type Source #

Show StakeRedeemer Source # 
Instance details

Defined in Agora.Stake

PConstantDecl StakeRedeemer Source # 
Instance details

Defined in Agora.Stake

FromData StakeRedeemer Source # 
Instance details

Defined in Agora.Stake

ToData StakeRedeemer Source # 
Instance details

Defined in Agora.Stake

UnsafeFromData StakeRedeemer Source # 
Instance details

Defined in Agora.Stake

type Rep StakeRedeemer Source # 
Instance details

Defined in Agora.Stake

type Rep StakeRedeemer = D1 ('MetaData "StakeRedeemer" "Agora.Stake" "agora-0.1.0-C1o5klqsCO77ggIWQdJiNp" 'False) ((C1 ('MetaCons "DepositWithdraw" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Tagged GTTag Integer))) :+: C1 ('MetaCons "Destroy" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "PermitVote" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ProposalLock)) :+: (C1 ('MetaCons "RetractVotes" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [ProposalLock])) :+: C1 ('MetaCons "WitnessStake" 'PrefixI 'False) (U1 :: Type -> Type))))
type PConstantRepr StakeRedeemer Source # 
Instance details

Defined in Agora.Stake

type PConstanted StakeRedeemer Source # 
Instance details

Defined in Agora.Stake

data Stake Source #

Parameters for creating Stake scripts.

Since: 0.1.0

Constructors

Stake 

Fields

Instances

Instances details
Generic Stake Source # 
Instance details

Defined in Agora.Stake

Associated Types

type Rep Stake :: Type -> Type Source #

Methods

from :: Stake -> Rep Stake x Source #

to :: Rep Stake x -> Stake Source #

type Rep Stake Source #

Since: 0.1.0

Instance details

Defined in Agora.Stake

type Rep Stake = D1 ('MetaData "Stake" "Agora.Stake" "agora-0.1.0-C1o5klqsCO77ggIWQdJiNp" 'False) (C1 ('MetaCons "Stake" 'PrefixI 'True) (S1 ('MetaSel ('Just "gtClassRef") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Tagged GTTag AssetClass)) :*: S1 ('MetaSel ('Just "proposalSTClass") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 AssetClass)))

data ProposalLock Source #

A lock placed on a Stake datum in order to prevent depositing and withdrawing when votes are in place.

NOTE: Due to retracting votes always being possible, this lock will only lock with contention on the proposal.

FIXME: Contention on Proposals could create contention on voting which in turn creates contention on stakers.

Vaguely this is the dependency graph for this locking interaction. Both the stake validator and the proposal validator are only able to check for one another through the datum belonging to the ST:

    ┌─────────────────┐   ┌────────────────────┐
    │ Stake Validator ├─┐ │ Proposal Validator │
    └────────┬────────┘ │ └──────┬─────┬───────┘
             │          │        │     │
             │        ┌─┼────────┘     │
             ▼        │ │              ▼
    ┌──────────────┐  │ │ ┌─────────────────┐
    │ Stake Policy │◄─┘ └►│ Proposal Policy │
    └──────────────┘      └─────────────────┘
    

Since: 0.1.0

Constructors

ProposalLock 

Fields

Instances

Instances details
Generic ProposalLock Source # 
Instance details

Defined in Agora.Stake

Associated Types

type Rep ProposalLock :: Type -> Type Source #

Show ProposalLock Source #

Since: 0.1.0

Instance details

Defined in Agora.Stake

PConstantDecl ProposalLock Source # 
Instance details

Defined in Agora.Stake

FromData ProposalLock Source # 
Instance details

Defined in Agora.Stake

ToData ProposalLock Source # 
Instance details

Defined in Agora.Stake

UnsafeFromData ProposalLock Source # 
Instance details

Defined in Agora.Stake

type Rep ProposalLock Source #

Since: 0.1.0

Instance details

Defined in Agora.Stake

type Rep ProposalLock = D1 ('MetaData "ProposalLock" "Agora.Stake" "agora-0.1.0-C1o5klqsCO77ggIWQdJiNp" 'False) (C1 ('MetaCons "ProposalLock" 'PrefixI 'True) (S1 ('MetaSel ('Just "vote") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ResultTag) :*: S1 ('MetaSel ('Just "proposalId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ProposalId)))
type PConstantRepr ProposalLock Source # 
Instance details

Defined in Agora.Stake

type PConstanted ProposalLock Source # 
Instance details

Defined in Agora.Stake

Plutarch-land

newtype PStakeDatum (s :: S) Source #

Plutarch-level datum for Stake scripts.

Since: 0.1.0

Constructors

PStakeDatum 

Fields

Instances

Instances details
PEq PStakeDatum Source #

Since: 0.1.0

Instance details

Defined in Agora.Stake

Methods

(#==) :: forall (s :: S). Term s PStakeDatum -> Term s PStakeDatum -> Term s PBool Source #

PIsData PStakeDatum Source #

Since: 0.1.0

Instance details

Defined in Agora.Stake

Methods

pfromDataImpl :: forall (s :: S). Term s (PAsData PStakeDatum) -> Term s PStakeDatum Source #

pdataImpl :: forall (s :: S). Term s PStakeDatum -> Term s PData Source #

PIsDataRepr PStakeDatum Source # 
Instance details

Defined in Agora.Stake

Associated Types

type PIsDataReprRepr PStakeDatum :: [[PLabeledType]] Source #

Methods

pconRepr :: forall (s :: S). PStakeDatum s -> Term s (PDataSum (PIsDataReprRepr PStakeDatum)) Source #

pmatchRepr :: forall (s :: S) (b :: PType). Term s (PDataSum (PIsDataReprRepr PStakeDatum)) -> (PStakeDatum s -> Term s b) -> Term s b Source #

PDataFields PStakeDatum Source # 
Instance details

Defined in Agora.Stake

Associated Types

type PFields PStakeDatum :: [PLabeledType] Source #

Methods

ptoFields :: forall (s :: S). Term s PStakeDatum -> Term s (PDataRecord (PFields PStakeDatum)) Source #

PlutusType PStakeDatum Source # 
Instance details

Defined in Agora.Stake

Associated Types

type PInner PStakeDatum b' :: PType Source #

Methods

pcon' :: forall (s :: S) (b :: PType). PStakeDatum s -> Term s (PInner PStakeDatum b) Source #

pmatch' :: forall (s :: S) (b :: PType). Term s (PInner PStakeDatum b) -> (PStakeDatum s -> Term s b) -> Term s b Source #

PUnsafeLiftDecl PStakeDatum Source #

Since: 0.1.0

Instance details

Defined in Agora.Stake

Associated Types

type PLifted PStakeDatum = (r :: Type) Source #

PTryFrom PData (PAsData PStakeDatum) Source # 
Instance details

Defined in Agora.Stake

Methods

ptryFrom' :: forall (s :: S) (r :: PType). Term s PData -> ((Term s (PAsData PStakeDatum), Reduce (PTryFromExcess PData (PAsData PStakeDatum) s)) -> Term s r) -> Term s r Source #

Generic (PStakeDatum s) Source # 
Instance details

Defined in Agora.Stake

Associated Types

type Rep (PStakeDatum s) :: Type -> Type Source #

Generic (PStakeDatum s) Source # 
Instance details

Defined in Agora.Stake

Associated Types

type Code (PStakeDatum s) :: [[Type]] Source #

type PIsDataReprRepr PStakeDatum Source #

Since: 0.1.0

Instance details

Defined in Agora.Stake

type PIsDataReprRepr PStakeDatum = PDataRecordFields2 (PCode 'SI PStakeDatum)
type PFields PStakeDatum Source #

Since: 0.1.0

Instance details

Defined in Agora.Stake

type PLifted PStakeDatum Source # 
Instance details

Defined in Agora.Stake

type PInner PStakeDatum b' Source #

Since: 0.1.0

Instance details

Defined in Agora.Stake

type PTryFromExcess PData (PAsData PStakeDatum) Source #

Since: 0.1.0

Instance details

Defined in Agora.Stake

type Rep (PStakeDatum s) Source #

Since: 0.1.0

Instance details

Defined in Agora.Stake

type Rep (PStakeDatum s) = D1 ('MetaData "PStakeDatum" "Agora.Stake" "agora-0.1.0-C1o5klqsCO77ggIWQdJiNp" 'True) (C1 ('MetaCons "PStakeDatum" 'PrefixI 'True) (S1 ('MetaSel ('Just "getStakeDatum") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Term s (PDataRecord '["stakedAmount" := PDiscrete GTTag, "owner" := PPubKeyHash, "lockedBy" := PBuiltinList (PAsData PProposalLock)])))))
type Code (PStakeDatum s) Source #

Since: 0.1.0

Instance details

Defined in Agora.Stake

data PStakeRedeemer (s :: S) Source #

Plutarch-level redeemer for Stake scripts.

Since: 0.1.0

Constructors

PDepositWithdraw (Term s (PDataRecord '["delta" := PDiscrete GTTag]))

Deposit or withdraw a discrete amount of the staked governance token.

PDestroy (Term s (PDataRecord '[]))

Destroy a stake, retrieving its LQ, the minimum ADA and any other assets.

PPermitVote (Term s (PDataRecord '["lock" := PProposalLock])) 
PRetractVotes (Term s (PDataRecord '["locks" := PBuiltinList (PAsData PProposalLock)])) 
PWitnessStake (Term s (PDataRecord '[])) 

Instances

Instances details
PIsData PStakeRedeemer Source #

Since: 0.1.0

Instance details

Defined in Agora.Stake

Methods

pfromDataImpl :: forall (s :: S). Term s (PAsData PStakeRedeemer) -> Term s PStakeRedeemer Source #

pdataImpl :: forall (s :: S). Term s PStakeRedeemer -> Term s PData Source #

PIsDataRepr PStakeRedeemer Source # 
Instance details

Defined in Agora.Stake

Associated Types

type PIsDataReprRepr PStakeRedeemer :: [[PLabeledType]] Source #

Methods

pconRepr :: forall (s :: S). PStakeRedeemer s -> Term s (PDataSum (PIsDataReprRepr PStakeRedeemer)) Source #

pmatchRepr :: forall (s :: S) (b :: PType). Term s (PDataSum (PIsDataReprRepr PStakeRedeemer)) -> (PStakeRedeemer s -> Term s b) -> Term s b Source #

PlutusType PStakeRedeemer Source # 
Instance details

Defined in Agora.Stake

Associated Types

type PInner PStakeRedeemer b' :: PType Source #

Methods

pcon' :: forall (s :: S) (b :: PType). PStakeRedeemer s -> Term s (PInner PStakeRedeemer b) Source #

pmatch' :: forall (s :: S) (b :: PType). Term s (PInner PStakeRedeemer b) -> (PStakeRedeemer s -> Term s b) -> Term s b Source #

PUnsafeLiftDecl PStakeRedeemer Source # 
Instance details

Defined in Agora.Stake

Associated Types

type PLifted PStakeRedeemer = (r :: Type) Source #

PTryFrom PData (PAsData PStakeRedeemer) Source # 
Instance details

Defined in Agora.Stake

Methods

ptryFrom' :: forall (s :: S) (r :: PType). Term s PData -> ((Term s (PAsData PStakeRedeemer), Reduce (PTryFromExcess PData (PAsData PStakeRedeemer) s)) -> Term s r) -> Term s r Source #

Generic (PStakeRedeemer s) Source # 
Instance details

Defined in Agora.Stake

Associated Types

type Rep (PStakeRedeemer s) :: Type -> Type Source #

Generic (PStakeRedeemer s) Source # 
Instance details

Defined in Agora.Stake

Associated Types

type Code (PStakeRedeemer s) :: [[Type]] Source #

type PIsDataReprRepr PStakeRedeemer Source #

Since: 0.1.0

Instance details

Defined in Agora.Stake

type PLifted PStakeRedeemer Source # 
Instance details

Defined in Agora.Stake

type PInner PStakeRedeemer b' Source #

Since: 0.1.0

Instance details

Defined in Agora.Stake

type PTryFromExcess PData (PAsData PStakeRedeemer) Source # 
Instance details

Defined in Agora.Stake

type Rep (PStakeRedeemer s) Source #

Since: 0.1.0

Instance details

Defined in Agora.Stake

type Code (PStakeRedeemer s) Source #

Since: 0.1.0

Instance details

Defined in Agora.Stake

newtype PProposalLock (s :: S) Source #

Plutarch-level version of ProposalLock.

Since: 0.1.0

Constructors

PProposalLock 

Fields

Instances

Instances details
PEq PProposalLock Source # 
Instance details

Defined in Agora.Stake

Methods

(#==) :: forall (s :: S). Term s PProposalLock -> Term s PProposalLock -> Term s PBool Source #

PIsData PProposalLock Source # 
Instance details

Defined in Agora.Stake

Methods

pfromDataImpl :: forall (s :: S). Term s (PAsData PProposalLock) -> Term s PProposalLock Source #

pdataImpl :: forall (s :: S). Term s PProposalLock -> Term s PData Source #

PIsDataRepr PProposalLock Source # 
Instance details

Defined in Agora.Stake

Associated Types

type PIsDataReprRepr PProposalLock :: [[PLabeledType]] Source #

Methods

pconRepr :: forall (s :: S). PProposalLock s -> Term s (PDataSum (PIsDataReprRepr PProposalLock)) Source #

pmatchRepr :: forall (s :: S) (b :: PType). Term s (PDataSum (PIsDataReprRepr PProposalLock)) -> (PProposalLock s -> Term s b) -> Term s b Source #

PDataFields PProposalLock Source # 
Instance details

Defined in Agora.Stake

Associated Types

type PFields PProposalLock :: [PLabeledType] Source #

PlutusType PProposalLock Source # 
Instance details

Defined in Agora.Stake

Associated Types

type PInner PProposalLock b' :: PType Source #

Methods

pcon' :: forall (s :: S) (b :: PType). PProposalLock s -> Term s (PInner PProposalLock b) Source #

pmatch' :: forall (s :: S) (b :: PType). Term s (PInner PProposalLock b) -> (PProposalLock s -> Term s b) -> Term s b Source #

PUnsafeLiftDecl PProposalLock Source # 
Instance details

Defined in Agora.Stake

Associated Types

type PLifted PProposalLock = (r :: Type) Source #

PTryFrom PData (PAsData PProposalLock) Source # 
Instance details

Defined in Agora.Stake

Methods

ptryFrom' :: forall (s :: S) (r :: PType). Term s PData -> ((Term s (PAsData PProposalLock), Reduce (PTryFromExcess PData (PAsData PProposalLock) s)) -> Term s r) -> Term s r Source #

Generic (PProposalLock s) Source # 
Instance details

Defined in Agora.Stake

Associated Types

type Rep (PProposalLock s) :: Type -> Type Source #

Generic (PProposalLock s) Source # 
Instance details

Defined in Agora.Stake

Associated Types

type Code (PProposalLock s) :: [[Type]] Source #

type PIsDataReprRepr PProposalLock Source # 
Instance details

Defined in Agora.Stake

type PIsDataReprRepr PProposalLock = PDataRecordFields2 (PCode 'SI PProposalLock)
type PFields PProposalLock Source # 
Instance details

Defined in Agora.Stake

type PLifted PProposalLock Source # 
Instance details

Defined in Agora.Stake

type PInner PProposalLock b' Source # 
Instance details

Defined in Agora.Stake

type PTryFromExcess PData (PAsData PProposalLock) Source # 
Instance details

Defined in Agora.Stake

type Rep (PProposalLock s) Source # 
Instance details

Defined in Agora.Stake

type Rep (PProposalLock s) = D1 ('MetaData "PProposalLock" "Agora.Stake" "agora-0.1.0-C1o5klqsCO77ggIWQdJiNp" 'True) (C1 ('MetaCons "PProposalLock" 'PrefixI 'True) (S1 ('MetaSel ('Just "getProposalLock") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Term s (PDataRecord '["vote" := PResultTag, "proposalTag" := PProposalId])))))
type Code (PProposalLock s) Source # 
Instance details

Defined in Agora.Stake

data PStakeUsage (s :: S) Source #

Represent the usage of a stake on a particular proposal. A stake can be used to either create or vote on a proposal.

Since: 0.1.0

Instances

Instances details
PEq PStakeUsage Source #

Since: 0.1.0

Instance details

Defined in Agora.Stake

Methods

(#==) :: forall (s :: S). Term s PStakeUsage -> Term s PStakeUsage -> Term s PBool Source #

PlutusType PStakeUsage Source # 
Instance details

Defined in Agora.Stake

Associated Types

type PInner PStakeUsage b' :: PType Source #

Methods

pcon' :: forall (s :: S) (b :: PType). PStakeUsage s -> Term s (PInner PStakeUsage b) Source #

pmatch' :: forall (s :: S) (b :: PType). Term s (PInner PStakeUsage b) -> (PStakeUsage s -> Term s b) -> Term s b Source #

Generic (PStakeUsage s) Source # 
Instance details

Defined in Agora.Stake

Associated Types

type Rep (PStakeUsage s) :: Type -> Type Source #

Generic (PStakeUsage s) Source # 
Instance details

Defined in Agora.Stake

Associated Types

type Code (PStakeUsage s) :: [[Type]] Source #

HasDatatypeInfo (PStakeUsage s) Source # 
Instance details

Defined in Agora.Stake

Associated Types

type DatatypeInfoOf (PStakeUsage s) :: DatatypeInfo Source #

type PInner PStakeUsage b' Source #

Since: 0.1.0

Instance details

Defined in Agora.Stake

type PInner PStakeUsage b' = ScottFn (ScottList 'SI (ToPType2 (Code (PStakeUsage 'SI))) b') b'
type Rep (PStakeUsage s) Source #

Since: 0.1.0

Instance details

Defined in Agora.Stake

type Rep (PStakeUsage s) = D1 ('MetaData "PStakeUsage" "Agora.Stake" "agora-0.1.0-C1o5klqsCO77ggIWQdJiNp" 'False) (C1 ('MetaCons "PVotedFor" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Term s PResultTag))) :+: (C1 ('MetaCons "PCreated" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PDidNothing" 'PrefixI 'False) (U1 :: Type -> Type)))
type Code (PStakeUsage s) Source #

Since: 0.1.0

Instance details

Defined in Agora.Stake

type DatatypeInfoOf (PStakeUsage s) Source #

Since: 0.1.0

Instance details

Defined in Agora.Stake

Utility functions

stakeLocked :: forall (s :: S). Term s (PStakeDatum :--> PBool) Source #

Check whether a Stake is locked. If it is locked, various actions are unavailable.

Since: 0.1.0

pgetStakeUsage :: Term _ (PBuiltinList (PAsData PProposalLock) :--> (PProposalId :--> PStakeUsage)) Source #

O(n) .Return the usage of a stake on a particular proposal, given the lockedBy field of a stake and the target proposal.

Since: 0.1.0