Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Apyx

Website · App · Docs · Contract Natspec


Apyx is the first dividend-backed stablecoin protocol, transforming preferred equity issued by Digital Asset Treasuries (DATs) into programmable, high-yield digital dollars. By bundling diversified preferred shares and leveraging protocol functionality, Apyx offers sustained double-digit yield with unprecedented transparency.

apxUSD is a synthetic dollar backed by DAT preferred shares, serving as the protocol's primary liquidity layer. apyUSD is the yield-bearing savings wrapper, accruing yield from the dividends paid by the underlying collateral.

Documentation

Contract Addresses (Ethereum Mainnet)


X · Discord · Telegram · GitHub · Reddit · LinkedIn

Overview

The Apyx protocol consists of multiple interconnected contracts that enable stablecoin minting, yield distribution, and token locking mechanisms.

ContractDescription
ApxUSDThe base ERC-20 stablecoin with supply cap, pause, and freeze functionality. Implements EIP-2612 permit for gasless approvals and uses the UUPS upgradeable pattern.
ApyUSDAn ERC-4626 yield-bearing vault that wraps apxUSD, allowing deposits to accrue yield from vesting distributions.
CommitTokenAn async redeem vault inspired by ERC-7540 with a configurable cooldown period for unlocking. Implements deny list checking and can lock arbitrary ERC-20 tokens for use in off-chain points systems. See ERC-7540 note below.
UnlockTokenA CommitToken subclass that allows a vault to initiate redeem requests on behalf of users, enabling automated withdrawal flows. See ERC-7540 note below.
MinterV0Handles apxUSD minting via EIP-712 signed orders with rate limiting and AccessManager integration for delayed execution.
LinearVestV0A linear vesting contract that gradually releases yield to the vault over a configurable period.
YieldDistributorReceives minting fees and deposits them to the vesting contract for gradual distribution.
AddressListProvides centralized deny list management for compliance across all Apyx contracts.

Architecture

The Apyx protocol consists of several interconnected systems. The following diagrams illustrate the key relationships and flows:

Minting Flow

A signed EIP-712 order must be submitted by a "Minter" (an m-of-n wallet). The MinterV0 contract validates the order and mints apxUSD after AccessManager delays. The beneficiary must be checked against the AddressList before minting completes.

flowchart TB
    User[User] -->|"signs EIP-712 order"| Minter["Minter (m-of-n wallet)"]
    Minter -->|"submits order"| MinterV0
    MinterV0 -->|"checks role + delay"| AccessManager
    MinterV0 -->|"checks beneficiary"| AddressList
    MinterV0 -->|"mint()"| ApxUSD
    AccessManager -.->|"manages mint permissions"| ApxUSD

Token Relationships

ApyUSD is an ERC-4626 vault that wraps apxUSD for yield-bearing deposits. Withdrawing from ApyUSD transfers the ApxUSD to the UnlockToken. The UnlockToken implements an async redemption flow inspired by ERC-7540. The UnlockToken allows ApyUSD to initiate redeem requests on behalf of users to start the unlocking period.

flowchart TB
    ApxUSD[ApxUSD - ERC-20 Stablecoin]
    ApyUSD[ApyUSD - ERC-4626 Vault]
    UnlockToken[UnlockToken - Vault-Initiated Redeems]
    AddressList[AddressList - Deny List]
    AccessManager[AccessManager]
    
    ApyUSD -->|"deposit/withdraw"| ApxUSD
    ApyUSD -->|"initiates redeems"| UnlockToken
    ApyUSD -->|"checks transfers"| AddressList
    UnlockToken -->|"checks transfers"| AddressList
    AccessManager -.->|"manages admin functions"| ApyUSD

Yield Distribution

When the underlying offchain collateral (preferred shares) pay dividends the dividends are minted as apxUSD to YieldDistributor. The YieldDistributor sits between the MinterV0 and the LinearVestV0 to decouple the two contracts and allows a yield operator to trigger deposits into the vesting contract.

flowchart TB
    MinterV0 -->|"fees on mint"| YieldDistributor
    YieldDistributor -->|"depositYield()"| LinearVestV0
    LinearVestV0 -->|"pullVestedYield()"| ApyUSD
    ApyUSD -->|"increases share value"| Depositors

Lock Tokens for Points

CommitToken is a standalone vault that locks any ERC-20 token with a configurable unlocking period. Users deposit tokens to receive non-transferable lock tokens, which can be used for off-chain points systems.

flowchart TB
    User -->|"deposit(assets)"| CommitToken
    CommitToken -->|"mints shares"| User
    User -->|"requestRedeem(shares)"| CommitToken
    CommitToken -->|"starts cooldown"| CooldownPeriod[Cooldown Period]
    CooldownPeriod -->|"after delay"| User
    User -->|"redeem()"| Assets[Original Assets]

ERC-7540 Note

CommitToken and UnlockToken implement a custom async redemption flow inspired by ERC-7540, but are NOT compliant with the ERC-7540 specification. They deviate from MUST requirements including: shares not removed from owner on request, preview functions not reverting, operator functionality not supported, and ERC-7575 share() method not implemented.

Installation

This project uses Foundry and Soldeer for dependency management.

# Clone the repository
git clone <repo-url>
cd evm-contracts

# Install dependencies
forge soldeer install

Development

Build

forge build

Or using the Justfile:

just build

Test

Run all tests:

forge test

Run with gas reporting:

forge test --gas-report
# or
just test-gas

Run with verbose output:

forge test -vvv

Code Coverage

forge coverage
# or
just coverage

Format Code

forge fmt
# or
just fmt

Testing

The test suite is organized in the test/ directory with the following structure:

  • test/contracts/ - Tests organized by contract (ApxUSD, ApyUSD, CommitToken, MinterV0, Vesting, YieldDistributor)
  • test/exts/ - Extension tests (ERC20FreezeableUpgradable)
  • test/mocks/ - Mock contracts for testing
  • test/utils/ - Test utilities (VmExt, Formatter, Errors)
  • test/reports/ - Report (csv) generation tests

Each contract subdirectory contains a BaseTest.sol with shared setup and individual test files for specific functionality.

Dependencies

Resources