YUE¶
Overview¶
YUE is the player's personal bank contract. Each player has a YUE that holds their assets, manages exchange rates, and provides withdrawals. It integrates with the CHAN for opt-in game mechanics.
- Inherits: DYSNOMIA V2
- License: Sharia
- Solidity: ^0.8.21
What This Means For Players¶
Plain English Summary: YUE is your personal bank - it holds your winnings and handles exchanges. Every player has their own YUE that stores game tokens, tracks activity, and lets you trade between different currencies. It's like having a private bank account in the game.
Real-World Analogy: Think of YUE as your bank account plus a currency exchange booth. You can deposit earnings, withdraw to your wallet, and exchange one type of game token for another. Your YUE remembers your transaction history and calculates rates for exchanges.
How It Affects Your Gameplay:
- Hold assets - Game rewards and earnings accumulate in your YUE
- Exchange tokens - Use Hong to buy and Hung to sell QING tokens
- Withdraw - Move tokens from your YUE to your actual wallet
- Track activity - Your bar values (Hypobar/Epibar) record your QING interactions
State Variables¶
| Variable | Type | Visibility | Description |
|---|---|---|---|
| Type | string | public constant | "YUE" |
| Chan | CHAN | public | Reference to CHAN player manager |
| Origin | address | public | Player's wallet address |
| Hypobar | mapping(address => uint256) | private | Accumulated Omega per QING |
| Epibar | mapping(address => uint256) | private | Accumulated Omicron per QING |
Read Functions¶
Bar¶
- Returns: (Hypobar, Epibar) for the QING - In Plain English: Check your accumulated activity points for a specific venue. These numbers grow as you interact with that QING and affect your rewards.IsValidAsset¶
- Returns: True if Integrative is in GwatAsset's chain - In Plain English: Check if two tokens can be exchanged. Tokens must be connected through a chain of venues - like checking if two currencies can be converted.GetAssetRate¶
- Returns: Exchange rate traversing the QING chain - In Plain English: Get the current exchange rate between two tokens. The rate is calculated by following the chain of venues connecting them.Write Functions¶
ChangeOrigin¶
- Access:onlyOwners
- Parameters:
- NewOrigin (address): New wallet address to own this YUE
- Description: Updates the Origin address that controls this YUE bank.
- Logic Flow:
1. Set Origin = NewOrigin
- Side Effects: Updates Origin state variable
- In Plain English: Move your bank account to a different wallet address. Useful if you need to change wallets but want to keep your game earnings. Only called via CHAN.TransferYue.
Hong¶
- Access:public
- Parameters:
- SpendAsset (address): Token you're paying with
- QingAsset (address): QING/GWAT token you want to buy
- PurchaseAmount (uint256): Amount of QingAsset to purchase
- Description: Purchases QING tokens by spending base asset at the calculated exchange rate.
- Logic Flow:
1. Validate asset pair: if(!IsValidAsset(QingAsset, SpendAsset)) revert InvalidPair
2. Get exchange rate: Rate = GetAssetRate(QingAsset, SpendAsset)
3. Calculate cost: Cost = PurchaseAmount * Rate / 10^decimals
4. Transfer spend from caller: SpendAsset.transferFrom(msg.sender, address(this), Cost)
5. Transfer receive to caller: QingAsset.transfer(msg.sender, PurchaseAmount)
- Computation Details:
- Rate traverses the QING→Asset chain, applying discounts at each level
- Cost calculation accounts for decimal precision
- Side Effects: Transfers tokens both directions
- In Plain English: Buy venue tokens using another currency. Like exchanging dollars for arcade tokens - you spend one type of token to get another at the calculated exchange rate based on the QING chain.
Hung¶
- Access:public
- Parameters:
- QingAsset (address): QING/GWAT token you're selling
- ReceiveAsset (address): Token you want to receive
- RedeemAmount (uint256): Amount of QingAsset to sell
- Description: Redeems QING tokens to receive base asset at the calculated exchange rate.
- Logic Flow:
1. Validate asset pair: if(!IsValidAsset(QingAsset, ReceiveAsset)) revert InvalidPair
2. Get exchange rate: Rate = GetAssetRate(QingAsset, ReceiveAsset)
3. Calculate receive amount: Receive = RedeemAmount * Rate / 10^decimals
4. Transfer QING from caller: QingAsset.transferFrom(msg.sender, address(this), RedeemAmount)
5. Transfer base to caller: ReceiveAsset.transfer(msg.sender, Receive)
- Side Effects: Transfers tokens both directions
- In Plain English: Sell venue tokens back for another currency. The reverse of Hong - you cash out venue tokens to get a different token at the current rate.
Withdraw¶
- Access:onlyOwners (only via CHAN after opt-in)
- Parameters:
- what (address): Token to withdraw
- To (address): Destination address
- amount (uint256): Amount to transfer
- Description: Withdraws tokens from the YUE bank. Requires CHAN authorization.
- Logic Flow:
1. Verify caller is CHAN: if(msg.sender != address(Chan)) revert OnlyChan
2. Check token has Mint function: if(!hasMint(what)) revert OnlyGameTokens
3. Execute transfer: DYSNOMIA(what).transfer(To, amount)
- Side Effects: Transfers tokens from YUE
- In Plain English: Take tokens out of your game bank and send them to any address. Must go through the CHAN player manager for security. Only game tokens (with Mint function) can be withdrawn.
MintToOrigin¶
- Access:onlyOwners (only via CHAN)
- Description: Mints YUE tokens to cap, then transfers 1 token to Origin.
- Logic Flow:
1. Verify caller is CHAN or owner
2. Mint to capacity: mintToCap()
3. If balance >= 1 token: _transfer(this, Origin, 1 * 10^decimals)
- Side Effects: Mints YUE tokens; may transfer 1 token to Origin
- In Plain English: Create tokens up to capacity, then send 1 token to your wallet. This is used during game setup and reward distribution to give you YUE tokens.
React¶
- Access:onlyOwners
- Parameters:
- Qing (address): QING venue address to react with
- Returns:
- Charge (uint256): Power value from XIE.Power calculation
- Description: Reacts with a QING venue, accumulating Hypobar/Epibar values.
- Logic Flow:
1. Get power values: (Charge, Omicron, Omega) = Chan.Xie().Power(QINGINTERFACE(Qing).Waat())
2. Accumulate Hypobar: Hypobar[Qing] += Omega
3. Accumulate Epibar: Epibar[Qing] += Omicron
4. Return Charge
- Computation Details:
- Hypobar accumulates Omega (venue-side metric)
- Epibar accumulates Omicron (player-side metric)
- Both grow over time with each interaction
- Side Effects: Updates Hypobar and Epibar mappings; triggers XIE.Power chain
- In Plain English: Interact with a venue to build up your activity score there. Each reaction adds Omega to your Hypobar and Omicron to your Epibar for that venue. These accumulated values affect future reward calculations.
Errors¶
| Error | Parameters | Description |
|---|---|---|
| InvalidPair | SpendAsset, ReceiveAsset | Assets not in valid chain |
| ExchangeRateNotFound | SpendAsset, ReceiveAsset | No rate found |
| OnlyChan | Sender, Chan | Only CHAN can call |
| OnlyGameTokens | what | Only mintable tokens |
| ZeroHoldings | Who | User has no YUE balance |
Contract Interactions¶
Depends On¶
- DYSNOMIA V2 - Base functionality
- CHAN - Player management
Created By¶
- SEI - Player onboarding
Special Mechanisms¶
Asset Chain Traversal¶
function IsValidAsset(address GwatAsset, address Integrative) {
QINGINTERFACE Gwat = QINGINTERFACE(GwatAsset);
while (Type != "QING") {
if(Gwat.Asset() == Integrative) return true;
Gwat = QINGINTERFACE(Gwat.Asset());
}
return Gwat.Asset() == Integrative;
}
Rate Calculation¶
Rates are computed by traversing the QING chain and multiplying rates with a discount modifier:
Mod = (AssetRate / (10 ** (decimals - 2)));
if(Mod < 777) Rate = Rate/((777 - Mod) * 10 ** (decimals - 5));
CHAN Authorization¶
Sensitive operations require the caller to be CHAN:
Bar Accumulation¶
React() accumulates values for later use:
Contract Verification¶
| Property | Value |
|---|---|
| Keccak256 Hash | 0xb3172df3e8180d1cf21f0746a6d7a4e34ab245e5f02ff07dfef2a74184e494d2 |
| Source URL | https://raw.githubusercontent.com/busytoby/atropa_pulsechain/main/solidity/dysnomia/domain/yue.sol |
| Hash Generated | 2026-02-08T00:29:08Z |