Address Contract Partially Verified
Address
0xBbDb4c81407DB26B4454A0499A15C998330D7691
Balance
0 ETH
Nonce
1
Code Size
6208 bytes
Creator
0xcf7EA369...9027 at tx 0xb6d997f5...7898b0
Indexed Transactions
0
Contract Bytecode
6208 bytes
0x608060405234801561000f575f80fd5b506004361061013d575f3560e01c806372e5bfb4116100b4578063ce16bc6b11610079578063ce16bc6b14610322578063e0bb12f714610335578063e41017cd14610348578063f2fde38b1461035b578063fd66091e1461036e578063fdc34496146103d8575f80fd5b806372e5bfb41461029a57806389f2c731146102ad5780638da5cb5b146102d5578063a3261403146102e5578063b37598c91461030f575f80fd5b8063558a729711610105578063558a72971461021f57806356049c5b14610232578063564c39241461024557806356efc9531461025857806359c259c714610278578063715018a614610292575f80fd5b8063029547ba146101415780630e95202d1461018057806313e7c9d8146101bd57806327d54a92146101df5780632ef0af0b1461020a575b5f80fd5b61015461014f36600461141f565b6103eb565b604080516001600160a01b03909416845260208401929092521515908201526060015b60405180910390f35b6101ad61018e366004611447565b6001600160a01b039081165f9081526006602052604090205416151590565b6040519015158152602001610177565b6101ad6101cb366004611447565b60046020525f908152604090205460ff1681565b6101f26101ed366004611447565b610436565b6040516001600160a01b039091168152602001610177565b61021d610218366004611447565b61048c565b005b61021d61022d366004611476565b6104b6565b6002546101f2906001600160a01b031681565b61021d61025336600461141f565b61051d565b61026b610266366004611447565b6107bb565b60405161017791906114a7565b610280610856565b60405161017796959493929190611573565b61021d610bce565b61021d6102a8366004611626565b610be1565b6101f26102bb366004611447565b60066020525f90815260409020546001600160a01b031681565b5f546001600160a01b03166101f2565b6102f86102f336600461141f565b610d2f565b604080519215158352602083019190915201610177565b61021d61031d36600461141f565b610e74565b61021d610330366004611669565b610f89565b6101f2610343366004611691565b611058565b61021d610356366004611447565b611080565b61021d610369366004611447565b611141565b6103ae61037c366004611447565b60056020525f90815260409020805460018201546002830154600384015460049094015460ff90931693919290919085565b6040805195151586526020860194909452928401919091526060830152608082015260a001610177565b61021d6103e6366004611447565b61117e565b6007602052815f5260405f208181548110610404575f80fd5b5f9182526020909120600390910201805460018201546002909201546001600160a01b03909116935090915060ff1683565b6002545f906001600160a01b0316331461046b5760405162461bcd60e51b8152600401610462906116a8565b60405180910390fd5b506001600160a01b038082165f90815260066020526040902054165b919050565b61049461138e565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b6104be61138e565b6001600160a01b0382165f81815260046020908152604091829020805460ff191685151590811790915591519182527f966c160e1c4dbc7df8d69af4ace01e9297c3cf016397b7914971f2fbfa32672d91015b60405180910390a25050565b335f9081526004602052604090205460ff168061054357505f546001600160a01b031633145b61055f5760405162461bcd60e51b8152600401610462906116df565b6001600160a01b0382166105ad5760405162461bcd60e51b8152602060048201526015602482015274496e76616c6964206167656e74206164647265737360581b6044820152606401610462565b611d4c8111156105fa5760405162461bcd60e51b8152602060048201526018602482015277086dedadad2e6e6d2dedc40e4c2e8ca40e8dede40d0d2ced60431b6044820152606401610462565b6001600160a01b0382165f9081526005602052604090205460ff161561066e5760405162461bcd60e51b815260206004820152602360248201527f4167656e7420616c7265616479207265676973746572656420616e642061637460448201526269766560e81b6064820152608401610462565b6001600160a01b0382165f90815260056020526040812060010154900361076f5760038054600180820183557fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b90910180546001600160a01b0319166001600160a01b0386169081179091556040805160a08101825283815260208082018781525f838501818152606085018281526080860183815288845260058652928790209551865460ff19169015151786559251978501979097559551600284015551958201959095559251600490930192909255905183815290917fd1b844701695237443dd884ed7193d9c8788f3befd35adc0910472eb166f33069101610511565b6001600160a01b0382165f81815260056020526040808220805460ff19166001179055517f260417376bfb1a5f9fbf2d2d67e9c975b4c4e37088eab604034d6d04cf06c9219190a25050565b6001600160a01b0381165f908152600760209081526040808320805482518185028101850190935280835260609492939192909184015b8282101561084b575f848152602090819020604080516060810182526003860290920180546001600160a01b031683526001808201548486015260029091015460ff1615159183019190915290835290920191016107f2565b505050509050919050565b6060806060806060805f60038054905090508067ffffffffffffffff81111561088157610881611716565b6040519080825280602002602001820160405280156108aa578160200160208202803683370190505b5096508067ffffffffffffffff8111156108c6576108c6611716565b6040519080825280602002602001820160405280156108ef578160200160208202803683370190505b5095508067ffffffffffffffff81111561090b5761090b611716565b604051908082528060200260200182016040528015610934578160200160208202803683370190505b5094508067ffffffffffffffff81111561095057610950611716565b604051908082528060200260200182016040528015610979578160200160208202803683370190505b5093508067ffffffffffffffff81111561099557610995611716565b6040519080825280602002602001820160405280156109be578160200160208202803683370190505b5092508067ffffffffffffffff8111156109da576109da611716565b604051908082528060200260200182016040528015610a03578160200160208202803683370190505b5091505f5b81811015610bc4575f60038281548110610a2457610a2461172a565b905f5260205f20015f9054906101000a90046001600160a01b0316905080898381518110610a5457610a5461172a565b6001600160a01b039283166020918202929092018101919091529082165f90815260059091526040902054885160ff90911690899084908110610a9957610a9961172a565b9115156020928302919091018201526001600160a01b0382165f908152600590915260409020600101548751889084908110610ad757610ad761172a565b60200260200101818152505060055f826001600160a01b03166001600160a01b031681526020019081526020015f2060020154868381518110610b1c57610b1c61172a565b60200260200101818152505060055f826001600160a01b03166001600160a01b031681526020019081526020015f2060030154858381518110610b6157610b6161172a565b60200260200101818152505060055f826001600160a01b03166001600160a01b031681526020019081526020015f2060040154848381518110610ba657610ba661172a565b60209081029190910101525080610bbc81611752565b915050610a08565b5050909192939495565b610bd661138e565b610bdf5f6113ba565b565b6002546001600160a01b03163314610c0b5760405162461bcd60e51b8152600401610462906116a8565b6001600160a01b038085165f90815260066020526040902054168015801590610c4b57506001600160a01b0381165f9081526005602052604090205460ff165b15610d28576001600160a01b038181165f81815260076020908152604080832081516060810183528b871681528084018b81528915158285019081528354600180820186559488528688209351600391820290940180546001600160a01b03191694909a1693909317895590519288019290925590516002909601805460ff191696151596909617909555928252600590529081209091018054869290610cf390849061176a565b90915550506001600160a01b0381165f9081526005602052604081206004018054859290610d2290849061176a565b90915550505b5050505050565b6002545f9081906001600160a01b03163314610d5d5760405162461bcd60e51b8152600401610462906116a8565b6001600160a01b038085165f90815260066020526040902054168015801590610d9d57506001600160a01b0381165f9081526005602052604090205460ff165b15610e65576001600160a01b0381165f9081526005602052604081206001015461271090610dcb9087611783565b610dd5919061179a565b6001600160a01b0383165f90815260056020526040812060020180549293508392909190610e0490849061176a565b92505081905550856001600160a01b0316826001600160a01b03167f9abf1573b316a64562bc0bbe3d299c36a815574133e45a19aebcfd8fe58b2ef283604051610e5091815260200190565b60405180910390a3600193509150610e6d9050565b5f8092509250505b9250929050565b335f9081526004602052604090205460ff1680610e9a57505f546001600160a01b031633145b610eb65760405162461bcd60e51b8152600401610462906116df565b6001600160a01b0382165f9081526005602052604090205460ff16610eed5760405162461bcd60e51b8152600401610462906117b9565b611d4c811115610f3a5760405162461bcd60e51b8152602060048201526018602482015277086dedadad2e6e6d2dedc40e4c2e8ca40e8dede40d0d2ced60431b6044820152606401610462565b6001600160a01b0382165f8181526005602052604090819020600101839055517fbaef45cead810df032ca6f6dc22d0fa78f7bc08a3e2f3177cfe2f37f4b08071a906105119084815260200190565b335f9081526004602052604090205460ff1680610faf57505f546001600160a01b031633145b610fcb5760405162461bcd60e51b8152600401610462906116df565b6001600160a01b0381165f9081526005602052604090205460ff166110025760405162461bcd60e51b8152600401610462906117b9565b6001600160a01b038281165f8181526006602052604080822080546001600160a01b0319169486169485179055517fa023ebe284637896ce19feee0dc9246b64e352e380384c6ea343d302cae159cc9190a35050565b60038181548110611067575f80fd5b5f918252602090912001546001600160a01b0316905081565b335f9081526004602052604090205460ff16806110a657505f546001600160a01b031633145b6110c25760405162461bcd60e51b8152600401610462906116df565b6001600160a01b0381165f9081526005602052604090205460ff166110f95760405162461bcd60e51b8152600401610462906117b9565b6001600160a01b0381165f81815260056020526040808220805460ff19169055517f9646504c7dd9dde87d9c30139e893fcaccf6a876099a1c344df9181ed516f9e19190a250565b61114961138e565b6001600160a01b03811661117257604051631e4fbdf760e01b81525f6004820152602401610462565b61117b816113ba565b50565b335f9081526004602052604090205460ff16806111a457505f546001600160a01b031633145b6111c05760405162461bcd60e51b8152600401610462906116df565b6001600160a01b0381165f9081526005602052604090206001015461121e5760405162461bcd60e51b81526020600482015260146024820152731059d95b9d081b9bdd081c9959da5cdd195c995960621b6044820152606401610462565b6001600160a01b0381165f908152600560205260408120805460ff191681556001810182905560028101829055600381018290556004018190555b60035481101561135757816001600160a01b0316600382815481106112805761128061172a565b5f918252602090912001546001600160a01b03160361134557600380546112a9906001906117e3565b815481106112b9576112b961172a565b5f91825260209091200154600380546001600160a01b0390921691839081106112e4576112e461172a565b905f5260205f20015f6101000a8154816001600160a01b0302191690836001600160a01b031602179055506003805480611320576113206117f6565b5f8281526020902081015f1990810180546001600160a01b0319169055019055611357565b8061134f81611752565b915050611259565b506040516001600160a01b038216907fb6500f86ea1b355d131f9ec2d1f06dda67ce80adda06e284b9af4503988bb36f905f90a250565b5f546001600160a01b03163314610bdf5760405163118cdaa760e01b8152336004820152602401610462565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80356001600160a01b0381168114610487575f80fd5b5f8060408385031215611430575f80fd5b61143983611409565b946020939093013593505050565b5f60208284031215611457575f80fd5b61146082611409565b9392505050565b80358015158114610487575f80fd5b5f8060408385031215611487575f80fd5b61149083611409565b915061149e60208401611467565b90509250929050565b602080825282518282018190525f919060409081850190868401855b828110156114fd57815180516001600160a01b031685528681015187860152850151151585850152606090930192908501906001016114c3565b5091979650505050505050565b5f8151808452602080850194508084015f5b8381101561153a57815115158752958201959082019060010161151c565b509495945050505050565b5f8151808452602080850194508084015f5b8381101561153a57815187529582019590820190600101611557565b60c080825287519082018190525f9060209060e0840190828b01845b828110156115b45781516001600160a01b03168452928401929084019060010161158f565b505050838103828501526115c8818a61150a565b91505082810360408401526115dd8188611545565b905082810360608401526115f18187611545565b905082810360808401526116058186611545565b905082810360a08401526116198185611545565b9998505050505050505050565b5f805f8060808587031215611639575f80fd5b61164285611409565b9350602085013592506040850135915061165e60608601611467565b905092959194509250565b5f806040838503121561167a575f80fd5b61168383611409565b915061149e60208401611409565b5f602082840312156116a1575f80fd5b5035919050565b6020808252601c908201527f4e6f7420617574686f72697a65643a20666163746f7279206f6e6c7900000000604082015260600190565b6020808252601d908201527f4e6f7420617574686f72697a65643a206f70657261746f72206f6e6c79000000604082015260600190565b634e487b7160e01b5f52604160045260245ffd5b634e487b7160e01b5f52603260045260245ffd5b634e487b7160e01b5f52601160045260245ffd5b5f600182016117635761176361173e565b5060010190565b8082018082111561177d5761177d61173e565b92915050565b808202811582820484141761177d5761177d61173e565b5f826117b457634e487b7160e01b5f52601260045260245ffd5b500490565b60208082526010908201526f4167656e74206e6f742061637469766560801b604082015260600190565b8181038181111561177d5761177d61173e565b634e487b7160e01b5f52603160045260245ffdfea26469706673582212201b042d22fef570412eaddfad91b999e00cbcc125023ae165f14cafcbff4b155264736f6c63430008140033
Verified Source Code Partial Match
Compiler: v0.8.20+commit.a1b79de6
EVM: shanghai
Optimization: Yes (200 runs)
AgentManager.sol 530 lines
// File: @openzeppelin/contracts/utils/Context.sol
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
// File: @openzeppelin/contracts/access/Ownable.sol
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
// File: @openzeppelin/contracts/utils/ReentrancyGuard.sol
// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at,
* consider using {ReentrancyGuardTransient} instead.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
uint256 private _status;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
constructor() {
_status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be NOT_ENTERED
if (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
_status = ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == ENTERED;
}
}
// File: @openzeppelin/contracts/token/ERC20/IERC20.sol
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
interface IERC20 {
/**
* @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);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) 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 a `value` amount of tokens 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 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
// File: contracts/contracts/AgentManager.sol
pragma solidity ^0.8.0;
contract AgentManager is Ownable, ReentrancyGuard {
address public hawalaFactory;
address[] public allAgents;
mapping(address => bool) public operators;
struct Transaction {
address wallet;
uint256 btcAmount;
bool orderType;
}
struct Agent {
bool isActive;
uint256 commissionRate; // in basis points (e.g., 250 = 2.5%)
uint256 totalCommission;
uint256 totalBtcVolume;
uint256 totalUsdtVolume;
}
mapping(address => Agent) public agents;
mapping(address => address) public clientToAgent;
mapping(address => Transaction[]) public agentToTransactions;
event AgentSuspended(address indexed agent);
event AgentApproved(address indexed agent);
event AgentDeleted(address indexed agent);
event AgentUpdated(address indexed agent, uint256 commissionRate);
event AgentRegistered(address indexed agent, uint256 commissionRate);
event ClientAssigned(address indexed client, address indexed agent);
event CommissionEarned(
address indexed agent,
address indexed client,
uint256 amount
);
event OperatorUpdated(address indexed operator, bool status);
modifier onlyOperator() {
require(
operators[msg.sender] || msg.sender == owner(),
"Not authorized: operator only"
);
_;
}
modifier onlyFactory() {
require(msg.sender == hawalaFactory, "Not authorized: factory only");
_;
}
constructor(address initialOwner) Ownable(initialOwner) {}
function setHawalaFactory(address _factory) external onlyOwner {
hawalaFactory = _factory;
}
function setOperator(address _operator, bool _status) external onlyOwner {
operators[_operator] = _status;
emit OperatorUpdated(_operator, _status);
}
function suspendAgent(address agent) external onlyOperator {
require(agents[agent].isActive, "Agent not active");
agents[agent].isActive = false;
emit AgentSuspended(agent);
}
function updateAgent(
address agent,
uint256 newCommission
) external onlyOperator {
require(agents[agent].isActive, "Agent not active");
require(newCommission <= 7500, "Commission rate too high");
agents[agent].commissionRate = newCommission;
emit AgentUpdated(agent, newCommission);
}
function approveAgent(
address agent,
uint256 commissionRate
) external onlyOperator {
require(agent != address(0), "Invalid agent address");
require(commissionRate <= 7500, "Commission rate too high");
require(!agents[agent].isActive, "Agent already registered and active");
if (agents[agent].commissionRate == 0) {
allAgents.push(agent);
agents[agent] = Agent({
isActive: true,
commissionRate: commissionRate,
totalCommission: 0,
totalBtcVolume: 0,
totalUsdtVolume: 0
});
emit AgentRegistered(agent, commissionRate);
} else {
agents[agent].isActive = true;
emit AgentApproved(agent);
}
}
function deleteAgent(address agent) external onlyOperator {
require(agents[agent].commissionRate > 0, "Agent not registered");
delete agents[agent];
for (uint i = 0; i < allAgents.length; i++) {
if (allAgents[i] == agent) {
allAgents[i] = allAgents[allAgents.length - 1];
allAgents.pop();
break;
}
}
emit AgentDeleted(agent);
}
function assignClientToAgent(
address client,
address agent
) external onlyOperator {
require(agents[agent].isActive, "Agent not active");
clientToAgent[client] = agent;
emit ClientAssigned(client, agent);
}
function recordTrade(
address trader,
uint256 btcAmount,
uint256 usdtAmount,
bool isBTCToUSDT
) external onlyFactory {
address agent = clientToAgent[trader];
if (agent != address(0) && agents[agent].isActive) {
agentToTransactions[agent].push(
Transaction({
wallet: trader,
btcAmount: btcAmount,
orderType: isBTCToUSDT
})
);
agents[agent].totalBtcVolume += btcAmount;
agents[agent].totalUsdtVolume += usdtAmount;
}
}
function getAgentTransactions(
address agent
) external view returns (Transaction[] memory) {
return agentToTransactions[agent];
}
function addCommission(
address trader,
uint256 amount
) external onlyFactory returns (bool, uint256) {
address agent = clientToAgent[trader];
if (agent != address(0) && agents[agent].isActive) {
uint256 commission = (amount * agents[agent].commissionRate) /
10000;
agents[agent].totalCommission += commission;
emit CommissionEarned(agent, trader, commission);
return (true, commission);
}
return (false, 0);
}
function getAgentAddress(
address trader
) external view onlyFactory returns (address) {
return clientToAgent[trader];
}
function isClientAssigned(address client) external view returns (bool) {
return clientToAgent[client] != address(0);
}
function getAllAgentsData()
external
view
returns (
address[] memory agentAddresses,
bool[] memory isActive,
uint256[] memory commissionRates,
uint256[] memory totalCommissions,
uint256[] memory btcVolumes,
uint256[] memory usdtVolumes
)
{
uint256 agentCount = allAgents.length;
agentAddresses = new address[](agentCount);
isActive = new bool[](agentCount);
commissionRates = new uint256[](agentCount);
totalCommissions = new uint256[](agentCount);
btcVolumes = new uint256[](agentCount);
usdtVolumes = new uint256[](agentCount);
for (uint256 i = 0; i < agentCount; i++) {
address agentAddr = allAgents[i];
agentAddresses[i] = agentAddr;
isActive[i] = agents[agentAddr].isActive;
commissionRates[i] = agents[agentAddr].commissionRate;
totalCommissions[i] = agents[agentAddr].totalCommission;
btcVolumes[i] = agents[agentAddr].totalBtcVolume;
usdtVolumes[i] = agents[agentAddr].totalUsdtVolume;
}
return (
agentAddresses,
isActive,
commissionRates,
totalCommissions,
btcVolumes,
usdtVolumes
);
}
}
Read Contract
agentToTransactions 0x029547ba → address, uint256, bool
agents 0xfd66091e → bool, uint256, uint256, uint256, uint256
allAgents 0xe0bb12f7 → address
clientToAgent 0x89f2c731 → address
getAgentAddress 0x27d54a92 → address
getAgentTransactions 0x56efc953 → tuple[]
getAllAgentsData 0x59c259c7 → address[], bool[], uint256[], uint256[], uint256[], uint256[]
hawalaFactory 0x56049c5b → address
isClientAssigned 0x0e95202d → bool
operators 0x13e7c9d8 → bool
owner 0x8da5cb5b → address
Write Contract 11 functions
These functions modify contract state and require a wallet transaction to execute.
addCommission 0xa3261403
address trader
uint256 amount
returns: bool, uint256
approveAgent 0x564c3924
address agent
uint256 commissionRate
assignClientToAgent 0xce16bc6b
address client
address agent
deleteAgent 0xfdc34496
address agent
recordTrade 0x72e5bfb4
address trader
uint256 btcAmount
uint256 usdtAmount
bool isBTCToUSDT
renounceOwnership 0x715018a6
No parameters
setHawalaFactory 0x2ef0af0b
address _factory
setOperator 0x558a7297
address _operator
bool _status
suspendAgent 0xe41017cd
address agent
transferOwnership 0xf2fde38b
address newOwner
updateAgent 0xb37598c9
address agent
uint256 newCommission
Recent Transactions
No transactions found for this address