Module Factory

The Module Factory is a contract that allows Account owners to install and manage Abstract Modules for their Account. You can install modules by interacting with the Account directly, i.e. via CLI, or by using the Account Console.

To recap from that chapter, there are three types of modules: App, Adapter, and Standalone.

Flow Diagrams

Install Module

When a developer requests the installation of a module, the following internal process is initiated:

RegistryModule FactoryAccountRegistryModule FactoryAccountalt[adapter][app /standalone]OwnerInstallModule1InstallModule2Query reference3Return address4Return code_id5Instantiate module6Register module address7Update module allowlist8Owner
Installation of a module

Execute on Module

Once the module is installed, there are essentially three ways to interact with it depending on the type of module:

Owner Execution

The owner of an Account can always execute on the module directly, even if the module is installed on a sub-account.

Module ("addr123")Module ("addr123")ModuleMsgOwnerExecute1Owner
Module Execution

Adapter Execution

In the following example, the abstract:dex module is installed on an Account and the user requests a swap on a dex. This swap will use the funds held in the Account to execute the swap on the target dex.

Dex PoolAccountabstract:dexDex PoolAccountabstract:dexDex::Swap {account: "juno1xd..."}DexMsgDexMsgOwnerCall module1Resolve asset names2Asset infos3Resolve dex pool4Pool metadata5Build swap msg for target dex6Forward execution7Execute8Owner
Adapter Execution

App Execution w/ Dependencies

In this example, we use Equilibrium’s Rebalance permissionless function as an example. Modules with dependencies (equilibrium:balancer is dependent on abstract:etf and abstract:dex) have their addresses dynamically resolved when called.

Target Dexabstract:dexAccountequilibrium:balancerTarget Dexabstract:dexAccountequilibrium:balancerDexMsgDexMsgUserRebalance1Query Allocations (Oracle)2Allocations3Calculate rebalancing requirements4Query abstract:dex address5Address6Call SwapRouter on dex7Build swap msg for target dex8Load account address9Forward execution10Execute11User
Dependent Execution