👛gToken Vaults

Collateral vaults supporting trading liquidity

Current gToken Vaults: gUSDC, gDAI, gETH

gToken vaults follow ERC-4626, a standard API for tokenized yield-bearing vaults that represent shares of a single underlying ERC-20 asset. For each vault, gToken shares represent the underlying token asset (I.e. gDAI => DAI).

Vaults serve as a counterparty to all trades made on the platform:

  • When traders win (positive PnL), their winnings are received from the vault.

  • When traders lose (negative PnL), their losses are sent to the vault.

In exchange, the vault receives a portion of trading fees. These fees are proportionally split among gToken shares, incentivizing stakers to stay in the vault.

The vault that earns fees, pays profits, receives losses, is determined by the collateral of each trade.

Collateralization of the vault depends on trader PnL. As long as fees earned is greater than PnL payouts, stakers earn a positive return. This has proven to be the case for two+ years and the protocol has various risk management measures in place to ensure it continues.

When overall PnL is negative, the vault starts to create a buffer with those funds, further protecting stakers' funds and the protocol from future PnL abnormalities.

To better approximate real collateralization ratio, and to minimize risks for the protocol (including stakers), the vault follows an epoch system for capturing snapshots of open PnL. Open PnL represents the aggregate PnL of all open trades at the time of the snapshot.


gTokens are ERC-20s representing ownership of the underlying token asset. It follows an exchange rate model (similar to Compound's cTokens) where the price of gToken to asset changes in real-time from two variables: accumulated fees and trader PnL (both open and closed).

gToken = 1 + accRewardsPerToken — Math.max(0, accPnlPerTokenUsed)

accRewardsPerToken: accumulator value representing how many fees a single gToken has accrued. This value always increases over time.

accPnlPerTokenUsed: a snapshotted accumulator value of trader PnL from all closed trades and a snapshot of open trades from the end of the previous epoch. This value changes every epoch and can move in either direction.

To summarize, the vault consists of two parts:

  • The asset staked by stakers, which corresponds 100% collateralization

  • The over-collaterization layer, which makes up anything beyond 100% -> note that the over-collateralization layer doesn't make the gToken price increase, see gToken price formula above.

Thus if the vault is at 110% it means that the OC is at 10%.

The over-collateralization layer (OC) acts as a buffer between traders and lenders, and profits and losses are paid out, or paid to, the OC as long as it exists. By design, the vault can be in two states; over-collaterized (>=100%) and under-collaterized (<100%).

  • If the vault is over-collateralized, a percentage of trader losses is diverted to a pool where users can sell GNS for the asset, OTC, using the 1-hour TWAP. This enables users to sell GNS without paying any slippage that would occur on an exchange, or affecting the GNS price. This GNS is then burned, to counteract any minting that happens while under-collateralized.

  • If the vault is under-collateralized, GNS is minted and sold for the asset, OTC. The asset is then used to replenish the vault. A maximum of 0.05% of the total supply of GNS can be minted every 24h (18.25% per year). Again, this creates a secondary market where users can buy GNS without having to pay any slippage.

  • Both the mints and burns are entirely decentralized and only happen when someone interacts with the vault. The interface for it is located at https://gains.trade/otc


gNFT is an ERC-721 representing ownership of locked gToken shares. Locked gToken is purchased at a discount, based on the amount of time a lender is willing to lock up their funds, and can be unlocked following the lock duration.

Locked gToken accumulates fees like all other shares.

Epoch system

Epoch system provides open PnL data to the vault in a decentralized manner, so the vault better understands its collateralization ratio. Calculating open PnL is too computationally expensive to do in real-time, on-chain.

There are two states the epoch system can be in:

  • Withdraw window - the period before open PnL values are being received and stakers may make withdraw-related actions (both requests and withdraws).

  • Open PnL window - the period before the epoch closes where the protocol requests open PnL snapshots from oracles. It makes multiple requests to a network of oracles, taking the median value, finally averaging across the request periods. This PnL value is then used in the succeeding epoch.

Withdraw locks

For the security of the vault, and to prevent stakers from front-running PnL changes, assets can't be withdrawn immediately. Instead they must go through a withdraw request system.

Depending on the collateralization ratio of the vault, a staker may withdraw either 1, 2, or 3 epochs after making a request. The higher collateralization ratio, the shorter the lock period.

If a staker misses their withdraw window, they must make a new request.

For a more detailed overview of the vault, please see our Medium post:


Last updated