Vote Contract

Vote

Users vote on governance proposals through this contract.
Request
1
{
2
userPublicKey: string,
3
timestamp: number,
4
type: ProtocolEventTypes,
5
fee: string,
6
proposalAccountId: string,
7
votes: BalanceLine[],
8
proposalType: ProposalType
9
}
Copied!
Fields:
  • proposalAccountId: The public key of the account being created as the proposal account.
  • proposalType: Represents the governance proposal type using the following enum
    1
    ProposalType {
    2
    ALLOCATION = 0,
    3
    CUSTOM = 1,
    4
    COUNCIL_SWAP_SIGNER = 2,
    5
    COUNCIL_LOCK_CONTRACT = 3
    6
    }
    Copied!
  • votes: array of user votes represented by BalanceLine's
    • If user is voting on a non-allocation update the assetCode will be YES or NO
    • If user is voting on an allocation update the assetCode will be a liability token code, pool token code, or YBX
    • amount is the number of votes the user wishes to cast

High-Level Contract Process Flow (MAY BE OUTDATED)

  1. 1.
    User enters the contract through an event handler which transforms their request.
  2. 2.
    Contract prerequisite data from horizon.
    1. 1.
      Pool Account Data
    2. 2.
      User Account Data
    3. 3.
      User Position Data
  3. 3.
    Contract builds a transaction builder object.
    1. 1.
      This is the object operations will be added to throughout the rest of the contract process flow.
  4. 4.
    Contract checks that the user has sufficient voting power for the total amount of votes they entered by looking at their veYBX holdings. If they do not the proposal rejects.
  5. 5.
    Contract adds a allowTrust operation where the escrow account authorizes the user to hold vYBX.
  6. 6.
    Contract checks how much vYBX the user currently has.
    1. 1.
      If the user does not have sufficient vYBX to cast their votes the contract adds a payment operation where the escrow account pays the necessary vYBX to the user.
    2. 2.
      If the user has too much vYBX the contract adds a payment operation that pays the excess vYBX to the escrow account.
  7. 7.
    Contract adds manageSellOffer operations where the user offers to sell vYBX for their input vote assets. Vote assets are assets with the input asset code with the proposal account as the issuer.
  8. 8.
    Contract adds a allowTrust operation where the escrow account authorizes the user to maintain vYBX liabilities.
  9. 9.
    Turret builds, signs, and returns the XDR.