Skip to content

Commit

Permalink
feat: add governance amount to VeSugar veNFT
Browse files Browse the repository at this point in the history
  • Loading branch information
ethzoomer committed Oct 26, 2023
1 parent e1af647 commit 7aa3161
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
13 changes: 12 additions & 1 deletion contracts/VeSugar.vy
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ struct VeNFT:
decimals: uint8
amount: uint128
voting_amount: uint256
governance_amount: uint256
rebase_amount: uint256
expires_at: uint256
voted_at: uint256
Expand Down Expand Up @@ -52,24 +53,30 @@ interface IVotingEscrow:
def ownerToNFTokenIdList(_account: address, _index: uint256) -> uint256: view
def voted(_venft_id: uint256) -> bool: view

interface IVetoGovernorVotes:
def clock() -> uint48: view
def getVotes(_venft_id: uint256, _timepoint: uint256) -> uint256: view

# Vars

voter: public(IVoter)
token: public(address)
ve: public(IVotingEscrow)
dist: public(IRewardsDistributor)
gov: public(IVetoGovernorVotes)

# Methods

@external
def __init__(_voter: address, _rewards_distributor: address):
def __init__(_voter: address, _rewards_distributor: address, _gov: address):
"""
@dev Sets up our external contract addresses
"""
self.voter = IVoter(_voter)
self.ve = IVotingEscrow(self.voter.ve())
self.token = self.ve.token()
self.dist = IRewardsDistributor(_rewards_distributor)
self.gov = IVetoGovernorVotes(_gov)

@external
@view
Expand Down Expand Up @@ -146,6 +153,9 @@ def _byId(_id: uint256) -> VeNFT:
amount, expires_at, perma = self.ve.locked(_id)
last_voted: uint256 = 0

timepoint: uint256 = convert(self.gov.clock(), uint256)
governance_amount: uint256 = self.gov.getVotes(_id, timepoint)

if self.ve.voted(_id):
last_voted = self.voter.lastVoted(_id)

Expand Down Expand Up @@ -179,6 +189,7 @@ def _byId(_id: uint256) -> VeNFT:

amount: amount,
voting_amount: self.ve.balanceOfNFT(_id),
governance_amount: governance_amount,
rebase_amount: self.dist.claimable(_id),
expires_at: expires_at,
voted_at: last_voted,
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ The returned data/struct of type `VeNFT` values represent:
* `decimals` - veNFT token decimals
* `amount` - veNFT locked amount
* `voting_amount` - veNFT voting power
* `governance_amount` - veNFT voting power in governance
* `rebase_amount` - veNFT accrued reabses amount
* `expires_at` - veNFT lock expiration timestamp
* `voted_at` - veNFT last vote timestamp
Expand Down

0 comments on commit 7aa3161

Please sign in to comment.