As a router, I want the ability to borrow additional liquidity from AAVE (offchain side)
Problem
If routers do not have enough liquidity readily available, we want users to still be able to bridge. The contract side is implemented but we don't have code in place to effectively make use of this yet.
Ideas to solve this
Using Aave v3 portals when there is no fast-liquidity available to facilitate a transaction increases the capital efficiency of Amarok as a liquidity layer on top of the nomad message passing infrastructure.
https://github.com/connext/nxtp/issues/1059
Acceptance Criteria
[ ] Where router does not have liquidity, it defaults to checking if AAVE is an option [ ] Only available to allowlisted routers [ ] Positions must be closed when funds are bridged
Other
From #1059
The changes should be isolated to the execute and reconcile function calls.
In execute if there is no fast liquidity available, the function should check a registry to see if (1) there is a corresponding aToken available on the chain and (2) if the given router has permissions to use Aave collateral. If both of these are true, then the router can call mintUnbacked to get an uncollateralized credit line and deliver the adopted asset to the user. Otherwise, the function reverts.
Once the mad assets are delivered by nomad, the contract should swap into the correct adopted asset and repay the loan + interest.
A step-by-step breakdown of this proposal is:
execute
- Check to make sure there is sufficient liquidity
- If there is, proceed with the normal transfer flow
- If there is not, check to see if the router can support Aave liquidity. If the router is not approved for this feature, revert
- Check to see if there is a corresponding
aTokenfor the desired adopted asset. If there is not, revert - Call
mintUnbackedfor an amount equal toprincipal - liquidity fee. Note here that there is not an additional fee because liquidity is being provided by Aave. Instead, the default liquidity fee should be high enough to pay the interest back on the position - Store an indicator that this transfer was supported via credit lines
- Unwrap the delivered
aTokenfor the adopted asset - Proceed with the normal
executeflow (either execute the calldata or send the funds to the user)
reconcile
- Check to see if the transfer was supported via credit lines. If it was not, follow the normal
reconcileflow - If it was, swap into the adopted asset from the
madAsset. If this is not enough, then additional liquidity should be withdrawn to close out the position. - Call
repaywith the underlying asset - Resume with the standard
reconcileflow
Domain Requirements
- Must have Aave deployed
- Must have
Connextlisted as an approvedBRIDGEon deployed Aave - Must have a token registry that connects mad, adopted, and aToken assets
New xcall comes in, can I afford it? If not Given I have access to AAVE portals as a router
- Check what assets are in the Portal (Does it have what I need?)
- Have I hit my limit? (What is my limit?)
Note: How do we display this to the user up front in the UI? Meaning setting expectations around fast vs slow liquidity, fees they will pay, etc

not planned