Skip to content

Aman035/Xyra

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

66 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Xyra

Xyra is a universal cross-chain lending protocol built on ZetaChain. It unifies liquidity across multiple blockchains, enabling seamless supply, borrow, repay, and withdraw actions from any chain to any chain.


🌐 Overview

Why Xyra?

Traditional lending protocols are siloed per chain - liquidity on Ethereum, Solana, or Base cannot easily interact. Xyra.Fi leverages ZetaChain’s universal smart contracts to unify liquidity, letting users supply and borrow across chains without bridging or manual swaps. Home Supply Borrow Withdraw Repay Portfolio


πŸ—οΈ Project Structure

Xyra/
β”œβ”€β”€ contracts/                  # Solidity smart contracts
β”‚   β”œβ”€β”€ src/                    # Protocol source code
β”‚   β”‚   β”œβ”€β”€ pool/               # LendingPool, PoolManager
β”‚   β”‚   β”œβ”€β”€ vaults/             # ERC4626 reserves
β”‚   β”‚   β”œβ”€β”€ interestRate/       # Interest rate logic
β”‚   β”‚   β”œβ”€β”€ liquidation/        # Liquidation mechanisms
β”‚   β”‚   β”œβ”€β”€ oracle/             # Price oracles
β”‚   β”‚   β”œβ”€β”€ swap/               # Cross-chain swap integration via Uni V2
β”‚   β”‚   β”œβ”€β”€ accessControl/      # Role & access control
β”‚   β”‚   β”œβ”€β”€ collateral/         # Collateral management
β”‚   β”‚   └── protocol/           # Base + Universal contracts
β”‚   β”œβ”€β”€ script/                 # Deployment & setup scripts
β”‚   └── test/                   # Foundry unit tests
β”‚
β”œβ”€β”€ e2e/                        # End-to-end cross-chain tests
β”‚   └── src/                    # Scripts for testing cross-chain calls
β”‚
β”œβ”€β”€ frontend/                   # Next.js frontend app
β”‚   β”œβ”€β”€ app/                    # Pages (home, supply, borrow, portfolio)
β”‚   β”œβ”€β”€ lib/                    # Chain configs, ABIs, utilities, Zeta Gateway Interaction
β”‚   └── components/             # Reusable UI components
β”‚
└── README.md                   # Project documentation


✨ Features

  • Supply to Vaults

    • Supply liquidity from Ethereum Sepolia, Base Sepolia, Zeta Athens, or Solana Devnet.
    • Supply can be done on behalf of another address.
    • If the supplied asset differs from the vault’s reserve asset, it is automatically swapped.
  • Borrow Across Chains

    • Borrow from vaults to any chain and any address.
    • Assets are swapped internally if the borrowed asset differs from the vault’s underlying.
  • Withdraw Anywhere

    • Withdraw supplied liquidity to a specific chain and address.
    • Withdrawals also support cross-asset swaps.
  • Repay Flexibly

    • Repay borrowed positions from any chain, any asset, and even on behalf of another address.

How It Works

Supply

