Geode Finance
Search…
⌃K

G-Derivatives

Fundamentals of gAVAX and gETH.

Dynamic Derivatives (ERC-1155)

Most of the on-chain derivatives in the market are either algorithmic, not backed by the availability of the underlying collateral like synthetics, or always guarantees the availability of the underlying collateral like wrappers.
However, neither make sense in the case of Liquid Staking where the availability of the collateral is vital.

Dynamic Derivatives use a pricing algorithm for minting/burning purposes while other derivatives use queues.

Geode-hosted Dynamic Derivatives

One can build a protocol on top of gETH and start using it as an internal database.

G-Derivatives are Databases of Balances and Prices with extra Scalability (interfaces).

Creation of a Staking Pool requires only two main parameters:
  • Balances of the Stakers
  • Price of the yield bearing asset of the Pool
To achieve this, all Staking Pools that are created with Geode Portal, uses a non-upgradable ERC1155 contract, a multi-token standard.
ERC1155 allows Geode to keep track of multiple Staking Pools. gAVAX or gETH is just the artificial chain-specific names of these sets of tokens.
Using a single ERC1155 instead of multiple ERC20s, can provide a better DeFi compatibility in the future. A Defi app can onboard all Geode-hosted derivatives at once without tracking and updating multiple token addresses.
The following explanation covers the implementation of gAVAX, however gETH has additional functionality. To see the differences:

Balances

gAVAX acts as a Database for the amount of staked Avax that is represented by multiple Maintainers.
Balances for the depositors of a single type of gAVAX, are tracked with a predetermined ID. IDs are the main separators of the different types of gAVAX, thus different maintainers.
// Mapping from token ID to account balances
mapping(uint256 => mapping(address => uint256)) private _balances;
Balances can be directly changed by Interfaces that are implemented and approved by the given ID's maintainer.

Pricing

The balance of users, that is stored in _balances parameter of the gAVAX contract, doesn’t change while the amount of the underlying Avax increases over time thanks to Staking Rewards.
Every different ID of gAVAX has a different _pricePerShare value.
// shows the underlying Avax for 1 staked Avax for given Representative
mapping(uint256 => uint256) private _pricePerShare;

_pricePerShare

Basically, a variable that represents the equivalent of 1 gAVAX(id) in terms of underlying Avax.
_pricePerShare is used while minting new tokens through Portal and updated by an Oracle contract with the data coming from the Avalanche P-Chain, collected by Telescope.
function setPricePerShare(uint256 pricePerShare_, uint256 _id)
external
virtual
{
require(hasRole(ORACLE, _msgSender()), "gAVAX: must have ORACLE to set");
...
}
_pricePerShare parameter is one of the key components for the support of DeFi.

Interfaces

ERC1155 Interfaces are one of the most important concepts introduced by Geode.fi.
ERC-1155 tokens are not compatible within the DeFi ecosystem, thus they need to be mutated for public usage.
Every Derivative token has a different use-case, depending on the represented Protocol, therefore it doesn’t come with a preset implementation.
Interfaces are external contracts used to manage the underlying asset(data) for different purposes, allowing Protocols to use the stored data with infinite flexibility!
There can be multiple Interfaces for one gAvax ID.
/**
* Mapping from Representative IDs to interface addresses
**/
mapping(uint256 => mapping(address => bool)) private _interfaces;
Only the Maintainer of a given ID can set new Interfaces.
function _setInterface(
address _Interface,
uint256 _id,
bool isSet
) internal virtual {
_interfaces[_id][_Interface] = isSet;
}
Transactions that are conducted with Interfaces can bypass the ERC1155 requirements while other non-compatible contracts cannot receive them.
function _doSafeTransferAcceptanceCheck(...) private {
if (to.isContract() && !isInterface(operator, id))
{
...
}

See our case studies about gAVAX interfaces here: