编译器
0.8.23+commit.f704f362
文件 1 的 14:AggregatorV3Interface.sol
pragma solidity ^0.8.0;
interface AggregatorV3Interface {
function decimals() external view returns (uint8);
function description() external view returns (string memory);
function version() external view returns (uint256);
function getRoundData(uint80 _roundId)
external
view
returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);
function latestRoundData()
external
view
returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);
}
文件 2 的 14:ArrayCastLib.sol
pragma solidity ^0.8.23;
import { InitSingleVaultData, InitMultiVaultData, LiqRequest } from "src/types/DataTypes.sol";
library ArrayCastLib {
function castLiqRequestToArray(LiqRequest memory value_) internal pure returns (LiqRequest[] memory values) {
values = new LiqRequest[](1);
values[0] = value_;
}
function castBoolToArray(bool value_) internal pure returns (bool[] memory values) {
values = new bool[](1);
values[0] = value_;
}
function castToMultiVaultData(InitSingleVaultData memory data_)
internal
pure
returns (InitMultiVaultData memory castedData_)
{
uint256[] memory superformIds = new uint256[](1);
superformIds[0] = data_.superformId;
uint256[] memory amounts = new uint256[](1);
amounts[0] = data_.amount;
uint256[] memory outputAmounts = new uint256[](1);
outputAmounts[0] = data_.outputAmount;
uint256[] memory maxSlippage = new uint256[](1);
maxSlippage[0] = data_.maxSlippage;
LiqRequest[] memory liqData = new LiqRequest[](1);
liqData[0] = data_.liqData;
castedData_ = InitMultiVaultData(
data_.payloadId,
superformIds,
amounts,
outputAmounts,
maxSlippage,
liqData,
castBoolToArray(data_.hasDstSwap),
castBoolToArray(data_.retain4626),
data_.receiverAddress,
data_.extraFormData
);
}
}
文件 3 的 14:DataLib.sol
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);
}
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();
}
}
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]);
}
}
function getDestinationChain(uint256 superformId_) internal pure returns (uint64 chainId_) {
chainId_ = uint64(superformId_ >> 192);
if (chainId_ == 0) {
revert Error.INVALID_CHAIN_ID();
}
}
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;
}
}
文件 4 的 14:DataTypes.sol
pragma solidity ^0.8.23;
enum TransactionType {
DEPOSIT,
WITHDRAW
}
enum CallbackType {
INIT,
RETURN,
FAIL
}
enum PayloadState {
STORED,
UPDATED,
PROCESSED
}
struct LiqRequest {
bytes txData;
address token;
address interimToken;
uint8 bridgeId;
uint64 liqDstChainId;
uint256 nativeAmount;
}
struct MultiVaultSFData {
uint256[] superformIds;
uint256[] amounts;
uint256[] outputAmounts;
uint256[] maxSlippages;
LiqRequest[] liqRequests;
bytes permit2data;
bool[] hasDstSwaps;
bool[] retain4626s;
address receiverAddress;
address receiverAddressSP;
bytes extraFormData;
}
struct SingleVaultSFData {
uint256 superformId;
uint256 amount;
uint256 outputAmount;
uint256 maxSlippage;
LiqRequest liqRequest;
bytes permit2data;
bool hasDstSwap;
bool retain4626;
address receiverAddress;
address receiverAddressSP;
bytes extraFormData;
}
struct MultiDstMultiVaultStateReq {
uint8[][] ambIds;
uint64[] dstChainIds;
MultiVaultSFData[] superformsData;
}
struct SingleXChainMultiVaultStateReq {
uint8[] ambIds;
uint64 dstChainId;
MultiVaultSFData superformsData;
}
struct MultiDstSingleVaultStateReq {
uint8[][] ambIds;
uint64[] dstChainIds;
SingleVaultSFData[] superformsData;
}
struct SingleXChainSingleVaultStateReq {
uint8[] ambIds;
uint64 dstChainId;
SingleVaultSFData superformData;
}
struct SingleDirectSingleVaultStateReq {
SingleVaultSFData superformData;
}
struct SingleDirectMultiVaultStateReq {
MultiVaultSFData superformData;
}
struct InitMultiVaultData {
uint256 payloadId;
uint256[] superformIds;
uint256[] amounts;
uint256[] outputAmounts;
uint256[] maxSlippages;
LiqRequest[] liqData;
bool[] hasDstSwaps;
bool[] retain4626s;
address receiverAddress;
bytes extraFormData;
}
struct InitSingleVaultData {
uint256 payloadId;
uint256 superformId;
uint256 amount;
uint256 outputAmount;
uint256 maxSlippage;
LiqRequest liqData;
bool hasDstSwap;
bool retain4626;
address receiverAddress;
bytes extraFormData;
}
struct QueuedWithdrawal {
address receiverAddress;
uint256 superformId;
uint256 amount;
uint256 srcPayloadId;
bool isProcessed;
}
enum TimelockStatus {
UNAVAILABLE,
PENDING,
PROCESSED
}
struct TimelockPayload {
uint8 isXChain;
uint64 srcChainId;
uint256 lockedTill;
InitSingleVaultData data;
TimelockStatus status;
}
struct AMBMessage {
uint256 txInfo;
bytes params;
}
struct BroadcastMessage {
bytes target;
bytes32 messageType;
bytes message;
}
struct ReturnMultiData {
uint256 payloadId;
uint256[] superformIds;
uint256[] amounts;
}
struct ReturnSingleData {
uint256 payloadId;
uint256 superformId;
uint256 amount;
}
struct AMBExtraData {
uint256[] gasPerAMB;
bytes[] extraDataPerAMB;
}
struct BroadCastAMBExtraData {
uint256[] gasPerDst;
bytes[] extraDataPerDst;
}
文件 5 的 14:Error.sol
pragma solidity ^0.8.23;
library Error {
error BLOCK_CHAIN_ID_OUT_OF_BOUNDS();
error CANNOT_REVOKE_NON_BROADCASTABLE_ROLES();
error CANNOT_REVOKE_LAST_ADMIN();
error DISABLED();
error DELAY_NOT_SET();
error INVALID_NATIVE_TOKEN_PRICE();
error REFUND_CHAIN_ID_NOT_SET();
error RELAYER_NOT_SET();
error ROLE_NOT_ASSIGNED();
error INVALID_INTERNAL_CALL();
error NOT_AMB_IMPLEMENTATION();
error NOT_ALLOWED_BROADCASTER();
error NOT_BROADCAST_AMB_IMPLEMENTATION();
error NOT_BROADCAST_REGISTRY();
error NOT_CORE_STATE_REGISTRY();
error NOT_EMERGENCY_ADMIN();
error NOT_EMERGENCY_QUEUE();
error NOT_MINTER();
error NOT_MINTER_STATE_REGISTRY_ROLE();
error NOT_PAYMASTER();
error NOT_PAYMENT_ADMIN();
error NOT_PROTOCOL_ADMIN();
error NOT_STATE_REGISTRY();
error NOT_SUPER_REGISTRY();
error NOT_SUPERFORM_ROUTER();
error NOT_SUPERFORM();
error NOT_SUPERFORM_FACTORY();
error NOT_TIMELOCK_SUPERFORM();
error NOT_TIMELOCK_STATE_REGISTRY();
error NOT_VALID_DISPUTER();
error NOT_PRIVILEGED_CALLER(bytes32 role);
error CALLER_NOT_ENDPOINT();
error CALLER_NOT_MAILBOX();
error CALLER_NOT_RELAYER();
error INVALID_SRC_SENDER();
error ARRAY_LENGTH_MISMATCH();
error INVALID_PAYLOAD_ID();
error MSG_VALUE_NOT_ZERO();
error ZERO_AMB_ID_LENGTH();
error ZERO_ADDRESS();
error ZERO_AMOUNT();
error ZERO_FINAL_TOKEN();
error ZERO_INPUT_VALUE();
error INVALID_SUPERFORMS_DATA();
error RECEIVER_ADDRESS_NOT_SET();
error ERC165_UNSUPPORTED();
error FORM_INTERFACE_UNSUPPORTED();
error FORM_IMPLEMENTATION_ALREADY_EXISTS();
error FORM_IMPLEMENTATION_ID_ALREADY_EXISTS();
error FORM_DOES_NOT_EXIST();
error INVALID_FORM_ID();
error SUPERFORM_ID_NONEXISTENT();
error VAULT_FORM_IMPLEMENTATION_COMBINATION_EXISTS();
error DIFFERENT_TOKENS();
error DIRECT_WITHDRAW_INVALID_LIQ_REQUEST();
error XCHAIN_WITHDRAW_INVALID_LIQ_REQUEST();
error BLACKLISTED_ROUTE_ID();
error NOT_BLACKLISTED_ROUTE_ID();
error BLACKLISTED_SELECTOR();
error NOT_BLACKLISTED_SELECTOR();
error INVALID_ACTION();
error INVALID_DEPOSIT_LIQ_DST_CHAIN_ID();
error INVALID_INDEX();
error INVALID_TXDATA_CHAIN_ID();
error INVALID_TXDATA_NO_DESTINATIONCALL_ALLOWED();
error INVALID_TXDATA_RECEIVER();
error INVALID_TXDATA_TOKEN();
error NO_TXDATA_PRESENT();
error DIFFERENT_PAYLOAD_UPDATE_AMOUNTS_LENGTH();
error DIFFERENT_PAYLOAD_UPDATE_TX_DATA_LENGTH();
error INVALID_UPDATE_FINAL_TOKEN();
error INVALID_BROADCAST_FINALITY();
error INVALID_BRIDGE_ID();
error INVALID_CHAIN_ID();
error INVALID_DST_SWAP_AMOUNT();
error INVALID_PROOF_BRIDGE_ID();
error INVALID_PROOF_BRIDGE_IDS();
error INVALID_RESCUE_DATA();
error INVALID_TIMELOCK_DELAY();
error NEGATIVE_SLIPPAGE();
error SLIPPAGE_OUT_OF_BOUNDS();
error SRC_SENDER_MISMATCH();
error SRC_TX_TYPE_MISMATCH();
error DIRECT_DEPOSIT_SWAP_FAILED();
error DUPLICATE_PAYLOAD();
error FAILED_TO_SEND_NATIVE();
error INSUFFICIENT_ALLOWANCE_FOR_DEPOSIT();
error INSUFFICIENT_BALANCE();
error INSUFFICIENT_NATIVE_AMOUNT();
error INVALID_PAYLOAD();
error INVALID_PAYLOAD_STATUS();
error INVALID_PAYLOAD_TYPE();
error CANNOT_DECODE_FINAL_SWAP_OUTPUT_TOKEN();
error FAILED_TO_EXECUTE_TXDATA(address token);
error INVALID_DEPOSIT_TOKEN();
error BRIDGE_TOKENS_PENDING();
error CANNOT_UPDATE_WITHDRAW_TX_DATA();
error DISPUTE_TIME_ELAPSED();
error INSUFFICIENT_QUORUM();
error INVALID_BROADCAST_PAYLOAD();
error INVALID_BROADCAST_FEE();
error INVALID_RETRY_FEE();
error INVALID_MESSAGE_TYPE();
error INVALID_PAYLOAD_HASH();
error INVALID_PAYLOAD_UPDATE_REQUEST();
error INVALID_REGISTRY_ID();
error INVALID_FORM_REGISTRY_ID();
error LOCKED();
error PAYLOAD_ALREADY_UPDATED();
error PAYLOAD_ALREADY_PROCESSED();
error PAYLOAD_NOT_UPDATED();
error RESCUE_LOCKED();
error RESCUE_ALREADY_PROPOSED();
error ZERO_PAYLOAD_HASH();
error DST_SWAP_ALREADY_PROCESSED();
error DUPLICATE_INDEX();
error FAILED_DST_SWAP_ALREADY_UPDATED();
error INDEX_OUT_OF_BOUNDS();
error INVALID_DST_SWAPPER_FAILED_SWAP();
error INVALID_DST_SWAPPER_FAILED_SWAP_NO_TOKEN_BALANCE();
error INVALID_DST_SWAPPER_FAILED_SWAP_NO_NATIVE_BALANCE();
error INVALID_INTERIM_TOKEN();
error INVALID_SWAP_OUTPUT();
error CANNOT_FORWARD_4646_TOKEN();
error NO_VALID_KYC_TOKEN();
error NOT_IMPLEMENTED();
error PAUSED();
error VAULT_IMPLEMENTATION_FAILED();
error WITHDRAW_TOKEN_NOT_UPDATED();
error WITHDRAW_TX_DATA_NOT_UPDATED();
error WITHDRAW_ZERO_COLLATERAL();
error CHAINLINK_MALFUNCTION();
error CHAINLINK_INCOMPLETE_ROUND();
error CHAINLINK_UNSUPPORTED_DECIMAL();
error EMERGENCY_WITHDRAW_NOT_QUEUED();
error EMERGENCY_WITHDRAW_PROCESSED_ALREADY();
error DYNAMIC_URI_FROZEN();
error TX_HISTORY_NOT_FOUND();
}
文件 6 的 14:IAccessControl.sol
pragma solidity ^0.8.20;
interface IAccessControl {
error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);
error AccessControlBadConfirmation();
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
function hasRole(bytes32 role, address account) external view returns (bool);
function getRoleAdmin(bytes32 role) external view returns (bytes32);
function grantRole(bytes32 role, address account) external;
function revokeRole(bytes32 role, address account) external;
function renounceRole(bytes32 role, address callerConfirmation) external;
}
文件 7 的 14:IAmbImplementation.sol
pragma solidity ^0.8.23;
interface IAmbImplementation {
event ChainAdded(uint64 indexed superChainId);
event AuthorizedImplAdded(uint64 indexed superChainId, address indexed authImpl);
function estimateFees(
uint64 dstChainId_,
bytes memory message_,
bytes memory extraData_
)
external
view
returns (uint256 fees);
function generateExtraData(uint256 gasLimit) external pure returns (bytes memory extraData);
function dispatchPayload(
address srcSender_,
uint64 dstChainId_,
bytes memory message_,
bytes memory extraData_
)
external
payable;
function retryPayload(bytes memory data_) external payable;
}
文件 8 的 14:IBaseStateRegistry.sol
pragma solidity ^0.8.23;
import { PayloadState } from "src/types/DataTypes.sol";
interface IBaseStateRegistry {
event PayloadReceived(uint64 indexed srcChainId, uint64 indexed dstChainId, uint256 indexed payloadId);
event ProofReceived(bytes32 indexed proof);
event PayloadUpdated(uint256 indexed payloadId);
event PayloadProcessed(uint256 indexed payloadId);
event SuperRegistryUpdated(address indexed superRegistry);
function payloadsCount() external view returns (uint256);
function payloadTracking(uint256 payloadId_) external view returns (PayloadState payloadState_);
function payloadBody(uint256 payloadId_) external view returns (bytes memory payloadBody_);
function payloadHeader(uint256 payloadId_) external view returns (uint256 payloadHeader_);
function getMessageAMB(uint256 payloadId_) external view returns (uint8[] memory ambIds_);
function dispatchPayload(
address srcSender_,
uint8[] memory ambIds_,
uint64 dstChainId_,
bytes memory message_,
bytes memory extraData_
)
external
payable;
function receivePayload(uint64 srcChainId_, bytes memory message_) external;
function processPayload(uint256 payloadId_) external payable;
}
文件 9 的 14:IPaymentHelperV2.sol
pragma solidity ^0.8.23;
import {
MultiDstMultiVaultStateReq,
MultiDstSingleVaultStateReq,
SingleXChainMultiVaultStateReq,
SingleXChainSingleVaultStateReq,
SingleDirectSingleVaultStateReq,
SingleDirectMultiVaultStateReq
} from "src/types/DataTypes.sol";
interface IPaymentHelperV2 {
struct PaymentHelperConfig {
address nativeFeedOracle;
address gasPriceOracle;
uint256 swapGasUsed;
uint256 updateDepositGasUsed;
uint256 depositGasUsed;
uint256 withdrawGasUsed;
uint256 defaultNativePrice;
uint256 defaultGasPrice;
uint256 dstGasPerByte;
uint256 ackGasCost;
uint256 timelockCost;
uint256 emergencyCost;
uint256 updateWithdrawGasUsed;
}
event ChainConfigUpdated(uint64 indexed chainId_, uint256 indexed configType_, bytes config_);
event ChainConfigAdded(uint64 chainId_, PaymentHelperConfig config_);
function calculateAMBData(
uint64 dstChainId_,
uint8[] calldata ambIds_,
bytes memory message_
)
external
view
returns (uint256 totalFees, bytes memory extraData);
function getRegisterTransmuterAMBData() external view returns (bytes memory extraData);
function estimateMultiDstMultiVault(
MultiDstMultiVaultStateReq calldata req_,
bool isDeposit_
)
external
view
returns (uint256 liqAmount, uint256 srcAmount, uint256 dstAmount, uint256 totalAmount);
function estimateMultiDstSingleVault(
MultiDstSingleVaultStateReq calldata req_,
bool isDeposit_
)
external
view
returns (uint256 liqAmount, uint256 srcAmount, uint256 dstAmount, uint256 totalAmount);
function estimateSingleXChainMultiVault(
SingleXChainMultiVaultStateReq calldata req_,
bool isDeposit_
)
external
view
returns (uint256 liqAmount, uint256 srcAmount, uint256 dstAmount, uint256 totalAmount);
function estimateSingleXChainSingleVault(
SingleXChainSingleVaultStateReq calldata req_,
bool isDeposit_
)
external
view
returns (uint256 liqAmount, uint256 srcAmount, uint256 dstAmount, uint256 totalAmount);
function estimateSingleDirectSingleVault(
SingleDirectSingleVaultStateReq calldata req_,
bool isDeposit_
)
external
view
returns (uint256 liqAmount, uint256 srcAmount, uint256 totalAmount);
function estimateSingleDirectMultiVault(
SingleDirectMultiVaultStateReq calldata req_,
bool isDeposit_
)
external
view
returns (uint256 liqAmount, uint256 srcAmount, uint256 totalAmount);
function estimateAMBFees(
uint8[] memory ambIds_,
uint64 dstChainId_,
bytes memory message_,
bytes[] memory extraData_
)
external
view
returns (uint256 ambFees, uint256[] memory);
function estimateAckCost(uint256 payloadId_) external view returns (uint256 totalFees);
function estimateAckCostDefault(
bool multi,
uint8[] memory ackAmbIds,
uint64 srcChainId
)
external
view
returns (uint256 totalFees);
function estimateAckCostDefaultNativeSource(
bool multi,
uint8[] memory ackAmbIds,
uint64 srcChainId
)
external
view
returns (uint256 totalFees);
function addRemoteChain(uint64 chainId_, PaymentHelperConfig calldata config_) external;
function addRemoteChains(uint64[] calldata chainIds_, PaymentHelperConfig[] calldata configs_) external;
function updateRemoteChain(uint64 chainId_, uint256 configType_, bytes memory config_) external;
function batchUpdateRemoteChain(
uint64 chainId_,
uint256[] calldata configTypes_,
bytes[] calldata configs_
)
external;
function batchUpdateRemoteChains(
uint64[] calldata chainIds_,
uint256[][] calldata configTypes_,
bytes[][] calldata configs_
)
external;
function updateRegisterAERC20Params(bytes memory extraDataForTransmuter_) external;
}
文件 10 的 14:ISuperRBAC.sol
pragma solidity ^0.8.23;
import { IAccessControl } from "openzeppelin-contracts/contracts/access/IAccessControl.sol";
interface ISuperRBAC is IAccessControl {
struct InitialRoleSetup {
address admin;
address emergencyAdmin;
address paymentAdmin;
address csrProcessor;
address tlProcessor;
address brProcessor;
address csrUpdater;
address srcVaaRelayer;
address dstSwapper;
address csrRescuer;
address csrDisputer;
}
event SuperRegistrySet(address indexed superRegistry);
event RoleAdminSet(bytes32 role, bytes32 adminRole);
function PROTOCOL_ADMIN_ROLE() external view returns (bytes32);
function EMERGENCY_ADMIN_ROLE() external view returns (bytes32);
function PAYMENT_ADMIN_ROLE() external view returns (bytes32);
function BROADCASTER_ROLE() external view returns (bytes32);
function CORE_STATE_REGISTRY_PROCESSOR_ROLE() external view returns (bytes32);
function TIMELOCK_STATE_REGISTRY_PROCESSOR_ROLE() external view returns (bytes32);
function BROADCAST_STATE_REGISTRY_PROCESSOR_ROLE() external view returns (bytes32);
function CORE_STATE_REGISTRY_UPDATER_ROLE() external view returns (bytes32);
function DST_SWAPPER_ROLE() external view returns (bytes32);
function CORE_STATE_REGISTRY_RESCUER_ROLE() external view returns (bytes32);
function CORE_STATE_REGISTRY_DISPUTER_ROLE() external view returns (bytes32);
function WORMHOLE_VAA_RELAYER_ROLE() external view returns (bytes32);
function hasProtocolAdminRole(address admin_) external view returns (bool);
function hasEmergencyAdminRole(address admin_) external view returns (bool);
function setSuperRegistry(address superRegistry_) external;
function setRoleAdmin(bytes32 role_, bytes32 adminRole_) external;
function revokeRoleSuperBroadcast(
bytes32 role_,
bytes memory extraData_,
bytes32 superRegistryAddressId_
)
external
payable;
function stateSyncBroadcast(bytes memory data_) external;
}
文件 11 的 14:ISuperRegistry.sol
pragma solidity ^0.8.23;
interface ISuperRegistry {
event SetPermit2(address indexed permit2);
event AddressUpdated(
bytes32 indexed protocolAddressId, uint64 indexed chainId, address indexed oldAddress, address newAddress
);
event SetBridgeAddress(uint256 indexed bridgeId, address indexed bridgeAddress);
event SetBridgeValidator(uint256 indexed bridgeId, address indexed bridgeValidator);
event SetAmbAddress(uint8 indexed ambId_, address indexed ambAddress_, bool indexed isBroadcastAMB_);
event SetStateRegistryAddress(uint8 indexed registryId_, address indexed registryAddress_);
event SetDelay(uint256 indexed oldDelay_, uint256 indexed newDelay_);
event SetVaultLimitPerDestination(uint64 indexed chainId_, uint256 indexed vaultLimit_);
function delay() external view returns (uint256);
function PERMIT2() external view returns (address);
function SUPERFORM_ROUTER() external view returns (bytes32);
function SUPERFORM_FACTORY() external view returns (bytes32);
function PAYMASTER() external view returns (bytes32);
function PAYMENT_HELPER() external view returns (bytes32);
function CORE_STATE_REGISTRY() external view returns (bytes32);
function TIMELOCK_STATE_REGISTRY() external view returns (bytes32);
function BROADCAST_REGISTRY() external view returns (bytes32);
function SUPER_POSITIONS() external view returns (bytes32);
function SUPER_RBAC() external view returns (bytes32);
function PAYLOAD_HELPER() external view returns (bytes32);
function DST_SWAPPER() external view returns (bytes32);
function EMERGENCY_QUEUE() external view returns (bytes32);
function SUPERFORM_RECEIVER() external view returns (bytes32);
function PAYMENT_ADMIN() external view returns (bytes32);
function CORE_REGISTRY_PROCESSOR() external view returns (bytes32);
function BROADCAST_REGISTRY_PROCESSOR() external view returns (bytes32);
function TIMELOCK_REGISTRY_PROCESSOR() external view returns (bytes32);
function CORE_REGISTRY_UPDATER() external view returns (bytes32);
function CORE_REGISTRY_RESCUER() external view returns (bytes32);
function CORE_REGISTRY_DISPUTER() external view returns (bytes32);
function DST_SWAPPER_PROCESSOR() external view returns (bytes32);
function getAddress(bytes32 id_) external view returns (address);
function getAddressByChainId(bytes32 id_, uint64 chainId_) external view returns (address);
function getBridgeAddress(uint8 bridgeId_) external view returns (address bridgeAddress_);
function getBridgeValidator(uint8 bridgeId_) external view returns (address bridgeValidator_);
function getAmbAddress(uint8 ambId_) external view returns (address ambAddress_);
function getAmbId(address ambAddress_) external view returns (uint8 ambId_);
function getStateRegistry(uint8 registryId_) external view returns (address registryAddress_);
function getStateRegistryId(address registryAddress_) external view returns (uint8 registryId_);
function getVaultLimitPerDestination(uint64 chainId_) external view returns (uint256 vaultLimitPerDestination_);
function isValidStateRegistry(address registryAddress_) external view returns (bool valid_);
function isValidAmbImpl(address ambAddress_) external view returns (bool valid_);
function isValidBroadcastAmbImpl(address ambAddress_) external view returns (bool valid_);
function setDelay(uint256 delay_) external;
function setPermit2(address permit2_) external;
function setVaultLimitPerDestination(uint64 chainId_, uint256 vaultLimit_) external;
function batchSetAddress(
bytes32[] calldata ids_,
address[] calldata newAddresses_,
uint64[] calldata chainIds_
)
external;
function setAddress(bytes32 id_, address newAddress_, uint64 chainId_) external;
function setBridgeAddresses(
uint8[] memory bridgeId_,
address[] memory bridgeAddress_,
address[] memory bridgeValidator_
)
external;
function setAmbAddress(
uint8[] memory ambId_,
address[] memory ambAddress_,
bool[] memory isBroadcastAMB_
)
external;
function setStateRegistryAddress(uint8[] memory registryId_, address[] memory registryAddress_) external;
}
文件 12 的 14:ISuperformFactory.sol
pragma solidity ^0.8.23;
interface ISuperformFactory {
enum PauseStatus {
NON_PAUSED,
PAUSED
}
event FormImplementationAdded(
address indexed formImplementation, uint256 indexed formImplementationId, uint8 indexed formStateRegistryId
);
event SuperformCreated(
uint256 indexed formImplementationId, address indexed vault, uint256 indexed superformId, address superform
);
event SuperRegistrySet(address indexed superRegistry);
event FormImplementationPaused(uint256 indexed formImplementationId, PauseStatus indexed paused);
function getFormCount() external view returns (uint256 forms_);
function getSuperformCount() external view returns (uint256 superforms_);
function getFormImplementation(uint32 formImplementationId_) external view returns (address formImplementation_);
function getFormStateRegistryId(uint32 formImplementationId_) external view returns (uint8 stateRegistryId_);
function isFormImplementationPaused(uint32 formImplementationId_) external view returns (bool paused_);
function getSuperform(uint256 superformId_)
external
pure
returns (address superform_, uint32 formImplementationId_, uint64 chainId_);
function isSuperform(uint256 superformId_) external view returns (bool isSuperform_);
function getAllSuperformsFromVault(address vault_)
external
view
returns (uint256[] memory superformIds_, address[] memory superforms_);
function addFormImplementation(
address formImplementation_,
uint32 formImplementationId_,
uint8 formStateRegistryId_
)
external;
function createSuperform(
uint32 formImplementationId_,
address vault_
)
external
returns (uint256 superformId_, address superform_);
function stateSyncBroadcast(bytes memory data_) external payable;
function changeFormImplementationPauseStatus(
uint32 formImplementationId_,
PauseStatus status_,
bytes memory extraData_
)
external
payable;
}
文件 13 的 14:PaymentHelper.sol
pragma solidity ^0.8.23;
import { IPaymentHelperV2 as IPaymentHelper } from "src/interfaces/IPaymentHelperV2.sol";
import { ISuperRBAC } from "src/interfaces/ISuperRBAC.sol";
import { ISuperRegistry } from "src/interfaces/ISuperRegistry.sol";
import { ISuperformFactory } from "src/interfaces/ISuperformFactory.sol";
import { IBaseStateRegistry } from "src/interfaces/IBaseStateRegistry.sol";
import { IAmbImplementation } from "src/interfaces/IAmbImplementation.sol";
import { Error } from "src/libraries/Error.sol";
import { DataLib } from "src/libraries/DataLib.sol";
import { ProofLib } from "src/libraries/ProofLib.sol";
import { ArrayCastLib } from "src/libraries/ArrayCastLib.sol";
import {
SingleDirectSingleVaultStateReq,
SingleXChainSingleVaultStateReq,
SingleDirectMultiVaultStateReq,
SingleXChainMultiVaultStateReq,
MultiDstSingleVaultStateReq,
MultiDstMultiVaultStateReq,
LiqRequest,
AMBMessage,
MultiVaultSFData,
SingleVaultSFData,
AMBExtraData,
InitMultiVaultData,
InitSingleVaultData,
ReturnMultiData,
ReturnSingleData
} from "src/types/DataTypes.sol";
import { AggregatorV3Interface } from "src/vendor/chainlink/AggregatorV3Interface.sol";
interface ReadOnlyBaseRegistry is IBaseStateRegistry {
function payloadsCount() external view returns (uint256);
}
contract PaymentHelper is IPaymentHelper {
using DataLib for uint256;
using ArrayCastLib for LiqRequest;
using ArrayCastLib for bool;
using ProofLib for bytes;
using ProofLib for AMBMessage;
uint256 private constant PROOF_LENGTH = 160;
uint8 private constant SUPPORTED_FEED_PRECISION = 8;
uint32 private constant TIMELOCK_FORM_ID = 2;
uint256 private constant MAX_UINT256 = type(uint256).max;
ISuperRegistry public immutable superRegistry;
uint64 public immutable CHAIN_ID;
mapping(uint64 chainId => AggregatorV3Interface) public nativeFeedOracle;
mapping(uint64 chainId => AggregatorV3Interface) public gasPriceOracle;
mapping(uint64 chainId => uint256 gasForSwap) public swapGasUsed;
mapping(uint64 chainId => uint256 gasForUpdateDeposit) public updateDepositGasUsed;
mapping(uint64 chainId => uint256 gasForUpdateWithdraw) public updateWithdrawGasUsed;
mapping(uint64 chainId => uint256 gasForDeposit) public depositGasUsed;
mapping(uint64 chainId => uint256 gasForWithdraw) public withdrawGasUsed;
mapping(uint64 chainId => uint256 defaultNativePrice) public nativePrice;
mapping(uint64 chainId => uint256 defaultGasPrice) public gasPrice;
mapping(uint64 chainId => uint256 gasPerByte) public gasPerByte;
mapping(uint64 chainId => uint256 gasForAck) public ackGasCost;
mapping(uint64 chainId => uint256 gasForTimelock) public timelockCost;
mapping(uint64 chainId => uint256 gasForEmergency) public emergencyCost;
bytes public extraDataForTransmuter;
struct EstimateAckCostVars {
uint256 currPayloadId;
uint256 payloadHeader;
uint8 callbackType;
bytes payloadBody;
uint8[] ackAmbIds;
uint8 isMulti;
uint64 srcChainId;
bytes message;
}
struct LocalEstimateVars {
uint256 len;
uint256 superformIdsLen;
uint256 totalGas;
uint256 ambFees;
bool paused;
}
struct CalculateAmountsReq {
uint256 i;
uint64[] dstChainIds;
uint8[] ambIds;
MultiVaultSFData[] superformsData;
SingleVaultSFData[] superformData;
ISuperformFactory factory;
bool isDeposit;
}
modifier onlyProtocolAdmin() {
if (!ISuperRBAC(_getAddress(keccak256("SUPER_RBAC"))).hasProtocolAdminRole(msg.sender)) {
revert Error.NOT_PROTOCOL_ADMIN();
}
_;
}
modifier onlyPaymentAdmin() {
if (
!ISuperRBAC(superRegistry.getAddress(keccak256("SUPER_RBAC"))).hasRole(
keccak256("PAYMENT_ADMIN_ROLE"), msg.sender
)
) {
revert Error.NOT_PAYMENT_ADMIN();
}
_;
}
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_);
}
function calculateAMBData(
uint64 dstChainId_,
uint8[] calldata ambIds_,
bytes memory message_
)
external
view
override
returns (uint256 totalFees, bytes memory extraData)
{
(uint256[] memory gasPerAMB, bytes[] memory extraDataPerAMB, uint256 fees) =
_estimateAMBFeesReturnExtraData(dstChainId_, ambIds_, message_);
extraData = abi.encode(AMBExtraData(gasPerAMB, extraDataPerAMB));
totalFees = fees;
}
function getRegisterTransmuterAMBData() external view override returns (bytes memory) {
return extraDataForTransmuter;
}
function estimateMultiDstMultiVault(
MultiDstMultiVaultStateReq calldata req_,
bool isDeposit_
)
external
view
override
returns (uint256 liqAmount, uint256 srcAmount, uint256 dstAmount, uint256 totalAmount)
{
uint256 len = req_.dstChainIds.length;
uint256 liqAmountIndex;
uint256 srcAmountIndex;
uint256 dstAmountIndex;
ISuperformFactory factory = ISuperformFactory(_getAddress(keccak256("SUPERFORM_FACTORY")));
SingleVaultSFData[] memory temp;
for (uint256 i; i < len; ++i) {
(liqAmountIndex, srcAmountIndex, dstAmountIndex) = _calculateAmounts(
CalculateAmountsReq(i, req_.dstChainIds, req_.ambIds[i], req_.superformsData, temp, factory, isDeposit_)
);
liqAmount += liqAmountIndex;
srcAmount += srcAmountIndex;
dstAmount += dstAmountIndex;
}
totalAmount = srcAmount + dstAmount + liqAmount;
}
function estimateMultiDstSingleVault(
MultiDstSingleVaultStateReq calldata req_,
bool isDeposit_
)
external
view
override
returns (uint256 liqAmount, uint256 srcAmount, uint256 dstAmount, uint256 totalAmount)
{
uint256 len = req_.dstChainIds.length;
uint256 liqAmountIndex;
uint256 srcAmountIndex;
uint256 dstAmountIndex;
ISuperformFactory factory = ISuperformFactory(_getAddress(keccak256("SUPERFORM_FACTORY")));
MultiVaultSFData[] memory temp;
for (uint256 i; i < len; ++i) {
(liqAmountIndex, srcAmountIndex, dstAmountIndex) = _calculateAmounts(
CalculateAmountsReq(i, req_.dstChainIds, req_.ambIds[i], temp, req_.superformsData, factory, isDeposit_)
);
liqAmount += liqAmountIndex;
srcAmount += srcAmountIndex;
dstAmount += dstAmountIndex;
}
totalAmount = srcAmount + dstAmount + liqAmount;
}
function estimateSingleXChainMultiVault(
SingleXChainMultiVaultStateReq calldata req_,
bool isDeposit_
)
external
view
override
returns (uint256 liqAmount, uint256 srcAmount, uint256 dstAmount, uint256 totalAmount)
{
ISuperformFactory factory = ISuperformFactory(_getAddress(keccak256("SUPERFORM_FACTORY")));
uint64[] memory dstChainIds = new uint64[](1);
dstChainIds[0] = req_.dstChainId;
SingleVaultSFData[] memory temp;
MultiVaultSFData[] memory sfData = new MultiVaultSFData[](1);
sfData[0] = req_.superformsData;
(liqAmount, srcAmount, dstAmount) =
_calculateAmounts(CalculateAmountsReq(0, dstChainIds, req_.ambIds, sfData, temp, factory, isDeposit_));
totalAmount = srcAmount + dstAmount + liqAmount;
}
function estimateSingleXChainSingleVault(
SingleXChainSingleVaultStateReq calldata req_,
bool isDeposit_
)
external
view
override
returns (uint256 liqAmount, uint256 srcAmount, uint256 dstAmount, uint256 totalAmount)
{
ISuperformFactory factory = ISuperformFactory(_getAddress(keccak256("SUPERFORM_FACTORY")));
uint64[] memory dstChainIds = new uint64[](1);
dstChainIds[0] = req_.dstChainId;
MultiVaultSFData[] memory temp;
SingleVaultSFData[] memory sfData = new SingleVaultSFData[](1);
sfData[0] = req_.superformData;
(liqAmount, srcAmount, dstAmount) =
_calculateAmounts(CalculateAmountsReq(0, dstChainIds, req_.ambIds, temp, sfData, factory, isDeposit_));
totalAmount = srcAmount + dstAmount + liqAmount;
}
function estimateSingleDirectSingleVault(
SingleDirectSingleVaultStateReq calldata req_,
bool isDeposit_
)
external
view
override
returns (uint256 liqAmount, uint256 dstOrSameChainAmt, uint256 totalAmount)
{
ISuperformFactory factory = ISuperformFactory(_getAddress(keccak256("SUPERFORM_FACTORY")));
uint64[] memory dstChainIds = new uint64[](1);
dstChainIds[0] = CHAIN_ID;
SingleVaultSFData[] memory sfData = new SingleVaultSFData[](1);
sfData[0] = req_.superformData;
MultiVaultSFData[] memory temp;
uint8[] memory ambIds;
(liqAmount,, dstOrSameChainAmt) =
_calculateAmounts(CalculateAmountsReq(0, dstChainIds, ambIds, temp, sfData, factory, isDeposit_));
totalAmount = liqAmount + dstOrSameChainAmt;
}
function estimateSingleDirectMultiVault(
SingleDirectMultiVaultStateReq calldata req_,
bool isDeposit_
)
external
view
override
returns (uint256 liqAmount, uint256 dstOrSameChainAmt, uint256 totalAmount)
{
ISuperformFactory factory = ISuperformFactory(_getAddress(keccak256("SUPERFORM_FACTORY")));
uint64[] memory dstChainIds = new uint64[](1);
dstChainIds[0] = CHAIN_ID;
SingleVaultSFData[] memory temp;
MultiVaultSFData[] memory sfData = new MultiVaultSFData[](1);
sfData[0] = req_.superformData;
uint8[] memory ambIds;
(liqAmount,, dstOrSameChainAmt) =
_calculateAmounts(CalculateAmountsReq(0, dstChainIds, ambIds, sfData, temp, factory, isDeposit_));
totalAmount = liqAmount + dstOrSameChainAmt;
}
function estimateAMBFees(
uint8[] memory ambIds_,
uint64 dstChainId_,
bytes memory message_,
bytes[] memory extraData_
)
public
view
override
returns (uint256 totalFees, uint256[] memory)
{
uint256 len = ambIds_.length;
uint256[] memory fees = new uint256[](len);
if (CHAIN_ID != dstChainId_) {
for (uint256 i; i < len; ++i) {
fees[i] = IAmbImplementation(superRegistry.getAmbAddress(ambIds_[i])).estimateFees(
dstChainId_, message_, extraData_[i]
);
totalFees += fees[i];
}
}
return (totalFees, fees);
}
function estimateAckCost(uint256 payloadId_) external view override returns (uint256 totalFees) {
EstimateAckCostVars memory v;
IBaseStateRegistry coreStateRegistry = IBaseStateRegistry(_getAddress(keccak256("CORE_STATE_REGISTRY")));
v.currPayloadId = coreStateRegistry.payloadsCount();
if (payloadId_ > v.currPayloadId) revert Error.INVALID_PAYLOAD_ID();
v.payloadHeader = coreStateRegistry.payloadHeader(payloadId_);
v.payloadBody = coreStateRegistry.payloadBody(payloadId_);
(, v.callbackType, v.isMulti,,, v.srcChainId) = DataLib.decodeTxInfo(v.payloadHeader);
if (v.callbackType != 0) return 0;
if (v.isMulti == 1) {
InitMultiVaultData memory data = abi.decode(v.payloadBody, (InitMultiVaultData));
v.payloadBody = abi.encode(ReturnMultiData(v.currPayloadId, data.superformIds, data.amounts));
} else {
InitSingleVaultData memory data = abi.decode(v.payloadBody, (InitSingleVaultData));
v.payloadBody = abi.encode(ReturnSingleData(v.currPayloadId, data.superformId, data.amount));
}
v.ackAmbIds = coreStateRegistry.getMessageAMB(payloadId_);
v.message = abi.encode(AMBMessage(coreStateRegistry.payloadHeader(payloadId_), v.payloadBody));
return _estimateAMBFees(v.ackAmbIds, v.srcChainId, v.message);
}
function estimateAckCostDefault(
bool multi,
uint8[] memory ackAmbIds,
uint64 srcChainId
)
public
view
override
returns (uint256 totalFees)
{
bytes memory payloadBody;
if (multi) {
uint256 vaultLimitPerDst = superRegistry.getVaultLimitPerDestination(srcChainId);
uint256[] memory maxUints = new uint256[](vaultLimitPerDst);
for (uint256 i; i < vaultLimitPerDst; ++i) {
maxUints[i] = type(uint256).max;
}
payloadBody = abi.encode(ReturnMultiData(type(uint256).max, maxUints, maxUints));
} else {
payloadBody = abi.encode(ReturnSingleData(type(uint256).max, type(uint256).max, type(uint256).max));
}
return _estimateAMBFees(ackAmbIds, srcChainId, abi.encode(AMBMessage(type(uint256).max, payloadBody)));
}
function estimateAckCostDefaultNativeSource(
bool multi,
uint8[] memory ackAmbIds,
uint64 srcChainId
)
external
view
override
returns (uint256)
{
return _convertToSrcNativeAmount(srcChainId, estimateAckCostDefault(multi, ackAmbIds, srcChainId));
}
function addRemoteChain(uint64 chainId_, PaymentHelperConfig calldata config_) public override onlyProtocolAdmin {
_addRemoteChain(chainId_, config_);
}
function addRemoteChains(
uint64[] calldata chainIds_,
PaymentHelperConfig[] calldata configs_
)
external
override
onlyProtocolAdmin
{
uint256 len = chainIds_.length;
if (len == 0) revert Error.ZERO_INPUT_VALUE();
if (len != configs_.length) revert Error.ARRAY_LENGTH_MISMATCH();
for (uint256 i; i < len; ++i) {
_addRemoteChain(chainIds_[i], configs_[i]);
}
}
function updateRemoteChain(
uint64 chainId_,
uint256 configType_,
bytes memory config_
)
external
override
onlyPaymentAdmin
{
_updateRemoteChain(chainId_, configType_, config_);
}
function batchUpdateRemoteChain(
uint64 chainId_,
uint256[] calldata configTypes_,
bytes[] calldata configs_
)
external
override
onlyPaymentAdmin
{
_batchUpdateRemoteChain(chainId_, configTypes_, configs_);
}
function batchUpdateRemoteChains(
uint64[] calldata chainIds_,
uint256[][] calldata configTypes_,
bytes[][] calldata configs_
)
external
override
onlyPaymentAdmin
{
uint256 len = chainIds_.length;
if (len == 0) revert Error.ZERO_INPUT_VALUE();
if (!(len == configTypes_.length && len == configs_.length)) revert Error.ARRAY_LENGTH_MISMATCH();
for (uint256 i; i < len; ++i) {
_batchUpdateRemoteChain(chainIds_[i], configTypes_[i], configs_[i]);
}
}
function updateRegisterAERC20Params(bytes memory extraDataForTransmuter_) external onlyPaymentAdmin {
extraDataForTransmuter = extraDataForTransmuter_;
}
function _getOracleDecimals(AggregatorV3Interface oracle_) internal view returns (uint8) {
return oracle_.decimals();
}
function _addRemoteChain(uint64 chainId_, PaymentHelperConfig calldata config_) internal {
if (config_.nativeFeedOracle != address(0)) {
AggregatorV3Interface nativeFeedOracleContract = AggregatorV3Interface(config_.nativeFeedOracle);
if (_getOracleDecimals(nativeFeedOracleContract) != SUPPORTED_FEED_PRECISION) {
revert Error.CHAINLINK_UNSUPPORTED_DECIMAL();
}
nativeFeedOracle[chainId_] = nativeFeedOracleContract;
}
if (config_.gasPriceOracle != address(0)) {
AggregatorV3Interface gasPriceOracleContract = AggregatorV3Interface(config_.gasPriceOracle);
if (_getOracleDecimals(gasPriceOracleContract) != SUPPORTED_FEED_PRECISION) {
revert Error.CHAINLINK_UNSUPPORTED_DECIMAL();
}
gasPriceOracle[chainId_] = gasPriceOracleContract;
}
swapGasUsed[chainId_] = config_.swapGasUsed;
updateDepositGasUsed[chainId_] = config_.updateDepositGasUsed;
depositGasUsed[chainId_] = config_.depositGasUsed;
withdrawGasUsed[chainId_] = config_.withdrawGasUsed;
nativePrice[chainId_] = config_.defaultNativePrice;
gasPrice[chainId_] = config_.defaultGasPrice;
gasPerByte[chainId_] = config_.dstGasPerByte;
ackGasCost[chainId_] = config_.ackGasCost;
timelockCost[chainId_] = config_.timelockCost;
emergencyCost[chainId_] = config_.emergencyCost;
updateWithdrawGasUsed[chainId_] = config_.updateWithdrawGasUsed;
emit ChainConfigAdded(chainId_, config_);
}
function _updateRemoteChain(uint64 chainId_, uint256 configType_, bytes memory config_) internal {
if (configType_ == 1) {
AggregatorV3Interface nativeFeedOracleContract = AggregatorV3Interface(abi.decode(config_, (address)));
if (
address(nativeFeedOracleContract) != address(0)
&& _getOracleDecimals(nativeFeedOracleContract) != SUPPORTED_FEED_PRECISION
) {
revert Error.CHAINLINK_UNSUPPORTED_DECIMAL();
}
nativeFeedOracle[chainId_] = nativeFeedOracleContract;
}
if (configType_ == 2) {
AggregatorV3Interface gasPriceOracleContract = AggregatorV3Interface(abi.decode(config_, (address)));
if (
address(gasPriceOracleContract) != address(0)
&& _getOracleDecimals(gasPriceOracleContract) != SUPPORTED_FEED_PRECISION
) {
revert Error.CHAINLINK_UNSUPPORTED_DECIMAL();
}
gasPriceOracle[chainId_] = gasPriceOracleContract;
}
if (configType_ == 3) {
swapGasUsed[chainId_] = abi.decode(config_, (uint256));
}
if (configType_ == 4) {
updateDepositGasUsed[chainId_] = abi.decode(config_, (uint256));
}
if (configType_ == 5) {
depositGasUsed[chainId_] = abi.decode(config_, (uint256));
}
if (configType_ == 6) {
withdrawGasUsed[chainId_] = abi.decode(config_, (uint256));
}
if (configType_ == 7) {
nativePrice[chainId_] = abi.decode(config_, (uint256));
}
if (configType_ == 8) {
gasPrice[chainId_] = abi.decode(config_, (uint256));
}
if (configType_ == 9) {
gasPerByte[chainId_] = abi.decode(config_, (uint256));
}
if (configType_ == 10) {
ackGasCost[chainId_] = abi.decode(config_, (uint256));
}
if (configType_ == 11) {
timelockCost[chainId_] = abi.decode(config_, (uint256));
}
if (configType_ == 12) {
emergencyCost[chainId_] = abi.decode(config_, (uint256));
}
if (configType_ == 13) {
updateWithdrawGasUsed[chainId_] = abi.decode(config_, (uint256));
}
emit ChainConfigUpdated(chainId_, configType_, config_);
}
function _batchUpdateRemoteChain(
uint64 chainId_,
uint256[] calldata configTypes_,
bytes[] calldata configs_
)
internal
{
uint256 len = configTypes_.length;
if (len == 0) revert Error.ZERO_INPUT_VALUE();
if (len != configs_.length) revert Error.ARRAY_LENGTH_MISMATCH();
for (uint256 i; i < len; ++i) {
_updateRemoteChain(chainId_, configTypes_[i], configs_[i]);
}
}
function _generateExtraData(
uint64 dstChainId_,
uint8[] memory ambIds_,
bytes memory message_
)
internal
view
returns (bytes[] memory extraDataPerAMB)
{
AMBMessage memory ambIdEncodedMessage = abi.decode(message_, (AMBMessage));
ambIdEncodedMessage.params = abi.encode(ambIds_, ambIdEncodedMessage.params);
uint256 len = ambIds_.length;
uint256 gasReqPerByte = gasPerByte[dstChainId_];
uint256 totalDstGasReqInWei = abi.encode(ambIdEncodedMessage).length * gasReqPerByte;
uint256 totalDstGasReqInWeiForProof = PROOF_LENGTH * gasReqPerByte;
extraDataPerAMB = new bytes[](len);
for (uint256 i; i < len; ++i) {
uint256 gasReq = i != 0 ? totalDstGasReqInWeiForProof : totalDstGasReqInWei;
extraDataPerAMB[i] = IAmbImplementation(superRegistry.getAmbAddress(ambIds_[i])).generateExtraData(gasReq);
}
}
function _estimateAMBFees(
uint8[] memory ambIds_,
uint64 dstChainId_,
bytes memory message_
)
internal
view
returns (uint256 totalFees)
{
uint256 len = ambIds_.length;
bytes[] memory extraDataPerAMB = _generateExtraData(dstChainId_, ambIds_, message_);
AMBMessage memory ambIdEncodedMessage = abi.decode(message_, (AMBMessage));
ambIdEncodedMessage.params = abi.encode(ambIds_, ambIdEncodedMessage.params);
bytes memory proof_ = abi.encode(AMBMessage(MAX_UINT256, abi.encode(keccak256(message_))));
if (CHAIN_ID != dstChainId_) {
for (uint256 i; i < len; ++i) {
uint256 tempFee = IAmbImplementation(superRegistry.getAmbAddress(ambIds_[i])).estimateFees(
dstChainId_, i != 0 ? proof_ : abi.encode(ambIdEncodedMessage), extraDataPerAMB[i]
);
totalFees += tempFee;
}
}
}
function _estimateAMBFeesReturnExtraData(
uint64 dstChainId_,
uint8[] calldata ambIds_,
bytes memory message_
)
internal
view
returns (uint256[] memory feeSplitUp, bytes[] memory extraDataPerAMB, uint256 totalFees)
{
AMBMessage memory ambIdEncodedMessage = abi.decode(message_, (AMBMessage));
ambIdEncodedMessage.params = abi.encode(ambIds_, ambIdEncodedMessage.params);
uint256 len = ambIds_.length;
extraDataPerAMB = _generateExtraData(dstChainId_, ambIds_, message_);
feeSplitUp = new uint256[](len);
bytes memory proof_ = abi.encode(AMBMessage(MAX_UINT256, abi.encode(keccak256(message_))));
if (CHAIN_ID != dstChainId_) {
for (uint256 i; i < len; ++i) {
uint256 tempFee = IAmbImplementation(superRegistry.getAmbAddress(ambIds_[i])).estimateFees(
dstChainId_, i != 0 ? proof_ : abi.encode(ambIdEncodedMessage), extraDataPerAMB[i]
);
totalFees += tempFee;
feeSplitUp[i] = tempFee;
}
}
}
function _estimateLiqAmount(LiqRequest[] memory req_) internal pure returns (uint256 liqAmount) {
uint256 len = req_.length;
for (uint256 i; i < len; ++i) {
liqAmount += req_[i].nativeAmount;
}
}
function _estimateSwapFees(
uint64 dstChainId_,
bool[] memory hasDstSwaps_
)
internal
view
returns (uint256 gasUsed)
{
uint256 totalSwaps;
if (CHAIN_ID == dstChainId_) {
return 0;
}
uint256 len = hasDstSwaps_.length;
for (uint256 i; i < len; ++i) {
if (hasDstSwaps_[i]) {
++totalSwaps;
}
}
if (totalSwaps == 0) {
return 0;
}
return totalSwaps * swapGasUsed[dstChainId_];
}
function _estimateUpdateDepositCost(
uint64 dstChainId_,
uint256 vaultsCount_
)
internal
view
returns (uint256 gasUsed)
{
return vaultsCount_ * updateDepositGasUsed[dstChainId_];
}
function _estimateUpdateWithdrawCost(
uint64 dstChainId_,
LiqRequest[] memory liqRequests_
)
internal
view
returns (uint256 gasUsed)
{
uint256 len = liqRequests_.length;
for (uint256 i; i < len; i++) {
if (liqRequests_[i].txData.length == 0 && liqRequests_[i].token != address(0)) {
gasUsed += updateWithdrawGasUsed[dstChainId_];
}
}
}
function _estimateDstExecutionCost(
bool isDeposit_,
uint64 dstChainId_,
uint256 vaultsCount_
)
internal
view
returns (uint256 gasUsed)
{
uint256 executionGasPerVault = isDeposit_ ? depositGasUsed[dstChainId_] : withdrawGasUsed[dstChainId_];
gasUsed = executionGasPerVault * vaultsCount_;
}
function _estimateAckProcessingCost(uint256 vaultsCount_) internal view returns (uint256 nativeFee) {
uint256 gasCost = vaultsCount_ * ackGasCost[CHAIN_ID];
return gasCost * _getGasPrice(CHAIN_ID);
}
function _generateSingleVaultMessage(SingleVaultSFData memory sfData_)
internal
view
returns (bytes memory message_)
{
bytes memory ambData = abi.encode(
InitSingleVaultData(
_getNextPayloadId(),
sfData_.superformId,
sfData_.amount,
sfData_.outputAmount,
sfData_.maxSlippage,
sfData_.liqRequest,
sfData_.hasDstSwap,
sfData_.retain4626,
sfData_.receiverAddress,
sfData_.extraFormData
)
);
message_ = abi.encode(AMBMessage(MAX_UINT256, ambData));
}
function _generateMultiVaultMessage(MultiVaultSFData memory sfData_)
internal
view
returns (bytes memory message_)
{
bytes memory ambData = abi.encode(
InitMultiVaultData(
_getNextPayloadId(),
sfData_.superformIds,
sfData_.amounts,
sfData_.outputAmounts,
sfData_.maxSlippages,
sfData_.liqRequests,
sfData_.hasDstSwaps,
sfData_.retain4626s,
sfData_.receiverAddress,
sfData_.extraFormData
)
);
message_ = abi.encode(AMBMessage(MAX_UINT256, ambData));
}
function _convertToNativeFee(
uint64 dstChainId_,
uint256 dstGas_,
bool xChain_
)
internal
view
returns (uint256 nativeFee)
{
uint256 dstNativeFee = dstGas_ * _getGasPrice(dstChainId_);
if (dstNativeFee == 0) {
return 0;
}
if (!xChain_) {
return dstNativeFee;
}
uint256 dstUsdValue = dstNativeFee * _getNativeTokenPrice(dstChainId_);
if (dstUsdValue == 0) {
return 0;
}
uint256 nativeTokenPrice = _getNativeTokenPrice(CHAIN_ID);
if (nativeTokenPrice == 0) revert Error.INVALID_NATIVE_TOKEN_PRICE();
nativeFee = (dstUsdValue) / nativeTokenPrice;
}
function _convertToSrcNativeAmount(
uint64 srcChainId_,
uint256 dstAmount_
)
internal
view
returns (uint256 nativeFee)
{
if (dstAmount_ == 0) {
return 0;
}
uint256 dstUsdValue = dstAmount_ * _getNativeTokenPrice(CHAIN_ID);
if (dstUsdValue == 0) {
return 0;
}
uint256 nativeTokenPrice = _getNativeTokenPrice(srcChainId_);
if (nativeTokenPrice == 0) revert Error.INVALID_NATIVE_TOKEN_PRICE();
nativeFee = dstUsdValue / nativeTokenPrice;
}
function _getNextPayloadId() internal view returns (uint256 nextPayloadId) {
nextPayloadId = ReadOnlyBaseRegistry(_getAddress(keccak256("CORE_STATE_REGISTRY"))).payloadsCount();
++nextPayloadId;
}
function _getGasPrice(uint64 chainId_) internal view returns (uint256) {
address oracleAddr = address(gasPriceOracle[chainId_]);
if (oracleAddr != address(0)) {
try AggregatorV3Interface(oracleAddr).latestRoundData() returns (
uint80, int256 value, uint256, uint256 updatedAt, uint80
) {
if (value <= 0) revert Error.CHAINLINK_MALFUNCTION();
if (updatedAt == 0) revert Error.CHAINLINK_INCOMPLETE_ROUND();
return uint256(value);
} catch {
}
}
return gasPrice[chainId_];
}
function _getNativeTokenPrice(uint64 chainId_) internal view returns (uint256) {
address oracleAddr = address(nativeFeedOracle[chainId_]);
if (oracleAddr != address(0)) {
try AggregatorV3Interface(oracleAddr).latestRoundData() returns (
uint80, int256 dstTokenPrice, uint256, uint256 updatedAt, uint80
) {
if (dstTokenPrice <= 0) revert Error.CHAINLINK_MALFUNCTION();
if (updatedAt == 0) revert Error.CHAINLINK_INCOMPLETE_ROUND();
return uint256(dstTokenPrice);
} catch {
}
}
return nativePrice[chainId_];
}
function _getAddress(bytes32 id_) internal view returns (address) {
return superRegistry.getAddress(id_);
}
function _calculateAmounts(CalculateAmountsReq memory req_)
internal
view
returns (uint256 liqAmount, uint256 srcAmount, uint256 dstOrSameChainAmt)
{
LocalEstimateVars memory v;
bool xChain = req_.dstChainIds[req_.i] != CHAIN_ID;
v.totalGas = 0;
bool multiVaults = req_.superformsData.length > 0;
bytes memory message = multiVaults
? _generateMultiVaultMessage(req_.superformsData[req_.i])
: _generateSingleVaultMessage(req_.superformData[req_.i]);
v.ambFees = xChain ? _estimateAMBFees(req_.ambIds, req_.dstChainIds[req_.i], message) : 0;
v.superformIdsLen = multiVaults ? req_.superformsData[req_.i].superformIds.length : 1;
srcAmount += v.ambFees;
LiqRequest[] memory liqRequests = multiVaults
? req_.superformsData[req_.i].liqRequests
: req_.superformData[req_.i].liqRequest.castLiqRequestToArray();
if (req_.isDeposit) {
liqAmount += _estimateLiqAmount(liqRequests);
if (xChain) {
v.totalGas += _estimateUpdateDepositCost(req_.dstChainIds[req_.i], v.superformIdsLen);
uint256 ackLen;
if (multiVaults) {
for (uint256 j; j < v.superformIdsLen; ++j) {
if (!req_.superformsData[req_.i].retain4626s[j]) ++ackLen;
}
} else {
if (!req_.superformData[req_.i].retain4626) ++ackLen;
}
srcAmount += _estimateAckProcessingCost(ackLen);
bool[] memory hasDstSwaps = multiVaults
? req_.superformsData[req_.i].hasDstSwaps
: req_.superformData[req_.i].hasDstSwap.castBoolToArray();
v.totalGas += _estimateSwapFees(req_.dstChainIds[req_.i], hasDstSwaps);
}
} else {
if (multiVaults) {
for (uint256 j; j < v.superformIdsLen; ++j) {
v.totalGas += _calculateTotalDstGasTimelockEmergency(
req_.superformsData[req_.i].superformIds[j], req_.dstChainIds[req_.i], req_.factory
);
}
} else {
v.totalGas += _calculateTotalDstGasTimelockEmergency(
req_.superformData[req_.i].superformId, req_.dstChainIds[req_.i], req_.factory
);
}
if (xChain) {
v.totalGas += _estimateUpdateWithdrawCost(req_.dstChainIds[req_.i], liqRequests);
}
}
v.totalGas +=
xChain ? _estimateDstExecutionCost(req_.isDeposit, req_.dstChainIds[req_.i], v.superformIdsLen) : 0;
dstOrSameChainAmt += _convertToNativeFee(req_.dstChainIds[req_.i], v.totalGas, xChain);
}
function _calculateTotalDstGasTimelockEmergency(
uint256 superformId_,
uint64 dstChainId_,
ISuperformFactory factory_
)
internal
view
returns (uint256 totalDstGas)
{
(, uint32 formId,) = superformId_.getSuperform();
bool paused = factory_.isFormImplementationPaused(formId);
if (!paused && formId == TIMELOCK_FORM_ID) {
totalDstGas += timelockCost[dstChainId_];
} else if (paused) {
totalDstGas += emergencyCost[dstChainId_];
}
}
}
文件 14 的 14:ProofLib.sol
pragma solidity ^0.8.23;
import { AMBMessage } from "src/types/DataTypes.sol";
library ProofLib {
function computeProof(AMBMessage memory message_) internal pure returns (bytes32) {
return keccak256(abi.encode(message_));
}
function computeProofBytes(AMBMessage memory message_) internal pure returns (bytes memory) {
return abi.encode(keccak256(abi.encode(message_)));
}
function computeProof(bytes memory message_) internal pure returns (bytes32) {
return keccak256(message_);
}
function computeProofBytes(bytes memory message_) internal pure returns (bytes memory) {
return abi.encode(keccak256(message_));
}
}
{
"compilationTarget": {
"src/payments/PaymentHelper.sol": "PaymentHelper"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": [
":@openzeppelin/contracts/=lib/ERC1155A/lib/openzeppelin-contracts/contracts/",
":ERC1155A/=lib/ERC1155A/src/",
":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/",
":solmate/=lib/ERC1155A/lib/solmate/src/",
":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/"
]
}
[{"inputs":[{"internalType":"address","name":"superRegistry_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ARRAY_LENGTH_MISMATCH","type":"error"},{"inputs":[],"name":"BLOCK_CHAIN_ID_OUT_OF_BOUNDS","type":"error"},{"inputs":[],"name":"CHAINLINK_INCOMPLETE_ROUND","type":"error"},{"inputs":[],"name":"CHAINLINK_MALFUNCTION","type":"error"},{"inputs":[],"name":"CHAINLINK_UNSUPPORTED_DECIMAL","type":"error"},{"inputs":[],"name":"INVALID_CHAIN_ID","type":"error"},{"inputs":[],"name":"INVALID_NATIVE_TOKEN_PRICE","type":"error"},{"inputs":[],"name":"INVALID_PAYLOAD_ID","type":"error"},{"inputs":[],"name":"NOT_PAYMENT_ADMIN","type":"error"},{"inputs":[],"name":"NOT_PROTOCOL_ADMIN","type":"error"},{"inputs":[],"name":"ZERO_ADDRESS","type":"error"},{"inputs":[],"name":"ZERO_INPUT_VALUE","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"chainId_","type":"uint64"},{"components":[{"internalType":"address","name":"nativeFeedOracle","type":"address"},{"internalType":"address","name":"gasPriceOracle","type":"address"},{"internalType":"uint256","name":"swapGasUsed","type":"uint256"},{"internalType":"uint256","name":"updateDepositGasUsed","type":"uint256"},{"internalType":"uint256","name":"depositGasUsed","type":"uint256"},{"internalType":"uint256","name":"withdrawGasUsed","type":"uint256"},{"internalType":"uint256","name":"defaultNativePrice","type":"uint256"},{"internalType":"uint256","name":"defaultGasPrice","type":"uint256"},{"internalType":"uint256","name":"dstGasPerByte","type":"uint256"},{"internalType":"uint256","name":"ackGasCost","type":"uint256"},{"internalType":"uint256","name":"timelockCost","type":"uint256"},{"internalType":"uint256","name":"emergencyCost","type":"uint256"},{"internalType":"uint256","name":"updateWithdrawGasUsed","type":"uint256"}],"indexed":false,"internalType":"struct IPaymentHelperV2.PaymentHelperConfig","name":"config_","type":"tuple"}],"name":"ChainConfigAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint64","name":"chainId_","type":"uint64"},{"indexed":true,"internalType":"uint256","name":"configType_","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"config_","type":"bytes"}],"name":"ChainConfigUpdated","type":"event"},{"inputs":[],"name":"CHAIN_ID","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"chainId","type":"uint64"}],"name":"ackGasCost","outputs":[{"internalType":"uint256","name":"gasForAck","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"chainId_","type":"uint64"},{"components":[{"internalType":"address","name":"nativeFeedOracle","type":"address"},{"internalType":"address","name":"gasPriceOracle","type":"address"},{"internalType":"uint256","name":"swapGasUsed","type":"uint256"},{"internalType":"uint256","name":"updateDepositGasUsed","type":"uint256"},{"internalType":"uint256","name":"depositGasUsed","type":"uint256"},{"internalType":"uint256","name":"withdrawGasUsed","type":"uint256"},{"internalType":"uint256","name":"defaultNativePrice","type":"uint256"},{"internalType":"uint256","name":"defaultGasPrice","type":"uint256"},{"internalType":"uint256","name":"dstGasPerByte","type":"uint256"},{"internalType":"uint256","name":"ackGasCost","type":"uint256"},{"internalType":"uint256","name":"timelockCost","type":"uint256"},{"internalType":"uint256","name":"emergencyCost","type":"uint256"},{"internalType":"uint256","name":"updateWithdrawGasUsed","type":"uint256"}],"internalType":"struct IPaymentHelperV2.PaymentHelperConfig","name":"config_","type":"tuple"}],"name":"addRemoteChain","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64[]","name":"chainIds_","type":"uint64[]"},{"components":[{"internalType":"address","name":"nativeFeedOracle","type":"address"},{"internalType":"address","name":"gasPriceOracle","type":"address"},{"internalType":"uint256","name":"swapGasUsed","type":"uint256"},{"internalType":"uint256","name":"updateDepositGasUsed","type":"uint256"},{"internalType":"uint256","name":"depositGasUsed","type":"uint256"},{"internalType":"uint256","name":"withdrawGasUsed","type":"uint256"},{"internalType":"uint256","name":"defaultNativePrice","type":"uint256"},{"internalType":"uint256","name":"defaultGasPrice","type":"uint256"},{"internalType":"uint256","name":"dstGasPerByte","type":"uint256"},{"internalType":"uint256","name":"ackGasCost","type":"uint256"},{"internalType":"uint256","name":"timelockCost","type":"uint256"},{"internalType":"uint256","name":"emergencyCost","type":"uint256"},{"internalType":"uint256","name":"updateWithdrawGasUsed","type":"uint256"}],"internalType":"struct IPaymentHelperV2.PaymentHelperConfig[]","name":"configs_","type":"tuple[]"}],"name":"addRemoteChains","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"chainId_","type":"uint64"},{"internalType":"uint256[]","name":"configTypes_","type":"uint256[]"},{"internalType":"bytes[]","name":"configs_","type":"bytes[]"}],"name":"batchUpdateRemoteChain","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64[]","name":"chainIds_","type":"uint64[]"},{"internalType":"uint256[][]","name":"configTypes_","type":"uint256[][]"},{"internalType":"bytes[][]","name":"configs_","type":"bytes[][]"}],"name":"batchUpdateRemoteChains","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"dstChainId_","type":"uint64"},{"internalType":"uint8[]","name":"ambIds_","type":"uint8[]"},{"internalType":"bytes","name":"message_","type":"bytes"}],"name":"calculateAMBData","outputs":[{"internalType":"uint256","name":"totalFees","type":"uint256"},{"internalType":"bytes","name":"extraData","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"chainId","type":"uint64"}],"name":"depositGasUsed","outputs":[{"internalType":"uint256","name":"gasForDeposit","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"chainId","type":"uint64"}],"name":"emergencyCost","outputs":[{"internalType":"uint256","name":"gasForEmergency","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8[]","name":"ambIds_","type":"uint8[]"},{"internalType":"uint64","name":"dstChainId_","type":"uint64"},{"internalType":"bytes","name":"message_","type":"bytes"},{"internalType":"bytes[]","name":"extraData_","type":"bytes[]"}],"name":"estimateAMBFees","outputs":[{"internalType":"uint256","name":"totalFees","type":"uint256"},{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"payloadId_","type":"uint256"}],"name":"estimateAckCost","outputs":[{"internalType":"uint256","name":"totalFees","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"multi","type":"bool"},{"internalType":"uint8[]","name":"ackAmbIds","type":"uint8[]"},{"internalType":"uint64","name":"srcChainId","type":"uint64"}],"name":"estimateAckCostDefault","outputs":[{"internalType":"uint256","name":"totalFees","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"multi","type":"bool"},{"internalType":"uint8[]","name":"ackAmbIds","type":"uint8[]"},{"internalType":"uint64","name":"srcChainId","type":"uint64"}],"name":"estimateAckCostDefaultNativeSource","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint8[][]","name":"ambIds","type":"uint8[][]"},{"internalType":"uint64[]","name":"dstChainIds","type":"uint64[]"},{"components":[{"internalType":"uint256[]","name":"superformIds","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"uint256[]","name":"outputAmounts","type":"uint256[]"},{"internalType":"uint256[]","name":"maxSlippages","type":"uint256[]"},{"components":[{"internalType":"bytes","name":"txData","type":"bytes"},{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"interimToken","type":"address"},{"internalType":"uint8","name":"bridgeId","type":"uint8"},{"internalType":"uint64","name":"liqDstChainId","type":"uint64"},{"internalType":"uint256","name":"nativeAmount","type":"uint256"}],"internalType":"struct LiqRequest[]","name":"liqRequests","type":"tuple[]"},{"internalType":"bytes","name":"permit2data","type":"bytes"},{"internalType":"bool[]","name":"hasDstSwaps","type":"bool[]"},{"internalType":"bool[]","name":"retain4626s","type":"bool[]"},{"internalType":"address","name":"receiverAddress","type":"address"},{"internalType":"address","name":"receiverAddressSP","type":"address"},{"internalType":"bytes","name":"extraFormData","type":"bytes"}],"internalType":"struct MultiVaultSFData[]","name":"superformsData","type":"tuple[]"}],"internalType":"struct MultiDstMultiVaultStateReq","name":"req_","type":"tuple"},{"internalType":"bool","name":"isDeposit_","type":"bool"}],"name":"estimateMultiDstMultiVault","outputs":[{"internalType":"uint256","name":"liqAmount","type":"uint256"},{"internalType":"uint256","name":"srcAmount","type":"uint256"},{"internalType":"uint256","name":"dstAmount","type":"uint256"},{"internalType":"uint256","name":"totalAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint8[][]","name":"ambIds","type":"uint8[][]"},{"internalType":"uint64[]","name":"dstChainIds","type":"uint64[]"},{"components":[{"internalType":"uint256","name":"superformId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"outputAmount","type":"uint256"},{"internalType":"uint256","name":"maxSlippage","type":"uint256"},{"components":[{"internalType":"bytes","name":"txData","type":"bytes"},{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"interimToken","type":"address"},{"internalType":"uint8","name":"bridgeId","type":"uint8"},{"internalType":"uint64","name":"liqDstChainId","type":"uint64"},{"internalType":"uint256","name":"nativeAmount","type":"uint256"}],"internalType":"struct LiqRequest","name":"liqRequest","type":"tuple"},{"internalType":"bytes","name":"permit2data","type":"bytes"},{"internalType":"bool","name":"hasDstSwap","type":"bool"},{"internalType":"bool","name":"retain4626","type":"bool"},{"internalType":"address","name":"receiverAddress","type":"address"},{"internalType":"address","name":"receiverAddressSP","type":"address"},{"internalType":"bytes","name":"extraFormData","type":"bytes"}],"internalType":"struct SingleVaultSFData[]","name":"superformsData","type":"tuple[]"}],"internalType":"struct MultiDstSingleVaultStateReq","name":"req_","type":"tuple"},{"internalType":"bool","name":"isDeposit_","type":"bool"}],"name":"estimateMultiDstSingleVault","outputs":[{"internalType":"uint256","name":"liqAmount","type":"uint256"},{"internalType":"uint256","name":"srcAmount","type":"uint256"},{"internalType":"uint256","name":"dstAmount","type":"uint256"},{"internalType":"uint256","name":"totalAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"uint256[]","name":"superformIds","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"uint256[]","name":"outputAmounts","type":"uint256[]"},{"internalType":"uint256[]","name":"maxSlippages","type":"uint256[]"},{"components":[{"internalType":"bytes","name":"txData","type":"bytes"},{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"interimToken","type":"address"},{"internalType":"uint8","name":"bridgeId","type":"uint8"},{"internalType":"uint64","name":"liqDstChainId","type":"uint64"},{"internalType":"uint256","name":"nativeAmount","type":"uint256"}],"internalType":"struct LiqRequest[]","name":"liqRequests","type":"tuple[]"},{"internalType":"bytes","name":"permit2data","type":"bytes"},{"internalType":"bool[]","name":"hasDstSwaps","type":"bool[]"},{"internalType":"bool[]","name":"retain4626s","type":"bool[]"},{"internalType":"address","name":"receiverAddress","type":"address"},{"internalType":"address","name":"receiverAddressSP","type":"address"},{"internalType":"bytes","name":"extraFormData","type":"bytes"}],"internalType":"struct MultiVaultSFData","name":"superformData","type":"tuple"}],"internalType":"struct SingleDirectMultiVaultStateReq","name":"req_","type":"tuple"},{"internalType":"bool","name":"isDeposit_","type":"bool"}],"name":"estimateSingleDirectMultiVault","outputs":[{"internalType":"uint256","name":"liqAmount","type":"uint256"},{"internalType":"uint256","name":"dstOrSameChainAmt","type":"uint256"},{"internalType":"uint256","name":"totalAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"components":[{"internalType":"uint256","name":"superformId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"outputAmount","type":"uint256"},{"internalType":"uint256","name":"maxSlippage","type":"uint256"},{"components":[{"internalType":"bytes","name":"txData","type":"bytes"},{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"interimToken","type":"address"},{"internalType":"uint8","name":"bridgeId","type":"uint8"},{"internalType":"uint64","name":"liqDstChainId","type":"uint64"},{"internalType":"uint256","name":"nativeAmount","type":"uint256"}],"internalType":"struct LiqRequest","name":"liqRequest","type":"tuple"},{"internalType":"bytes","name":"permit2data","type":"bytes"},{"internalType":"bool","name":"hasDstSwap","type":"bool"},{"internalType":"bool","name":"retain4626","type":"bool"},{"internalType":"address","name":"receiverAddress","type":"address"},{"internalType":"address","name":"receiverAddressSP","type":"address"},{"internalType":"bytes","name":"extraFormData","type":"bytes"}],"internalType":"struct SingleVaultSFData","name":"superformData","type":"tuple"}],"internalType":"struct SingleDirectSingleVaultStateReq","name":"req_","type":"tuple"},{"internalType":"bool","name":"isDeposit_","type":"bool"}],"name":"estimateSingleDirectSingleVault","outputs":[{"internalType":"uint256","name":"liqAmount","type":"uint256"},{"internalType":"uint256","name":"dstOrSameChainAmt","type":"uint256"},{"internalType":"uint256","name":"totalAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint8[]","name":"ambIds","type":"uint8[]"},{"internalType":"uint64","name":"dstChainId","type":"uint64"},{"components":[{"internalType":"uint256[]","name":"superformIds","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"uint256[]","name":"outputAmounts","type":"uint256[]"},{"internalType":"uint256[]","name":"maxSlippages","type":"uint256[]"},{"components":[{"internalType":"bytes","name":"txData","type":"bytes"},{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"interimToken","type":"address"},{"internalType":"uint8","name":"bridgeId","type":"uint8"},{"internalType":"uint64","name":"liqDstChainId","type":"uint64"},{"internalType":"uint256","name":"nativeAmount","type":"uint256"}],"internalType":"struct LiqRequest[]","name":"liqRequests","type":"tuple[]"},{"internalType":"bytes","name":"permit2data","type":"bytes"},{"internalType":"bool[]","name":"hasDstSwaps","type":"bool[]"},{"internalType":"bool[]","name":"retain4626s","type":"bool[]"},{"internalType":"address","name":"receiverAddress","type":"address"},{"internalType":"address","name":"receiverAddressSP","type":"address"},{"internalType":"bytes","name":"extraFormData","type":"bytes"}],"internalType":"struct MultiVaultSFData","name":"superformsData","type":"tuple"}],"internalType":"struct SingleXChainMultiVaultStateReq","name":"req_","type":"tuple"},{"internalType":"bool","name":"isDeposit_","type":"bool"}],"name":"estimateSingleXChainMultiVault","outputs":[{"internalType":"uint256","name":"liqAmount","type":"uint256"},{"internalType":"uint256","name":"srcAmount","type":"uint256"},{"internalType":"uint256","name":"dstAmount","type":"uint256"},{"internalType":"uint256","name":"totalAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint8[]","name":"ambIds","type":"uint8[]"},{"internalType":"uint64","name":"dstChainId","type":"uint64"},{"components":[{"internalType":"uint256","name":"superformId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"outputAmount","type":"uint256"},{"internalType":"uint256","name":"maxSlippage","type":"uint256"},{"components":[{"internalType":"bytes","name":"txData","type":"bytes"},{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"interimToken","type":"address"},{"internalType":"uint8","name":"bridgeId","type":"uint8"},{"internalType":"uint64","name":"liqDstChainId","type":"uint64"},{"internalType":"uint256","name":"nativeAmount","type":"uint256"}],"internalType":"struct LiqRequest","name":"liqRequest","type":"tuple"},{"internalType":"bytes","name":"permit2data","type":"bytes"},{"internalType":"bool","name":"hasDstSwap","type":"bool"},{"internalType":"bool","name":"retain4626","type":"bool"},{"internalType":"address","name":"receiverAddress","type":"address"},{"internalType":"address","name":"receiverAddressSP","type":"address"},{"internalType":"bytes","name":"extraFormData","type":"bytes"}],"internalType":"struct SingleVaultSFData","name":"superformData","type":"tuple"}],"internalType":"struct SingleXChainSingleVaultStateReq","name":"req_","type":"tuple"},{"internalType":"bool","name":"isDeposit_","type":"bool"}],"name":"estimateSingleXChainSingleVault","outputs":[{"internalType":"uint256","name":"liqAmount","type":"uint256"},{"internalType":"uint256","name":"srcAmount","type":"uint256"},{"internalType":"uint256","name":"dstAmount","type":"uint256"},{"internalType":"uint256","name":"totalAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"extraDataForTransmuter","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"chainId","type":"uint64"}],"name":"gasPerByte","outputs":[{"internalType":"uint256","name":"gasPerByte","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"chainId","type":"uint64"}],"name":"gasPrice","outputs":[{"internalType":"uint256","name":"defaultGasPrice","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"chainId","type":"uint64"}],"name":"gasPriceOracle","outputs":[{"internalType":"contract AggregatorV3Interface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRegisterTransmuterAMBData","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"chainId","type":"uint64"}],"name":"nativeFeedOracle","outputs":[{"internalType":"contract AggregatorV3Interface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"chainId","type":"uint64"}],"name":"nativePrice","outputs":[{"internalType":"uint256","name":"defaultNativePrice","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"superRegistry","outputs":[{"internalType":"contract ISuperRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"chainId","type":"uint64"}],"name":"swapGasUsed","outputs":[{"internalType":"uint256","name":"gasForSwap","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"chainId","type":"uint64"}],"name":"timelockCost","outputs":[{"internalType":"uint256","name":"gasForTimelock","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"chainId","type":"uint64"}],"name":"updateDepositGasUsed","outputs":[{"internalType":"uint256","name":"gasForUpdateDeposit","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"extraDataForTransmuter_","type":"bytes"}],"name":"updateRegisterAERC20Params","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"chainId_","type":"uint64"},{"internalType":"uint256","name":"configType_","type":"uint256"},{"internalType":"bytes","name":"config_","type":"bytes"}],"name":"updateRemoteChain","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"chainId","type":"uint64"}],"name":"updateWithdrawGasUsed","outputs":[{"internalType":"uint256","name":"gasForUpdateWithdraw","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"chainId","type":"uint64"}],"name":"withdrawGasUsed","outputs":[{"internalType":"uint256","name":"gasForWithdraw","type":"uint256"}],"stateMutability":"view","type":"function"}]