sequenceDiagram
    autonumber
    participant U as User Wallet (External Chain)
    participant ASSET as Source Asset (ERC20/SPL)
    participant GW as External Gateway (EVM/Solana)
    participant LP as LendingPool (ZetaChain β€’ Universal)
    participant DEX as DEX/Aggregator (Zeta)
    participant VAULT as Target Vault (ERC4626Reserve on Zeta)
    participant ID as UniversalIdentityLib
    participant IR as InterestRateManager
    participant OR as PriceOracle
    participant CM as CollateralManager

    Note over U,GW: Params: fromChain, fromAsset, amount,<br/>toVault (ETH/SOL/USDC...), onBehalfOf(Chain, Address)
    Note over VAULT: Vault asset = vault ZRC20 (e.g., ETH/SOL/USDC as ZRC20)

    rect rgb(245,245,245)
      Note over ASSET: (EVM) ERC20 approve may be required
      U->>ASSET: (1) approve()  ⟡ if ERC20
    end


    U->>GW: (2) depositAndCall(supply,fromAsset, toVault, amount, onBehalfOf(Chain, Address))

    GW-->>LP: (3) CCTX to ZetaChain + credit incoming ZRC20 equivalent

    LP->>ID: (4) map(onBehalfOf) β†’ universal identity
    LP-->>LP: (5) validate params & basic health checks

    alt fromAsset (ZRC20) β‰  vaultAsset (ZRC20)
      LP->>DEX: (6) swap fromAsset.ZRC20 β†’ vaultAsset.ZRC20
      DEX-->>LP: (7) receive vaultAsset.ZRC20
    else already correct asset
      LP-->>LP: (6) skip swap
    end

    LP->>VAULT: (8) deposit(vaultAsset.ZRC20, amount)
    VAULT-->>LP: (9) mint xERC20 to onBehalfOf

    par Post-accounting
      LP->>IR: (10) update utilization/interest
      LP->>OR: (11) record spot/price snapshot
      LP->>CM: (12) refresh collateral/LTV state
    end

    LP-->>U: (13) success: xERC20 credited to onBehalfOf (cross-chain supply finalized)

Loading

Borrow

sequenceDiagram
    autonumber
    participant U as User Wallet (External Chain)
    participant GW as External Gateway (EVM/Solana)
    participant LP as LendingPool (ZetaChain β€’ Universal)
    participant VAULT as Source Vault (ERC4626Reserve on Zeta)
    participant DEX as DEX/Aggregator (Zeta)
    participant IR as InterestRateManager
    participant OR as PriceOracle
    participant CM as CollateralManager
    participant OUT as Outbound Gateway (to Target Chain)

    Note over U,GW: Params: fromChain, fromVault, amount, borrowAsset, deliverTo(Chain, Address)
    Note over VAULT: Vault asset = vault ZRC20 (e.g., ETH/SOL/USDC as ZRC20)

    U->>GW: (1) call(borrow, fromVault, amount, borrowAsset, deliverTo)

    GW-->>LP: (2) CCTX delivery to LendingPool (Zeta)

    LP-->>LP: (3) validate collateral & health factor, max borrowable

    LP->>VAULT: (4) withdraw/redeem(vaultAsset.ZRC20, amount)
    VAULT-->>LP: (5) send vaultAsset.ZRC20 to LP

    alt borrowAsset (ZRC20) β‰  vaultAsset (ZRC20)
      LP->>DEX: (6) swap vaultAsset.ZRC20 β†’ borrowAsset.ZRC20
      DEX-->>LP: (7) receive borrowAsset.ZRC20
    else already correct asset
      LP-->>LP: (6) skip swap
    end

    LP->>OUT: (8) outbound transfer to deliverTo(Chain, Address)
    OUT-->>U: (9) asset delivered on target chain/address

    par Post-accounting
      LP->>IR: (10) accrue interest & update utilization
      LP->>OR: (11) record price snapshot for health checks
      LP->>CM: (12) update borrower debt & health factor
    end

    LP-->>U: (13) success: borrow finalized, debt recorded
Loading


πŸš€ Deployments

🌐 Frontend

The Xyra frontend is live on Vercel:
πŸ‘‰ https://xyra-sigma.vercel.app/

⛓️ Contracts (ZetaChain Testnet)


πŸ“Š Supported Networks

Action Sepolia Base Sepolia Zeta Athens Solana Devnet
Wallet Connections βœ… βœ… βœ… βœ…
Interact via βœ… βœ… βœ… Coming Soon
Supply βœ… βœ… βœ… βœ…
Borrow βœ… βœ… βœ… βœ…
Withdraw βœ… βœ… βœ… βœ…
Repay βœ… βœ… βœ… βœ…

πŸš€ Getting Started

Prerequisites

Contracts

cd contracts
forge install
forge build
forge test

Frontend

cd frontend
pnpm install
pnpm dev

E2E Tests

cd e2e
npm install
npm test

πŸ‘₯ Contributors

Made with ❀️ by

for the ZetaChain Γ— Google Cloud AI Buildathon πŸš€

About

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •