Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0x42eBF47dB15dc996b1288f417062b8386A8A3873
Balance 0 ETH
Nonce 1
Code Size 9528 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

9528 bytes
0x6080604052600436106101b9575f3560e01c806343d32e9c116100f25780638da5cb5b11610092578063c625e9b111610062578063c625e9b114610574578063ce31a06b14610587578063dd62ed3e1461059b578063f2fde38b146105ec575f80fd5b80638da5cb5b146104f957806395d89b41146105225780639fdc800514610536578063a9059cbb14610555575f80fd5b8063670f7151116100cd578063670f7151146104665780636b5caec41461048557806370a08231146104a4578063715018a6146104e5575f80fd5b806343d32e9c146103fa5780635a29638d1461040e5780635d52f9fc1461043a575f80fd5b80631df137511161015d57806323f2470d1161013857806323f2470d146103685780632ac00f431461038a5780632b112e49146103a9578063313ce567146103bd575f80fd5b80631df137511461030b5780631f3e51fd1461032a57806323b872dd14610349575f80fd5b8063095ea7b311610198578063095ea7b31461023357806310814c371461026257806318160ddd146102b35780631cb78541146102d1575f80fd5b8062ae3bf8146101bd578063018a25e8146101de57806306fdde0314610212575b5f80fd5b3480156101c8575f80fd5b506101dc6101d7366004611f8a565b61060b565b005b3480156101e9575f80fd5b506101f261076e565b60405169ffffffffffffffffffff90911681526020015b60405180910390f35b34801561021d575f80fd5b5061022661094b565b6040516102099190611fac565b34801561023e575f80fd5b5061025261024d366004611fff565b6109db565b6040519015158152602001610209565b34801561026d575f80fd5b5060085461028e9073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610209565b3480156102be575f80fd5b506003545b604051908152602001610209565b3480156102dc575f80fd5b5060065461028e906a0100000000000000000000900473ffffffffffffffffffffffffffffffffffffffff1681565b348015610316575f80fd5b506101dc610325366004612036565b610ad8565b348015610335575f80fd5b506101dc610344366004611f8a565b610b11565b348015610354575f80fd5b50610252610363366004612051565b610cc8565b348015610373575f80fd5b506006546101f29069ffffffffffffffffffff1681565b348015610395575f80fd5b506101dc6103a436600461208f565b610dc5565b3480156103b4575f80fd5b506102c3610e22565b3480156103c8575f80fd5b5060405160ff7f0000000000000000000000000000000000000000000000000000000000000006168152602001610209565b348015610405575f80fd5b506101f2610e8a565b348015610419575f80fd5b5060075461028e9073ffffffffffffffffffffffffffffffffffffffff1681565b348015610445575f80fd5b5060095461028e9073ffffffffffffffffffffffffffffffffffffffff1681565b348015610471575f80fd5b506101dc6104803660046120c6565b61104e565b348015610490575f80fd5b506101dc61049f366004611f8a565b611441565b3480156104af575f80fd5b506102c36104be366004611f8a565b73ffffffffffffffffffffffffffffffffffffffff165f9081526004602052604090205490565b3480156104f0575f80fd5b506101dc611490565b348015610504575f80fd5b505f5473ffffffffffffffffffffffffffffffffffffffff1661028e565b34801561052d575f80fd5b506102266114a3565b348015610541575f80fd5b50610252610550366004611f8a565b6114b2565b348015610560575f80fd5b5061025261056f366004611fff565b6114dd565b6101dc6105823660046120c6565b6115d1565b348015610592575f80fd5b506101dc61185c565b3480156105a6575f80fd5b506102c36105b53660046120e9565b73ffffffffffffffffffffffffffffffffffffffff9182165f90815260056020908152604080832093909416825291909152205490565b3480156105f7575f80fd5b506101dc610606366004611f8a565b6118ab565b61061361195f565b8073ffffffffffffffffffffffffffffffffffffffff1663a9059cbb61064d5f5473ffffffffffffffffffffffffffffffffffffffff1690565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8516906370a0823190602401602060405180830381865afa1580156106b5573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906106d99190612115565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b16815273ffffffffffffffffffffffffffffffffffffffff909216600483015260248201526044016020604051808303815f875af1158015610746573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061076a919061212c565b5050565b5f6003545f0361085b576007546040517fea4bc51c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2811660048301529091169063ea4bc51c90602401602060405180830381865afa158015610806573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061082a9190612147565b60065469ffffffffffffffffffff9182169161084c911664eb28b0f40061219d565b61085691906121fc565b905090565b60035460071b61088c7f0000000000000000000000000000000000000000000000000000000000000006600a61235c565b60095f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166363011d1a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156108f6573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061091a919061236a565b6fffffffffffffffffffffffffffffffff166109369190612399565b61094190607f612399565b61085691906123b0565b60606001805461095a906123c3565b80601f0160208091040260200160405190810160405280929190818152602001828054610986906123c3565b80156109d15780601f106109a8576101008083540402835291602001916109d1565b820191905f5260205f20905b8154815290600101906020018083116109b457829003601f168201915b5050505050905090565b5f6006600a9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663bb5424046040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a47573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a6b9190612414565b73ffffffffffffffffffffffffffffffffffffffff16631352d3e36040518163ffffffff1660e01b81526004015f604051808303815f87803b158015610aaf575f80fd5b505af1158015610ac1573d5f803e3d5ffd5b50505050610acf83836119df565b90505b92915050565b610ae061195f565b600b80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016911515919091179055565b610b1961195f565b60085f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663c1f36c686040518163ffffffff1660e01b81526004015f604051808303815f87803b158015610b7f575f80fd5b505af1158015610b91573d5f803e3d5ffd5b50506009546040517f1b9a91a400000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff909116803160248301529250631b9a91a491506044015f604051808303815f87803b158015610c04575f80fd5b505af1158015610c16573d5f803e3d5ffd5b5050600980547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff8516908117909155604080517f439370b1000000000000000000000000000000000000000000000000000000008152905191935063439370b1925047916004808301925f92919082900301818588803b158015610cae575f80fd5b505af1158015610cc0573d5f803e3d5ffd5b505050505050565b5f6006600a9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663bb5424046040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d34573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d589190612414565b73ffffffffffffffffffffffffffffffffffffffff16631352d3e36040518163ffffffff1660e01b81526004015f604051808303815f87803b158015610d9c575f80fd5b505af1158015610dae573d5f803e3d5ffd5b50505050610dbd848484611a57565b949350505050565b610dcd61195f565b73ffffffffffffffffffffffffffffffffffffffff919091165f908152600a6020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016911515919091179055565b60046020527f17ef568e3e12ab5b9c7254a8d58478811de00f9e6eb34345acd53bf8fd09d3ec5461dead5f9081527f42c63635470f1fb1d6d4b6441c413cb435b1ebb6fedd1896dd5e25d1399147dd549091610e7d9161242f565b6003546108569190612442565b5f6003545f03610f68576007546040517fea4bc51c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2811660048301529091169063ea4bc51c90602401602060405180830381865afa158015610f22573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610f469190612147565b60065469ffffffffffffffffffff9182169161084c911664e680992c0061219d565b60035460071b610f997f0000000000000000000000000000000000000000000000000000000000000006600a61235c565b60095f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166363011d1a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611003573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611027919061236a565b6fffffffffffffffffffffffffffffffff166110439190612399565b610941906081612399565b815f03611059575050565b335f908152600560209081526040808320308452909152902054821115611107576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f596f75206d75737420617070726f766520796f757220746f6b656e7320746f2060448201527f6265207370656e742e000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b335f908152600a602052604090205460ff16806111275750600b5460ff16155b61118d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f4e6f742077686974656c697374656420666f72206275726e696e672e0000000060448201526064016110fe565b5f611196610e8a565b90505f6111c47f0000000000000000000000000000000000000000000000000000000000000006600a61235c565b6111d39064e8d4a51000612399565b846111f269ffffffffffffffffffff8516670de0b6b3a7640000612399565b6111fc9190612399565b61120691906123b0565b90506112135f3386611bee565b6008546040517f382e47810000000000000000000000000000000000000000000000000000000081526004810183905273ffffffffffffffffffffffffffffffffffffffff9091169063382e4781906024015f604051808303815f87803b15801561127c575f80fd5b505af115801561128e573d5f803e3d5ffd5b50506009546040517f1b9a91a400000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8781166004830152602482018690529091169250631b9a91a491506044015b5f604051808303815f87803b158015611304575f80fd5b505af1158015611316573d5f803e3d5ffd5b50506007546040517fea4bc51c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc28116600483015264e8d4a510009450909116915063ea4bc51c90602401602060405180830381865afa1580156113af573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906113d39190612147565b69ffffffffffffffffffff168369ffffffffffffffffffff166113f69190612455565b61140091906124bb565b600680547fffffffffffffffffffffffffffffffffffffffffffff000000000000000000001669ffffffffffffffffffff9290921691909117905550505050565b61144961195f565b600880547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b61149861195f565b6114a15f611deb565b565b60606002805461095a906123c3565b5f610ad2827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6109db565b5f6006600a9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663bb5424046040518163ffffffff1660e01b8152600401602060405180830381865afa158015611549573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061156d9190612414565b73ffffffffffffffffffffffffffffffffffffffff16631352d3e36040518163ffffffff1660e01b81526004015f604051808303815f87803b1580156115b1575f80fd5b505af11580156115c3573d5f803e3d5ffd5b50505050610acf8383611e5f565b815f036115dc575050565b335f908152600a602052604090205460ff16806115fc5750600b5460ff16155b611662576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f4e6f742077686974656c697374656420666f72206d696e74696e672e0000000060448201526064016110fe565b5f61166b61076e565b90505f6116997f0000000000000000000000000000000000000000000000000000000000000006600a61235c565b6116a89064e8d4a51000612399565b846116c769ffffffffffffffffffff8516670de0b6b3a7640000612399565b6116d19190612399565b6116db91906123b0565b905080341015611747576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f4e6f7420656e6f75676820657468657265756d207761732073656e740000000060448201526064016110fe565b336108fc6117558334612442565b6040518115909202915f818181858888f1935050505015801561177a573d5f803e3d5ffd5b50611786835f86611bee565b60095f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663439370b1826040518263ffffffff1660e01b81526004015f604051808303818588803b1580156117ed575f80fd5b505af11580156117ff573d5f803e3d5ffd5b50506008546040517f8287ccb40000000000000000000000000000000000000000000000000000000081526004810186905273ffffffffffffffffffffffffffffffffffffffff9091169350638287ccb4925060240190506112ed565b61186461195f565b5f805460405173ffffffffffffffffffffffffffffffffffffffff909116914780156108fc02929091818181858888f193505050501580156118a8573d5f803e3d5ffd5b50565b6118b361195f565b73ffffffffffffffffffffffffffffffffffffffff8116611956576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016110fe565b6118a881611deb565b5f5473ffffffffffffffffffffffffffffffffffffffff1633146114a1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016110fe565b335f81815260056020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716808552925280832085905551919290917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590611a469086815260200190565b60405180910390a350600192915050565b5f73ffffffffffffffffffffffffffffffffffffffff8316611ad5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f496e76616c69642061646472657373000000000000000000000000000000000060448201526064016110fe565b73ffffffffffffffffffffffffffffffffffffffff84165f908152600560209081526040808320338452909152902054821115611b6e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f416c6c6f77616e6365206578636565646564000000000000000000000000000060448201526064016110fe565b73ffffffffffffffffffffffffffffffffffffffff84165f908152600560209081526040808320338452909152902054611ba9908390612442565b73ffffffffffffffffffffffffffffffffffffffff85165f908152600560209081526040808320338452909152902055611be4838584611bee565b5060019392505050565b73ffffffffffffffffffffffffffffffffffffffff82165f9081526004602052604090205481111580611c35575073ffffffffffffffffffffffffffffffffffffffff8216155b611c9b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f496e73756666696369656e742066756e6473000000000000000000000000000060448201526064016110fe565b73ffffffffffffffffffffffffffffffffffffffff821615611cf65773ffffffffffffffffffffffffffffffffffffffff82165f9081526004602052604081208054839290611ceb908490612442565b90915550611d0d9050565b8060035f828254611d07919061242f565b90915550505b73ffffffffffffffffffffffffffffffffffffffff831615611d685773ffffffffffffffffffffffffffffffffffffffff83165f9081526004602052604081208054839290611d5d90849061242f565b90915550611d7f9050565b8060035f828254611d799190612442565b90915550505b8273ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051611dde91815260200190565b60405180910390a3505050565b5f805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b5f73ffffffffffffffffffffffffffffffffffffffff8316611edd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f496e76616c69642061646472657373000000000000000000000000000000000060448201526064016110fe565b335f90815260046020526040902054821115611f55576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f496e73756666696369656e742066756e6473000000000000000000000000000060448201526064016110fe565b611f60833384611bee565b50600192915050565b73ffffffffffffffffffffffffffffffffffffffff811681146118a8575f80fd5b5f60208284031215611f9a575f80fd5b8135611fa581611f69565b9392505050565b602081525f82518060208401528060208501604085015e5f6040828501015260407fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011684010191505092915050565b5f8060408385031215612010575f80fd5b823561201b81611f69565b946020939093013593505050565b80151581146118a8575f80fd5b5f60208284031215612046575f80fd5b8135611fa581612029565b5f805f60608486031215612063575f80fd5b833561206e81611f69565b9250602084013561207e81611f69565b929592945050506040919091013590565b5f80604083850312156120a0575f80fd5b82356120ab81611f69565b915060208301356120bb81612029565b809150509250929050565b5f80604083850312156120d7575f80fd5b8235915060208301356120bb81611f69565b5f80604083850312156120fa575f80fd5b823561210581611f69565b915060208301356120bb81611f69565b5f60208284031215612125575f80fd5b5051919050565b5f6020828403121561213c575f80fd5b8151611fa581612029565b5f60208284031215612157575f80fd5b815169ffffffffffffffffffff81168114611fa5575f80fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b6fffffffffffffffffffffffffffffffff81811683821602908116908181146121c8576121c8612170565b5092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f6fffffffffffffffffffffffffffffffff83168061221d5761221d6121cf565b806fffffffffffffffffffffffffffffffff84160491505092915050565b6001815b60018411156122765780850481111561225a5761225a612170565b600184161561226857908102905b60019390931c92800261223f565b935093915050565b5f8261228c57506001610ad2565b8161229857505f610ad2565b81600181146122ae57600281146122b8576122d4565b6001915050610ad2565b60ff8411156122c9576122c9612170565b50506001821b610ad2565b5060208310610133831016604e8410600b84101617156122f7575081810a610ad2565b6123227fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff848461223b565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0482111561235457612354612170565b029392505050565b5f610acf60ff84168361227e565b5f6020828403121561237a575f80fd5b81516fffffffffffffffffffffffffffffffff81168114611fa5575f80fd5b8082028115828204841417610ad257610ad2612170565b5f826123be576123be6121cf565b500490565b600181811c908216806123d757607f821691505b60208210810361240e577f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b50919050565b5f60208284031215612424575f80fd5b8151611fa581611f69565b80820180821115610ad257610ad2612170565b81810381811115610ad257610ad2612170565b5f73ffffffffffffffffffffffffffffffffffffffff821673ffffffffffffffffffffffffffffffffffffffff841673ffffffffffffffffffffffffffffffffffffffff81830216925081830481148215176124b3576124b3612170565b505092915050565b5f73ffffffffffffffffffffffffffffffffffffffff8316806124e0576124e06121cf565b8073ffffffffffffffffffffffffffffffffffffffff8416049150509291505056fea26469706673582212200d993f0470f0a09f1fa70c189eb5f1a8094a5e3bbdf7d3bf8b20ba837ae4450f64736f6c634300081a0033

