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

StakedToken

Git Source

Inherits: ERC4626

Title: StakedToken

ERC4626 vault for staking plDXY-BEAR or plDXY-BULL tokens.

Used as Morpho collateral. Exchange rate increases via yield donations. Implements 1000x virtual share offset to prevent inflation attacks.

Functions

constructor

Creates a new staking vault for a synthetic token.

constructor(
    IERC20 _asset,
    string memory _name,
    string memory _symbol
) ERC4626(_asset) ERC20(_name, _symbol);

Parameters

NameTypeDescription
_assetIERC20The underlying plDXY token to stake (plDXY-BEAR or plDXY-BULL).
_namestringVault share name (e.g., “Staked plDXY-BEAR”).
_symbolstringVault share symbol (e.g., “splDXY-BEAR”).

donateYield

Allows anyone to inject yield into the vault.

Increases the share price for all stakers immediately.

function donateYield(
    uint256 amount
) external;

Parameters

NameTypeDescription
amountuint256The amount of underlying tokens to donate

depositWithPermit

Deposit assets with a permit signature (gasless approval).

Combines EIP-2612 permit with ERC-4626 deposit in a single transaction.

function depositWithPermit(
    uint256 assets,
    address receiver,
    uint256 deadline,
    uint8 v,
    bytes32 r,
    bytes32 s
) external returns (uint256 shares);

Parameters

NameTypeDescription
assetsuint256Amount of underlying tokens to deposit
receiveraddressAddress to receive the vault shares
deadlineuint256Permit signature expiration timestamp
vuint8Signature recovery byte
rbytes32Signature r component
sbytes32Signature s component

Returns

NameTypeDescription
sharesuint256Amount of vault shares minted

_decimalsOffset

Virtual share offset (10^3 = 1000x) to prevent inflation attacks.

function _decimalsOffset() internal pure override returns (uint8);