pragma solidity ^0.8.0;
|
|
interface IERC20 {
|
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
|
function approve(address spender, uint256 amount) external returns (bool);
|
function transfer(address to, uint256 amount) external returns (bool);
|
function balanceOf(address account) external view returns (uint256);
|
function allowance(address _owner, address spender) external view returns (uint256);
|
}
|
|
contract ANDAOContract {
|
using SafeMath for uint256;
|
address owner;
|
address private usdtAddress = 0x55d398326f99059fF775485246999027B3197955;
|
IERC20 private usdtToken;
|
|
constructor() {
|
usdtToken = IERC20(usdtAddress);
|
owner = 0xCe74955CF5289E803EE518902076eF42BB09b7a8;
|
}
|
|
address blpSwap = 0x1562e481cEF00B14693e43465444B726739e0CBA;
|
address alpSwap = 0x3614B30913f284e8868d7f6814Bbcb62e3f84127;
|
|
event received(address indexed from, uint256 amount,string regFlow);
|
event withdrawn(address indexed to, uint256 amount);
|
|
function receiveANDAO(uint256 amount,string calldata regFlow) external {
|
uint256 allowance = usdtToken.allowance(msg.sender, address(this));
|
require(allowance >= amount, "Insufficient allowance");
|
|
bool transferSuccessful = usdtToken.transferFrom(msg.sender, address(this), amount);
|
require(transferSuccessful, "Transfer failed");
|
uint256 blpSwapAmount = amount.mul(10).div(100);
|
require(usdtToken.transfer(blpSwap, blpSwapAmount), "Transfer failed");
|
uint256 alpSwapAmount = amount.mul(70).div(100);
|
require(usdtToken.transfer(alpSwap, alpSwapAmount), "Transfer failed");
|
|
emit received(msg.sender, amount,regFlow);
|
}
|
|
function withdrawANDAO(address recipient,uint256 amount) external {
|
require(msg.sender == owner, "Only the contract creator can call this method");
|
uint256 contractBalance = usdtToken.balanceOf(address(this));
|
require(contractBalance >= amount, "Insufficient balance");
|
|
require(usdtToken.transfer(recipient, amount), "Transfer failed");
|
emit withdrawn(recipient, amount);
|
}
|
|
}
|
|
library SafeMath {
|
/**
|
* @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) {
|
uint256 c = a + b;
|
require(c >= a, "SafeMath: addition overflow");
|
|
return c;
|
}
|
|
/**
|
* @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 sub(a, b, "SafeMath: subtraction overflow");
|
}
|
|
/**
|
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
|
* overflow (when the result is negative).
|
*
|
* Counterpart to Solidity's `-` operator.
|
*
|
* Requirements:
|
* - Subtraction cannot overflow.
|
*/
|
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
|
require(b <= a, errorMessage);
|
uint256 c = a - b;
|
|
return c;
|
}
|
|
/**
|
* @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) {
|
// 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;
|
}
|
|
/**
|
* @dev Returns the integer division of two unsigned integers. Reverts on
|
* division by zero. The result is rounded towards zero.
|
*
|
* 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) internal pure returns (uint256) {
|
return div(a, b, "SafeMath: division by zero");
|
}
|
|
/**
|
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
|
* division by zero. The result is rounded towards zero.
|
*
|
* 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) {
|
// 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;
|
}
|
|
/**
|
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
|
* Reverts 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 mod(a, b, "SafeMath: modulo by zero");
|
}
|
|
/**
|
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
|
* Reverts with custom message 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, string memory errorMessage) internal pure returns (uint256) {
|
require(b != 0, errorMessage);
|
return a % b;
|
}
|
}
|