enzymefinance / protocol

Enzyme Protocol Implementation
https://enzyme.finance
GNU General Public License v3.0
375 stars 156 forks source link

refactor: externalize integration adapters and combine asset validation into callOnIntegration #1003

Closed SeanJCasey closed 4 years ago

SeanJCasey commented 4 years ago

This PR changes the way adapters work by having the Vault call them via a low-level .call() rather than .delegatecall(). This has the affect of adapter functions being called within their own contract context, rather than the context of the caller (i.e., the Vault). This allows the Vault to treat adapters in a less trusted manner, as adapters no longer have direct access to manipulate its storage, and the Vault specifies which and how much asset to approve the adapter to use in each action (though these amounts are currently specified by the adapter, so it can still ask for whatever assets it wants to use).

A few other tasks and changes were made during this refactor:

SeanJCasey commented 4 years ago

@fubhy I made the refactor that we discussed: passing the parsed assets to transfer as an encoded arg to _adapter.call()