Executor Smart Contract

The Executor smart contract is a central component of the GasStation protocol, responsible for managing user interactions, minting and burning GIX tokens, handling ETH collateral, and interacting with external contracts such as the Insurance Interest Rate Model (IIRM) and Pool contract. This contract ensures that the protocol functions correctly, adjusting token supply and collateralization according to real-time data and user transactions.

Key Features

  • Mint/Burn GIX: Handles the minting and burning of GIX tokens based on user interactions and changes in the insurance interest rate model (IIRM).

  • Manage Collateral: Manages the deposit and withdrawal of ETH collateral, ensuring that it stays within the system’s set limits.

  • Slippage and Fee Management: Ensures slippage and fees are accounted for in user transactions, with configurable parameters to control their impact.

Functions

buyGIX()

Allows users to purchase GIX tokens by sending ETH to the contract. The contract calculates how much GIX the user will receive based on the current gas price and applies a transaction fee. The ETH received is split between the protocol’s pool and the owner’s fee account.

  • Requirements:

    • The ETH sent must be greater than zero.

    • The pool's total collateral, after the transaction, must not exceed maxETHCap.

  • Returns: The amount of GIX tokens minted for the user.

  • Events: UserAction (eventType: "buy").

sellGIX(uint256 amountIn)

Allows users to sell their GIX tokens in exchange for ETH. The contract burns the user’s GIX tokens and calculates the corresponding ETH amount based on the gas price. Fees and slippage are applied to the final ETH payout according to the pool collaterals.

  • Requirements:

    • The user must have enough GIX tokens to sell.

  • Returns: The amount of ETH the user receives.

  • Events: UserAction (eventType: "sell").

depositCollateral()

Allows users to deposit ETH directly into the Pool contract as collateral, increasing the total collateral in the system.

  • Requirements:

    • The ETH sent must be greater than zero.

    • The total collateral after the transaction must not exceed maxETHCap.

  • Returns: The amount of ETH deposited.

  • Events: UserAction (eventType: "deposit").

withdrawEquityCollateral(uint256 amountEquityOut)

Allows users to withdraw a portion of their equity collateral from the Pool, subject to available collateral.

  • Requirements:

    • The user must have enough equity collateral to withdraw.

  • Returns: The amount of ETH withdrawn.

  • Events: UserAction (eventType: "withdraw").

renormalizeGIX()

Rebalances the GIX token supply based on the current gas price and the state of the protocol. This function adjusts the rebase factor for GIX tokens and ensures the system’s stability by burning excess equity if needed.

  • Returns: A tuple containing:

    • payout: The amount of GIX tokens that need to be rebalanced.

    • equityToBurnFromGIX: The equity to be burned from the GIX token supply.

    • lastUserAmount: The last amount processed during the renormalization.

Summary of Events

  • UserAction: Emitted whenever a user interacts with the protocol (buying, selling GIX, depositing, or withdrawing collateral). Provides detailed information about the transaction, including GIX total supply, ETH amount, gas price, collateral values, and the interest rate.

  • MaxCapETHChanged: Emitted when the maxETHCap is updated.

  • SlippageParamChanged: Emitted when the slippage parameter is changed.

  • AddressesChanged: Emitted when the GIX, interest rate, or pool contract addresses are updated.

Simulation Functions

The contract also provides functions to simulate the effects of buying or selling GIX, allowing users to preview outcomes before executing actual transactions. However these functions are still in development.

  • simulateBuyGIX(uint256 ethAmount, uint256 gasPrice): Simulates the purchase of GIX tokens.

  • simulateSellGIX(uint256 gixAmount, uint256 gasPrice): Simulates the sale of GIX tokens.

Last updated