Skip to content

Instantly share code, notes, and snippets.

@yorhodes
Last active October 19, 2021 19:24
Show Gist options
  • Save yorhodes/ad5755340504ae1d5e3bba51e5f8e3d2 to your computer and use it in GitHub Desktop.
Save yorhodes/ad5755340504ae1d5e3bba51e5f8e3d2 to your computer and use it in GitHub Desktop.

Overview

Please see our Understanding ReleaseGold docs.

Balances

The Celo Rosetta service exposes 3 types of ReleaseGold balances on the /account/balance endpoint.

ReleaseGoldVested

This type corresponds to the total amount of gold that has released up to the current timestamp. Crucially, it does not account for any withdrawals that have already taken place and simply calculates the aggregate released amount according to the schedule.

You can refer to the contract function getCurrentReleasedTotalAmount()

ReleaseGoldUnvestedLocked

This type simply corresponds to the contract's locked gold balance, including the sum of any pending withdrawals. The unvested modifier is misleading.

You can refer to the contract function getRemainingLockedBalance()

ReleaseGoldUnvestedUnlocked

This type simply corresponds to the unlocked gold balance in the contract. The unvested modifier is misleading.

You can refer to the contract function getRemainingUnlockedBalance()

Transactions

The ReleaseGold.withdraw operation on the /construction/metadata endpoint is the transaction builder for the contract function withdraw(uint256 amount).

There are a few invariants that must be satisfied for a successful withdrawal:

  • ReleaseGoldVested >= totalWithdrawn + amount
  • maxDistribution >= totalWithdrawn + amount
  • ReleaseGoldUnvestedUnlocked >= amount
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment