编译器
0.8.17+commit.8df45f5f
文件 1 的 25:Address.sol
pragma solidity 0.8.17;
library Address {
function isContract(address account) internal view returns (bool) {
return account.code.length > 0;
}
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
if (returndata.length > 0) {
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
文件 2 的 25:EbtcZapRouter.sol
pragma solidity ^0.8.17;
import {ICdpManagerData} from "@ebtc/contracts/interfaces/ICdpManagerData.sol";
import {ICdpManager} from "@ebtc/contracts/interfaces/ICdpManager.sol";
import {IBorrowerOperations} from "@ebtc/contracts/interfaces/IBorrowerOperations.sol";
import {IPositionManagers} from "@ebtc/contracts/interfaces/IPositionManagers.sol";
import {IERC20} from "@ebtc/contracts/Dependencies/IERC20.sol";
import {SafeERC20} from "@ebtc/contracts/Dependencies/SafeERC20.sol";
import {IStETH} from "./interface/IStETH.sol";
import {IWrappedETH} from "./interface/IWrappedETH.sol";
import {IEbtcZapRouter} from "./interface/IEbtcZapRouter.sol";
import {IWstETH} from "./interface/IWstETH.sol";
interface IMinChangeGetter {
function MIN_CHANGE() external view returns (uint256);
}
contract EbtcZapRouter is IEbtcZapRouter {
using SafeERC20 for IERC20;
address public constant NATIVE_ETH_ADDRESS =
0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
uint256 public constant LIQUIDATOR_REWARD = 2e17;
uint256 public constant MIN_NET_STETH_BALANCE = 2e18;
IStETH public immutable stEth;
IERC20 public immutable ebtc;
IERC20 public immutable wrappedEth;
IERC20 public immutable wstEth;
IBorrowerOperations public immutable borrowerOperations;
ICdpManager public immutable cdpManager;
address public immutable owner;
uint256 public immutable MIN_CHANGE;
constructor(
IERC20 _wstEth,
IERC20 _wEth,
IStETH _stEth,
IERC20 _ebtc,
IBorrowerOperations _borrowerOperations,
ICdpManager _cdpManager,
address _owner
) {
wstEth = _wstEth;
wrappedEth = _wEth;
stEth = _stEth;
ebtc = _ebtc;
borrowerOperations = _borrowerOperations;
cdpManager = _cdpManager;
owner = _owner;
stEth.approve(address(borrowerOperations), type(uint256).max);
wrappedEth.approve(address(wrappedEth), type(uint256).max);
wstEth.approve(address(wstEth), type(uint256).max);
stEth.approve(address(wstEth), type(uint256).max);
MIN_CHANGE = IMinChangeGetter(address(borrowerOperations)).MIN_CHANGE();
}
receive() external payable {
require(
msg.sender == address(wrappedEth),
"EbtcZapRouter: only allow Wrapped ETH to send Ether!"
);
}
function openCdp(
uint256 _debt,
bytes32 _upperHint,
bytes32 _lowerHint,
uint256 _stEthBalance,
PositionManagerPermit calldata _positionManagerPermit
) external returns (bytes32 cdpId) {
uint256 _collVal = _transferInitialStETHFromCaller(_stEthBalance);
cdpId = _openCdpWithPermit(
_debt,
_upperHint,
_lowerHint,
_collVal,
_positionManagerPermit
);
emit ZapOperationEthVariant(
cdpId,
EthVariantZapOperationType.OpenCdp,
true,
address(stEth),
_stEthBalance,
_collVal,
msg.sender
);
}
function openCdpWithEth(
uint256 _debt,
bytes32 _upperHint,
bytes32 _lowerHint,
uint256 _ethBalance,
PositionManagerPermit calldata _positionManagerPermit
) external payable returns (bytes32 cdpId) {
uint256 _collVal = _convertRawEthToStETH(_ethBalance);
cdpId = _openCdpWithPermit(
_debt,
_upperHint,
_lowerHint,
_collVal,
_positionManagerPermit
);
emit ZapOperationEthVariant(
cdpId,
EthVariantZapOperationType.OpenCdp,
true,
NATIVE_ETH_ADDRESS,
_ethBalance,
_collVal,
msg.sender
);
}
function openCdpWithWrappedEth(
uint256 _debt,
bytes32 _upperHint,
bytes32 _lowerHint,
uint256 _wethBalance,
PositionManagerPermit calldata _positionManagerPermit
) external returns (bytes32 cdpId) {
uint256 _collVal = _convertWrappedEthToStETH(_wethBalance);
cdpId = _openCdpWithPermit(
_debt,
_upperHint,
_lowerHint,
_collVal,
_positionManagerPermit
);
emit ZapOperationEthVariant(
cdpId,
EthVariantZapOperationType.OpenCdp,
true,
address(wrappedEth),
_wethBalance,
_collVal,
msg.sender
);
}
function openCdpWithWstEth(
uint256 _debt,
bytes32 _upperHint,
bytes32 _lowerHint,
uint256 _wstEthBalance,
PositionManagerPermit calldata _positionManagerPermit
) external returns (bytes32 cdpId) {
uint256 _collVal = _convertWstEthToStETH(_wstEthBalance);
cdpId = _openCdpWithPermit(
_debt,
_upperHint,
_lowerHint,
_collVal,
_positionManagerPermit
);
emit ZapOperationEthVariant(
cdpId,
EthVariantZapOperationType.OpenCdp,
true,
address(wstEth),
_wstEthBalance,
_collVal,
msg.sender
);
}
function closeCdp(
bytes32 _cdpId,
PositionManagerPermit calldata _positionManagerPermit
) external {
_closeCdpWithPermit(_cdpId, false, _positionManagerPermit);
}
function closeCdpForWstETH(
bytes32 _cdpId,
PositionManagerPermit calldata _positionManagerPermit
) external {
_closeCdpWithPermit(_cdpId, true, _positionManagerPermit);
}
function adjustCdpWithEth(
bytes32 _cdpId,
uint256 _collBalanceDecrease,
uint256 _debtChange,
bool _isDebtIncrease,
bytes32 _upperHint,
bytes32 _lowerHint,
uint256 _ethBalanceIncrease,
bool _useWstETHForDecrease,
PositionManagerPermit calldata _positionManagerPermit
) external payable {
_adjustCdpWithEth(
_cdpId,
_collBalanceDecrease,
_debtChange,
_isDebtIncrease,
_upperHint,
_lowerHint,
_ethBalanceIncrease,
_useWstETHForDecrease,
_positionManagerPermit
);
}
function _adjustCdpWithEth(
bytes32 _cdpId,
uint256 _collBalanceDecrease,
uint256 _debtChange,
bool _isDebtIncrease,
bytes32 _upperHint,
bytes32 _lowerHint,
uint256 _ethBalanceIncrease,
bool _useWstETHForDecrease,
PositionManagerPermit calldata _positionManagerPermit
) internal {
uint256 _collBalanceIncrease = _ethBalanceIncrease;
if (_ethBalanceIncrease > 0) {
_collBalanceIncrease = _convertRawEthToStETH(_ethBalanceIncrease);
emit ZapOperationEthVariant(
_cdpId,
EthVariantZapOperationType.AdjustCdp,
true,
NATIVE_ETH_ADDRESS,
_ethBalanceIncrease,
_collBalanceIncrease,
msg.sender
);
}
_adjustCdpWithPermit(
_cdpId,
_collBalanceDecrease,
_debtChange,
_isDebtIncrease,
_upperHint,
_lowerHint,
_collBalanceIncrease,
_useWstETHForDecrease,
_positionManagerPermit
);
}
function adjustCdpWithWrappedEth(
bytes32 _cdpId,
uint256 _collBalanceDecrease,
uint256 _debtChange,
bool _isDebtIncrease,
bytes32 _upperHint,
bytes32 _lowerHint,
uint256 _wethBalanceIncrease,
bool _useWstETHForDecrease,
PositionManagerPermit calldata _positionManagerPermit
) external {
uint256 _collBalanceIncrease = _wethBalanceIncrease;
if (_wethBalanceIncrease > 0) {
_collBalanceIncrease = _convertWrappedEthToStETH(
_wethBalanceIncrease
);
emit ZapOperationEthVariant(
_cdpId,
EthVariantZapOperationType.AdjustCdp,
true,
address(wrappedEth),
_wethBalanceIncrease,
_collBalanceIncrease,
msg.sender
);
}
_adjustCdpWithPermit(
_cdpId,
_collBalanceDecrease,
_debtChange,
_isDebtIncrease,
_upperHint,
_lowerHint,
_collBalanceIncrease,
_useWstETHForDecrease,
_positionManagerPermit
);
}
function adjustCdpWithWstEth(
bytes32 _cdpId,
uint256 _collBalanceDecrease,
uint256 _debtChange,
bool _isDebtIncrease,
bytes32 _upperHint,
bytes32 _lowerHint,
uint256 _wstEthBalanceIncrease,
bool _useWstETHForDecrease,
PositionManagerPermit calldata _positionManagerPermit
) external {
uint256 _collBalanceIncrease = _wstEthBalanceIncrease;
if (_wstEthBalanceIncrease > 0) {
_collBalanceIncrease = _convertWstEthToStETH(
_wstEthBalanceIncrease
);
emit ZapOperationEthVariant(
_cdpId,
EthVariantZapOperationType.AdjustCdp,
true,
address(wstEth),
_wstEthBalanceIncrease,
_collBalanceIncrease,
msg.sender
);
}
_adjustCdpWithPermit(
_cdpId,
_collBalanceDecrease,
_debtChange,
_isDebtIncrease,
_upperHint,
_lowerHint,
_collBalanceIncrease,
_useWstETHForDecrease,
_positionManagerPermit
);
}
function adjustCdp(
bytes32 _cdpId,
uint256 _collBalanceDecrease,
uint256 _debtChange,
bool _isDebtIncrease,
bytes32 _upperHint,
bytes32 _lowerHint,
uint256 _collBalanceIncrease,
bool _useWstETHForDecrease,
PositionManagerPermit calldata _positionManagerPermit
) external {
if (_collBalanceIncrease > 0) {
uint256 _collVal = _transferInitialStETHFromCaller(_collBalanceIncrease);
emit ZapOperationEthVariant(
_cdpId,
EthVariantZapOperationType.AdjustCdp,
true,
address(stEth),
_collBalanceIncrease,
_collVal,
msg.sender
);
}
_adjustCdpWithPermit(
_cdpId,
_collBalanceDecrease,
_debtChange,
_isDebtIncrease,
_upperHint,
_lowerHint,
_collBalanceIncrease,
_useWstETHForDecrease,
_positionManagerPermit
);
}
function addCollWithEth(
bytes32 _cdpId,
bytes32 _upperHint,
bytes32 _lowerHint,
uint256 _ethBalanceIncrease,
PositionManagerPermit calldata _positionManagerPermit
) external payable {
_adjustCdpWithEth(
_cdpId,
0,
0,
false,
_upperHint,
_lowerHint,
_ethBalanceIncrease,
false,
_positionManagerPermit
);
}
function sweepToken(address token, uint256 amount) public {
require(owner == msg.sender, "Must be owner");
if (amount > 0) {
IERC20(token).safeTransfer(msg.sender, amount);
}
}
function _openCdpWithPermit(
uint256 _debt,
bytes32 _upperHint,
bytes32 _lowerHint,
uint256 _stEthBalance,
PositionManagerPermit calldata _positionManagerPermit
) internal returns (bytes32 cdpId) {
require(
stEth.balanceOf(address(this)) >= _stEthBalance,
"EbtcZapRouter: not enough collateral for open!"
);
_requireZeroOrMinAdjustment(_debt);
_requireAtLeastMinNetStEthBalance(_stEthBalance - LIQUIDATOR_REWARD);
_permitPositionManagerApproval(_positionManagerPermit);
cdpId = borrowerOperations.openCdpFor(
_debt,
_upperHint,
_lowerHint,
_stEthBalance,
msg.sender
);
ebtc.transfer(msg.sender, _debt);
}
function _closeCdpWithPermit(
bytes32 _cdpId,
bool _useWstETH,
PositionManagerPermit calldata _positionManagerPermit
) internal {
require(
msg.sender == _getOwnerAddress(_cdpId),
"EbtcZapRouter: not owner for close!"
);
uint256 _debt = ICdpManagerData(address(cdpManager)).getSyncedCdpDebt(
_cdpId
);
ebtc.transferFrom(msg.sender, address(this), _debt);
_permitPositionManagerApproval(_positionManagerPermit);
uint256 _zapStEthBalanceBefore = stEth.balanceOf(address(this));
borrowerOperations.closeCdp(_cdpId);
uint256 _zapStEthBalanceAfter = stEth.balanceOf(address(this));
uint256 _stETHDiff = _zapStEthBalanceAfter - _zapStEthBalanceBefore;
_transferStEthToCaller(_cdpId, EthVariantZapOperationType.CloseCdp, _useWstETH, _stETHDiff);
}
function _transferStEthToCaller(
bytes32 _cdpId,
EthVariantZapOperationType _operationType,
bool _useWstETH,
uint256 _stEthVal
) internal {
if (_useWstETH) {
uint256 _wstETHVal = IWstETH(address(wstEth)).wrap(_stEthVal);
emit ZapOperationEthVariant(
_cdpId,
_operationType,
false,
address(wstEth),
_wstETHVal,
_stEthVal,
msg.sender
);
wstEth.transfer(msg.sender, _wstETHVal);
} else {
emit ZapOperationEthVariant(
_cdpId,
_operationType,
false,
address(stEth),
_stEthVal,
_stEthVal,
msg.sender
);
stEth.transfer(msg.sender, _stEthVal);
}
}
function _adjustCdpWithPermit(
bytes32 _cdpId,
uint256 _collBalanceDecrease,
uint256 _debtChange,
bool isDebtIncrease,
bytes32 _upperHint,
bytes32 _lowerHint,
uint256 _collBalanceIncrease,
bool _useWstETH,
PositionManagerPermit calldata _positionManagerPermit
) internal {
require(
msg.sender == _getOwnerAddress(_cdpId),
"EbtcZapRouter: not owner for adjust!"
);
require(
(_collBalanceDecrease > 0 && _collBalanceIncrease == 0) ||
(_collBalanceIncrease > 0 && _collBalanceDecrease == 0) ||
(_collBalanceIncrease == 0 && _collBalanceDecrease == 0),
"EbtcZapRouter: can't add and remove collateral at the same time!"
);
_requireNonZeroAdjustment(_collBalanceIncrease, _collBalanceDecrease, _debtChange);
_requireZeroOrMinAdjustment(_debtChange);
_requireZeroOrMinAdjustment(_collBalanceIncrease);
_requireZeroOrMinAdjustment(_collBalanceDecrease);
_permitPositionManagerApproval(_positionManagerPermit);
if (!isDebtIncrease && _debtChange > 0) {
ebtc.transferFrom(msg.sender, address(this), _debtChange);
}
uint256 _zapStEthBalanceBefore = stEth.balanceOf(address(this));
borrowerOperations.adjustCdpWithColl(
_cdpId,
_collBalanceDecrease,
_debtChange,
isDebtIncrease,
_upperHint,
_lowerHint,
_collBalanceIncrease
);
uint256 _zapStEthBalanceAfter = stEth.balanceOf(address(this));
if (isDebtIncrease && _debtChange > 0) {
ebtc.transfer(msg.sender, _debtChange);
}
if (_collBalanceDecrease > 0) {
_transferStEthToCaller(
_cdpId,
EthVariantZapOperationType.AdjustCdp,
_useWstETH,
_zapStEthBalanceAfter - _zapStEthBalanceBefore
);
}
}
function _transferInitialStETHFromCaller(
uint256 _initialStETH
) internal returns (uint256) {
uint256 _balBefore = stEth.balanceOf(address(this));
stEth.transferFrom(msg.sender, address(this), _initialStETH);
uint256 _deposit = stEth.balanceOf(address(this)) - _balBefore;
return _deposit;
}
function _convertRawEthToStETH(
uint256 _initialETH
) internal returns (uint256) {
require(
msg.value == _initialETH,
"EbtcZapRouter: Incorrect ETH amount"
);
return _depositRawEthIntoLido(_initialETH);
}
function _depositRawEthIntoLido(
uint256 _initialETH
) internal returns (uint256) {
uint256 _balBefore = stEth.balanceOf(address(this));
payable(address(stEth)).call{value: _initialETH}("");
uint256 _deposit = stEth.balanceOf(address(this)) - _balBefore;
return _deposit;
}
function _convertWrappedEthToStETH(
uint256 _initialWETH
) internal returns (uint256) {
uint256 _wETHBalBefore = wrappedEth.balanceOf(address(this));
wrappedEth.transferFrom(msg.sender, address(this), _initialWETH);
uint256 _wETHReiceived = wrappedEth.balanceOf(address(this)) -
_wETHBalBefore;
uint256 _rawETHBalBefore = address(this).balance;
IWrappedETH(address(wrappedEth)).withdraw(_wETHReiceived);
uint256 _rawETHConverted = address(this).balance - _rawETHBalBefore;
return _depositRawEthIntoLido(_rawETHConverted);
}
function _convertWstEthToStETH(
uint256 _initialWstETH
) internal returns (uint256) {
require(
wstEth.transferFrom(msg.sender, address(this), _initialWstETH),
"EbtcZapRouter: transfer wstETH failure!"
);
uint256 _stETHBalBefore = stEth.balanceOf(address(this));
IWstETH(address(wstEth)).unwrap(_initialWstETH);
uint256 _stETHReiceived = stEth.balanceOf(address(this)) -
_stETHBalBefore;
return _stETHReiceived;
}
function _permitPositionManagerApproval(
PositionManagerPermit calldata _positionManagerPermit
) internal {
try
borrowerOperations.permitPositionManagerApproval(
msg.sender,
address(this),
IPositionManagers.PositionManagerApproval.OneTime,
_positionManagerPermit.deadline,
_positionManagerPermit.v,
_positionManagerPermit.r,
_positionManagerPermit.s
)
{} catch {
}
}
function _getOwnerAddress(bytes32 cdpId) internal pure returns (address) {
uint256 _tmp = uint256(cdpId) >> 96;
return address(uint160(_tmp));
}
function _requireZeroOrMinAdjustment(uint256 _change) internal view {
require(
_change == 0 || _change >= MIN_CHANGE,
"EbtcZapRouter: Debt or collateral change must be zero or above min"
);
}
function _requireAtLeastMinNetStEthBalance(uint256 _stEthBalance) internal pure {
require(
_stEthBalance >= MIN_NET_STETH_BALANCE,
"EbtcZapRouter: Cdp's net stEth balance must not fall below minimum"
);
}
function _requireNonZeroAdjustment(
uint256 _stEthBalanceIncrease,
uint256 _stEthBalanceDecrease,
uint256 _debtChange
) internal pure {
require(
_stEthBalanceIncrease > 0 || _stEthBalanceDecrease > 0 || _debtChange > 0,
"EbtcZapRouter: There must be either a collateral or debt change"
);
}
}
文件 3 的 25:IActivePool.sol
pragma solidity 0.8.17;
import "./IPool.sol";
import "./ITwapWeightedObserver.sol";
interface IActivePool is IPool, ITwapWeightedObserver {
event ActivePoolEBTCDebtUpdated(uint256 _EBTCDebt);
event SystemCollSharesUpdated(uint256 _coll);
event FeeRecipientClaimableCollSharesIncreased(uint256 _coll, uint256 _fee);
event FeeRecipientClaimableCollSharesDecreased(uint256 _coll, uint256 _fee);
event FlashLoanSuccess(
address indexed _receiver,
address indexed _token,
uint256 _amount,
uint256 _fee
);
event SweepTokenSuccess(address indexed _token, uint256 _amount, address indexed _recipient);
function transferSystemCollShares(address _account, uint256 _amount) external;
function increaseSystemCollShares(uint256 _value) external;
function transferSystemCollSharesAndLiquidatorReward(
address _account,
uint256 _shares,
uint256 _liquidatorRewardShares
) external;
function allocateSystemCollSharesToFeeRecipient(uint256 _shares) external;
function claimFeeRecipientCollShares(uint256 _shares) external;
function feeRecipientAddress() external view returns (address);
function getFeeRecipientClaimableCollShares() external view returns (uint256);
}
文件 4 的 25:IBaseTwapWeightedObserver.sol
pragma solidity 0.8.17;
interface IBaseTwapWeightedObserver {
struct PackedData {
uint128 observerCumuVal;
uint128 accumulator;
uint64 lastObserved;
uint64 lastAccrued;
uint128 lastObservedAverage;
}
}
文件 5 的 25:IBorrowerOperations.sol
pragma solidity 0.8.17;
import "./IPositionManagers.sol";
interface IBorrowerOperations is IPositionManagers {
event FeeRecipientAddressChanged(address indexed _feeRecipientAddress);
event FlashLoanSuccess(
address indexed _receiver,
address indexed _token,
uint256 _amount,
uint256 _fee
);
function openCdp(
uint256 _EBTCAmount,
bytes32 _upperHint,
bytes32 _lowerHint,
uint256 _stEthBalance
) external returns (bytes32);
function openCdpFor(
uint _EBTCAmount,
bytes32 _upperHint,
bytes32 _lowerHint,
uint _collAmount,
address _borrower
) external returns (bytes32);
function addColl(
bytes32 _cdpId,
bytes32 _upperHint,
bytes32 _lowerHint,
uint256 _stEthBalanceIncrease
) external;
function withdrawColl(
bytes32 _cdpId,
uint256 _stEthBalanceDecrease,
bytes32 _upperHint,
bytes32 _lowerHint
) external;
function withdrawDebt(
bytes32 _cdpId,
uint256 _amount,
bytes32 _upperHint,
bytes32 _lowerHint
) external;
function repayDebt(
bytes32 _cdpId,
uint256 _amount,
bytes32 _upperHint,
bytes32 _lowerHint
) external;
function closeCdp(bytes32 _cdpId) external;
function adjustCdp(
bytes32 _cdpId,
uint256 _stEthBalanceDecrease,
uint256 _debtChange,
bool isDebtIncrease,
bytes32 _upperHint,
bytes32 _lowerHint
) external;
function adjustCdpWithColl(
bytes32 _cdpId,
uint256 _stEthBalanceDecrease,
uint256 _debtChange,
bool isDebtIncrease,
bytes32 _upperHint,
bytes32 _lowerHint,
uint256 _stEthBalanceIncrease
) external;
function claimSurplusCollShares() external;
function feeRecipientAddress() external view returns (address);
}
文件 6 的 25:ICdpManager.sol
pragma solidity 0.8.17;
import "./IEbtcBase.sol";
import "./ICdpManagerData.sol";
interface ICdpManager is IEbtcBase, ICdpManagerData {
function liquidate(bytes32 _cdpId) external;
function partiallyLiquidate(
bytes32 _cdpId,
uint256 _partialAmount,
bytes32 _upperPartialHint,
bytes32 _lowerPartialHint
) external;
function batchLiquidateCdps(bytes32[] calldata _cdpArray) external;
function redeemCollateral(
uint256 _EBTCAmount,
bytes32 _firstRedemptionHint,
bytes32 _upperPartialRedemptionHint,
bytes32 _lowerPartialRedemptionHint,
uint256 _partialRedemptionHintNICR,
uint256 _maxIterations,
uint256 _maxFee
) external;
function updateStakeAndTotalStakes(bytes32 _cdpId) external returns (uint256);
function syncAccounting(bytes32 _cdpId) external;
function closeCdp(bytes32 _cdpId, address _borrower, uint256 _debt, uint256 _coll) external;
function getRedemptionRate() external view returns (uint256);
function getRedemptionRateWithDecay() external view returns (uint256);
function getRedemptionFeeWithDecay(uint256 _stETHToRedeem) external view returns (uint256);
function getCdpStatus(bytes32 _cdpId) external view returns (uint256);
function getCdpStake(bytes32 _cdpId) external view returns (uint256);
function getCdpDebt(bytes32 _cdpId) external view returns (uint256);
function getCdpCollShares(bytes32 _cdpId) external view returns (uint256);
function getCdpLiquidatorRewardShares(bytes32 _cdpId) external view returns (uint);
function initializeCdp(
bytes32 _cdpId,
uint256 _debt,
uint256 _coll,
uint256 _liquidatorRewardShares,
address _borrower
) external;
function updateCdp(
bytes32 _cdpId,
address _borrower,
uint256 _coll,
uint256 _debt,
uint256 _newColl,
uint256 _newDebt
) external;
function getCachedTCR(uint256 _price) external view returns (uint256);
function checkRecoveryMode(uint256 _price) external view returns (bool);
}
文件 7 的 25:ICdpManagerData.sol
pragma solidity 0.8.17;
import "./ICollSurplusPool.sol";
import "./IEBTCToken.sol";
import "./ISortedCdps.sol";
import "./IActivePool.sol";
import "./IRecoveryModeGracePeriod.sol";
import "../Dependencies/ICollateralTokenOracle.sol";
interface ICdpManagerData is IRecoveryModeGracePeriod {
event StakingRewardSplitSet(uint256 _stakingRewardSplit);
event RedemptionFeeFloorSet(uint256 _redemptionFeeFloor);
event MinuteDecayFactorSet(uint256 _minuteDecayFactor);
event BetaSet(uint256 _beta);
event RedemptionsPaused(bool _paused);
event Liquidation(uint256 _liquidatedDebt, uint256 _liquidatedColl, uint256 _liqReward);
event Redemption(
uint256 _debtToRedeemExpected,
uint256 _debtToRedeemActual,
uint256 _collSharesSent,
uint256 _feeCollShares,
address indexed _redeemer
);
event CdpUpdated(
bytes32 indexed _cdpId,
address indexed _borrower,
address indexed _executor,
uint256 _oldDebt,
uint256 _oldCollShares,
uint256 _debt,
uint256 _collShares,
uint256 _stake,
CdpOperation _operation
);
event CdpLiquidated(
bytes32 indexed _cdpId,
address indexed _borrower,
uint _debt,
uint _collShares,
CdpOperation _operation,
address indexed _liquidator,
uint _premiumToLiquidator
);
event CdpPartiallyLiquidated(
bytes32 indexed _cdpId,
address indexed _borrower,
uint256 _debt,
uint256 _collShares,
CdpOperation operation,
address indexed _liquidator,
uint _premiumToLiquidator
);
event BaseRateUpdated(uint256 _baseRate);
event LastRedemptionTimestampUpdated(uint256 _lastFeeOpTime);
event TotalStakesUpdated(uint256 _newTotalStakes);
event SystemSnapshotsUpdated(uint256 _totalStakesSnapshot, uint256 _totalCollateralSnapshot);
event SystemDebtRedistributionIndexUpdated(uint256 _systemDebtRedistributionIndex);
event CdpDebtRedistributionIndexUpdated(bytes32 _cdpId, uint256 _cdpDebtRedistributionIndex);
event CdpArrayIndexUpdated(bytes32 _cdpId, uint256 _newIndex);
event StEthIndexUpdated(uint256 _oldIndex, uint256 _newIndex, uint256 _updTimestamp);
event CollateralFeePerUnitUpdated(uint256 _oldPerUnit, uint256 _newPerUnit, uint256 _feeTaken);
event CdpFeeSplitApplied(
bytes32 _cdpId,
uint256 _oldPerUnitCdp,
uint256 _newPerUnitCdp,
uint256 _collReduced,
uint256 _collLeft
);
enum CdpOperation {
openCdp,
closeCdp,
adjustCdp,
syncAccounting,
liquidateInNormalMode,
liquidateInRecoveryMode,
redeemCollateral,
partiallyLiquidate,
failedPartialRedemption
}
enum Status {
nonExistent,
active,
closedByOwner,
closedByLiquidation,
closedByRedemption
}
struct Cdp {
uint256 debt;
uint256 coll;
uint256 stake;
uint128 liquidatorRewardShares;
Status status;
}
struct CdpDebtAndCollShares {
uint256 debt;
uint256 collShares;
}
struct LiquidationLocals {
bytes32 cdpId;
uint256 partialAmount;
uint256 price;
uint256 ICR;
bytes32 upperPartialHint;
bytes32 lowerPartialHint;
bool recoveryModeAtStart;
uint256 TCR;
uint256 totalSurplusCollShares;
uint256 totalCollSharesToSend;
uint256 totalDebtToBurn;
uint256 totalDebtToRedistribute;
uint256 totalLiquidatorRewardCollShares;
}
struct LiquidationRecoveryModeLocals {
uint256 entireSystemDebt;
uint256 entireSystemColl;
uint256 totalDebtToBurn;
uint256 totalCollSharesToSend;
uint256 totalSurplusCollShares;
bytes32 cdpId;
uint256 price;
uint256 ICR;
uint256 totalDebtToRedistribute;
uint256 totalLiquidatorRewardCollShares;
}
struct LocalVariables_OuterLiquidationFunction {
uint256 price;
bool recoveryModeAtStart;
uint256 liquidatedDebt;
uint256 liquidatedColl;
}
struct LocalVariables_LiquidationSequence {
uint256 i;
uint256 ICR;
bytes32 cdpId;
bool backToNormalMode;
uint256 entireSystemDebt;
uint256 entireSystemColl;
uint256 price;
uint256 TCR;
}
struct SingleRedemptionInputs {
bytes32 cdpId;
uint256 maxEBTCamount;
uint256 price;
bytes32 upperPartialRedemptionHint;
bytes32 lowerPartialRedemptionHint;
uint256 partialRedemptionHintNICR;
}
struct LiquidationValues {
uint256 entireCdpDebt;
uint256 debtToBurn;
uint256 totalCollToSendToLiquidator;
uint256 debtToRedistribute;
uint256 collSurplus;
uint256 liquidatorCollSharesReward;
}
struct LiquidationTotals {
uint256 totalDebtInSequence;
uint256 totalDebtToBurn;
uint256 totalCollToSendToLiquidator;
uint256 totalDebtToRedistribute;
uint256 totalCollSurplus;
uint256 totalCollReward;
}
struct RedemptionTotals {
uint256 remainingDebtToRedeem;
uint256 debtToRedeem;
uint256 collSharesDrawn;
uint256 totalCollSharesSurplus;
uint256 feeCollShares;
uint256 collSharesToRedeemer;
uint256 decayedBaseRate;
uint256 price;
uint256 systemDebtAtStart;
uint256 twapSystemDebtAtStart;
uint256 systemCollSharesAtStart;
uint256 tcrAtStart;
}
struct SingleRedemptionValues {
uint256 debtToRedeem;
uint256 collSharesDrawn;
uint256 collSurplus;
uint256 liquidatorRewardShares;
bool cancelledPartial;
bool fullRedemption;
uint256 newPartialNICR;
}
function getActiveCdpsCount() external view returns (uint256);
function totalStakes() external view returns (uint256);
function ebtcToken() external view returns (IEBTCToken);
function systemStEthFeePerUnitIndex() external view returns (uint256);
function systemStEthFeePerUnitIndexError() external view returns (uint256);
function stEthIndex() external view returns (uint256);
function calcFeeUponStakingReward(
uint256 _newIndex,
uint256 _prevIndex
) external view returns (uint256, uint256, uint256);
function syncGlobalAccounting() external;
function syncGlobalAccountingAndGracePeriod() external;
function getAccumulatedFeeSplitApplied(
bytes32 _cdpId,
uint256 _systemStEthFeePerUnitIndex
) external view returns (uint256, uint256);
function getCachedNominalICR(bytes32 _cdpId) external view returns (uint256);
function getCachedICR(bytes32 _cdpId, uint256 _price) external view returns (uint256);
function getSyncedCdpDebt(bytes32 _cdpId) external view returns (uint256);
function getSyncedCdpCollShares(bytes32 _cdpId) external view returns (uint256);
function getSyncedICR(bytes32 _cdpId, uint256 _price) external view returns (uint256);
function getSyncedTCR(uint256 _price) external view returns (uint256);
function getSyncedSystemCollShares() external view returns (uint256);
function getSyncedNominalICR(bytes32 _cdpId) external view returns (uint256);
function getPendingRedistributedDebt(bytes32 _cdpId) external view returns (uint256);
function hasPendingRedistributedDebt(bytes32 _cdpId) external view returns (bool);
function getSyncedDebtAndCollShares(
bytes32 _cdpId
) external view returns (uint256 debt, uint256 collShares);
function canLiquidateRecoveryMode(uint256 icr, uint256 tcr) external view returns (bool);
function totalCollateralSnapshot() external view returns (uint256);
function totalStakesSnapshot() external view returns (uint256);
}
文件 8 的 25:ICollSurplusPool.sol
pragma solidity 0.8.17;
interface ICollSurplusPool {
event SurplusCollSharesAdded(
bytes32 indexed _cdpId,
address indexed _account,
uint256 _claimableSurplusCollShares,
uint256 _surplusCollSharesAddedFromCollateral,
uint256 _surplusCollSharesAddedFromLiquidatorReward
);
event CollSharesTransferred(address indexed _to, uint256 _amount);
event SweepTokenSuccess(address indexed _token, uint256 _amount, address indexed _recipient);
function getTotalSurplusCollShares() external view returns (uint256);
function getSurplusCollShares(address _account) external view returns (uint256);
function increaseSurplusCollShares(
bytes32 _cdpId,
address _account,
uint256 _collateralShares,
uint256 _liquidatorRewardShares
) external;
function claimSurplusCollShares(address _account) external;
function increaseTotalSurplusCollShares(uint256 _value) external;
}
文件 9 的 25:ICollateralToken.sol
pragma solidity 0.8.17;
import "./IERC20.sol";
interface ICollateralToken is IERC20 {
function getSharesByPooledEth(uint256 _ethAmount) external view returns (uint256);
function getPooledEthByShares(uint256 _sharesAmount) external view returns (uint256);
function transferShares(address _recipient, uint256 _sharesAmount) external returns (uint256);
function sharesOf(address _account) external view returns (uint256);
function getOracle() external view returns (address);
}
文件 10 的 25:ICollateralTokenOracle.sol
pragma solidity 0.8.17;
interface ICollateralTokenOracle {
function getBeaconSpec()
external
view
returns (
uint64 epochsPerFrame,
uint64 slotsPerEpoch,
uint64 secondsPerSlot,
uint64 genesisTime
);
}
文件 11 的 25:IEBTCToken.sol
pragma solidity 0.8.17;
import "../Dependencies/IERC20.sol";
import "../Dependencies/IERC2612.sol";
interface IEBTCToken is IERC20, IERC2612 {
function mint(address _account, uint256 _amount) external;
function burn(address _account, uint256 _amount) external;
}
文件 12 的 25:IERC20.sol
pragma solidity 0.8.17;
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function increaseAllowance(address spender, uint256 addedValue) external returns (bool);
function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
文件 13 的 25:IERC2612.sol
pragma solidity 0.8.17;
interface IERC2612 {
function permit(
address owner,
address spender,
uint256 amount,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
function nonces(address owner) external view returns (uint256);
function version() external view returns (string memory);
function permitTypeHash() external view returns (bytes32);
function domainSeparator() external view returns (bytes32);
}
文件 14 的 25:IEbtcBase.sol
pragma solidity 0.8.17;
import "./IPriceFeed.sol";
interface IEbtcBase {
function priceFeed() external view returns (IPriceFeed);
}
文件 15 的 25:IEbtcZapRouter.sol
pragma solidity ^0.8.17;
interface IEbtcZapRouter {
struct PositionManagerPermit {
uint256 deadline;
uint8 v;
bytes32 r;
bytes32 s;
}
enum EthVariantZapOperationType {
OpenCdp,
AdjustCdp,
CloseCdp
}
event ZapOperationEthVariant(
bytes32 indexed cdpId,
EthVariantZapOperationType indexed operation,
bool isCollateralIncrease,
address indexed collateralToken,
uint256 collateralTokenDelta,
uint256 stEthDelta,
address cdpOwner
);
function openCdp(
uint256 _debt,
bytes32 _upperHint,
bytes32 _lowerHint,
uint256 _stEthBalance,
PositionManagerPermit memory _positionManagerPermit
) external returns (bytes32 cdpId);
function openCdpWithEth(
uint256 _debt,
bytes32 _upperHint,
bytes32 _lowerHint,
uint256 _ethBalance,
PositionManagerPermit memory _positionManagerPermit
) external payable returns (bytes32 cdpId);
function openCdpWithWrappedEth(
uint256 _debt,
bytes32 _upperHint,
bytes32 _lowerHint,
uint256 _wethBalance,
PositionManagerPermit memory _positionManagerPermit
) external returns (bytes32 cdpId);
function openCdpWithWstEth(
uint256 _debt,
bytes32 _upperHint,
bytes32 _lowerHint,
uint256 _wstEthBalance,
PositionManagerPermit memory _positionManagerPermit
) external returns (bytes32 cdpId);
function adjustCdp(
bytes32 _cdpId,
uint256 _stEthBalanceDecrease,
uint256 _debtChange,
bool _isDebtIncrease,
bytes32 _upperHint,
bytes32 _lowerHint,
uint256 _stEthBalanceIncrease,
bool _useWstETHForDecrease,
PositionManagerPermit memory _positionManagerPermit
) external;
function adjustCdpWithEth(
bytes32 _cdpId,
uint256 _stEthBalanceDecrease,
uint256 _debtChange,
bool _isDebtIncrease,
bytes32 _upperHint,
bytes32 _lowerHint,
uint256 _ethBalanceIncrease,
bool _useWstETHForDecrease,
PositionManagerPermit memory _positionManagerPermit
) external payable;
function adjustCdpWithWrappedEth(
bytes32 _cdpId,
uint256 _stEthBalanceDecrease,
uint256 _debtChange,
bool _isDebtIncrease,
bytes32 _upperHint,
bytes32 _lowerHint,
uint256 _wethBalanceIncrease,
bool _useWstETHForDecrease,
PositionManagerPermit memory _positionManagerPermit
) external;
function adjustCdpWithWstEth(
bytes32 _cdpId,
uint256 _stEthBalanceDecrease,
uint256 _debtChange,
bool _isDebtIncrease,
bytes32 _upperHint,
bytes32 _lowerHint,
uint256 _wstEthBalanceIncrease,
bool _useWstETHForDecrease,
PositionManagerPermit memory _positionManagerPermit
) external;
function closeCdp(
bytes32 _cdpId,
PositionManagerPermit memory _positionManagerPermit
) external;
function closeCdpForWstETH(
bytes32 _cdpId,
PositionManagerPermit memory _positionManagerPermit
) external;
}
文件 16 的 25:IPool.sol
pragma solidity 0.8.17;
interface IPool {
event ETHBalanceUpdated(uint256 _newBalance);
event EBTCBalanceUpdated(uint256 _newBalance);
event CollSharesTransferred(address indexed _to, uint256 _amount);
function getSystemCollShares() external view returns (uint256);
function getSystemDebt() external view returns (uint256);
function increaseSystemDebt(uint256 _amount) external;
function decreaseSystemDebt(uint256 _amount) external;
}
文件 17 的 25:IPositionManagers.sol
pragma solidity 0.8.17;
interface IPositionManagers {
enum PositionManagerApproval {
None,
OneTime,
Persistent
}
event PositionManagerApprovalSet(
address indexed _borrower,
address indexed _positionManager,
PositionManagerApproval _approval
);
function getPositionManagerApproval(
address _borrower,
address _positionManager
) external view returns (PositionManagerApproval);
function setPositionManagerApproval(
address _positionManager,
PositionManagerApproval _approval
) external;
function revokePositionManagerApproval(address _positionManager) external;
function renouncePositionManagerApproval(address _borrower) external;
function permitPositionManagerApproval(
address _borrower,
address _positionManager,
PositionManagerApproval _approval,
uint _deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
function version() external view returns (string memory);
function permitTypeHash() external view returns (bytes32);
function domainSeparator() external view returns (bytes32);
}
文件 18 的 25:IPriceFeed.sol
pragma solidity 0.8.17;
interface IPriceFeed {
event LastGoodPriceUpdated(uint256 _lastGoodPrice);
event PriceFeedStatusChanged(Status newStatus);
event FallbackCallerChanged(
address indexed _oldFallbackCaller,
address indexed _newFallbackCaller
);
event UnhealthyFallbackCaller(address indexed _fallbackCaller, uint256 timestamp);
event CollateralFeedSourceUpdated(address indexed stEthFeed);
struct ChainlinkResponse {
uint80 roundEthBtcId;
uint80 roundStEthEthId;
uint256 answer;
uint256 timestampEthBtc;
uint256 timestampStEthEth;
bool success;
}
struct FallbackResponse {
uint256 answer;
uint256 timestamp;
bool success;
}
enum Status {
chainlinkWorking,
usingFallbackChainlinkUntrusted,
bothOraclesUntrusted,
usingFallbackChainlinkFrozen,
usingChainlinkFallbackUntrusted
}
function fetchPrice() external returns (uint256);
}
文件 19 的 25:IRecoveryModeGracePeriod.sol
pragma solidity 0.8.17;
interface IRecoveryModeGracePeriod {
event TCRNotified(uint256 TCR);
event GracePeriodStart();
event GracePeriodEnd();
event GracePeriodDurationSet(uint256 _recoveryModeGracePeriodDuration);
function notifyStartGracePeriod(uint256 tcr) external;
function notifyEndGracePeriod(uint256 tcr) external;
}
文件 20 的 25:ISortedCdps.sol
pragma solidity 0.8.17;
interface ISortedCdps {
event NodeAdded(bytes32 _id, uint _NICR);
event NodeRemoved(bytes32 _id);
function remove(bytes32 _id) external;
function batchRemove(bytes32[] memory _ids) external;
function reInsert(bytes32 _id, uint256 _newICR, bytes32 _prevId, bytes32 _nextId) external;
function contains(bytes32 _id) external view returns (bool);
function isFull() external view returns (bool);
function isEmpty() external view returns (bool);
function getSize() external view returns (uint256);
function getMaxSize() external view returns (uint256);
function getFirst() external view returns (bytes32);
function getLast() external view returns (bytes32);
function getNext(bytes32 _id) external view returns (bytes32);
function getPrev(bytes32 _id) external view returns (bytes32);
function validInsertPosition(
uint256 _ICR,
bytes32 _prevId,
bytes32 _nextId
) external view returns (bool);
function findInsertPosition(
uint256 _ICR,
bytes32 _prevId,
bytes32 _nextId
) external view returns (bytes32, bytes32);
function insert(
address owner,
uint256 _ICR,
bytes32 _prevId,
bytes32 _nextId
) external returns (bytes32);
function getOwnerAddress(bytes32 _id) external pure returns (address);
function nonExistId() external view returns (bytes32);
function cdpCountOf(address owner) external view returns (uint256);
function getCdpCountOf(
address owner,
bytes32 startNodeId,
uint maxNodes
) external view returns (uint256, bytes32);
function getCdpsOf(address owner) external view returns (bytes32[] memory);
function getAllCdpsOf(
address owner,
bytes32 startNodeId,
uint maxNodes
) external view returns (bytes32[] memory, uint256, bytes32);
function cdpOfOwnerByIndex(address owner, uint256 index) external view returns (bytes32);
function cdpOfOwnerByIdx(
address owner,
uint256 index,
bytes32 startNodeId,
uint maxNodes
) external view returns (bytes32, bool);
function toCdpId(
address owner,
uint256 blockHeight,
uint256 nonce
) external pure returns (bytes32);
function nextCdpNonce() external view returns (uint256);
}
文件 21 的 25:IStETH.sol
pragma solidity 0.8.17;
import "@ebtc/contracts/Dependencies/ICollateralToken.sol";
interface IStETH is ICollateralToken {
function submit(address _referral) external payable returns (uint256);
}
文件 22 的 25:ITwapWeightedObserver.sol
pragma solidity 0.8.17;
import {IBaseTwapWeightedObserver} from "./IBaseTwapWeightedObserver.sol";
interface ITwapWeightedObserver is IBaseTwapWeightedObserver {
event TwapDisabled();
function PERIOD() external view returns (uint256);
function valueToTrack() external view returns (uint128);
function timeToAccrue() external view returns (uint64);
function getLatestAccumulator() external view returns (uint128);
function observe() external returns (uint256);
function update() external;
function twapDisabled() external view returns (bool);
}
文件 23 的 25:IWrappedETH.sol
pragma solidity 0.8.17;
interface IWrappedETH {
function withdraw(uint wad) external;
}
文件 24 的 25:IWstETH.sol
pragma solidity 0.8.17;
interface IWstETH {
function unwrap(uint256 _wstETHAmount) external returns (uint256);
function wrap(uint256 _stETHAmount) external returns (uint256);
function getWstETHByStETH(
uint256 _stETHAmount
) external view returns (uint256);
function getStETHByWstETH(
uint256 _stETHAmount
) external view returns (uint256);
}
文件 25 的 25:SafeERC20.sol
pragma solidity 0.8.17;
import "./IERC20.sol";
import "./Address.sol";
library SafeERC20 {
using Address for address;
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeApprove(IERC20 token, address spender, uint256 amount) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, amount));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(
token,
abi.encodeWithSelector(token.transferFrom.selector, from, to, value)
);
}
function _callOptionalReturn(IERC20 token, bytes memory data) private {
bytes memory returndata = address(token).functionCall(
data,
"SafeERC20: low-level call failed"
);
require(
returndata.length == 0 || abi.decode(returndata, (bool)),
"SafeERC20: ERC20 operation did not succeed"
);
}
}
{
"compilationTarget": {
"src/EbtcZapRouter.sol": "EbtcZapRouter"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": [
":@crytic/=lib/",
":@ebtc/=lib/ebtc/packages/contracts/",
":ERC4626/=lib/properties/lib/ERC4626/contracts/",
":ds-test/=lib/forge-std/lib/ds-test/src/",
":ebtc/=lib/ebtc/",
":erc4626-tests/=lib/properties/lib/openzeppelin-contracts/lib/erc4626-tests/",
":forge-std/=lib/forge-std/src/",
":openzeppelin-contracts/=lib/properties/lib/openzeppelin-contracts/",
":properties/=lib/properties/contracts/",
":solmate/=lib/properties/lib/solmate/src/"
]
}
[{"inputs":[{"internalType":"contract IERC20","name":"_wstEth","type":"address"},{"internalType":"contract IERC20","name":"_wEth","type":"address"},{"internalType":"contract IStETH","name":"_stEth","type":"address"},{"internalType":"contract IERC20","name":"_ebtc","type":"address"},{"internalType":"contract IBorrowerOperations","name":"_borrowerOperations","type":"address"},{"internalType":"contract ICdpManager","name":"_cdpManager","type":"address"},{"internalType":"address","name":"_owner","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"cdpId","type":"bytes32"},{"indexed":true,"internalType":"enum IEbtcZapRouter.EthVariantZapOperationType","name":"operation","type":"uint8"},{"indexed":false,"internalType":"bool","name":"isCollateralIncrease","type":"bool"},{"indexed":true,"internalType":"address","name":"collateralToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"collateralTokenDelta","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"stEthDelta","type":"uint256"},{"indexed":false,"internalType":"address","name":"cdpOwner","type":"address"}],"name":"ZapOperationEthVariant","type":"event"},{"inputs":[],"name":"LIQUIDATOR_REWARD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_CHANGE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_NET_STETH_BALANCE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NATIVE_ETH_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_cdpId","type":"bytes32"},{"internalType":"bytes32","name":"_upperHint","type":"bytes32"},{"internalType":"bytes32","name":"_lowerHint","type":"bytes32"},{"internalType":"uint256","name":"_ethBalanceIncrease","type":"uint256"},{"components":[{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct IEbtcZapRouter.PositionManagerPermit","name":"_positionManagerPermit","type":"tuple"}],"name":"addCollWithEth","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_cdpId","type":"bytes32"},{"internalType":"uint256","name":"_collBalanceDecrease","type":"uint256"},{"internalType":"uint256","name":"_debtChange","type":"uint256"},{"internalType":"bool","name":"_isDebtIncrease","type":"bool"},{"internalType":"bytes32","name":"_upperHint","type":"bytes32"},{"internalType":"bytes32","name":"_lowerHint","type":"bytes32"},{"internalType":"uint256","name":"_collBalanceIncrease","type":"uint256"},{"internalType":"bool","name":"_useWstETHForDecrease","type":"bool"},{"components":[{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct IEbtcZapRouter.PositionManagerPermit","name":"_positionManagerPermit","type":"tuple"}],"name":"adjustCdp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_cdpId","type":"bytes32"},{"internalType":"uint256","name":"_collBalanceDecrease","type":"uint256"},{"internalType":"uint256","name":"_debtChange","type":"uint256"},{"internalType":"bool","name":"_isDebtIncrease","type":"bool"},{"internalType":"bytes32","name":"_upperHint","type":"bytes32"},{"internalType":"bytes32","name":"_lowerHint","type":"bytes32"},{"internalType":"uint256","name":"_ethBalanceIncrease","type":"uint256"},{"internalType":"bool","name":"_useWstETHForDecrease","type":"bool"},{"components":[{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct IEbtcZapRouter.PositionManagerPermit","name":"_positionManagerPermit","type":"tuple"}],"name":"adjustCdpWithEth","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_cdpId","type":"bytes32"},{"internalType":"uint256","name":"_collBalanceDecrease","type":"uint256"},{"internalType":"uint256","name":"_debtChange","type":"uint256"},{"internalType":"bool","name":"_isDebtIncrease","type":"bool"},{"internalType":"bytes32","name":"_upperHint","type":"bytes32"},{"internalType":"bytes32","name":"_lowerHint","type":"bytes32"},{"internalType":"uint256","name":"_wethBalanceIncrease","type":"uint256"},{"internalType":"bool","name":"_useWstETHForDecrease","type":"bool"},{"components":[{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct IEbtcZapRouter.PositionManagerPermit","name":"_positionManagerPermit","type":"tuple"}],"name":"adjustCdpWithWrappedEth","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_cdpId","type":"bytes32"},{"internalType":"uint256","name":"_collBalanceDecrease","type":"uint256"},{"internalType":"uint256","name":"_debtChange","type":"uint256"},{"internalType":"bool","name":"_isDebtIncrease","type":"bool"},{"internalType":"bytes32","name":"_upperHint","type":"bytes32"},{"internalType":"bytes32","name":"_lowerHint","type":"bytes32"},{"internalType":"uint256","name":"_wstEthBalanceIncrease","type":"uint256"},{"internalType":"bool","name":"_useWstETHForDecrease","type":"bool"},{"components":[{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct IEbtcZapRouter.PositionManagerPermit","name":"_positionManagerPermit","type":"tuple"}],"name":"adjustCdpWithWstEth","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"borrowerOperations","outputs":[{"internalType":"contract IBorrowerOperations","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cdpManager","outputs":[{"internalType":"contract ICdpManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_cdpId","type":"bytes32"},{"components":[{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct IEbtcZapRouter.PositionManagerPermit","name":"_positionManagerPermit","type":"tuple"}],"name":"closeCdp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_cdpId","type":"bytes32"},{"components":[{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct IEbtcZapRouter.PositionManagerPermit","name":"_positionManagerPermit","type":"tuple"}],"name":"closeCdpForWstETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"ebtc","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_debt","type":"uint256"},{"internalType":"bytes32","name":"_upperHint","type":"bytes32"},{"internalType":"bytes32","name":"_lowerHint","type":"bytes32"},{"internalType":"uint256","name":"_stEthBalance","type":"uint256"},{"components":[{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct IEbtcZapRouter.PositionManagerPermit","name":"_positionManagerPermit","type":"tuple"}],"name":"openCdp","outputs":[{"internalType":"bytes32","name":"cdpId","type":"bytes32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_debt","type":"uint256"},{"internalType":"bytes32","name":"_upperHint","type":"bytes32"},{"internalType":"bytes32","name":"_lowerHint","type":"bytes32"},{"internalType":"uint256","name":"_ethBalance","type":"uint256"},{"components":[{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct IEbtcZapRouter.PositionManagerPermit","name":"_positionManagerPermit","type":"tuple"}],"name":"openCdpWithEth","outputs":[{"internalType":"bytes32","name":"cdpId","type":"bytes32"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_debt","type":"uint256"},{"internalType":"bytes32","name":"_upperHint","type":"bytes32"},{"internalType":"bytes32","name":"_lowerHint","type":"bytes32"},{"internalType":"uint256","name":"_wethBalance","type":"uint256"},{"components":[{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct IEbtcZapRouter.PositionManagerPermit","name":"_positionManagerPermit","type":"tuple"}],"name":"openCdpWithWrappedEth","outputs":[{"internalType":"bytes32","name":"cdpId","type":"bytes32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_debt","type":"uint256"},{"internalType":"bytes32","name":"_upperHint","type":"bytes32"},{"internalType":"bytes32","name":"_lowerHint","type":"bytes32"},{"internalType":"uint256","name":"_wstEthBalance","type":"uint256"},{"components":[{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct IEbtcZapRouter.PositionManagerPermit","name":"_positionManagerPermit","type":"tuple"}],"name":"openCdpWithWstEth","outputs":[{"internalType":"bytes32","name":"cdpId","type":"bytes32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stEth","outputs":[{"internalType":"contract IStETH","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"sweepToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"wrappedEth","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"wstEth","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]