Verified Source Code Full Match

Compiler: v0.8.26+commit.8a97fa7a EVM: cancun Optimization: Yes (7770777 runs)
dsyncbottoken.sol 418 lines
// SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.24;


/*
 *		DSYNC TRADING BOT TOKEN
 *
 *  Trades DSYNC.  No idea if this will make money,
 *  mainly doing it as an experiment.  I plan to
 *  make an actual AMM but I want to release this
 *  first to test things out and see what happens.
 *
*/


abstract contract Context {
	function _msgSender() internal view virtual returns (address) {
		return msg.sender;
	}

	function _msgData() internal view virtual returns (bytes calldata) {
		return msg.data;
	}
}


interface IERC20 {
	function totalSupply() external view returns (uint256);

	function balanceOf(address account) external view returns (uint256);

	function transfer(address recipient, uint256 amount) external returns (bool);

	function decimals() external view returns (uint8);

	function allowance(
		address owner,
		address spender
	) external view returns (uint256);

	function approve(address spender, uint256 amount) external returns (bool);

	function transferFrom(
		address sender,
		address recipient,
		uint256 amount
	) external returns (bool);

	event Transfer(address indexed from, address indexed to, uint256 value);
	event Approval(address indexed owner, address indexed spender, uint256 value);
}

abstract contract Ownable is Context {
	address private _owner;

	event OwnershipTransferred(
		address indexed previousOwner,
		address indexed newOwner
	);

	constructor() {
		_transferOwnership(_msgSender());
	}

	modifier onlyOwner() {
		_checkOwner();
		_;
	}

	function owner() public view virtual returns (address) {
		return _owner;
	}

	function _checkOwner() internal view virtual {
		require(owner() == _msgSender(), "Ownable: caller is not the owner");
	}

	function renounceOwnership() public virtual onlyOwner {
		_transferOwnership(address(0));
	}

	function transferOwnership(address newOwner) public virtual onlyOwner {
		require(newOwner != address(0), "Ownable: new owner is the zero address");
		_transferOwnership(newOwner);
	}

	function _transferOwnership(address newOwner) internal virtual {
		address oldOwner = _owner;
		_owner = newOwner;
		emit OwnershipTransferred(oldOwner, newOwner);
	}
}


