Skip to content

Interactive adapters

Igor Sobolev edited this page Mar 24, 2020 · 7 revisions

In this section, further plans are described.

Table of Contents

Planned architecture

  • InteractiveAdapter is a special contract for every protocol. Its main purpose is to wrap all the protocol interactions, namely "withdraw" and "deposit". Withdraw is the action when tokens are transferred from the protocol (withdraw deposit, borrow debt, use flash loan). Deposit is the action when tokens are transferred to the protocol (lend tokens, repay debt, return flash loan).
  • Logic contract is the main contract for all the interactions. It checks signatures, transfers tokens via TokenSpender, and interacts with the protocols.
  • TokenSpender is the contract holding all the tokens' approvals. Logic contract calls it after signature verification.

Logic

  1. (optional) Verifies the supplied signature and extracts the address of spender from it.
  2. Iterates over array of actions, checks adapter in AdapterRegistry, and delegatecalls corresponding InteractiveAdapter with assets, amounts, and additional data as arguments (deposit, or withdraw).
  3. Returns all the resulting tokens back to the account.
function executeActions(Action[] actions) payable
function executeActions(Action[] actions, Approval[] approvals, bytes signature) payable

TokenSpender

Sends all the assets under the request of Logic contract. Adds all the transferred assets to the list of resulting tokens.

function transferApprovedAssets(Approval[] approvals) external returns (address[])

InteractiveAdapter is ProtocolAdapter (interface)

Interface for protocol wrappers. Includes all the functions required to be implemented. Should be stateless. Only internal constant state variables may be used.

Functions


deposit(address, uint256, bytes) payable returns (address[])

Deposits assets to the lending/borrow/swap/liquidity. MUST return addresses of the assets sent back to the msg.sender.


withdraw(address, uint256, bytes) payable returns (address[])

Withdraws assets from the lending/borrow/liquidity. MUST return addresses of the assets sent back to the msg.sender.