ExternalPositionProxy
is deployed by a persistent ExternalPositionFactory
, which serves as an enduring registry of external position "types" (e.g., Compound CDP) and all valid ExternalPositionProxy
instances (i.e., those created via the factory).ExternalPositionProxy
is deployed with a VaultProxy
as its owner.ExternalPositionProxy
fetches its library via a getExternalPositionType()
callback to its VaultProxy
.ExternalPositionProxy
should pass through a protected receiveCallFromVault()
, guaranteeing the call passed through the owning VaultProxy
.ExternalPositionManagerActions
on the ExternalPositionManager
extension:CreateExternalPosition
-- create (deploy) a new external position and activate it on the VaultProxy
CallOnExternalPosition
-- make allowed arbitrary calls to interact with the external position, and transfer assets to / from the VaultProxy
RemoveExternalPosition
-- deactivate an external position from the VaultProxy
ReactivateExternalPosition
-- reactivate an existing external position on the VaultProxy
ExternalPositionManager
stores two updatable reference contracts per external position type, which contain all logic specific to that type:lib
is the target library of the beacon ExternalPositionProxy
, and contains the business logic for its local accounting and interactions with external protocolsparser
is a contract used by the ExternalPositionManager
to validate and parse call data for each specific action on its external position typeExternalPositionManager
's CallOnExternalPosition
action via ComptrollerProxy.callOnExtension()
with the desired payload to add 100 cDAI as collateralExternalPositionManager
looks up its stored CompoundDebtPositionParser
and forwards it the payloadCompoundDebtPositionParser
validates the call, e.g., that cDAI is a valid cTokenCompoundDebtPositionParser
formats the outgoing 100 cDAI into assetsToTransfer
and amountsToTransfer
arrays, which it returns to the ExternalPositionManager
ExternalPositionManager
passes the payload along with the data for assets to transfer (100 cDAI) and to receive (none) to the VaultProxy
VaultProxy
transfers 100 cDAI to the target ExternalPositionProxy
VaultProxy
calls ExternalPositionProxy.receiveCallFromVault()
, passing in the payloadExternalPositionProxy
calls back to the VaultProxy
for the library to use for its type (Compound CDP), which it pulls from the ExternalPositionManager
ExternalPositionProxy
uses the returned CompoundDebtPositionLib
to parse and execute the AddCollateralAssets
action, adding cDAI to its internal accounting of its managed assets and interacting with Compound to use cDAI as collateral as needed.