// Abridged to contain only what we need
abstract contract IHoldingContractUtils {
	// PRICE DATA

	function getTwapPriceP12(int8 decimalDiff, address base, address quote, uint32 duration) public virtual view returns (uint80 price12);
	function getTwapPricePX96(address poolAddress, address base, address quote, uint32 duration) public virtual view returns (uint256 priceX96);
	function safeGetPriceUSDC12Of(address token) public virtual view returns (uint80 price12);
	function safeGetPrice12Of(address base, address quote) public virtual view returns (uint80 price12);
	function value12OfTokensAgainst(address token, address quote, uint256 quantity) external virtual view returns (uint128 value12);

	// Primary should either be USDC or address(0), indicating Eth.  This will save the contract address
	// for the pool this contract can use later. 
	function findV3PoolFor(address base, address quote, uint128 minValueUSDC12) public virtual returns (address bestPool);
}


abstract contract IAssetHolder {

	function getTotalValueUsd12() public virtual view returns (uint128 valueUsd12);
	function getTotalValueEth12() public virtual view returns (uint128 valueEth12);
	function getUsd12ValueIn(address token) public virtual view returns (uint128 valueUsd12);

}

interface RunnableTask {
	function execute(uint256 handle) external;
}


interface RunnableChecker {
	function shouldExecute(uint256 handle) external view returns (bool);
}


