Description:
Multi-signature wallet contract requiring multiple confirmations for transaction execution.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"src/dinero/DineroStrategyV2.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.22;
import { IERC20, IERC20Metadata } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { SafeCast } from "@openzeppelin/contracts/utils/math/SafeCast.sol";
import { IAutoPxEth } from "./interfaces/IAutoPxEth.sol";
import { IPirexEth } from "./interfaces/IPirexEth.sol";
import { IWETH9 } from "./interfaces/IWETH9.sol";
import { IHolding } from "@jigsaw/src/interfaces/core/IHolding.sol";
import { IManager } from "@jigsaw/src/interfaces/core/IManager.sol";
import { IReceiptToken } from "@jigsaw/src/interfaces/core/IReceiptToken.sol";
import { IStrategy } from "@jigsaw/src/interfaces/core/IStrategy.sol";
import { OperationsLib } from "../libraries/OperationsLib.sol";
import { StrategyConfigLib } from "../libraries/StrategyConfigLib.sol";
import { IStakerLight } from "../staker/interfaces/IStakerLight.sol";
import { IStakerLightFactory } from "../staker/interfaces/IStakerLightFactory.sol";
import { StrategyBaseUpgradeableV2 } from "../StrategyBaseUpgradeableV2.sol";
import { IFeeManager } from "../extensions/interfaces/IFeeManager.sol";
/**
* @title DineroStrategyV2
* @dev Strategy used for Dinero protocol's autoPxEth.
* @author Hovooo (@hovooo)
* @custom:oz-upgrades-from DineroStrategy
*/
contract DineroStrategyV2 is IStrategy, StrategyBaseUpgradeableV2 {
using SafeERC20 for IERC20;
using SafeCast for uint256;
// -- Errors --
error OperationNotSupported();
error InvalidEthSender(address sender);
// -- Events --
/**
* @notice Event indicating that the contract received Ether.
*
* @param from The address that sent the Ether.
* @param amount The amount of Ether received (in wei).
*/
event Received(address indexed from, uint256 amount);
// -- Custom types --
/**
* @notice Struct for the initializer params.
*/
struct InitializerParams {
address owner; // The address of the initial owner of the Strategy contract
address manager; // The address of the Manager contract
address stakerFactory; // The address of the StakerLightFactory contract
address pirexEth; // The address of the PirexEth
address autoPirexEth; // The address of the AutoPirexEth
address jigsawRewardToken; // The address of the Jigsaw reward token associated with the strategy
uint256 jigsawRewardDuration; // The address of the initial Jigsaw reward distribution duration for the strategy
address tokenIn; // The address of the LP token
address tokenOut; // The address of the PirexEth receipt token (pxEth)
}
/**
* @notice Struct for the initializer params.
* @param owner The address of the initial owner of the Strategy contract
* @param feeManager The address of the feeManager contract
*/
struct ReinitializerParams {
address feeManager;
}
// -- State variables --
/**
* @notice The WETH token is utilized as the input token, which is later unwrapped to ETH and re-wrapped to
* facilitate Dinero investments.
*/
address public override tokenIn;
/**
* @notice The PirexEth receipt token address.
*/
address public override tokenOut;
/**
* @notice The reward token offered to users.
*/
address public override rewardToken;
/**
* @notice The receipt token associated with this strategy.
*/
IReceiptToken public override receiptToken;
/**
* @notice The PirexEth contract.
*/
IPirexEth public pirexEth;
/**
* @notice The PirexEth contract.
*/
IAutoPxEth public autoPirexEth;
/**
* @notice The Jigsaw Rewards Controller contract.
*/
IStakerLight public jigsawStaker;
/**
* @notice The number of decimals of the strategy's shares.
*/
uint256 public override sharesDecimals;
/**
* @notice A mapping that stores participant details by address.
*/
mapping(address recipient => IStrategy.RecipientInfo info) public override recipients;
// -- Constructor --
constructor() {
_disableInitializers();
}
// -- Initialization --
/**
* @notice Initializes the Dinero Strategy contract with necessary parameters.
*
* @dev Configures core components such as manager, tokens, pools needed for the strategy to operate.
*
* @dev This function is only callable once due to the `initializer` modifier.
*
* @notice Ensures that critical addresses are non-zero to prevent misconfiguration:
* - `_params.manager` must be valid (`"3065"` error code if invalid).
* - `_params.pirexEth` must be valid (`"3036"` error code if invalid).
* - `_params.autoPirexEth` must be valid (`"3036"` error code if invalid).
* - `_params.tokenIn` and `_params.tokenOut` must be valid (`"3000"` error code if invalid).
*
* @param _params Struct containing all initialization parameters.
*/
function initialize(
InitializerParams memory _params
) public initializer {
require(_params.manager != address(0), "3065");
require(_params.pirexEth != address(0), "3036");
require(_params.autoPirexEth != address(0), "3036");
require(_params.tokenIn != address(0), "3000");
require(_params.tokenOut != address(0), "3000");
__StrategyBase_init({ _initialOwner: _params.owner });
manager = IManager(_params.manager);
pirexEth = IPirexEth(_params.pirexEth);
autoPirexEth = IAutoPxEth(_params.autoPirexEth);
tokenIn = _params.tokenIn;
tokenOut = _params.tokenOut;
sharesDecimals = IERC20Metadata(_params.tokenOut).decimals();
receiptToken = IReceiptToken(
StrategyConfigLib.configStrategy({
_initialOwner: _params.owner,
_receiptTokenFactory: manager.receiptTokenFactory(),
_receiptTokenName: "PirexEth Strategy Receipt Token",
_receiptTokenSymbol: "DiRT"
})
);
jigsawStaker = IStakerLight(
IStakerLightFactory(_params.stakerFactory).createStakerLight({
_initialOwner: _params.owner,
_holdingManager: manager.holdingManager(),
_rewardToken: _params.jigsawRewardToken,
_strategy: address(this),
_rewardsDuration: _params.jigsawRewardDuration
})
);
}
/**
* @custom:oz-upgrades-validate-as-initializer
*
* @notice Initializes the Aave Strategy V2 contract with necessary parameters.
*
* @dev Configures core components such as manager, tokens, pools, and reward systems
* needed for the strategy to operate.
*
* @dev This function is only callable once due to the `initializer` modifier.
*
* @notice Ensures that critical addresses are non-zero to prevent misconfiguration:
* - `_params.feeManager` must be valid (`"3000"` error code if invalid).
*
* @param _params Struct containing all initialization parameters.
*/
function reinitialize(
ReinitializerParams memory _params
) public reinitializer(2) {
require(_params.feeManager != address(0), "3000");
feeManager = IFeeManager(_params.feeManager);
}
// -- User-specific Methods --
/**
* @notice Deposits funds into the strategy.
*
* @param _asset The token to be invested.
* @param _amount The amount of the token to be invested.
* @param _recipient The address on behalf of which the funds are deposited.
*
* @return The amount of receipt tokens obtained.
* @return The amount of the 'tokenIn()' token.
*/
function deposit(
address _asset,
uint256 _amount,
address _recipient,
bytes calldata
) external override nonReentrant onlyValidAmount(_amount) onlyStrategyManager returns (uint256, uint256) {
require(_asset == tokenIn, "3001");
uint256 balanceBefore = IERC20(tokenOut).balanceOf(_recipient);
IHolding(_recipient).transfer({ _token: _asset, _to: address(this), _amount: _amount });
// Swap WETH to ETH.
IWETH9(tokenIn).withdraw(_amount);
// Deposit ETH to mint pxETH and stakes pxETH for autocompounding.
pirexEth.deposit{ value: _amount }({ receiver: _recipient, shouldCompound: true });
uint256 shares = IERC20(tokenOut).balanceOf(_recipient) - balanceBefore;
recipients[_recipient].investedAmount += _amount;
recipients[_recipient].totalShares += shares;
// Mint Strategy's receipt tokens to allow later withdrawal.
_mint({ _receiptToken: receiptToken, _recipient: _recipient, _amount: shares, _tokenDecimals: sharesDecimals });
// Register `_recipient`'s deposit operation to generate jigsaw rewards.
jigsawStaker.deposit({ _user: _recipient, _amount: shares });
emit Deposit({
asset: _asset,
tokenIn: tokenIn,
assetAmount: _amount,
tokenInAmount: _amount,
shares: shares,
recipient: _recipient
});
return (shares, _amount);
}
/**
* @notice Withdraws deposited funds from the strategy.
*
* @param _shares The amount of shares to withdraw.
* @param _recipient The address on behalf of which the funds are withdrawn.
* @param _asset The token to be withdrawn.
*
* @return The amount of the asset obtained from the operation.
* @return The amount of the 'tokenIn()' token.
*/
function withdraw(
uint256 _shares,
address _recipient,
address _asset,
bytes calldata
) external override nonReentrant onlyStrategyManager returns (uint256, uint256, int256, uint256) {
require(_asset == tokenIn, "3001");
require(_shares <= IERC20(tokenOut).balanceOf(_recipient), "2002");
WithdrawParams memory params = WithdrawParams({
shares: _shares,
totalShares: recipients[_recipient].totalShares,
shareRatio: 0,
shareDecimals: sharesDecimals,
investment: 0,
assetsToWithdraw: 0, // not used in Dinero strategy
balanceBefore: 0,
withdrawnAmount: 0,
yield: 0,
fee: 0
});
// Calculate the ratio between all user's shares and the amount of shares used for withdrawal.
params.shareRatio = OperationsLib.getRatio({
numerator: params.shares,
denominator: params.totalShares,
precision: params.shareDecimals,
rounding: OperationsLib.Rounding.Floor
});
// Burn Strategy's receipt tokens used for withdrawal.
_burn({
_receiptToken: receiptToken,
_recipient: _recipient,
_shares: params.shares,
_totalShares: params.totalShares,
_tokenDecimals: params.shareDecimals
});
// To accurately compute the protocol's fees from the yield generated by the strategy, we first need to
// determine the percentage of the initial investment being withdrawn. This allows us to assess whether any
// yield has been generated beyond the initial investment.
params.investment = (recipients[_recipient].investedAmount * params.shareRatio) / (10 ** params.shareDecimals);
params.balanceBefore = IERC20(tokenIn).balanceOf(_recipient);
// Redeem pxETH via the AutoPirexEth contract using the recipient's `IHolding` contract.
(, bytes memory returnData) = _genericCall({
_holding: _recipient,
_contract: address(autoPirexEth),
_call: abi.encodeCall(IAutoPxEth.redeem, (_shares, address(this), _recipient))
});
// Use the PirexEth contract to instantly redeem the withdrawn pxETH for ETH.
// Note: The `instantRedeemWithPxEth` function can be paused by PirexEth protocol, reverting the transaction.
(uint256 postFeeAmount,) = pirexEth.instantRedeemWithPxEth(abi.decode(returnData, (uint256)), address(this));
// Transfer WETH to the `_recipient`.
IWETH9(tokenIn).deposit{ value: postFeeAmount }();
IERC20(tokenIn).safeTransfer(_recipient, postFeeAmount);
// Get the actually withdrawn amount and calculate the generated yield
params.withdrawnAmount = IERC20(tokenIn).balanceOf(_recipient) - params.balanceBefore;
params.yield = params.withdrawnAmount.toInt256() - params.investment.toInt256();
// Take protocol's fee from generated yield if any.
if (params.yield > 0) {
params.fee = _takePerformanceFee({ _token: tokenIn, _recipient: _recipient, _yield: uint256(params.yield) });
if (params.fee > 0) {
params.withdrawnAmount -= params.fee;
params.yield -= params.fee.toInt256();
}
}
recipients[_recipient].totalShares -= params.shares;
recipients[_recipient].investedAmount = params.investment > recipients[_recipient].investedAmount
? 0
: recipients[_recipient].investedAmount - params.investment;
emit Withdraw({
asset: _asset,
recipient: _recipient,
shares: params.shares,
withdrawnAmount: params.withdrawnAmount,
initialInvestment: params.investment,
yield: params.yield
});
// Register `_recipient`'s withdrawal operation to stop generating jigsaw rewards.
jigsawStaker.withdraw({ _user: _recipient, _amount: params.shares });
return (params.withdrawnAmount, params.investment, params.yield, params.fee);
}
/**
* @notice Claims rewards from the PirexEth.
* @return The amounts of rewards claimed.
* @return The addresses of the reward tokens.
*/
function claimRewards(
address,
bytes calldata
) external pure override returns (uint256[] memory, address[] memory) {
revert OperationNotSupported();
}
// -- Getters --
/**
* @notice Returns the address of the receipt token.
*/
function getReceiptTokenAddress() external view override returns (address) {
return address(receiptToken);
}
// -- Utilities --
/**
* @notice Allows the contract to accept incoming Ether transfers.
* @dev This function is executed when the contract receives Ether with no data in the transaction.
*
* @notice Emits:
* - `Received` event to log the sender's address and the amount received.
*/
receive() external payable {
if (msg.sender != address(tokenIn) && msg.sender != address(pirexEth)) revert InvalidEthSender(msg.sender);
emit Received({ from: msg.sender, amount: msg.value });
}
}
"
},
"lib/jigsaw-protocol-v1/lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
"
},
"lib/jigsaw-protocol-v1/lib/openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev An operation with an ERC20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data);
if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
}
}
"
},
"lib/jigsaw-protocol-v1/lib/openzeppelin-contracts/contracts/utils/math/SafeCast.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.
pragma solidity ^0.8.20;
/**
* @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
* checks.
*
* Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
* easily result in undesired exploitation or bugs, since developers usually
* assume that overflows raise errors. `SafeCast` restores this intuition by
* reverting the transaction when such an operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeCast {
/**
* @dev Value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);
/**
* @dev An int value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedIntToUint(int256 value);
/**
* @dev Value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);
/**
* @dev An uint value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedUintToInt(uint256 value);
/**
* @dev Returns the downcasted uint248 from uint256, reverting on
* overflow (when the input is greater than largest uint248).
*
* Counterpart to Solidity's `uint248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*/
function toUint248(uint256 value) internal pure returns (uint248) {
if (value > type(uint248).max) {
revert SafeCastOverflowedUintDowncast(248, value);
}
return uint248(value);
}
/**
* @dev Returns the downcasted uint240 from uint256, reverting on
* overflow (when the input is greater than largest uint240).
*
* Counterpart to Solidity's `uint240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*/
function toUint240(uint256 value) internal pure returns (uint240) {
if (value > type(uint240).max) {
revert SafeCastOverflowedUintDowncast(240, value);
}
return uint240(value);
}
/**
* @dev Returns the downcasted uint232 from uint256, reverting on
* overflow (when the input is greater than largest uint232).
*
* Counterpart to Solidity's `uint232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*/
function toUint232(uint256 value) internal pure returns (uint232) {
if (value > type(uint232).max) {
revert SafeCastOverflowedUintDowncast(232, value);
}
return uint232(value);
}
/**
* @dev Returns the downcasted uint224 from uint256, reverting on
* overflow (when the input is greater than largest uint224).
*
* Counterpart to Solidity's `uint224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toUint224(uint256 value) internal pure returns (uint224) {
if (value > type(uint224).max) {
revert SafeCastOverflowedUintDowncast(224, value);
}
return uint224(value);
}
/**
* @dev Returns the downcasted uint216 from uint256, reverting on
* overflow (when the input is greater than largest uint216).
*
* Counterpart to Solidity's `uint216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*/
function toUint216(uint256 value) internal pure returns (uint216) {
if (value > type(uint216).max) {
revert SafeCastOverflowedUintDowncast(216, value);
}
return uint216(value);
}
/**
* @dev Returns the downcasted uint208 from uint256, reverting on
* overflow (when the input is greater than largest uint208).
*
* Counterpart to Solidity's `uint208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*/
function toUint208(uint256 value) internal pure returns (uint208) {
if (value > type(uint208).max) {
revert SafeCastOverflowedUintDowncast(208, value);
}
return uint208(value);
}
/**
* @dev Returns the downcasted uint200 from uint256, reverting on
* overflow (when the input is greater than largest uint200).
*
* Counterpart to Solidity's `uint200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*/
function toUint200(uint256 value) internal pure returns (uint200) {
if (value > type(uint200).max) {
revert SafeCastOverflowedUintDowncast(200, value);
}
return uint200(value);
}
/**
* @dev Returns the downcasted uint192 from uint256, reverting on
* overflow (when the input is greater than largest uint192).
*
* Counterpart to Solidity's `uint192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*/
function toUint192(uint256 value) internal pure returns (uint192) {
if (value > type(uint192).max) {
revert SafeCastOverflowedUintDowncast(192, value);
}
return uint192(value);
}
/**
* @dev Returns the downcasted uint184 from uint256, reverting on
* overflow (when the input is greater than largest uint184).
*
* Counterpart to Solidity's `uint184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*/
function toUint184(uint256 value) internal pure returns (uint184) {
if (value > type(uint184).max) {
revert SafeCastOverflowedUintDowncast(184, value);
}
return uint184(value);
}
/**
* @dev Returns the downcasted uint176 from uint256, reverting on
* overflow (when the input is greater than largest uint176).
*
* Counterpart to Solidity's `uint176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*/
function toUint176(uint256 value) internal pure returns (uint176) {
if (value > type(uint176).max) {
revert SafeCastOverflowedUintDowncast(176, value);
}
return uint176(value);
}
/**
* @dev Returns the downcasted uint168 from uint256, reverting on
* overflow (when the input is greater than largest uint168).
*
* Counterpart to Solidity's `uint168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*/
function toUint168(uint256 value) internal pure returns (uint168) {
if (value > type(uint168).max) {
revert SafeCastOverflowedUintDowncast(168, value);
}
return uint168(value);
}
/**
* @dev Returns the downcasted uint160 from uint256, reverting on
* overflow (when the input is greater than largest uint160).
*
* Counterpart to Solidity's `uint160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*/
function toUint160(uint256 value) internal pure returns (uint160) {
if (value > type(uint160).max) {
revert SafeCastOverflowedUintDowncast(160, value);
}
return uint160(value);
}
/**
* @dev Returns the downcasted uint152 from uint256, reverting on
* overflow (when the input is greater than largest uint152).
*
* Counterpart to Solidity's `uint152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*/
function toUint152(uint256 value) internal pure returns (uint152) {
if (value > type(uint152).max) {
revert SafeCastOverflowedUintDowncast(152, value);
}
return uint152(value);
}
/**
* @dev Returns the downcasted uint144 from uint256, reverting on
* overflow (when the input is greater than largest uint144).
*
* Counterpart to Solidity's `uint144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*/
function toUint144(uint256 value) internal pure returns (uint144) {
if (value > type(uint144).max) {
revert SafeCastOverflowedUintDowncast(144, value);
}
return uint144(value);
}
/**
* @dev Returns the downcasted uint136 from uint256, reverting on
* overflow (when the input is greater than largest uint136).
*
* Counterpart to Solidity's `uint136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*/
function toUint136(uint256 value) internal pure returns (uint136) {
if (value > type(uint136).max) {
revert SafeCastOverflowedUintDowncast(136, value);
}
return uint136(value);
}
/**
* @dev Returns the downcasted uint128 from uint256, reverting on
* overflow (when the input is greater than largest uint128).
*
* Counterpart to Solidity's `uint128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toUint128(uint256 value) internal pure returns (uint128) {
if (value > type(uint128).max) {
revert SafeCastOverflowedUintDowncast(128, value);
}
return uint128(value);
}
/**
* @dev Returns the downcasted uint120 from uint256, reverting on
* overflow (when the input is greater than largest uint120).
*
* Counterpart to Solidity's `uint120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*/
function toUint120(uint256 value) internal pure returns (uint120) {
if (value > type(uint120).max) {
revert SafeCastOverflowedUintDowncast(120, value);
}
return uint120(value);
}
/**
* @dev Returns the downcasted uint112 from uint256, reverting on
* overflow (when the input is greater than largest uint112).
*
* Counterpart to Solidity's `uint112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*/
function toUint112(uint256 value) internal pure returns (uint112) {
if (value > type(uint112).max) {
revert SafeCastOverflowedUintDowncast(112, value);
}
return uint112(value);
}
/**
* @dev Returns the downcasted uint104 from uint256, reverting on
* overflow (when the input is greater than largest uint104).
*
* Counterpart to Solidity's `uint104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*/
function toUint104(uint256 value) internal pure returns (uint104) {
if (value > type(uint104).max) {
revert SafeCastOverflowedUintDowncast(104, value);
}
return uint104(value);
}
/**
* @dev Returns the downcasted uint96 from uint256, reverting on
* overflow (when the input is greater than largest uint96).
*
* Counterpart to Solidity's `uint96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toUint96(uint256 value) internal pure returns (uint96) {
if (value > type(uint96).max) {
revert SafeCastOverflowedUintDowncast(96, value);
}
return uint96(value);
}
/**
* @dev Returns the downcasted uint88 from uint256, reverting on
* overflow (when the input is greater than largest uint88).
*
* Counterpart to Solidity's `uint88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*/
function toUint88(uint256 value) internal pure returns (uint88) {
if (value > type(uint88).max) {
revert SafeCastOverflowedUintDowncast(88, value);
}
return uint88(value);
}
/**
* @dev Returns the downcasted uint80 from uint256, reverting on
* overflow (when the input is greater than largest uint80).
*
* Counterpart to Solidity's `uint80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*/
function toUint80(uint256 value) internal pure returns (uint80) {
if (value > type(uint80).max) {
revert SafeCastOverflowedUintDowncast(80, value);
}
return uint80(value);
}
/**
* @dev Returns the downcasted uint72 from uint256, reverting on
* overflow (when the input is greater than largest uint72).
*
* Counterpart to Solidity's `uint72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*/
function toUint72(uint256 value) internal pure returns (uint72) {
if (value > type(uint72).max) {
revert SafeCastOverflowedUintDowncast(72, value);
}
return uint72(value);
}
/**
* @dev Returns the downcasted uint64 from uint256, reverting on
* overflow (when the input is greater than largest uint64).
*
* Counterpart to Solidity's `uint64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toUint64(uint256 value) internal pure returns (uint64) {
if (value > type(uint64).max) {
revert SafeCastOverflowedUintDowncast(64, value);
}
return uint64(value);
}
/**
* @dev Returns the downcasted uint56 from uint256, reverting on
* overflow (when the input is greater than largest uint56).
*
* Counterpart to Solidity's `uint56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*/
function toUint56(uint256 value) internal pure returns (uint56) {
if (value > type(uint56).max) {
revert SafeCastOverflowedUintDowncast(56, value);
}
return uint56(value);
}
/**
* @dev Returns the downcasted uint48 from uint256, reverting on
* overflow (when the input is greater than largest uint48).
*
* Counterpart to Solidity's `uint48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*/
function toUint48(uint256 value) internal pure returns (uint48) {
if (value > type(uint48).max) {
revert SafeCastOverflowedUintDowncast(48, value);
}
return uint48(value);
}
/**
* @dev Returns the downcasted uint40 from uint256, reverting on
* overflow (when the input is greater than largest uint40).
*
* Counterpart to Solidity's `uint40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*/
function toUint40(uint256 value) internal pure returns (uint40) {
if (value > type(uint40).max) {
revert SafeCastOverflowedUintDowncast(40, value);
}
return uint40(value);
}
/**
* @dev Returns the downcasted uint32 from uint256, reverting on
* overflow (when the input is greater than largest uint32).
*
* Counterpart to Solidity's `uint32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toUint32(uint256 value) internal pure returns (uint32) {
if (value > type(uint32).max) {
revert SafeCastOverflowedUintDowncast(32, value);
}
return uint32(value);
}
/**
* @dev Returns the downcasted uint24 from uint256, reverting on
* overflow (when the input is greater than largest uint24).
*
* Counterpart to Solidity's `uint24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*/
function toUint24(uint256 value) internal pure returns (uint24) {
if (value > type(uint24).max) {
revert SafeCastOverflowedUintDowncast(24, value);
}
return uint24(value);
}
/**
* @dev Returns the downcasted uint16 from uint256, reverting on
* overflow (when the input is greater than largest uint16).
*
* Counterpart to Solidity's `uint16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toUint16(uint256 value) internal pure returns (uint16) {
if (value > type(uint16).max) {
revert SafeCastOverflowedUintDowncast(16, value);
}
return uint16(value);
}
/**
* @dev Returns the downcasted uint8 from uint256, reverting on
* overflow (when the input is greater than largest uint8).
*
* Counterpart to Solidity's `uint8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*/
function toUint8(uint256 value) internal pure returns (uint8) {
if (value > type(uint8).max) {
revert SafeCastOverflowedUintDowncast(8, value);
}
return uint8(value);
}
/**
* @dev Converts a signed int256 into an unsigned uint256.
*
* Requirements:
*
* - input must be greater than or equal to 0.
*/
function toUint256(int256 value) internal pure returns (uint256) {
if (value < 0) {
revert SafeCastOverflowedIntToUint(value);
}
return uint256(value);
}
/**
* @dev Returns the downcasted int248 from int256, reverting on
* overflow (when the input is less than smallest int248 or
* greater than largest int248).
*
* Counterpart to Solidity's `int248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*/
function toInt248(int256 value) internal pure returns (int248 downcasted) {
downcasted = int248(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(248, value);
}
}
/**
* @dev Returns the downcasted int240 from int256, reverting on
* overflow (when the input is less than smallest int240 or
* greater than largest int240).
*
* Counterpart to Solidity's `int240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*/
function toInt240(int256 value) internal pure returns (int240 downcasted) {
downcasted = int240(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(240, value);
}
}
/**
* @dev Returns the downcasted int232 from int256, reverting on
* overflow (when the input is less than smallest int232 or
* greater than largest int232).
*
* Counterpart to Solidity's `int232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*/
function toInt232(int256 value) internal pure returns (int232 downcasted) {
downcasted = int232(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(232, value);
}
}
/**
* @dev Returns the downcasted int224 from int256, reverting on
* overflow (when the input is less than smallest int224 or
* greater than largest int224).
*
* Counterpart to Solidity's `int224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toInt224(int256 value) internal pure returns (int224 downcasted) {
downcasted = int224(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(224, value);
}
}
/**
* @dev Returns the downcasted int216 from int256, reverting on
* overflow (when the input is less than smallest int216 or
* greater than largest int216).
*
* Counterpart to Solidity's `int216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*/
function toInt216(int256 value) internal pure returns (int216 downcasted) {
downcasted = int216(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(216, value);
}
}
/**
* @dev Returns the downcasted int208 from int256, reverting on
* overflow (when the input is less than smallest int208 or
* greater than largest int208).
*
* Counterpart to Solidity's `int208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*/
function toInt208(int256 value) internal pure returns (int208 downcasted) {
downcasted = int208(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(208, value);
}
}
/**
* @dev Returns the downcasted int200 from int256, reverting on
* overflow (when the input is less than smallest int200 or
* greater than largest int200).
*
* Counterpart to Solidity's `int200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*/
function toInt200(int256 value) internal pure returns (int200 downcasted) {
downcasted = int200(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(200, value);
}
}
/**
* @dev Returns the downcasted int192 from int256, reverting on
* overflow (when the input is less than smallest int192 or
* greater than largest int192).
*
* Counterpart to Solidity's `int192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*/
function toInt192(int256 value) internal pure returns (int192 downcasted) {
downcasted = int192(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(192, value);
}
}
/**
* @dev Returns the downcasted int184 from int256, reverting on
* overflow (when the input is less than smallest int184 or
* greater than largest int184).
*
* Counterpart to Solidity's `int184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*/
function toInt184(int256 value) internal pure returns (int184 downcasted) {
downcasted = int184(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(184, value);
}
}
/**
* @dev Returns the downcasted int176 from int256, reverting on
* overflow (when the input is less than smallest int176 or
* greater than largest int176).
*
* Counterpart to Solidity's `int176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*/
function toInt176(int256 value) internal pure returns (int176 downcasted) {
downcasted = int176(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(176, value);
}
}
/**
* @dev Returns the downcasted int168 from int256, reverting on
* overflow (when the input is less than smallest int168 or
* greater than largest int168).
*
* Counterpart to Solidity's `int168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*/
function toInt168(int256 value) internal pure returns (int168 downcasted) {
downcasted = int168(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(168, value);
}
}
/**
* @dev Returns the downcasted int160 from int256, reverting on
* overflow (when the input is less than smallest int160 or
* greater than largest int160).
*
* Counterpart to Solidity's `int160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*/
function toInt160(int256 value) internal pure returns (int160 downcasted) {
downcasted = int160(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(160, value);
}
}
/**
* @dev Returns the downcasted int152 from int256, reverting on
* overflow (when the input is less than smallest int152 or
* greater than largest int152).
*
* Counterpart to Solidity's `int152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*/
function toInt152(int256 value) internal pure returns (int152 downcasted) {
downcasted = int152(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(152, value);
}
}
/**
* @dev Returns the downcasted int144 from int256, reverting on
* overflow (when the input is less than smallest int144 or
* greater than largest int144).
*
* Counterpart to Solidity's `int144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*/
function toInt144(int256 value) internal pure returns (int144 downcasted) {
downcasted = int144(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(144, value);
}
}
/**
* @dev Returns the downcasted int136 from int256, reverting on
* overflow (when the input is less than smallest int136 or
* greater than largest int136).
*
* Counterpart to Solidity's `int136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*/
function toInt136(int256 value) internal pure returns (int136 downcasted) {
downcasted = int136(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(136, value);
}
}
/**
* @dev Returns the downcasted int128 from int256, reverting on
* overflow (when the input is less than smallest int128 or
* greater than largest int128).
*
* Counterpart to Solidity's `int128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toInt128(int256 value) internal pure returns (int128 downcasted) {
downcasted = int128(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(128, value);
}
}
/**
* @dev Returns the downcasted int120 from int256, reverting on
* overflow (when the input is less than smallest int120 or
* greater than largest int120).
*
* Counterpart to Solidity's `int120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*/
function toInt120(int256 value) internal pure returns (int120 downcasted) {
downcasted = int120(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(120, value);
}
}
/**
* @dev Returns the downcasted int112 from int256, reverting on
* overflow (when the input is less than smallest int112 or
* greater than largest int112).
*
* Counterpart to Solidity's `int112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*/
function toInt112(int256 value) internal pure returns (int112 downcasted) {
downcasted = int112(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(112, value);
}
}
/**
* @dev Returns the downcasted int104 from int256, reverting on
* overflow (when the input is less than smallest int104 or
* greater than largest int104).
*
* Counterpart to Solidity's `int104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*/
function toInt104(int256 value) internal pure returns (int104 downcasted) {
downcasted = int104(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(104, value);
}
}
/**
* @dev Returns the downcasted int96 from int256, reverting on
* overflow (when the input is less than smallest int96 or
* greater than largest int96).
*
* Counterpart to Solidity's `int96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toInt96(int256 value) internal pure returns (int96 downcasted) {
downcasted = int96(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(96, value);
}
}
/**
* @dev Returns the downcasted int88 from int256, reverting on
* overflow (when the input is less than smallest int88 or
* greater than largest int88).
*
* Counterpart to Solidity's `int88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*/
function toInt88(int256 value) internal pure returns (int88 downcasted) {
downcasted = int88(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(88, value);
}
}
/**
* @dev Returns the downcasted int80 from int256, reverting on
* overflow (when the input is less than smallest int80 or
* greater than largest int80).
*
* Counterpart to Solidity's `int80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*/
function toInt80(int256 value) internal pure returns (int80 downcasted) {
downcasted = int80(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(80, value);
}
}
/**
* @dev Returns the downcasted int72 from int256, reverting on
* overflow (when the input is less than smallest int72 or
* greater than largest int72).
*
* Counterpart to Solidity's `int72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*/
function toInt72(int256 value) internal pure returns (int72 downcasted) {
downcasted = int72(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(72, value);
}
}
/**
* @dev Returns the downcasted int64 from int256, reverting on
* overflow (when the input is less than smallest int64 or
* greater than largest int64).
*
* Counterpart to Solidity's `int64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toInt64(int256 value) internal pure returns (int64 downcasted) {
downcasted = int64(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(64, value);
}
}
/**
* @dev Returns the downcasted int56 from int256, reverting on
* overflow (when the input is less than smallest int56 or
* greater than largest int56).
*
* Counterpart to Solidity's `int56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*/
function toInt56(int256 value) internal pure returns (int56 downcasted) {
downcasted = int56(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(56, value);
}
}
/**
* @dev Returns the downcasted int48 from int256, reverting on
* overflow (when the input is less than smallest int48 or
* greater than largest int48).
*
* Counterpart to Solidity's `int48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*/
function toInt48(int256 value) internal pure returns (int48 downcasted) {
downcasted = int48(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(48, value);
}
}
/**
* @dev Returns the downcasted int40 from int256, reverting on
* overflow (when the input is less than smallest int40 or
* greater than largest int40).
*
* Counterpart to Solidity's `int40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*/
function toInt40(int256 value) internal pure returns (int40 downcasted) {
downcasted = int40(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(40, value);
}
}
/**
* @dev Returns the downcasted int32 from int256, reverting on
* overflow (when the input is less than smallest int32 or
* greater than largest int32).
*
* Counterpart to Solidity's `int32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toInt32(int256 value) internal pure returns (int32 downcasted) {
downcasted = int32(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(32, value);
}
}
/**
* @dev Returns the downcasted int24 from int256, reverting on
* overflow (when the input is less than smallest int24 or
* greater than largest int24).
*
* Counterpart to Solidity's `int24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*/
function toInt24(int256 value) internal pure returns (int24 downcasted) {
downcasted = int24(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(24, value);
}
}
/**
* @dev Returns the downcasted int16 from int256, reverting on
* overflow (when the input is less than smallest int16 or
* greater than largest int16).
*
* Counterpart to Solidity's `int16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toInt16(int256 value) internal pure returns (int16 downcasted) {
downcasted = int16(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(16, value);
}
}
/**
* @dev Returns the downcasted int8 from int256, reverting on
* overflow (when the input is less than smallest int8 or
* greater than largest int8).
*
* Counterpart to Solidity's `int8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*/
function toInt8(int256 value) internal pure returns (int8 downcasted) {
downcasted = int8(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(8, value);
}
}
/**
* @dev Converts an unsigned uint256 into a signed int256.
*
* Requirements:
*
* - input must be less than or equal to maxInt256.
*/
function toInt256(uint256 value) internal pure returns (int256) {
// Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
if (value > uint256(type(int256).max)) {
revert SafeCastOverflowedUintToInt(value);
}
return int256(value);
}
}
"
},
"src/dinero/interfaces/IAutoPxEth.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.22;
import { IERC4626 } from "@openzeppelin/contracts/interfaces/IERC4626.sol";
/**
* @title AutoPxEth
* @notice Autocompounding vault for (staked) pxETH, adapted from pxCVX vault system
* @dev This contract enables autocompounding for pxETH assets and includes various fee mechanisms.
*/
interface IAutoPxEth is IERC4626 {
/**
* @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver.
*/
function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets);
}
"
},
"src/dinero/interfaces/IPirexEth.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
interface IPirexEth {
/**
* @notice Handle pxETH minting in return for ETH deposits
* @dev This function handles the minting of pxETH in return for ETH deposits.
* @param receiver address Receiver of the minted pxETH or apxEth
* @param shouldCompound bool Whether to also compound into the vault
* @return postFeeAmount uint256 pxETH minted for the receiver
* @return feeAmount uint256 pxETH distributed as fees
*/
function deposit(
address receiver,
bool shouldCompound
) external payable returns (uint256 postFeeAmount, uint256 feeAmount);
/**
* @notice Instant redeem back ETH using pxETH
* @dev This function burns pxETH, calculates fees, and transfers ETH to the receiver.
* @param assets uint256 Amount of pxETH to redeem.
* @param receiver address Address of the ETH receiver.
* @return postFeeAmount uint256 Post-fee amount for the receiver.
* @return feeAmount uint256 Fee amount sent to the PirexFees.
*/
function instantRedeemWithPxEth(
uint256 assets,
address receiver
) external returns (uint256 postFeeAmount, uint256 feeAmount);
}
"
},
"src/dinero/interfaces/IWETH9.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.22;
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
/**
* @title Interface for WETH9
*/
interface IWETH9 is IERC20 {
/**
* @notice Deposit ether to get wrapped ether
*/
function deposit() external payable;
/**
* @notice Withdraw wrapped ether to get ether
*/
function withdraw(
uint256
) external;
}
"
},
"lib/jigsaw-protocol-v1/src/interfaces/core/IHolding.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import { IManager } from "./IManager.sol";
/**
* @title IHolding
* @dev Interface for the Holding Contract.
*/
interface IHolding {
// -- Events --
/**
* @notice Emitted when the emergency invoker is set.
*/
event EmergencyInvokerSet(address indexed oldInvoker, address indexed newInvoker);
// -- State variables --
/**
* @notice Returns the emergency invoker address.
* @return The address of the emergency invoker.
*/
function emergencyInvoker() external view returns (address);
/**
* @notice Contract that contains all the necessary configs of the protocol.
*/
function manager() external view returns (IManager);
// -- User specific methods --
/**
* @notice Sets the emergency invoker address for this holding.
*
* @notice Requirements:
* - The caller must be the owner of this holding.
*
* @notice Effects:
* - Updates the emergency invoker address to the provided value.
* - Emits an event to track the change for off-chain monitoring.
*
* @param _emergencyInvoker The address to set as the emergency invoker.
*/
function setEmergencyInvoker(
address _emergencyInvoker
) external;
/**
* @notice Approves an `_amount` of a specified token to be spent on behalf of the `msg.sender` by `_destination`.
*
* @notice Requirements:
* - The caller must be allowed to make this call.
*
* @notice Effects:
* - Safe approves the `_amount` of `_tokenAddress` to `_destination`.
*
* @param _tokenAddress Token user to be spent.
* @param _destination Destination address of the approval.
* @param _amount Withdrawal amount.
*/
function approve(address _tokenAddress, address _destination, uint256 _amount) external;
/**
* @notice Transfers `_token` from the holding contract to `_to` address.
*
* @notice Requirements:
* - The caller must be allowed.
*
* @notice Effects:
* - Safe transfers `_amount` of `_token` to `_to`.
*
* @param _token Token address.
* @param _to Address to move token to.
* @param _amount Transfer amount.
*/
function transfer(address _token, address _to, uint256 _amount) external;
/**
* @notice Executes generic call on the `contract`.
*
* @notice Requirements:
* - The caller must be allowed.
*
* @notice Effects:
* - Makes a low-level call to the `_contract` with the provided `_call` data.
*
* @param _contract The contract address for which the call will be invoked.
* @param _call Abi.encodeWithSignature data for the call.
*
* @return success Indicates if the call was successful.
* @return result The result returned by the call.
*/
function genericCall(
address _contract,
bytes calldata _call
) external payable returns (bool success, bytes memory result);
/**
* @notice Executes an emergency generic call on the specified contract.
*
* @notice Requirements:
* - The caller must be the designated emergency invoker.
* - The emergency invoker must be an allowed invoker in the Manager contract.
* - Protected by nonReentrant modifier to prevent reentrancy attacks.
*
* @notice Effects:
* - Makes a low-level call to the `_contract` with the provided `_call` data.
* - Forwards any ETH value sent with the transaction.
*
* @param _contract The contract address for which the call will be invoked.
* @param _call Abi.encodeWithSignature data for the call.
*
* @return success Indicates if the call was successful.
* @return result The result returned by the call.
*/
function emergencyGenericCall(
address _contract,
bytes calldata _call
) external payable returns (bool success, bytes memory result);
}
"
},
"lib/jigsaw-protocol-v1/src/interfaces/core/IManager.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import { IOracle } from "../oracle/IOracle.sol";
/**
* @title IManager.
* @dev I
Submitted on: 2025-09-24 16:36:45
Comments
Log in to comment.
No comments yet.