Set Documentation

Creating a Perpetual Leverage Token

This page presents a sample guide on how to deploy a leverage token that uses Perp V2 on Optimism as the underlying source of leverage. Deploying the strategy will require technical knowledge on deploying smart contract instances. No Solidity coding is required if deployed as-is
Perpetuals and leveraged products come with additional risk of liquidation. Therefore, asset managers should be aware of choosing suitable parameters

Creating the SetToken

  1. 1.
    Perp V2 is a perpetual protocol built on Optimism that utilizes USDC as the margin asset. To learn more about Perp, navigate to their site here
  2. 2.
    The first step to deploying your own leverage token is to create the SetToken which will custody perp positions and help you accept capital. Follow the guide in this section to create using the TokenSets UI.
  3. 3.
    1. 1.
      As Perp is USDC margined, we recommend creating the SetToken in 100% USDC to make it simple to initialize perp positions. Fill the component with the USDC address and units with the price of the Set you want to start with. USDC contains 6 decimals so 10000000 = 100 USDC = $100 Set price
    2. 2.
      Modules should include the PerpV2LeverageModule (functionality for trading using perp) and SlippageIssuanceModule (functionality for issuing Sets with perp positions) at a minimum. If you want to charge streaming fees, you may also choose to enable the StreamingFeeModule
    3. 3.
      Set the manager address to your own deployer for now. This will be updated to the BaseManager later on

Deploy Strategies

  1. 1.
    Get started with Set V2 Strategies Deployments repo here
  2. 2.
    At a minimum, to set up a Perp leverage token, must deploy the BaseManager and PerpV2LeverageStrategy contract. Check out an example deploy script for an ETH2x token here.
  3. 3.
    Below are Parameters that are passed in during deployment that vary depending on your asset and parameters
Set token address
Address of operator which typically executes manager only functions on Set Protocol modulesAddress of operator which typically executes manager only functions on Set Protocol modules
Address of methodologist which serves as providing methodology for the indexAddress of methodologist which serves as providing methodology for the index
Base manager address
Struct of contract settings. See below
Struct of methodology settings. See below
Struct of execution settings. See below
Struct of incentive settings. See below
Struct of exchange settings. See below
struct ContractSettings {
ISetToken setToken; // Instance of leverage token
IPerpV2LeverageModule perpV2LeverageModule; // Instance of Perp V2 leverage module
IAccountBalance perpV2AccountBalance; // Instance of Perp V2 AccountBalance contract used to fetch position balances
IChainlinkAggregatorV3 basePriceOracle; // Chainlink oracle feed that returns prices in 8 decimals for base asset
IChainlinkAggregatorV3 quotePriceOracle; // Chainlink oracle feed that returns prices in 8 decimals for quote asset
address virtualBaseAddress; // Address of virtual base asset (e.g. vETH, vWBTC etc)
address virtualQuoteAddress; // Address of virtual USDC quote asset. The Perp V2 system uses USDC for all markets
struct MethodologySettings {
int256 targetLeverageRatio; // Long term target ratio in precise units (10e18). For short tokens target ratio is negative.
// E.g. 2e18 for ETH 2x and -2e18 for ETH -2x.
int256 minLeverageRatio; // For both long and short tokens, if magnitude of current leverage is lower, rebalance target is
// this ratio. In precise units (10e18). E.g. 1.7e17 for ETH 2x and -1.7e17 for ETH -1x.
int256 maxLeverageRatio; // For both long and short tokens, if magniutde of current leverage is higher, rebalance target is
// this ratio. In precise units (10e18). E.g. 1.7e17 for ETH 2x and -1.7e17 for ETH -1x.
uint256 recenteringSpeed; // % at which to rebalance back to target leverage in precise units (10e18). Always a positive number
uint256 rebalanceInterval; // Period of time required since last rebalance timestamp in seconds
struct ExecutionSettings {
uint256 slippageTolerance; // % in precise units to price min token receive amount from trade quantities
uint256 twapCooldownPeriod; // Cooldown period required since last trade timestamp in seconds
struct IncentiveSettings {
uint256 etherReward; // ETH reward for incentivized rebalances
int256 incentivizedLeverageRatio; // Leverage ratio for incentivized rebalances. For long tokens, this is a positive number higher than
// maxLeverageRatio. For short tokens, this is a negative number lower than maxLeverageRatio
uint256 incentivizedSlippageTolerance; // Slippage tolerance percentage for incentivized rebalances
uint256 incentivizedTwapCooldownPeriod; // TWAP cooldown in seconds for incentivized rebalances
struct ExchangeSettings {
uint256 twapMaxTradeSize; // Max trade size in base assset base units. Always a positive number
uint256 incentivizedTwapMaxTradeSize; // Max trade size for incentivized rebalances in base asset units. Always a positive number

Depositing a Set's USDC as collateral

After creating a new SetToken with 100% USDC as a default position, you can now deposit that USDC into a new account in Perpetual Protocol by using the PerpV2LeverageModule (see the deposit function in the contract docs).
After successfully depositing collateral into the Perp account, you are now able to open your desired vAsset positions that your SetToken will represent, using the trade function.

Engaging/Levering up the Set

Note: this is only possible if you have enabled the Strategy Extension to your BaseManager.
Engaging is defined as "levering" up a Set for the very first time. This step is required during the Set creation process to prepare the leverage ratios that are declared in the strategy.
Once you call the engage function in the Strategy Extension contract, the Set will be "engaged" to the Target Leverage Ratio. If the Set still returns a nonzero answer for the shouldRebalance getter (aka the SetToken still needs to be rebalanced) you can continue to call the engage function until the Set does not need to be rebalanced anymore.

Configuring a Perpetual Leverage Token's Manager Contracts

In other guides in the developer directory, you'll learn what configurations are available to help build your perfect Set. Perpetual Leverage Tokens can be configured just like an ordinary Set, meaning the following adapter contracts can be deployed to assist your Set:
  • A FeeSplit Extension contract to specify how the streaming, issuance and redemption fees which accumulate for the token should be split.
When building Perpetual Leverage Tokens, the PerpV2LeverageStrategyExtension is the most important contract to deploy.
  • The Strategy Extension contract describes operational parameters such as what leverage ratio the token should target and what incentives bots or other market participants have to keep the token operating close to an ideal leverage ratio under all market conditions.