Verified contractExactMIT
YollotlToken
Address0x3c65e2b2ca2c3ec4d1770b969db3c05fcb70c566
- Balance
0 ETH
- Transactions
2
- Compiler
solc 0.8.34
- Same code
Only this contract
Details
- Compiler
- solc 0.8.34+commit.80d5c536
- Language
- solidity
- Optimization
- No
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,439,027
- Creation transaction
- 0x2626529403…3e94423f90
yollot.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
/**
* @title Yollotl Security Token
* @dev Self-contained ERC-20 security token with KYC whitelist, snapshots, and dividends.
* All OpenZeppelin base contracts inlined to avoid dependency resolution issues.
*/
// ============ Context ============
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
// ============ IERC20 ============
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, uint256 value) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 value) external returns (bool);
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
// ============ IERC20Metadata ============
interface IERC20Metadata is IERC20 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
}
// ============ ERC20 ============
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
function name() public view virtual returns (string memory) { return _name; }
function symbol() public view virtual returns (string memory) { return _symbol; }
function decimals() public view virtual returns (uint8) { return 18; }
function totalSupply() public view virtual returns (uint256) { return _totalSupply; }
function balanceOf(address account) public view virtual returns (uint256) { return _balances[account]; }
function transfer(address to, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_transfer(owner, to, value);
return true;
}
function allowance(address owner, address spender) public view virtual returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, value);
return true;
}
function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, value);
_transfer(from, to, value);
return true;
}
function _transfer(address from, address to, uint256 value) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_update(from, to, value);
}
function _update(address from, address to, uint256 value) internal virtual {
if (from == address(0)) {
_totalSupply += value;
} else {
uint256 fromBalance = _balances[from];
require(fromBalance >= value, "ERC20: insufficient balance");
unchecked {
_balances[from] = fromBalance - value;
}
}
if (to == address(0)) {
unchecked {
_totalSupply -= value;
}
} else {
unchecked {
_balances[to] += value;
}
}
emit Transfer(from, to, value);
}
function _mint(address account, uint256 value) internal {
require(account != address(0), "ERC20: mint to the zero address");
_update(address(0), account, value);
}
function _burn(address account, uint256 value) internal {
require(account != address(0), "ERC20: burn from the zero address");
_update(account, address(0), value);
}
function _approve(address owner, address spender, uint256 value) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = value;
emit Approval(owner, spender, value);
}
function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= value, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - value);
}
}
}
}
// ============ Ownable ============
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor(address initialOwner) {
require(initialOwner != address(0), "Ownable: invalid owner");
_transferOwnership(initialOwner);
}
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
function owner() public view virtual returns (address) { return _owner; }
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: invalid new owner");
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
// ============ Pausable ============
abstract contract Pausable is Context {
bool private _paused;
event Paused(address account);
event Unpaused(address account);
constructor() { _paused = false; }
function paused() public view virtual returns (bool) { return _paused; }
modifier whenNotPaused() {
require(!paused(), "Pausable: paused");
_;
}
modifier whenPaused() {
require(paused(), "Pausable: not paused");
_;
}
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
// ========================================================
// APPLICATION CONTRACTS
// ========================================================
/**
* @title IdentityRegistry
* @dev Control de lista blanca KYC/AML para inversores de YOLLOTL
*/
contract IdentityRegistry is Ownable {
mapping(address => bool) private _verified;
mapping(address => uint16) private _countryCode;
event InvestorStatusUpdated(address indexed investor, bool status, uint16 country);
constructor(address initialOwner) Ownable(initialOwner) {}
function setInvestor(address investor, bool status, uint16 country) external onlyOwner {
_verified[investor] = status;
_countryCode[investor] = country;
emit InvestorStatusUpdated(investor, status, country);
}
function isVerified(address investor) external view returns (bool) {
return _verified[investor];
}
function getCountry(address investor) external view returns (uint16) {
return _countryCode[investor];
}
}
/**
* @title YollotlToken
* @dev Token de Seguridad ERC-3643 compatible con Snapshots para dividendos
*/
contract YollotlToken is ERC20, Ownable, Pausable {
IdentityRegistry public identityRegistry;
uint256 public constant TOTAL_SUPPLY_CAP = 25_000_000 * 10**18;
address public dividendDistributor;
// --- Snapshot logic (replaces ERC20Snapshot which was removed in OZ v5) ---
struct Snapshot {
uint256 id;
uint256 value;
}
mapping(address => Snapshot[]) private _accountSnapshots;
Snapshot[] private _totalSupplySnapshots;
uint256 private _currentSnapshotId;
event SnapshotTaken(uint256 id);
modifier onlyDistributorOrOwner() {
require(msg.sender == owner() || msg.sender == dividendDistributor, "No autorizado");
_;
}
constructor(address _identityRegistry, address initialOwner)
ERC20("HarvestCoin", "HarvestCoin")
Ownable(initialOwner)
{
require(_identityRegistry != address(0), "Registro invalido");
identityRegistry = IdentityRegistry(_identityRegistry);
_mint(msg.sender, TOTAL_SUPPLY_CAP);
}
function setDividendDistributor(address _distributor) external onlyOwner {
dividendDistributor = _distributor;
}
function snapshot() external onlyDistributorOrOwner returns (uint256) {
_currentSnapshotId++;
uint256 currentId = _currentSnapshotId;
_updateSnapshot(_totalSupplySnapshots, currentId, totalSupply());
emit SnapshotTaken(currentId);
return currentId;
}
function balanceOfAt(address account, uint256 snapshotId) external view returns (uint256) {
require(snapshotId > 0 && snapshotId <= _currentSnapshotId, "Snapshot inexistente");
return _valueAt(_accountSnapshots[account], snapshotId);
}
function totalSupplyAt(uint256 snapshotId) external view returns (uint256) {
require(snapshotId > 0 && snapshotId <= _currentSnapshotId, "Snapshot inexistente");
return _valueAt(_totalSupplySnapshots, snapshotId);
}
function _valueAt(Snapshot[] storage snaps, uint256 snapshotId) private view returns (uint256) {
uint256 low = 0;
uint256 high = snaps.length;
while (low < high) {
uint256 mid = (low + high) / 2;
if (snaps[mid].id > snapshotId) {
high = mid;
} else {
low = mid + 1;
}
}
return high == 0 ? 0 : snaps[high - 1].value;
}
function _updateSnapshot(Snapshot[] storage snaps, uint256 currentId, uint256 currentValue) private {
if (snaps.length > 0 && snaps[snaps.length - 1].id == currentId) {
snaps[snaps.length - 1].value = currentValue;
} else {
snaps.push(Snapshot(currentId, currentValue));
}
}
function _updateAccountSnapshot(address account) private {
_updateSnapshot(_accountSnapshots[account], _currentSnapshotId, balanceOf(account));
}
function _updateTotalSupplySnapshot() private {
_updateSnapshot(_totalSupplySnapshots, _currentSnapshotId, totalSupply());
}
function pause() external onlyOwner {
_pause();
}
function unpause() external onlyOwner {
_unpause();
}
function _update(address from, address to, uint256 value) internal override {
if (!paused()) {
if (from != address(0) && to != address(0)) {
require(identityRegistry.isVerified(from), "Emisor sin KYC verificado");
require(identityRegistry.isVerified(to), "Receptor sin KYC verificado");
}
}
super._update(from, to, value);
if (_currentSnapshotId > 0) {
if (from != address(0)) {
_updateAccountSnapshot(from);
}
if (to != address(0)) {
_updateAccountSnapshot(to);
}
_updateTotalSupplySnapshot();
}
}
}
/**
* @title DividendDistributor
* @dev Distribucion mensual de utilidades en USDC
*/
contract DividendDistributor is Ownable {
YollotlToken public immutable yollotl;
IERC20 public immutable usdc;
struct Distribution {
uint256 snapshotId;
uint256 totalAmount;
uint256 totalSupply;
uint256 timestamp;
}
Distribution[] public distributions;
mapping(uint256 => mapping(address => bool)) public claimed;
event DividendDeposited(uint256 indexed id, uint256 snapshotId, uint256 amount);
event DividendClaimed(uint256 indexed id, address indexed user, uint256 amount);
constructor(address _yollotl, address _usdc, address initialOwner) Ownable(initialOwner) {
yollotl = YollotlToken(_yollotl);
usdc = IERC20(_usdc);
}
function depositDividend(uint256 amount) external onlyOwner {
require(amount > 0, "Monto invalido");
require(usdc.transferFrom(msg.sender, address(this), amount), "Fallo deposito USDC");
uint256 snapId = yollotl.snapshot();
uint256 supply = yollotl.totalSupplyAt(snapId);
distributions.push(Distribution({
snapshotId: snapId,
totalAmount: amount,
totalSupply: supply,
timestamp: block.timestamp
}));
emit DividendDeposited(distributions.length - 1, snapId, amount);
}
function claim(uint256 distId) external {
require(distId < distributions.length, "Distribucion no existe");
require(!claimed[distId][msg.sender], "Ya cobrado");
Distribution memory d = distributions[distId];
uint256 balance = yollotl.balanceOfAt(msg.sender, d.snapshotId);
require(balance > 0, "Sin balance en el snapshot");
uint256 payout = (d.totalAmount * balance) / d.totalSupply;
claimed[distId][msg.sender] = true;
require(usdc.transfer(msg.sender, payout), "Fallo envio USDC");
emit DividendClaimed(distId, msg.sender, payout);
}
}
Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": false
},
"remappings": []
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.