Pesto enables users to create independent short and long positions in a single transaction.

Three examples of positions that can be created with Pesto are: (1) a stable short, (2) a spread short, and (3) a stable long.

A stable short position is most similar to traditional short-selling, where users borrow the asset they want to short, and sell it for a stable asset. For example, if you’re bearish on BTC, you could supply USDC as collateral to borrow WBTC, and swap for USDC. If WBTC's value drops, less USDC is required to buy the WBTC to repay the loan. The remaining USDC is profit.

A spread short position is a more complex strategy, where users choose to borrow the asset they want to short, and swap it for a non-stable asset. The aim of such a strategy is to profit from the favorable spread between the short asset and the long asset. For example, if you’re bullish on ETH and bearish on BTC, you could supply USDC as collateral to borrow WBTC, and swap for WETH. This means you could profit from WETH's rise and WBTC's fall.

A stable long position involves borrowing a stable asset and swapping it for a non-stable asset to hold. For example, if you’re bullish on ETH, you could supply WETH as collateral to borrow DAI, and swap for more WETH. If ETH's value rises, you swap it for more DAI than you borrowed, and keep the difference as profit.

The Pesto protocol employs two mechanisms to mitigate liquidation risk across different positions. The first one is the architecture design of Pesto positions. Each Pesto position is an independent smart contract owned by the user. This means that users can have as many different positions as they wish, and the risk from one of their positions does not affect others. The second mechanism is the fact that all the assets backing a particular position are supplied to Aave as collateral, allowing users to earn additional interest and improving the health factor of their position’s loan on Aave.

Users have full freedom to withdraw the assets backing a position from Aave. For example, if users observe opportunities to earn a higher yield elsewhere, they could withdraw some of the collateral backing one of their Pesto positions, without closing the position, and take advantage of said opportunity. 

Furthermore, users can use some of the collateral backing a Pesto position to add leverage to the position. This process can be repeated multiple times, increasing their exposure.

The core Pesto protocol is immutable, operates without governance, and incentivizes decentralized frontends. The Pesto protocol consists of three primary smart contracts: two core and one periphery.

The core contracts are the PositionFactory and the Position contract. The PositionFactory contract is responsible for creating Position contracts. The Position contract represents one position of an individual user. A single user can own multiple Position contracts, each representing a different combination of tokens.

The only periphery contract at present is the FeeCollector contract, which is responsible for collecting and allocating protocol fees. A small protocol fee is charged when users increase a position's size and when they add leverage to a position. A portion of this fee goes to the protocol and another portion is allocated to frontend operators. Frontend operators can also choose to offer users of their frontend a discount on the protocol fee, which incentivizes users to use their frontend.