// Abridged: Just what we need
abstract contract ITaskEngine is Ownable, RunnableChecker {

	// Ticking and Execution functions
	function piggybackTick() external virtual;
}


interface IAutomationToken is IERC20 {
	function getTaskEngine() external view returns (ITaskEngine taskEngine);
}


abstract contract BasicPurchasableERC20 is IERC20 {
	// Returns in units of eth per token, scaled to 1e12.
	// Note that it is eth vs your token, not counting decimals, so if your token
	// has 18 decimals then to get the raw uint256 token amount you 
	function getBuyPrice() public virtual view returns (uint80);
	function getSellPrice() public virtual view returns (uint80);

	// This will revert if you do not send enough.
	function buyTokens(uint256 tokens, address receiver) public virtual payable;
	// This requires that your balance is high enough AND that you've
	// approved this contract to spend your balance.
	function sellTokens(uint256 tokens, address receiver) external virtual;

	event TokensBought(uint256 tokens, uint256 cost, uint80 priceEth12, uint80 priceUsd12, uint256 totalSupply);
	event TokensSold(uint256 tokens, uint256 cost, uint80 priceEth12, uint80 priceUsd12, uint256 totalSupply);


	address constant DEAD = 0x000000000000000000000000000000000000dEaD;
	address constant ZERO = 0x0000000000000000000000000000000000000000;


	string _name;
	string _symbol;
	uint8 immutable _decimals;

	uint256 _totalSupply = 0;

	mapping(address => uint256) _balances;
	mapping(address => mapping(address => uint256)) _allowances;

	constructor(string memory initName, string memory initSymbol, uint8 initDecimals) {
		_name = initName;
		_symbol = initSymbol;
		_decimals = initDecimals;
	}


	function totalSupply() external view override returns (uint256) {
		return _totalSupply;
	}

	function decimals() external view returns (uint8) {
		return _decimals;
	}

	function symbol() external view returns (string memory) {
		return _symbol;
	}

	function name() external view returns (string memory) {
		return _name;
	}

	function balanceOf(address account) public view override returns (uint256) {
		return _balances[account];
	}

	function transfer(address to, uint tokens) public virtual override returns (bool success) {
		require(to != address(0), "Invalid address");
		require(tokens <= _balances[msg.sender], "Insufficient funds");

		_transfer(to, msg.sender, tokens);

		return true;
	}

	function approve(address spender, uint tokens) public virtual override returns (bool success) {
		_allowances[msg.sender][spender] = tokens;
		emit Approval(msg.sender, spender, tokens);

		return true;
	}

	function allowance(address holder, address spender) external view override returns (uint256) {
		return _allowances[holder][spender];
	}

	function transferFrom(address from, address to, uint tokens) public virtual override returns (bool success) {
		require(to != address(0x0), "Invalid address");
		require(tokens <= _allowances[from][msg.sender], "Allowance exceeded");
		_allowances[from][msg.sender] = _allowances[from][msg.sender] - tokens;
		_transfer(to, from, tokens);

		return true;
	}

	function _transfer(address to, address from, uint256 tokens) internal {
		require(_balances[from] >= tokens || from == address(0), "Insufficient funds");

		if (from != address(0x0))
			_balances[from] -= tokens;
		else
			_totalSupply += tokens;

		if (to != address(0x0))
			_balances[to] += tokens;
		else
			_totalSupply -= tokens;

		emit Transfer(from, to, uint(tokens));
	}

	function approveMaxAmount(address spender) external returns (bool) {
		return approve(spender, type(uint256).max);
	}

	function getCirculatingSupply() public view returns (uint256) {
		return _totalSupply - (balanceOf(DEAD) + balanceOf(ZERO));
	}
}

