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:
The validation functionalities of OrderFiller.sol and OrderTaker.sol are now lifted to the Vault and take place alongside the asset balance calculations made for policy management.
All adapters inherit an AdapterBase with common operations. Especially important is the fundAssetsTransferHandler modifier that handles the transfer of approved assets to the adapter, and from the adapter back to the Vault at the end of the call.
Adapters are refactored to implement function calls (i.e., takeOrder) directly once again, rather than the convoluted syntax of OrderTaker.
A MathHelpers.sol util was added to help with finding a missing quantity in two relative fractions (i.e., in an order).
An AddressArrayLib.sol library was added for common operations performed on asset arrays, e.g., checking uniqueness of the array and checking if an item is contained by the array.
"maker/taker" terminology was replaced by "incoming/outgoing" in adapters where makes/takes are not relevant (Kyber/Uniswap)
All non-OasisDex-specific tests using OasisDex were refactored to use more relevant exchanges (Kyber and 0x)
"Maker/taker" terminology was replaced with "incoming/outgoing" in tests where the latter is more relevant
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., theVault
). This allows theVault
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:
OrderFiller.sol
andOrderTaker.sol
are now lifted to the Vault and take place alongside the asset balance calculations made for policy management.AdapterBase
with common operations. Especially important is thefundAssetsTransferHandler
modifier that handles the transfer of approved assets to the adapter, and from the adapter back to theVault
at the end of the call.takeOrder
) directly once again, rather than the convoluted syntax ofOrderTaker
.MathHelpers.sol
util was added to help with finding a missing quantity in two relative fractions (i.e., in an order).AddressArrayLib.sol
library was added for common operations performed on asset arrays, e.g., checking uniqueness of the array and checking if an item is contained by the array.