User Balances

How to load user vesting token balances

When a user purchases a bond from BondProtocol, they receive a vesting token. The underlying payout token is held by the Teller contract. Users can redeem their vesting tokens for the underlying payout token when the vesting period is complete.

The way our contracts work is to create a vesting token for each unique combination of underlying token + vesting date timestamp. All tokens vest at midnight UTC.

Our Fixed-Expiry markets create an ERC-20 vesting token, while our Fixed-Term markets create an ERC-1155 vesting token.

Our Teller contracts have functions which return the token address (in the case of an ERC-20) or token ID (in the case of an ERC-1155). In both cases, you must provide the address of the underlying payout token, and the vesting date timestamp.

For Fixed-Expiry markets, this is straightforward - there is only one expiry date, and as such, only one vesting token.

For Fixed-Term markets, there is a different vesting token for each day the market is open, with the vesting timestamp being the day of purchase plus the vesting term.

See below for more details.

ERC-20 (Fixed-Expiry) Vesting Tokens

You can find the vesting token address by calling the bondTokens(payoutTokenAddress, vestingTimestamp) function on the FixedExpiryTeller contract.

As the vesting token is an ERC-20 token, you can then call the vesting token's balanceOf(holderAddress) function to get the user's balance.

ERC-1155 (Fixed-Term) Vesting Tokens

The easiest way to get the data required below is from our subgraph. However, as our Ethereum Mainnet subgraph is on Graph Protocol's decentralized network, this would require you to pay query fees.

At the time of writing, other chains are available on the Graph Protocol hosted service without fees. Graph Protocol have not yet announced a timeline for migrating the other chains we support to their decentralized network.

As all tokens vest at midnight UTC, one manual alternative method of generating vesting date timestamps is, for each day your market will be open, to add the vesting term to a midnight UTC timestamp for that date.

You can find the vesting token ID by calling the getTokenId(payoutTokenAddress, vestingTimestamp) function on the FixedTermTeller contract.

As the vesting token is an ERC-1155 token, you can then call the vesting token's balanceOf(holderAddress, tokenId) function to get the user's balance.

Last updated