Pool Smart Contract

The Pool smart contract is a critical component of the GasStation protocol, responsible for managing the protocol’s ETH collateral and equity collateral. This contract handles deposits, withdrawals, and burning of collateral based on interactions with users, all via the Executor contract.

Users never interect directly with this contract. However, anyone can use it go get information about the collaterals held by the users.

Key Features

  • Manage Collateral: Accepts ETH collateral deposits and calculates equity shares for users.

  • Withdraw and Burn Collateral: Handles withdrawals and burning of equity collateral when users exit or interact with GIX tokens.

  • Fee and Slippage Management: Applies fee and slippage parameters to transactions involving GIX token interactions.

Functions

depositCollateral(address user)

Allows to deposit ETH into the Pool, which is converted into equity collateral based on the current collateralization ratio of the system.

  • Requirements:

    • Only callable by the Executor.

    • The ETH sent must be greater than zero.

  • Returns: The amount of equity collateral issued to the user.

  • Events: CollateralDeposited.

withdrawEquityCollateral(address user, uint256 amountEquity)

Allows to withdraw a portion of their equity collateral, which is converted back into ETH based on the current system’s collateralization ratio.

  • Requirements:

    • Only callable by the Executor.

    • The user must have enough equity collateral to withdraw.

  • Returns: The amount of ETH withdrawn.

  • Events: EquityCollateralWithdrawn.

withdrawCollateralFromGIX(address user, address gixAddress, uint256 amount, uint256 fee, uint256 slippageParam)

Withdraws ETH collateral from the Pool when a user sells their GIX tokens. The function applies fees and slippage parameters to calculate the final ETH payout.

  • Requirements:

    • Only callable by the Executor.

  • Returns: The amount of ETH withdrawn after fees and slippage.

  • Events: CollateralWithdrawnFromGIX.

burnEquityCollateralFromGIX(address lastUser, address gixAddress, uint256 percAmount)

Burns a portion of the equity collateral from GIX holders based on a percentage amount computed by the interest rate smart contract and passed via the Executor.

  • Requirements:

    • Only callable by the Executor.

  • Returns: The last amount of ETH held by the last user if all equity collateral is burned.

  • Events: EquityCollateralBurned.

withdrawCollateralSimulator(address gixAddress, uint256 amount, uint256 fee, uint256 slippageParam)

Simulates the withdrawal of collateral based on GIX token interactions. This function is used to estimate the effects of fees and slippage before executing the actual transaction.

  • Returns: The amount of ETH that would be withdrawn after simulating the transaction.

getCollateralOf(address user)

Returns the total amount of ETH collateral belonging to a specific user based on their equity collateral.

  • Returns: The ETH collateral of the user.

getEquityCollateralOf(address user)

Returns the equity collateral balance of a specific user.

  • Returns: The equity collateral of the user.

equityToETH(uint256 equityAmount)

Converts a given amount of equity collateral to ETH based on the current system’s collateralization ratio.

  • Returns: The equivalent amount of ETH for the specified equity amount.

ETHToEquity(uint256 amountETH)

Converts a given amount of ETH to equity collateral based on the current system’s collateralization ratio.

  • Returns: The equivalent amount of equity collateral for the specified ETH amount.

Summary of Events

  • CollateralDeposited: Emitted when a user deposits ETH collateral into the Pool.

  • EquityCollateralWithdrawn: Emitted when a user withdraws equity collateral.

  • CollateralWithdrawnFromGIX: Emitted when collateral is withdrawn from the Pool during a GIX token interaction.

  • EquityCollateralBurned: Emitted when equity collateral is burned from a GIX holder.

  • ETHFeesWithdrawn: Emitted when ETH fees are withdrawn from the Pool to the owner.

Last updated