Output Receiver Overview

The most powerful feature off Revest's composability

This document references documents from the Revest Protocol API

Understanding Output Receivers

An output receiver is an address that tokens are sent to when they are withdrawn from an FNFT. While internally it is referred to as "pipeToContract" in the FNFT Config, for the sake of consistency, this document will solely refer to them as output receivers. At first glance, this may sound rather counter-intuitive: isn't the point of withdrawing from an FNFT that the tokens within are sent to the person who holds the FNFT they are withdrawing from? As we'll see, while that is typically the case, output receivers allow for:

  • Complex handling of received funds, with custom callbacks triggered on contracts implementing IOutputReceiver allowing for piping of funds to arbitrary points, such as executing trades on an AMM and then transferring the exchanged value to the user who originally made the call

  • Contracts to make use of FNFTs that contain no actual value. As we'll see, there are several ways that "null-value" can be implemented to allow the Revest Protocol itself to act solely as the lock provider for external vaults, rather than containing the locked value itself.

  • The storage of additional data about FNFTs within separate contracts and performing operations with that data at the end of an FNFT's lifecycle. This is thanks to each FNFT having a unique ID within its series.

  • Transactional layer (Upcoming V2 only) that allows for an output receiver to swap the contents of any FNFTs pointing towards it to power the complex interactions needed for escrow.

Output receivers are typically contracts that implement the IOutputReceiver interface, generally offer their own entry points for those looking to utilize the Revest protocol, and use the withdrawal function as a trigger for the complex routing behavior needed. Output receivers also offer convenient ways to present on-chain data to users utilizing the Output Receiver Metadata system. This will be discussed in further detail deeper into the documentation.

Properly implemented, output receivers can obviate the need for developers to build a significant portion of frontend themselves and allows them to offload such to Revest's core systems themselves.

Callbacks

The IOutputReceiver interface contains the following function that any contract implementing it must also contain:

function receiveRevestOutput(uint fnftId, address asset, address payable owner, uint quantity ) external;

Within the Revest TokenVault, if the FNFT in question has an output receiver designated (again, with the pipeToContract field), and that FNFT properly implements IOutputReceiver, then during a withdrawal operation, TokenVault will first forward the value contained in the FNFT (if any is present) and will then call this function to inform the output receiver that it may now perform further actions with these funds.

Example: A contract allows users to automatically swap funds to USDC upon withdrawal from an FNFT. A user holds one such FNFT and makes a withdrawal. The Revest TokenVault forwards the value to the output receiver and calls "receiveRevestOutput" on it. The output receiver takes the value passed into it and swaps it on Uniswap for USDC, which it then transfers to the "address payable owner" who made the initial call for token withdrawal.

Last updated