PirexEth.sol
General Overview
The PirexEth.sol
contract is the main contracts for handling pxETH interactions. It allows users to deposit ETH and receive pxETH tokens, which can be automatically staked for earning rewards. Users can also redeem their pxETH for ETH or upxETH. It also manages all associated fees for depositing, redeeming, and instantly converting pxETH.
Technical Overview
Inherits: PirexEthValidators
Author: redactedcartel.finance
State Variables
pirexFees
maxFees
fees
paused
Functions
whenNotPaused
constructor
Parameters
Name | Type | Description |
---|---|---|
_pxEth | address | PxETH contract address |
_admin | address | Admin address |
_beaconChainDepositContract | address | The address of the beacon chain deposit contract |
_upxEth | address | UpxETH address |
_depositSize | uint256 | Amount of eth to stake |
_preDepositAmount | uint256 | Amount of ETH for pre-deposit |
_pirexFees | address | PirexFees contract address |
_initialDelay | uint48 | Delay required to schedule the acceptance of a access control transfer started |
setFee
Set fee
Parameters
Name | Type | Description |
---|---|---|
f | DataTypes.Fees | Fee |
fee | uint32 | Fee amount |
setMaxFee
Set Max fee
Parameters
Name | Type | Description |
---|---|---|
f | DataTypes.Fees | Fee |
maxFee | uint32 | Max fee amount |
togglePauseState
toggle the contract's pause state
emergencyWithdraw
Emergency withdrawal for all ERC20 tokens (except pxETH) and ETH
This function should only be called under major emergency
Parameters
Name | Type | Description |
---|---|---|
receiver | address | Receiver address |
token | address | Token address |
amount | uint256 | Token amount |
deposit
Handle pxETH minting in return for ETH deposits
Parameters
Name | Type | Description |
---|---|---|
receiver | address | Receiver of the minted pxETH or apxEth |
shouldCompound | bool | Whether to also compound into the vault |
Returns
Name | Type | Description |
---|---|---|
postFeeAmount | uint256 | pxETH minted for the receiver |
feeAmount | uint256 | pxETH distributed as fees |
initiateRedemption
Initiate redemption by burning pxETH in return for upxETH
Parameters
Name | Type | Description |
---|---|---|
_assets | uint256 | If caller is AutoPxEth then apxETH; pxETH otherwise |
_receiver | address | Receiver for upxETH |
_shouldTriggerValidatorExit | bool | Whether the initiation should trigger voluntary exit |
Returns
Name | Type | Description |
---|---|---|
postFeeAmount | uint256 | pxETH burnt for the receiver |
feeAmount | uint256 | pxETH distributed as fees |
redeemWithUpxEth
Redeem back ETH using upxEth
Parameters
Name | Type | Description |
---|---|---|
_tokenId | uint256 | Redeem batch identifier |
_assets | uint256 | Amount of ETH to redeem |
_receiver | address | Address of the ETH receiver |
instantRedeemWithPxEth
Instant redeem back ETH using pxETH
Parameters
Name | Type | Description |
---|---|---|
_assets | uint256 | Amount of pxETH to redeem |
_receiver | address | Address of the ETH receiver |
Returns
Name | Type | Description |
---|---|---|
postFeeAmount | uint256 | Post-fee amount for the receiver |
feeAmount | uint256 | Fee amount sent to the PirexFees |
_computeAssetAmounts
Compute post-fee asset and fee amounts from a fee type and total assets
Parameters
Name | Type | Description |
---|---|---|
f | DataTypes.Fees | Fee |
assets | uint256 | ETH or pxETH asset amount |
Returns
Name | Type | Description |
---|---|---|
postFeeAmount | uint256 | Post-fee asset amount (for mint/burn/claim/etc.) |
feeAmount | uint256 | Fee amount |