- When traders win (positive PnL), their winnings are received from the vault.
- When traders lose (negative PnL), their losses are sent to the vault.
gToken
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 overcollateralization layer, which makes up anything beyond 100%
- If the vault is overcollateralized, 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 undercollateralized, 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. (Please note that in the case of BtcUSD, $GNS will not be minted in order to replenish an undercollateralized vault, it instead relies on its partner — Bifrost — to restore the overcollateralization buffer.)
- 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
gNFT is an ERC-721 representing ownership of locked gToken shares. Locked gToken is purchased at a discount based on the lock duration, and can be unlocked after that duration ends. Locked gToken accumulates fees like all other shares.Epoch system
The epoch system provides open PnL data to the vault in a decentralized manner, so the vault can better estimate its collateralization ratio. Calculating open PnL in real time on-chain would be too computationally expensive. 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.
