| Maintainer | connor@mlabs.city |
|---|---|
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Agora.Governor.Scripts
Description
Plutus scripts for Governors.
Synopsis
- governorPolicy :: Governor -> ClosedTerm PMintingPolicy
- governorValidator :: Governor -> ClosedTerm PValidator
- governorSTSymbolFromGovernor :: Governor -> CurrencySymbol
- governorSTAssetClassFromGovernor :: Governor -> AssetClass
- proposalSTAssetClassFromGovernor :: Governor -> AssetClass
- stakeSTSymbolFromGovernor :: Governor -> CurrencySymbol
- stakeFromGovernor :: Governor -> Stake
- stakeValidatorHashFromGovernor :: Governor -> ValidatorHash
- proposalFromGovernor :: Governor -> Proposal
- proposalValidatorHashFromGovernor :: Governor -> ValidatorHash
- proposalSTSymbolFromGovernor :: Governor -> CurrencySymbol
- stakeSTAssetClassFromGovernor :: Governor -> AssetClass
- governorValidatorHash :: Governor -> ValidatorHash
- authorityTokenFromGovernor :: Governor -> AuthorityToken
- authorityTokenSymbolFromGovernor :: Governor -> CurrencySymbol
GST
Governance state token, aka. GST, is an NFT that identifies a UTXO that carries the state datum of the Governance script.
This token is minted by a one-shot monetary policy governorPolicy,
meaning that the token has guaranteed uniqueness.
The governorValidator ensures that exactly one GST stays
at the address of itself forever.
Scripts
governorPolicy :: Governor -> ClosedTerm PMintingPolicy Source #
Policy for minting GSTs.
This policy perform the following checks:
- The UTXO referenced in the parameter is spent in the transaction.
- Exactly one GST is minted.
- Ensure the token name is empty.
- Said UTXO should carry a valid
GovernorDatum.
NOTE: It's user's responsibility to make sure the token is sent to the corresponding governor validator. We can't really check this in the policy, otherwise we create a cyclic reference issue.
Since: 0.1.0
governorValidator :: Governor -> ClosedTerm PValidator Source #
Validator for Governors.
Common checks
The validator always ensures:
- The UTXO which holds the GST must be spent.
- The GST always stays at the validator's address.
- The new state UTXO has a valid datum of type
GovernorDatum.
Creating a Proposal
When the redeemer is CreateProposal, the script will check:
For governor's state datum:
nextProposalIdis advanced.- Nothing is changed other that that.
- Exactly one stake (the "input stake") must be provided in the input:
- At least
stackedAmountof GT must be spent in the transaction. - The transaction must be signed by the stake owner.
- Exactly one new proposal state token is minted.
An UTXO which holds the newly minted proposal state token is sent to the proposal validator. This UTXO must have a valid datum of type
ProposalDatum, the datum must:- Copy its id and thresholds from the governor's state.
- Have status set to
Draft. - Have zero votes.
- Have exactly one cosigner - the stake owner
An UTXO which holds the stake state token is sent back to the stake validator. This UTXO must have a valid datum of type
StakeDatum:- The
stakedAmountandownershould not be changed, comparing to the input stake. - The new proposal locks must be appended to the
lockedBy.
- The
Minting GATs
When the redeemer is MintGATs, the script will check:
- Governor's state is not changed.
- Exactly only one proposal is in the inputs. Let's call this the input proposal.
- The proposal is in the
Executablestate.
NOTE: The input proposal is found by looking for the UTXO with a proposal state token in the inputs.
Effect Group Selection
Currently a proposal can have two or more than two options to vote on, meaning that it can contains two or more effect groups, according to #39.
Either way, the shapes of votes and effects should be the same.
This is checked by proposalDatumValid.
The script will look at the the votes to determine which group has the highest votes,
said group shoud be executed.
During the process, minimum votes requirement will also be enforced.
Next, the script will:
- Ensure that for every effect in the said effect group, exactly one valid GAT is minted and sent to the effect.
- The amount of GAT minted in the transaction should be equal to the number of effects.
A new UTXO is sent to the proposal validator, this UTXO should:
- Include the one proposal state token.
- Have a valid datum of type
ProposalDatum. This datum should be as same as the one of the input proposal, except its status should beFinished.
Changing the State
Redeemer MutateGovernor allows the state datum to be changed by an external effect.
In this case, the script will check
- Exactly one GAT is burnt in the transaction.
- Said GAT is tagged by the effect.
Since: 0.1.0
Bridges
governorSTSymbolFromGovernor :: Governor -> CurrencySymbol Source #
Get the CurrencySymbol of GST.
Since: 0.1.0
governorSTAssetClassFromGovernor :: Governor -> AssetClass Source #
Get the AssetClass of GST.
Since: 0.1.0
proposalSTAssetClassFromGovernor :: Governor -> AssetClass Source #
Get the AssetClass of the proposal state token.
Since: 0.1.0
stakeSTSymbolFromGovernor :: Governor -> CurrencySymbol Source #
Get the CurrencySymbol of the stake token/
Since: 0.1.0
stakeFromGovernor :: Governor -> Stake Source #
stakeValidatorHashFromGovernor :: Governor -> ValidatorHash Source #
Get the hash of stakePolicy.
Since: 0.1.0
proposalValidatorHashFromGovernor :: Governor -> ValidatorHash Source #
Get the hash of proposalPolicy.
Since: 0.1.0
proposalSTSymbolFromGovernor :: Governor -> CurrencySymbol Source #
Get the CurrencySymbol of the proposal state token.
Since: 0.1.0
stakeSTAssetClassFromGovernor :: Governor -> AssetClass Source #
Get the AssetClass of the stake token.
Note that the token is tagged with the hash of the stake validator.
See stakePolicy.
Since: 0.1.0
governorValidatorHash :: Governor -> ValidatorHash Source #
Get the hash of proposalValidator.
Since: 0.1.0
authorityTokenFromGovernor :: Governor -> AuthorityToken Source #
Get the AuthorityToken parameter given the Governor parameter.
Since: 0.1.0
authorityTokenSymbolFromGovernor :: Governor -> CurrencySymbol Source #
Get the CurrencySymbol of the authority token.
Since: 0.1.0