xPYT is a permissionless vault framework for auto-compounding the yield earned by Timeless perpetual yield tokens (PYT) into more PYT. It is introduced for two reasons:
- Makes it easier to build yield-leveraging strategies.
- xPYT has better composability with other protocols that don't expect to claim the yield earned by PYT. (e.g. Rari Fuse, Uniswap, cross-chain bridges) If raw PYT is used instead of xPYT in contracts without Timeless support, the yield accrued to the contract will be lost, so xPYT should be used instead.
xPYT has the following features:
- Permissionless deployment: Anyone can use the
xPYTFactory
contract to deploy xPYT vaults. - Permissionless auto-compounding: Rather than relying on centralized strategists/harvesters to perform the auto-compounding, xPYT makes the auto-compounding executable by anyone, and the caller would receive a portion of the claimed yield as reward. This means xPYT vaults can rely on MEV bots to perform the auto-compounding, rather than having to build out centralized infrastructure.
- Minimal sandwiching losses: xPYT uses a TWAP oracle to make sure that when it auto-compounds yield into PYT the price it gets doesn't deviate too much from the TWAP, minimizing losses from sandwiching attacks.
xPYT.sol
: Permissionless auto-compounding vault for Timeless perpetual yield tokensuniswap-v3/
: Uniswap V3 supportUniswapV3xPYT.sol
: xPYT implementation using Uniswap V3 to swap NYT into PYTUniswapV3xPYTFactory.sol
: Factory for deploying UniswapV3xPYT contractslib/
: Libraries usedPoolAddress.sol
: Provides functions for deriving a Uniswap V3 pool address from the factory, tokens, and the feeOracleLibrary.sol
: Provides functions to integrate with V3 pool oracleTickMath.sol
: Math library for computing sqrt prices from ticks and vice versa
curve-v2/
: Curve v2 supportCurveV2xPYT.sol
: xPYT implementation using Curve V2 to swap NYT into PYTCurveV2xPYTFactory.sol
: Factory for deploying CurveV2xPYT contracts
To install with DappTools:
dapp install timeless-fi/xPYT
To install with Foundry:
forge install timeless-fi/xPYT
This project uses Foundry as the development framework.
make install
make build
make test
Since calling pound()
is (intentionally) permissionless, an attacker can sandwich attack the swap that occurs during the call to extract profit. Realistically it's not a problem since the amount of yield being compounded is usually small (on the same order of magnitude as the gas cost).