The idea
Most DeFi actions turn one token into another.- Swapping ETH for USDC on Uniswap turns ETH into USDC.
- Supplying USDC on Aave turns USDC into a token that earns interest.
- Staking ETH on Lido turns ETH into stETH, then wstETH.
Interface
inAssets are the tokens the transaction sends in. payload is whatever the adaptor needs to know, such as a slippage limit. outAssets are the tokens it returns.
How a call runs
- You build a transaction of the adaptor call kind. It names the adaptor, the tokens to send, and the payload. The proof spends your notes.
- The pool checks the proof and releases the tokens to the adaptor handler.
- The handler calls the adaptor with
delegatecall, so the adaptor runs with the handler’s balance. - The adaptor calls the other protocol and returns the output tokens.
- The handler checks each output token is active in the pool and that it holds at least the amount returned. It then lets the pool pull the output.
- The pool creates a note for each output token. The notes belong to the refund address you named in the transaction. A memo on each note lets only you recover its blinding, so only you can spend it. The amounts are public, because the pool builds the commitments from what the adaptor returned.
What an adaptor is
- Stateless. It keeps no balances. It holds immutable addresses of the protocol it talks to.
- Registered. Only the pool owner can register an adaptor. An unregistered adaptor is rejected.
- Limited. The handler accepts only output tokens that are active in the pool and amounts it actually holds.