CHAN
Address
Code
[
{
"inputs": [
{
"internalType": "address",
"name": "XieAddress",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [
{
"internalType": "address",
"name": "Origin",
"type": "address"
},
{
"internalType": "address",
"name": "Yue",
"type": "address"
},
{
"internalType": "address",
"name": "New",
"type": "address"
}
],
"name": "AlreadyAdded",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "origin",
"type": "address"
},
{
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"internalType": "address",
"name": "what",
"type": "address"
},
{
"internalType": "uint256",
"name": "allowance",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "needed",
"type": "uint256"
}
],
"name": "DysnomiaInsufficientAllowance",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "origin",
"type": "address"
},
{
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"internalType": "address",
"name": "from",
"type": "address"
},
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "address",
"name": "what",
"type": "address"
},
{
"internalType": "uint256",
"name": "balance",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "needed",
"type": "uint256"
}
],
"name": "DysnomiaInsufficientBalance",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "asset",
"type": "address"
}
],
"name": "MarketRateNotFound",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "YueOrigin",
"type": "address"
},
{
"internalType": "address",
"name": "Requestor",
"type": "address"
}
],
"name": "NotOrigin",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "origin",
"type": "address"
},
{
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"internalType": "address",
"name": "what",
"type": "address"
}
],
"name": "OwnableInvalidOwner",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "origin",
"type": "address"
},
{
"internalType": "address",
"name": "account",
"type": "address"
},
{
"internalType": "address",
"name": "what",
"type": "address"
}
],
"name": "OwnableUnauthorizedAccount",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "Player",
"type": "address"
},
{
"internalType": "address",
"name": "Yue",
"type": "address"
},
{
"internalType": "address",
"name": "Contract",
"type": "address"
}
],
"name": "PlayerMustOptIn",
"type": "error"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "Approval",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "Origin",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "Yue",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "Contract",
"type": "address"
},
{
"indexed": false,
"internalType": "bool",
"name": "Allow",
"type": "bool"
}
],
"name": "NewSpenderContractOptIn",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "newOwner",
"type": "address"
},
{
"indexed": true,
"internalType": "bool",
"name": "state",
"type": "bool"
}
],
"name": "OwnershipUpdate",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "from",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "to",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "Transfer",
"type": "event"
},
{
"inputs": [
{
"internalType": "address",
"name": "Origin",
"type": "address"
},
{
"internalType": "address",
"name": "Yue",
"type": "address"
}
],
"name": "AddYue",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_a",
"type": "address"
}
],
"name": "GetMarketRate",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "MotzkinPrime",
"outputs": [
{
"internalType": "uint64",
"name": "",
"type": "uint64"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "Contract",
"type": "address"
},
{
"internalType": "bool",
"name": "Allow",
"type": "bool"
}
],
"name": "OptIn",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract YUEINTERFACE",
"name": "Yue",
"type": "address"
},
{
"internalType": "address",
"name": "Contract",
"type": "address"
}
],
"name": "OptedIn",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_t",
"type": "address"
},
{
"internalType": "uint256",
"name": "_a",
"type": "uint256"
}
],
"name": "Purchase",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract YUEINTERFACE",
"name": "Yue",
"type": "address"
},
{
"internalType": "address",
"name": "Qing",
"type": "address"
}
],
"name": "ReactYue",
"outputs": [
{
"internalType": "uint256",
"name": "Charge",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_t",
"type": "address"
},
{
"internalType": "uint256",
"name": "_a",
"type": "uint256"
}
],
"name": "Redeem",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "string",
"name": "newName",
"type": "string"
},
{
"internalType": "string",
"name": "newSymbol",
"type": "string"
}
],
"name": "Rename",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "Yue",
"type": "address"
},
{
"internalType": "address",
"name": "NewOrigin",
"type": "address"
}
],
"name": "TransferYue",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "Type",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "Xiao",
"outputs": [
{
"internalType": "contract atropaMath",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "Xie",
"outputs": [
{
"internalType": "contract XIE",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "Yan",
"outputs": [
{
"internalType": "address",
"name": "Yue",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract YUEINTERFACE",
"name": "Yue",
"type": "address"
},
{
"internalType": "address",
"name": "From",
"type": "address"
},
{
"internalType": "address",
"name": "To",
"type": "address"
},
{
"internalType": "uint256",
"name": "Amount",
"type": "uint256"
}
],
"name": "YueForceTransfer",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract YUEINTERFACE",
"name": "Yue",
"type": "address"
}
],
"name": "YueMintToOrigin",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "contract YUEINTERFACE",
"name": "Yue",
"type": "address"
},
{
"internalType": "address",
"name": "Asset",
"type": "address"
},
{
"internalType": "address",
"name": "To",
"type": "address"
},
{
"internalType": "uint256",
"name": "Amount",
"type": "uint256"
}
],
"name": "YueWithdraw",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "addOwner",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"internalType": "address",
"name": "spender",
"type": "address"
}
],
"name": "allowance",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "approve",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "account",
"type": "address"
}
],
"name": "balanceOf",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "decimals",
"outputs": [
{
"internalType": "uint8",
"name": "",
"type": "uint8"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "maxSupply",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "mintToCap",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "name",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "cOwner",
"type": "address"
}
],
"name": "owner",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "owner",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "toRemove",
"type": "address"
}
],
"name": "renounceOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "symbol",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "totalSupply",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "transfer",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "from",
"type": "address"
},
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "transferFrom",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
}
]// SPDX-License-Identifier: Sharia
pragma solidity ^0.8.21;
import "../../01_dysnomia_v2.sol";
import "../interfaces/yueinterface.sol";
contract CHAN is DYSNOMIA {
string public constant Type = "CHAN";
XIE public Xie;
mapping(address => address Yue) public Yan;
mapping(address Holder => mapping(address Contract => bool MayTransfer)) private _optInList;
constructor(address XieAddress) DYSNOMIA("Dysnomia Chan", "CHAN", address(DYSNOMIA(XieAddress).Xiao())) {
Xie = XIE(XieAddress);
addOwner(tx.origin);
_mintToCap();
uint256 originMint = Xiao.Random() % maxSupply / 10;
_mint(tx.origin, originMint * 10 ** decimals());
_addMarketRate(AFFECTIONContract, 1 * 10 ** decimals());
_addMarketRate(XieAddress, 1 * 10 ** decimals());
}
error AlreadyAdded(address Origin, address Yue, address New);
function AddYue(address Origin, address Yue) public onlyOwners {
if(Yan[Origin] != address(0x0)) revert AlreadyAdded(Origin, Yan[Origin], Yue);
Yan[Origin] = Yue;
_mintToCap();
}
error NotOrigin(address YueOrigin, address Requestor);
function TransferYue(address Yue, address NewOrigin) public {
if(Yan[NewOrigin] != address(0x0)) revert AlreadyAdded(YUEINTERFACE(Yan[NewOrigin]).Origin(), Yue, NewOrigin);
YUEINTERFACE _chi = YUEINTERFACE(Yue);
if(_chi.Origin() != tx.origin) revert NotOrigin(_chi.Origin(), tx.origin);
Yan[_chi.Origin()] = address(0x0);
_chi.ChangeOrigin(NewOrigin);
Yan[NewOrigin] = Yue;
_mintToCap();
}
function ReactYue(YUEINTERFACE Yue, address Qing) public onlyOwners returns(uint256 Charge) {
return Yue.React(Qing);
}
event NewSpenderContractOptIn(address Origin, address Yue, address Contract, bool Allow);
function OptIn(address Contract, bool Allow) public {
address Yue = Yan[tx.origin];
_optInList[Yue][Contract] = Allow;
emit NewSpenderContractOptIn(tx.origin, Yue, Contract, Allow);
_mintToCap();
}
function OptedIn(YUEINTERFACE Yue, address Contract) public view returns (bool) {
return _optInList[address(Yue)][Contract];
}
error PlayerMustOptIn(address Player, address Yue, address Contract);
function YueWithdraw(YUEINTERFACE Yue, address Asset, address To, uint256 Amount) public onlyOwners {
if(!_optInList[address(Yue)][msg.sender]) revert PlayerMustOptIn(Yue.Origin(), address(Yue), msg.sender);
Yue.Withdraw(Asset, To, Amount);
_mintToCap();
}
function YueMintToOrigin(YUEINTERFACE Yue) public onlyOwners {
Yue.MintToOrigin();
_mintToCap();
}
function YueForceTransfer(YUEINTERFACE Yue, address From, address To, uint256 Amount) public onlyOwners {
if(!_optInList[address(Yue)][msg.sender]) revert PlayerMustOptIn(Yue.Origin(), address(Yue), msg.sender);
Yue.ForceTransfer(From, To, Amount);
_mintToCap();
}
}Last updated