Verified contractExactMIT
AdapterRouter
Address0x3cd847bdccb486b3a3dfeedaa95964dc4928fd8e
- Balance
0 ETH
- Transactions
3
- Compiler
solc 0.8.26
- Same code
Only this contract
Details
- Compiler
- solc 0.8.26+commit.8a97fa7a
- Language
- solidity
- Optimization
- Yes, 200 runs
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,257,224
- Creation transaction
- 0xa6ea10a023…63f5ec9bd6
aggdotfun/aggdotfun/AdapterRouter.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
// ================================================================
// AdapterRouter
// ================================================================
// project agg.fun
// web https://agg.fun
// x @tetranode
// ----------------------------------------------------------------
// Remembers which adapter should handle orders for a token.
// The owner and any operator can set or clear a route. Reading
// a route that was never set gives back the zero address.
//
// order -> [ router ] -> adapter -> curve or pool
//
// Failed writes return false. No reverts.
// ================================================================
contract AdapterRouter {
address public owner;
bool public ready;
uint256 public routed;
mapping(address => address) private routes;
mapping(address => bool) public operator;
event RouteSet(address indexed token, address indexed adapter);
event RouteCleared(address indexed token);
event OperatorSet(address indexed who, bool on);
function initAgg() external returns (bool) {
if (ready) return false;
ready = true;
owner = msg.sender;
return true;
}
function setOperator(address who, bool on) external returns (bool) {
if (msg.sender != owner || who == address(0)) return false;
operator[who] = on;
emit OperatorSet(who, on);
return true;
}
function setRoute(address token, address adapter) external returns (bool) {
if (!_allowed(msg.sender) || token == address(0) || adapter == address(0)) return false;
if (routes[token] == address(0)) routed += 1;
routes[token] = adapter;
emit RouteSet(token, adapter);
return true;
}
function clearRoute(address token) external returns (bool) {
if (!_allowed(msg.sender) || routes[token] == address(0)) return false;
delete routes[token];
routed -= 1;
emit RouteCleared(token);
return true;
}
function routeOf(address token) external view returns (address) {
return routes[token];
}
function _allowed(address who) private view returns (bool) {
return who == owner || operator[who];
}
}
Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": true
},
"remappings": []
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.