interface IDsyncBotV1 {
	function prepareWithdraw(uint256 amtEth) external;
	function prepareWithdrawAll() external;
	function onDeposit(uint256 howMuch) external;
}


abstract contract IDepositable is IAssetHolder {

	// ADMINISTRATION

	function getFunder() external virtual view returns (address _funder);
	function setFunder(address newFunder) external virtual;

	// DEPOSITS

	function depositToken(address token, uint256 amount) external virtual;
	function depositEth() external virtual payable;

	// WITHDRAWS

	function withdrawEth(address destination, uint256 amount) external virtual;
	function withdrawToken(address token, address destination, uint256 amount) external virtual;

	// EVENTS

	event FunderSet(address newController, address oldController);
	event Deposited(address token, uint256 amount);
	event Withdrawn(address token, uint256 amount);
}

contract DsyncBotV1Token is Ownable, BasicPurchasableERC20 {

	address internal immutable WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;

	uint80 public lastPriceUsd12 = 1e12;

	// Automation stuff
	IAutomationToken public automator = IAutomationToken(0xaAa000e1b72bf8DFA74C958e19E925C0bFAE9dEd);

	// External contracts
	IHoldingContractUtils public utils;
	IDsyncBotV1 public bot;
	IDepositable public holdingContract;

	mapping(address => bool) isWhitelistedForMint;
	bool isMintWhitelistEnabled = true;


	constructor(address utilsAdr, address holdingAdr) BasicPurchasableERC20("Dsync Bot V1", "DSYNCBOT1", 6) {
		isWhitelistedForMint[msg.sender] = true;

		// Set up contract addresses
		holdingContract = IDepositable(holdingAdr);
		utils = IHoldingContractUtils(utilsAdr);
	}


	// ADMINISTRATION

	// Only trusted addresses will mint/burn in the beginning just in case of security issues

	function setAdrCanMint(address adr, bool canOrNot) external onlyOwner {
		isWhitelistedForMint[adr] = canOrNot;
	}

	function setMintWhitelist(bool enabled) external onlyOwner {
		isMintWhitelistEnabled = enabled;
	}

	function setBot(address botAdr) external onlyOwner {
		bot = IDsyncBotV1(botAdr);
	}

	function setHoldingContract(address holdingAdr) external onlyOwner {
		// Withdraw everything from the previous contract first

		bot.prepareWithdrawAll();
		holdingContract.withdrawEth(address(this), address(holdingContract).balance);
		holdingContract = IDepositable(holdingAdr);
		holdingContract.depositEth{value: address(this).balance}();
	}


	// MINTING AND BURNING FUNCTIONS

	function getBuyPrice() public override view returns (uint80) {
		if (_totalSupply == 0)
			return uint80((uint128(lastPriceUsd12) * 101e10) / utils.safeGetPriceUSDC12Of(WETH));
		else
			return uint80((holdingContract.getTotalValueEth12() * (10**_decimals) * 127) / (_totalSupply << 7));
	}

	function getSellPrice() public override view returns (uint80) {
		if (_totalSupply == 0)
			return uint80((uint128(lastPriceUsd12) * 99e10) / utils.safeGetPriceUSDC12Of(WETH));
		else
			return uint80((holdingContract.getTotalValueEth12() * (10**_decimals) * 129) / (_totalSupply << 7));
	}

	// This will revert if you do not send enough.
	function buyTokens(uint256 tokens, address receiver) public override payable {
		if (tokens == 0)
			return;

		require(isWhitelistedForMint[msg.sender] || !isMintWhitelistEnabled, "Not whitelisted for minting.");

		uint80 priceEth12 = getBuyPrice();
		uint256 transactionValue = (1 ether * uint256(priceEth12) * tokens) / (1e12 * (10**_decimals));

		require(msg.value >= transactionValue, "Not enough ethereum was sent");
		payable(msg.sender).transfer(msg.value - transactionValue);

		_transfer(receiver, address(0), tokens);
		holdingContract.depositEth{value: transactionValue}();
		bot.onDeposit(transactionValue);

		lastPriceUsd12 = uint80((uint160(priceEth12) * utils.safeGetPriceUSDC12Of(WETH)) / 1e12);
	}

	// This requires that your balance is high enough AND that you've
	// approved this contract to spend your balance.
	function sellTokens(uint256 tokens, address receiver) external override {
		if (tokens == 0)
			return;
		require(_allowances[msg.sender][address(this)] >= tokens, "You must approve your tokens to be spent.");
		require(isWhitelistedForMint[msg.sender] || !isMintWhitelistEnabled, "Not whitelisted for burning.");

		uint80 priceEth12 = getSellPrice();
		uint256 transactionValue = (1 ether * uint256(priceEth12) * tokens) / (1e12 * (10**_decimals));

		// Burn the user's tokens and send the 
		_transfer(address(0), msg.sender, tokens);
		bot.prepareWithdraw(transactionValue);
		holdingContract.withdrawEth(receiver, transactionValue);

		lastPriceUsd12 = uint80((uint160(priceEth12) * utils.safeGetPriceUSDC12Of(WETH)) / 1e12);
	}


	// ADMINISTRATION FUNCTIONS

	// In case eth gets stuck in the contract (that should never happen but whatever)
	function rescueEth() external onlyOwner {
		payable(owner()).transfer(address(this).balance);
	}

	function rescueTokens(address token) external onlyOwner {
		IERC20(token).transfer(owner(), IERC20(token).balanceOf(address(this)));
	}

	function transfer(address to, uint tokens) public override returns (bool success) {
		automator.getTaskEngine().piggybackTick();
		return super.transfer(to, tokens);
	}

	function approve(address spender, uint tokens) public override returns (bool success) {
		automator.getTaskEngine().piggybackTick();
		return super.approve(spender, tokens);
	}

	function transferFrom(address from, address to, uint tokens) public override returns (bool success) {
		automator.getTaskEngine().piggybackTick();
		return super.transferFrom(from, to, tokens);
	}
}

