Skip to main content

GFILedger

GFILedger

Deployment on Ethereum mainnet:

https://etherscan.io/address/0xbc1081885da00404bd0108B70EC5aC0dbe98A077

Track GFI held by owners and ensure the GFI has been accounted for.

ZeroDepositAmount

error ZeroDepositAmount()

Thrown when depositing zero GFI for a position

InvalidWithdrawAmount

error InvalidWithdrawAmount(uint256 requested, uint256 max)

Thrown when withdrawing an invalid amount for a position

InvalidOwnerIndex

error InvalidOwnerIndex()

Thrown when depositing from address(0)

IndexGreaterThanTokenSupply

error IndexGreaterThanTokenSupply()

Thrown when querying token supply with an index greater than the supply

positions

mapping(uint256 => struct IGFILedger.Position) positions

owners

mapping(address => uint256[]) owners

totals

mapping(address => struct UserEpochTotal) totals

Total held by each user, while being aware of the deposit epoch

positionCounter

uint256 positionCounter

constructor

constructor(contract Context _context) public

Construct the contract

deposit

function deposit(address owner, uint256 amount) external returns (uint256 positionId)

Account for a new deposit by the owner.

Parameters

NameTypeDescription
owneraddressaddress to account for the deposit
amountuint256how much was deposited

Return Values

NameTypeDescription
positionIduint256how much was deposited

withdraw

function withdraw(uint256 positionId) external returns (uint256)

Account for a new withdraw by the owner.

Parameters

NameTypeDescription
positionIduint256id of the position

Return Values

NameTypeDescription
[0]uint256how much was withdrawn

withdraw

function withdraw(uint256 positionId, uint256 amount) external returns (uint256)

Account for a new withdraw by the owner.

Parameters

NameTypeDescription
positionIduint256id of the position
amountuint256how much to withdraw

Return Values

NameTypeDescription
[0]uint256how much was withdrawn

balanceOf

function balanceOf(address addr) external view returns (uint256 balance)

Get the number of GFI positions held by an address

Parameters

NameTypeDescription
addraddressaddress

Return Values

NameTypeDescription
balanceuint256positions held by address

ownerOf

function ownerOf(uint256 positionId) external view returns (address)

Get the owner of a given position.

Parameters

NameTypeDescription
positionIduint256id of the position

Return Values

NameTypeDescription
[0]addressowner of the position

totalsOf

function totalsOf(address addr) external view returns (uint256 eligibleAmount, uint256 totalAmount)

Get amount of GFI of owners positions, reporting what is currently eligible and the total amount.

this is used by Membership to determine how much is eligible in the current epoch vs the next epoch.

Return Values

NameTypeDescription
eligibleAmountuint256GFI amount of positions eligible for rewards
totalAmountuint256total GFI amount of positions

totalSupply

function totalSupply() public view returns (uint256)

Total number of positions in the ledger

Return Values

NameTypeDescription
[0]uint256number of positions in the ledger

tokenOfOwnerByIndex

function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256)

Returns a position ID owned by owner at a given index of its position list

use with {balanceOf} to enumerate all of owner's positions

Parameters

NameTypeDescription
owneraddressowner of the positions
indexuint256index of the owner's balance to get the position ID of

Return Values

NameTypeDescription
[0]uint256position id

tokenByIndex

function tokenByIndex(uint256 index) external view returns (uint256)

Returns a position ID at a given index of all the positions stored by the contract. use with {totalSupply} to enumerate all positions

Parameters

NameTypeDescription
indexuint256index to get the position ID at

Return Values

NameTypeDescription
[0]uint256token id

_mintPosition

function _mintPosition(address owner, uint256 amount) private returns (uint256 positionId)

_withdraw

function _withdraw(uint256 positionId) private returns (uint256)