Source Code
Overview
ETH Balance
0 ETH
ETH Value
$0.00
Cross-Chain Transactions
Loading...
Loading
Contract Name:
AllBridgeAdapter
Compiler Version
v0.8.21+commit.d9974bed
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../interfaces/IAdapter.sol";
import "../interfaces/IAllBridge.sol";
import "../interfaces/IERC20.sol";
import "../libraries/SafeERC20.sol";
// The AllBridge Vault just support usdc & usdt.
contract AllBridgeAdapter is IAdapter {
address immutable router;
uint256 constant ADDRESS_MASK = 0x000000000000000000000000ffffffffffffffffffffffffffffffffffffffff;
constructor(address _router) {
router = _router;
}
function _allBridgeSwap(address to, address, bytes memory data) internal {
(bytes32 fromToken, bytes32 toToken) = abi.decode(data, (bytes32, bytes32));
uint256 amountIn = IERC20(address(uint160(ADDRESS_MASK & uint256(fromToken)))).balanceOf(address(this));
SafeERC20.safeApprove(IERC20(address(uint160(ADDRESS_MASK & uint256(fromToken)))), router, amountIn);
IAllBridge(router).swap(amountIn, fromToken, toToken, to, 1);
}
function sellBase(address to, address pool, bytes memory moreInfo)
external
override
{
_allBridgeSwap(to, pool, moreInfo);
}
function sellQuote(address to, address pool, bytes memory moreInfo)
external
override
{
_allBridgeSwap(to, pool, moreInfo);
}
}/// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
pragma abicoder v2;
interface IAdapter {
function sellBase(
address to,
address pool,
bytes memory data
) external;
function sellQuote(
address to,
address pool,
bytes memory data
) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
pragma abicoder v2;
import "./IERC20.sol";
interface IAllBridge {
function swap(
uint amount,
bytes32 token,
bytes32 receiveToken,
address recipient,
uint receiveAmountMin
) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title Interface for DAI-style permits
interface IDaiLikePermit {
function permit(
address holder,
address spender,
uint256 nonce,
uint256 expiry,
bool allowed,
uint8 v,
bytes32 r,
bytes32 s
) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IERC20 {
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
event Transfer(address indexed from, address indexed to, uint256 value);
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
function totalSupply() external view returns (uint256);
function balanceOf(address owner) external view returns (uint256);
function allowance(address owner, address spender)
external
view
returns (uint256);
function approve(address spender, uint256 value) external returns (bool);
function transfer(address to, uint256 value) external returns (bool);
function transferFrom(
address from,
address to,
uint256 value
) external returns (bool);
}// SPDX-License-Identifier: MIT
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
pragma solidity ^0.8.0;
/**
* @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
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly {
codehash := extcodehash(account)
}
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Converts an `address` into `address payable`. Note that this is
* simply a type cast: the actual underlying value is not changed.
*
* _Available since v2.4.0._
*/
function toPayable(address account)
internal
pure
returns (address payable)
{
return payable(account);
}
/**
* @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://diligence.consensys.net/posts/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.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*
* _Available since v2.4.0._
*/
function sendValue(address recipient, uint256 amount) internal {
require(
address(this).balance >= amount,
"Address: insufficient balance"
);
// solhint-disable-next-line avoid-call-value
(bool success, ) = recipient.call{value: amount}("");
require(
success,
"Address: unable to send value, recipient may have reverted"
);
}
}/// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
library RevertReasonForwarder {
function reRevert() internal pure {
// bubble up revert reason from latest external call
/// @solidity memory-safe-assembly
assembly { // solhint-disable-line no-inline-assembly
let ptr := mload(0x40)
returndatacopy(ptr, 0, returndatasize())
revert(ptr, returndatasize())
}
}
}/// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./SafeMath.sol"; import "./Address.sol"; import "./RevertReasonForwarder.sol"; import "../interfaces/IERC20.sol"; import "../interfaces/IERC20Permit.sol"; import "../interfaces/IDaiLikePermit.sol"; // File @1inch/solidity-utils/contracts/libraries/[email protected] library SafeERC20 { error SafeTransferFailed(); error SafeTransferFromFailed(); error ForceApproveFailed(); error SafeIncreaseAllowanceFailed(); error SafeDecreaseAllowanceFailed(); error SafePermitBadLength(); // Ensures method do not revert or return boolean `true`, admits call to non-smart-contract function safeTransferFrom(IERC20 token, address from, address to, uint256 amount) internal { bytes4 selector = token.transferFrom.selector; bool success; /// @solidity memory-safe-assembly assembly { // solhint-disable-line no-inline-assembly let data := mload(0x40) mstore(data, selector) mstore(add(data, 0x04), from) mstore(add(data, 0x24), to) mstore(add(data, 0x44), amount) success := call(gas(), token, 0, data, 100, 0x0, 0x20) if success { switch returndatasize() case 0 { success := gt(extcodesize(token), 0) } default { success := and(gt(returndatasize(), 31), eq(mload(0), 1)) } } } if (!success) revert SafeTransferFromFailed(); } // Ensures method do not revert or return boolean `true`, admits call to non-smart-contract function safeTransfer(IERC20 token, address to, uint256 value) internal { if (!_makeCall(token, token.transfer.selector, to, value)) { revert SafeTransferFailed(); } } function safeApprove(IERC20 token, address spender, uint256 value) internal { forceApprove(token, spender, value); } // If `approve(from, to, amount)` fails, try to `approve(from, to, 0)` before retry function forceApprove(IERC20 token, address spender, uint256 value) internal { if (!_makeCall(token, token.approve.selector, spender, value)) { if (!_makeCall(token, token.approve.selector, spender, 0) || !_makeCall(token, token.approve.selector, spender, value)) { revert ForceApproveFailed(); } } } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 allowance = token.allowance(address(this), spender); if (value > type(uint256).max - allowance) revert SafeIncreaseAllowanceFailed(); forceApprove(token, spender, allowance + value); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 allowance = token.allowance(address(this), spender); if (value > allowance) revert SafeDecreaseAllowanceFailed(); forceApprove(token, spender, allowance - value); } function safePermit(IERC20 token, bytes calldata permit) internal { bool success; if (permit.length == 32 * 7) { success = _makeCalldataCall(token, IERC20Permit.permit.selector, permit); } else if (permit.length == 32 * 8) { success = _makeCalldataCall(token, IDaiLikePermit.permit.selector, permit); } else { revert SafePermitBadLength(); } if (!success) RevertReasonForwarder.reRevert(); } function _makeCall(IERC20 token, bytes4 selector, address to, uint256 amount) private returns(bool success) { /// @solidity memory-safe-assembly assembly { // solhint-disable-line no-inline-assembly let data := mload(0x40) mstore(data, selector) mstore(add(data, 0x04), to) mstore(add(data, 0x24), amount) success := call(gas(), token, 0, data, 0x44, 0x0, 0x20) if success { switch returndatasize() case 0 { success := gt(extcodesize(token), 0) } default { success := and(gt(returndatasize(), 31), eq(mload(0), 1)) } } } } function _makeCalldataCall(IERC20 token, bytes4 selector, bytes calldata args) private returns(bool success) { /// @solidity memory-safe-assembly assembly { // solhint-disable-line no-inline-assembly let len := add(4, args.length) let data := mload(0x40) mstore(data, selector) calldatacopy(add(data, 0x04), args.offset, args.length) success := call(gas(), token, 0, data, len, 0x0, 0x20) if success { switch returndatasize() case 0 { success := gt(extcodesize(token), 0) } default { success := and(gt(returndatasize(), 31), eq(mload(0), 1)) } } } } }
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
library SafeMath {
uint256 constant WAD = 10**18;
uint256 constant RAY = 10**27;
function wad() public pure returns (uint256) {
return WAD;
}
function ray() public pure returns (uint256) {
return RAY;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a <= b ? a : b;
}
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a >= b ? a : b;
}
function sqrt(uint256 a) internal pure returns (uint256 b) {
if (a > 3) {
b = a;
uint256 x = a / 2 + 1;
while (x < b) {
b = x;
x = (a / x + x) / 2;
}
} else if (a != 0) {
b = 1;
}
}
function wmul(uint256 a, uint256 b) internal pure returns (uint256) {
return mul(a, b) / WAD;
}
function wmulRound(uint256 a, uint256 b) internal pure returns (uint256) {
return add(mul(a, b), WAD / 2) / WAD;
}
function rmul(uint256 a, uint256 b) internal pure returns (uint256) {
return mul(a, b) / RAY;
}
function rmulRound(uint256 a, uint256 b) internal pure returns (uint256) {
return add(mul(a, b), RAY / 2) / RAY;
}
function wdiv(uint256 a, uint256 b) internal pure returns (uint256) {
return div(mul(a, WAD), b);
}
function wdivRound(uint256 a, uint256 b) internal pure returns (uint256) {
return add(mul(a, WAD), b / 2) / b;
}
function rdiv(uint256 a, uint256 b) internal pure returns (uint256) {
return div(mul(a, RAY), b);
}
function rdivRound(uint256 a, uint256 b) internal pure returns (uint256) {
return add(mul(a, RAY), b / 2) / b;
}
function wpow(uint256 x, uint256 n) internal pure returns (uint256) {
uint256 result = WAD;
while (n > 0) {
if (n % 2 != 0) {
result = wmul(result, x);
}
x = wmul(x, x);
n /= 2;
}
return result;
}
function rpow(uint256 x, uint256 n) internal pure returns (uint256) {
uint256 result = RAY;
while (n > 0) {
if (n % 2 != 0) {
result = rmul(result, x);
}
x = rmul(x, x);
n /= 2;
}
return result;
}
function divCeil(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 quotient = div(a, b);
uint256 remainder = a - quotient * b;
if (remainder > 0) {
return quotient + 1;
} else {
return quotient;
}
}
}{
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_router","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ForceApproveFailed","type":"error"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"address","name":"pool","type":"address"},{"internalType":"bytes","name":"moreInfo","type":"bytes"}],"name":"sellBase","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"address","name":"pool","type":"address"},{"internalType":"bytes","name":"moreInfo","type":"bytes"}],"name":"sellQuote","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
60a060405234801561000f575f80fd5b5060405161045c38038061045c83398101604081905261002e9161003f565b6001600160a01b031660805261006c565b5f6020828403121561004f575f80fd5b81516001600160a01b0381168114610065575f80fd5b9392505050565b6080516103d261008a5f395f818160f1015261015101526103d25ff3fe608060405234801561000f575f80fd5b5060043610610034575f3560e01c806330e6ae31146100385780636f7929f214610038575b5f80fd5b61004b610046366004610298565b61004d565b005b61005883838361005d565b505050565b5f80828060200190518101906100739190610363565b6040516370a0823160e01b815230600482015291935091505f906001600160a01b038416906370a0823190602401602060405180830381865afa1580156100bc573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906100e09190610385565b90506101166001600160a01b0384167f0000000000000000000000000000000000000000000000000000000000000000836101b0565b60405163198c1c5960e11b81526004810182905260248101849052604481018390526001600160a01b038781166064830152600160848301527f0000000000000000000000000000000000000000000000000000000000000000169063331838b29060a4015f604051808303815f87803b158015610192575f80fd5b505af11580156101a4573d5f803e3d5ffd5b50505050505050505050565b6100588383836101c98363095ea7b360e01b848461021a565b610058576101e08363095ea7b360e01b845f61021a565b15806101fc57506101fa8363095ea7b360e01b848461021a565b155b156100585760405163019be9a960e41b815260040160405180910390fd5b5f60405184815283600482015282602482015260205f6044835f8a5af19150508015610261573d80156102585760015f5114601f3d1116915061025f565b5f863b1191505b505b949350505050565b80356001600160a01b038116811461027f575f80fd5b919050565b634e487b7160e01b5f52604160045260245ffd5b5f805f606084860312156102aa575f80fd5b6102b384610269565b92506102c160208501610269565b9150604084013567ffffffffffffffff808211156102dd575f80fd5b818601915086601f8301126102f0575f80fd5b81358181111561030257610302610284565b604051601f8201601f19908116603f0116810190838211818310171561032a5761032a610284565b81604052828152896020848701011115610342575f80fd5b826020860160208301375f6020848301015280955050505050509250925092565b5f8060408385031215610374575f80fd5b505080516020909101519092909150565b5f60208284031215610395575f80fd5b505191905056fea26469706673582212201d5e5f980ca879b704c2e8fe707f5c0ae74fb37ae7bd87d09ee9058f1fcdfeb664736f6c63430008150033000000000000000000000000d5cc9ccbd4144385ff1f8c75bf66236f1f779c3d
Deployed Bytecode
0x608060405234801561000f575f80fd5b5060043610610034575f3560e01c806330e6ae31146100385780636f7929f214610038575b5f80fd5b61004b610046366004610298565b61004d565b005b61005883838361005d565b505050565b5f80828060200190518101906100739190610363565b6040516370a0823160e01b815230600482015291935091505f906001600160a01b038416906370a0823190602401602060405180830381865afa1580156100bc573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906100e09190610385565b90506101166001600160a01b0384167f000000000000000000000000d5cc9ccbd4144385ff1f8c75bf66236f1f779c3d836101b0565b60405163198c1c5960e11b81526004810182905260248101849052604481018390526001600160a01b038781166064830152600160848301527f000000000000000000000000d5cc9ccbd4144385ff1f8c75bf66236f1f779c3d169063331838b29060a4015f604051808303815f87803b158015610192575f80fd5b505af11580156101a4573d5f803e3d5ffd5b50505050505050505050565b6100588383836101c98363095ea7b360e01b848461021a565b610058576101e08363095ea7b360e01b845f61021a565b15806101fc57506101fa8363095ea7b360e01b848461021a565b155b156100585760405163019be9a960e41b815260040160405180910390fd5b5f60405184815283600482015282602482015260205f6044835f8a5af19150508015610261573d80156102585760015f5114601f3d1116915061025f565b5f863b1191505b505b949350505050565b80356001600160a01b038116811461027f575f80fd5b919050565b634e487b7160e01b5f52604160045260245ffd5b5f805f606084860312156102aa575f80fd5b6102b384610269565b92506102c160208501610269565b9150604084013567ffffffffffffffff808211156102dd575f80fd5b818601915086601f8301126102f0575f80fd5b81358181111561030257610302610284565b604051601f8201601f19908116603f0116810190838211818310171561032a5761032a610284565b81604052828152896020848701011115610342575f80fd5b826020860160208301375f6020848301015280955050505050509250925092565b5f8060408385031215610374575f80fd5b505080516020909101519092909150565b5f60208284031215610395575f80fd5b505191905056fea26469706673582212201d5e5f980ca879b704c2e8fe707f5c0ae74fb37ae7bd87d09ee9058f1fcdfeb664736f6c63430008150033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000d5cc9ccbd4144385ff1f8c75bf66236f1f779c3d
-----Decoded View---------------
Arg [0] : _router (address): 0xd5CC9ccBD4144385ff1f8C75BF66236F1F779c3d
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000d5cc9ccbd4144385ff1f8c75bf66236f1f779c3d
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 32 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
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.