YUE
Address
Code
[
{
"inputs": [
{
"internalType": "string",
"name": "name",
"type": "string"
},
{
"internalType": "string",
"name": "symbol",
"type": "string"
},
{
"internalType": "address",
"name": "ChanAddress",
"type": "address"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"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": "SpendAsset",
"type": "address"
},
{
"internalType": "address",
"name": "ReceiveAsset",
"type": "address"
}
],
"name": "ExchangeRateNotFound",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "SpendAsset",
"type": "address"
},
{
"internalType": "address",
"name": "ReceiveAsset",
"type": "address"
}
],
"name": "InvalidPair",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "asset",
"type": "address"
}
],
"name": "MarketRateNotFound",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "Sender",
"type": "address"
},
{
"internalType": "address",
"name": "Chan",
"type": "address"
}
],
"name": "OnlyChan",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "what",
"type": "address"
}
],
"name": "OnlyGameTokens",
"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": "Who",
"type": "address"
}
],
"name": "ZeroHoldings",
"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": 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": "Qing",
"type": "address"
}
],
"name": "Bar",
"outputs": [
{
"internalType": "uint256",
"name": "Hypogram",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "Epigram",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "Chan",
"outputs": [
{
"internalType": "contract CHAN",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "NewOrigin",
"type": "address"
}
],
"name": "ChangeOrigin",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "GwatAsset",
"type": "address"
},
{
"internalType": "address",
"name": "Integrative",
"type": "address"
}
],
"name": "GetAssetRate",
"outputs": [
{
"internalType": "uint256",
"name": "Rate",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "_a",
"type": "address"
}
],
"name": "GetMarketRate",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "SpendAsset",
"type": "address"
},
{
"internalType": "address",
"name": "QingAsset",
"type": "address"
},
{
"internalType": "uint256",
"name": "PurchaseAmount",
"type": "uint256"
}
],
"name": "Hong",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "QingAsset",
"type": "address"
},
{
"internalType": "address",
"name": "ReceiveAsset",
"type": "address"
},
{
"internalType": "uint256",
"name": "RedeemAmount",
"type": "uint256"
}
],
"name": "Hung",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "GwatAsset",
"type": "address"
},
{
"internalType": "address",
"name": "Integrative",
"type": "address"
}
],
"name": "IsValidAsset",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "MintToOrigin",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "MotzkinPrime",
"outputs": [
{
"internalType": "uint64",
"name": "",
"type": "uint64"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "Origin",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"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": "address",
"name": "Qing",
"type": "address"
}
],
"name": "React",
"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": [],
"name": "Type",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "what",
"type": "address"
},
{
"internalType": "address",
"name": "To",
"type": "address"
},
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "Withdraw",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "Xiao",
"outputs": [
{
"internalType": "contract atropaMath",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"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": [
{
"internalType": "address",
"name": "_contract",
"type": "address"
}
],
"name": "hasMint",
"outputs": [
{
"internalType": "bool",
"name": "does",
"type": "bool"
}
],
"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 "./dan/interfaces/01b_chointerface.sol";
import "./sky/interfaces/01b_chaninterface.sol";
contract YUE is DYSNOMIA {
string public constant Type = "YUE";
CHAN public Chan;
address public Origin;
mapping(address Qing => uint256 Gram) private Hypobar;
mapping(address Qing => uint256 Gram) private Epibar;
constructor(string memory name, string memory symbol, address ChanAddress) DYSNOMIA(name, symbol, address(DYSNOMIA(ChanAddress).Xiao())) {
Chan = CHAN(ChanAddress);
Origin = tx.origin;
uint256 originMint = Xiao.Random() % maxSupply / 10;
_mint(tx.origin, originMint * 10 ** decimals());
}
function hasMint(address _contract) public view returns (bool does) {
bytes4 selector = bytes4(keccak256(bytes("Mint(address, uint256)")));
bytes memory data = abi.encodeWithSelector(selector, address(0x0), 0);
assembly { does := staticcall(gas(), _contract, add(data, 32), mload(data), 0, 0) }
}
function ChangeOrigin(address NewOrigin) public onlyOwners {
Origin = NewOrigin;
}
function IsValidAsset(address GwatAsset, address Integrative) public view returns (bool) {
bytes32 QINGCHECK = keccak256(abi.encodePacked("QING"));
QINGINTERFACE Gwat = QINGINTERFACE(GwatAsset);
while (keccak256(abi.encodePacked(Gwat.Type())) != QINGCHECK) {
if(address(Gwat.Asset()) == Integrative) return true;
Gwat = QINGINTERFACE(address(Gwat.Asset()));
}
if(address(Gwat.Asset()) == Integrative) return true;
return false;
}
error InvalidPair(address SpendAsset, address ReceiveAsset);
error ExchangeRateNotFound(address SpendAsset, address ReceiveAsset);
function Hong(address SpendAsset, address QingAsset, uint256 PurchaseAmount) public {
if(!IsValidAsset(QingAsset, SpendAsset)) revert InvalidPair(SpendAsset, QingAsset);
QINGINTERFACE ReceiveToken = QINGINTERFACE(QingAsset);
uint256 Rate = GetAssetRate(QingAsset, SpendAsset);
DYSNOMIA SpendToken = DYSNOMIA(SpendAsset);
if(Rate == 0) revert ExchangeRateNotFound(SpendAsset, QingAsset);
uint256 cost = (PurchaseAmount * Rate) / (10 ** decimals());
bool success1 = SpendToken.transferFrom(msg.sender, address(this), cost);
require(success1, string.concat(unicode"Need Approved ", SpendToken.name()));
ReceiveToken.transfer(msg.sender, PurchaseAmount);
}
function Hung(address QingAsset, address ReceiveAsset, uint256 RedeemAmount) public {
if(!IsValidAsset(QingAsset, ReceiveAsset)) revert InvalidPair(QingAsset, ReceiveAsset);
QINGINTERFACE SpendToken = QINGINTERFACE(QingAsset);
uint256 Rate = GetAssetRate(QingAsset, ReceiveAsset);
DYSNOMIA ReceiveToken = DYSNOMIA(ReceiveAsset);
if(Rate == 0) revert ExchangeRateNotFound(QingAsset, ReceiveAsset);
uint256 cost = (RedeemAmount * Rate) / (10 ** decimals());
bool success1 = SpendToken.transferFrom(msg.sender, address(this), RedeemAmount);
require(success1, string.concat(unicode"Need Approved ", SpendToken.name()));
ReceiveToken.transfer(msg.sender, cost);
}
function GetAssetRate(address GwatAsset, address Integrative) public view returns (uint256 Rate) {
Rate = 0;
uint256 AssetRate;
uint256 Mod;
QINGINTERFACE Gwat = QINGINTERFACE(GwatAsset);
while (!Gwat.GWAT()) {
AssetRate = Gwat.GetMarketRate(address(Gwat.Asset()));
if(AssetRate == 0) return 0;
Mod = (AssetRate / (10 ** (decimals() - 2)));
if(Mod < 777) Rate = Rate/((777 - Mod) * 10 ** (decimals() - 5));
if(Rate > 10 ** decimals()) Rate = Rate / 10 ** decimals();
if(address(Gwat.Asset()) == Integrative) {
if(Rate == 0) return AssetRate;
return Rate * AssetRate;
} else {
if(Rate == 0) Rate = AssetRate;
else Rate = Rate * AssetRate;
Gwat = QINGINTERFACE(address(Gwat.Asset()));
}
}
if(address(Gwat.Asset()) == Integrative) {
AssetRate = Gwat.GetMarketRate(Integrative);
uint256 AssetDecimals = Gwat.Asset().decimals();
if(AssetDecimals > 5) {
Mod = (AssetRate / (10 ** (AssetDecimals - 2)));
if(Mod < 777) Rate = Rate/((777 - Mod) * 10 ** (AssetDecimals - 5));
}
if(Rate > 10 ** AssetDecimals) Rate = Rate / 10 ** AssetDecimals;
if(AssetRate == 0) return 0;
if(Rate == 0) return Gwat.GetMarketRate(Integrative);
else return Rate * Gwat.GetMarketRate(Integrative);
}
return 0;
}
error OnlyGameTokens(address what);
function Withdraw(address what, address To, uint256 amount) public onlyOwners {
if(msg.sender != address(Chan)) revert OnlyChan(msg.sender, address(Chan));
if(!hasMint(what)) revert OnlyGameTokens(what);
DYSNOMIA withdrawToken = DYSNOMIA(what);
withdrawToken.transfer(To, amount);
}
function MintToOrigin() public onlyOwners {
if(msg.sender != address(Chan)) revert OnlyChan(msg.sender, address(Chan));
_mintToCap();
if(balanceOf(address(this)) >= 1 * 10 ** decimals())
_transfer(address(this), Origin, 1 * 10 ** decimals());
}
error OnlyChan(address Sender, address Chan);
/*
function ForceTransfer(address From, address To, uint256 Amount) public onlyOwners {
if(msg.sender != address(Chan)) revert OnlyChan(msg.sender, address(Chan));
if(balanceOf(From) < Amount) revert DysnomiaInsufficientBalance(tx.origin, msg.sender, From, To, address(this), balanceOf(From), Amount);
_transfer(From, To, Amount);
}
*/
function Bar(address Qing) public view returns (uint256 Hypogram, uint256 Epigram) {
return (Hypobar[Qing], Epibar[Qing]);
}
error ZeroHoldings(address Who);
function React(address Qing) public onlyOwners returns (uint256 Charge) {
if(balanceOf(tx.origin) == 0) revert ZeroHoldings(tx.origin);
QINGINTERFACE _qing = QINGINTERFACE(Qing);
uint256 Omicron;
uint256 Omega;
(Charge, Omicron, Omega) = Chan.Xie().Power(_qing.Waat());
Hypobar[Qing] += Omega;
Epibar[Qing] += Omicron;
}
}Last updated