Sugar comes with contracts to help working with GovNFT data!
Instead of relying on an API for GovNFT data, these contracts can be called in an efficient way to directly fetch the same data off-chain.
Main goals of this little project are:
- to maximize the developers UX of working with GovNFT
- simplify complexity
- document and test everything
On-chain data is organized for transaction cost and efficiency. We think
we can hide a lot of the complexity by leveraging structs
to present the data
and normalize it based on it's relevancy.
Below is the list of data we support.
GovNFTSugar.vy
is deployed at 0xbEDAbeDf82d4BEFc73742E46352B0af5a5bd3460
It allows fetching GovNFT data.
The returned data/struct of type GovNft
values represent:
id
- token ID of the GovNFTtotal_locked
- total locked amount of the GovNFT at creationamount
- current locked amount of the GovNFTtotal_claimed
- amount of total tokens claimed by the ownerclaimable
- current amount of tokens that are vested and claimablesplit_count
- number of times the GovNFT has been splitcliff_length
- the length of the vesting cliff, in secondsstart
- timestamp of when vesting beginsend
- timestamp of when vesting endstoken
- the underlying vesting ERC20 token of the GovNFTvault
- the vault address of the GovNFTminter
- the address of the creator of the GovNFTowner
- the owner of the GovNFTaddress
- the address of the GovNFT collectiondelegated
- the address that the underlying ERC20 token of the GovNFT is being delegated to
The returned data/struct of type Collection
values represent:
address
- address of the GovNFT collectionowner
- owner admin of the GovNFT collection contractname
- name of the GovNFT collectionsymbol
- symbol of the GovNFT collectionsupply
- total number of GovNFTs in the collection
The available methods are:
collections() -> Collection[]
- returns a list of all GovNFTCollection
structs that have been created by the factory.owned(_account: address, _collection: address) -> GovNft[]
- returns a list of allGovNft
structs owned by the given account for the given collection.minted(_account: address, _collection: address) -> GovNft[]
- returns a list of allGovNft
structs minted by the given account for the given collection.byId(_govnft_id: uint256, _collection: address) -> GovNft
- returns theGovNft
based on the given ID and collection.
To setup the environment, build the Docker image first:
docker build ./ -t govnft/sugar
Next start the container with existing environment variables:
docker run --env-file=env.example --rm -v $(pwd):/app -w /app -it govnft/sugar sh
The environment has Brownie and Vyper already installed.
To run the tests inside the container, use:
brownie test --network=optimism-test
Sugar is written in Vyper, and Optimistic Etherscan fails at times to
generate the same bytecode (probably because of the hardcoded evm_version
).
Consider using the web tool at https://abi.hashex.org to build the arguments and provide the generated value as part of the Etherscan verification form.