Read Contract

allowance 0xdd62ed3e → uint256
automator 0x1cb78541 → address
balanceOf 0x70a08231 → uint256
bot 0x10814c37 → address
decimals 0x313ce567 → uint8
getBuyPrice 0x018a25e8 → uint80
getCirculatingSupply 0x2b112e49 → uint256
getSellPrice 0x43d32e9c → uint80
holdingContract 0x5d52f9fc → address
lastPriceUsd12 0x23f2470d → uint80
name 0x06fdde03 → string
owner 0x8da5cb5b → address
symbol 0x95d89b41 → string
totalSupply 0x18160ddd → uint256
utils 0x5a29638d → address

Write Contract 14 functions

These functions modify contract state and require a wallet transaction to execute.

approve 0x095ea7b3
address spender
uint256 tokens
returns: bool
approveMaxAmount 0x9fdc8005
address spender
returns: bool
buyTokens 0xc625e9b1
uint256 tokens
address receiver
renounceOwnership 0x715018a6
No parameters
rescueEth 0xce31a06b
No parameters
rescueTokens 0x00ae3bf8
address token
sellTokens 0x670f7151
uint256 tokens
address receiver
setAdrCanMint 0x2ac00f43
address adr
bool canOrNot
setBot 0x6b5caec4
address botAdr
setHoldingContract 0x1f3e51fd
address holdingAdr
setMintWhitelist 0x1df13751
bool enabled
transfer 0xa9059cbb
address to
uint256 tokens
returns: bool
transferFrom 0x23b872dd
address from
address to
uint256 tokens
returns: bool
transferOwnership 0xf2fde38b
address newOwner

Recent Transactions

No transactions found for this address