Skip to content

Commit

Permalink
Fix: use delegates function to fetch delegation
Browse files Browse the repository at this point in the history
  • Loading branch information
ethzoomer committed Oct 27, 2023
1 parent 693aa97 commit 3aab396
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
12 changes: 2 additions & 10 deletions contracts/VeSugar.vy
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ struct VeNFT:
permanent: bool
delegate_id: uint256

struct Checkpoint:
from_timestamp: uint256
owner: address
delegated_balance: uint256
delegatee: uint256

# Our contracts / Interfaces

interface IVoter:
Expand All @@ -59,8 +53,7 @@ interface IVotingEscrow:
def locked(_venft_id: uint256) -> (uint128, uint256, bool): view
def ownerToNFTokenIdList(_account: address, _index: uint256) -> uint256: view
def voted(_venft_id: uint256) -> bool: view
def numCheckpoints(_venft_id: uint256) -> uint48: view
def checkpoints(_venft_id: uint256, _index: uint48) -> Checkpoint: view
def delegates(_venft_id: uint256) -> uint256: view

interface IGovernor:
def clock() -> uint48: view
Expand Down Expand Up @@ -165,8 +158,7 @@ def _byId(_id: uint256) -> VeNFT:
timepoint: uint256 = convert(self.gov.clock(), uint256)
governance_amount: uint256 = self.gov.getVotes(_id, timepoint - 1)

checkpoint_length: uint48 = self.ve.numCheckpoints(_id)
delegate_id: uint256 = self.ve.checkpoints(_id, checkpoint_length - 1).delegatee
delegate_id: uint256 = self.ve.delegates(_id)

if self.ve.voted(_id):
last_voted = self.voter.lastVoted(_id)
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ To fetch a list of rewards for a specific veNFT, this method is available:

### Vote-Escrow Locked NFT (veNFT) Data

`VeSugar.vy` is deployed at `0xc176b85C8c49120D95ed6B3942b700086A1ee2A3`
`VeSugar.vy` is deployed at `0x3B3dce7385e19F3582c8C0f9431b7d0998856626`

It allows fetching on-chain veNFT data (including the rewards accrued).
The returned data/struct of type `VeNFT` values represent:
Expand Down

0 comments on commit 3aab396

Please sign in to comment.