Latest 25 from a total of 267 transactions
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Deposit4626 | 28974188 | 29 days ago | IN | 0 ETH | 0.00000071 | ||||
| Deposit4626 | 28599671 | 37 days ago | IN | 0 ETH | 0.00000023 | ||||
| Deposit4626 | 28511203 | 40 days ago | IN | 0 ETH | 0.00000028 | ||||
| Deposit4626 | 28510753 | 40 days ago | IN | 0 ETH | 0.00000031 | ||||
| Deposit4626 | 28451143 | 41 days ago | IN | 0 ETH | 0.00000043 | ||||
| Deposit4626 | 28405934 | 42 days ago | IN | 0 ETH | 0.00000043 | ||||
| Deposit4626 | 28209266 | 47 days ago | IN | 0 ETH | 0.00000001 | ||||
| Deposit4626 | 28026388 | 51 days ago | IN | 0 ETH | 0.00000013 | ||||
| Deposit4626 | 28025446 | 51 days ago | IN | 0 ETH | 0 | ||||
| Deposit4626 | 28023327 | 51 days ago | IN | 0 ETH | 0 | ||||
| Deposit4626 | 28020732 | 51 days ago | IN | 0 ETH | 0 | ||||
| Deposit4626 | 28019968 | 51 days ago | IN | 0 ETH | 0.00000009 | ||||
| Deposit4626 | 28017221 | 51 days ago | IN | 0 ETH | 0.00000024 | ||||
| Deposit4626 | 28012625 | 51 days ago | IN | 0 ETH | 0 | ||||
| Deposit4626 | 28010188 | 51 days ago | IN | 0 ETH | 0.00000005 | ||||
| Deposit4626 | 28010158 | 51 days ago | IN | 0 ETH | 0.00000048 | ||||
| Deposit4626 | 27981105 | 52 days ago | IN | 0 ETH | 0 | ||||
| Deposit4626 | 27965118 | 52 days ago | IN | 0 ETH | 0.00000003 | ||||
| Deposit4626 | 27953865 | 52 days ago | IN | 0 ETH | 0 | ||||
| Deposit4626 | 27783707 | 56 days ago | IN | 0 ETH | 0 | ||||
| Deposit4626 | 27635716 | 60 days ago | IN | 0 ETH | 0 | ||||
| Deposit4626 | 27245396 | 69 days ago | IN | 0 ETH | 0.00000007 | ||||
| Deposit4626 | 26906367 | 77 days ago | IN | 0 ETH | 0 | ||||
| Deposit4626 | 26468011 | 87 days ago | IN | 0 ETH | 0 | ||||
| Deposit4626 | 26452360 | 87 days ago | IN | 0 ETH | 0 |
Latest 1 internal transaction
| Parent Transaction Hash | Block | From | To | |||
|---|---|---|---|---|---|---|
| 14559249 | 362 days ago | Contract Creation | 0 ETH |
Cross-Chain Transactions
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0x57bf790F...657f8C7d1 The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.23;
import { SafeERC20 } from "openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol";
import { IERC4626 } from "openzeppelin-contracts/contracts/interfaces/IERC4626.sol";
import { SuperPositions } from "src/SuperPositions.sol";
import { Error } from "src/libraries/Error.sol";
import { SingleVaultSFData, MultiVaultSFData } from "src/types/DataTypes.sol";
import {
BaseSuperformRouterPlus,
SingleDirectSingleVaultStateReq,
SingleDirectMultiVaultStateReq,
SingleXChainSingleVaultStateReq,
SingleXChainMultiVaultStateReq,
MultiDstMultiVaultStateReq,
MultiDstSingleVaultStateReq
} from "src/router-plus/BaseSuperformRouterPlus.sol";
import { IBaseRouter } from "src/interfaces/IBaseRouter.sol";
import { ISuperformRouterPlus, IERC20 } from "src/interfaces/ISuperformRouterPlus.sol";
import { ISuperformRouterPlusAsync } from "src/interfaces/ISuperformRouterPlusAsync.sol";
import { LiqRequest } from "src/types/DataTypes.sol";
import { IBridgeValidator } from "src/interfaces/IBridgeValidator.sol";
/// @title SuperformRouterPlus
/// @dev Performs rebalances and deposits on the Superform platform
/// @author Zeropoint Labs
contract SuperformRouterPlus is ISuperformRouterPlus, BaseSuperformRouterPlus {
using SafeERC20 for IERC20;
uint256 public GLOBAL_SLIPPAGE;
uint256 public ROUTER_PLUS_PAYLOAD_ID;
/// @dev Tolerance constant to account for tokens with rounding issues on transfer
uint256 constant TOLERANCE_CONSTANT = 10 wei;
//////////////////////////////////////////////////////////////
// CONSTRUCTOR //
//////////////////////////////////////////////////////////////
constructor(address superRegistry_) BaseSuperformRouterPlus(superRegistry_) {
/// @dev default to 0.1% slippage as a start
GLOBAL_SLIPPAGE = 10;
}
//////////////////////////////////////////////////////////////
// EXTERNAL WRITE FUNCTIONS //
//////////////////////////////////////////////////////////////
/// @inheritdoc ISuperformRouterPlus
function rebalanceSinglePosition(RebalanceSinglePositionSyncArgs calldata args) external payable override {
///@notice when building the data to rebalance to it is important to carefuly calculate
/// expectedAmountToReceivePostRebalanceFrom
/// this is especially important in multi vault rebalance
address superPositions = _getAddress(keccak256("SUPER_POSITIONS"));
address router = _getAddress(keccak256("SUPERFORM_ROUTER"));
(uint256 balanceBefore, uint256 totalFee) = _beforeRebalanceChecks(
args.interimAsset, args.receiverAddressSP, args.rebalanceFromMsgValue, args.rebalanceToMsgValue
);
/// @dev transfers a single superPosition to this contract and approves router
_transferSuperPositions(superPositions, router, msg.sender, args.id, args.sharesToRedeem);
uint256[] memory sharesToRedeem = new uint256[](1);
sharesToRedeem[0] = args.sharesToRedeem;
_rebalancePositionsSync(
router,
RebalancePositionsSyncArgs(
Actions.REBALANCE_FROM_SINGLE,
sharesToRedeem,
args.expectedAmountToReceivePostRebalanceFrom,
args.interimAsset,
args.slippage,
args.rebalanceFromMsgValue,
args.rebalanceToMsgValue,
args.receiverAddressSP,
balanceBefore
),
args.callData,
args.rebalanceToCallData
);
_refundUnusedAndResetApprovals(superPositions, router, args.interimAsset, msg.sender, balanceBefore, totalFee);
emit RebalanceSyncCompleted(args.receiverAddressSP, args.id, args.sharesToRedeem);
}
/// @inheritdoc ISuperformRouterPlus
function rebalanceMultiPositions(RebalanceMultiPositionsSyncArgs calldata args) external payable override {
///@notice when building the data to rebalance to it is important to carefuly calculate
/// expectedAmountToReceivePostRebalanceFrom
/// this is especially important in multi vault rebalance
address superPositions = _getAddress(keccak256("SUPER_POSITIONS"));
address router = _getAddress(keccak256("SUPERFORM_ROUTER"));
(uint256 balanceBefore, uint256 totalFee) = _beforeRebalanceChecks(
args.interimAsset, args.receiverAddressSP, args.rebalanceFromMsgValue, args.rebalanceToMsgValue
);
if (args.ids.length != args.sharesToRedeem.length) {
revert Error.ARRAY_LENGTH_MISMATCH();
}
/// @dev transfers multiple superPositions to this contract and approves router
_transferBatchSuperPositions(superPositions, router, msg.sender, args.ids, args.sharesToRedeem);
_rebalancePositionsSync(
router,
RebalancePositionsSyncArgs(
Actions.REBALANCE_FROM_MULTI,
args.sharesToRedeem,
args.expectedAmountToReceivePostRebalanceFrom,
args.interimAsset,
args.slippage,
args.rebalanceFromMsgValue,
args.rebalanceToMsgValue,
args.receiverAddressSP,
balanceBefore
),
args.callData,
args.rebalanceToCallData
);
_refundUnusedAndResetApprovals(superPositions, router, args.interimAsset, msg.sender, balanceBefore, totalFee);
emit RebalanceMultiSyncCompleted(args.receiverAddressSP, args.ids, args.sharesToRedeem);
}
/// @inheritdoc ISuperformRouterPlus
function startCrossChainRebalance(InitiateXChainRebalanceArgs calldata args) external payable override {
address superPositions = _getAddress(keccak256("SUPER_POSITIONS"));
address router = _getAddress(keccak256("SUPERFORM_ROUTER"));
if (args.interimAsset == address(0) || args.receiverAddressSP == address(0)) {
revert Error.ZERO_ADDRESS();
}
if (args.expectedAmountInterimAsset == 0) {
revert Error.ZERO_AMOUNT();
}
/// @dev transfers a single superPosition to this contract and approves router
_transferSuperPositions(superPositions, router, msg.sender, args.id, args.sharesToRedeem);
/// @dev this can only be IBaseRouter.singleXChainSingleVaultWithdraw.selector due to the whitelist in
/// BaseSuperformRouterPlus
if (!whitelistedSelectors[Actions.REBALANCE_X_CHAIN_FROM_SINGLE][_parseSelectorMem(args.callData)]) {
revert INVALID_REBALANCE_FROM_SELECTOR();
}
if (!whitelistedSelectors[Actions.DEPOSIT][args.rebalanceToSelector]) {
revert INVALID_DEPOSIT_SELECTOR();
}
/// @dev validate the call data
SingleXChainSingleVaultStateReq memory req =
abi.decode(_parseCallData(args.callData), (SingleXChainSingleVaultStateReq));
if (req.superformData.liqRequest.token != args.interimAsset) {
revert REBALANCE_SINGLE_POSITIONS_DIFFERENT_TOKEN();
}
if (req.superformData.liqRequest.liqDstChainId != CHAIN_ID) {
revert REBALANCE_SINGLE_POSITIONS_DIFFERENT_CHAIN();
}
if (req.superformData.amount != args.sharesToRedeem) {
revert REBALANCE_SINGLE_POSITIONS_DIFFERENT_AMOUNT();
}
address ROUTER_PLUS_ASYNC = _getAddress(keccak256("SUPERFORM_ROUTER_PLUS_ASYNC"));
if (req.superformData.receiverAddress != ROUTER_PLUS_ASYNC) {
revert REBALANCE_XCHAIN_INVALID_RECEIVER_ADDRESS();
}
/// @dev send SPs to router
/// @notice msg.value here is the sum of rebalanceFromMsgValue and rebalanceToMsgValue (to be executed later by
/// the keeper)
_callSuperformRouter(router, args.callData, msg.value);
uint256 routerPlusPayloadId = ++ROUTER_PLUS_PAYLOAD_ID;
ISuperformRouterPlusAsync(ROUTER_PLUS_ASYNC).setXChainRebalanceCallData(
args.receiverAddressSP,
/// @dev user must send an address that controls on the destination chain
routerPlusPayloadId,
XChainRebalanceData({
rebalanceSelector: args.rebalanceToSelector,
interimAsset: args.interimAsset,
slippage: args.finalizeSlippage,
expectedAmountInterimAsset: args.expectedAmountInterimAsset,
rebalanceToAmbIds: args.rebalanceToAmbIds,
rebalanceToDstChainIds: args.rebalanceToDstChainIds,
rebalanceToSfData: args.rebalanceToSfData
})
);
emit XChainRebalanceInitiated(
args.receiverAddressSP,
routerPlusPayloadId,
args.id,
args.sharesToRedeem,
args.interimAsset,
args.finalizeSlippage,
args.expectedAmountInterimAsset,
args.rebalanceToSelector
);
}
/// @inheritdoc ISuperformRouterPlus
function startCrossChainRebalanceMulti(InitiateXChainRebalanceMultiArgs calldata args) external payable override {
address superPositions = _getAddress(keccak256("SUPER_POSITIONS"));
address router = _getAddress(keccak256("SUPERFORM_ROUTER"));
if (args.ids.length != args.sharesToRedeem.length) {
revert Error.ARRAY_LENGTH_MISMATCH();
}
if (args.interimAsset == address(0) || args.receiverAddressSP == address(0)) {
revert Error.ZERO_ADDRESS();
}
if (args.expectedAmountInterimAsset == 0) {
revert Error.ZERO_AMOUNT();
}
/// @dev transfers multiple superPositions to this contract and approves router
_transferBatchSuperPositions(superPositions, router, msg.sender, args.ids, args.sharesToRedeem);
/// @dev validate the call data
bytes4 selector = _parseSelectorMem(args.callData);
if (!whitelistedSelectors[Actions.REBALANCE_X_CHAIN_FROM_MULTI][selector]) {
revert INVALID_REBALANCE_FROM_SELECTOR();
}
address ROUTER_PLUS_ASYNC = _getAddress(keccak256("SUPERFORM_ROUTER_PLUS_ASYNC"));
if (selector == IBaseRouter.singleXChainMultiVaultWithdraw.selector) {
SingleXChainMultiVaultStateReq memory req =
abi.decode(_parseCallData(args.callData), (SingleXChainMultiVaultStateReq));
uint256 len = req.superformsData.liqRequests.length;
for (uint256 i; i < len; ++i) {
// Validate that the token and chainId is equal in all indexes
if (req.superformsData.liqRequests[i].token != args.interimAsset) {
revert REBALANCE_MULTI_POSITIONS_DIFFERENT_TOKEN();
}
if (req.superformsData.liqRequests[i].liqDstChainId != CHAIN_ID) {
revert REBALANCE_MULTI_POSITIONS_DIFFERENT_CHAIN();
}
if (req.superformsData.amounts[i] != args.sharesToRedeem[i]) {
revert REBALANCE_MULTI_POSITIONS_DIFFERENT_AMOUNTS();
}
}
if (req.superformsData.receiverAddress != ROUTER_PLUS_ASYNC) {
revert REBALANCE_XCHAIN_INVALID_RECEIVER_ADDRESS();
}
} else if (selector == IBaseRouter.multiDstMultiVaultWithdraw.selector) {
MultiDstMultiVaultStateReq memory req =
abi.decode(_parseCallData(args.callData), (MultiDstMultiVaultStateReq));
uint256 len = req.superformsData.length;
uint256 count;
for (uint256 i; i < len; ++i) {
uint256 len2 = req.superformsData[i].liqRequests.length;
for (uint256 j; j < len2; ++j) {
// Validate that the token and chainId is equal in all indexes
if (req.superformsData[i].liqRequests[j].token != args.interimAsset) {
revert REBALANCE_MULTI_POSITIONS_DIFFERENT_TOKEN();
}
if (req.superformsData[i].liqRequests[j].liqDstChainId != CHAIN_ID) {
revert REBALANCE_MULTI_POSITIONS_DIFFERENT_CHAIN();
}
/// @dev WARNING: for multiDst all shares are organized in a single array
/// array starts in the first destination with all the shares
/// then it continues through all destinations with the same process
if (req.superformsData[i].amounts[j] != args.sharesToRedeem[count]) {
revert REBALANCE_MULTI_POSITIONS_DIFFERENT_AMOUNTS();
}
++count;
}
if (req.superformsData[i].receiverAddress != ROUTER_PLUS_ASYNC) {
revert REBALANCE_XCHAIN_INVALID_RECEIVER_ADDRESS();
}
}
} else if (selector == IBaseRouter.multiDstSingleVaultWithdraw.selector) {
MultiDstSingleVaultStateReq memory req =
abi.decode(_parseCallData(args.callData), (MultiDstSingleVaultStateReq));
uint256 len = req.superformsData.length;
for (uint256 i; i < len; ++i) {
// Validate that the token and chainId is equal in all indexes
if (req.superformsData[i].liqRequest.token != args.interimAsset) {
revert REBALANCE_MULTI_POSITIONS_DIFFERENT_TOKEN();
}
if (req.superformsData[i].liqRequest.liqDstChainId != CHAIN_ID) {
revert REBALANCE_MULTI_POSITIONS_DIFFERENT_CHAIN();
}
/// @dev WARNING: for multiDst all shares are organized in a single array
/// array starts in the first destination with all the shares
/// then it continues through all destinations with the same process
if (req.superformsData[i].amount != args.sharesToRedeem[i]) {
revert REBALANCE_MULTI_POSITIONS_DIFFERENT_AMOUNTS();
}
if (req.superformsData[i].receiverAddress != ROUTER_PLUS_ASYNC) {
revert REBALANCE_XCHAIN_INVALID_RECEIVER_ADDRESS();
}
}
}
/// @dev send SPs to router
_callSuperformRouter(router, args.callData, msg.value);
if (!whitelistedSelectors[Actions.DEPOSIT][args.rebalanceToSelector]) {
revert INVALID_DEPOSIT_SELECTOR();
}
uint256 routerPlusPayloadId = ++ROUTER_PLUS_PAYLOAD_ID;
/// @dev in multiDst multiple payloads ids will be generated on source chain
ISuperformRouterPlusAsync(ROUTER_PLUS_ASYNC).setXChainRebalanceCallData(
args.receiverAddressSP,
/// @dev user must send an address that controls on the destination chain
routerPlusPayloadId,
XChainRebalanceData({
rebalanceSelector: args.rebalanceToSelector,
interimAsset: args.interimAsset,
slippage: args.finalizeSlippage,
expectedAmountInterimAsset: args.expectedAmountInterimAsset,
rebalanceToAmbIds: args.rebalanceToAmbIds,
rebalanceToDstChainIds: args.rebalanceToDstChainIds,
rebalanceToSfData: args.rebalanceToSfData
})
);
emit XChainRebalanceMultiInitiated(
args.receiverAddressSP,
routerPlusPayloadId,
args.ids,
args.sharesToRedeem,
args.interimAsset,
args.finalizeSlippage,
args.expectedAmountInterimAsset,
args.rebalanceToSelector
);
}
/// @inheritdoc ISuperformRouterPlus
function deposit4626(address[] calldata vaults_, Deposit4626Args[] calldata args) external payable {
/// @notice: args.receiverAddress SP is purely ignored now (not added in natspec to preserve the interface)
uint256 length = vaults_.length;
if (length != args.length) {
revert Error.ARRAY_LENGTH_MISMATCH();
}
if (length == 0) {
revert Error.ZERO_INPUT_VALUE();
}
uint256 valueToPass = msg.value / length;
for (uint256 i; i < length; ++i) {
if (!whitelistedSelectors[Actions.DEPOSIT][_parseSelectorMem(args[i].depositCallData)]) {
revert INVALID_DEPOSIT_SELECTOR();
}
if (i == length - 1) {
valueToPass += msg.value % length;
}
_deposit4626(vaults_[i], args[i], valueToPass);
}
}
/// @inheritdoc ISuperformRouterPlus
function forwardDustToPaymaster(address token_) external override {
if (token_ == address(0)) revert Error.ZERO_ADDRESS();
address paymaster = _getAddress(keccak256("PAYMASTER"));
IERC20 token = IERC20(token_);
uint256 dust = token.balanceOf(address(this));
if (dust != 0) {
token.safeTransfer(paymaster, dust);
emit RouterPlusDustForwardedToPaymaster(token_, dust);
}
}
/// @inheritdoc ISuperformRouterPlus
function setGlobalSlippage(uint256 slippage_) external {
if (!_hasRole(keccak256("EMERGENCY_ADMIN_ROLE"), msg.sender)) {
revert Error.NOT_PRIVILEGED_CALLER(keccak256("EMERGENCY_ADMIN_ROLE"));
}
if (slippage_ > ENTIRE_SLIPPAGE || slippage_ == 0) {
revert INVALID_GLOBAL_SLIPPAGE();
}
GLOBAL_SLIPPAGE = slippage_;
}
//////////////////////////////////////////////////////////////
// INTERNAL FUNCTIONS //
//////////////////////////////////////////////////////////////
function _rebalancePositionsSync(
address router_,
RebalancePositionsSyncArgs memory args,
bytes calldata callData,
bytes calldata rebalanceToCallData
)
internal
{
/// @notice: args.receiverAddress SP is purely ignored now (not added in natspec to preserve the interface)
IERC20 interimAsset = IERC20(args.interimAsset);
/// @dev validate the call dataREBALANCE_SINGLE_POSITIONS_DIFFERENT_AMOUNT
if (!whitelistedSelectors[args.action][_parseSelectorMem(callData)]) {
revert INVALID_REBALANCE_FROM_SELECTOR();
}
if (args.action == Actions.REBALANCE_FROM_SINGLE) {
SingleDirectSingleVaultStateReq memory req =
abi.decode(_parseCallData(callData), (SingleDirectSingleVaultStateReq));
if (req.superformData.liqRequest.token != args.interimAsset) {
revert REBALANCE_SINGLE_POSITIONS_DIFFERENT_TOKEN();
}
if (req.superformData.liqRequest.liqDstChainId != CHAIN_ID) {
revert REBALANCE_SINGLE_POSITIONS_DIFFERENT_CHAIN();
}
if (req.superformData.amount != args.sharesToRedeem[0]) {
revert REBALANCE_SINGLE_POSITIONS_DIFFERENT_AMOUNT();
}
if (req.superformData.receiverAddress != address(this)) {
revert REBALANCE_SINGLE_POSITIONS_UNEXPECTED_RECEIVER_ADDRESS();
}
} else {
/// then must be Actions.REBALANCE_FROM_MULTI
SingleDirectMultiVaultStateReq memory req =
abi.decode(_parseCallData(callData), (SingleDirectMultiVaultStateReq));
uint256 len = req.superformData.liqRequests.length;
for (uint256 i; i < len; ++i) {
// Validate that the token and chainId is equal in all indexes
if (req.superformData.liqRequests[i].token != args.interimAsset) {
revert REBALANCE_MULTI_POSITIONS_DIFFERENT_TOKEN();
}
if (req.superformData.liqRequests[i].liqDstChainId != CHAIN_ID) {
revert REBALANCE_MULTI_POSITIONS_DIFFERENT_CHAIN();
}
if (req.superformData.amounts[i] != args.sharesToRedeem[i]) {
revert REBALANCE_MULTI_POSITIONS_DIFFERENT_AMOUNTS();
}
if (req.superformData.receiverAddress != address(this)) {
revert REBALANCE_MULTI_POSITIONS_UNEXPECTED_RECEIVER_ADDRESS();
}
}
}
/// @dev send SPs to router
_callSuperformRouter(router_, callData, args.rebalanceFromMsgValue);
uint256 availableBalanceToDeposit = interimAsset.balanceOf(address(this)) - args.balanceBefore;
if (availableBalanceToDeposit == 0) revert Error.ZERO_AMOUNT();
if (
ENTIRE_SLIPPAGE * availableBalanceToDeposit
< ((args.expectedAmountToReceivePostRebalanceFrom * (ENTIRE_SLIPPAGE - args.slippage)))
) {
revert Error.VAULT_IMPLEMENTATION_FAILED();
}
uint256 amountIn = _validateAndGetAmountIn(rebalanceToCallData, availableBalanceToDeposit);
_deposit(router_, interimAsset, amountIn, args.rebalanceToMsgValue, rebalanceToCallData);
}
function _takeAmountIn(LiqRequest memory liqReq, uint256 sfDataAmount) internal view returns (uint256 amountIn) {
bytes memory txData = liqReq.txData;
if (txData.length == 0) {
amountIn = sfDataAmount;
} else {
amountIn = IBridgeValidator(superRegistry.getBridgeValidator(liqReq.bridgeId)).decodeAmountIn(txData, false);
}
}
function _transferSuperPositions(
address superPositions_,
address router_,
address user_,
uint256 id_,
uint256 amount_
)
internal
{
SuperPositions(superPositions_).safeTransferFrom(user_, address(this), id_, amount_, "");
SuperPositions(superPositions_).setApprovalForOne(router_, id_, amount_);
}
function _transferBatchSuperPositions(
address superPositions_,
address router_,
address user_,
uint256[] memory ids_,
uint256[] memory amounts_
)
internal
{
SuperPositions(superPositions_).safeBatchTransferFrom(user_, address(this), ids_, amounts_, "");
SuperPositions(superPositions_).setApprovalForAll(router_, true);
}
function _transferERC20In(IERC20 erc20_, address user_, uint256 amount_) internal {
erc20_.safeTransferFrom(user_, address(this), amount_);
}
function _redeemShare(
IERC4626 vault_,
address assetAdr_,
uint256 amountToRedeem_,
uint256 expectedOutputAmount_,
uint256 maxSlippage_
)
internal
returns (uint256 balanceDifference)
{
IERC20 asset = IERC20(assetAdr_);
uint256 assetsBalanceBefore = asset.balanceOf(address(this));
/// @dev redeem the vault shares and receive collateral
uint256 assets = vault_.redeem(amountToRedeem_, address(this), address(this));
/// @dev collateral balance after
uint256 assetsBalanceAfter = asset.balanceOf(address(this));
balanceDifference = assetsBalanceAfter - assetsBalanceBefore;
/// @dev validate the tolerance
if (assets < TOLERANCE_CONSTANT || balanceDifference < assets - TOLERANCE_CONSTANT) revert TOLERANCE_EXCEEDED();
/// @dev validate the slippage
if ((ENTIRE_SLIPPAGE * assets < ((expectedOutputAmount_ * (ENTIRE_SLIPPAGE - maxSlippage_))))) {
revert ASSETS_RECEIVED_OUT_OF_SLIPPAGE();
}
}
/// @dev helps parse bytes memory selector
function _parseSelectorMem(bytes memory data) internal pure returns (bytes4 selector) {
assembly {
selector := mload(add(data, 0x20))
}
}
/// @dev helps parse calldata
function _parseCallData(bytes calldata callData_) internal pure returns (bytes calldata) {
return callData_[4:];
}
function _beforeRebalanceChecks(
address asset_,
address user_,
uint256 rebalanceFromMsgValue_,
uint256 rebalanceToMsgValue_
)
internal
returns (uint256 balanceBefore, uint256 totalFee)
{
if (asset_ == address(0) || user_ == address(0)) {
revert Error.ZERO_ADDRESS();
}
balanceBefore = IERC20(asset_).balanceOf(address(this));
totalFee = rebalanceFromMsgValue_ + rebalanceToMsgValue_;
if (msg.value < totalFee) {
revert INVALID_FEE();
}
}
function _tokenRefunds(address router_, address asset_, address user_, uint256 balanceBefore) internal {
uint256 balanceDiff = IERC20(asset_).balanceOf(address(this)) - balanceBefore;
if (balanceDiff > 0) {
IERC20(asset_).safeTransfer(user_, balanceDiff);
}
if (IERC20(asset_).allowance(address(this), router_) > 0) {
IERC20(asset_).forceApprove(router_, 0);
}
}
/// @dev refunds any unused funds and clears approvals
function _refundUnusedAndResetApprovals(
address superPositions_,
address router_,
address asset_,
address user_,
uint256 balanceBefore,
uint256 totalFee
)
internal
{
SuperPositions(superPositions_).setApprovalForAll(router_, false);
_tokenRefunds(router_, asset_, user_, balanceBefore);
if (msg.value > totalFee) {
/// @dev refunds msg.sender if msg.value was more than needed
(bool success,) = payable(msg.sender).call{ value: msg.value - totalFee }("");
if (!success) {
revert Error.FAILED_TO_SEND_NATIVE();
}
}
}
/// @notice deposits ERC4626 vault shares into superform
/// @param vault_ The ERC4626 vault to redeem from
/// @param args Rest of the arguments to deposit 4626
/// @param valueToPass The value to pass to the deposit function
function _deposit4626(address vault_, Deposit4626Args calldata args, uint256 valueToPass) internal {
address user = msg.sender;
_transferERC20In(IERC20(vault_), user, args.amount);
IERC4626 vault = IERC4626(vault_);
address assetAdr = vault.asset();
IERC20 asset = IERC20(assetAdr);
uint256 balanceBefore = asset.balanceOf(address(this));
uint256 amountRedeemed = _redeemShare(vault, assetAdr, args.amount, args.expectedOutputAmount, args.maxSlippage);
uint256 amountIn = _validateAndGetAmountIn(args.depositCallData, amountRedeemed);
address router = _getAddress(keccak256("SUPERFORM_ROUTER"));
_deposit(router, asset, amountIn, valueToPass, args.depositCallData);
_tokenRefunds(router, assetAdr, user, balanceBefore);
emit Deposit4626Completed(user, vault_);
}
function _validateAndGetAmountIn(
bytes calldata rebalanceToCallData,
uint256 availableBalanceToDeposit
)
internal
view
returns (uint256 amountIn)
{
bytes4 rebalanceToSelector = _parseSelectorMem(rebalanceToCallData);
if (!whitelistedSelectors[Actions.DEPOSIT][rebalanceToSelector]) {
revert INVALID_DEPOSIT_SELECTOR();
}
uint256 amountInTemp;
if (rebalanceToSelector == IBaseRouter.singleDirectSingleVaultDeposit.selector) {
SingleVaultSFData memory sfData =
abi.decode(_parseCallData(rebalanceToCallData), (SingleDirectSingleVaultStateReq)).superformData;
amountIn = _takeAmountIn(sfData.liqRequest, sfData.amount);
} else if (rebalanceToSelector == IBaseRouter.singleXChainSingleVaultDeposit.selector) {
SingleVaultSFData memory sfData =
abi.decode(_parseCallData(rebalanceToCallData), (SingleXChainSingleVaultStateReq)).superformData;
amountIn = _takeAmountIn(sfData.liqRequest, sfData.amount);
} else if (rebalanceToSelector == IBaseRouter.singleDirectMultiVaultDeposit.selector) {
MultiVaultSFData memory sfData =
abi.decode(_parseCallData(rebalanceToCallData), (SingleDirectMultiVaultStateReq)).superformData;
uint256 len = sfData.liqRequests.length;
for (uint256 i; i < len; ++i) {
amountInTemp = _takeAmountIn(sfData.liqRequests[i], sfData.amounts[i]);
amountIn += amountInTemp;
}
} else if (rebalanceToSelector == IBaseRouter.singleXChainMultiVaultDeposit.selector) {
MultiVaultSFData memory sfData =
abi.decode(_parseCallData(rebalanceToCallData), (SingleXChainMultiVaultStateReq)).superformsData;
uint256 len = sfData.liqRequests.length;
for (uint256 i; i < len; ++i) {
amountInTemp = _takeAmountIn(sfData.liqRequests[i], sfData.amounts[i]);
amountIn += amountInTemp;
}
} else if (rebalanceToSelector == IBaseRouter.multiDstSingleVaultDeposit.selector) {
SingleVaultSFData[] memory sfData =
abi.decode(_parseCallData(rebalanceToCallData), (MultiDstSingleVaultStateReq)).superformsData;
uint256 lenDst = sfData.length;
for (uint256 i; i < lenDst; ++i) {
amountInTemp = _takeAmountIn(sfData[i].liqRequest, sfData[i].amount);
amountIn += amountInTemp;
}
} else if (rebalanceToSelector == IBaseRouter.multiDstMultiVaultDeposit.selector) {
MultiVaultSFData[] memory sfData =
abi.decode(_parseCallData(rebalanceToCallData), (MultiDstMultiVaultStateReq)).superformsData;
uint256 lenDst = sfData.length;
for (uint256 i; i < lenDst; ++i) {
uint256 len = sfData[i].liqRequests.length;
for (uint256 j; j < len; ++j) {
amountInTemp = _takeAmountIn(sfData[i].liqRequests[j], sfData[i].amounts[j]);
amountIn += amountInTemp;
}
}
}
/// @dev amountIn must be artificially off-chain reduced to be less than availableBalanceToDeposit otherwise the
/// @dev approval to transfer tokens to SuperformRouter won't work
if (amountIn > availableBalanceToDeposit) revert AMOUNT_IN_NOT_EQUAL_OR_LOWER_THAN_BALANCE();
/// @dev check amountIn against availableBalanceToDeposit (available balance) via a GLOBAL_SLIPPAGE to prevent a
/// @dev malicious keeper from sending a low amountIn
if (ENTIRE_SLIPPAGE * amountIn < ((availableBalanceToDeposit * (ENTIRE_SLIPPAGE - GLOBAL_SLIPPAGE)))) {
revert ASSETS_RECEIVED_OUT_OF_SLIPPAGE();
}
}
}// 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 ERC-20 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 ERC-20 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;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC4626.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../token/ERC20/IERC20.sol";
import {IERC20Metadata} from "../token/ERC20/extensions/IERC20Metadata.sol";
/**
* @dev Interface of the ERC-4626 "Tokenized Vault Standard", as defined in
* https://eips.ethereum.org/EIPS/eip-4626[ERC-4626].
*/
interface IERC4626 is IERC20, IERC20Metadata {
event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);
event Withdraw(
address indexed sender,
address indexed receiver,
address indexed owner,
uint256 assets,
uint256 shares
);
/**
* @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.
*
* - MUST be an ERC-20 token contract.
* - MUST NOT revert.
*/
function asset() external view returns (address assetTokenAddress);
/**
* @dev Returns the total amount of the underlying asset that is “managed” by Vault.
*
* - SHOULD include any compounding that occurs from yield.
* - MUST be inclusive of any fees that are charged against assets in the Vault.
* - MUST NOT revert.
*/
function totalAssets() external view returns (uint256 totalManagedAssets);
/**
* @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal
* scenario where all the conditions are met.
*
* - MUST NOT be inclusive of any fees that are charged against assets in the Vault.
* - MUST NOT show any variations depending on the caller.
* - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
* - MUST NOT revert.
*
* NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the
* “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and
* from.
*/
function convertToShares(uint256 assets) external view returns (uint256 shares);
/**
* @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal
* scenario where all the conditions are met.
*
* - MUST NOT be inclusive of any fees that are charged against assets in the Vault.
* - MUST NOT show any variations depending on the caller.
* - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.
* - MUST NOT revert.
*
* NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the
* “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and
* from.
*/
function convertToAssets(uint256 shares) external view returns (uint256 assets);
/**
* @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver,
* through a deposit call.
*
* - MUST return a limited value if receiver is subject to some deposit limit.
* - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.
* - MUST NOT revert.
*/
function maxDeposit(address receiver) external view returns (uint256 maxAssets);
/**
* @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given
* current on-chain conditions.
*
* - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit
* call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called
* in the same transaction.
* - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the
* deposit would be accepted, regardless if the user has enough tokens approved, etc.
* - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
* - MUST NOT revert.
*
* NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in
* share price or some other type of condition, meaning the depositor will lose assets by depositing.
*/
function previewDeposit(uint256 assets) external view returns (uint256 shares);
/**
* @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.
*
* - MUST emit the Deposit event.
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
* deposit execution, and are accounted for during deposit.
* - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not
* approving enough underlying tokens to the Vault contract, etc).
*
* NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
*/
function deposit(uint256 assets, address receiver) external returns (uint256 shares);
/**
* @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.
* - MUST return a limited value if receiver is subject to some mint limit.
* - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.
* - MUST NOT revert.
*/
function maxMint(address receiver) external view returns (uint256 maxShares);
/**
* @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given
* current on-chain conditions.
*
* - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call
* in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the
* same transaction.
* - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint
* would be accepted, regardless if the user has enough tokens approved, etc.
* - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.
* - MUST NOT revert.
*
* NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in
* share price or some other type of condition, meaning the depositor will lose assets by minting.
*/
function previewMint(uint256 shares) external view returns (uint256 assets);
/**
* @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.
*
* - MUST emit the Deposit event.
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint
* execution, and are accounted for during mint.
* - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not
* approving enough underlying tokens to the Vault contract, etc).
*
* NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.
*/
function mint(uint256 shares, address receiver) external returns (uint256 assets);
/**
* @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the
* Vault, through a withdraw call.
*
* - MUST return a limited value if owner is subject to some withdrawal limit or timelock.
* - MUST NOT revert.
*/
function maxWithdraw(address owner) external view returns (uint256 maxAssets);
/**
* @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block,
* given current on-chain conditions.
*
* - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw
* call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if
* called
* in the same transaction.
* - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though
* the withdrawal would be accepted, regardless if the user has enough shares, etc.
* - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
* - MUST NOT revert.
*
* NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in
* share price or some other type of condition, meaning the depositor will lose assets by depositing.
*/
function previewWithdraw(uint256 assets) external view returns (uint256 shares);
/**
* @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver.
*
* - MUST emit the Withdraw event.
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
* withdraw execution, and are accounted for during withdraw.
* - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner
* not having enough shares, etc).
*
* Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
* Those methods should be performed separately.
*/
function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);
/**
* @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault,
* through a redeem call.
*
* - MUST return a limited value if owner is subject to some withdrawal limit or timelock.
* - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.
* - MUST NOT revert.
*/
function maxRedeem(address owner) external view returns (uint256 maxShares);
/**
* @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block,
* given current on-chain conditions.
*
* - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call
* in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the
* same transaction.
* - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the
* redemption would be accepted, regardless if the user has enough shares, etc.
* - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.
* - MUST NOT revert.
*
* NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in
* share price or some other type of condition, meaning the depositor will lose assets by redeeming.
*/
function previewRedeem(uint256 shares) external view returns (uint256 assets);
/**
* @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver.
*
* - MUST emit the Withdraw event.
* - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the
* redeem execution, and are accounted for during redeem.
* - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner
* not having enough shares, etc).
*
* NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed.
* Those methods should be performed separately.
*/
function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets);
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.23;
import { ERC1155A } from "ERC1155A/ERC1155A.sol";
import { aERC20 } from "ERC1155A/aERC20.sol";
import { Broadcastable } from "src/crosschain-data/utils/Broadcastable.sol";
import { ISuperPositions } from "src/interfaces/ISuperPositions.sol";
import { ISuperRegistry } from "src/interfaces/ISuperRegistry.sol";
import { ISuperRBAC } from "src/interfaces/ISuperRBAC.sol";
import { ISuperformFactory } from "src/interfaces/ISuperformFactory.sol";
import { IBaseForm } from "src/interfaces/IBaseForm.sol";
import { IPaymentHelper } from "./interfaces/IPaymentHelper.sol";
import { Error } from "src/libraries/Error.sol";
import { DataLib } from "src/libraries/DataLib.sol";
import {
TransactionType,
ReturnMultiData,
ReturnSingleData,
CallbackType,
AMBMessage,
BroadcastMessage
} from "src/types/DataTypes.sol";
import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
/// @title SuperPositions
/// @dev Cross-chain LP token minted on source chain
/// @author Zeropoint Labs
contract SuperPositions is ISuperPositions, ERC1155A, Broadcastable {
using DataLib for uint256;
//////////////////////////////////////////////////////////////
// CONSTANTS //
//////////////////////////////////////////////////////////////
ISuperRegistry public immutable superRegistry;
uint64 public immutable CHAIN_ID;
uint8 internal constant CORE_STATE_REGISTRY_ID = 1;
bytes32 internal constant DEPLOY_NEW_AERC20 = keccak256("DEPLOY_NEW_AERC20");
//////////////////////////////////////////////////////////////
// STATE VARIABLES //
//////////////////////////////////////////////////////////////
/// @dev maps all transaction data routed through the smart contract.
mapping(uint256 transactionId => TxHistory txHistory) public override txHistory;
/// @dev is the base uri set by admin
string public dynamicURI;
/// @dev is the base uri frozen status
bool public dynamicURIFrozen;
/// @dev nonce for aERC20 broadcast
uint256 public xChainPayloadCounter;
//////////////////////////////////////////////////////////////
// MODIFIERS //
//////////////////////////////////////////////////////////////
modifier onlyRouter() {
if (msg.sender != superRegistry.getAddress(keccak256("SUPERFORM_ROUTER"))) revert Error.NOT_SUPERFORM_ROUTER();
_;
}
modifier onlyProtocolAdmin() {
if (!ISuperRBAC(superRegistry.getAddress(keccak256("SUPER_RBAC"))).hasProtocolAdminRole(msg.sender)) {
revert Error.NOT_PROTOCOL_ADMIN();
}
_;
}
/// @dev is used in same chain case (as superform is available on the chain to validate caller)
modifier onlyMinter(uint256 superformId) {
address router = superRegistry.getAddress(keccak256("SUPERFORM_ROUTER"));
/// if msg.sender isn't superformRouter then it must be state registry of that form
if (msg.sender != router) {
uint8 registryId = superRegistry.getStateRegistryId(msg.sender);
(address superform,,) = DataLib.getSuperform(superformId);
uint8 formRegistryId = IBaseForm(superform).getStateRegistryId();
if (registryId != formRegistryId) {
revert Error.NOT_MINTER();
}
}
_;
}
modifier onlyBroadcastRegistry() {
if (msg.sender != superRegistry.getAddress(keccak256("BROADCAST_REGISTRY"))) {
revert Error.NOT_BROADCAST_REGISTRY();
}
_;
}
modifier onlyBatchMinter(uint256[] memory superformIds) {
address router = superRegistry.getAddress(keccak256("SUPERFORM_ROUTER"));
/// if msg.sender isn't superformRouter then it must be state registry for that superform
if (msg.sender != router) {
uint256 len = superformIds.length;
for (uint256 i; i < len; ++i) {
(, uint32 formImplementationId,) = DataLib.getSuperform(superformIds[i]);
uint8 registryId = superRegistry.getStateRegistryId(msg.sender);
if (uint32(registryId) != formImplementationId) {
revert Error.NOT_MINTER();
}
}
}
_;
}
//////////////////////////////////////////////////////////////
// CONSTRUCTOR //
//////////////////////////////////////////////////////////////
/// @param dynamicURI_ URL for external metadata of ERC1155 SuperPositions
/// @param superRegistry_ the superform registry contract
constructor(
string memory dynamicURI_,
address superRegistry_,
string memory name_,
string memory symbol_
)
ERC1155A(name_, symbol_)
{
if (block.chainid > type(uint64).max) {
revert Error.BLOCK_CHAIN_ID_OUT_OF_BOUNDS();
}
CHAIN_ID = uint64(block.chainid);
superRegistry = ISuperRegistry(superRegistry_);
dynamicURI = dynamicURI_;
}
//////////////////////////////////////////////////////////////
// EXTERNAL VIEW FUNCTIONS //
//////////////////////////////////////////////////////////////
/// @inheritdoc ERC1155A
function supportsInterface(bytes4 interfaceId_) public view virtual override(ERC1155A, IERC165) returns (bool) {
return super.supportsInterface(interfaceId_);
}
//////////////////////////////////////////////////////////////
// EXTERNAL WRITE FUNCTIONS //
//////////////////////////////////////////////////////////////
/// @inheritdoc ISuperPositions
function updateTxHistory(
uint256 payloadId_,
uint256 txInfo_,
address receiverAddressSP_
)
external
override
onlyRouter
{
txHistory[payloadId_] = TxHistory({ txInfo: txInfo_, receiverAddressSP: receiverAddressSP_ });
emit TxHistorySet(payloadId_, txInfo_, receiverAddressSP_);
}
/// @inheritdoc ISuperPositions
function mintSingle(address receiverAddressSP_, uint256 id_, uint256 amount_) external override onlyMinter(id_) {
_mint(receiverAddressSP_, msg.sender, id_, amount_, "");
}
/// @inheritdoc ISuperPositions
function mintBatch(
address receiverAddressSP_,
uint256[] memory ids_,
uint256[] memory amounts_
)
external
override
onlyBatchMinter(ids_)
{
if (ids_.length != amounts_.length) revert Error.ARRAY_LENGTH_MISMATCH();
_batchMint(receiverAddressSP_, msg.sender, ids_, amounts_, "");
}
/// @inheritdoc ISuperPositions
function burnSingle(address srcSender_, uint256 id_, uint256 amount_) external override onlyRouter {
_burn(srcSender_, msg.sender, id_, amount_);
}
/// @inheritdoc ISuperPositions
function burnBatch(
address srcSender_,
uint256[] memory ids_,
uint256[] memory amounts_
)
external
override
onlyRouter
{
if (ids_.length != amounts_.length) revert Error.ARRAY_LENGTH_MISMATCH();
_batchBurn(srcSender_, msg.sender, ids_, amounts_);
}
/// @inheritdoc ISuperPositions
function stateMultiSync(AMBMessage memory data_) external override returns (uint64 srcChainId_) {
/// @dev here we decode the txInfo and params from the data brought back from destination
(uint256 returnTxType, uint256 callbackType, uint8 multi,,,) = data_.txInfo.decodeTxInfo();
if (callbackType != uint256(CallbackType.RETURN) && callbackType != uint256(CallbackType.FAIL)) {
revert Error.INVALID_PAYLOAD_TYPE();
}
/// @dev decode remaining info on superPositions to mint from destination
ReturnMultiData memory returnData = abi.decode(data_.params, (ReturnMultiData));
_validateStateSyncer(returnData.superformIds);
uint256 txInfo = txHistory[returnData.payloadId].txInfo;
/// @dev if txInfo is zero then the payloadId is invalid for ack
if (txInfo == 0) {
revert Error.TX_HISTORY_NOT_FOUND();
}
uint256 txType;
/// @dev decode initial payload info stored on source chain in this contract
(txType,,,,, srcChainId_) = txInfo.decodeTxInfo();
/// @dev verify this is a not single vault mint
if (multi != 1) revert Error.INVALID_PAYLOAD_TYPE();
/// @dev compare txType to be the same (dst/src)
if (returnTxType != txType) revert Error.SRC_TX_TYPE_MISMATCH();
/// @dev mint super positions accordingly
if (
(txType == uint256(TransactionType.DEPOSIT) && callbackType == uint256(CallbackType.RETURN))
|| (txType == uint256(TransactionType.WITHDRAW) && callbackType == uint256(CallbackType.FAIL))
) {
_batchMint(
txHistory[returnData.payloadId].receiverAddressSP,
msg.sender,
returnData.superformIds,
returnData.amounts,
""
);
} else {
revert Error.INVALID_PAYLOAD_TYPE();
}
emit Completed(returnData.payloadId);
}
/// @inheritdoc ISuperPositions
function stateSync(AMBMessage memory data_) external override returns (uint64 srcChainId_) {
/// @dev here we decode the txInfo and params from the data brought back from destination
(uint256 returnTxType, uint256 callbackType, uint8 multi,,,) = data_.txInfo.decodeTxInfo();
if (callbackType != uint256(CallbackType.RETURN) && callbackType != uint256(CallbackType.FAIL)) {
revert Error.INVALID_PAYLOAD_TYPE();
}
/// @dev decode remaining info on superPositions to mint from destination
ReturnSingleData memory returnData = abi.decode(data_.params, (ReturnSingleData));
_validateStateSyncer(returnData.superformId);
uint256 txInfo = txHistory[returnData.payloadId].txInfo;
/// @dev if txInfo is zero then the payloadId is invalid for ack
if (txInfo == 0) {
revert Error.TX_HISTORY_NOT_FOUND();
}
uint256 txType;
/// @dev decode initial payload info stored on source chain in this contract
(txType,,,,, srcChainId_) = txInfo.decodeTxInfo();
/// @dev this is a not multi vault mint
if (multi != 0) revert Error.INVALID_PAYLOAD_TYPE();
/// @dev compare txType to be the same (dst/src)
if (returnTxType != txType) revert Error.SRC_TX_TYPE_MISMATCH();
/// @dev mint super positions accordingly
if (
(txType == uint256(TransactionType.DEPOSIT) && callbackType == uint256(CallbackType.RETURN))
|| (txType == uint256(TransactionType.WITHDRAW) && callbackType == uint256(CallbackType.FAIL))
) {
_mint(
txHistory[returnData.payloadId].receiverAddressSP,
msg.sender,
returnData.superformId,
returnData.amount,
""
);
} else {
revert Error.INVALID_PAYLOAD_TYPE();
}
emit Completed(returnData.payloadId);
}
/// @inheritdoc ISuperPositions
function stateSyncBroadcast(bytes memory data_) external payable override onlyBroadcastRegistry {
BroadcastMessage memory transmuterPayload = abi.decode(data_, (BroadcastMessage));
if (transmuterPayload.messageType != DEPLOY_NEW_AERC20) {
revert Error.INVALID_MESSAGE_TYPE();
}
_deployTransmuter(transmuterPayload.message);
}
/// @inheritdoc ISuperPositions
function setDynamicURI(string memory dynamicURI_, bool freeze_) external override onlyProtocolAdmin {
if (dynamicURIFrozen) {
revert Error.DYNAMIC_URI_FROZEN();
}
string memory oldURI = dynamicURI;
dynamicURI = dynamicURI_;
dynamicURIFrozen = freeze_;
emit DynamicURIUpdated(oldURI, dynamicURI_, freeze_);
}
//////////////////////////////////////////////////////////////
// INTERNAL FUNCTIONS //
//////////////////////////////////////////////////////////////
/// @notice Used to construct return url
function _baseURI() internal view override returns (string memory) {
return dynamicURI;
}
/// @dev helps validate the state registry id for minting superform id
/// @dev is used in cross chain case (as superform is not available on the chain to validate caller)
function _validateStateSyncer(uint256 superformId_) internal view {
uint8 registryId = superRegistry.getStateRegistryId(msg.sender);
_isValidStateSyncer(registryId, superformId_);
}
/// @dev helps validate the state registry id for minting superform id
function _validateStateSyncer(uint256[] memory superformIds_) internal view {
uint8 registryId = superRegistry.getStateRegistryId(msg.sender);
for (uint256 i; i < superformIds_.length; ++i) {
_isValidStateSyncer(registryId, superformIds_[i]);
}
}
function _isValidStateSyncer(uint8 registryId_, uint256 superformId_) internal view {
/// @dev registryId_ zero check is done in superRegistry.getStateRegistryId()
/// @dev If registryId is 1, meaning CoreStateRegistry, no further checks are necessary.
/// @dev This is because CoreStateRegistry is the default minter for all kinds of forms
/// @dev In case registryId is > 1, we need to check if the registryId matches the formImplementationId
if (registryId_ == CORE_STATE_REGISTRY_ID) {
return;
}
(, uint32 formImplementationId,) = DataLib.getSuperform(superformId_);
uint8 formRegistryId = ISuperformFactory(superRegistry.getAddress(keccak256("SUPERFORM_FACTORY")))
.getFormStateRegistryId(formImplementationId);
if (registryId_ != formRegistryId) {
revert Error.NOT_MINTER_STATE_REGISTRY_ROLE();
}
}
function _registerAERC20(uint256 id) internal override returns (address aErc20Token) {
if (!ISuperformFactory(superRegistry.getAddress(keccak256("SUPERFORM_FACTORY"))).isSuperform(id)) {
revert Error.SUPERFORM_ID_NONEXISTENT();
}
(address superform,,) = id.getSuperform();
string memory name = IBaseForm(superform).superformYieldTokenName();
string memory symbol = IBaseForm(superform).superformYieldTokenSymbol();
uint8 decimal = uint8(IBaseForm(superform).getVaultDecimals());
aErc20Token = address(new aERC20(name, symbol, decimal));
/// @dev broadcast and deploy to the other destination chains
BroadcastMessage memory transmuterPayload = BroadcastMessage(
"SUPER_POSITIONS",
DEPLOY_NEW_AERC20,
abi.encode(CHAIN_ID, ++xChainPayloadCounter, id, name, symbol, decimal)
);
_broadcast(
superRegistry.getAddress(keccak256("BROADCAST_REGISTRY")),
superRegistry.getAddress(keccak256("PAYMASTER")),
abi.encode(transmuterPayload),
IPaymentHelper(superRegistry.getAddress(keccak256("PAYMENT_HELPER"))).getRegisterTransmuterAMBData()
);
emit AERC20TokenRegistered(id, aErc20Token);
return aErc20Token;
}
/// @dev deploys new transmuter on broadcasting
function _deployTransmuter(bytes memory message_) internal {
(,, uint256 superformId, string memory name, string memory symbol, uint8 decimal) =
abi.decode(message_, (uint64, uint256, uint256, string, string, uint8));
if (aErc20TokenId[superformId] != address(0)) revert AERC20_ALREADY_REGISTERED();
address aErc20Token = address(new aERC20(name, symbol, decimal));
aErc20TokenId[superformId] = aErc20Token;
emit AERC20TokenRegistered(superformId, aErc20Token);
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.23;
library Error {
//////////////////////////////////////////////////////////////
// CONFIGURATION ERRORS //
//////////////////////////////////////////////////////////////
///@notice errors thrown in protocol setup
/// @dev thrown if chain id exceeds max(uint64)
error BLOCK_CHAIN_ID_OUT_OF_BOUNDS();
/// @dev thrown if not possible to revoke a role in broadcasting
error CANNOT_REVOKE_NON_BROADCASTABLE_ROLES();
/// @dev thrown if not possible to revoke last admin
error CANNOT_REVOKE_LAST_ADMIN();
/// @dev thrown if trying to set again pseudo immutables in super registry
error DISABLED();
/// @dev thrown if rescue delay is not yet set for a chain
error DELAY_NOT_SET();
/// @dev thrown if get native token price estimate in paymentHelper is 0
error INVALID_NATIVE_TOKEN_PRICE();
/// @dev thrown if wormhole refund chain id is not set
error REFUND_CHAIN_ID_NOT_SET();
/// @dev thrown if wormhole relayer is not set
error RELAYER_NOT_SET();
/// @dev thrown if a role to be revoked is not assigned
error ROLE_NOT_ASSIGNED();
//////////////////////////////////////////////////////////////
// AUTHORIZATION ERRORS //
//////////////////////////////////////////////////////////////
///@notice errors thrown if functions cannot be called
/// COMMON AUTHORIZATION ERRORS
/// ---------------------------------------------------------
/// @dev thrown if caller is not address(this), internal call
error INVALID_INTERNAL_CALL();
/// @dev thrown if msg.sender is not a valid amb implementation
error NOT_AMB_IMPLEMENTATION();
/// @dev thrown if msg.sender is not an allowed broadcaster
error NOT_ALLOWED_BROADCASTER();
/// @dev thrown if msg.sender is not broadcast amb implementation
error NOT_BROADCAST_AMB_IMPLEMENTATION();
/// @dev thrown if msg.sender is not broadcast state registry
error NOT_BROADCAST_REGISTRY();
/// @dev thrown if msg.sender is not core state registry
error NOT_CORE_STATE_REGISTRY();
/// @dev thrown if msg.sender is not emergency admin
error NOT_EMERGENCY_ADMIN();
/// @dev thrown if msg.sender is not emergency queue
error NOT_EMERGENCY_QUEUE();
/// @dev thrown if msg.sender is not minter
error NOT_MINTER();
/// @dev thrown if msg.sender is not minter state registry
error NOT_MINTER_STATE_REGISTRY_ROLE();
/// @dev thrown if msg.sender is not paymaster
error NOT_PAYMASTER();
/// @dev thrown if msg.sender is not payment admin
error NOT_PAYMENT_ADMIN();
/// @dev thrown if msg.sender is not protocol admin
error NOT_PROTOCOL_ADMIN();
/// @dev thrown if msg.sender is not state registry
error NOT_STATE_REGISTRY();
/// @dev thrown if msg.sender is not super registry
error NOT_SUPER_REGISTRY();
/// @dev thrown if msg.sender is not superform router
error NOT_SUPERFORM_ROUTER();
/// @dev thrown if msg.sender is not a superform
error NOT_SUPERFORM();
/// @dev thrown if msg.sender is not superform factory
error NOT_SUPERFORM_FACTORY();
/// @dev thrown if msg.sender is not timelock form
error NOT_TIMELOCK_SUPERFORM();
/// @dev thrown if msg.sender is not timelock state registry
error NOT_TIMELOCK_STATE_REGISTRY();
/// @dev thrown if msg.sender is not user or disputer
error NOT_VALID_DISPUTER();
/// @dev thrown if the msg.sender is not privileged caller
error NOT_PRIVILEGED_CALLER(bytes32 role);
/// STATE REGISTRY AUTHORIZATION ERRORS
/// ---------------------------------------------------------
/// @dev layerzero adapter specific error, thrown if caller not layerzero endpoint
error CALLER_NOT_ENDPOINT();
/// @dev hyperlane adapter specific error, thrown if caller not hyperlane mailbox
error CALLER_NOT_MAILBOX();
/// @dev wormhole relayer specific error, thrown if caller not wormhole relayer
error CALLER_NOT_RELAYER();
/// @dev thrown if src chain sender is not valid
error INVALID_SRC_SENDER();
//////////////////////////////////////////////////////////////
// INPUT VALIDATION ERRORS //
//////////////////////////////////////////////////////////////
///@notice errors thrown if input variables are not valid
/// COMMON INPUT VALIDATION ERRORS
/// ---------------------------------------------------------
/// @dev thrown if there is an array length mismatch
error ARRAY_LENGTH_MISMATCH();
/// @dev thrown if payload id does not exist
error INVALID_PAYLOAD_ID();
/// @dev error thrown when msg value should be zero in certain payable functions
error MSG_VALUE_NOT_ZERO();
/// @dev thrown if amb ids length is 0
error ZERO_AMB_ID_LENGTH();
/// @dev thrown if address input is address 0
error ZERO_ADDRESS();
/// @dev thrown if amount input is 0
error ZERO_AMOUNT();
/// @dev thrown if final token is address 0
error ZERO_FINAL_TOKEN();
/// @dev thrown if value input is 0
error ZERO_INPUT_VALUE();
/// SUPERFORM ROUTER INPUT VALIDATION ERRORS
/// ---------------------------------------------------------
/// @dev thrown if the vaults data is invalid
error INVALID_SUPERFORMS_DATA();
/// @dev thrown if receiver address is not set
error RECEIVER_ADDRESS_NOT_SET();
/// SUPERFORM FACTORY INPUT VALIDATION ERRORS
/// ---------------------------------------------------------
/// @dev thrown if a form is not ERC165 compatible
error ERC165_UNSUPPORTED();
/// @dev thrown if a form is not form interface compatible
error FORM_INTERFACE_UNSUPPORTED();
/// @dev error thrown if form implementation address already exists
error FORM_IMPLEMENTATION_ALREADY_EXISTS();
/// @dev error thrown if form implementation id already exists
error FORM_IMPLEMENTATION_ID_ALREADY_EXISTS();
/// @dev thrown if a form does not exist
error FORM_DOES_NOT_EXIST();
/// @dev thrown if form id is larger than max uint16
error INVALID_FORM_ID();
/// @dev thrown if superform not on factory
error SUPERFORM_ID_NONEXISTENT();
/// @dev thrown if same vault and form implementation is used to create new superform
error VAULT_FORM_IMPLEMENTATION_COMBINATION_EXISTS();
/// FORM INPUT VALIDATION ERRORS
/// ---------------------------------------------------------
/// @dev thrown if in case of no txData, if liqData.token != vault.asset()
/// in case of txData, if token output of swap != vault.asset()
error DIFFERENT_TOKENS();
/// @dev thrown if the amount in direct withdraw is not correct
error DIRECT_WITHDRAW_INVALID_LIQ_REQUEST();
/// @dev thrown if the amount in xchain withdraw is not correct
error XCHAIN_WITHDRAW_INVALID_LIQ_REQUEST();
/// LIQUIDITY BRIDGE INPUT VALIDATION ERRORS
/// ---------------------------------------------------------
/// @dev thrown if route id is blacklisted in socket
error BLACKLISTED_ROUTE_ID();
/// @dev thrown if route id is not blacklisted in socket
error NOT_BLACKLISTED_ROUTE_ID();
/// @dev error thrown when txData selector of lifi bridge is a blacklisted selector
error BLACKLISTED_SELECTOR();
/// @dev error thrown when txData selector of lifi bridge is not a blacklisted selector
error NOT_BLACKLISTED_SELECTOR();
/// @dev thrown if a certain action of the user is not allowed given the txData provided
error INVALID_ACTION();
/// @dev thrown if in deposits, the liqDstChainId doesn't match the stateReq dstChainId
error INVALID_DEPOSIT_LIQ_DST_CHAIN_ID();
/// @dev thrown if index is invalid
error INVALID_INDEX();
/// @dev thrown if the chain id in the txdata is invalid
error INVALID_TXDATA_CHAIN_ID();
/// @dev thrown if the validation of bridge txData fails due to a destination call present
error INVALID_TXDATA_NO_DESTINATIONCALL_ALLOWED();
/// @dev thrown if the validation of bridge txData fails due to wrong receiver
error INVALID_TXDATA_RECEIVER();
/// @dev thrown if the validation of bridge txData fails due to wrong token
error INVALID_TXDATA_TOKEN();
/// @dev thrown if txData is not present (in case of xChain actions)
error NO_TXDATA_PRESENT();
/// STATE REGISTRY INPUT VALIDATION ERRORS
/// ---------------------------------------------------------
/// @dev thrown if payload is being updated with final amounts length different than amounts length
error DIFFERENT_PAYLOAD_UPDATE_AMOUNTS_LENGTH();
/// @dev thrown if payload is being updated with tx data length different than liq data length
error DIFFERENT_PAYLOAD_UPDATE_TX_DATA_LENGTH();
/// @dev thrown if keeper update final token is different than the vault underlying
error INVALID_UPDATE_FINAL_TOKEN();
/// @dev thrown if broadcast finality for wormhole is invalid
error INVALID_BROADCAST_FINALITY();
/// @dev thrown if amb id is not valid leading to an address 0 of the implementation
error INVALID_BRIDGE_ID();
/// @dev thrown if chain id involved in xchain message is invalid
error INVALID_CHAIN_ID();
/// @dev thrown if payload update amount isn't equal to dst swapper amount
error INVALID_DST_SWAP_AMOUNT();
/// @dev thrown if message amb and proof amb are the same
error INVALID_PROOF_BRIDGE_ID();
/// @dev thrown if order of proof AMBs is incorrect, either duplicated or not incrementing
error INVALID_PROOF_BRIDGE_IDS();
/// @dev thrown if rescue data lengths are invalid
error INVALID_RESCUE_DATA();
/// @dev thrown if delay is invalid
error INVALID_TIMELOCK_DELAY();
/// @dev thrown if amounts being sent in update payload mean a negative slippage
error NEGATIVE_SLIPPAGE();
/// @dev thrown if slippage is outside of bounds
error SLIPPAGE_OUT_OF_BOUNDS();
/// SUPERPOSITION INPUT VALIDATION ERRORS
/// ---------------------------------------------------------
/// @dev thrown if src senders mismatch in state sync
error SRC_SENDER_MISMATCH();
/// @dev thrown if src tx types mismatch in state sync
error SRC_TX_TYPE_MISMATCH();
//////////////////////////////////////////////////////////////
// EXECUTION ERRORS //
//////////////////////////////////////////////////////////////
///@notice errors thrown due to function execution logic
/// COMMON EXECUTION ERRORS
/// ---------------------------------------------------------
/// @dev thrown if the swap in a direct deposit resulted in insufficient tokens
error DIRECT_DEPOSIT_SWAP_FAILED();
/// @dev thrown if payload is not unique
error DUPLICATE_PAYLOAD();
/// @dev thrown if native tokens fail to be sent to superform contracts
error FAILED_TO_SEND_NATIVE();
/// @dev thrown if allowance is not correct to deposit
error INSUFFICIENT_ALLOWANCE_FOR_DEPOSIT();
/// @dev thrown if contract has insufficient balance for operations
error INSUFFICIENT_BALANCE();
/// @dev thrown if native amount is not at least equal to the amount in the request
error INSUFFICIENT_NATIVE_AMOUNT();
/// @dev thrown if payload cannot be decoded
error INVALID_PAYLOAD();
/// @dev thrown if payload status is invalid
error INVALID_PAYLOAD_STATUS();
/// @dev thrown if payload type is invalid
error INVALID_PAYLOAD_TYPE();
/// LIQUIDITY BRIDGE EXECUTION ERRORS
/// ---------------------------------------------------------
/// @dev thrown if we try to decode the final swap output token in a xChain liquidity bridging action
error CANNOT_DECODE_FINAL_SWAP_OUTPUT_TOKEN();
/// @dev thrown if liquidity bridge fails for erc20 or native tokens
error FAILED_TO_EXECUTE_TXDATA(address token);
/// @dev thrown if asset being used for deposit mismatches in multivault deposits
error INVALID_DEPOSIT_TOKEN();
/// STATE REGISTRY EXECUTION ERRORS
/// ---------------------------------------------------------
/// @dev thrown if bridge tokens haven't arrived to destination
error BRIDGE_TOKENS_PENDING();
/// @dev thrown if withdrawal tx data cannot be updated
error CANNOT_UPDATE_WITHDRAW_TX_DATA();
/// @dev thrown if rescue passed dispute deadline
error DISPUTE_TIME_ELAPSED();
/// @dev thrown if message failed to reach the specified level of quorum needed
error INSUFFICIENT_QUORUM();
/// @dev thrown if broadcast payload is invalid
error INVALID_BROADCAST_PAYLOAD();
/// @dev thrown if broadcast fee is invalid
error INVALID_BROADCAST_FEE();
/// @dev thrown if retry fees is less than required
error INVALID_RETRY_FEE();
/// @dev thrown if broadcast message type is wrong
error INVALID_MESSAGE_TYPE();
/// @dev thrown if payload hash is invalid during `retryMessage` on Layezero implementation
error INVALID_PAYLOAD_HASH();
/// @dev thrown if update payload function was called on a wrong payload
error INVALID_PAYLOAD_UPDATE_REQUEST();
/// @dev thrown if a state registry id is 0
error INVALID_REGISTRY_ID();
/// @dev thrown if a form state registry id is 0
error INVALID_FORM_REGISTRY_ID();
/// @dev thrown if trying to finalize the payload but the withdraw is still locked
error LOCKED();
/// @dev thrown if payload is already updated (during xChain deposits)
error PAYLOAD_ALREADY_UPDATED();
/// @dev thrown if payload is already processed
error PAYLOAD_ALREADY_PROCESSED();
/// @dev thrown if payload is not in UPDATED state
error PAYLOAD_NOT_UPDATED();
/// @dev thrown if rescue is still in timelocked state
error RESCUE_LOCKED();
/// @dev thrown if rescue is already proposed
error RESCUE_ALREADY_PROPOSED();
/// @dev thrown if payload hash is zero during `retryMessage` on Layezero implementation
error ZERO_PAYLOAD_HASH();
/// DST SWAPPER EXECUTION ERRORS
/// ---------------------------------------------------------
/// @dev thrown if process dst swap is tried for processed payload id
error DST_SWAP_ALREADY_PROCESSED();
/// @dev thrown if indices have duplicates
error DUPLICATE_INDEX();
/// @dev thrown if failed dst swap is already updated
error FAILED_DST_SWAP_ALREADY_UPDATED();
/// @dev thrown if indices are out of bounds
error INDEX_OUT_OF_BOUNDS();
/// @dev thrown if failed swap token amount is 0
error INVALID_DST_SWAPPER_FAILED_SWAP();
/// @dev thrown if failed swap token amount is not 0 and if token balance is less than amount (non zero)
error INVALID_DST_SWAPPER_FAILED_SWAP_NO_TOKEN_BALANCE();
/// @dev thrown if failed swap token amount is not 0 and if native amount is less than amount (non zero)
error INVALID_DST_SWAPPER_FAILED_SWAP_NO_NATIVE_BALANCE();
/// @dev forbid xChain deposits with destination swaps without interim token set (for user protection)
error INVALID_INTERIM_TOKEN();
/// @dev thrown if dst swap output is less than minimum expected
error INVALID_SWAP_OUTPUT();
/// FORM EXECUTION ERRORS
/// ---------------------------------------------------------
/// @dev thrown if try to forward 4626 share from the superform
error CANNOT_FORWARD_4646_TOKEN();
/// @dev thrown in KYCDAO form if no KYC token is present
error NO_VALID_KYC_TOKEN();
/// @dev thrown in forms where a certain functionality is not allowed or implemented
error NOT_IMPLEMENTED();
/// @dev thrown if form implementation is PAUSED, users cannot perform any action
error PAUSED();
/// @dev thrown if shares != deposit output or assets != redeem output when minting SuperPositions
error VAULT_IMPLEMENTATION_FAILED();
/// @dev thrown if withdrawal tx data is not updated
error WITHDRAW_TOKEN_NOT_UPDATED();
/// @dev thrown if withdrawal tx data is not updated
error WITHDRAW_TX_DATA_NOT_UPDATED();
/// @dev thrown when redeeming from vault yields zero collateral
error WITHDRAW_ZERO_COLLATERAL();
/// PAYMENT HELPER EXECUTION ERRORS
/// ---------------------------------------------------------
/// @dev thrown if chainlink is reporting an improper price
error CHAINLINK_MALFUNCTION();
/// @dev thrown if chainlink is reporting an incomplete round
error CHAINLINK_INCOMPLETE_ROUND();
/// @dev thrown if feed decimals is not 8
error CHAINLINK_UNSUPPORTED_DECIMAL();
/// EMERGENCY QUEUE EXECUTION ERRORS
/// ---------------------------------------------------------
/// @dev thrown if emergency withdraw is not queued
error EMERGENCY_WITHDRAW_NOT_QUEUED();
/// @dev thrown if emergency withdraw is already processed
error EMERGENCY_WITHDRAW_PROCESSED_ALREADY();
/// SUPERPOSITION EXECUTION ERRORS
/// ---------------------------------------------------------
/// @dev thrown if uri cannot be updated
error DYNAMIC_URI_FROZEN();
/// @dev thrown if tx history is not found while state sync
error TX_HISTORY_NOT_FOUND();
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.23;
/// @dev contains all the common struct and enums used for data communication between chains.
/// @dev There are two transaction types in Superform Protocol
enum TransactionType {
DEPOSIT,
WITHDRAW
}
/// @dev Message types can be INIT, RETURN (for successful Deposits) and FAIL (for failed withdraws)
enum CallbackType {
INIT,
RETURN,
FAIL
}
/// @dev Payloads are stored, updated (deposits) or processed (finalized)
enum PayloadState {
STORED,
UPDATED,
PROCESSED
}
/// @dev contains all the common struct used for interchain token transfers.
struct LiqRequest {
/// @dev generated data
bytes txData;
/// @dev input token for deposits, desired output token on target liqDstChainId for withdraws. Must be set for
/// txData to be updated on destination for withdraws
address token;
/// @dev intermediary token on destination. Relevant for xChain deposits where a destination swap is needed for
/// validation purposes
address interimToken;
/// @dev what bridge to use to move tokens
uint8 bridgeId;
/// @dev dstChainId = liqDstchainId for deposits. For withdraws it is the target chain id for where the underlying
/// is to be delivered
uint64 liqDstChainId;
/// @dev currently this amount is used as msg.value in the txData call.
uint256 nativeAmount;
}
/// @dev main struct that holds required multi vault data for an action
struct MultiVaultSFData {
// superformids must have same destination. Can have different underlyings
uint256[] superformIds;
uint256[] amounts; // on deposits, amount of token to deposit on dst, on withdrawals, superpositions to burn
uint256[] outputAmounts; // on deposits, amount of shares to receive, on withdrawals, amount of assets to receive
uint256[] maxSlippages;
LiqRequest[] liqRequests; // if length = 1; amount = sum(amounts) | else amounts must match the amounts being sent
bytes permit2data;
bool[] hasDstSwaps;
bool[] retain4626s; // if true, we don't mint SuperPositions, and send the 4626 back to the user instead
address receiverAddress;
/// this address must always be an EOA otherwise funds may be lost
address receiverAddressSP;
/// this address can be a EOA or a contract that implements onERC1155Receiver. must always be set for deposits
bytes extraFormData; // extraFormData
}
/// @dev main struct that holds required single vault data for an action
struct SingleVaultSFData {
// superformids must have same destination. Can have different underlyings
uint256 superformId;
uint256 amount;
uint256 outputAmount; // on deposits, amount of shares to receive, on withdrawals, amount of assets to receive
uint256 maxSlippage;
LiqRequest liqRequest; // if length = 1; amount = sum(amounts)| else amounts must match the amounts being sent
bytes permit2data;
bool hasDstSwap;
bool retain4626; // if true, we don't mint SuperPositions, and send the 4626 back to the user instead
address receiverAddress;
/// this address must always be an EOA otherwise funds may be lost
address receiverAddressSP;
/// this address can be a EOA or a contract that implements onERC1155Receiver. must always be set for deposits
bytes extraFormData; // extraFormData
}
/// @dev overarching struct for multiDst requests with multi vaults
struct MultiDstMultiVaultStateReq {
uint8[][] ambIds;
uint64[] dstChainIds;
MultiVaultSFData[] superformsData;
}
/// @dev overarching struct for single cross chain requests with multi vaults
struct SingleXChainMultiVaultStateReq {
uint8[] ambIds;
uint64 dstChainId;
MultiVaultSFData superformsData;
}
/// @dev overarching struct for multiDst requests with single vaults
struct MultiDstSingleVaultStateReq {
uint8[][] ambIds;
uint64[] dstChainIds;
SingleVaultSFData[] superformsData;
}
/// @dev overarching struct for single cross chain requests with single vaults
struct SingleXChainSingleVaultStateReq {
uint8[] ambIds;
uint64 dstChainId;
SingleVaultSFData superformData;
}
/// @dev overarching struct for single direct chain requests with single vaults
struct SingleDirectSingleVaultStateReq {
SingleVaultSFData superformData;
}
/// @dev overarching struct for single direct chain requests with multi vaults
struct SingleDirectMultiVaultStateReq {
MultiVaultSFData superformData;
}
/// @dev struct for SuperRouter with re-arranged data for the message (contains the payloadId)
/// @dev realize that receiverAddressSP is not passed, only needed on source chain to mint
struct InitMultiVaultData {
uint256 payloadId;
uint256[] superformIds;
uint256[] amounts;
uint256[] outputAmounts;
uint256[] maxSlippages;
LiqRequest[] liqData;
bool[] hasDstSwaps;
bool[] retain4626s;
address receiverAddress;
bytes extraFormData;
}
/// @dev struct for SuperRouter with re-arranged data for the message (contains the payloadId)
struct InitSingleVaultData {
uint256 payloadId;
uint256 superformId;
uint256 amount;
uint256 outputAmount;
uint256 maxSlippage;
LiqRequest liqData;
bool hasDstSwap;
bool retain4626;
address receiverAddress;
bytes extraFormData;
}
/// @dev struct for Emergency Queue
struct QueuedWithdrawal {
address receiverAddress;
uint256 superformId;
uint256 amount;
uint256 srcPayloadId;
bool isProcessed;
}
/// @dev all statuses of the timelock payload
enum TimelockStatus {
UNAVAILABLE,
PENDING,
PROCESSED
}
/// @dev holds information about the timelock payload
struct TimelockPayload {
uint8 isXChain;
uint64 srcChainId;
uint256 lockedTill;
InitSingleVaultData data;
TimelockStatus status;
}
/// @dev struct that contains the type of transaction, callback flags and other identification, as well as the vaults
/// data in params
struct AMBMessage {
uint256 txInfo; // tight packing of TransactionType txType, CallbackType flag if multi/single vault, registry id,
// srcSender and srcChainId
bytes params; // decoding txInfo will point to the right datatype of params. Refer PayloadHelper.sol
}
/// @dev struct that contains the information required for broadcasting changes
struct BroadcastMessage {
bytes target;
bytes32 messageType;
bytes message;
}
/// @dev struct that contains info on returned data from destination
struct ReturnMultiData {
uint256 payloadId;
uint256[] superformIds;
uint256[] amounts;
}
/// @dev struct that contains info on returned data from destination
struct ReturnSingleData {
uint256 payloadId;
uint256 superformId;
uint256 amount;
}
/// @dev struct that contains the data on the fees to pay to the AMBs
struct AMBExtraData {
uint256[] gasPerAMB;
bytes[] extraDataPerAMB;
}
/// @dev struct that contains the data on the fees to pay to the AMBs on broadcasts
struct BroadCastAMBExtraData {
uint256[] gasPerDst;
bytes[] extraDataPerDst;
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.23;
import { Address } from "openzeppelin-contracts/contracts/utils/Address.sol";
import { IERC1155Receiver } from "openzeppelin-contracts/contracts/token/ERC1155/IERC1155Receiver.sol";
import { IERC165 } from "openzeppelin-contracts/contracts/utils/introspection/IERC165.sol";
import { IERC20 } from "openzeppelin-contracts/contracts/interfaces/IERC20.sol";
import { SafeERC20 } from "openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol";
import { ISuperRBAC } from "src/interfaces/ISuperRBAC.sol";
import { ISuperRegistry } from "src/interfaces/ISuperRegistry.sol";
import { IBaseSuperformRouterPlus } from "src/interfaces/IBaseSuperformRouterPlus.sol";
import { IBaseRouter } from "src/interfaces/IBaseRouter.sol";
import { Error } from "src/libraries/Error.sol";
import {
SingleDirectSingleVaultStateReq,
SingleDirectMultiVaultStateReq,
SingleXChainSingleVaultStateReq,
SingleXChainMultiVaultStateReq,
MultiDstMultiVaultStateReq,
MultiDstSingleVaultStateReq
} from "src/types/DataTypes.sol";
abstract contract BaseSuperformRouterPlus is IBaseSuperformRouterPlus, IERC1155Receiver {
using SafeERC20 for IERC20;
//////////////////////////////////////////////////////////////
// CONSTANTS //
//////////////////////////////////////////////////////////////
ISuperRegistry public immutable superRegistry;
uint64 public immutable CHAIN_ID;
uint256 internal constant ENTIRE_SLIPPAGE = 10_000;
//////////////////////////////////////////////////////////////
// STATE VARIABLES //
//////////////////////////////////////////////////////////////
mapping(Actions => mapping(bytes4 selector => bool whitelisted)) public whitelistedSelectors;
//////////////////////////////////////////////////////////////
// CONSTRUCTOR //
//////////////////////////////////////////////////////////////
constructor(address superRegistry_) {
if (superRegistry_ == address(0)) {
revert Error.ZERO_ADDRESS();
}
if (block.chainid > type(uint64).max) {
revert Error.BLOCK_CHAIN_ID_OUT_OF_BOUNDS();
}
CHAIN_ID = uint64(block.chainid);
superRegistry = ISuperRegistry(superRegistry_);
whitelistedSelectors[Actions.REBALANCE_FROM_SINGLE][IBaseRouter.singleDirectSingleVaultWithdraw.selector] = true;
whitelistedSelectors[Actions.REBALANCE_FROM_MULTI][IBaseRouter.singleDirectMultiVaultWithdraw.selector] = true;
whitelistedSelectors[Actions.REBALANCE_X_CHAIN_FROM_SINGLE][IBaseRouter.singleXChainSingleVaultWithdraw.selector]
= true;
whitelistedSelectors[Actions.REBALANCE_X_CHAIN_FROM_MULTI][IBaseRouter.singleXChainMultiVaultWithdraw.selector]
= true;
whitelistedSelectors[Actions.REBALANCE_X_CHAIN_FROM_MULTI][IBaseRouter.multiDstSingleVaultWithdraw.selector] =
true;
whitelistedSelectors[Actions.REBALANCE_X_CHAIN_FROM_MULTI][IBaseRouter.multiDstMultiVaultWithdraw.selector] =
true;
whitelistedSelectors[Actions.DEPOSIT][IBaseRouter.singleDirectSingleVaultDeposit.selector] = true;
whitelistedSelectors[Actions.DEPOSIT][IBaseRouter.singleXChainSingleVaultDeposit.selector] = true;
whitelistedSelectors[Actions.DEPOSIT][IBaseRouter.singleDirectMultiVaultDeposit.selector] = true;
whitelistedSelectors[Actions.DEPOSIT][IBaseRouter.singleXChainMultiVaultDeposit.selector] = true;
whitelistedSelectors[Actions.DEPOSIT][IBaseRouter.multiDstSingleVaultDeposit.selector] = true;
whitelistedSelectors[Actions.DEPOSIT][IBaseRouter.multiDstMultiVaultDeposit.selector] = true;
}
//////////////////////////////////////////////////////////////
// EXTERNAL PURE FUNCTIONS //
//////////////////////////////////////////////////////////////
/// @dev overrides receive functions
function onERC1155Received(
address,
address,
uint256,
uint256,
bytes calldata
)
external
pure
override
returns (bytes4)
{
return this.onERC1155Received.selector;
}
function onERC1155BatchReceived(
address,
address,
uint256[] calldata,
uint256[] calldata,
bytes calldata
)
external
pure
override
returns (bytes4)
{
return this.onERC1155BatchReceived.selector;
}
function supportsInterface(bytes4 interfaceId) external pure override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
//////////////////////////////////////////////////////////////
// INTERNAL FUNCTIONS //
//////////////////////////////////////////////////////////////
function _callSuperformRouter(address router_, bytes memory callData_, uint256 msgValue_) internal {
(bool success, bytes memory returndata) = router_.call{ value: msgValue_ }(callData_);
Address.verifyCallResult(success, returndata);
}
function _deposit(
address router_,
IERC20 asset_,
uint256 amountToDeposit_,
uint256 msgValue_,
bytes memory callData_
)
internal
{
/// @dev approves superform router on demand
asset_.forceApprove(router_, amountToDeposit_);
/// @notice this is used in all actions. In cross chain rebalances, most key data is validated, but not on
/// @notice same chain rebalances or deposits
_callSuperformRouter(router_, callData_, msgValue_);
}
/// @dev returns the address from super registry
function _getAddress(bytes32 id_) internal view returns (address) {
return superRegistry.getAddress(id_);
}
/// @dev returns if an address has a specific role
/// @param id_ the role id
/// @param addressToCheck_ the address to check
/// @return true if the address has the role, false otherwise
function _hasRole(bytes32 id_, address addressToCheck_) internal view returns (bool) {
return ISuperRBAC(superRegistry.getAddress(keccak256("SUPER_RBAC"))).hasRole(id_, addressToCheck_);
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.23;
import "src/types/DataTypes.sol";
/// @title IBaseRouter
/// @dev Interface for abstract BaseRouter
/// @author Zeropoint Labs
interface IBaseRouter {
//////////////////////////////////////////////////////////////
// EXTERNAL WRITE FUNCTIONS //
//////////////////////////////////////////////////////////////
/// @dev Performs single direct x single vault deposits
/// @param req_ is the request object containing all the necessary data for the action
function singleDirectSingleVaultDeposit(SingleDirectSingleVaultStateReq memory req_) external payable;
/// @dev Performs single xchain destination x single vault deposits
/// @param req_ is the request object containing all the necessary data for the action
function singleXChainSingleVaultDeposit(SingleXChainSingleVaultStateReq memory req_) external payable;
/// @dev Performs single direct x multi vault deposits
/// @param req_ is the request object containing all the necessary data for the action
function singleDirectMultiVaultDeposit(SingleDirectMultiVaultStateReq memory req_) external payable;
/// @dev Performs single destination x multi vault deposits
/// @param req_ is the request object containing all the necessary data for the action
function singleXChainMultiVaultDeposit(SingleXChainMultiVaultStateReq memory req_) external payable;
/// @dev Performs multi destination x single vault deposits
/// @param req_ is the request object containing all the necessary data for the action
function multiDstSingleVaultDeposit(MultiDstSingleVaultStateReq calldata req_) external payable;
/// @dev Performs multi destination x multi vault deposits
/// @param req_ is the request object containing all the necessary data for the action
function multiDstMultiVaultDeposit(MultiDstMultiVaultStateReq calldata req_) external payable;
/// @dev Performs single direct x single vault withdraws
/// @param req_ is the request object containing all the necessary data for the action
function singleDirectSingleVaultWithdraw(SingleDirectSingleVaultStateReq memory req_) external payable;
/// @dev Performs single xchain destination x single vault withdraws
/// @param req_ is the request object containing all the necessary data for the action
function singleXChainSingleVaultWithdraw(SingleXChainSingleVaultStateReq memory req_) external payable;
/// @dev Performs single direct x multi vault withdraws
/// @param req_ is the request object containing all the necessary data for the action
function singleDirectMultiVaultWithdraw(SingleDirectMultiVaultStateReq memory req_) external payable;
/// @dev Performs single destination x multi vault withdraws
/// @param req_ is the request object containing all the necessary data for the action
function singleXChainMultiVaultWithdraw(SingleXChainMultiVaultStateReq memory req_) external payable;
/// @dev Performs multi destination x single vault withdraws
/// @param req_ is the request object containing all the necessary data for the action
function multiDstSingleVaultWithdraw(MultiDstSingleVaultStateReq calldata req_) external payable;
/// @dev Performs multi destination x multi vault withdraws
/// @param req_ is the request object containing all the necessary data for the action
function multiDstMultiVaultWithdraw(MultiDstMultiVaultStateReq calldata req_) external payable;
/// @dev Forwards dust to Paymaster
/// @param token_ the token to forward
function forwardDustToPaymaster(address token_) external;
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.23;
import { IBaseSuperformRouterPlus } from "./IBaseSuperformRouterPlus.sol";
import { IERC20 } from "openzeppelin-contracts/contracts/interfaces/IERC20.sol";
interface ISuperformRouterPlus is IBaseSuperformRouterPlus {
//////////////////////////////////////////////////////////////
// ERRORS //
//////////////////////////////////////////////////////////////
/// @notice thrown when an invalid rebalance from selector is provided
error INVALID_REBALANCE_FROM_SELECTOR();
/// @notice thrown when an invalid deposit selector provided
error INVALID_DEPOSIT_SELECTOR();
/// @notice thrown if the interimToken is different than expected
error REBALANCE_SINGLE_POSITIONS_DIFFERENT_TOKEN();
/// @notice thrown if the liqDstChainId is different than expected
error REBALANCE_SINGLE_POSITIONS_DIFFERENT_CHAIN();
/// @notice thrown if the amounts to redeem differ
error REBALANCE_SINGLE_POSITIONS_DIFFERENT_AMOUNT();
/// @notice thrown if the receiver address is invalid (not the router plus)
error REBALANCE_SINGLE_POSITIONS_UNEXPECTED_RECEIVER_ADDRESS();
/// @notice thrown if the interimToken is different than expected in the array
error REBALANCE_MULTI_POSITIONS_DIFFERENT_TOKEN();
/// @notice thrown if the liqDstChainId is different than expected in the array
error REBALANCE_MULTI_POSITIONS_DIFFERENT_CHAIN();
/// @notice thrown if the amounts to redeem differ
error REBALANCE_MULTI_POSITIONS_DIFFERENT_AMOUNTS();
/// @notice thrown if the receiver address is invalid (not the router plus)
error REBALANCE_MULTI_POSITIONS_UNEXPECTED_RECEIVER_ADDRESS();
/// @notice thrown if the receiver address is invalid (not the router plus)
error REBALANCE_XCHAIN_INVALID_RECEIVER_ADDRESS();
/// @notice thrown if msg.value is lower than the required fee
error INVALID_FEE();
/// @notice thrown if the amount of assets received is lower than the slippage
error ASSETS_RECEIVED_OUT_OF_SLIPPAGE();
/// @notice thrown if the slippage is invalid
error INVALID_GLOBAL_SLIPPAGE();
/// @notice thrown if the tolerance is exceeded during shares redemption
error TOLERANCE_EXCEEDED();
/// @notice thrown if the amountIn is not equal or lower than the balance available
error AMOUNT_IN_NOT_EQUAL_OR_LOWER_THAN_BALANCE();
//////////////////////////////////////////////////////////////
// EVENTS //
//////////////////////////////////////////////////////////////
/// @notice emitted when a single position rebalance is completed
/// @param receiver The address receiving the rebalanced position
/// @param id The ID of the rebalanced position
/// @param amount The amount of tokens rebalanced
event RebalanceSyncCompleted(address indexed receiver, uint256 indexed id, uint256 amount);
/// @notice emitted when multiple positions are rebalanced
/// @param receiver The address receiving the rebalanced positions
/// @param ids The IDs of the rebalanced positions
/// @param amounts The amounts of tokens rebalanced for each position
event RebalanceMultiSyncCompleted(address indexed receiver, uint256[] ids, uint256[] amounts);
/// @notice emitted when a cross-chain rebalance is initiated
/// @param receiver The address receiving the rebalanced position
/// @param routerPlusPayloadId The router plus payload Id
/// @param id The ID of the position being rebalanced
/// @param amount The amount of tokens being rebalanced
/// @param interimAsset The address of the interim asset used in the cross-chain transfer
/// @param finalizeSlippage The slippage tolerance for the finalization step
/// @param expectedAmountInterimAsset The expected amount of interim asset to be received
/// @param rebalanceToSelector The selector for the rebalance to function
event XChainRebalanceInitiated(
address indexed receiver,
uint256 indexed routerPlusPayloadId,
uint256 id,
uint256 amount,
address interimAsset,
uint256 finalizeSlippage,
uint256 expectedAmountInterimAsset,
bytes4 rebalanceToSelector
);
/// @notice emitted when multiple cross-chain rebalances are initiated
/// @param receiver The address receiving the rebalanced positions
/// @param routerPlusPayloadId The router plus payload Id
/// @param ids The IDs of the positions being rebalanced
/// @param amounts The amounts of tokens being rebalanced for each position
/// @param interimAsset The address of the interim asset used in the cross-chain transfer
/// @param finalizeSlippage The slippage tolerance for the finalization step
/// @param expectedAmountInterimAsset The expected amount of interim asset to be received
/// @param rebalanceToSelector The selector for the rebalance to function
event XChainRebalanceMultiInitiated(
address indexed receiver,
uint256 indexed routerPlusPayloadId,
uint256[] ids,
uint256[] amounts,
address interimAsset,
uint256 finalizeSlippage,
uint256 expectedAmountInterimAsset,
bytes4 rebalanceToSelector
);
/// @notice emitted when a deposit from an ERC4626 vault is completed
/// @param receiver The address receiving the deposited tokens
/// @param vault The address of the ERC4626 vault
event Deposit4626Completed(address indexed receiver, address indexed vault);
/// @notice emitted when dust is forwarded to the paymaster
/// @param token The address of the token
/// @param amount The amount of tokens forwarded
event RouterPlusDustForwardedToPaymaster(address indexed token, uint256 amount);
//////////////////////////////////////////////////////////////
// STRUCTS //
//////////////////////////////////////////////////////////////
struct RebalanceSinglePositionSyncArgs {
uint256 id;
uint256 sharesToRedeem;
uint256 expectedAmountToReceivePostRebalanceFrom;
uint256 rebalanceFromMsgValue;
uint256 rebalanceToMsgValue;
address interimAsset;
uint256 slippage;
address receiverAddressSP;
bytes callData;
bytes rebalanceToCallData;
}
struct RebalanceMultiPositionsSyncArgs {
uint256[] ids;
uint256[] sharesToRedeem;
uint256 expectedAmountToReceivePostRebalanceFrom;
uint256 rebalanceFromMsgValue;
uint256 rebalanceToMsgValue;
address interimAsset;
uint256 slippage;
address receiverAddressSP;
bytes callData;
bytes rebalanceToCallData;
}
struct RebalancePositionsSyncArgs {
Actions action;
uint256[] sharesToRedeem;
uint256 expectedAmountToReceivePostRebalanceFrom;
address interimAsset;
uint256 slippage;
uint256 rebalanceFromMsgValue;
uint256 rebalanceToMsgValue;
address receiverAddressSP;
uint256 balanceBefore;
}
struct InitiateXChainRebalanceArgs {
uint256 id;
uint256 sharesToRedeem;
address receiverAddressSP;
address interimAsset;
uint256 finalizeSlippage;
uint256 expectedAmountInterimAsset;
bytes4 rebalanceToSelector;
bytes callData;
uint8[][] rebalanceToAmbIds;
uint64[] rebalanceToDstChainIds;
bytes rebalanceToSfData;
}
struct InitiateXChainRebalanceMultiArgs {
uint256[] ids;
uint256[] sharesToRedeem;
address receiverAddressSP;
address interimAsset;
uint256 finalizeSlippage;
uint256 expectedAmountInterimAsset;
bytes4 rebalanceToSelector;
bytes callData;
uint8[][] rebalanceToAmbIds;
uint64[] rebalanceToDstChainIds;
bytes rebalanceToSfData;
}
struct Deposit4626Args {
uint256 amount;
uint256 expectedOutputAmount;
uint256 maxSlippage;
address receiverAddressSP;
bytes depositCallData;
}
//////////////////////////////////////////////////////////////
// EXTERNAL WRITE FUNCTIONS //
//////////////////////////////////////////////////////////////
/// @notice rebalances a single SuperPosition synchronously
/// @notice interim asset and receiverAddressSP must be set. In non smart contract wallet rebalances,
/// receiverAddressSP is only used for refunds
/// @param args The arguments for rebalancing single positions
function rebalanceSinglePosition(RebalanceSinglePositionSyncArgs calldata args) external payable;
/// @notice rebalances multiple SuperPositions synchronously
/// @notice interim asset and receiverAddressSP must be set. In non smart contract wallet rebalances,
/// receiverAddressSP is only used for refunds
/// @notice receiverAddressSP of rebalanceCallData must be the address of the router plus for smart wallets
/// @notice for normal deposits receiverAddressSP is the users' specified receiverAddressSP
/// @param args The arguments for rebalancing multiple positions
function rebalanceMultiPositions(RebalanceMultiPositionsSyncArgs calldata args) external payable;
/// @notice initiates the rebalance process for a position on a different chain
/// @param args The arguments for initiating cross-chain rebalance for single positions
function startCrossChainRebalance(InitiateXChainRebalanceArgs calldata args) external payable;
/// @notice initiates the rebalance process for multiple positions on different chains
/// @param args The arguments for initiating cross-chain rebalance for multiple positions
function startCrossChainRebalanceMulti(InitiateXChainRebalanceMultiArgs memory args) external payable;
/// @notice deposits ERC4626 vault shares into superform
/// @param vaults_ The ERC4626 vaults to redeem from
/// @param args Rest of the arguments to deposit 4626
function deposit4626(address[] calldata vaults_, Deposit4626Args[] calldata args) external payable;
/// @dev Forwards dust to Paymaster
/// @param token_ the token to forward
function forwardDustToPaymaster(address token_) external;
/// @dev only callable by Emergency Admin
/// @notice sets the global slippage for all rebalances
/// @param slippage_ The slippage tolerance for same chain rebalances
function setGlobalSlippage(uint256 slippage_) external;
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.23;
import { LiqRequest } from "src/types/DataTypes.sol";
import { IBaseSuperformRouterPlus } from "./IBaseSuperformRouterPlus.sol";
import { IERC20 } from "openzeppelin-contracts/contracts/interfaces/IERC20.sol";
interface ISuperformRouterPlusAsync is IBaseSuperformRouterPlus {
//////////////////////////////////////////////////////////////
// ERRORS //
//////////////////////////////////////////////////////////////
/// @notice thrown if the XChainRebalanceData is already set
error ALREADY_SET();
/// @notice thrown when a non-processor attempts to call a processor-only function
error NOT_ROUTER_PLUS_PROCESSOR();
/// @notice thrown if the caller is not router plus
error NOT_ROUTER_PLUS();
/// @notice thrown if the caller is not core state registry rescuer
error NOT_CORE_STATE_REGISTRY_RESCUER();
/// @notice thrown if the rebalance to update is invalid
error COMPLETE_REBALANCE_INVALID_TX_DATA_UPDATE();
/// @notice thrown if the rebalance to update is invalid
error COMPLETE_REBALANCE_DIFFERENT_TOKEN();
/// @notice thrown if the rebalance to update is invalid
error COMPLETE_REBALANCE_DIFFERENT_BRIDGE_ID();
/// @notice thrown if the rebalance to update is invalid
error COMPLETE_REBALANCE_DIFFERENT_CHAIN();
/// @notice thrown if the rebalance to update is invalid
error COMPLETE_REBALANCE_DIFFERENT_RECEIVER();
/// @notice thrown if the rebalance to update is invalid
error COMPLETE_REBALANCE_AMOUNT_OUT_OF_SLIPPAGE(uint256 newAmount, uint256 expectedAmount, uint256 userSlippage);
/// @notice thrown if the rebalance to update is invalid
error COMPLETE_REBALANCE_OUTPUTAMOUNT_OUT_OF_SLIPPAGE(
uint256 newOutputAmount, uint256 expectedOutputAmount, uint256 userSlippage
);
/// @notice thrown if the refund is already requested
error REFUND_ALREADY_REQUESTED();
/// @notice thrown to avoid processing the same rebalance payload twice
error REBALANCE_ALREADY_PROCESSED();
/// @notice thrown when the refund requester is not the payload receiver
error INVALID_REQUESTER();
/// @notice thrown when the refund payload is invalid
error INVALID_REFUND_DATA();
/// @notice thrown when requested refund amount is too high
error REQUESTED_AMOUNT_TOO_HIGH();
//////////////////////////////////////////////////////////////
// EVENTS //
//////////////////////////////////////////////////////////////
/// @notice emitted when a cross-chain rebalance is completed
/// @param receiver The address receiving the rebalanced position
/// @param routerPlusPayloadId The router plus payload id of the rebalance
event XChainRebalanceComplete(address indexed receiver, uint256 indexed routerPlusPayloadId);
/// @notice emitted when a new refund is created
/// @param routerPlusPayloadId is the unique identifier for the payload
/// @param refundReceiver is the address of the user who'll receiver the refund
/// @param refundToken is the token to be refunded
/// @param refundAmount is the new refund amount
event RefundInitiated(
uint256 indexed routerPlusPayloadId, address indexed refundReceiver, address refundToken, uint256 refundAmount
);
/// @notice emitted when a refund is proposed
/// @param routerPlusPayloadId is the unique identifier for the payload
/// @param refundReceiver is the address of the user who'll receiver the refund
/// @param refundToken is the token to be refunded
/// @param refundAmount is the new refund amount
event refundRequested(
uint256 indexed routerPlusPayloadId, address indexed refundReceiver, address refundToken, uint256 refundAmount
);
/// @notice emitted when an existing refund got disputed
/// @param routerPlusPayloadId is the unique identifier for the payload
/// @param disputer is the address of the user who disputed the refund
event RefundDisputed(uint256 indexed routerPlusPayloadId, address indexed disputer);
/// @notice emitted when a new refund amount is proposed
/// @param routerPlusPayloadId is the unique identifier for the payload
/// @param newRefundAmount is the new refund amount proposed
event NewRefundAmountProposed(uint256 indexed routerPlusPayloadId, uint256 indexed newRefundAmount);
/// @notice emitted when a refund is complete
/// @param routerPlusPayloadId is the unique identifier for the payload
/// @param caller is the address of the user who called the function
event RefundCompleted(uint256 indexed routerPlusPayloadId, address indexed caller);
//////////////////////////////////////////////////////////////
// STRUCTS //
//////////////////////////////////////////////////////////////
struct Refund {
address receiver;
address interimToken;
uint256 amount;
}
struct DecodedRouterPlusRebalanceCallData {
address interimAsset;
bytes4 rebalanceSelector;
uint256 userSlippage;
address[] receiverAddress;
uint256[][] superformIds;
uint256[][] amounts;
uint256[][] outputAmounts;
uint8[][] ambIds;
uint64[] dstChainIds;
}
struct CompleteCrossChainRebalanceArgs {
address receiverAddressSP;
uint256 routerPlusPayloadId;
uint256 amountReceivedInterimAsset;
uint256[][] newAmounts;
uint256[][] newOutputAmounts;
LiqRequest[][] liqRequests;
}
struct CompleteCrossChainRebalanceLocalVars {
uint256 balanceOfInterim;
IERC20 interimAsset;
bytes rebalanceToCallData;
uint8[][] rebalanceToDstAmbIds;
uint64[] rebalanceToDstChainIds;
}
//////////////////////////////////////////////////////////////
// EXTERNAL VIEW FUNCTIONS //
//////////////////////////////////////////////////////////////
/// @notice returns the decoded call data for a cross-chain rebalance
/// @param receiverAddressSP_ The address of the receiver
/// @param routerPlusPayloadId_ The router plus payload id
/// @return D The DecodedRouterPlusRebalanceCallData struct
function decodeXChainRebalanceCallData(
address receiverAddressSP_,
uint256 routerPlusPayloadId_
)
external
view
returns (DecodedRouterPlusRebalanceCallData memory D);
//////////////////////////////////////////////////////////////
// EXTERNAL WRITE FUNCTIONS //
//////////////////////////////////////////////////////////////
/// @dev only callable by router plus
/// @param receiverAddressSP_ The address of the receiver
/// @param routerPlusPayloadId_ The router plus payload id
/// @param data_ The XChainRebalanceData struct
function setXChainRebalanceCallData(
address receiverAddressSP_,
uint256 routerPlusPayloadId_,
XChainRebalanceData memory data_
)
external;
/// @notice completes the rebalance process for positions on different chains
/// @param args_ The arguments of the rebalance
/// @return rebalanceSuccessful Whether the rebalance was successful
function completeCrossChainRebalance(CompleteCrossChainRebalanceArgs memory args_)
external
payable
returns (bool rebalanceSuccessful);
/// @notice allows the user to request a refund for the rebalance
/// @param routerplusPayloadId_ the router plus payload id
function requestRefund(uint256 routerplusPayloadId_, uint256 requestedAmount) external;
/// @dev only callable by core state registry rescuer
/// @notice approves a refund for the rebalance and sends funds to the receiver
/// @param routerplusPayloadId_ the router plus payload id
function approveRefund(uint256 routerplusPayloadId_) external;
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.23;
/// @title Bridge Validator Interface
/// @dev Interface all Bridge Validators must follow
/// @author Zeropoint Labs
interface IBridgeValidator {
//////////////////////////////////////////////////////////////
// STRUCTS //
//////////////////////////////////////////////////////////////
struct ValidateTxDataArgs {
bytes txData;
uint64 srcChainId;
uint64 dstChainId;
uint64 liqDstChainId;
bool deposit;
address superform;
address receiverAddress;
address liqDataToken;
address liqDataInterimToken;
}
//////////////////////////////////////////////////////////////
// EXTERNAL VIEW FUNCTIONS //
//////////////////////////////////////////////////////////////
/// @dev validates the receiver of the liquidity request
/// @param txData_ is the txData of the cross chain deposit
/// @param receiver_ is the address of the receiver to validate
/// @return valid_ if the address is valid
function validateReceiver(bytes calldata txData_, address receiver_) external view returns (bool valid_);
/// @dev validates the txData of a cross chain deposit
/// @param args_ the txData arguments to validate in txData
/// @return hasDstSwap if the txData contains a destination swap
function validateTxData(ValidateTxDataArgs calldata args_) external view returns (bool hasDstSwap);
/// @dev decodes the txData and returns the amount of input token on source
/// @param txData_ is the txData of the cross chain deposit
/// @param genericSwapDisallowed_ true if generic swaps are disallowed
/// @return amount_ the amount expected
function decodeAmountIn(
bytes calldata txData_,
bool genericSwapDisallowed_
)
external
view
returns (uint256 amount_);
/// @dev decodes neccesary information for processing swaps on the destination chain
/// @param txData_ is the txData to be decoded
/// @return token_ is the address of the token
/// @return amount_ the amount expected
function decodeDstSwap(bytes calldata txData_) external pure returns (address token_, uint256 amount_);
/// @dev decodes the final output token address (for only direct chain actions!)
/// @param txData_ is the txData to be decoded
/// @return token_ the address of the token
function decodeSwapOutputToken(bytes calldata txData_) external pure returns (address token_);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[ERC-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC-20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*
* CAUTION: See Security Considerations above.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error AddressInsufficientBalance(address account);
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedInnerCall();
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert AddressInsufficientBalance(address(this));
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert FailedInnerCall();
}
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {FailedInnerCall} error.
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert AddressInsufficientBalance(address(this));
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
* unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {FailedInnerCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
*/
function _revert(bytes memory returndata) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert FailedInnerCall();
}
}
}// 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 ERC-20 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);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;
import { IERC1155A } from "./interfaces/IERC1155A.sol";
import { IaERC20 } from "./interfaces/IaERC20.sol";
import { Strings } from "openzeppelin-contracts/contracts/utils/Strings.sol";
import { IERC165 } from "openzeppelin-contracts/contracts/interfaces/IERC165.sol";
import { IERC1155 } from "openzeppelin-contracts/contracts/interfaces/IERC1155.sol";
import { IERC1155MetadataURI } from "openzeppelin-contracts/contracts/interfaces/IERC1155MetadataURI.sol";
import { IERC1155Errors } from "openzeppelin-contracts/contracts/interfaces/draft-IERC6093.sol";
import { IERC1155Receiver } from "openzeppelin-contracts/contracts/token/ERC1155/IERC1155Receiver.sol";
/// @title ERC1155A
/// @dev Single/range based id approve capability with conversion to ERC20s
/// @author Zeropoint Labs
abstract contract ERC1155A is IERC1155A, IERC1155Errors {
//////////////////////////////////////////////////////////////
// CONSTANTS //
//////////////////////////////////////////////////////////////
bytes private constant EMPTY_BYTES = bytes("");
//////////////////////////////////////////////////////////////
// STATE VARIABLES //
//////////////////////////////////////////////////////////////
/// @dev ERC20-like mapping for single id supply.
mapping(uint256 => uint256) private _totalSupply;
/// @dev ERC20-like mapping for single id approvals.
mapping(address owner => mapping(address operator => mapping(uint256 id => uint256 amount))) private allowances;
/// @dev Implementation copied from solmate/ERC1155
mapping(address => mapping(uint256 => uint256)) public balanceOf;
/// @dev Implementation copied from solmate/ERC1155
mapping(address => mapping(address => bool)) public isApprovedForAll;
/// @dev mapping of token ids to aErc20 token addresses
mapping(uint256 id => address aErc20Token) public aErc20TokenId;
/// @dev ERC1155A name
string public name;
/// @dev ERC1155A symbol
string public symbol;
//////////////////////////////////////////////////////////////
// CONSTRUCTOR //
//////////////////////////////////////////////////////////////
/// @dev Initializes ERC1155A
/// @param name_ ERC1155A name
/// @param symbol_ ERC1155A symbol
constructor(string memory name_, string memory symbol_) {
name = name_;
symbol = symbol_;
}
//////////////////////////////////////////////////////////////
// EXTERNAL VIEW FUNCTIONS //
//////////////////////////////////////////////////////////////
// Basic Token Information
// --------------------------
/// @inheritdoc IERC1155A
function totalSupply(uint256 id) external view virtual returns (uint256) {
return _totalSupply[id];
}
/// @inheritdoc IERC1155A
function exists(uint256 id) external view virtual returns (bool) {
return _totalSupply[id] != 0;
}
/// @inheritdoc IERC1155
function balanceOfBatch(
address[] memory owners,
uint256[] memory ids
)
public
view
virtual
returns (uint256[] memory balances)
{
if (owners.length != ids.length) revert LENGTH_MISMATCH();
balances = new uint256[](owners.length);
for (uint256 i; i < owners.length; ++i) {
balances[i] = balanceOf[owners[i]][ids[i]];
}
}
// Allowance and Approval Checking
// --------------------------------
/// @inheritdoc IERC1155A
function allowance(address owner, address operator, uint256 id) public view virtual returns (uint256) {
return allowances[owner][operator][id];
}
// aERC20 Token Management
// ------------------------
/// @inheritdoc IERC1155A
function aERC20Exists(uint256 id) external view virtual returns (bool) {
return aErc20TokenId[id] != address(0);
}
/// @inheritdoc IERC1155A
function getERC20TokenAddress(uint256 id) external view virtual override returns (address) {
return aErc20TokenId[id];
}
// Metadata and Interface Support
// ------------------------------
/// @inheritdoc IERC1155A
function uri(uint256 id) public view virtual returns (string memory) {
return string.concat(_baseURI(), Strings.toString(id));
}
/// @dev return interface checks
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId // ERC165 Interface ID for ERC165
|| interfaceId == type(IERC1155).interfaceId // ERC165 Interface ID for ERC1155
|| interfaceId == type(IERC1155MetadataURI).interfaceId; // ERC165 Interface ID for ERC1155MetadataURI
}
//////////////////////////////////////////////////////////////
// EXTERNAL WRITE FUNCTIONS //
//////////////////////////////////////////////////////////////
// Token Approval Management
// --------------------------
/// @inheritdoc IERC1155A
function setApprovalForOne(address operator, uint256 id, uint256 amount) public virtual {
_setAllowance(msg.sender, operator, id, amount, true);
}
/// @inheritdoc IERC1155A
function setApprovalForMany(address operator, uint256[] memory ids, uint256[] memory amounts) public virtual {
uint256 idsLength = ids.length;
if (idsLength != amounts.length) revert LENGTH_MISMATCH();
for (uint256 i; i < idsLength; ++i) {
_setAllowance(msg.sender, operator, ids[i], amounts[i], true);
}
}
/// @inheritdoc IERC1155
function setApprovalForAll(address operator, bool approved) public virtual {
if (operator == address(0)) revert ZERO_ADDRESS();
isApprovedForAll[msg.sender][operator] = approved;
emit ApprovalForAll(msg.sender, operator, approved);
}
// Allowance Modification
// -----------------------
/// @inheritdoc IERC1155A
function increaseAllowance(address operator, uint256 id, uint256 addedValue) public virtual returns (bool) {
_setAllowance(msg.sender, operator, id, allowance(msg.sender, operator, id) + addedValue, true);
return true;
}
/// @inheritdoc IERC1155A
function decreaseAllowance(address operator, uint256 id, uint256 subtractedValue) public virtual returns (bool) {
return _decreaseAllowance(msg.sender, operator, id, subtractedValue, true);
}
/// @inheritdoc IERC1155A
function increaseAllowanceForMany(
address operator,
uint256[] memory ids,
uint256[] memory addedValues
)
public
virtual
returns (bool)
{
uint256 idsLength = ids.length;
if (idsLength != addedValues.length) revert LENGTH_MISMATCH();
for (uint256 i; i < idsLength; ++i) {
_setAllowance(msg.sender, operator, ids[i], allowance(msg.sender, operator, ids[i]) + addedValues[i], true);
}
return true;
}
/// @inheritdoc IERC1155A
function decreaseAllowanceForMany(
address operator,
uint256[] memory ids,
uint256[] memory subtractedValues
)
public
virtual
returns (bool)
{
uint256 idsLength = ids.length;
if (idsLength != subtractedValues.length) revert LENGTH_MISMATCH();
for (uint256 i; i < idsLength; ++i) {
_decreaseAllowance(msg.sender, operator, ids[i], subtractedValues[i], true);
}
return true;
}
// Token Transfer Functions
// -------------------------
/// @notice see {IERC1155-safeTransferFrom}
/// @dev adds supports for user to not have called setApprovalForAll
/// @dev single id approval is senior in execution flow
/// @dev if approved for all, function executes without reducing allowance
function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
)
public
virtual
override
{
if (from == address(0) || to == address(0)) revert ZERO_ADDRESS();
address operator = msg.sender;
/// @dev message sender is not from and is not approved for all
if (from != operator && !isApprovedForAll[from][operator]) {
_decreaseAllowance(from, operator, id, amount, false);
_safeTransferFrom(from, to, id, amount);
} else {
/// @dev message sender is from || is approved for all
_safeTransferFrom(from, to, id, amount);
}
emit TransferSingle(operator, from, to, id, amount);
_doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);
}
/// @notice see {IERC1155-safeBatchTransferFrom}
/// @dev adds supports for user to not have called setApprovalForAll
/// @dev single id approvals are senior in execution flow
/// @dev if approved for all, function executes without reducing allowance
function safeBatchTransferFrom(
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
)
public
virtual
override
{
if (from == address(0) || to == address(0)) revert ZERO_ADDRESS();
uint256 len = ids.length;
if (len != amounts.length) revert LENGTH_MISMATCH();
address operator = msg.sender;
/// @dev case to handle single id / multi id approvals
if (operator != from && !isApprovedForAll[from][operator]) {
uint256 id;
uint256 amount;
for (uint256 i; i < len; ++i) {
id = ids[i];
amount = amounts[i];
_decreaseAllowance(from, operator, id, amount, false);
_safeTransferFrom(from, to, id, amount);
}
} else {
for (uint256 i; i < len; ++i) {
_safeTransferFrom(from, to, ids[i], amounts[i]);
}
}
emit TransferBatch(operator, from, to, ids, amounts);
_doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data);
}
// Token Transmutation
// --------------------
/// @inheritdoc IERC1155A
function transmuteToERC20(address owner, uint256 id, uint256 amount, address receiver) external override {
if (owner == address(0) || receiver == address(0)) revert ZERO_ADDRESS();
/// @dev an approval is needed to burn
_burn(owner, msg.sender, id, amount);
address aERC20Token = aErc20TokenId[id];
if (aERC20Token == address(0)) revert AERC20_NOT_REGISTERED();
IaERC20(aERC20Token).mint(receiver, amount);
emit TransmutedToERC20(owner, id, amount, receiver);
}
/// @inheritdoc IERC1155A
function transmuteToERC1155A(address owner, uint256 id, uint256 amount, address receiver) external override {
if (owner == address(0) || receiver == address(0)) revert ZERO_ADDRESS();
address aERC20Token = aErc20TokenId[id];
if (aERC20Token == address(0)) revert AERC20_NOT_REGISTERED();
/// @dev an approval is needed to burn
IaERC20(aERC20Token).burn(owner, msg.sender, amount);
_mint(receiver, msg.sender, id, amount, EMPTY_BYTES);
emit TransmutedToERC1155A(owner, id, amount, receiver);
}
/// @inheritdoc IERC1155A
function transmuteBatchToERC20(
address owner,
uint256[] memory ids,
uint256[] memory amounts,
address receiver
)
external
override
{
if (owner == address(0) || receiver == address(0)) revert ZERO_ADDRESS();
uint256 idsLength = ids.length; // Saves MLOADs.
if (idsLength != amounts.length) revert LENGTH_MISMATCH();
/// @dev an approval is needed to burn
_batchBurn(owner, msg.sender, ids, amounts);
for (uint256 i; i < idsLength; ++i) {
address aERC20Token = aErc20TokenId[ids[i]];
if (aERC20Token == address(0)) revert AERC20_NOT_REGISTERED();
IaERC20(aERC20Token).mint(receiver, amounts[i]);
}
emit TransmutedBatchToERC20(owner, ids, amounts, receiver);
}
/// @inheritdoc IERC1155A
function transmuteBatchToERC1155A(
address owner,
uint256[] memory ids,
uint256[] memory amounts,
address receiver
)
external
override
{
if (owner == address(0) || receiver == address(0)) revert ZERO_ADDRESS();
uint256 idsLength = ids.length; // Saves MLOADs.
if (idsLength != amounts.length) revert LENGTH_MISMATCH();
uint256 id;
uint256 amount;
for (uint256 i; i < ids.length; ++i) {
id = ids[i];
amount = amounts[i];
address aERC20Token = aErc20TokenId[id];
if (aERC20Token == address(0)) revert AERC20_NOT_REGISTERED();
/// @dev an approval is needed on each aERC20 to burn
IaERC20(aERC20Token).burn(owner, msg.sender, amount);
}
_batchMint(receiver, msg.sender, ids, amounts, EMPTY_BYTES);
emit TransmutedBatchToERC1155A(owner, ids, amounts, receiver);
}
// aERC20 Registration
// --------------------
/// @inheritdoc IERC1155A
function registerAERC20(uint256 id) external payable override returns (address) {
if (_totalSupply[id] == 0) revert ID_NOT_MINTED_YET();
if (aErc20TokenId[id] != address(0)) revert AERC20_ALREADY_REGISTERED();
address aErc20Token = _registerAERC20(id);
aErc20TokenId[id] = aErc20Token;
return aErc20TokenId[id];
}
//////////////////////////////////////////////////////////////
// INTERNAL FUNCTIONS //
//////////////////////////////////////////////////////////////
// Token Transfer and Balance Management
// --------------------------------------
/// @notice Internal safeTranferFrom function called after all checks from the public function are done
/// @dev Notice `operator` param. It's msg.sender to the safeTransferFrom function. Function is specific to
/// @dev singleId approve logic.
function _safeTransferFrom(address from, address to, uint256 id, uint256 amount) internal virtual {
balanceOf[from][id] -= amount;
balanceOf[to][id] += amount;
}
/// @dev Implementation copied from solmate/ERC1155 and adapted with operator logic
function _mint(address to, address operator, uint256 id, uint256 amount, bytes memory data) internal virtual {
balanceOf[to][id] += amount;
_totalSupply[id] += amount;
emit TransferSingle(operator, address(0), to, id, amount);
_doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data);
}
/// @dev Implementation copied from solmate/ERC1155 and adapted with operator logic
function _batchMint(
address to,
address operator,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
)
internal
virtual
{
uint256 idsLength = ids.length; // Saves MLOADs.
if (idsLength != amounts.length) revert LENGTH_MISMATCH();
uint256 id;
uint256 amount;
for (uint256 i; i < idsLength; ++i) {
id = ids[i];
amount = amounts[i];
balanceOf[to][id] += amount;
_totalSupply[id] += amount;
}
emit TransferBatch(operator, address(0), to, ids, amounts);
_doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data);
}
/// @dev Implementation copied from solmate/ERC1155 and adapted with operator logic
function _burn(address from, address operator, uint256 id, uint256 amount) internal virtual {
// Check if the msg.sender is the owner or is approved for all tokens
/// Most implementations of _burn don't use allowance, but it is a good practice to check for it
/// Otherwise it could allow to burn tokens on which no explicit allowance is given
if (operator != from && !isApprovedForAll[from][operator]) {
_decreaseAllowance(from, operator, id, amount, false);
}
// Update the balances and total supply
_safeTransferFrom(from, address(0), id, amount);
_totalSupply[id] -= amount;
emit TransferSingle(operator, from, address(0), id, amount);
}
/// @dev Implementation copied from solmate/ERC1155 and adapted with operator logic
function _batchBurn(
address from,
address operator,
uint256[] memory ids,
uint256[] memory amounts
)
internal
virtual
{
uint256 idsLength = ids.length; // Saves MLOADs.
if (idsLength != amounts.length) revert LENGTH_MISMATCH();
uint256 id;
uint256 amount;
/// @dev case to handle single id / multi id approvals
if (operator != from && !isApprovedForAll[from][operator]) {
for (uint256 i; i < idsLength; ++i) {
id = ids[i];
amount = amounts[i];
_decreaseAllowance(from, operator, id, amount, false);
_safeTransferFrom(from, address(0), id, amount);
_totalSupply[ids[i]] -= amounts[i];
}
} else {
for (uint256 i; i < idsLength; ++i) {
id = ids[i];
amount = amounts[i];
_safeTransferFrom(from, address(0), id, amount);
_totalSupply[ids[i]] -= amounts[i];
}
}
emit TransferBatch(operator, from, address(0), ids, amounts);
}
// Allowance and Approval Handling
// --------------------------------
/// @notice Internal function for decreasing single id approval amount
/// @dev Only to be used by address(this)
/// @dev Notice `owner` param, only contract functions should be able to define it
/// @dev Re-adapted from ERC20
function _decreaseAllowance(
address owner,
address operator,
uint256 id,
uint256 subtractedValue,
bool emitEvent
)
internal
virtual
returns (bool)
{
uint256 currentAllowance = allowance(owner, operator, id);
if (currentAllowance < subtractedValue) revert DECREASED_ALLOWANCE_BELOW_ZERO();
_setAllowance(owner, operator, id, currentAllowance - subtractedValue, emitEvent);
return true;
}
/// @notice Internal function for setting single id approval
/// @dev Used for fine-grained control over approvals with increase/decrease allowance
/// @dev Notice `owner` param, only contract functions should be able to define it
function _setAllowance(
address owner,
address operator,
uint256 id,
uint256 amount,
bool emitEvent
)
internal
virtual
{
if (owner == address(0)) revert ZERO_ADDRESS();
if (operator == address(0)) revert ZERO_ADDRESS();
allowances[owner][operator][id] = amount;
if (emitEvent) {
emit ApprovalForOne(owner, operator, id, amount);
}
}
// ERC1155A Transfer Checks
// ------------------------
/// @dev Implementation copied from openzeppelin-contracts/ERC1155 with new custom error logic
function _doSafeTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256 id,
uint256 value,
bytes memory data
)
private
{
if (to.code.length != 0) {
try IERC1155Receiver(to).onERC1155Received(operator, from, id, value, data) returns (bytes4 response) {
if (response != IERC1155Receiver.onERC1155Received.selector) {
// Tokens rejected
revert ERC1155InvalidReceiver(to);
}
} catch (bytes memory reason) {
if (reason.length == 0) {
// non-ERC1155Receiver implementer
revert ERC1155InvalidReceiver(to);
} else {
/// @solidity memory-safe-assembly
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
if (to == address(0)) revert TRANSFER_TO_ADDRESS_ZERO();
}
}
/// @dev Implementation copied from openzeppelin-contracts/ERC1155 with new custom error logic and revert on
/// transfer to address 0
function _doSafeBatchTransferAcceptanceCheck(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory values,
bytes memory data
)
private
{
if (to.code.length != 0) {
try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, values, data) returns (bytes4 response)
{
if (response != IERC1155Receiver.onERC1155BatchReceived.selector) {
// Tokens rejected
revert ERC1155InvalidReceiver(to);
}
} catch (bytes memory reason) {
if (reason.length == 0) {
// non-ERC1155Receiver implementer
revert ERC1155InvalidReceiver(to);
} else {
/// @solidity memory-safe-assembly
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
if (to == address(0)) revert TRANSFER_TO_ADDRESS_ZERO();
}
}
// aERC20 Token Creation
// ----------------------
/// @dev allows a developer to integrate their logic to create an aERC20
function _registerAERC20(uint256 id) internal virtual returns (address aErc20Token);
// Metadata and URI Handling
// --------------------------
/// @dev Used to construct return url
function _baseURI() internal view virtual returns (string memory);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;
import { IaERC20 } from "./interfaces/IaERC20.sol";
import { ERC20 } from "openzeppelin-contracts/contracts/token/ERC20/ERC20.sol";
/// @title aERC20
/// @dev ERC20 tokens out of 1155A
/// @author Zeropoint Labs
contract aERC20 is ERC20, IaERC20 {
//////////////////////////////////////////////////////////////
// CONSTANTS //
//////////////////////////////////////////////////////////////
address public immutable ERC1155A;
uint8 private immutable TOKEN_DECIMALS;
//////////////////////////////////////////////////////////////
// MODIFIERS //
//////////////////////////////////////////////////////////////
modifier onlyTokenTransmuter() {
if (msg.sender != ERC1155A) {
revert ONLY_ERC1155A();
}
_;
}
//////////////////////////////////////////////////////////////
// CONSTRUCTOR //
//////////////////////////////////////////////////////////////
constructor(string memory name_, string memory symbol_, uint8 decimals_) ERC20(name_, symbol_) {
ERC1155A = msg.sender;
TOKEN_DECIMALS = decimals_;
}
//////////////////////////////////////////////////////////////
// EXTERNAL VIEW FUNCTIONS //
//////////////////////////////////////////////////////////////
/// inheritdoc IaERC20
function decimals() public view override returns (uint8) {
return TOKEN_DECIMALS;
}
//////////////////////////////////////////////////////////////
// EXTERNAL WRITE FUNCTIONS //
//////////////////////////////////////////////////////////////
/// inheritdoc IaERC20
function mint(address owner, uint256 amount) external override onlyTokenTransmuter {
_mint(owner, amount);
}
/// inheritdoc IaERC20
function burn(address owner, address operator, uint256 amount) external override onlyTokenTransmuter {
if (owner != operator) _spendAllowance(owner, operator, amount);
_burn(owner, amount);
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.23;
import { IBroadcastRegistry } from "src/interfaces/IBroadcastRegistry.sol";
import { Error } from "src/libraries/Error.sol";
/// @title Broadcastable
/// @dev Can be inherited in contracts that wish to support broadcasting
/// @author ZeroPoint Labs
abstract contract Broadcastable {
//////////////////////////////////////////////////////////////
// INTERNAL FUNCTIONS //
//////////////////////////////////////////////////////////////
/// @dev broadcasts state changes to all connected remote chains
/// @param broadcastRegistry_ is the address of the broadcast registry contract.
/// @param payMaster_ is the address of the paymaster contract.
/// @param message_ is the crosschain message to be sent.
/// @param extraData_ is the amb override information.
function _broadcast(
address broadcastRegistry_,
address payMaster_,
bytes memory message_,
bytes memory extraData_
)
internal
{
(uint8 ambId, bytes memory broadcastParams) = abi.decode(extraData_, (uint8, bytes));
/// @dev if the broadcastParams are wrong this will revert
(uint256 gasFee, bytes memory extraData) = abi.decode(broadcastParams, (uint256, bytes));
if (msg.value < gasFee) {
revert Error.INVALID_BROADCAST_FEE();
}
/// @dev ambIds are validated inside the broadcast state registry
IBroadcastRegistry(broadcastRegistry_).broadcastPayload{ value: gasFee }(
msg.sender, ambId, gasFee, message_, extraData
);
if (msg.value > gasFee) {
/// @dev forwards the rest to paymaster
(bool success,) = payable(payMaster_).call{ value: msg.value - gasFee }("");
if (!success) {
revert Error.FAILED_TO_SEND_NATIVE();
}
}
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.23;
import { IERC1155A } from "ERC1155A/interfaces/IERC1155A.sol";
import { AMBMessage } from "../types/DataTypes.sol";
/// @title ISuperPositions
/// @dev Interface for SuperPositions
/// @author Zeropoint Labs
interface ISuperPositions is IERC1155A {
//////////////////////////////////////////////////////////////
// STRUCTS //
//////////////////////////////////////////////////////////////
struct TxHistory {
uint256 txInfo;
address receiverAddressSP;
}
//////////////////////////////////////////////////////////////
// EVENTS //
//////////////////////////////////////////////////////////////
/// @dev is emitted when a dynamic uri is updated
event DynamicURIUpdated(string indexed oldURI, string indexed newURI, bool indexed frozen);
/// @dev is emitted when a cross-chain transaction is completed.
event Completed(uint256 indexed txId);
/// @dev is emitted when a aErc20 token is registered
event AERC20TokenRegistered(uint256 indexed tokenId, address indexed tokenAddress);
/// @dev is emitted when a tx info is saved
event TxHistorySet(uint256 indexed payloadId, uint256 txInfo, address indexed receiverAddress);
//////////////////////////////////////////////////////////////
// EXTERNAL VIEW FUNCTIONS //
//////////////////////////////////////////////////////////////
/// @dev returns the payload header and the receiver address for a tx id on the source chain
/// @param txId_ is the identifier of the transaction issued by superform router
/// @return txInfo is the header of the payload
/// @return receiverAddressSP is the address of the receiver of superPositions
function txHistory(uint256 txId_) external view returns (uint256 txInfo, address receiverAddressSP);
//////////////////////////////////////////////////////////////
// EXTERNAL WRITE FUNCTIONS //
//////////////////////////////////////////////////////////////
/// @dev saves the message being sent together with the associated id formulated in a router
/// @param payloadId_ is the id of the message being saved
/// @param txInfo_ is the header of the AMBMessage of the transaction being saved
/// @param receiverAddressSP_ is the address of the receiver of superPositions
function updateTxHistory(uint256 payloadId_, uint256 txInfo_, address receiverAddressSP_) external;
/// @dev allows minter to mint shares on source
/// @param receiverAddress_ is the beneficiary of shares
/// @param id_ is the id of the shares
/// @param amount_ is the amount of shares to mint
function mintSingle(address receiverAddress_, uint256 id_, uint256 amount_) external;
/// @dev allows minter to mint shares on source in batch
/// @param receiverAddress_ is the beneficiary of shares
/// @param ids_ are the ids of the shares
/// @param amounts_ are the amounts of shares to mint
function mintBatch(address receiverAddress_, uint256[] memory ids_, uint256[] memory amounts_) external;
/// @dev allows superformRouter to burn shares on source
/// @notice burn is done optimistically by the router in the beginning of the withdraw transactions
/// @notice in case the withdraw tx fails on the destination, shares are reminted through stateSync
/// @param srcSender_ is the address of the sender
/// @param id_ is the id of the shares
/// @param amount_ is the amount of shares to burn
function burnSingle(address srcSender_, uint256 id_, uint256 amount_) external;
/// @dev allows burner to burn shares on source in batch
/// @param srcSender_ is the address of the sender
/// @param ids_ are the ids of the shares
/// @param amounts_ are the amounts of shares to burn
function burnBatch(address srcSender_, uint256[] memory ids_, uint256[] memory amounts_) external;
/// @dev allows state registry contract to mint shares on source
/// @param data_ is the received information to be processed.
/// @return srcChainId_ is the decoded srcChainId.
function stateMultiSync(AMBMessage memory data_) external returns (uint64 srcChainId_);
/// @dev allows state registry contract to mint shares on source
/// @param data_ is the received information to be processed.
/// @return srcChainId_ is the decoded srcChainId.
function stateSync(AMBMessage memory data_) external returns (uint64 srcChainId_);
/// @dev sets the dynamic uri for NFT
/// @param dynamicURI_ is the dynamic uri of the NFT
/// @param freeze_ is to prevent updating the metadata once migrated to IPFS
function setDynamicURI(string memory dynamicURI_, bool freeze_) external;
/// @dev allows to create sERC0 using broadcast state registry
/// @param data_ is the crosschain payload
function stateSyncBroadcast(bytes memory data_) external payable;
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.23;
/// @title ISuperRegistry
/// @dev Interface for SuperRegistry
/// @author Zeropoint Labs
interface ISuperRegistry {
//////////////////////////////////////////////////////////////
// EVENTS //
//////////////////////////////////////////////////////////////
/// @dev emitted when permit2 is set.
event SetPermit2(address indexed permit2);
/// @dev is emitted when an address is set.
event AddressUpdated(
bytes32 indexed protocolAddressId, uint64 indexed chainId, address indexed oldAddress, address newAddress
);
/// @dev is emitted when a new token bridge is configured.
event SetBridgeAddress(uint256 indexed bridgeId, address indexed bridgeAddress);
/// @dev is emitted when a new bridge validator is configured.
event SetBridgeValidator(uint256 indexed bridgeId, address indexed bridgeValidator);
/// @dev is emitted when a new amb is configured.
event SetAmbAddress(uint8 indexed ambId_, address indexed ambAddress_, bool indexed isBroadcastAMB_);
/// @dev is emitted when a new state registry is configured.
event SetStateRegistryAddress(uint8 indexed registryId_, address indexed registryAddress_);
/// @dev is emitted when a new delay is configured.
event SetDelay(uint256 indexed oldDelay_, uint256 indexed newDelay_);
/// @dev is emitted when a new vault limit is configured
event SetVaultLimitPerDestination(uint64 indexed chainId_, uint256 indexed vaultLimit_);
//////////////////////////////////////////////////////////////
// EXTERNAL VIEW FUNCTIONS //
//////////////////////////////////////////////////////////////
/// @dev gets the deposit rescue delay
function delay() external view returns (uint256);
/// @dev returns the permit2 address
function PERMIT2() external view returns (address);
/// @dev returns the id of the superform router module
function SUPERFORM_ROUTER() external view returns (bytes32);
/// @dev returns the id of the superform factory module
function SUPERFORM_FACTORY() external view returns (bytes32);
/// @dev returns the id of the superform paymaster contract
function PAYMASTER() external view returns (bytes32);
/// @dev returns the id of the superform payload helper contract
function PAYMENT_HELPER() external view returns (bytes32);
/// @dev returns the id of the core state registry module
function CORE_STATE_REGISTRY() external view returns (bytes32);
/// @dev returns the id of the timelock form state registry module
function TIMELOCK_STATE_REGISTRY() external view returns (bytes32);
/// @dev returns the id of the broadcast state registry module
function BROADCAST_REGISTRY() external view returns (bytes32);
/// @dev returns the id of the super positions module
function SUPER_POSITIONS() external view returns (bytes32);
/// @dev returns the id of the super rbac module
function SUPER_RBAC() external view returns (bytes32);
/// @dev returns the id of the payload helper module
function PAYLOAD_HELPER() external view returns (bytes32);
/// @dev returns the id of the dst swapper keeper
function DST_SWAPPER() external view returns (bytes32);
/// @dev returns the id of the emergency queue
function EMERGENCY_QUEUE() external view returns (bytes32);
/// @dev returns the id of the superform receiver
function SUPERFORM_RECEIVER() external view returns (bytes32);
/// @dev returns the id of the payment admin keeper
function PAYMENT_ADMIN() external view returns (bytes32);
/// @dev returns the id of the core state registry processor keeper
function CORE_REGISTRY_PROCESSOR() external view returns (bytes32);
/// @dev returns the id of the broadcast registry processor keeper
function BROADCAST_REGISTRY_PROCESSOR() external view returns (bytes32);
/// @dev returns the id of the timelock form state registry processor keeper
function TIMELOCK_REGISTRY_PROCESSOR() external view returns (bytes32);
/// @dev returns the id of the core state registry updater keeper
function CORE_REGISTRY_UPDATER() external view returns (bytes32);
/// @dev returns the id of the core state registry updater keeper
function CORE_REGISTRY_RESCUER() external view returns (bytes32);
/// @dev returns the id of the core state registry updater keeper
function CORE_REGISTRY_DISPUTER() external view returns (bytes32);
/// @dev returns the id of the core state registry updater keeper
function DST_SWAPPER_PROCESSOR() external view returns (bytes32);
/// @dev gets the address of a contract on current chain
/// @param id_ is the id of the contract
function getAddress(bytes32 id_) external view returns (address);
/// @dev gets the address of a contract on a target chain
/// @param id_ is the id of the contract
/// @param chainId_ is the chain id of that chain
function getAddressByChainId(bytes32 id_, uint64 chainId_) external view returns (address);
/// @dev gets the address of a bridge
/// @param bridgeId_ is the id of a bridge
/// @return bridgeAddress_ is the address of the form
function getBridgeAddress(uint8 bridgeId_) external view returns (address bridgeAddress_);
/// @dev gets the address of a bridge validator
/// @param bridgeId_ is the id of a bridge
/// @return bridgeValidator_ is the address of the form
function getBridgeValidator(uint8 bridgeId_) external view returns (address bridgeValidator_);
/// @dev gets the address of a amb
/// @param ambId_ is the id of a bridge
/// @return ambAddress_ is the address of the form
function getAmbAddress(uint8 ambId_) external view returns (address ambAddress_);
/// @dev gets the id of the amb
/// @param ambAddress_ is the address of an amb
/// @return ambId_ is the identifier of an amb
function getAmbId(address ambAddress_) external view returns (uint8 ambId_);
/// @dev gets the address of the registry
/// @param registryId_ is the id of the state registry
/// @return registryAddress_ is the address of the state registry
function getStateRegistry(uint8 registryId_) external view returns (address registryAddress_);
/// @dev gets the id of the registry
/// @notice reverts if the id is not found
/// @param registryAddress_ is the address of the state registry
/// @return registryId_ is the id of the state registry
function getStateRegistryId(address registryAddress_) external view returns (uint8 registryId_);
/// @dev gets the safe vault limit
/// @param chainId_ is the id of the remote chain
/// @return vaultLimitPerDestination_ is the safe number of vaults to deposit
/// without hitting out of gas error
function getVaultLimitPerDestination(uint64 chainId_) external view returns (uint256 vaultLimitPerDestination_);
/// @dev helps validate if an address is a valid state registry
/// @param registryAddress_ is the address of the state registry
/// @return valid_ a flag indicating if its valid.
function isValidStateRegistry(address registryAddress_) external view returns (bool valid_);
/// @dev helps validate if an address is a valid amb implementation
/// @param ambAddress_ is the address of the amb implementation
/// @return valid_ a flag indicating if its valid.
function isValidAmbImpl(address ambAddress_) external view returns (bool valid_);
/// @dev helps validate if an address is a valid broadcast amb implementation
/// @param ambAddress_ is the address of the broadcast amb implementation
/// @return valid_ a flag indicating if its valid.
function isValidBroadcastAmbImpl(address ambAddress_) external view returns (bool valid_);
//////////////////////////////////////////////////////////////
// EXTERNAL WRITE FUNCTIONS //
//////////////////////////////////////////////////////////////
/// @dev sets the deposit rescue delay
/// @param delay_ the delay in seconds before the deposit rescue can be finalized
function setDelay(uint256 delay_) external;
/// @dev sets the permit2 address
/// @param permit2_ the address of the permit2 contract
function setPermit2(address permit2_) external;
/// @dev sets the safe vault limit
/// @param chainId_ is the remote chain identifier
/// @param vaultLimit_ is the max limit of vaults per transaction
function setVaultLimitPerDestination(uint64 chainId_, uint256 vaultLimit_) external;
/// @dev sets new addresses on specific chains.
/// @param ids_ are the identifiers of the address on that chain
/// @param newAddresses_ are the new addresses on that chain
/// @param chainIds_ are the chain ids of that chain
function batchSetAddress(
bytes32[] calldata ids_,
address[] calldata newAddresses_,
uint64[] calldata chainIds_
)
external;
/// @dev sets a new address on a specific chain.
/// @param id_ the identifier of the address on that chain
/// @param newAddress_ the new address on that chain
/// @param chainId_ the chain id of that chain
function setAddress(bytes32 id_, address newAddress_, uint64 chainId_) external;
/// @dev allows admin to set the bridge address for an bridge id.
/// @notice this function operates in an APPEND-ONLY fashion.
/// @param bridgeId_ represents the bridge unique identifier.
/// @param bridgeAddress_ represents the bridge address.
/// @param bridgeValidator_ represents the bridge validator address.
function setBridgeAddresses(
uint8[] memory bridgeId_,
address[] memory bridgeAddress_,
address[] memory bridgeValidator_
)
external;
/// @dev allows admin to set the amb address for an amb id.
/// @notice this function operates in an APPEND-ONLY fashion.
/// @param ambId_ represents the bridge unique identifier.
/// @param ambAddress_ represents the bridge address.
/// @param isBroadcastAMB_ represents whether the amb implementation supports broadcasting
function setAmbAddress(
uint8[] memory ambId_,
address[] memory ambAddress_,
bool[] memory isBroadcastAMB_
)
external;
/// @dev allows admin to set the state registry address for an state registry id.
/// @notice this function operates in an APPEND-ONLY fashion.
/// @param registryId_ represents the state registry's unique identifier.
/// @param registryAddress_ represents the state registry's address.
function setStateRegistryAddress(uint8[] memory registryId_, address[] memory registryAddress_) external;
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.23;
import { IAccessControl } from "openzeppelin-contracts/contracts/access/IAccessControl.sol";
/// @title ISuperRBAC
/// @dev Interface for SuperRBAC
/// @author Zeropoint Labs
interface ISuperRBAC is IAccessControl {
//////////////////////////////////////////////////////////////
// STRUCTS //
//////////////////////////////////////////////////////////////
struct InitialRoleSetup {
address admin;
address emergencyAdmin;
address paymentAdmin;
address csrProcessor;
address tlProcessor;
address brProcessor;
address csrUpdater;
address srcVaaRelayer;
address dstSwapper;
address csrRescuer;
address csrDisputer;
}
//////////////////////////////////////////////////////////////
// EVENTS //
//////////////////////////////////////////////////////////////
/// @dev is emitted when superRegistry is set
event SuperRegistrySet(address indexed superRegistry);
/// @dev is emitted when an admin is set for a role
event RoleAdminSet(bytes32 role, bytes32 adminRole);
//////////////////////////////////////////////////////////////
// EXTERNAL VIEW FUNCTIONS //
//////////////////////////////////////////////////////////////
/// @dev returns the id of the protocol admin role
function PROTOCOL_ADMIN_ROLE() external view returns (bytes32);
/// @dev returns the id of the emergency admin role
function EMERGENCY_ADMIN_ROLE() external view returns (bytes32);
/// @dev returns the id of the payment admin role
function PAYMENT_ADMIN_ROLE() external view returns (bytes32);
/// @dev returns the id of the broadcaster role
function BROADCASTER_ROLE() external view returns (bytes32);
/// @dev returns the id of the core state registry processor role
function CORE_STATE_REGISTRY_PROCESSOR_ROLE() external view returns (bytes32);
/// @dev returns the id of the timelock state registry processor role
function TIMELOCK_STATE_REGISTRY_PROCESSOR_ROLE() external view returns (bytes32);
/// @dev returns the id of the broadcast state registry processor role
function BROADCAST_STATE_REGISTRY_PROCESSOR_ROLE() external view returns (bytes32);
/// @dev returns the id of the core state registry updater role
function CORE_STATE_REGISTRY_UPDATER_ROLE() external view returns (bytes32);
/// @dev returns the id of the dst swapper role
function DST_SWAPPER_ROLE() external view returns (bytes32);
/// @dev returns the id of the core state registry rescuer role
function CORE_STATE_REGISTRY_RESCUER_ROLE() external view returns (bytes32);
/// @dev returns the id of the core state registry rescue disputer role
function CORE_STATE_REGISTRY_DISPUTER_ROLE() external view returns (bytes32);
/// @dev returns the id of wormhole vaa relayer role
function WORMHOLE_VAA_RELAYER_ROLE() external view returns (bytes32);
/// @dev returns whether the given address has the protocol admin role
/// @param admin_ the address to check
function hasProtocolAdminRole(address admin_) external view returns (bool);
/// @dev returns whether the given address has the emergency admin role
/// @param admin_ the address to check
function hasEmergencyAdminRole(address admin_) external view returns (bool);
//////////////////////////////////////////////////////////////
// EXTERNAL WRITE FUNCTIONS //
//////////////////////////////////////////////////////////////
/// @dev updates the super registry address
function setSuperRegistry(address superRegistry_) external;
/// @dev configures a new role in superForm
/// @param role_ the role to set
/// @param adminRole_ the admin role to set as admin
function setRoleAdmin(bytes32 role_, bytes32 adminRole_) external;
/// @dev revokes the role_ from superRegistryAddressId_ on all chains
/// @param role_ the role to revoke
/// @param extraData_ amb config if broadcasting is required
/// @param superRegistryAddressId_ the super registry address id
function revokeRoleSuperBroadcast(
bytes32 role_,
bytes memory extraData_,
bytes32 superRegistryAddressId_
)
external
payable;
/// @dev allows sync of global roles from different chains using broadcast registry
/// @notice may not work for all roles
function stateSyncBroadcast(bytes memory data_) external;
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.23;
/// @title ISuperformFactory
/// @dev Interface for SuperformFactory
/// @author ZeroPoint Labs
interface ISuperformFactory {
//////////////////////////////////////////////////////////////
// CONSTANTS //
//////////////////////////////////////////////////////////////
enum PauseStatus {
NON_PAUSED,
PAUSED
}
//////////////////////////////////////////////////////////////
// EVENTS //
//////////////////////////////////////////////////////////////
/// @dev emitted when a new formImplementation is entered into the factory
/// @param formImplementation is the address of the new form implementation
/// @param formImplementationId is the id of the formImplementation
/// @param formStateRegistryId is any additional state registry id of the formImplementation
event FormImplementationAdded(
address indexed formImplementation, uint256 indexed formImplementationId, uint8 indexed formStateRegistryId
);
/// @dev emitted when a new Superform is created
/// @param formImplementationId is the id of the form implementation
/// @param vault is the address of the vault
/// @param superformId is the id of the superform
/// @param superform is the address of the superform
event SuperformCreated(
uint256 indexed formImplementationId, address indexed vault, uint256 indexed superformId, address superform
);
/// @dev emitted when a new SuperRegistry is set
/// @param superRegistry is the address of the super registry
event SuperRegistrySet(address indexed superRegistry);
/// @dev emitted when a form implementation is paused
/// @param formImplementationId is the id of the form implementation
/// @param paused is the new paused status
event FormImplementationPaused(uint256 indexed formImplementationId, PauseStatus indexed paused);
//////////////////////////////////////////////////////////////
// EXTERNAL VIEW FUNCTIONS //
//////////////////////////////////////////////////////////////
/// @dev returns the number of forms
/// @return forms_ is the number of forms
function getFormCount() external view returns (uint256 forms_);
/// @dev returns the number of superforms
/// @return superforms_ is the number of superforms
function getSuperformCount() external view returns (uint256 superforms_);
/// @dev returns the address of a form implementation
/// @param formImplementationId_ is the id of the form implementation
/// @return formImplementation_ is the address of the form implementation
function getFormImplementation(uint32 formImplementationId_) external view returns (address formImplementation_);
/// @dev returns the form state registry id of a form implementation
/// @param formImplementationId_ is the id of the form implementation
/// @return stateRegistryId_ is the additional state registry id of the form
function getFormStateRegistryId(uint32 formImplementationId_) external view returns (uint8 stateRegistryId_);
/// @dev returns the paused status of form implementation
/// @param formImplementationId_ is the id of the form implementation
/// @return paused_ is the current paused status of the form formImplementationId_
function isFormImplementationPaused(uint32 formImplementationId_) external view returns (bool paused_);
/// @dev returns the address of a superform
/// @param superformId_ is the id of the superform
/// @return superform_ is the address of the superform
/// @return formImplementationId_ is the id of the form implementation
/// @return chainId_ is the chain id
function getSuperform(uint256 superformId_)
external
pure
returns (address superform_, uint32 formImplementationId_, uint64 chainId_);
/// @dev returns if an address has been added to a Form
/// @param superformId_ is the id of the superform
/// @return isSuperform_ bool if it exists
function isSuperform(uint256 superformId_) external view returns (bool isSuperform_);
/// @dev Reverse query of getSuperform, returns all superforms for a given vault
/// @param vault_ is the address of a vault
/// @return superformIds_ is the id of the superform
/// @return superforms_ is the address of the superform
function getAllSuperformsFromVault(address vault_)
external
view
returns (uint256[] memory superformIds_, address[] memory superforms_);
//////////////////////////////////////////////////////////////
// EXTERNAL WRITE FUNCTIONS //
//////////////////////////////////////////////////////////////
/// @dev allows an admin to add a Form implementation to the factory
/// @param formImplementation_ is the address of a form implementation
/// @param formImplementationId_ is the id of the form implementation (generated off-chain and equal in all chains)
/// @param formStateRegistryId_ is the id of any additional state registry for that form
/// @dev formStateRegistryId_ 1 is default for all form implementations, pass in formStateRegistryId_ only if an
/// additional state registry is required
function addFormImplementation(
address formImplementation_,
uint32 formImplementationId_,
uint8 formStateRegistryId_
)
external;
/// @dev To add new vaults to Form implementations, fusing them together into Superforms
/// @param formImplementationId_ is the form implementation we want to attach the vault to
/// @param vault_ is the address of the vault
/// @return superformId_ is the id of the created superform
/// @return superform_ is the address of the created superform
function createSuperform(
uint32 formImplementationId_,
address vault_
)
external
returns (uint256 superformId_, address superform_);
/// @dev to synchronize superforms added to different chains using broadcast registry
/// @param data_ is the cross-chain superform id
function stateSyncBroadcast(bytes memory data_) external payable;
/// @dev allows an admin to change the status of a form
/// @param formImplementationId_ is the id of the form implementation
/// @param status_ is the new status
/// @param extraData_ is optional & passed when broadcasting of status is needed
function changeFormImplementationPauseStatus(
uint32 formImplementationId_,
PauseStatus status_,
bytes memory extraData_
)
external
payable;
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.23;
import { InitSingleVaultData } from "src/types/DataTypes.sol";
import { IERC165 } from "openzeppelin-contracts/contracts/utils/introspection/IERC165.sol";
import { IERC4626 } from "openzeppelin-contracts/contracts/interfaces/IERC4626.sol";
/// @title IBaseForm
/// @dev Interface for BaseForm
/// @author ZeroPoint Labs
interface IBaseForm is IERC165 {
//////////////////////////////////////////////////////////////
// EVENTS //
//////////////////////////////////////////////////////////////
/// @dev is emitted when a new vault is added by the admin.
event VaultAdded(uint256 indexed id, IERC4626 indexed vault);
/// @dev is emitted when a payload is processed by the destination contract.
event Processed(
uint64 indexed srcChainID,
uint64 indexed dstChainId,
uint256 indexed srcPayloadId,
uint256 amount,
address vault
);
/// @dev is emitted when an emergency withdrawal is processed
event EmergencyWithdrawalProcessed(address indexed refundAddress, uint256 indexed amount);
/// @dev is emitted when dust is forwarded to the paymaster
event FormDustForwardedToPaymaster(address indexed token, uint256 indexed amount);
//////////////////////////////////////////////////////////////
// EXTERNAL VIEW FUNCTIONS //
//////////////////////////////////////////////////////////////
/// @notice get Superform name of the ERC20 vault representation
/// @return The ERC20 name
function superformYieldTokenName() external view returns (string memory);
/// @notice get Superform symbol of the ERC20 vault representation
/// @return The ERC20 symbol
function superformYieldTokenSymbol() external view returns (string memory);
/// @notice get the state registry id associated with the vault
function getStateRegistryId() external view returns (uint8);
/// @notice Returns the vault address
/// @return The address of the vault
function getVaultAddress() external view returns (address);
/// @notice Returns the vault address
/// @return The address of the vault asset
function getVaultAsset() external view returns (address);
/// @notice Returns the name of the vault.
/// @return The name of the vault
function getVaultName() external view returns (string memory);
/// @notice Returns the symbol of a vault.
/// @return The symbol associated with a vault
function getVaultSymbol() external view returns (string memory);
/// @notice Returns the number of decimals in a vault for accounting purposes
/// @return The number of decimals in the vault balance
function getVaultDecimals() external view returns (uint256);
/// @notice Returns the amount of underlying tokens each share of a vault is worth.
/// @return The pricePerVaultShare value
function getPricePerVaultShare() external view returns (uint256);
/// @notice Returns the amount of vault shares owned by the form.
/// @return The form's vault share balance
function getVaultShareBalance() external view returns (uint256);
/// @notice get the total amount of underlying managed in the ERC4626 vault
function getTotalAssets() external view returns (uint256);
/// @notice get the total amount of unredeemed vault shares in circulation
function getTotalSupply() external view returns (uint256);
/// @notice get the total amount of assets received if shares are actually redeemed
/// @notice https://eips.ethereum.org/EIPS/eip-4626
function getPreviewPricePerVaultShare() external view returns (uint256);
/// @dev API may need to know state of funds deployed
function previewDepositTo(uint256 assets_) external view returns (uint256);
/// @notice positionBalance() -> .vaultIds&destAmounts
/// @return how much of an asset + interest (accrued) is to withdraw from the Vault
function previewWithdrawFrom(uint256 assets_) external view returns (uint256);
/// @dev API may need to know state of funds deployed
function previewRedeemFrom(uint256 shares_) external view returns (uint256);
//////////////////////////////////////////////////////////////
// EXTERNAL WRITE FUNCTIONS //
//////////////////////////////////////////////////////////////
/// @dev process same chain id deposits
/// @param singleVaultData_ A bytes representation containing all the data required to make a form action
/// @param srcSender_ The address of the sender of the transaction
/// @return shares The amount of vault shares received
function directDepositIntoVault(
InitSingleVaultData memory singleVaultData_,
address srcSender_
)
external
payable
returns (uint256 shares);
/// @dev process same chain id deposits
/// @param singleVaultData_ A bytes representation containing all the data required to make a form action
/// @param srcSender_ The address of the sender of the transaction
/// @param srcChainId_ The chain id of the source chain
/// @return shares The amount of vault shares received
/// @dev is shares is `0` then no further action/acknowledgement needs to be sent
function xChainDepositIntoVault(
InitSingleVaultData memory singleVaultData_,
address srcSender_,
uint64 srcChainId_
)
external
returns (uint256 shares);
/// @dev process withdrawal of asset from a vault
/// @param singleVaultData_ A bytes representation containing all the data required to make a form action
/// @param srcSender_ The address of the sender of the transaction
/// @return assets The amount of assets received
function directWithdrawFromVault(
InitSingleVaultData memory singleVaultData_,
address srcSender_
)
external
returns (uint256 assets);
/// @dev process withdrawal of asset from a vault
/// @param singleVaultData_ A bytes representation containing all the data required to make a form action
/// @param srcSender_ The address of the sender of the transaction
/// @param srcChainId_ The chain id of the source chain
/// @return assets The amount of assets received
function xChainWithdrawFromVault(
InitSingleVaultData memory singleVaultData_,
address srcSender_,
uint64 srcChainId_
)
external
returns (uint256 assets);
/// @dev process withdrawal of shares if form is paused
/// @param receiverAddress_ The address to refund the shares to
/// @param amount_ The amount of vault shares to refund
function emergencyWithdraw(address receiverAddress_, uint256 amount_) external;
/// @dev moves all dust in the contract to Paymaster contract
/// @param token_ The address of the token to forward
function forwardDustToPaymaster(address token_) external;
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.23;
import {
MultiDstMultiVaultStateReq,
MultiDstSingleVaultStateReq,
SingleXChainMultiVaultStateReq,
SingleXChainSingleVaultStateReq,
SingleDirectSingleVaultStateReq,
SingleDirectMultiVaultStateReq
} from "src/types/DataTypes.sol";
/// @title IPaymentHelper
/// @dev Interface for PaymentHelper
/// @author ZeroPoint Labs
interface IPaymentHelper {
//////////////////////////////////////////////////////////////
// STRUCTS //
//////////////////////////////////////////////////////////////
/// @param nativeFeedOracle is the native price feed oracle
/// @param gasPriceOracle is the gas price oracle
/// @param swapGasUsed is the swap gas params
/// @param updateGasUsed is the update gas params
/// @param depositGasUsed is the deposit per vault gas on the chain
/// @param withdrawGasUsed is the withdraw per vault gas on the chain
/// @param defaultNativePrice is the native price on the specified chain
/// @param defaultGasPrice is the gas price on the specified chain
/// @param dstGasPerByte is the gas per size of data on the specified chain
/// @param ackGasCost is the gas cost for sending and processing from dst->src
/// @param timelockCost is the extra cost for processing timelocked payloads
/// @param emergencyCost is the extra cost for processing emergency payloads
struct PaymentHelperConfig {
address nativeFeedOracle;
address gasPriceOracle;
uint256 swapGasUsed;
uint256 updateGasUsed;
uint256 depositGasUsed;
uint256 withdrawGasUsed;
uint256 defaultNativePrice;
uint256 defaultGasPrice;
uint256 dstGasPerByte;
uint256 ackGasCost;
uint256 timelockCost;
uint256 emergencyCost;
}
//////////////////////////////////////////////////////////////
// EVENTS //
//////////////////////////////////////////////////////////////
event ChainConfigUpdated(uint64 indexed chainId_, uint256 indexed configType_, bytes config_);
event ChainConfigAdded(uint64 chainId_, PaymentHelperConfig config_);
//////////////////////////////////////////////////////////////
// EXTERNAL VIEW FUNCTIONS //
//////////////////////////////////////////////////////////////
/// @dev returns the amb overrides & gas to be used
/// @param dstChainId_ is the unique dst chain identifier
/// @param ambIds_ is the identifiers of arbitrary message bridges to be used
/// @param message_ is the encoded cross-chain payload
function calculateAMBData(
uint64 dstChainId_,
uint8[] calldata ambIds_,
bytes memory message_
)
external
view
returns (uint256 totalFees, bytes memory extraData);
/// @dev returns the amb overrides & gas to be used
/// @return extraData the amb specific override information
function getRegisterTransmuterAMBData() external view returns (bytes memory extraData);
/// @dev estimates the gas fees for multiple destination and multi vault operation
/// @param req_ is the request object containing all necessary data for the actual operation on SuperRouter
/// @param isDeposit_ indicated if the datatype will be used for a deposit
/// @return liqAmount is the amount of liquidity to be provided in native tokens
/// @return srcAmount is the gas expense on source chain in native tokens
/// @return dstAmount is the gas expense on dst chain in terms of src chain's native tokens
/// @return totalAmount is the native_tokens to be sent along the transaction
function estimateMultiDstMultiVault(
MultiDstMultiVaultStateReq calldata req_,
bool isDeposit_
)
external
view
returns (uint256 liqAmount, uint256 srcAmount, uint256 dstAmount, uint256 totalAmount);
/// @dev estimates the gas fees for multiple destination and single vault operation
/// @param req_ is the request object containing all necessary data for the actual operation on SuperRouter
/// @param isDeposit_ indicated if the datatype will be used for a deposit
/// @return liqAmount is the amount of liquidity to be provided in native tokens
/// @return srcAmount is the gas expense on source chain in native tokens
/// @return dstAmount is the gas expense on dst chain in terms of src chain's native tokens
/// @return totalAmount is the native_tokens to be sent along the transaction
function estimateMultiDstSingleVault(
MultiDstSingleVaultStateReq calldata req_,
bool isDeposit_
)
external
view
returns (uint256 liqAmount, uint256 srcAmount, uint256 dstAmount, uint256 totalAmount);
/// @dev estimates the gas fees for single destination and multi vault operation
/// @param req_ is the request object containing all necessary data for the actual operation on SuperRouter
/// @param isDeposit_ indicated if the datatype will be used for a deposit
/// @return liqAmount is the amount of liquidity to be provided in native tokens
/// @return srcAmount is the gas expense on source chain in native tokens
/// @return dstAmount is the gas expense on dst chain in terms of src chain's native tokens
/// @return totalAmount is the native_tokens to be sent along the transaction
function estimateSingleXChainMultiVault(
SingleXChainMultiVaultStateReq calldata req_,
bool isDeposit_
)
external
view
returns (uint256 liqAmount, uint256 srcAmount, uint256 dstAmount, uint256 totalAmount);
/// @dev estimates the gas fees for single destination and single vault operation
/// @param req_ is the request object containing all necessary data for the actual operation on SuperRouter
/// @param isDeposit_ indicated if the datatype will be used for a deposit
/// @return liqAmount is the amount of liquidity to be provided in native tokens
/// @return srcAmount is the gas expense on source chain in native tokens
/// @return dstAmount is the gas expense on dst chain in terms of src chain's native tokens
/// @return totalAmount is the native_tokens to be sent along the transaction
function estimateSingleXChainSingleVault(
SingleXChainSingleVaultStateReq calldata req_,
bool isDeposit_
)
external
view
returns (uint256 liqAmount, uint256 srcAmount, uint256 dstAmount, uint256 totalAmount);
/// @dev estimates the gas fees for same chain operation
/// @param req_ is the request object containing all necessary data for the actual operation on SuperRouter
/// @param isDeposit_ indicated if the datatype will be used for a deposit
/// @return liqAmount is the amount of liquidity to be provided in native tokens
/// @return srcAmount is the gas expense on source chain in native tokens
/// @return totalAmount is the native_tokens to be sent along the transaction
function estimateSingleDirectSingleVault(
SingleDirectSingleVaultStateReq calldata req_,
bool isDeposit_
)
external
view
returns (uint256 liqAmount, uint256 srcAmount, uint256 totalAmount);
/// @dev estimates the gas fees for multiple same chain operation
/// @param req_ is the request object containing all necessary data for the actual operation on SuperRouter
/// @param isDeposit_ indicated if the datatype will be used for a deposit
/// @return liqAmount is the amount of liquidity to be provided in native tokens
/// @return srcAmount is the gas expense on source chain in native tokens
/// @return totalAmount is the native_tokens to be sent along the transaction
function estimateSingleDirectMultiVault(
SingleDirectMultiVaultStateReq calldata req_,
bool isDeposit_
)
external
view
returns (uint256 liqAmount, uint256 srcAmount, uint256 totalAmount);
/// @dev returns the gas fees estimation in native tokens if we send message through a combination of AMBs
/// @param ambIds_ is the identifier of different AMBs
/// @param dstChainId_ is the identifier of the destination chain
/// @param message_ is the cross-chain message
/// @param extraData_ is any amb-specific information
/// @return ambFees is the native_tokens to be sent along the transaction for all the ambIds_ included
function estimateAMBFees(
uint8[] memory ambIds_,
uint64 dstChainId_,
bytes memory message_,
bytes[] memory extraData_
)
external
view
returns (uint256 ambFees, uint256[] memory);
/// @dev helps estimate the acknowledgement costs for amb processing
/// @param payloadId_ is the payload identifier
/// @return totalFees is the total fees to be paid in native tokens
function estimateAckCost(uint256 payloadId_) external view returns (uint256 totalFees);
/// @dev helps estimate the acknowledgement costs for amb processing without relying on payloadId (using max values)
/// @param multi is the flag indicating if the payload is multi or single
/// @param ackAmbIds is the list of ambIds to be used for acknowledgement
/// @param srcChainId is the source chain identifier
/// @return totalFees is the total fees to be paid in native tokens
function estimateAckCostDefault(
bool multi,
uint8[] memory ackAmbIds,
uint64 srcChainId
)
external
view
returns (uint256 totalFees);
/// @dev helps estimate the acknowledgement costs for amb processing without relying on payloadId (using max values)
/// with source native amounts
/// @param multi is the flag indicating if the payload is multi or single
/// @param ackAmbIds is the list of ambIds to be used for acknowledgement
/// @param srcChainId is the source chain identifier
/// @return totalFees is the total fees to be paid in native tokens
function estimateAckCostDefaultNativeSource(
bool multi,
uint8[] memory ackAmbIds,
uint64 srcChainId
)
external
view
returns (uint256 totalFees);
//////////////////////////////////////////////////////////////
// EXTERNAL WRITE FUNCTIONS //
//////////////////////////////////////////////////////////////
/// @dev admin can configure a remote chain for first time
/// @param chainId_ is the identifier of new chain id
/// @param config_ is the chain config
function addRemoteChain(uint64 chainId_, PaymentHelperConfig calldata config_) external;
/// @dev admin can specifically configure/update certain configuration of a remote chain
/// @param chainId_ is the remote chain's identifier
/// @param configType_ is the type of config from 1 -> 6
/// @param config_ is the encoded new configuration
function updateRemoteChain(uint64 chainId_, uint256 configType_, bytes memory config_) external;
/// @dev admin updates config for register transmuter amb params
/// @param extraDataForTransmuter_ is the broadcast extra data
function updateRegisterAERC20Params(bytes memory extraDataForTransmuter_) external;
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.23;
import { Error } from "src/libraries/Error.sol";
library DataLib {
function packTxInfo(
uint8 txType_,
uint8 callbackType_,
uint8 multi_,
uint8 registryId_,
address srcSender_,
uint64 srcChainId_
)
internal
pure
returns (uint256 txInfo)
{
txInfo = uint256(txType_);
txInfo |= uint256(callbackType_) << 8;
txInfo |= uint256(multi_) << 16;
txInfo |= uint256(registryId_) << 24;
txInfo |= uint256(uint160(srcSender_)) << 32;
txInfo |= uint256(srcChainId_) << 192;
}
function decodeTxInfo(uint256 txInfo_)
internal
pure
returns (uint8 txType, uint8 callbackType, uint8 multi, uint8 registryId, address srcSender, uint64 srcChainId)
{
txType = uint8(txInfo_);
callbackType = uint8(txInfo_ >> 8);
multi = uint8(txInfo_ >> 16);
registryId = uint8(txInfo_ >> 24);
srcSender = address(uint160(txInfo_ >> 32));
srcChainId = uint64(txInfo_ >> 192);
}
/// @dev returns the vault-form-chain pair of a superform
/// @param superformId_ is the id of the superform
/// @return superform_ is the address of the superform
/// @return formImplementationId_ is the form id
/// @return chainId_ is the chain id
function getSuperform(uint256 superformId_)
internal
pure
returns (address superform_, uint32 formImplementationId_, uint64 chainId_)
{
superform_ = address(uint160(superformId_));
formImplementationId_ = uint32(superformId_ >> 160);
chainId_ = uint64(superformId_ >> 192);
if (chainId_ == 0) {
revert Error.INVALID_CHAIN_ID();
}
}
/// @dev returns the vault-form-chain pair of an array of superforms
/// @param superformIds_ array of superforms
/// @return superforms_ are the address of the vaults
function getSuperforms(uint256[] memory superformIds_) internal pure returns (address[] memory superforms_) {
uint256 len = superformIds_.length;
superforms_ = new address[](len);
for (uint256 i; i < len; ++i) {
(superforms_[i],,) = getSuperform(superformIds_[i]);
}
}
/// @dev returns the destination chain of a given superform
/// @param superformId_ is the id of the superform
/// @return chainId_ is the chain id
function getDestinationChain(uint256 superformId_) internal pure returns (uint64 chainId_) {
chainId_ = uint64(superformId_ >> 192);
if (chainId_ == 0) {
revert Error.INVALID_CHAIN_ID();
}
}
/// @dev generates the superformId
/// @param superform_ is the address of the superform
/// @param formImplementationId_ is the type of the form
/// @param chainId_ is the chain id on which the superform is deployed
function packSuperform(
address superform_,
uint32 formImplementationId_,
uint64 chainId_
)
internal
pure
returns (uint256 superformId_)
{
superformId_ = uint256(uint160(superform_));
superformId_ |= uint256(formImplementationId_) << 160;
superformId_ |= uint256(chainId_) << 192;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/IERC1155Receiver.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../../utils/introspection/IERC165.sol";
/**
* @dev Interface that must be implemented by smart contracts in order to receive
* ERC-1155 token transfers.
*/
interface IERC1155Receiver is IERC165 {
/**
* @dev Handles the receipt of a single ERC-1155 token type. This function is
* called at the end of a `safeTransferFrom` after the balance has been updated.
*
* NOTE: To accept the transfer, this must return
* `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
* (i.e. 0xf23a6e61, or its own function selector).
*
* @param operator The address which initiated the transfer (i.e. msg.sender)
* @param from The address which previously owned the token
* @param id The ID of the token being transferred
* @param value The amount of tokens being transferred
* @param data Additional data with no specified format
* @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
*/
function onERC1155Received(
address operator,
address from,
uint256 id,
uint256 value,
bytes calldata data
) external returns (bytes4);
/**
* @dev Handles the receipt of a multiple ERC-1155 token types. This function
* is called at the end of a `safeBatchTransferFrom` after the balances have
* been updated.
*
* NOTE: To accept the transfer(s), this must return
* `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
* (i.e. 0xbc197c81, or its own function selector).
*
* @param operator The address which initiated the batch transfer (i.e. msg.sender)
* @param from The address which previously owned the token
* @param ids An array containing ids of each token being transferred (order and length must match values array)
* @param values An array containing amounts of each token being transferred (order and length must match ids array)
* @param data Additional data with no specified format
* @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
*/
function onERC1155BatchReceived(
address operator,
address from,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external returns (bytes4);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../token/ERC20/IERC20.sol";// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.23;
interface IBaseSuperformRouterPlus {
//////////////////////////////////////////////////////////////
// ERRORS //
//////////////////////////////////////////////////////////////
/// @notice thrown if the provided selector is invalid
error INVALID_REBALANCE_SELECTOR();
//////////////////////////////////////////////////////////////
// STRUCTS //
//////////////////////////////////////////////////////////////
struct XChainRebalanceData {
bytes4 rebalanceSelector;
address interimAsset;
uint256 slippage;
uint256 expectedAmountInterimAsset;
uint8[][] rebalanceToAmbIds;
uint64[] rebalanceToDstChainIds;
bytes rebalanceToSfData;
}
//////////////////////////////////////////////////////////////
// ENUMS //
//////////////////////////////////////////////////////////////
enum Actions {
DEPOSIT,
REBALANCE_FROM_SINGLE,
REBALANCE_FROM_MULTI,
REBALANCE_X_CHAIN_FROM_SINGLE,
REBALANCE_X_CHAIN_FROM_MULTI
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;
import { IERC1155 } from "openzeppelin-contracts/contracts/token/ERC1155/IERC1155.sol";
/// @title IERC1155A
/// @author Zeropoint Labs
/// @dev Single/range based id approve capability with conversion to ERC20s
interface IERC1155A is IERC1155 {
//////////////////////////////////////////////////////////////
// EVENTS //
//////////////////////////////////////////////////////////////
/// @dev emitted when single id approval is set
event ApprovalForOne(address indexed owner, address indexed spender, uint256 id, uint256 amount);
/// @dev emitted when an ERC1155A id is transmuted to an aERC20
event TransmutedToERC20(address indexed user, uint256 id, uint256 amount, address indexed receiver);
/// @dev emitted when an aERC20 is transmuted to an ERC1155 id
event TransmutedToERC1155A(address indexed user, uint256 id, uint256 amount, address indexed receiver);
/// @dev emitted when multiple ERC1155A ids are transmuted to aERC20s
event TransmutedBatchToERC20(address indexed user, uint256[] ids, uint256[] amounts, address indexed receiver);
/// @dev emitted when multiple aERC20s are transmuted to ERC1155A ids
event TransmutedBatchToERC1155A(address indexed user, uint256[] ids, uint256[] amounts, address indexed receiver);
//////////////////////////////////////////////////////////////
// ERRORS //
//////////////////////////////////////////////////////////////
/// @dev thrown if aERC20 was already registered
error AERC20_ALREADY_REGISTERED();
/// @dev thrown if aERC20 was not registered
error AERC20_NOT_REGISTERED();
/// @dev thrown if allowance amount will be decreased below zero
error DECREASED_ALLOWANCE_BELOW_ZERO();
/// @dev thrown if the associated ERC1155A id has not been minted before registering an aERC20
error ID_NOT_MINTED_YET();
/// @dev thrown if there is a length mismatch in batch operations
error LENGTH_MISMATCH();
/// @dev thrown if transfer is made to address 0
error TRANSFER_TO_ADDRESS_ZERO();
/// @dev thrown if address is 0
error ZERO_ADDRESS();
//////////////////////////////////////////////////////////////
// EXTERNAL VIEW FUNCTIONS //
//////////////////////////////////////////////////////////////
/// @notice Public getter for existing single id total supply
/// @param id id of the ERC1155
function totalSupply(uint256 id) external view returns (uint256);
/// @notice Public getter to know if a token id exists
/// @dev determines based on total supply for the id
/// @param id id of the ERC1155
function exists(uint256 id) external view returns (bool);
/// @notice Public getter for existing single id approval
/// @param owner address of the owner of the ERC1155A id
/// @param spender address of the contract to approve
/// @param id id of the ERC1155A to approve
function allowance(address owner, address spender, uint256 id) external returns (uint256);
/// @notice handy helper to check if a AERC20 is registered
/// @param id id of the ERC1155
function aERC20Exists(uint256 id) external view returns (bool);
/// @notice Public getter for the address of the aErc20 token for a given ERC1155 id
/// @param id id of the ERC1155 to get the aErc20 token address for
/// @return aERC20 address of the aErc20 token for the given ERC1155 id
function getERC20TokenAddress(uint256 id) external view returns (address aERC20);
/// @notice Compute return string from baseURI set for this contract and unique vaultId
/// @param id id of the ERC1155
function uri(uint256 id) external view returns (string memory);
/// @notice ERC1155A name
function name() external view returns (string memory);
/// @notice ERC1155A symbol
function symbol() external view returns (string memory);
//////////////////////////////////////////////////////////////
// EXTERNAL WRITE FUNCTIONS //
//////////////////////////////////////////////////////////////
/// @notice Public function for setting single id approval
/// @dev Notice `owner` param, it will always be msg.sender, see _setApprovalForOne()
/// @param spender address of the contract to approve
/// @param id id of the ERC1155A to approve
/// @param amount amount of the ERC1155A to approve
function setApprovalForOne(address spender, uint256 id, uint256 amount) external;
/// @notice Public function for setting multiple id approval
/// @dev extension of sigle id approval
/// @param spender address of the contract to approve
/// @param ids ids of the ERC1155A to approve
/// @param amounts amounts of the ERC1155A to approve
function setApprovalForMany(address spender, uint256[] memory ids, uint256[] memory amounts) external;
/// @notice Public function for increasing single id approval amount
/// @dev Re-adapted from ERC20
/// @param spender address of the contract to approve
/// @param id id of the ERC1155A to approve
/// @param addedValue amount of the allowance to increase by
function increaseAllowance(address spender, uint256 id, uint256 addedValue) external returns (bool);
/// @notice Public function for decreasing single id approval amount
/// @dev Re-adapted from ERC20
/// @param spender address of the contract to approve
/// @param id id of the ERC1155A to approve
/// @param subtractedValue amount of the allowance to decrease by
function decreaseAllowance(address spender, uint256 id, uint256 subtractedValue) external returns (bool);
/// @notice Public function for increasing multiple id approval amount at once
/// @dev extension of single id increase allowance
/// @param spender address of the contract to approve
/// @param ids ids of the ERC1155A to approve
/// @param addedValues amounts of the allowance to increase by
function increaseAllowanceForMany(
address spender,
uint256[] memory ids,
uint256[] memory addedValues
)
external
returns (bool);
/// @notice Public function for decreasing multiple id approval amount at once
/// @dev extension of single id decrease allowance
/// @param spender address of the contract to approve
/// @param ids ids of the ERC1155A to approve
/// @param subtractedValues amounts of the allowance to decrease by
function decreaseAllowanceForMany(
address spender,
uint256[] memory ids,
uint256[] memory subtractedValues
)
external
returns (bool);
/// @notice Turn ERC1155A id into an aERC20
/// @dev allows owner to send ERC1155A id as an aERC20 to receiver
/// @param owner address of the user on whose behalf this transmutation is happening
/// @param id id of the ERC20s to transmute to aERC20
/// @param amount amount of the ERC20s to transmute to aERC20
/// @param receiver address of the user to receive the aERC20 token
function transmuteToERC20(address owner, uint256 id, uint256 amount, address receiver) external;
/// @notice Turn aERC20 into an ERC1155A id
/// @dev allows owner to send ERC20 as an ERC1155A id to receiver
/// @param owner address of the user on whose behalf this transmutation is happening
/// @param id id of the ERC20s to transmute to erc1155
/// @param amount amount of the ERC20s to transmute to erc1155
/// @param receiver address of the user to receive the erc1155 token id
function transmuteToERC1155A(address owner, uint256 id, uint256 amount, address receiver) external;
/// @notice Turn ERC1155A ids into aERC20s
/// @dev allows owner to send ERC1155A ids as aERC20s to receiver
/// @param owner address of the user on whose behalf this transmutation is happening
/// @param ids ids of the ERC1155A to transmute
/// @param amounts amounts of the ERC1155A to transmute
/// @param receiver address of the user to receive the aERC20 tokens
function transmuteBatchToERC20(
address owner,
uint256[] memory ids,
uint256[] memory amounts,
address receiver
)
external;
/// @notice Turn aERC20s into ERC1155A ids
/// @dev allows owner to send aERC20s as ERC1155A ids to receiver
/// @param owner address of the user on whose behalf this transmutation is happening
/// @param ids ids of the ERC20 to transmute
/// @param amounts amounts of the ERC20 to transmute
/// @param receiver address of the user to receive the ERC1155 token ids
function transmuteBatchToERC1155A(
address owner,
uint256[] memory ids,
uint256[] memory amounts,
address receiver
)
external;
/// @notice payable to allow any implementing cross-chain protocol to be paid for fees for broadcasting
/// @dev should emit any required events inside _registerAERC20 internal function
/// @param id of the ERC1155 to create a ERC20 for
function registerAERC20(uint256 id) external payable returns (address);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;
import { IERC20 } from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
/// @title IaERC20
/// @author Zeropoint Labs
/// @dev ERC20 tokens out of 1155A
interface IaERC20 is IERC20 {
/// @dev thrown if ERC1155A is not caller for mint/burn in transmute
error ONLY_ERC1155A();
/// @dev allows msg.sender set in constructor to mint
/// @param owner address of the owner of the tokens
/// @param amount amount of tokens to mint
function mint(address owner, uint256 amount) external;
/// @dev allows msg.sender set in constructor to burn
/// @param owner address of the owner of the tokens
/// @param operator address of the operator of the tokens
/// @param amount amount of tokens to burn
function burn(address owner, address operator, uint256 amount) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol)
pragma solidity ^0.8.20;
import {Math} from "./math/Math.sol";
import {SignedMath} from "./math/SignedMath.sol";
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant HEX_DIGITS = "0123456789abcdef";
uint8 private constant ADDRESS_LENGTH = 20;
/**
* @dev The `value` string doesn't fit in the specified `length`.
*/
error StringsInsufficientHexLength(uint256 value, uint256 length);
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/
function toStringSigned(int256 value) internal pure returns (string memory) {
return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value)));
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
uint256 localValue = value;
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = HEX_DIGITS[localValue & 0xf];
localValue >>= 4;
}
if (localValue != 0) {
revert StringsInsufficientHexLength(value, length);
}
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal
* representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);
}
/**
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../utils/introspection/IERC165.sol";// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC1155.sol)
pragma solidity ^0.8.20;
import {IERC1155} from "../token/ERC1155/IERC1155.sol";// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC1155MetadataURI.sol)
pragma solidity ^0.8.20;
import {IERC1155MetadataURI} from "../token/ERC1155/extensions/IERC1155MetadataURI.sol";// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard ERC-20 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens.
*/
interface IERC20Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC20InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC20InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
* @param spender Address that may be allowed to operate on tokens without being their owner.
* @param allowance Amount of tokens a `spender` is allowed to operate with.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC20InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `spender` to be approved. Used in approvals.
* @param spender Address that may be allowed to operate on tokens without being their owner.
*/
error ERC20InvalidSpender(address spender);
}
/**
* @dev Standard ERC-721 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens.
*/
interface IERC721Errors {
/**
* @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-20.
* Used in balance queries.
* @param owner Address of the current owner of a token.
*/
error ERC721InvalidOwner(address owner);
/**
* @dev Indicates a `tokenId` whose `owner` is the zero address.
* @param tokenId Identifier number of a token.
*/
error ERC721NonexistentToken(uint256 tokenId);
/**
* @dev Indicates an error related to the ownership over a particular token. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param tokenId Identifier number of a token.
* @param owner Address of the current owner of a token.
*/
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC721InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC721InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param tokenId Identifier number of a token.
*/
error ERC721InsufficientApproval(address operator, uint256 tokenId);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC721InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC721InvalidOperator(address operator);
}
/**
* @dev Standard ERC-1155 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens.
*/
interface IERC1155Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
* @param tokenId Identifier number of a token.
*/
error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC1155InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC1155InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param owner Address of the current owner of a token.
*/
error ERC1155MissingApprovalForAll(address operator, address owner);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC1155InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC1155InvalidOperator(address operator);
/**
* @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
* Used in batch transfers.
* @param idsLength Length of the array of token identifiers
* @param valuesLength Length of the array of token amounts
*/
error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC20Metadata} from "./extensions/IERC20Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {IERC20Errors} from "../../interfaces/draft-IERC6093.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC-20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the ERC may not emit
* these events, as it isn't required by the specification.
*/
abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
mapping(address account => uint256) private _balances;
mapping(address account => mapping(address spender => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the default value returned by this function, unless
* it's overridden.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `value`.
*/
function transfer(address to, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_transfer(owner, to, value);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `value` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, value);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the ERC. See the note at the beginning of {ERC20}.
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `value`.
* - the caller must have allowance for ``from``'s tokens of at least
* `value`.
*/
function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, value);
_transfer(from, to, value);
return true;
}
/**
* @dev Moves a `value` amount of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _transfer(address from, address to, uint256 value) internal {
if (from == address(0)) {
revert ERC20InvalidSender(address(0));
}
if (to == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(from, to, value);
}
/**
* @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
* (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
* this function.
*
* Emits a {Transfer} event.
*/
function _update(address from, address to, uint256 value) internal virtual {
if (from == address(0)) {
// Overflow check required: The rest of the code assumes that totalSupply never overflows
_totalSupply += value;
} else {
uint256 fromBalance = _balances[from];
if (fromBalance < value) {
revert ERC20InsufficientBalance(from, fromBalance, value);
}
unchecked {
// Overflow not possible: value <= fromBalance <= totalSupply.
_balances[from] = fromBalance - value;
}
}
if (to == address(0)) {
unchecked {
// Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
_totalSupply -= value;
}
} else {
unchecked {
// Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
_balances[to] += value;
}
}
emit Transfer(from, to, value);
}
/**
* @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
* Relies on the `_update` mechanism
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _mint(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(address(0), account, value);
}
/**
* @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
* Relies on the `_update` mechanism.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead
*/
function _burn(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidSender(address(0));
}
_update(account, address(0), value);
}
/**
* @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*
* Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
*/
function _approve(address owner, address spender, uint256 value) internal {
_approve(owner, spender, value, true);
}
/**
* @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
*
* By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
* `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any
* `Approval` event during `transferFrom` operations.
*
* Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to
* true using the following override:
* ```
* function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
* super._approve(owner, spender, value, true);
* }
* ```
*
* Requirements are the same as {_approve}.
*/
function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
if (owner == address(0)) {
revert ERC20InvalidApprover(address(0));
}
if (spender == address(0)) {
revert ERC20InvalidSpender(address(0));
}
_allowances[owner][spender] = value;
if (emitEvent) {
emit Approval(owner, spender, value);
}
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `value`.
*
* Does not update the allowance value in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Does not emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
if (currentAllowance < value) {
revert ERC20InsufficientAllowance(spender, currentAllowance, value);
}
unchecked {
_approve(owner, spender, currentAllowance - value, false);
}
}
}
}// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.23;
/// @title IBroadcastRegistry
/// @dev Interface for BroadcastRegistry
/// @author ZeroPoint Labs
interface IBroadcastRegistry {
//////////////////////////////////////////////////////////////
// EXTERNAL WRITE FUNCTIONS //
//////////////////////////////////////////////////////////////
/// @dev emitted when a payload is broadcasted
event PayloadSent(address indexed sender);
/// @dev emitted when a broadcast payload is received
event PayloadReceived(uint256 indexed payloadId, uint64 indexed srcChainId);
//////////////////////////////////////////////////////////////
// EXTERNAL WRITE FUNCTIONS //
//////////////////////////////////////////////////////////////
/// @dev allows core contracts to send payload to all configured destination chain.
/// @param srcSender_ is the caller of the function (used for gas refunds).
/// @param ambId_ is the identifier of the arbitrary message bridge to be used
/// @param gasFee_ is the gas fee to be used for broadcasting
/// @param message_ is the crosschain payload to be broadcasted
/// @param extraData_ defines all the message bridge related overrides
function broadcastPayload(
address srcSender_,
uint8 ambId_,
uint256 gasFee_,
bytes memory message_,
bytes memory extraData_
)
external
payable;
/// @dev allows ambs to write broadcasted payloads
function receiveBroadcastPayload(uint64 srcChainId_, bytes memory message_) external;
/// @dev allows privileged actors to process broadcasted payloads
/// @param payloadId_ is the identifier of the cross-chain payload
function processPayload(uint256 payloadId_) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)
pragma solidity ^0.8.20;
/**
* @dev External interface of AccessControl declared to support ERC-165 detection.
*/
interface IAccessControl {
/**
* @dev The `account` is missing a role.
*/
error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);
/**
* @dev The caller of a function is not the expected one.
*
* NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
*/
error AccessControlBadConfirmation();
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {AccessControl-_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*/
function renounceRole(bytes32 role, address callerConfirmation) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/IERC1155.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC-1155 compliant contract, as defined in the
* https://eips.ethereum.org/EIPS/eip-1155[ERC].
*/
interface IERC1155 is IERC165 {
/**
* @dev Emitted when `value` amount of tokens of type `id` are transferred from `from` to `to` by `operator`.
*/
event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);
/**
* @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
* transfers.
*/
event TransferBatch(
address indexed operator,
address indexed from,
address indexed to,
uint256[] ids,
uint256[] values
);
/**
* @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
* `approved`.
*/
event ApprovalForAll(address indexed account, address indexed operator, bool approved);
/**
* @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
*
* If an {URI} event was emitted for `id`, the standard
* https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
* returned by {IERC1155MetadataURI-uri}.
*/
event URI(string value, uint256 indexed id);
/**
* @dev Returns the value of tokens of token type `id` owned by `account`.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id) external view returns (uint256);
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(
address[] calldata accounts,
uint256[] calldata ids
) external view returns (uint256[] memory);
/**
* @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
*
* Emits an {ApprovalForAll} event.
*
* Requirements:
*
* - `operator` cannot be the caller.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address account, address operator) external view returns (bool);
/**
* @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`.
*
* WARNING: This function can potentially allow a reentrancy attack when transferring tokens
* to an untrusted contract, when invoking {onERC1155Received} on the receiver.
* Ensure to follow the checks-effects-interactions pattern and consider employing
* reentrancy guards when interacting with untrusted contracts.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
* - `from` must have a balance of tokens of type `id` of at least `value` amount.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes calldata data) external;
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
*
* WARNING: This function can potentially allow a reentrancy attack when transferring tokens
* to an untrusted contract, when invoking {onERC1155BatchReceived} on the receiver.
* Ensure to follow the checks-effects-interactions pattern and consider employing
* reentrancy guards when interacting with untrusted contracts.
*
* Emits either a {TransferSingle} or a {TransferBatch} event, depending on the length of the array arguments.
*
* Requirements:
*
* - `ids` and `values` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
/**
* @dev Muldiv operation overflow.
*/
error MathOverflowedMulDiv();
enum Rounding {
Floor, // Toward negative infinity
Ceil, // Toward positive infinity
Trunc, // Toward zero
Expand // Away from zero
}
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an overflow flag.
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds towards infinity instead
* of rounding towards zero.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
if (b == 0) {
// Guarantee the same behavior as in a regular Solidity division.
return a / b;
}
// The following calculation ensures accurate ceiling division without overflow.
// Since a is non-zero, (a - 1) / b will not overflow.
// The largest possible result occurs when (a - 1) / b is type(uint256).max,
// but the largest value we can obtain is type(uint256).max - 1, which happens
// when a = type(uint256).max and b = 1.
unchecked {
return a == 0 ? 0 : (a - 1) / b + 1;
}
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
* denominator == 0.
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
* Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0 = x * y; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
if (denominator <= prod1) {
revert MathOverflowedMulDiv();
}
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator.
// Always >= 1. See https://cs.stackexchange.com/q/138556/92363.
uint256 twos = denominator & (0 - denominator);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
// works in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
* towards zero.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256 of a positive value rounded towards zero.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);
}
}
/**
* @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
*/
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
return uint8(rounding) % 2 == 1;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard signed math utilities missing in the Solidity language.
*/
library SignedMath {
/**
* @dev Returns the largest of two signed numbers.
*/
function max(int256 a, int256 b) internal pure returns (int256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two signed numbers.
*/
function min(int256 a, int256 b) internal pure returns (int256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two signed numbers without overflow.
* The result is rounded towards zero.
*/
function average(int256 a, int256 b) internal pure returns (int256) {
// Formula from the book "Hacker's Delight"
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// must be unchecked in order to support `n = type(int256).min`
return uint256(n >= 0 ? n : -n);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/extensions/IERC1155MetadataURI.sol)
pragma solidity ^0.8.20;
import {IERC1155} from "../IERC1155.sol";
/**
* @dev Interface of the optional ERC1155MetadataExtension interface, as defined
* in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[ERC].
*/
interface IERC1155MetadataURI is IERC1155 {
/**
* @dev Returns the URI for token type `id`.
*
* If the `\{id\}` substring is present in the URI, it must be replaced by
* clients with the actual token type ID.
*/
function uri(uint256 id) external view returns (string memory);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}{
"remappings": [
"solmate/=lib/ERC1155A/lib/solmate/src/",
"ERC1155A/=lib/ERC1155A/src/",
"@openzeppelin/contracts/=lib/ERC1155A/lib/openzeppelin-contracts/contracts/",
"ds-test/=lib/ds-test/src/",
"erc4626-tests/=lib/ERC1155A/lib/openzeppelin-contracts/lib/erc4626-tests/",
"forge-std/=lib/forge-std/src/",
"openzeppelin-contracts/=lib/ERC1155A/lib/openzeppelin-contracts/",
"pigeon/=lib/pigeon/src/",
"solady/=lib/pigeon/lib/solady/",
"super-vaults/=lib/super-vaults/src/",
"v2-core/=lib/super-vaults/lib/v2-core/contracts/",
"v2-periphery/=lib/super-vaults/lib/v2-periphery/contracts/",
"v3-core/=lib/super-vaults/lib/v3-core/"
],
"optimizer": {
"enabled": true,
"runs": 200
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "paris",
"viaIR": false,
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"superRegistry_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AMOUNT_IN_NOT_EQUAL_OR_LOWER_THAN_BALANCE","type":"error"},{"inputs":[],"name":"ARRAY_LENGTH_MISMATCH","type":"error"},{"inputs":[],"name":"ASSETS_RECEIVED_OUT_OF_SLIPPAGE","type":"error"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"BLOCK_CHAIN_ID_OUT_OF_BOUNDS","type":"error"},{"inputs":[],"name":"FAILED_TO_SEND_NATIVE","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[],"name":"INVALID_DEPOSIT_SELECTOR","type":"error"},{"inputs":[],"name":"INVALID_FEE","type":"error"},{"inputs":[],"name":"INVALID_GLOBAL_SLIPPAGE","type":"error"},{"inputs":[],"name":"INVALID_REBALANCE_FROM_SELECTOR","type":"error"},{"inputs":[],"name":"INVALID_REBALANCE_SELECTOR","type":"error"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"NOT_PRIVILEGED_CALLER","type":"error"},{"inputs":[],"name":"REBALANCE_MULTI_POSITIONS_DIFFERENT_AMOUNTS","type":"error"},{"inputs":[],"name":"REBALANCE_MULTI_POSITIONS_DIFFERENT_CHAIN","type":"error"},{"inputs":[],"name":"REBALANCE_MULTI_POSITIONS_DIFFERENT_TOKEN","type":"error"},{"inputs":[],"name":"REBALANCE_MULTI_POSITIONS_UNEXPECTED_RECEIVER_ADDRESS","type":"error"},{"inputs":[],"name":"REBALANCE_SINGLE_POSITIONS_DIFFERENT_AMOUNT","type":"error"},{"inputs":[],"name":"REBALANCE_SINGLE_POSITIONS_DIFFERENT_CHAIN","type":"error"},{"inputs":[],"name":"REBALANCE_SINGLE_POSITIONS_DIFFERENT_TOKEN","type":"error"},{"inputs":[],"name":"REBALANCE_SINGLE_POSITIONS_UNEXPECTED_RECEIVER_ADDRESS","type":"error"},{"inputs":[],"name":"REBALANCE_XCHAIN_INVALID_RECEIVER_ADDRESS","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"TOLERANCE_EXCEEDED","type":"error"},{"inputs":[],"name":"VAULT_IMPLEMENTATION_FAILED","type":"error"},{"inputs":[],"name":"ZERO_ADDRESS","type":"error"},{"inputs":[],"name":"ZERO_AMOUNT","type":"error"},{"inputs":[],"name":"ZERO_INPUT_VALUE","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":true,"internalType":"address","name":"vault","type":"address"}],"name":"Deposit4626Completed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"RebalanceMultiSyncCompleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RebalanceSyncCompleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RouterPlusDustForwardedToPaymaster","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":true,"internalType":"uint256","name":"routerPlusPayloadId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"interimAsset","type":"address"},{"indexed":false,"internalType":"uint256","name":"finalizeSlippage","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"expectedAmountInterimAsset","type":"uint256"},{"indexed":false,"internalType":"bytes4","name":"rebalanceToSelector","type":"bytes4"}],"name":"XChainRebalanceInitiated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":true,"internalType":"uint256","name":"routerPlusPayloadId","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"indexed":false,"internalType":"address","name":"interimAsset","type":"address"},{"indexed":false,"internalType":"uint256","name":"finalizeSlippage","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"expectedAmountInterimAsset","type":"uint256"},{"indexed":false,"internalType":"bytes4","name":"rebalanceToSelector","type":"bytes4"}],"name":"XChainRebalanceMultiInitiated","type":"event"},{"inputs":[],"name":"CHAIN_ID","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"GLOBAL_SLIPPAGE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ROUTER_PLUS_PAYLOAD_ID","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"vaults_","type":"address[]"},{"components":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"expectedOutputAmount","type":"uint256"},{"internalType":"uint256","name":"maxSlippage","type":"uint256"},{"internalType":"address","name":"receiverAddressSP","type":"address"},{"internalType":"bytes","name":"depositCallData","type":"bytes"}],"internalType":"struct ISuperformRouterPlus.Deposit4626Args[]","name":"args","type":"tuple[]"}],"name":"deposit4626","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"token_","type":"address"}],"name":"forwardDustToPaymaster","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155BatchReceived","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","type":"function"},{"inputs":[{"components":[{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"sharesToRedeem","type":"uint256[]"},{"internalType":"uint256","name":"expectedAmountToReceivePostRebalanceFrom","type":"uint256"},{"internalType":"uint256","name":"rebalanceFromMsgValue","type":"uint256"},{"internalType":"uint256","name":"rebalanceToMsgValue","type":"uint256"},{"internalType":"address","name":"interimAsset","type":"address"},{"internalType":"uint256","name":"slippage","type":"uint256"},{"internalType":"address","name":"receiverAddressSP","type":"address"},{"internalType":"bytes","name":"callData","type":"bytes"},{"internalType":"bytes","name":"rebalanceToCallData","type":"bytes"}],"internalType":"struct ISuperformRouterPlus.RebalanceMultiPositionsSyncArgs","name":"args","type":"tuple"}],"name":"rebalanceMultiPositions","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"sharesToRedeem","type":"uint256"},{"internalType":"uint256","name":"expectedAmountToReceivePostRebalanceFrom","type":"uint256"},{"internalType":"uint256","name":"rebalanceFromMsgValue","type":"uint256"},{"internalType":"uint256","name":"rebalanceToMsgValue","type":"uint256"},{"internalType":"address","name":"interimAsset","type":"address"},{"internalType":"uint256","name":"slippage","type":"uint256"},{"internalType":"address","name":"receiverAddressSP","type":"address"},{"internalType":"bytes","name":"callData","type":"bytes"},{"internalType":"bytes","name":"rebalanceToCallData","type":"bytes"}],"internalType":"struct ISuperformRouterPlus.RebalanceSinglePositionSyncArgs","name":"args","type":"tuple"}],"name":"rebalanceSinglePosition","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"slippage_","type":"uint256"}],"name":"setGlobalSlippage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"sharesToRedeem","type":"uint256"},{"internalType":"address","name":"receiverAddressSP","type":"address"},{"internalType":"address","name":"interimAsset","type":"address"},{"internalType":"uint256","name":"finalizeSlippage","type":"uint256"},{"internalType":"uint256","name":"expectedAmountInterimAsset","type":"uint256"},{"internalType":"bytes4","name":"rebalanceToSelector","type":"bytes4"},{"internalType":"bytes","name":"callData","type":"bytes"},{"internalType":"uint8[][]","name":"rebalanceToAmbIds","type":"uint8[][]"},{"internalType":"uint64[]","name":"rebalanceToDstChainIds","type":"uint64[]"},{"internalType":"bytes","name":"rebalanceToSfData","type":"bytes"}],"internalType":"struct ISuperformRouterPlus.InitiateXChainRebalanceArgs","name":"args","type":"tuple"}],"name":"startCrossChainRebalance","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"sharesToRedeem","type":"uint256[]"},{"internalType":"address","name":"receiverAddressSP","type":"address"},{"internalType":"address","name":"interimAsset","type":"address"},{"internalType":"uint256","name":"finalizeSlippage","type":"uint256"},{"internalType":"uint256","name":"expectedAmountInterimAsset","type":"uint256"},{"internalType":"bytes4","name":"rebalanceToSelector","type":"bytes4"},{"internalType":"bytes","name":"callData","type":"bytes"},{"internalType":"uint8[][]","name":"rebalanceToAmbIds","type":"uint8[][]"},{"internalType":"uint64[]","name":"rebalanceToDstChainIds","type":"uint64[]"},{"internalType":"bytes","name":"rebalanceToSfData","type":"bytes"}],"internalType":"struct ISuperformRouterPlus.InitiateXChainRebalanceMultiArgs","name":"args","type":"tuple"}],"name":"startCrossChainRebalanceMulti","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"superRegistry","outputs":[{"internalType":"contract ISuperRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"enum IBaseSuperformRouterPlus.Actions","name":"","type":"uint8"},{"internalType":"bytes4","name":"selector","type":"bytes4"}],"name":"whitelistedSelectors","outputs":[{"internalType":"bool","name":"whitelisted","type":"bool"}],"stateMutability":"view","type":"function"}]Contract Creation Code
0x60c06040523480156200001157600080fd5b5060405162004ce038038062004ce08339810160408190526200003491620002cd565b806001600160a01b0381166200005d5760405163538ba4f960e01b815260040160405180910390fd5b6001600160401b034611156200008657604051637ecdf93360e01b815260040160405180910390fd5b466001600160401b031660a0526001600160a01b0316608052507f3632447b4e3c54c51d2660a36da1f9d2ed1cdd494379b0d67a45fef3202094918054600160ff1991821681179092557f7c42047726f655b3859613b62c9c434d8cbe177ced1e853b7813c2306582ddd180548216831790557fabfc950554d6e12becfef2eb28ba7b5c8f72f645c02a6e6e49d73da657934d9780548216831790557f586876344e26a55e1524cd8e0e07a0392c80b74a497fdd87d2145e49e110109f80548216831790557fef7222e73ddb1ee2cd8b55f300cefbd3adf6d97b82b1dd5b7955b47036a1605c80548216831790557ff4e9b919f1d82082176cb16d166006451a6a3d4a20c31fa0a9a731e077a1ac8380548216831790557f19c9f28811059b586661795be40d3467675efccdda61bae869cb522860a3786080548216831790557f2df2d18d2684c019b38633c561aefb14e85a173dc44fcb699164e428eaf8922880548216831790557fb45bdcb1d14e0885bedef394f1d8236dec6ae033385b988668e0f73d46f2466e80548216831790557fac0d3d8b6028724dd35571be58cf0d822585b87d59c97a4eff563df0aee3c32580548216831790557f44f5f01255d66d24006e570bd9ba6423a10af1c75bca320e0108051eff91a60c8054821683179055633e753c6360e21b6000527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb56020527f93356010fe9e617ee9a2f246eaec7ea47145f318870ee3a2ee48ea0355672c0b805490911682179055600a9055620002ff565b600060208284031215620002e057600080fd5b81516001600160a01b0381168114620002f857600080fd5b9392505050565b60805160a05161497c62000364600039600081816101ec0152818161085c01528181610a7f01528181610cb70152818161157a01528181611f4b01526120ad01526000818161015a01528181611bd5015281816127d30152613112015261497c6000f3fe6080604052600436106100e85760003560e01c806385fb5e2c1161008a578063d14b23b411610059578063d14b23b4146102d9578063d49aa89f146102ec578063ed88e59414610310578063f23a6e611461032657600080fd5b806385fb5e2c14610226578063b8cae75c14610239578063bc197c8114610271578063cb1f78b8146102b957600080fd5b806338e4e543116100c657806338e4e543146101945780634dcd03c0146101a75780637f157d30146101c757806385e1f4d0146101da57600080fd5b806301ffc9a7146100ed5780631e8e655f1461013357806324c73dda14610148575b600080fd5b3480156100f957600080fd5b5061011e6101083660046134bf565b6001600160e01b0319166301ffc9a760e01b1490565b60405190151581526020015b60405180910390f35b6101466101413660046134f3565b610353565b005b34801561015457600080fd5b5061017c7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200161012a565b6101466101a236600461353a565b610554565b3480156101b357600080fd5b506101466101c236600461358e565b6110c8565b6101466101d53660046135ef565b6111f0565b3480156101e657600080fd5b5061020e7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160401b03909116815260200161012a565b61014661023436600461353a565b611362565b34801561024557600080fd5b5061011e61025436600461365a565b600060208181529281526040808220909352908152205460ff1681565b34801561027d57600080fd5b506102a061028c3660046136d4565b63bc197c8160e01b98975050505050505050565b6040516001600160e01b0319909116815260200161012a565b3480156102c557600080fd5b506101466102d4366004613792565b6118c2565b6101466102e73660046134f3565b611961565b3480156102f857600080fd5b5061030260015481565b60405190815260200161012a565b34801561031c57600080fd5b5061030260025481565b34801561033257600080fd5b506102a06103413660046137ab565b63f23a6e6160e01b9695505050505050565b600061036c6000805160206148e7833981519152611bbc565b90506000610387600080516020614907833981519152611bbc565b90506000806103bf61039f60c0870160a0880161358e565b6103b0610100880160e0890161358e565b87606001358860800135611c4e565b90925090506103d6848433883560208a0135611d2c565b604080516001808252818301909252600091602080830190803683370190505090508560200135816000815181106104105761041061383c565b6020026020010181815250506104d6846040518061012001604052806001600481111561043f5761043f613852565b81526020810185905260408a8101359082015260600161046560c08b0160a08c0161358e565b6001600160a01b031681526020018960c00135815260200189606001358152602001896080013581526020018960e00160208101906104a4919061358e565b6001600160a01b031681526020018690526104c36101008a018a613868565b6104d16101208c018c613868565b611e1a565b6104f385856104eb60c08a0160a08b0161358e565b33878761233f565b8535610506610100880160e0890161358e565b6001600160a01b03167fb7dda660aee9356789dca101ff746f669397b46cf6c6ac0f8783ef9efaf727c8886020013560405161054491815260200190565b60405180910390a3505050505050565b600061056d6000805160206148e7833981519152611bbc565b90506000610588600080516020614907833981519152611bbc565b905061059760208401846138ae565b90506105a384806138ae565b9050146105c357604051634456f5e960e11b815260040160405180910390fd5b60006105d5608085016060860161358e565b6001600160a01b03161480610602575060006105f7606085016040860161358e565b6001600160a01b0316145b156106205760405163538ba4f960e01b815260040160405180910390fd5b8260a0013560000361064557604051630f6fa54560e41b815260040160405180910390fd5b6106cb82823361065587806138ae565b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506106949250505060208901896138ae565b8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061242d92505050565b60006107176106dd60e0860186613868565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506124c692505050565b6001600160e01b0319811660009081527f52d75039926638d3c558b2bdefb945d5be8dae29dedd1c313212a4d472d9fde5602052604090205490915060ff16610773576040516311935f2360e01b815260040160405180910390fd5b600061079e7fac6fb5c3012e2b63885f4f7968d39ab5b69a5472a05927cac7e24779bc95a569611bbc565b90506378b6c1df60e01b6001600160e01b03198316016109805760006107cf6107ca60e0880188613868565b6124cd565b8101906107dc9190613e75565b6040810151608001515190915060005b8181101561093d576108046080890160608a0161358e565b6001600160a01b031683604001516080015182815181106108275761082761383c565b6020026020010151602001516001600160a01b03161461085a57604051633c0f143b60e01b815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160401b0316836040015160800151828151811061089e5761089e61383c565b6020026020010151608001516001600160401b0316146108d15760405163d1ba03c760e01b815260040160405180910390fd5b6108de60208901896138ae565b828181106108ee576108ee61383c565b90506020020135836040015160200151828151811061090f5761090f61383c565b6020026020010151146109355760405163e013298b60e01b815260040160405180910390fd5b6001016107ec565b50826001600160a01b0316826040015161010001516001600160a01b0316146109795760405163523066ad60e11b815260040160405180910390fd5b5050610df0565b63e9a485c560e01b6001600160e01b0319831601610c045760006109aa6107ca60e0880188613868565b8101906109b7919061400f565b6040810151519091506000805b82811015610bfb576000846040015182815181106109e4576109e461383c565b60200260200101516080015151905060005b81811015610b9d57610a0e60808c0160608d0161358e565b6001600160a01b031686604001518481518110610a2d57610a2d61383c565b6020026020010151608001518281518110610a4a57610a4a61383c565b6020026020010151602001516001600160a01b031614610a7d57604051633c0f143b60e01b815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160401b031686604001518481518110610abd57610abd61383c565b6020026020010151608001518281518110610ada57610ada61383c565b6020026020010151608001516001600160401b031614610b0d5760405163d1ba03c760e01b815260040160405180910390fd5b610b1a60208c018c6138ae565b85818110610b2a57610b2a61383c565b9050602002013586604001518481518110610b4757610b4761383c565b6020026020010151602001518281518110610b6457610b6461383c565b602002602001015114610b8a5760405163e013298b60e01b815260040160405180910390fd5b610b938461414a565b93506001016109f6565b50856001600160a01b031685604001518381518110610bbe57610bbe61383c565b602002602001015161010001516001600160a01b031614610bf25760405163523066ad60e11b815260040160405180910390fd5b506001016109c4565b50505050610df0565b631d0e1ff960e31b6001600160e01b0319831601610df0576000610c2e6107ca60e0880188613868565b810190610c3b919061420f565b60408101515190915060005b81811015610dec57610c5f6080890160608a0161358e565b6001600160a01b031683604001518281518110610c7e57610c7e61383c565b602002602001015160800151602001516001600160a01b031614610cb557604051633c0f143b60e01b815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160401b031683604001518281518110610cf557610cf561383c565b602002602001015160800151608001516001600160401b031614610d2c5760405163d1ba03c760e01b815260040160405180910390fd5b610d3960208901896138ae565b82818110610d4957610d4961383c565b9050602002013583604001518281518110610d6657610d6661383c565b60200260200101516020015114610d905760405163e013298b60e01b815260040160405180910390fd5b836001600160a01b031683604001518281518110610db057610db061383c565b602002602001015161010001516001600160a01b031614610de45760405163523066ad60e11b815260040160405180910390fd5b600101610c47565b5050505b610e3d83610e0160e0880188613868565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152503492506124e9915050565b6000808052602081905260008051602061492783398151915290610e6760e0880160c089016134bf565b6001600160e01b031916815260208101919091526040016000205460ff16610ea257604051630e4be19360e41b815260040160405180910390fd5b6000600260008154610eb39061414a565b918290555090506001600160a01b03821663e9368b64610ed96060890160408a0161358e565b836040518060e001604052808b60c0016020810190610ef891906134bf565b6001600160e01b0319168152602001610f1760808d0160608e0161358e565b6001600160a01b0316815260808c0135602082015260a08c01356040820152606001610f476101008d018d6138ae565b610f5091614321565b8152602001610f636101208d018d6138ae565b80806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250505090825250602001610fa86101408d018d613868565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050509152506040516001600160e01b031960e086901b16815261100193929190600401614445565b600060405180830381600087803b15801561101b57600080fd5b505af115801561102f573d6000803e3d6000fd5b50839250611046915050606088016040890161358e565b6001600160a01b03167fa138eaa85fc70fe8329ad10bf334b2ddbe1ba5e2f7608a4e0861aaf3bf321e4f61107a89806138ae565b61108760208c018c6138ae565b61109760808e0160608f0161358e565b8d608001358e60a001358f60c00160208101906110b491906134bf565b604051610544989796959493929190614525565b6001600160a01b0381166110ef5760405163538ba4f960e01b815260040160405180910390fd5b600061111a7fbddfa8c39a1f6275bcfb3aa5c70638c466999edbf14e6162d81b3492caca9fce611bbc565b6040516370a0823160e01b815230600482015290915082906000906001600160a01b038316906370a0823190602401602060405180830381865afa158015611166573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061118a9190614587565b905080156111ea576111a66001600160a01b0383168483612556565b836001600160a01b03167f141c84b86bfe9ffa1ebeca61071c35255a8cc7d0e98e80c5a2f994d77e431cfd826040516111e191815260200190565b60405180910390a25b50505050565b8281811461121157604051634456f5e960e11b815260040160405180910390fd5b806000036112325760405163021b4ea160e01b815260040160405180910390fd5b600061123e82346145b6565b905060005b8281101561135957600080805260208190526000805160206149278339815191529061129a87878581811061127a5761127a61383c565b905060200281019061128c91906145ca565b6106dd906080810190613868565b6001600160e01b031916815260208101919091526040016000205460ff166112d557604051630e4be19360e41b815260040160405180910390fd5b6112e06001846145ea565b81036112fd576112f083346145fd565b6112fa9083614611565b91505b6113518787838181106113125761131261383c565b9050602002016020810190611327919061358e565b8686848181106113395761133961383c565b905060200281019061134b91906145ca565b846125ba565b600101611243565b50505050505050565b600061137b6000805160206148e7833981519152611bbc565b90506000611396600080516020614907833981519152611bbc565b905060006113aa608085016060860161358e565b6001600160a01b031614806113d7575060006113cc606085016040860161358e565b6001600160a01b0316145b156113f55760405163538ba4f960e01b815260040160405180910390fd5b8260a0013560000361141a57604051630f6fa54560e41b815260040160405180910390fd5b61142c82823386356020880135611d2c565b6003600090815260208190527f101e368776582e57ab3d116ffe2517c0a585cd5b23174b01e275c2d8329c3d839061146a6106dd60e0870187613868565b6001600160e01b031916815260208101919091526040016000205460ff166114a5576040516311935f2360e01b815260040160405180910390fd5b60008080526020819052600080516020614927833981519152906114cf60e0860160c087016134bf565b6001600160e01b031916815260208101919091526040016000205460ff1661150a57604051630e4be19360e41b815260040160405180910390fd5b600061151c6107ca60e0860186613868565b8101906115299190614624565b905061153b608085016060860161358e565b6001600160a01b0316816040015160800151602001516001600160a01b0316146115785760405163029379e760e11b815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160401b0316816040015160800151608001516001600160401b0316146115d65760405163b466a6f760e01b815260040160405180910390fd5b8360200135816040015160200151146116025760405163796c29b760e01b815260040160405180910390fd5b600061162d7fac6fb5c3012e2b63885f4f7968d39ab5b69a5472a05927cac7e24779bc95a569611bbc565b9050806001600160a01b0316826040015161010001516001600160a01b03161461166a5760405163523066ad60e11b815260040160405180910390fd5b61167b83610e0160e0880188613868565b600060026000815461168c9061414a565b918290555090506001600160a01b03821663e9368b646116b26060890160408a0161358e565b836040518060e001604052808b60c00160208101906116d191906134bf565b6001600160e01b03191681526020016116f060808d0160608e0161358e565b6001600160a01b0316815260808c0135602082015260a08c013560408201526060016117206101008d018d6138ae565b61172991614321565b815260200161173c6101208d018d6138ae565b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505050908252506020016117816101408d018d613868565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050509152506040516001600160e01b031960e086901b1681526117da93929190600401614445565b600060405180830381600087803b1580156117f457600080fd5b505af1158015611808573d6000803e3d6000fd5b5083925061181f915050606088016040890161358e565b6001600160a01b03167f4409eb08b3c8780e5bcd4ca12b158f7904ffb1ab7f12a0bb06d77cfd93807fb1883560208a013561186060808c0160608d0161358e565b8b608001358c60a001358d60c001602081019061187d91906134bf565b6040805196875260208701959095526001600160a01b0390931693850193909352606084015260808301919091526001600160e01b03191660a082015260c001610544565b6118ec7f5358bcfd81d1ef3da152b1755e1c3c6739686fa7e83dbcad0071568cc4b73a633361279b565b611930576040516361381e6b60e11b81527f5358bcfd81d1ef3da152b1755e1c3c6739686fa7e83dbcad0071568cc4b73a6360048201526024015b60405180910390fd5b61271081118061193e575080155b1561195c57604051630ec71c7d60e21b815260040160405180910390fd5b600155565b600061197a6000805160206148e7833981519152611bbc565b90506000611995600080516020614907833981519152611bbc565b90506000806119ad61039f60c0870160a0880161358e565b90925090506119bf60208601866138ae565b90506119cb86806138ae565b9050146119eb57604051634456f5e960e11b815260040160405180910390fd5b611a3a8484336119fb89806138ae565b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506106949250505060208b018b6138ae565b611b2e8360405180610120016040528060026004811115611a5d57611a5d613852565b8152602001888060200190611a7291906138ae565b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505050908252506040808a0135602083015201611ac260c08a0160a08b0161358e565b6001600160a01b031681526020018860c00135815260200188606001358152602001886080013581526020018860e0016020810190611b01919061358e565b6001600160a01b03168152602001859052611b20610100890189613868565b6104d16101208b018b613868565b611b4b8484611b4360c0890160a08a0161358e565b33868661233f565b611b5c610100860160e0870161358e565b6001600160a01b03167f20f0b022ea8533c8bb3db76cfbf94e0231259f57e2280c8c1ea27d70fb8fea9d611b9087806138ae565b611b9d60208a018a6138ae565b604051611bad94939291906146b6565b60405180910390a25050505050565b6040516321f8a72160e01b8152600481018290526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906321f8a72190602401602060405180830381865afa158015611c24573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c4891906146dd565b92915050565b6000806001600160a01b0386161580611c6e57506001600160a01b038516155b15611c8c5760405163538ba4f960e01b815260040160405180910390fd5b6040516370a0823160e01b81523060048201526001600160a01b038716906370a0823190602401602060405180830381865afa158015611cd0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cf49190614587565b9150611d008385614611565b905080341015611d2357604051632fb15b8760e01b815260040160405180910390fd5b94509492505050565b604051637921219560e11b81526001600160a01b038481166004830152306024830152604482018490526064820183905260a06084830152600060a483015286169063f242432a9060c401600060405180830381600087803b158015611d9157600080fd5b505af1158015611da5573d6000803e3d6000fd5b505060405163524fca8b60e11b81526001600160a01b03878116600483015260248201869052604482018590528816925063a49f951691506064015b600060405180830381600087803b158015611dfb57600080fd5b505af1158015611e0f573d6000803e3d6000fd5b505050505050505050565b6060850151855160009081906004811115611e3757611e37613852565b6004811115611e4857611e48613852565b81526020019081526020016000206000611e9787878080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506124c692505050565b6001600160e01b031916815260208101919091526040016000205460ff16611ed2576040516311935f2360e01b815260040160405180910390fd5b600186516004811115611ee757611ee7613852565b03612022576000611ef886866124cd565b810190611f0591906146fa565b905086606001516001600160a01b0316816000015160800151602001516001600160a01b031614611f495760405163029379e760e11b815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160401b0316816000015160800151608001516001600160401b031614611fa75760405163b466a6f760e01b815260040160405180910390fd5b8660200151600081518110611fbe57611fbe61383c565b602002602001015181600001516020015114611fed5760405163796c29b760e01b815260040160405180910390fd5b805161010001516001600160a01b0316301461201c57604051631613db5360e01b815260040160405180910390fd5b506121bb565b600061202e86866124cd565b81019061203b9190614766565b8051608001515190915060005b818110156121b75788606001516001600160a01b031683600001516080015182815181106120785761207861383c565b6020026020010151602001516001600160a01b0316146120ab57604051633c0f143b60e01b815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000006001600160401b031683600001516080015182815181106120ef576120ef61383c565b6020026020010151608001516001600160401b0316146121225760405163d1ba03c760e01b815260040160405180910390fd5b886020015181815181106121385761213861383c565b6020026020010151836000015160200151828151811061215a5761215a61383c565b6020026020010151146121805760405163e013298b60e01b815260040160405180910390fd5b825161010001516001600160a01b031630146121af576040516318a7b7b160e11b815260040160405180910390fd5b600101612048565b5050505b6121ff8786868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050505060a08901516124e9565b6101008601516040516370a0823160e01b8152306004820152600091906001600160a01b038416906370a0823190602401602060405180830381865afa15801561224d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122719190614587565b61227b91906145ea565b90508060000361229e57604051630f6fa54560e41b815260040160405180910390fd5b60808701516122af906127106145ea565b87604001516122be91906147c6565b6122ca826127106147c6565b10156122e957604051635ebf8da160e11b815260040160405180910390fd5b60006122f68585846128c0565b9050611e0f8984838b60c0015189898080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250612d1592505050565b60405163a22cb46560e01b81526001600160a01b0386811660048301526000602483015287169063a22cb46590604401600060405180830381600087803b15801561238957600080fd5b505af115801561239d573d6000803e3d6000fd5b505050506123ad85858585612d3b565b80341115612425576000336123c283346145ea565b604051600081818185875af1925050503d80600081146123fe576040519150601f19603f3d011682016040523d82523d6000602084013e612403565b606091505b50509050806113595760405163220d375360e01b815260040160405180910390fd5b505050505050565b604051631759616b60e11b81526001600160a01b03861690632eb2c2d69061245f90869030908790879060040161480e565b600060405180830381600087803b15801561247957600080fd5b505af115801561248d573d6000803e3d6000fd5b505060405163a22cb46560e01b81526001600160a01b038781166004830152600160248301528816925063a22cb4659150604401611de1565b6020015190565b3660006124dd8360048187614869565b915091505b9250929050565b600080846001600160a01b031683856040516125059190614893565b60006040518083038185875af1925050503d8060008114612542576040519150601f19603f3d011682016040523d82523d6000602084013e612547565b606091505b50915091506124258282612e5d565b6040516001600160a01b038381166024830152604482018390526125b591859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050612e79565b505050565b336125c784828535612edc565b60008490506000816001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561260c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061263091906146dd565b6040516370a0823160e01b815230600482015290915081906000906001600160a01b038316906370a0823190602401602060405180830381865afa15801561267c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126a09190614587565b905060006126ba85858a3560208c013560408d0135612ef1565b905060006126d46126ce60808b018b613868565b846128c0565b905060006126ef600080516020614907833981519152611bbc565b90506127428186848c8e80608001906127089190613868565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250612d1592505050565b61274e81878a87612d3b565b8a6001600160a01b0316886001600160a01b03167f709067c661df529510fce32dc66881c859f62fcbdfa319bbd2ae37745b6903d360405160405180910390a35050505050505050505050565b6040516321f8a72160e01b81527f6b50fa17b77d24e42e27a04b69fe50cd6967cfb767d18de0bd5fe7e1a32aa86860048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906321f8a72190602401602060405180830381865afa158015612822573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061284691906146dd565b604051632474521560e21b8152600481018590526001600160a01b03848116602483015291909116906391d1485490604401602060405180830381865afa158015612895573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128b991906148a5565b9392505050565b60008061290285858080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506124c692505050565b6001600160e01b031981166000908152600080516020614927833981519152602052604090205490915060ff1661294c57604051630e4be19360e41b815260040160405180910390fd5b6000634e6233cd60e01b6001600160e01b031983160161299f57600061297287876124cd565b81019061297f91906146fa565b600001519050612997816080015182602001516130de565b935050612ca7565b631a98d1dd60e01b6001600160e01b03198316016129e85760006129c387876124cd565b8101906129d09190614624565b604001519050612997816080015182602001516130de565b6305f09b1560e01b6001600160e01b0319831601612a90576000612a0c87876124cd565b810190612a199190614766565b5160808101515190915060005b81811015612a8857612a7283608001518281518110612a4757612a4761383c565b602002602001015184602001518381518110612a6557612a6561383c565b60200260200101516130de565b9350612a7e8487614611565b9550600101612a26565b505050612ca7565b6377e2bd4560e01b6001600160e01b0319831601612b08576000612ab487876124cd565b810190612ac19190613e75565b6040015160808101515190915060005b81811015612a8857612af283608001518281518110612a4757612a4761383c565b9350612afe8487614611565b9550600101612ad1565b6328f7cb8760e11b6001600160e01b0319831601612ba7576000612b2c87876124cd565b810190612b39919061420f565b60400151805190915060005b81811015612a8857612b91838281518110612b6257612b6261383c565b602002602001015160800151848381518110612b8057612b8061383c565b6020026020010151602001516130de565b9350612b9d8487614611565b9550600101612b45565b63018ac39d60e21b6001600160e01b0319831601612ca7576000612bcb87876124cd565b810190612bd8919061400f565b60400151805190915060005b81811015612ca3576000838281518110612c0057612c0061383c565b60200260200101516080015151905060005b81811015612c9957612c83858481518110612c2f57612c2f61383c565b6020026020010151608001518281518110612c4c57612c4c61383c565b6020026020010151868581518110612c6657612c6661383c565b6020026020010151602001518381518110612a6557612a6561383c565b9550612c8f8689614611565b9750600101612c12565b5050600101612be4565b5050505b83831115612cc857604051631d8363b160e01b815260040160405180910390fd5b600154612cd7906127106145ea565b612ce190856147c6565b612ced846127106147c6565b1015612d0c57604051630201878760e11b815260040160405180910390fd5b50509392505050565b612d296001600160a01b03851686856131fe565b612d348582846124e9565b5050505050565b6040516370a0823160e01b815230600482015260009082906001600160a01b038616906370a0823190602401602060405180830381865afa158015612d84573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612da89190614587565b612db291906145ea565b90508015612dce57612dce6001600160a01b0385168483612556565b604051636eb1769f60e11b81523060048201526001600160a01b0386811660248301526000919086169063dd62ed3e90604401602060405180830381865afa158015612e1e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e429190614587565b1115612d3457612d346001600160a01b0385168660006131fe565b606082612e7257612e6d8261328e565b611c48565b5080611c48565b6000612e8e6001600160a01b038416836132ba565b90508051600014158015612eb3575080806020019051810190612eb191906148a5565b155b156125b557604051635274afe760e01b81526001600160a01b0384166004820152602401611927565b6125b56001600160a01b0384168330846132c8565b6040516370a0823160e01b8152306004820152600090859082906001600160a01b038316906370a0823190602401602060405180830381865afa158015612f3c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f609190614587565b604051635d043b2960e11b815260048101889052306024820181905260448201529091506000906001600160a01b038a169063ba087652906064016020604051808303816000875af1158015612fba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fde9190614587565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038516906370a0823190602401602060405180830381865afa158015613028573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061304c9190614587565b905061305883826145ea565b9450600a821080613072575061306f600a836145ea565b85105b1561309057604051632a21dd4360e11b815260040160405180910390fd5b61309c866127106145ea565b6130a690886147c6565b6130b2836127106147c6565b10156130d157604051630201878760e11b815260040160405180910390fd5b5050505095945050505050565b815180516000919082036130f4578291506131f7565b6060840151604051633a16cad560e21b815260ff90911660048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063e85b2b5490602401602060405180830381865afa158015613161573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061318591906146dd565b6001600160a01b0316639bbbb5c88260006040518363ffffffff1660e01b81526004016131b39291906148c2565b602060405180830381865afa1580156131d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131f49190614587565b91505b5092915050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b17905261324f8482613301565b6111ea576040516001600160a01b0384811660248301526000604483015261328491869182169063095ea7b390606401612583565b6111ea8482612e79565b80511561329e5780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b50565b60606128b9838360006133a9565b6040516001600160a01b0384811660248301528381166044830152606482018390526111ea9186918216906323b872dd90608401612583565b6000806000846001600160a01b03168460405161331e9190614893565b6000604051808303816000865af19150503d806000811461335b576040519150601f19603f3d011682016040523d82523d6000602084013e613360565b606091505b509150915081801561338a57508051158061338a57508080602001905181019061338a91906148a5565b80156133a057506000856001600160a01b03163b115b95945050505050565b6060814710156133ce5760405163cd78605960e01b8152306004820152602401611927565b600080856001600160a01b031684866040516133ea9190614893565b60006040518083038185875af1925050503d8060008114613427576040519150601f19603f3d011682016040523d82523d6000602084013e61342c565b606091505b509150915061343c868383613446565b9695505050505050565b60608261345b576134568261328e565b6128b9565b815115801561347257506001600160a01b0384163b155b1561349b57604051639996b31560e01b81526001600160a01b0385166004820152602401611927565b50806128b9565b80356001600160e01b0319811681146134ba57600080fd5b919050565b6000602082840312156134d157600080fd5b6128b9826134a2565b600061014082840312156134ed57600080fd5b50919050565b60006020828403121561350557600080fd5b81356001600160401b0381111561351b57600080fd5b6131f4848285016134da565b600061016082840312156134ed57600080fd5b60006020828403121561354c57600080fd5b81356001600160401b0381111561356257600080fd5b6131f484828501613527565b6001600160a01b03811681146132b757600080fd5b80356134ba8161356e565b6000602082840312156135a057600080fd5b81356128b98161356e565b60008083601f8401126135bd57600080fd5b5081356001600160401b038111156135d457600080fd5b6020830191508360208260051b85010111156124e257600080fd5b6000806000806040858703121561360557600080fd5b84356001600160401b038082111561361c57600080fd5b613628888389016135ab565b9096509450602087013591508082111561364157600080fd5b5061364e878288016135ab565b95989497509550505050565b6000806040838503121561366d57600080fd5b82356005811061367c57600080fd5b915061368a602084016134a2565b90509250929050565b60008083601f8401126136a557600080fd5b5081356001600160401b038111156136bc57600080fd5b6020830191508360208285010111156124e257600080fd5b60008060008060008060008060a0898b0312156136f057600080fd5b88356136fb8161356e565b9750602089013561370b8161356e565b965060408901356001600160401b038082111561372757600080fd5b6137338c838d016135ab565b909850965060608b013591508082111561374c57600080fd5b6137588c838d016135ab565b909650945060808b013591508082111561377157600080fd5b5061377e8b828c01613693565b999c989b5096995094979396929594505050565b6000602082840312156137a457600080fd5b5035919050565b60008060008060008060a087890312156137c457600080fd5b86356137cf8161356e565b955060208701356137df8161356e565b9450604087013593506060870135925060808701356001600160401b0381111561380857600080fd5b61381489828a01613693565b979a9699509497509295939492505050565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b6000808335601e1984360301811261387f57600080fd5b8301803591506001600160401b0382111561389957600080fd5b6020019150368190038213156124e257600080fd5b6000808335601e198436030181126138c557600080fd5b8301803591506001600160401b038211156138df57600080fd5b6020019150600581901b36038213156124e257600080fd5b60405161016081016001600160401b038111828210171561391a5761391a613826565b60405290565b604051606081016001600160401b038111828210171561391a5761391a613826565b604051602081016001600160401b038111828210171561391a5761391a613826565b604051601f8201601f191681016001600160401b038111828210171561398c5761398c613826565b604052919050565b60006001600160401b038211156139ad576139ad613826565b5060051b60200190565b803560ff811681146134ba57600080fd5b600082601f8301126139d957600080fd5b813560206139ee6139e983613994565b613964565b8083825260208201915060208460051b870101935086841115613a1057600080fd5b602086015b84811015613a3357613a26816139b7565b8352918301918301613a15565b509695505050505050565b80356001600160401b03811681146134ba57600080fd5b600082601f830112613a6657600080fd5b81356020613a766139e983613994565b8083825260208201915060208460051b870101935086841115613a9857600080fd5b602086015b84811015613a335780358352918301918301613a9d565b600082601f830112613ac557600080fd5b81356001600160401b03811115613ade57613ade613826565b613af1601f8201601f1916602001613964565b818152846020838601011115613b0657600080fd5b816020850160208301376000918101602001919091529392505050565b600060c08284031215613b3557600080fd5b60405160c081016001600160401b038282108183111715613b5857613b58613826565b816040528293508435915080821115613b7057600080fd5b50613b7d85828601613ab4565b8252506020830135613b8e8161356e565b60208201526040830135613ba18161356e565b6040820152613bb2606084016139b7565b6060820152613bc360808401613a3e565b608082015260a083013560a08201525092915050565b600082601f830112613bea57600080fd5b81356020613bfa6139e983613994565b82815260059290921b84018101918181019086841115613c1957600080fd5b8286015b84811015613a335780356001600160401b03811115613c3c5760008081fd5b613c4a8986838b0101613b23565b845250918301918301613c1d565b80151581146132b757600080fd5b80356134ba81613c58565b600082601f830112613c8257600080fd5b81356020613c926139e983613994565b8083825260208201915060208460051b870101935086841115613cb457600080fd5b602086015b84811015613a33578035613ccc81613c58565b8352918301918301613cb9565b60006101608284031215613cec57600080fd5b613cf46138f7565b905081356001600160401b0380821115613d0d57600080fd5b613d1985838601613a55565b83526020840135915080821115613d2f57600080fd5b613d3b85838601613a55565b60208401526040840135915080821115613d5457600080fd5b613d6085838601613a55565b60408401526060840135915080821115613d7957600080fd5b613d8585838601613a55565b60608401526080840135915080821115613d9e57600080fd5b613daa85838601613bd9565b608084015260a0840135915080821115613dc357600080fd5b613dcf85838601613ab4565b60a084015260c0840135915080821115613de857600080fd5b613df485838601613c71565b60c084015260e0840135915080821115613e0d57600080fd5b613e1985838601613c71565b60e08401526101009150613e2e828501613583565b828401526101209150613e42828501613583565b8284015261014091508184013581811115613e5c57600080fd5b613e6886828701613ab4565b8385015250505092915050565b600060208284031215613e8757600080fd5b81356001600160401b0380821115613e9e57600080fd5b9083019060608286031215613eb257600080fd5b613eba613920565b823582811115613ec957600080fd5b613ed5878286016139c8565b825250613ee460208401613a3e565b6020820152604083013582811115613efb57600080fd5b613f0787828601613cd9565b60408301525095945050505050565b6000613f246139e984613994565b8381529050602080820190600585901b840186811115613f4357600080fd5b845b81811015613f7e5780356001600160401b03811115613f645760008081fd5b613f70898289016139c8565b855250928201928201613f45565b505050509392505050565b600082601f830112613f9a57600080fd5b6128b983833560208501613f16565b600082601f830112613fba57600080fd5b81356020613fca6139e983613994565b8083825260208201915060208460051b870101935086841115613fec57600080fd5b602086015b84811015613a335761400281613a3e565b8352918301918301613ff1565b6000602080838503121561402257600080fd5b82356001600160401b038082111561403957600080fd5b908401906060828703121561404d57600080fd5b614055613920565b82358281111561406457600080fd5b61407088828601613f89565b825250838301358281111561408457600080fd5b61409088828601613fa9565b85830152506040830135828111156140a757600080fd5b80840193505086601f8401126140bc57600080fd5b82356140ca6139e982613994565b81815260059190911b840185019085810190898311156140e957600080fd5b8686015b83811015614121578035868111156141055760008081fd5b6141138c8a838b0101613cd9565b8452509187019187016140ed565b5060408401525090979650505050505050565b634e487b7160e01b600052601160045260246000fd5b60006001820161415c5761415c614134565b5060010190565b6000610160828403121561417657600080fd5b61417e6138f7565b90508135815260208201356020820152604082013560408201526060820135606082015260808201356001600160401b03808211156141bc57600080fd5b6141c885838601613b23565b608084015260a08401359150808211156141e157600080fd5b6141ed85838601613ab4565b60a08401526141fe60c08501613c66565b60c0840152613e1960e08501613c66565b6000602080838503121561422257600080fd5b82356001600160401b038082111561423957600080fd5b908401906060828703121561424d57600080fd5b614255613920565b82358281111561426457600080fd5b61427088828601613f89565b825250838301358281111561428457600080fd5b61429088828601613fa9565b85830152506040830135828111156142a757600080fd5b80840193505086601f8401126142bc57600080fd5b82356142ca6139e982613994565b81815260059190911b840185019085810190898311156142e957600080fd5b8686015b83811015614121578035868111156143055760008081fd5b6143138c8a838b0101614163565b8452509187019187016142ed565b60006128b9368484613f16565b600082825180855260208086019550808260051b8401018186016000805b858110156143a257868403601f19018a52825180518086529086019086860190845b8181101561438d57835160ff168352928801929188019160010161436e565b50509a86019a9450509184019160010161434c565b509198975050505050505050565b60008151808452602080850194506020840160005b838110156143ea5781516001600160401b0316875295820195908201906001016143c5565b509495945050505050565b60005b838110156144105781810151838201526020016143f8565b50506000910152565b600081518084526144318160208601602086016143f5565b601f01601f19169290920160200192915050565b600060018060a01b0380861683528460208401526060604084015263ffffffff60e01b845116606084015280602085015116608084015250604083015160a0830152606083015160c0830152608083015160e0808401526144aa61014084018261432e565b905060a0840151605f1980858403016101008601526144c983836143b0565b925060c086015191508085840301610120860152506144e88282614419565b979650505050505050565b81835260006001600160fb1b0383111561450c57600080fd5b8260051b80836020870137939093016020019392505050565b60c08152600061453960c083018a8c6144f3565b828103602084015261454c81898b6144f3565b6001600160a01b039790971660408401525050606081019390935260808301919091526001600160e01b03191660a090910152949350505050565b60006020828403121561459957600080fd5b5051919050565b634e487b7160e01b600052601260045260246000fd5b6000826145c5576145c56145a0565b500490565b60008235609e198336030181126145e057600080fd5b9190910192915050565b81810381811115611c4857611c48614134565b60008261460c5761460c6145a0565b500690565b80820180821115611c4857611c48614134565b60006020828403121561463657600080fd5b81356001600160401b038082111561464d57600080fd5b908301906060828603121561466157600080fd5b614669613920565b82358281111561467857600080fd5b614684878286016139c8565b82525061469360208401613a3e565b60208201526040830135828111156146aa57600080fd5b613f0787828601614163565b6040815260006146ca6040830186886144f3565b82810360208401526144e88185876144f3565b6000602082840312156146ef57600080fd5b81516128b98161356e565b60006020828403121561470c57600080fd5b81356001600160401b038082111561472357600080fd5b908301906020828603121561473757600080fd5b61473f613942565b82358281111561474e57600080fd5b61475a87828601614163565b82525095945050505050565b60006020828403121561477857600080fd5b81356001600160401b038082111561478f57600080fd5b90830190602082860312156147a357600080fd5b6147ab613942565b8235828111156147ba57600080fd5b61475a87828601613cd9565b8082028115828204841417611c4857611c48614134565b60008151808452602080850194506020840160005b838110156143ea578151875295820195908201906001016147f2565b6001600160a01b0385811682528416602082015260a06040820181905260009061483a908301856147dd565b828103606084015261484c81856147dd565b838103608090940193909352505060008152602001949350505050565b6000808585111561487957600080fd5b8386111561488657600080fd5b5050820193919092039150565b600082516145e08184602087016143f5565b6000602082840312156148b757600080fd5b81516128b981613c58565b6040815260006148d56040830185614419565b90508215156020830152939250505056feba0b74768b1de73590a53e1384870dcbc846e5c73bab23c07d71eaa7cbf8411b3a2f5529773e03d975be44bdae98a8509bdf1159e407504e558536cde56cf6acad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5a264697066735822122071261314b1c3ef689a3da2bbcaffd3c3b599fee4a10471bc3047033a769be15e64736f6c6343000817003300000000000000000000000017a332dc7b40ae701485023b219e9d6f493a2514
Deployed Bytecode
0x6080604052600436106100e85760003560e01c806385fb5e2c1161008a578063d14b23b411610059578063d14b23b4146102d9578063d49aa89f146102ec578063ed88e59414610310578063f23a6e611461032657600080fd5b806385fb5e2c14610226578063b8cae75c14610239578063bc197c8114610271578063cb1f78b8146102b957600080fd5b806338e4e543116100c657806338e4e543146101945780634dcd03c0146101a75780637f157d30146101c757806385e1f4d0146101da57600080fd5b806301ffc9a7146100ed5780631e8e655f1461013357806324c73dda14610148575b600080fd5b3480156100f957600080fd5b5061011e6101083660046134bf565b6001600160e01b0319166301ffc9a760e01b1490565b60405190151581526020015b60405180910390f35b6101466101413660046134f3565b610353565b005b34801561015457600080fd5b5061017c7f00000000000000000000000017a332dc7b40ae701485023b219e9d6f493a251481565b6040516001600160a01b03909116815260200161012a565b6101466101a236600461353a565b610554565b3480156101b357600080fd5b506101466101c236600461358e565b6110c8565b6101466101d53660046135ef565b6111f0565b3480156101e657600080fd5b5061020e7f0000000000000000000000000000000000000000000000000000000000013e3181565b6040516001600160401b03909116815260200161012a565b61014661023436600461353a565b611362565b34801561024557600080fd5b5061011e61025436600461365a565b600060208181529281526040808220909352908152205460ff1681565b34801561027d57600080fd5b506102a061028c3660046136d4565b63bc197c8160e01b98975050505050505050565b6040516001600160e01b0319909116815260200161012a565b3480156102c557600080fd5b506101466102d4366004613792565b6118c2565b6101466102e73660046134f3565b611961565b3480156102f857600080fd5b5061030260015481565b60405190815260200161012a565b34801561031c57600080fd5b5061030260025481565b34801561033257600080fd5b506102a06103413660046137ab565b63f23a6e6160e01b9695505050505050565b600061036c6000805160206148e7833981519152611bbc565b90506000610387600080516020614907833981519152611bbc565b90506000806103bf61039f60c0870160a0880161358e565b6103b0610100880160e0890161358e565b87606001358860800135611c4e565b90925090506103d6848433883560208a0135611d2c565b604080516001808252818301909252600091602080830190803683370190505090508560200135816000815181106104105761041061383c565b6020026020010181815250506104d6846040518061012001604052806001600481111561043f5761043f613852565b81526020810185905260408a8101359082015260600161046560c08b0160a08c0161358e565b6001600160a01b031681526020018960c00135815260200189606001358152602001896080013581526020018960e00160208101906104a4919061358e565b6001600160a01b031681526020018690526104c36101008a018a613868565b6104d16101208c018c613868565b611e1a565b6104f385856104eb60c08a0160a08b0161358e565b33878761233f565b8535610506610100880160e0890161358e565b6001600160a01b03167fb7dda660aee9356789dca101ff746f669397b46cf6c6ac0f8783ef9efaf727c8886020013560405161054491815260200190565b60405180910390a3505050505050565b600061056d6000805160206148e7833981519152611bbc565b90506000610588600080516020614907833981519152611bbc565b905061059760208401846138ae565b90506105a384806138ae565b9050146105c357604051634456f5e960e11b815260040160405180910390fd5b60006105d5608085016060860161358e565b6001600160a01b03161480610602575060006105f7606085016040860161358e565b6001600160a01b0316145b156106205760405163538ba4f960e01b815260040160405180910390fd5b8260a0013560000361064557604051630f6fa54560e41b815260040160405180910390fd5b6106cb82823361065587806138ae565b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506106949250505060208901896138ae565b8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525061242d92505050565b60006107176106dd60e0860186613868565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506124c692505050565b6001600160e01b0319811660009081527f52d75039926638d3c558b2bdefb945d5be8dae29dedd1c313212a4d472d9fde5602052604090205490915060ff16610773576040516311935f2360e01b815260040160405180910390fd5b600061079e7fac6fb5c3012e2b63885f4f7968d39ab5b69a5472a05927cac7e24779bc95a569611bbc565b90506378b6c1df60e01b6001600160e01b03198316016109805760006107cf6107ca60e0880188613868565b6124cd565b8101906107dc9190613e75565b6040810151608001515190915060005b8181101561093d576108046080890160608a0161358e565b6001600160a01b031683604001516080015182815181106108275761082761383c565b6020026020010151602001516001600160a01b03161461085a57604051633c0f143b60e01b815260040160405180910390fd5b7f0000000000000000000000000000000000000000000000000000000000013e316001600160401b0316836040015160800151828151811061089e5761089e61383c565b6020026020010151608001516001600160401b0316146108d15760405163d1ba03c760e01b815260040160405180910390fd5b6108de60208901896138ae565b828181106108ee576108ee61383c565b90506020020135836040015160200151828151811061090f5761090f61383c565b6020026020010151146109355760405163e013298b60e01b815260040160405180910390fd5b6001016107ec565b50826001600160a01b0316826040015161010001516001600160a01b0316146109795760405163523066ad60e11b815260040160405180910390fd5b5050610df0565b63e9a485c560e01b6001600160e01b0319831601610c045760006109aa6107ca60e0880188613868565b8101906109b7919061400f565b6040810151519091506000805b82811015610bfb576000846040015182815181106109e4576109e461383c565b60200260200101516080015151905060005b81811015610b9d57610a0e60808c0160608d0161358e565b6001600160a01b031686604001518481518110610a2d57610a2d61383c565b6020026020010151608001518281518110610a4a57610a4a61383c565b6020026020010151602001516001600160a01b031614610a7d57604051633c0f143b60e01b815260040160405180910390fd5b7f0000000000000000000000000000000000000000000000000000000000013e316001600160401b031686604001518481518110610abd57610abd61383c565b6020026020010151608001518281518110610ada57610ada61383c565b6020026020010151608001516001600160401b031614610b0d5760405163d1ba03c760e01b815260040160405180910390fd5b610b1a60208c018c6138ae565b85818110610b2a57610b2a61383c565b9050602002013586604001518481518110610b4757610b4761383c565b6020026020010151602001518281518110610b6457610b6461383c565b602002602001015114610b8a5760405163e013298b60e01b815260040160405180910390fd5b610b938461414a565b93506001016109f6565b50856001600160a01b031685604001518381518110610bbe57610bbe61383c565b602002602001015161010001516001600160a01b031614610bf25760405163523066ad60e11b815260040160405180910390fd5b506001016109c4565b50505050610df0565b631d0e1ff960e31b6001600160e01b0319831601610df0576000610c2e6107ca60e0880188613868565b810190610c3b919061420f565b60408101515190915060005b81811015610dec57610c5f6080890160608a0161358e565b6001600160a01b031683604001518281518110610c7e57610c7e61383c565b602002602001015160800151602001516001600160a01b031614610cb557604051633c0f143b60e01b815260040160405180910390fd5b7f0000000000000000000000000000000000000000000000000000000000013e316001600160401b031683604001518281518110610cf557610cf561383c565b602002602001015160800151608001516001600160401b031614610d2c5760405163d1ba03c760e01b815260040160405180910390fd5b610d3960208901896138ae565b82818110610d4957610d4961383c565b9050602002013583604001518281518110610d6657610d6661383c565b60200260200101516020015114610d905760405163e013298b60e01b815260040160405180910390fd5b836001600160a01b031683604001518281518110610db057610db061383c565b602002602001015161010001516001600160a01b031614610de45760405163523066ad60e11b815260040160405180910390fd5b600101610c47565b5050505b610e3d83610e0160e0880188613868565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152503492506124e9915050565b6000808052602081905260008051602061492783398151915290610e6760e0880160c089016134bf565b6001600160e01b031916815260208101919091526040016000205460ff16610ea257604051630e4be19360e41b815260040160405180910390fd5b6000600260008154610eb39061414a565b918290555090506001600160a01b03821663e9368b64610ed96060890160408a0161358e565b836040518060e001604052808b60c0016020810190610ef891906134bf565b6001600160e01b0319168152602001610f1760808d0160608e0161358e565b6001600160a01b0316815260808c0135602082015260a08c01356040820152606001610f476101008d018d6138ae565b610f5091614321565b8152602001610f636101208d018d6138ae565b80806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250505090825250602001610fa86101408d018d613868565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050509152506040516001600160e01b031960e086901b16815261100193929190600401614445565b600060405180830381600087803b15801561101b57600080fd5b505af115801561102f573d6000803e3d6000fd5b50839250611046915050606088016040890161358e565b6001600160a01b03167fa138eaa85fc70fe8329ad10bf334b2ddbe1ba5e2f7608a4e0861aaf3bf321e4f61107a89806138ae565b61108760208c018c6138ae565b61109760808e0160608f0161358e565b8d608001358e60a001358f60c00160208101906110b491906134bf565b604051610544989796959493929190614525565b6001600160a01b0381166110ef5760405163538ba4f960e01b815260040160405180910390fd5b600061111a7fbddfa8c39a1f6275bcfb3aa5c70638c466999edbf14e6162d81b3492caca9fce611bbc565b6040516370a0823160e01b815230600482015290915082906000906001600160a01b038316906370a0823190602401602060405180830381865afa158015611166573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061118a9190614587565b905080156111ea576111a66001600160a01b0383168483612556565b836001600160a01b03167f141c84b86bfe9ffa1ebeca61071c35255a8cc7d0e98e80c5a2f994d77e431cfd826040516111e191815260200190565b60405180910390a25b50505050565b8281811461121157604051634456f5e960e11b815260040160405180910390fd5b806000036112325760405163021b4ea160e01b815260040160405180910390fd5b600061123e82346145b6565b905060005b8281101561135957600080805260208190526000805160206149278339815191529061129a87878581811061127a5761127a61383c565b905060200281019061128c91906145ca565b6106dd906080810190613868565b6001600160e01b031916815260208101919091526040016000205460ff166112d557604051630e4be19360e41b815260040160405180910390fd5b6112e06001846145ea565b81036112fd576112f083346145fd565b6112fa9083614611565b91505b6113518787838181106113125761131261383c565b9050602002016020810190611327919061358e565b8686848181106113395761133961383c565b905060200281019061134b91906145ca565b846125ba565b600101611243565b50505050505050565b600061137b6000805160206148e7833981519152611bbc565b90506000611396600080516020614907833981519152611bbc565b905060006113aa608085016060860161358e565b6001600160a01b031614806113d7575060006113cc606085016040860161358e565b6001600160a01b0316145b156113f55760405163538ba4f960e01b815260040160405180910390fd5b8260a0013560000361141a57604051630f6fa54560e41b815260040160405180910390fd5b61142c82823386356020880135611d2c565b6003600090815260208190527f101e368776582e57ab3d116ffe2517c0a585cd5b23174b01e275c2d8329c3d839061146a6106dd60e0870187613868565b6001600160e01b031916815260208101919091526040016000205460ff166114a5576040516311935f2360e01b815260040160405180910390fd5b60008080526020819052600080516020614927833981519152906114cf60e0860160c087016134bf565b6001600160e01b031916815260208101919091526040016000205460ff1661150a57604051630e4be19360e41b815260040160405180910390fd5b600061151c6107ca60e0860186613868565b8101906115299190614624565b905061153b608085016060860161358e565b6001600160a01b0316816040015160800151602001516001600160a01b0316146115785760405163029379e760e11b815260040160405180910390fd5b7f0000000000000000000000000000000000000000000000000000000000013e316001600160401b0316816040015160800151608001516001600160401b0316146115d65760405163b466a6f760e01b815260040160405180910390fd5b8360200135816040015160200151146116025760405163796c29b760e01b815260040160405180910390fd5b600061162d7fac6fb5c3012e2b63885f4f7968d39ab5b69a5472a05927cac7e24779bc95a569611bbc565b9050806001600160a01b0316826040015161010001516001600160a01b03161461166a5760405163523066ad60e11b815260040160405180910390fd5b61167b83610e0160e0880188613868565b600060026000815461168c9061414a565b918290555090506001600160a01b03821663e9368b646116b26060890160408a0161358e565b836040518060e001604052808b60c00160208101906116d191906134bf565b6001600160e01b03191681526020016116f060808d0160608e0161358e565b6001600160a01b0316815260808c0135602082015260a08c013560408201526060016117206101008d018d6138ae565b61172991614321565b815260200161173c6101208d018d6138ae565b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505050908252506020016117816101408d018d613868565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050509152506040516001600160e01b031960e086901b1681526117da93929190600401614445565b600060405180830381600087803b1580156117f457600080fd5b505af1158015611808573d6000803e3d6000fd5b5083925061181f915050606088016040890161358e565b6001600160a01b03167f4409eb08b3c8780e5bcd4ca12b158f7904ffb1ab7f12a0bb06d77cfd93807fb1883560208a013561186060808c0160608d0161358e565b8b608001358c60a001358d60c001602081019061187d91906134bf565b6040805196875260208701959095526001600160a01b0390931693850193909352606084015260808301919091526001600160e01b03191660a082015260c001610544565b6118ec7f5358bcfd81d1ef3da152b1755e1c3c6739686fa7e83dbcad0071568cc4b73a633361279b565b611930576040516361381e6b60e11b81527f5358bcfd81d1ef3da152b1755e1c3c6739686fa7e83dbcad0071568cc4b73a6360048201526024015b60405180910390fd5b61271081118061193e575080155b1561195c57604051630ec71c7d60e21b815260040160405180910390fd5b600155565b600061197a6000805160206148e7833981519152611bbc565b90506000611995600080516020614907833981519152611bbc565b90506000806119ad61039f60c0870160a0880161358e565b90925090506119bf60208601866138ae565b90506119cb86806138ae565b9050146119eb57604051634456f5e960e11b815260040160405180910390fd5b611a3a8484336119fb89806138ae565b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152506106949250505060208b018b6138ae565b611b2e8360405180610120016040528060026004811115611a5d57611a5d613852565b8152602001888060200190611a7291906138ae565b808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505050908252506040808a0135602083015201611ac260c08a0160a08b0161358e565b6001600160a01b031681526020018860c00135815260200188606001358152602001886080013581526020018860e0016020810190611b01919061358e565b6001600160a01b03168152602001859052611b20610100890189613868565b6104d16101208b018b613868565b611b4b8484611b4360c0890160a08a0161358e565b33868661233f565b611b5c610100860160e0870161358e565b6001600160a01b03167f20f0b022ea8533c8bb3db76cfbf94e0231259f57e2280c8c1ea27d70fb8fea9d611b9087806138ae565b611b9d60208a018a6138ae565b604051611bad94939291906146b6565b60405180910390a25050505050565b6040516321f8a72160e01b8152600481018290526000907f00000000000000000000000017a332dc7b40ae701485023b219e9d6f493a25146001600160a01b0316906321f8a72190602401602060405180830381865afa158015611c24573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c4891906146dd565b92915050565b6000806001600160a01b0386161580611c6e57506001600160a01b038516155b15611c8c5760405163538ba4f960e01b815260040160405180910390fd5b6040516370a0823160e01b81523060048201526001600160a01b038716906370a0823190602401602060405180830381865afa158015611cd0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cf49190614587565b9150611d008385614611565b905080341015611d2357604051632fb15b8760e01b815260040160405180910390fd5b94509492505050565b604051637921219560e11b81526001600160a01b038481166004830152306024830152604482018490526064820183905260a06084830152600060a483015286169063f242432a9060c401600060405180830381600087803b158015611d9157600080fd5b505af1158015611da5573d6000803e3d6000fd5b505060405163524fca8b60e11b81526001600160a01b03878116600483015260248201869052604482018590528816925063a49f951691506064015b600060405180830381600087803b158015611dfb57600080fd5b505af1158015611e0f573d6000803e3d6000fd5b505050505050505050565b6060850151855160009081906004811115611e3757611e37613852565b6004811115611e4857611e48613852565b81526020019081526020016000206000611e9787878080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506124c692505050565b6001600160e01b031916815260208101919091526040016000205460ff16611ed2576040516311935f2360e01b815260040160405180910390fd5b600186516004811115611ee757611ee7613852565b03612022576000611ef886866124cd565b810190611f0591906146fa565b905086606001516001600160a01b0316816000015160800151602001516001600160a01b031614611f495760405163029379e760e11b815260040160405180910390fd5b7f0000000000000000000000000000000000000000000000000000000000013e316001600160401b0316816000015160800151608001516001600160401b031614611fa75760405163b466a6f760e01b815260040160405180910390fd5b8660200151600081518110611fbe57611fbe61383c565b602002602001015181600001516020015114611fed5760405163796c29b760e01b815260040160405180910390fd5b805161010001516001600160a01b0316301461201c57604051631613db5360e01b815260040160405180910390fd5b506121bb565b600061202e86866124cd565b81019061203b9190614766565b8051608001515190915060005b818110156121b75788606001516001600160a01b031683600001516080015182815181106120785761207861383c565b6020026020010151602001516001600160a01b0316146120ab57604051633c0f143b60e01b815260040160405180910390fd5b7f0000000000000000000000000000000000000000000000000000000000013e316001600160401b031683600001516080015182815181106120ef576120ef61383c565b6020026020010151608001516001600160401b0316146121225760405163d1ba03c760e01b815260040160405180910390fd5b886020015181815181106121385761213861383c565b6020026020010151836000015160200151828151811061215a5761215a61383c565b6020026020010151146121805760405163e013298b60e01b815260040160405180910390fd5b825161010001516001600160a01b031630146121af576040516318a7b7b160e11b815260040160405180910390fd5b600101612048565b5050505b6121ff8786868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050505060a08901516124e9565b6101008601516040516370a0823160e01b8152306004820152600091906001600160a01b038416906370a0823190602401602060405180830381865afa15801561224d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122719190614587565b61227b91906145ea565b90508060000361229e57604051630f6fa54560e41b815260040160405180910390fd5b60808701516122af906127106145ea565b87604001516122be91906147c6565b6122ca826127106147c6565b10156122e957604051635ebf8da160e11b815260040160405180910390fd5b60006122f68585846128c0565b9050611e0f8984838b60c0015189898080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250612d1592505050565b60405163a22cb46560e01b81526001600160a01b0386811660048301526000602483015287169063a22cb46590604401600060405180830381600087803b15801561238957600080fd5b505af115801561239d573d6000803e3d6000fd5b505050506123ad85858585612d3b565b80341115612425576000336123c283346145ea565b604051600081818185875af1925050503d80600081146123fe576040519150601f19603f3d011682016040523d82523d6000602084013e612403565b606091505b50509050806113595760405163220d375360e01b815260040160405180910390fd5b505050505050565b604051631759616b60e11b81526001600160a01b03861690632eb2c2d69061245f90869030908790879060040161480e565b600060405180830381600087803b15801561247957600080fd5b505af115801561248d573d6000803e3d6000fd5b505060405163a22cb46560e01b81526001600160a01b038781166004830152600160248301528816925063a22cb4659150604401611de1565b6020015190565b3660006124dd8360048187614869565b915091505b9250929050565b600080846001600160a01b031683856040516125059190614893565b60006040518083038185875af1925050503d8060008114612542576040519150601f19603f3d011682016040523d82523d6000602084013e612547565b606091505b50915091506124258282612e5d565b6040516001600160a01b038381166024830152604482018390526125b591859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050612e79565b505050565b336125c784828535612edc565b60008490506000816001600160a01b03166338d52e0f6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561260c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061263091906146dd565b6040516370a0823160e01b815230600482015290915081906000906001600160a01b038316906370a0823190602401602060405180830381865afa15801561267c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126a09190614587565b905060006126ba85858a3560208c013560408d0135612ef1565b905060006126d46126ce60808b018b613868565b846128c0565b905060006126ef600080516020614907833981519152611bbc565b90506127428186848c8e80608001906127089190613868565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250612d1592505050565b61274e81878a87612d3b565b8a6001600160a01b0316886001600160a01b03167f709067c661df529510fce32dc66881c859f62fcbdfa319bbd2ae37745b6903d360405160405180910390a35050505050505050505050565b6040516321f8a72160e01b81527f6b50fa17b77d24e42e27a04b69fe50cd6967cfb767d18de0bd5fe7e1a32aa86860048201526000907f00000000000000000000000017a332dc7b40ae701485023b219e9d6f493a25146001600160a01b0316906321f8a72190602401602060405180830381865afa158015612822573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061284691906146dd565b604051632474521560e21b8152600481018590526001600160a01b03848116602483015291909116906391d1485490604401602060405180830381865afa158015612895573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128b991906148a5565b9392505050565b60008061290285858080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506124c692505050565b6001600160e01b031981166000908152600080516020614927833981519152602052604090205490915060ff1661294c57604051630e4be19360e41b815260040160405180910390fd5b6000634e6233cd60e01b6001600160e01b031983160161299f57600061297287876124cd565b81019061297f91906146fa565b600001519050612997816080015182602001516130de565b935050612ca7565b631a98d1dd60e01b6001600160e01b03198316016129e85760006129c387876124cd565b8101906129d09190614624565b604001519050612997816080015182602001516130de565b6305f09b1560e01b6001600160e01b0319831601612a90576000612a0c87876124cd565b810190612a199190614766565b5160808101515190915060005b81811015612a8857612a7283608001518281518110612a4757612a4761383c565b602002602001015184602001518381518110612a6557612a6561383c565b60200260200101516130de565b9350612a7e8487614611565b9550600101612a26565b505050612ca7565b6377e2bd4560e01b6001600160e01b0319831601612b08576000612ab487876124cd565b810190612ac19190613e75565b6040015160808101515190915060005b81811015612a8857612af283608001518281518110612a4757612a4761383c565b9350612afe8487614611565b9550600101612ad1565b6328f7cb8760e11b6001600160e01b0319831601612ba7576000612b2c87876124cd565b810190612b39919061420f565b60400151805190915060005b81811015612a8857612b91838281518110612b6257612b6261383c565b602002602001015160800151848381518110612b8057612b8061383c565b6020026020010151602001516130de565b9350612b9d8487614611565b9550600101612b45565b63018ac39d60e21b6001600160e01b0319831601612ca7576000612bcb87876124cd565b810190612bd8919061400f565b60400151805190915060005b81811015612ca3576000838281518110612c0057612c0061383c565b60200260200101516080015151905060005b81811015612c9957612c83858481518110612c2f57612c2f61383c565b6020026020010151608001518281518110612c4c57612c4c61383c565b6020026020010151868581518110612c6657612c6661383c565b6020026020010151602001518381518110612a6557612a6561383c565b9550612c8f8689614611565b9750600101612c12565b5050600101612be4565b5050505b83831115612cc857604051631d8363b160e01b815260040160405180910390fd5b600154612cd7906127106145ea565b612ce190856147c6565b612ced846127106147c6565b1015612d0c57604051630201878760e11b815260040160405180910390fd5b50509392505050565b612d296001600160a01b03851686856131fe565b612d348582846124e9565b5050505050565b6040516370a0823160e01b815230600482015260009082906001600160a01b038616906370a0823190602401602060405180830381865afa158015612d84573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612da89190614587565b612db291906145ea565b90508015612dce57612dce6001600160a01b0385168483612556565b604051636eb1769f60e11b81523060048201526001600160a01b0386811660248301526000919086169063dd62ed3e90604401602060405180830381865afa158015612e1e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e429190614587565b1115612d3457612d346001600160a01b0385168660006131fe565b606082612e7257612e6d8261328e565b611c48565b5080611c48565b6000612e8e6001600160a01b038416836132ba565b90508051600014158015612eb3575080806020019051810190612eb191906148a5565b155b156125b557604051635274afe760e01b81526001600160a01b0384166004820152602401611927565b6125b56001600160a01b0384168330846132c8565b6040516370a0823160e01b8152306004820152600090859082906001600160a01b038316906370a0823190602401602060405180830381865afa158015612f3c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f609190614587565b604051635d043b2960e11b815260048101889052306024820181905260448201529091506000906001600160a01b038a169063ba087652906064016020604051808303816000875af1158015612fba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612fde9190614587565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038516906370a0823190602401602060405180830381865afa158015613028573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061304c9190614587565b905061305883826145ea565b9450600a821080613072575061306f600a836145ea565b85105b1561309057604051632a21dd4360e11b815260040160405180910390fd5b61309c866127106145ea565b6130a690886147c6565b6130b2836127106147c6565b10156130d157604051630201878760e11b815260040160405180910390fd5b5050505095945050505050565b815180516000919082036130f4578291506131f7565b6060840151604051633a16cad560e21b815260ff90911660048201527f00000000000000000000000017a332dc7b40ae701485023b219e9d6f493a25146001600160a01b03169063e85b2b5490602401602060405180830381865afa158015613161573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061318591906146dd565b6001600160a01b0316639bbbb5c88260006040518363ffffffff1660e01b81526004016131b39291906148c2565b602060405180830381865afa1580156131d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131f49190614587565b91505b5092915050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b17905261324f8482613301565b6111ea576040516001600160a01b0384811660248301526000604483015261328491869182169063095ea7b390606401612583565b6111ea8482612e79565b80511561329e5780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b50565b60606128b9838360006133a9565b6040516001600160a01b0384811660248301528381166044830152606482018390526111ea9186918216906323b872dd90608401612583565b6000806000846001600160a01b03168460405161331e9190614893565b6000604051808303816000865af19150503d806000811461335b576040519150601f19603f3d011682016040523d82523d6000602084013e613360565b606091505b509150915081801561338a57508051158061338a57508080602001905181019061338a91906148a5565b80156133a057506000856001600160a01b03163b115b95945050505050565b6060814710156133ce5760405163cd78605960e01b8152306004820152602401611927565b600080856001600160a01b031684866040516133ea9190614893565b60006040518083038185875af1925050503d8060008114613427576040519150601f19603f3d011682016040523d82523d6000602084013e61342c565b606091505b509150915061343c868383613446565b9695505050505050565b60608261345b576134568261328e565b6128b9565b815115801561347257506001600160a01b0384163b155b1561349b57604051639996b31560e01b81526001600160a01b0385166004820152602401611927565b50806128b9565b80356001600160e01b0319811681146134ba57600080fd5b919050565b6000602082840312156134d157600080fd5b6128b9826134a2565b600061014082840312156134ed57600080fd5b50919050565b60006020828403121561350557600080fd5b81356001600160401b0381111561351b57600080fd5b6131f4848285016134da565b600061016082840312156134ed57600080fd5b60006020828403121561354c57600080fd5b81356001600160401b0381111561356257600080fd5b6131f484828501613527565b6001600160a01b03811681146132b757600080fd5b80356134ba8161356e565b6000602082840312156135a057600080fd5b81356128b98161356e565b60008083601f8401126135bd57600080fd5b5081356001600160401b038111156135d457600080fd5b6020830191508360208260051b85010111156124e257600080fd5b6000806000806040858703121561360557600080fd5b84356001600160401b038082111561361c57600080fd5b613628888389016135ab565b9096509450602087013591508082111561364157600080fd5b5061364e878288016135ab565b95989497509550505050565b6000806040838503121561366d57600080fd5b82356005811061367c57600080fd5b915061368a602084016134a2565b90509250929050565b60008083601f8401126136a557600080fd5b5081356001600160401b038111156136bc57600080fd5b6020830191508360208285010111156124e257600080fd5b60008060008060008060008060a0898b0312156136f057600080fd5b88356136fb8161356e565b9750602089013561370b8161356e565b965060408901356001600160401b038082111561372757600080fd5b6137338c838d016135ab565b909850965060608b013591508082111561374c57600080fd5b6137588c838d016135ab565b909650945060808b013591508082111561377157600080fd5b5061377e8b828c01613693565b999c989b5096995094979396929594505050565b6000602082840312156137a457600080fd5b5035919050565b60008060008060008060a087890312156137c457600080fd5b86356137cf8161356e565b955060208701356137df8161356e565b9450604087013593506060870135925060808701356001600160401b0381111561380857600080fd5b61381489828a01613693565b979a9699509497509295939492505050565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b6000808335601e1984360301811261387f57600080fd5b8301803591506001600160401b0382111561389957600080fd5b6020019150368190038213156124e257600080fd5b6000808335601e198436030181126138c557600080fd5b8301803591506001600160401b038211156138df57600080fd5b6020019150600581901b36038213156124e257600080fd5b60405161016081016001600160401b038111828210171561391a5761391a613826565b60405290565b604051606081016001600160401b038111828210171561391a5761391a613826565b604051602081016001600160401b038111828210171561391a5761391a613826565b604051601f8201601f191681016001600160401b038111828210171561398c5761398c613826565b604052919050565b60006001600160401b038211156139ad576139ad613826565b5060051b60200190565b803560ff811681146134ba57600080fd5b600082601f8301126139d957600080fd5b813560206139ee6139e983613994565b613964565b8083825260208201915060208460051b870101935086841115613a1057600080fd5b602086015b84811015613a3357613a26816139b7565b8352918301918301613a15565b509695505050505050565b80356001600160401b03811681146134ba57600080fd5b600082601f830112613a6657600080fd5b81356020613a766139e983613994565b8083825260208201915060208460051b870101935086841115613a9857600080fd5b602086015b84811015613a335780358352918301918301613a9d565b600082601f830112613ac557600080fd5b81356001600160401b03811115613ade57613ade613826565b613af1601f8201601f1916602001613964565b818152846020838601011115613b0657600080fd5b816020850160208301376000918101602001919091529392505050565b600060c08284031215613b3557600080fd5b60405160c081016001600160401b038282108183111715613b5857613b58613826565b816040528293508435915080821115613b7057600080fd5b50613b7d85828601613ab4565b8252506020830135613b8e8161356e565b60208201526040830135613ba18161356e565b6040820152613bb2606084016139b7565b6060820152613bc360808401613a3e565b608082015260a083013560a08201525092915050565b600082601f830112613bea57600080fd5b81356020613bfa6139e983613994565b82815260059290921b84018101918181019086841115613c1957600080fd5b8286015b84811015613a335780356001600160401b03811115613c3c5760008081fd5b613c4a8986838b0101613b23565b845250918301918301613c1d565b80151581146132b757600080fd5b80356134ba81613c58565b600082601f830112613c8257600080fd5b81356020613c926139e983613994565b8083825260208201915060208460051b870101935086841115613cb457600080fd5b602086015b84811015613a33578035613ccc81613c58565b8352918301918301613cb9565b60006101608284031215613cec57600080fd5b613cf46138f7565b905081356001600160401b0380821115613d0d57600080fd5b613d1985838601613a55565b83526020840135915080821115613d2f57600080fd5b613d3b85838601613a55565b60208401526040840135915080821115613d5457600080fd5b613d6085838601613a55565b60408401526060840135915080821115613d7957600080fd5b613d8585838601613a55565b60608401526080840135915080821115613d9e57600080fd5b613daa85838601613bd9565b608084015260a0840135915080821115613dc357600080fd5b613dcf85838601613ab4565b60a084015260c0840135915080821115613de857600080fd5b613df485838601613c71565b60c084015260e0840135915080821115613e0d57600080fd5b613e1985838601613c71565b60e08401526101009150613e2e828501613583565b828401526101209150613e42828501613583565b8284015261014091508184013581811115613e5c57600080fd5b613e6886828701613ab4565b8385015250505092915050565b600060208284031215613e8757600080fd5b81356001600160401b0380821115613e9e57600080fd5b9083019060608286031215613eb257600080fd5b613eba613920565b823582811115613ec957600080fd5b613ed5878286016139c8565b825250613ee460208401613a3e565b6020820152604083013582811115613efb57600080fd5b613f0787828601613cd9565b60408301525095945050505050565b6000613f246139e984613994565b8381529050602080820190600585901b840186811115613f4357600080fd5b845b81811015613f7e5780356001600160401b03811115613f645760008081fd5b613f70898289016139c8565b855250928201928201613f45565b505050509392505050565b600082601f830112613f9a57600080fd5b6128b983833560208501613f16565b600082601f830112613fba57600080fd5b81356020613fca6139e983613994565b8083825260208201915060208460051b870101935086841115613fec57600080fd5b602086015b84811015613a335761400281613a3e565b8352918301918301613ff1565b6000602080838503121561402257600080fd5b82356001600160401b038082111561403957600080fd5b908401906060828703121561404d57600080fd5b614055613920565b82358281111561406457600080fd5b61407088828601613f89565b825250838301358281111561408457600080fd5b61409088828601613fa9565b85830152506040830135828111156140a757600080fd5b80840193505086601f8401126140bc57600080fd5b82356140ca6139e982613994565b81815260059190911b840185019085810190898311156140e957600080fd5b8686015b83811015614121578035868111156141055760008081fd5b6141138c8a838b0101613cd9565b8452509187019187016140ed565b5060408401525090979650505050505050565b634e487b7160e01b600052601160045260246000fd5b60006001820161415c5761415c614134565b5060010190565b6000610160828403121561417657600080fd5b61417e6138f7565b90508135815260208201356020820152604082013560408201526060820135606082015260808201356001600160401b03808211156141bc57600080fd5b6141c885838601613b23565b608084015260a08401359150808211156141e157600080fd5b6141ed85838601613ab4565b60a08401526141fe60c08501613c66565b60c0840152613e1960e08501613c66565b6000602080838503121561422257600080fd5b82356001600160401b038082111561423957600080fd5b908401906060828703121561424d57600080fd5b614255613920565b82358281111561426457600080fd5b61427088828601613f89565b825250838301358281111561428457600080fd5b61429088828601613fa9565b85830152506040830135828111156142a757600080fd5b80840193505086601f8401126142bc57600080fd5b82356142ca6139e982613994565b81815260059190911b840185019085810190898311156142e957600080fd5b8686015b83811015614121578035868111156143055760008081fd5b6143138c8a838b0101614163565b8452509187019187016142ed565b60006128b9368484613f16565b600082825180855260208086019550808260051b8401018186016000805b858110156143a257868403601f19018a52825180518086529086019086860190845b8181101561438d57835160ff168352928801929188019160010161436e565b50509a86019a9450509184019160010161434c565b509198975050505050505050565b60008151808452602080850194506020840160005b838110156143ea5781516001600160401b0316875295820195908201906001016143c5565b509495945050505050565b60005b838110156144105781810151838201526020016143f8565b50506000910152565b600081518084526144318160208601602086016143f5565b601f01601f19169290920160200192915050565b600060018060a01b0380861683528460208401526060604084015263ffffffff60e01b845116606084015280602085015116608084015250604083015160a0830152606083015160c0830152608083015160e0808401526144aa61014084018261432e565b905060a0840151605f1980858403016101008601526144c983836143b0565b925060c086015191508085840301610120860152506144e88282614419565b979650505050505050565b81835260006001600160fb1b0383111561450c57600080fd5b8260051b80836020870137939093016020019392505050565b60c08152600061453960c083018a8c6144f3565b828103602084015261454c81898b6144f3565b6001600160a01b039790971660408401525050606081019390935260808301919091526001600160e01b03191660a090910152949350505050565b60006020828403121561459957600080fd5b5051919050565b634e487b7160e01b600052601260045260246000fd5b6000826145c5576145c56145a0565b500490565b60008235609e198336030181126145e057600080fd5b9190910192915050565b81810381811115611c4857611c48614134565b60008261460c5761460c6145a0565b500690565b80820180821115611c4857611c48614134565b60006020828403121561463657600080fd5b81356001600160401b038082111561464d57600080fd5b908301906060828603121561466157600080fd5b614669613920565b82358281111561467857600080fd5b614684878286016139c8565b82525061469360208401613a3e565b60208201526040830135828111156146aa57600080fd5b613f0787828601614163565b6040815260006146ca6040830186886144f3565b82810360208401526144e88185876144f3565b6000602082840312156146ef57600080fd5b81516128b98161356e565b60006020828403121561470c57600080fd5b81356001600160401b038082111561472357600080fd5b908301906020828603121561473757600080fd5b61473f613942565b82358281111561474e57600080fd5b61475a87828601614163565b82525095945050505050565b60006020828403121561477857600080fd5b81356001600160401b038082111561478f57600080fd5b90830190602082860312156147a357600080fd5b6147ab613942565b8235828111156147ba57600080fd5b61475a87828601613cd9565b8082028115828204841417611c4857611c48614134565b60008151808452602080850194506020840160005b838110156143ea578151875295820195908201906001016147f2565b6001600160a01b0385811682528416602082015260a06040820181905260009061483a908301856147dd565b828103606084015261484c81856147dd565b838103608090940193909352505060008152602001949350505050565b6000808585111561487957600080fd5b8386111561488657600080fd5b5050820193919092039150565b600082516145e08184602087016143f5565b6000602082840312156148b757600080fd5b81516128b981613c58565b6040815260006148d56040830185614419565b90508215156020830152939250505056feba0b74768b1de73590a53e1384870dcbc846e5c73bab23c07d71eaa7cbf8411b3a2f5529773e03d975be44bdae98a8509bdf1159e407504e558536cde56cf6acad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5a264697066735822122071261314b1c3ef689a3da2bbcaffd3c3b599fee4a10471bc3047033a769be15e64736f6c63430008170033
Net Worth in USD
Net Worth in ETH
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.