# Developers

### Architecture Overview

#### Hub-and-Spoke Model

xTokens are omnichain OFTs that use a hub-and-spoke architecture powered by LayerZero V2:

```
┌─────────────┐         ┌─────────────┐         ┌─────────────┐
│   Arbitrum  │         │   HyperEVM  │         │     Base    │
│   (Spoke)   │◄───────►│    (Hub)    │◄───────►│   (Spoke)   │
└─────────────┘         └─────────────┘         └─────────────┘
     User                xTokens Logic               User
  Interaction            Asset Management          Interaction
                         Share Minting
```

### Key Concepts

#### Share Tokens

Share tokens represent proportional ownership in the vault:

* **Decimals**: Always 18 decimals across all chains
* **Ticker**: Specific to each xToken (e.g., xHYPE, xBTC)
* **Cross-Chain**: Can be transferred between any supported chain via LayerZero
* **Yield-Bearing**: Share value increases as vault assets grow (tracked via NAV)

The "Hub Share" are managed by the `ShareManager` contract while the cross-chain "Spoke Share" are managed by ShareOFT.

This ensure the `ShareManager`  on the hub (HyperEVM) always hold the total supply of shares available on all supported chain.&#x20;

The ShareManager (Hub Share) is wrapped by an OFTAdapter for cross-chain capacity and linking with the Spoke Share.

#### Deposit&#x20;

Deposits are done through the `DepositPipe` contracts, there is 1 DepositPipe per asset per xToken.

| Asset | Decimals | Example Amount    |
| ----- | -------- | ----------------- |
| USDT0 | 6        | 1000000 = 1 USDT0 |
| USDC  | 6        | 1000000 = 1 USDC  |
| USDH  | 6        | 1000000 = 1 USDH  |

**Note**: Each XToken may support different assets. Check the specific XToken documentation for supported assets.

#### Redemption Asset

Redemptions are done through the `RedemptionPipe` contract, there is only 1 RedemptionPipe per xToken. As of now, shares can only be redeemed for USDT0.

#### OFT (Omnichain Fungible Tokens)

LayerZero V2 OFT enables cross-chain token transfers:

* **AssetOFT**: Wraps deposit assets (USDC, USDT0, etc.) for cross-chain transfers
* **ShareOFT**: Wraps vault shares for cross-chain transfers
* **OFTAdapter**: For tokens with existing supply (e.g., on the hub chain)
* **Compose Messages**: Trigger vault operations (deposits/redemptions) on message receipt

#### Oracle

NAV determines the share price:

```
Share Price = Total NAV / Total Share Supply
Share Price = NAVOracle.getNAV() / ShareManager.totalSupply()
```

* **18 Decimals**: NAV is always tracked in 18 decimals internally
* **On-Chain Oracle**: Real-time NAV available via `NAVOracle.getNAV()`
* **Dynamic**: Updates with deposits, redemptions, and vault performance

A **Pyth** price feed is also available for each xTokens.
