Contract Overview
Balance:
0 MATIC
MATIC Value:
$0.00
My Name Tag:
Not Available, login to update
Txn Hash |
Method
|
Block
|
From
|
To
|
Value | [Txn Fee] | |||
---|---|---|---|---|---|---|---|---|---|
0xd22513cece9733e0817aa7241b6a98b85874ac3a6058ffbe532df1f673fccfa4 | 0x60806040 | 16875073 | 562 days 12 hrs ago | 0xb0dd96118594903bacb2746eb228550c10b2b1da | IN | Create: QuickswapLogic | 0 MATIC | 0.001327279132 |
[ Download CSV Export ]
Contract Name:
QuickswapLogic
Compiler Version
v0.8.4+commit.c7e474f2
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @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 `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, 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 `sender` to `recipient` 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 sender, address recipient, uint256 amount) external returns (bool); /** * @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); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20.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; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } 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' // solhint-disable-next-line max-line-length 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)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } 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"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @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"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// 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) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 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://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]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (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 functionCall(target, data, "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"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(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) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(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) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // 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 // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } }
//SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IMemory { function getUint(uint256) external view returns (uint256); function setUint(uint256 id, uint256 value) external; function getAToken(address asset) external view returns (address); function setAToken(address asset, address _aToken) external; function getCrToken(address asset) external view returns (address); function setCrToken(address asset, address _crToken) external; }
//SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @title RegistryInterface Interface */ interface IRegistry { function logic(address logicAddr) external view returns (bool); function implementation(bytes32 key) external view returns (address); function notAllowed(address erc20) external view returns (bool); function deployWallet() external returns (address); function wallets(address user) external view returns (address); function getFee() external view returns (uint256); function feeRecipient() external view returns (address); function memoryAddr() external view returns (address); function distributionContract(address token) external view returns (address); }
//SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "../libs/UniversalERC20.sol"; interface IUniswapV2Exchange { function swap( uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data ) external; } library UniswapV2ExchangeLib { using SafeMath for uint256; using UniversalERC20 for IERC20; function getReturn( IUniswapV2Exchange exchange, IERC20 fromToken, IERC20 destToken, uint256 amountIn ) internal view returns (uint256) { uint256 reserveIn = fromToken.universalBalanceOf(address(exchange)); uint256 reserveOut = destToken.universalBalanceOf(address(exchange)); uint256 amountInWithFee = amountIn.mul(997); uint256 numerator = amountInWithFee.mul(reserveOut); uint256 denominator = reserveIn.mul(1000).add(amountInWithFee); return (denominator == 0) ? 0 : numerator.div(denominator); } }
//SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IUniswapV2Router { function factory() external pure returns (address); function WETH() external pure returns (address); function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts); function addLiquidity( address tokenA, address tokenB, uint256 amountADesired, uint256 amountBDesired, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline ) external returns ( uint256 amountA, uint256 amountB, uint256 liquidity ); function removeLiquidity( address tokenA, address tokenB, uint256 liquidity, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline ) external returns (uint256 amountA, uint256 amountB); function swapExactTokensForTokens( uint256 amountIn, uint256 amountOutMin, address[] calldata path, address to, uint256 deadline ) external returns (uint256[] memory amounts); }
//SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; abstract contract IWETH is IERC20 { function deposit() external payable virtual; function withdraw(uint256 amount) external virtual; }
//SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IWallet { event LogMint(address indexed erc20, uint256 tokenAmt); event LogRedeem(address indexed erc20, uint256 tokenAmt); event LogBorrow(address indexed erc20, uint256 tokenAmt); event LogPayback(address indexed erc20, uint256 tokenAmt); event LogDeposit(address indexed erc20, uint256 tokenAmt); event LogWithdraw(address indexed erc20, uint256 tokenAmt); event LogSwap(address indexed src, address indexed dest, uint256 amount); event LogLiquidityAdd( address indexed tokenA, address indexed tokenB, uint256 amountA, uint256 amountB ); event LogLiquidityRemove( address indexed tokenA, address indexed tokenB, uint256 amountA, uint256 amountB ); event VaultDeposit(address indexed erc20, uint256 tokenAmt); event VaultWithdraw(address indexed erc20, uint256 tokenAmt); event VaultClaim(address indexed erc20, uint256 tokenAmt); event DelegateAdded(address delegate); event DelegateRemoved(address delegate); function executeMetaTransaction(bytes memory sign, bytes memory data) external; function execute(address[] calldata targets, bytes[] calldata datas) external payable; function owner() external view returns (address); function registry() external view returns (address); function DELEGATE_ROLE() external view returns (bytes32); function hasRole(bytes32, address) external view returns (bool); }
//SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; library UniversalERC20 { using SafeMath for uint256; using SafeERC20 for IERC20; IERC20 private constant ZERO_ADDRESS = IERC20(0x0000000000000000000000000000000000000000); IERC20 private constant ETH_ADDRESS = IERC20(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE); function universalTransfer( IERC20 token, address to, uint256 amount ) internal returns (bool success) { if (amount == 0) { return true; } if (isETH(token)) { payable(to).transfer(amount); } else { token.safeTransfer(to, amount); return true; } } function universalTransferFrom( IERC20 token, address from, address to, uint256 amount ) internal { if (amount == 0) { return; } if (isETH(token)) { require( from == msg.sender && msg.value >= amount, "Wrong useage of ETH.universalTransferFrom()" ); if (to != address(this)) { payable(to).transfer(amount); } if (msg.value > amount) { payable(msg.sender).transfer(msg.value.sub(amount)); } } else { token.safeTransferFrom(from, to, amount); } } function universalTransferFromSenderToThis(IERC20 token, uint256 amount) internal { if (amount == 0) { return; } if (isETH(token)) { if (msg.value > amount) { // Return remainder if exist payable(msg.sender).transfer(msg.value.sub(amount)); } } else { token.safeTransferFrom(msg.sender, address(this), amount); } } function universalApprove( IERC20 token, address to, uint256 amount ) internal { if (!isETH(token)) { if (amount == 0) { token.safeApprove(to, 0); return; } uint256 allowance = token.allowance(address(this), to); if (allowance < amount) { if (allowance > 0) { token.safeApprove(to, 0); } token.safeApprove(to, amount); } } } function universalBalanceOf(IERC20 token, address who) internal view returns (uint256) { if (isETH(token)) { return who.balance; } else { return token.balanceOf(who); } } function universalDecimals(IERC20 token) internal view returns (uint256) { if (isETH(token)) { return 18; } (bool success, bytes memory data) = address(token).staticcall{gas: 10000}( abi.encodeWithSignature("decimals()") ); if (!success || data.length == 0) { (success, data) = address(token).staticcall{gas: 10000}( abi.encodeWithSignature("DECIMALS()") ); } return (success && data.length > 0) ? abi.decode(data, (uint256)) : 18; } function isETH(IERC20 token) internal pure returns (bool) { return (address(token) == address(ZERO_ADDRESS) || address(token) == address(ETH_ADDRESS)); } }
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; import "../interfaces/IMemory.sol"; import "../interfaces/IRegistry.sol"; import "../interfaces/IWallet.sol"; contract Helpers { /** * @dev Return Memory Variable Address */ function getMemoryAddr() public view returns (address) { return IRegistry(IWallet(address(this)).registry()).memoryAddr(); } /** * @dev Get Uint value from Memory Contract. */ function getUint(uint256 id) internal view returns (uint256) { return IMemory(getMemoryAddr()).getUint(id); } /** * @dev Set Uint value in Memory Contract. */ function setUint(uint256 id, uint256 val) internal { IMemory(getMemoryAddr()).setUint(id, val); } /** * @dev Get aToken address from Memory Contract. */ function getAToken(address asset) internal view returns (address) { return IMemory(getMemoryAddr()).getAToken(asset); } /** * @dev Get crToken address from Memory Contract. */ function getCrToken(address asset) internal view returns (address) { return IMemory(getMemoryAddr()).getCrToken(asset); } }
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; import "../interfaces/IUniswapV2Router.sol"; import "../interfaces/IUniswapV2Exchange.sol"; import "../interfaces/IWETH.sol"; import "../libs/UniversalERC20.sol"; import "./Helpers.sol"; contract QuickswapResolver is Helpers { using SafeMath for uint256; using UniversalERC20 for IERC20; using UniversalERC20 for IWETH; IUniswapV2Router internal constant router = IUniswapV2Router(0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff); IWETH internal constant wmatic = IWETH(0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270); // EVENTS event LogSwap(address indexed src, address indexed dest, uint256 amount); event LogLiquidityAdd( address indexed tokenA, address indexed tokenB, uint256 amountA, uint256 amountB ); event LogLiquidityRemove( address indexed tokenA, address indexed tokenB, uint256 amountA, uint256 amountB ); /** * @dev Swap tokens in Quickswap dex * @param path swap route fromToken => destToken * @param tokenAmt amount of fromTokens to swap * @param getId read value of tokenAmt from memory contract * @param setId set value of tokens swapped in memory contract */ function swap( address[] memory path, uint256 tokenAmt, uint256 getId, uint256 setId, uint256 divider ) external payable { require(path.length >= 2, "INVALID PATH"); uint256 realAmt = getId > 0 ? getUint(getId).div(divider) : tokenAmt; require(realAmt > 0, "ZERO AMOUNT"); IERC20 fromToken = IERC20(path[0]); IERC20 destToken = IERC20(path[path.length - 1]); if (fromToken.isETH()) { wmatic.deposit{value: realAmt}(); wmatic.universalApprove(address(router), realAmt); path[0] = address(wmatic); } else fromToken.universalApprove(address(router), realAmt); if (destToken.isETH()) path[path.length - 1] = address(wmatic); require(path[0] != path[path.length - 1], "SAME ASSETS"); uint256 received = router.swapExactTokensForTokens( realAmt, 1, path, address(this), block.timestamp + 1 )[path.length - 1]; if (destToken.isETH()) { wmatic.withdraw(received); } // set destTokens received if (setId > 0) { setUint(setId, received); } emit LogSwap(address(fromToken), address(destToken), realAmt); } /** * @dev Add liquidity to Quickswap pools * @param amtA amount of A tokens to add * @param amtB amount of B tokens to add * @param getId read value of tokenAmt from memory contract position 1 * @param getId2 read value of tokenAmt from memory contract position 2 * @param setId set value of LP tokens received in memory contract */ function addLiquidity( IERC20 tokenA, IERC20 tokenB, uint256 amtA, uint256 amtB, uint256 getId, uint256 getId2, uint256 setId, uint256 divider ) external payable { uint256 realAmtA = getId > 0 ? getUint(getId).div(divider) : amtA; uint256 realAmtB = getId2 > 0 ? getUint(getId2).div(divider) : amtB; require(realAmtA > 0 && realAmtB > 0, "INVALID AMOUNTS"); IERC20 tokenAReal = tokenA.isETH() ? wmatic : tokenA; IERC20 tokenBReal = tokenB.isETH() ? wmatic : tokenB; // Wrap Ether if (tokenA.isETH()) { wmatic.deposit{value: realAmtA}(); } if (tokenB.isETH()) { wmatic.deposit{value: realAmtB}(); } // Approve Router tokenAReal.universalApprove(address(router), realAmtA); tokenBReal.universalApprove(address(router), realAmtB); (uint256 amountA, uint256 amountB, uint256 liquidity) = router .addLiquidity( address(tokenAReal), address(tokenBReal), realAmtA, realAmtB, 1, 1, address(this), block.timestamp + 1 ); // set aTokens received if (setId > 0) { setUint(setId, liquidity); } emit LogLiquidityAdd( address(tokenAReal), address(tokenBReal), amountA, amountB ); } /** * @dev Remove liquidity from Quickswap pool * @param tokenA address of token A from the pool * @param tokenA address of token B from the pool * @param poolToken address of the LP token * @param amtPoolTokens amount of LP tokens to burn * @param getId read value from memory contract * @param setId set value of amount tokenB received in memory contract position 1 * @param setId2 set value of amount tokenB received in memory contract position 2 */ function removeLiquidity( IERC20 tokenA, IERC20 tokenB, IERC20 poolToken, uint256 amtPoolTokens, uint256 getId, uint256 setId, uint256 setId2, uint256 divider ) external payable { uint256 realAmt = getId > 0 ? getUint(getId).div(divider) : amtPoolTokens; IERC20 tokenAReal = tokenA.isETH() ? wmatic : tokenA; IERC20 tokenBReal = tokenB.isETH() ? wmatic : tokenB; // Approve Router IERC20(address(poolToken)).universalApprove(address(router), realAmt); (uint256 amountA, uint256 amountB) = router.removeLiquidity( address(tokenAReal), address(tokenBReal), realAmt, 1, 1, address(this), block.timestamp + 1 ); // set tokenA received if (setId > 0) { setUint(setId, amountA); } // set tokenA received if (setId2 > 0) { setUint(setId2, amountB); } emit LogLiquidityRemove( address(tokenAReal), address(tokenBReal), amountA, amountB ); } } contract QuickswapLogic is QuickswapResolver { receive() external payable {} }
{ "evmVersion": "istanbul", "libraries": {}, "metadata": { "bytecodeHash": "ipfs", "useLiteralContent": true }, "optimizer": { "enabled": true, "runs": 200 }, "remappings": [], "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"tokenA","type":"address"},{"indexed":true,"internalType":"address","name":"tokenB","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountA","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountB","type":"uint256"}],"name":"LogLiquidityAdd","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"tokenA","type":"address"},{"indexed":true,"internalType":"address","name":"tokenB","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountA","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountB","type":"uint256"}],"name":"LogLiquidityRemove","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"src","type":"address"},{"indexed":true,"internalType":"address","name":"dest","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"LogSwap","type":"event"},{"inputs":[{"internalType":"contract IERC20","name":"tokenA","type":"address"},{"internalType":"contract IERC20","name":"tokenB","type":"address"},{"internalType":"uint256","name":"amtA","type":"uint256"},{"internalType":"uint256","name":"amtB","type":"uint256"},{"internalType":"uint256","name":"getId","type":"uint256"},{"internalType":"uint256","name":"getId2","type":"uint256"},{"internalType":"uint256","name":"setId","type":"uint256"},{"internalType":"uint256","name":"divider","type":"uint256"}],"name":"addLiquidity","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"getMemoryAddr","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"tokenA","type":"address"},{"internalType":"contract IERC20","name":"tokenB","type":"address"},{"internalType":"contract IERC20","name":"poolToken","type":"address"},{"internalType":"uint256","name":"amtPoolTokens","type":"uint256"},{"internalType":"uint256","name":"getId","type":"uint256"},{"internalType":"uint256","name":"setId","type":"uint256"},{"internalType":"uint256","name":"setId2","type":"uint256"},{"internalType":"uint256","name":"divider","type":"uint256"}],"name":"removeLiquidity","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address[]","name":"path","type":"address[]"},{"internalType":"uint256","name":"tokenAmt","type":"uint256"},{"internalType":"uint256","name":"getId","type":"uint256"},{"internalType":"uint256","name":"setId","type":"uint256"},{"internalType":"uint256","name":"divider","type":"uint256"}],"name":"swap","outputs":[],"stateMutability":"payable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
608060405234801561001057600080fd5b5061170d806100206000396000f3fe6080604052600436106100435760003560e01c80633145cbb41461004f57806390d4369714610064578063ba1ffd0314610077578063fa821c9b1461008a57600080fd5b3661004a57005b600080fd5b61006261005d3660046113bc565b6100bb565b005b610062610072366004611249565b6102d0565b610062610085366004611432565b6107f3565b34801561009657600080fd5b5061009f610b96565b6040516001600160a01b03909116815260200160405180910390f35b60008085116100ca57856100dd565b6100dd826100d787610c7e565b90610d0b565b905060006100f38a6001600160a01b0316610d1e565b6100fd5789610113565b730d500b1d8e8ef31e21c99d1db9a6444d3adf12705b905060006101298a6001600160a01b0316610d1e565b6101335789610149565b730d500b1d8e8ef31e21c99d1db9a6444d3adf12705b90506101736001600160a01b038a1673a5e0829caced8ffdd4de3c43696c57f7d7a678ff85610d57565b60008073a5e0829caced8ffdd4de3c43696c57f7d7a678ff63baa2abde858588600180306101a14283611618565b60405160e089901b6001600160e01b03191681526001600160a01b039788166004820152958716602487015260448601949094526064850192909252608484015290921660a482015260c481019190915260e4016040805180830381600087803b15801561020e57600080fd5b505af1158015610222573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061024691906114b4565b9092509050871561025b5761025b8883610e45565b861561026b5761026b8782610e45565b826001600160a01b0316846001600160a01b03167f45f6d7544bb29446542d65c92e426535ed61bd26d0faca61c7137df272e3636f84846040516102b9929190918252602082015260400190565b60405180910390a350505050505050505050505050565b6002855110156103165760405162461bcd60e51b815260206004820152600c60248201526b0929cac8298928840a082a8960a31b60448201526064015b60405180910390fd5b60008084116103255784610332565b610332826100d786610c7e565b9050600081116103725760405162461bcd60e51b815260206004820152600b60248201526a16915493c8105353d5539560aa1b604482015260640161030d565b60008660008151811061039557634e487b7160e01b600052603260045260246000fd5b60200260200101519050600087600189516103b09190611650565b815181106103ce57634e487b7160e01b600052603260045260246000fd5b602002602001015190506103ea826001600160a01b0316610d1e565b156104e957730d500b1d8e8ef31e21c99d1db9a6444d3adf12706001600160a01b031663d0e30db0846040518263ffffffff1660e01b81526004016000604051808303818588803b15801561043e57600080fd5b505af1158015610452573d6000803e3d6000fd5b5061048e9350730d500b1d8e8ef31e21c99d1db9a6444d3adf1270925073a5e0829caced8ffdd4de3c43696c57f7d7a678ff9150869050610d57565b730d500b1d8e8ef31e21c99d1db9a6444d3adf1270886000815181106104c457634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b031681525050610511565b6105116001600160a01b03831673a5e0829caced8ffdd4de3c43696c57f7d7a678ff85610d57565b610523816001600160a01b0316610d1e565b1561058b57730d500b1d8e8ef31e21c99d1db9a6444d3adf12708860018a5161054c9190611650565b8151811061056a57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b0316815250505b876001895161059a9190611650565b815181106105b857634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b0316886000815181106105ea57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b031614156106375760405162461bcd60e51b815260206004820152600b60248201526a53414d452041535345545360a81b604482015260640161030d565b600073a5e0829caced8ffdd4de3c43696c57f7d7a678ff6338ed17398560018c306106624284611618565b6040518663ffffffff1660e01b8152600401610682959493929190611553565b600060405180830381600087803b15801561069c57600080fd5b505af11580156106b0573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526106d89190810190611309565b60018a516106e69190611650565b8151811061070457634e487b7160e01b600052603260045260246000fd5b60200260200101519050610720826001600160a01b0316610d1e565b1561078b57604051632e1a7d4d60e01b815260048101829052730d500b1d8e8ef31e21c99d1db9a6444d3adf127090632e1a7d4d90602401600060405180830381600087803b15801561077257600080fd5b505af1158015610786573d6000803e3d6000fd5b505050505b851561079b5761079b8682610e45565b816001600160a01b0316836001600160a01b03167f97a2ac50c3be9b01862011d786db2a0db9e7ebff678bccfc2c8ed1698f2b0913866040516107e091815260200190565b60405180910390a3505050505050505050565b6000808511610802578661080f565b61080f826100d787610c7e565b90506000808511610820578661082d565b61082d836100d787610c7e565b905060008211801561083f5750600081115b61087d5760405162461bcd60e51b815260206004820152600f60248201526e494e56414c494420414d4f554e545360881b604482015260640161030d565b60006108918b6001600160a01b0316610d1e565b61089b578a6108b1565b730d500b1d8e8ef31e21c99d1db9a6444d3adf12705b905060006108c78b6001600160a01b0316610d1e565b6108d1578a6108e7565b730d500b1d8e8ef31e21c99d1db9a6444d3adf12705b90506108fb8c6001600160a01b0316610d1e565b1561096957730d500b1d8e8ef31e21c99d1db9a6444d3adf12706001600160a01b031663d0e30db0856040518263ffffffff1660e01b81526004016000604051808303818588803b15801561094f57600080fd5b505af1158015610963573d6000803e3d6000fd5b50505050505b61097b8b6001600160a01b0316610d1e565b156109e957730d500b1d8e8ef31e21c99d1db9a6444d3adf12706001600160a01b031663d0e30db0846040518263ffffffff1660e01b81526004016000604051808303818588803b1580156109cf57600080fd5b505af11580156109e3573d6000803e3d6000fd5b50505050505b610a116001600160a01b03831673a5e0829caced8ffdd4de3c43696c57f7d7a678ff86610d57565b610a396001600160a01b03821673a5e0829caced8ffdd4de3c43696c57f7d7a678ff85610d57565b6000808073a5e0829caced8ffdd4de3c43696c57f7d7a678ff63e8e3370086868a8a60018030610a694283611618565b60405160e08a901b6001600160e01b03191681526001600160a01b039889166004820152968816602488015260448701959095526064860193909352608485019190915260a484015290921660c482015260e481019190915261010401606060405180830381600087803b158015610ae057600080fd5b505af1158015610af4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b1891906114d7565b919450925090508815610b2f57610b2f8982610e45565b836001600160a01b0316856001600160a01b03167f1a51391fad825e66369b29a1916819cb01e8d05cade4f39bfe7c6ea4edabb80a8585604051610b7d929190918252602082015260400190565b60405180910390a3505050505050505050505050505050565b6000306001600160a01b0316637b1039996040518163ffffffff1660e01b815260040160206040518083038186803b158015610bd157600080fd5b505afa158015610be5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c09919061122d565b6001600160a01b031663f54ad35f6040518163ffffffff1660e01b815260040160206040518083038186803b158015610c4157600080fd5b505afa158015610c55573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c79919061122d565b905090565b6000610c88610b96565b6001600160a01b031663a9c70eaa836040518263ffffffff1660e01b8152600401610cb591815260200190565b60206040518083038186803b158015610ccd57600080fd5b505afa158015610ce1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d05919061149c565b92915050565b6000610d178284611630565b9392505050565b60006001600160a01b0382161580610d0557506001600160a01b03821673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1492915050565b610d6083610d1e565b610d7e5780610d8357610d7e6001600160a01b038416836000610eb4565b505050565b604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e9060440160206040518083038186803b158015610dce57600080fd5b505afa158015610de2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e06919061149c565b905081811015610e3f578015610e2b57610e2b6001600160a01b038516846000610eb4565b610e3f6001600160a01b0385168484610eb4565b50505050565b610e4d610b96565b604051631878f25160e21b815260048101849052602481018390526001600160a01b0391909116906361e3c94490604401600060405180830381600087803b158015610e9857600080fd5b505af1158015610eac573d6000803e3d6000fd5b505050505050565b801580610f3d5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b158015610f0357600080fd5b505afa158015610f17573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f3b919061149c565b155b610fa85760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b606482015260840161030d565b604080516001600160a01b03848116602483015260448083018590528351808403909101815260649092018352602080830180516001600160e01b031663095ea7b360e01b17905283518085019094528084527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656490840152610d7e928692916000916110389185169084906110b5565b805190915015610d7e5780806020019051810190611056919061139c565b610d7e5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161030d565b60606110c484846000856110cc565b949350505050565b60608247101561112d5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161030d565b843b61117b5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161030d565b600080866001600160a01b031685876040516111979190611504565b60006040518083038185875af1925050503d80600081146111d4576040519150601f19603f3d011682016040523d82523d6000602084013e6111d9565b606091505b50915091506111e98282866111f4565b979650505050505050565b60608315611203575081610d17565b8251156112135782518084602001fd5b8160405162461bcd60e51b815260040161030d9190611520565b60006020828403121561123e578081fd5b8151610d17816116bf565b600080600080600060a08688031215611260578081fd5b853567ffffffffffffffff811115611276578182fd5b8601601f81018813611286578182fd5b8035602061129b611296836115f4565b6115c3565b8083825282820191508285018c848660051b88010111156112ba578687fd5b8695505b848610156112e55780356112d1816116bf565b8352600195909501949183019183016112be565b509b918a01359a505060408901359860608101359850608001359650945050505050565b6000602080838503121561131b578182fd5b825167ffffffffffffffff811115611331578283fd5b8301601f81018513611341578283fd5b805161134f611296826115f4565b80828252848201915084840188868560051b870101111561136e578687fd5b8694505b83851015611390578051835260019490940193918501918501611372565b50979650505050505050565b6000602082840312156113ad578081fd5b81518015158114610d17578182fd5b600080600080600080600080610100898b0312156113d8578283fd5b88356113e3816116bf565b975060208901356113f3816116bf565b96506040890135611403816116bf565b979a96995096976060810135975060808101359660a0820135965060c0820135955060e0909101359350915050565b600080600080600080600080610100898b03121561144e578384fd5b8835611459816116bf565b97506020890135611469816116bf565b979a9799505050506040860135956060810135956080820135955060a0820135945060c0820135935060e0909101359150565b6000602082840312156114ad578081fd5b5051919050565b600080604083850312156114c6578182fd5b505080516020909101519092909150565b6000806000606084860312156114eb578283fd5b8351925060208401519150604084015190509250925092565b60008251611516818460208701611667565b9190910192915050565b602081526000825180602084015261153f816040850160208701611667565b601f01601f19169190910160400192915050565b600060a082018783526020878185015260a0604085015281875180845260c0860191508289019350845b818110156115a25784516001600160a01b03168352938301939183019160010161157d565b50506001600160a01b03969096166060850152505050608001529392505050565b604051601f8201601f1916810167ffffffffffffffff811182821017156115ec576115ec6116a9565b604052919050565b600067ffffffffffffffff82111561160e5761160e6116a9565b5060051b60200190565b6000821982111561162b5761162b611693565b500190565b60008261164b57634e487b7160e01b81526012600452602481fd5b500490565b60008282101561166257611662611693565b500390565b60005b8381101561168257818101518382015260200161166a565b83811115610e3f5750506000910152565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146116d457600080fd5b5056fea2646970667358221220f8f06da9c383b0813a596616fd3700c47df10112299044bedae3866109994c9f64736f6c63430008040033
Age | Block | Fee Address | BC Fee Address | Voting Power | Jailed | Incoming |
---|
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.