More Info
Private Name Tags
ContractCreator
Latest 25 internal transactions (View All)
Advanced mode:
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
107557777 | 594 days ago | 0 ETH | ||||
107557777 | 594 days ago | 0 ETH | ||||
107557777 | 594 days ago | 0 ETH | ||||
107557777 | 594 days ago | 0 ETH | ||||
107557775 | 594 days ago | 0 ETH | ||||
107557440 | 594 days ago | 0 ETH | ||||
107557440 | 594 days ago | 0 ETH | ||||
107557440 | 594 days ago | 0 ETH | ||||
107557440 | 594 days ago | 0 ETH | ||||
107557438 | 594 days ago | 0 ETH | ||||
107556782 | 594 days ago | 0 ETH | ||||
107556782 | 594 days ago | 0 ETH | ||||
107556782 | 594 days ago | 0 ETH | ||||
107556782 | 594 days ago | 0 ETH | ||||
107556780 | 594 days ago | 0 ETH | ||||
107555544 | 594 days ago | 0 ETH | ||||
107555123 | 594 days ago | 0 ETH | ||||
107555123 | 594 days ago | 0 ETH | ||||
107555123 | 594 days ago | 0 ETH | ||||
107555123 | 594 days ago | 0 ETH | ||||
107555120 | 594 days ago | 0 ETH | ||||
107554292 | 594 days ago | 0 ETH | ||||
107554292 | 594 days ago | 0 ETH | ||||
107554292 | 594 days ago | 0 ETH | ||||
107554292 | 594 days ago | 0 ETH |
Loading...
Loading
Contract Name:
MagpieStargateBridge
Compiler Version
v0.8.17+commit.8df45f5f
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: Unlicense pragma solidity 0.8.17; import {Ownable} from "openzeppelin-solidity/contracts/access/Ownable.sol"; import {IMagpieStargateBridge} from "./interfaces/IMagpieStargateBridge.sol"; import {IStargateRouter} from "./interfaces/stargate/IStargateRouter.sol"; import {LibAsset} from "./libraries/LibAsset.sol"; import {LibTransferKey, TransferKey} from "./libraries/LibTransferKey.sol"; error StargateBridgeIsNotReady(); contract MagpieStargateBridge is IMagpieStargateBridge, Ownable { using LibAsset for address; Settings public settings; mapping(uint16 => mapping(bytes32 => mapping(uint64 => mapping(address => uint256)))) public deposits; modifier onlyMagpieAggregator() { require(msg.sender == settings.aggregatorAddress); _; } modifier onlyStargate() { require(msg.sender == settings.routerAddress); _; } function updateSettings(Settings calldata _settings) external onlyOwner { settings = _settings; } function withdraw(WithdrawArgs calldata withdrawArgs) external onlyMagpieAggregator returns (uint256 amount) { amount = deposits[withdrawArgs.transferKey.networkId][withdrawArgs.transferKey.senderAddress][ withdrawArgs.transferKey.swapSequence ][withdrawArgs.assetAddress]; if (amount == 0) { IStargateRouter(settings.routerAddress).clearCachedSwap( withdrawArgs.srcChainId, withdrawArgs.srcAddress, withdrawArgs.nonce ); } amount = deposits[withdrawArgs.transferKey.networkId][withdrawArgs.transferKey.senderAddress][ withdrawArgs.transferKey.swapSequence ][withdrawArgs.assetAddress]; if (amount == 0) { revert StargateBridgeIsNotReady(); } deposits[withdrawArgs.transferKey.networkId][withdrawArgs.transferKey.senderAddress][ withdrawArgs.transferKey.swapSequence ][withdrawArgs.assetAddress] = 0; withdrawArgs.assetAddress.transfer(settings.aggregatorAddress, amount); } function sgReceive( uint16, bytes calldata, uint256, address assetAddress, uint256 amount, bytes calldata payload ) external override onlyStargate { TransferKey memory transferKey = LibTransferKey.decode(payload); deposits[transferKey.networkId][transferKey.senderAddress][transferKey.swapSequence][assetAddress] += amount; } }
// SPDX-License-Identifier: Unlicense pragma solidity 0.8.17; import {TransferKey} from "../libraries/LibTransferKey.sol"; interface IMagpieStargateBridge { struct Settings { address aggregatorAddress; address routerAddress; } function updateSettings(Settings calldata _settings) external; struct WithdrawArgs { uint16 srcChainId; uint256 nonce; address assetAddress; bytes srcAddress; TransferKey transferKey; } function withdraw(WithdrawArgs calldata withdrawArgs) external returns (uint256 amountOut); function sgReceive( uint16, bytes calldata, uint256, address assetAddress, uint256 amount, bytes calldata payload ) external; }
// SPDX-License-Identifier: Unlicense pragma solidity 0.8.17; interface IWETH { function deposit() external payable; function transfer(address to, uint256 value) external returns (bool); function withdraw(uint256) external; }
// SPDX-License-Identifier: Unlicense pragma solidity 0.8.17; interface IStargateRouter { struct lzTxObj { uint256 dstGasForCall; uint256 dstNativeAmount; bytes dstNativeAddr; } function addLiquidity(uint256 _poolId, uint256 _amountLD, address _to) external; function swap( uint16 _dstChainId, uint256 _srcPoolId, uint256 _dstPoolId, address payable _refundAddress, uint256 _amountLD, uint256 _minAmountLD, lzTxObj memory _lzTxParams, bytes calldata _to, bytes calldata _payload ) external payable; function redeemRemote( uint16 _dstChainId, uint256 _srcPoolId, uint256 _dstPoolId, address payable _refundAddress, uint256 _amountLP, uint256 _minAmountLD, bytes calldata _to, lzTxObj memory _lzTxParams ) external payable; function instantRedeemLocal(uint16 _srcPoolId, uint256 _amountLP, address _to) external returns (uint256); function redeemLocal( uint16 _dstChainId, uint256 _srcPoolId, uint256 _dstPoolId, address payable _refundAddress, uint256 _amountLP, bytes calldata _to, lzTxObj memory _lzTxParams ) external payable; function sendCredits( uint16 _dstChainId, uint256 _srcPoolId, uint256 _dstPoolId, address payable _refundAddress ) external payable; function quoteLayerZeroFee( uint16 _dstChainId, uint8 _functionType, bytes calldata _toAddress, bytes calldata _transferAndCallPayload, lzTxObj memory _lzTxParams ) external view returns (uint256, uint256); function clearCachedSwap(uint16 _srcChainId, bytes calldata _srcAddress, uint256 _nonce) external; struct CachedSwap { address token; uint256 amountLD; address to; bytes payload; } function cachedSwapLookup(uint16, bytes calldata, uint256) external view returns (CachedSwap memory); function factory() external view returns (address); }
// SPDX-License-Identifier: Unlicense pragma solidity 0.8.17; import "openzeppelin-solidity/contracts/token/ERC20/IERC20.sol"; import "openzeppelin-solidity/contracts/token/ERC20/utils/SafeERC20.sol"; import "openzeppelin-solidity/contracts/utils/Address.sol"; import "../interfaces/IWETH.sol"; error AssetNotReceived(); library LibAsset { using LibAsset for address; address constant NATIVE_ASSETID = address(0); function isNative(address self) internal pure returns (bool) { return self == NATIVE_ASSETID; } function getBalanceOf(address self, address target) internal view returns (uint256) { return self.isNative() ? target.balance : IERC20(self).balanceOf(target); } function getBalance(address self) internal view returns (uint256) { return self.isNative() ? address(this).balance : IERC20(self).balanceOf(address(this)); } function transferFrom(address self, address from, address to, uint256 amount) internal { SafeERC20.safeTransferFrom(IERC20(self), from, to, amount); } function transfer(address self, address recipient, uint256 amount) internal { if (self.isNative()) { Address.sendValue(payable(recipient), amount); } else { SafeERC20.safeTransfer(IERC20(self), recipient, amount); } } function approve(address self, address spender, uint256 amount) internal { SafeERC20.forceApprove(IERC20(self), spender, amount); } function getAllowance(address self, address owner, address spender) internal view returns (uint256) { return IERC20(self).allowance(owner, spender); } function deposit(address self, address weth, uint256 amount) internal { if (self.isNative()) { if (msg.value < amount) { revert AssetNotReceived(); } IWETH(weth).deposit{value: amount}(); } else { self.transferFrom(msg.sender, address(this), amount); } } function withdraw(address self, address weth, address to, uint256 amount) internal { if (self.isNative()) { IWETH(weth).withdraw(amount); } self.transfer(payable(to), amount); } function getDecimals(address self) internal view returns (uint8 tokenDecimals) { tokenDecimals = 18; if (!self.isNative()) { (, bytes memory queriedDecimals) = self.staticcall(abi.encodeWithSignature("decimals()")); tokenDecimals = abi.decode(queriedDecimals, (uint8)); } } }
// SPDX-License-Identifier: Unlicense pragma solidity 0.8.17; struct TransferKey { uint16 networkId; bytes32 senderAddress; uint64 swapSequence; } error InvalidTransferKey(); library LibTransferKey { function encode(TransferKey memory transferKey) internal pure returns (bytes memory) { bytes memory payload = new bytes(42); assembly { mstore(add(payload, 32), shl(240, mload(transferKey))) mstore(add(payload, 34), mload(add(transferKey, 32))) mstore(add(payload, 66), shl(192, mload(add(transferKey, 64)))) } return payload; } function decode(bytes memory payload) internal pure returns (TransferKey memory transferKey) { assembly { mstore(transferKey, shr(240, mload(add(payload, 32)))) mstore(add(transferKey, 32), mload(add(payload, 34))) mstore(add(transferKey, 64), shr(192, mload(add(payload, 66)))) } } function validate(TransferKey memory self, TransferKey memory transferKey) internal pure { if ( self.networkId != transferKey.networkId || self.senderAddress != transferKey.senderAddress || self.swapSequence != transferKey.swapSequence ) { revert InvalidTransferKey(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 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. */ 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]. */ 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 v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ 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 amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` 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 amount) 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 `amount` 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 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` 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 amount) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/IERC20Permit.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; /** * @dev 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.encodeWithSelector(token.transfer.selector, 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.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 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); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value)); } /** * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value)); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Compatible with tokens that require the approval to be set to * 0 before setting it to a non-zero value. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0)); _callOptionalReturn(token, approvalCall); } } /** * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`. * Revert on invalid signature. */ function safePermit( IERC20Permit token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @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, "SafeERC20: low-level call failed"); require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } /** * @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.isContract(address(token)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @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.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @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, it is bubbled up by this * function (like regular Solidity function calls). * * 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. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @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`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) 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(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @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; } }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"name":"StargateBridgeIsNotReady","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"},{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"uint64","name":"","type":"uint64"},{"internalType":"address","name":"","type":"address"}],"name":"deposits","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"settings","outputs":[{"internalType":"address","name":"aggregatorAddress","type":"address"},{"internalType":"address","name":"routerAddress","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"},{"internalType":"bytes","name":"","type":"bytes"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"assetAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"payload","type":"bytes"}],"name":"sgReceive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"aggregatorAddress","type":"address"},{"internalType":"address","name":"routerAddress","type":"address"}],"internalType":"struct IMagpieStargateBridge.Settings","name":"_settings","type":"tuple"}],"name":"updateSettings","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint16","name":"srcChainId","type":"uint16"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"address","name":"assetAddress","type":"address"},{"internalType":"bytes","name":"srcAddress","type":"bytes"},{"components":[{"internalType":"uint16","name":"networkId","type":"uint16"},{"internalType":"bytes32","name":"senderAddress","type":"bytes32"},{"internalType":"uint64","name":"swapSequence","type":"uint64"}],"internalType":"struct TransferKey","name":"transferKey","type":"tuple"}],"internalType":"struct IMagpieStargateBridge.WithdrawArgs","name":"withdrawArgs","type":"tuple"}],"name":"withdraw","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b5061001a3361001f565b61006f565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b610e928061007e6000396000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c8063c028da0f1161005b578063c028da0f146100eb578063ca960930146100fe578063e06174e414610138578063f2fde38b1461017257600080fd5b80636302c1371461008d578063715018a6146100b35780638da5cb5b146100bd578063ab8236f3146100d8575b600080fd5b6100a061009b366004610a98565b610185565b6040519081526020015b60405180910390f35b6100bb610466565b005b6000546040516001600160a01b0390911681526020016100aa565b6100bb6100e6366004610b4a565b61047a565b6100bb6100f9366004610bf2565b61053f565b6100a061010c366004610c22565b600360209081526000948552604080862082529385528385208152918452828420909152825290205481565b600154600254610152916001600160a01b03908116911682565b604080516001600160a01b039384168152929091166020830152016100aa565b6100bb610180366004610c71565b610559565b6001546000906001600160a01b0316331461019f57600080fd5b600360006101b360a0850160808601610c8e565b61ffff1681526020808201929092526040908101600090812060a086013582529092528120906101e960e0850160c08601610ca9565b67ffffffffffffffff1667ffffffffffffffff16815260200190815260200160002060008360400160208101906102209190610c71565b6001600160a01b03166001600160a01b03168152602001908152602001600020549050806000036102cd576002546001600160a01b031663403a9f7a6102696020850185610c8e565b6102766060860186610cc4565b86602001356040518563ffffffff1660e01b815260040161029a9493929190610d0b565b600060405180830381600087803b1580156102b457600080fd5b505af11580156102c8573d6000803e3d6000fd5b505050505b600360006102e160a0850160808601610c8e565b61ffff1681526020808201929092526040908101600090812060a0860135825290925281209061031760e0850160c08601610ca9565b67ffffffffffffffff1667ffffffffffffffff168152602001908152602001600020600083604001602081019061034e9190610c71565b6001600160a01b03166001600160a01b031681526020019081526020016000205490508060000361039257604051630c76c27160e11b815260040160405180910390fd5b60006003816103a760a0860160808701610c8e565b61ffff1681526020808201929092526040908101600090812060a087013582529092528120906103dd60e0860160c08701610ca9565b67ffffffffffffffff1667ffffffffffffffff16815260200190815260200160002060008460400160208101906104149190610c71565b6001600160a01b03908116825260208201929092526040908101600020929092556001546104619291169083906104519060608701908701610c71565b6001600160a01b031691906105d7565b919050565b61046e6105fa565b6104786000610654565b565b6002546001600160a01b0316331461049157600080fd5b60006104d283838080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506106a492505050565b805161ffff16600090815260036020908152604080832082850151845282528083208185015167ffffffffffffffff16845282528083206001600160a01b038a16845290915281208054929350869290919061052f908490610d4f565b9091555050505050505050505050565b6105476105fa565b8060016105548282610d96565b505050565b6105616105fa565b6001600160a01b0381166105cb5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b6105d481610654565b50565b6001600160a01b0383166105ef5761055482826106df565b6105548383836107f8565b6000546001600160a01b031633146104785760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016105c2565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b604080516060810182526000808252602080830182815293830191825284015160f01c8252602284015190925260429092015160c01c905290565b8047101561072f5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e636500000060448201526064016105c2565b6000826001600160a01b03168260405160006040518083038185875af1925050503d806000811461077c576040519150601f19603f3d011682016040523d82523d6000602084013e610781565b606091505b50509050806105545760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d6179206861766520726576657274656400000000000060648201526084016105c2565b604080516001600160a01b03848116602483015260448083018590528351808403909101815260649092018352602080830180516001600160e01b031663a9059cbb60e01b17905283518085019094528084527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65649084015261055492869291600091610888918516908490610908565b90508051600014806108a95750808060200190518101906108a99190610dc7565b6105545760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016105c2565b6060610917848460008561091f565b949350505050565b6060824710156109805760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016105c2565b600080866001600160a01b0316858760405161099c9190610e0d565b60006040518083038185875af1925050503d80600081146109d9576040519150601f19603f3d011682016040523d82523d6000602084013e6109de565b606091505b50915091506109ef878383876109fa565b979650505050505050565b60608315610a69578251600003610a62576001600160a01b0385163b610a625760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016105c2565b5081610917565b6109178383815115610a7e5781518083602001fd5b8060405162461bcd60e51b81526004016105c29190610e29565b600060208284031215610aaa57600080fd5b813567ffffffffffffffff811115610ac157600080fd5b820160e08185031215610ad357600080fd5b9392505050565b803561ffff8116811461046157600080fd5b60008083601f840112610afe57600080fd5b50813567ffffffffffffffff811115610b1657600080fd5b602083019150836020828501011115610b2e57600080fd5b9250929050565b6001600160a01b03811681146105d457600080fd5b60008060008060008060008060c0898b031215610b6657600080fd5b610b6f89610ada565b9750602089013567ffffffffffffffff80821115610b8c57600080fd5b610b988c838d01610aec565b909950975060408b0135965060608b01359150610bb482610b35565b90945060808a0135935060a08a01359080821115610bd157600080fd5b50610bde8b828c01610aec565b999c989b5096995094979396929594505050565b600060408284031215610c0457600080fd5b50919050565b803567ffffffffffffffff8116811461046157600080fd5b60008060008060808587031215610c3857600080fd5b610c4185610ada565b935060208501359250610c5660408601610c0a565b91506060850135610c6681610b35565b939692955090935050565b600060208284031215610c8357600080fd5b8135610ad381610b35565b600060208284031215610ca057600080fd5b610ad382610ada565b600060208284031215610cbb57600080fd5b610ad382610c0a565b6000808335601e19843603018112610cdb57600080fd5b83018035915067ffffffffffffffff821115610cf657600080fd5b602001915036819003821315610b2e57600080fd5b61ffff85168152606060208201528260608201528284608083013760006080848301015260006080601f19601f860116830101905082604083015295945050505050565b80820180821115610d7057634e487b7160e01b600052601160045260246000fd5b92915050565b80546001600160a01b0319166001600160a01b0392909216919091179055565b8135610da181610b35565b610dab8183610d76565b506020820135610dba81610b35565b6105548160018401610d76565b600060208284031215610dd957600080fd5b81518015158114610ad357600080fd5b60005b83811015610e04578181015183820152602001610dec565b50506000910152565b60008251610e1f818460208701610de9565b9190910192915050565b6020815260008251806020840152610e48816040850160208701610de9565b601f01601f1916919091016040019291505056fea2646970667358221220541bc657aeb00f05a1e5a316c4c2d577c71b2c965955ad4ca5836d8aabbd4bd664736f6c63430008110033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106100885760003560e01c8063c028da0f1161005b578063c028da0f146100eb578063ca960930146100fe578063e06174e414610138578063f2fde38b1461017257600080fd5b80636302c1371461008d578063715018a6146100b35780638da5cb5b146100bd578063ab8236f3146100d8575b600080fd5b6100a061009b366004610a98565b610185565b6040519081526020015b60405180910390f35b6100bb610466565b005b6000546040516001600160a01b0390911681526020016100aa565b6100bb6100e6366004610b4a565b61047a565b6100bb6100f9366004610bf2565b61053f565b6100a061010c366004610c22565b600360209081526000948552604080862082529385528385208152918452828420909152825290205481565b600154600254610152916001600160a01b03908116911682565b604080516001600160a01b039384168152929091166020830152016100aa565b6100bb610180366004610c71565b610559565b6001546000906001600160a01b0316331461019f57600080fd5b600360006101b360a0850160808601610c8e565b61ffff1681526020808201929092526040908101600090812060a086013582529092528120906101e960e0850160c08601610ca9565b67ffffffffffffffff1667ffffffffffffffff16815260200190815260200160002060008360400160208101906102209190610c71565b6001600160a01b03166001600160a01b03168152602001908152602001600020549050806000036102cd576002546001600160a01b031663403a9f7a6102696020850185610c8e565b6102766060860186610cc4565b86602001356040518563ffffffff1660e01b815260040161029a9493929190610d0b565b600060405180830381600087803b1580156102b457600080fd5b505af11580156102c8573d6000803e3d6000fd5b505050505b600360006102e160a0850160808601610c8e565b61ffff1681526020808201929092526040908101600090812060a0860135825290925281209061031760e0850160c08601610ca9565b67ffffffffffffffff1667ffffffffffffffff168152602001908152602001600020600083604001602081019061034e9190610c71565b6001600160a01b03166001600160a01b031681526020019081526020016000205490508060000361039257604051630c76c27160e11b815260040160405180910390fd5b60006003816103a760a0860160808701610c8e565b61ffff1681526020808201929092526040908101600090812060a087013582529092528120906103dd60e0860160c08701610ca9565b67ffffffffffffffff1667ffffffffffffffff16815260200190815260200160002060008460400160208101906104149190610c71565b6001600160a01b03908116825260208201929092526040908101600020929092556001546104619291169083906104519060608701908701610c71565b6001600160a01b031691906105d7565b919050565b61046e6105fa565b6104786000610654565b565b6002546001600160a01b0316331461049157600080fd5b60006104d283838080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506106a492505050565b805161ffff16600090815260036020908152604080832082850151845282528083208185015167ffffffffffffffff16845282528083206001600160a01b038a16845290915281208054929350869290919061052f908490610d4f565b9091555050505050505050505050565b6105476105fa565b8060016105548282610d96565b505050565b6105616105fa565b6001600160a01b0381166105cb5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b6105d481610654565b50565b6001600160a01b0383166105ef5761055482826106df565b6105548383836107f8565b6000546001600160a01b031633146104785760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016105c2565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b604080516060810182526000808252602080830182815293830191825284015160f01c8252602284015190925260429092015160c01c905290565b8047101561072f5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e636500000060448201526064016105c2565b6000826001600160a01b03168260405160006040518083038185875af1925050503d806000811461077c576040519150601f19603f3d011682016040523d82523d6000602084013e610781565b606091505b50509050806105545760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d6179206861766520726576657274656400000000000060648201526084016105c2565b604080516001600160a01b03848116602483015260448083018590528351808403909101815260649092018352602080830180516001600160e01b031663a9059cbb60e01b17905283518085019094528084527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65649084015261055492869291600091610888918516908490610908565b90508051600014806108a95750808060200190518101906108a99190610dc7565b6105545760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016105c2565b6060610917848460008561091f565b949350505050565b6060824710156109805760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016105c2565b600080866001600160a01b0316858760405161099c9190610e0d565b60006040518083038185875af1925050503d80600081146109d9576040519150601f19603f3d011682016040523d82523d6000602084013e6109de565b606091505b50915091506109ef878383876109fa565b979650505050505050565b60608315610a69578251600003610a62576001600160a01b0385163b610a625760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016105c2565b5081610917565b6109178383815115610a7e5781518083602001fd5b8060405162461bcd60e51b81526004016105c29190610e29565b600060208284031215610aaa57600080fd5b813567ffffffffffffffff811115610ac157600080fd5b820160e08185031215610ad357600080fd5b9392505050565b803561ffff8116811461046157600080fd5b60008083601f840112610afe57600080fd5b50813567ffffffffffffffff811115610b1657600080fd5b602083019150836020828501011115610b2e57600080fd5b9250929050565b6001600160a01b03811681146105d457600080fd5b60008060008060008060008060c0898b031215610b6657600080fd5b610b6f89610ada565b9750602089013567ffffffffffffffff80821115610b8c57600080fd5b610b988c838d01610aec565b909950975060408b0135965060608b01359150610bb482610b35565b90945060808a0135935060a08a01359080821115610bd157600080fd5b50610bde8b828c01610aec565b999c989b5096995094979396929594505050565b600060408284031215610c0457600080fd5b50919050565b803567ffffffffffffffff8116811461046157600080fd5b60008060008060808587031215610c3857600080fd5b610c4185610ada565b935060208501359250610c5660408601610c0a565b91506060850135610c6681610b35565b939692955090935050565b600060208284031215610c8357600080fd5b8135610ad381610b35565b600060208284031215610ca057600080fd5b610ad382610ada565b600060208284031215610cbb57600080fd5b610ad382610c0a565b6000808335601e19843603018112610cdb57600080fd5b83018035915067ffffffffffffffff821115610cf657600080fd5b602001915036819003821315610b2e57600080fd5b61ffff85168152606060208201528260608201528284608083013760006080848301015260006080601f19601f860116830101905082604083015295945050505050565b80820180821115610d7057634e487b7160e01b600052601160045260246000fd5b92915050565b80546001600160a01b0319166001600160a01b0392909216919091179055565b8135610da181610b35565b610dab8183610d76565b506020820135610dba81610b35565b6105548160018401610d76565b600060208284031215610dd957600080fd5b81518015158114610ad357600080fd5b60005b83811015610e04578181015183820152602001610dec565b50506000910152565b60008251610e1f818460208701610de9565b9190910192915050565b6020815260008251806020840152610e48816040850160208701610de9565b601f01601f1916919091016040019291505056fea2646970667358221220541bc657aeb00f05a1e5a316c4c2d577c71b2c965955ad4ca5836d8aabbd4bd664736f6c63430008110033
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
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.