1delta Unite
Use 1inch limit orders to open margin trades via Aave/Morpho—gasless, composable, no inventory.
Problem Statement
1delta Unite (see also in our readme in the repository)A Limit Order extension for the 1inhc protocol that allows using the orders for defi spot margin trading an lenders like Aave and Morpho Blue.Limit orders for basis trading using 1inchExecute pre-action as composed lending operations.100% Gasless possible for users.Partial fils possibly included.Many lenders supported (Aave, Morpho and Compounds).Triggers possible inpostInteraction.Contract architecture✨ Execution flowthe user defines the order and lending operations (borrow and deposit in our examples)setup for the userthey can decide to deposit the initial margin upfront, but it can also be part of thepreInteraction(they would then only need to permit the deposit action)the borrow delegation needs to be provided (either viapermit(then it is in thepreInteraction) or via simpleapproveDelegationcall)the order and extension action need to be signed (this can be abbreviated, but for simplicity we do it with 2 signatures)the order and extension can be broadcast to fillersFill: A filler can pick it up and define atakerInteractionto fill the orderour settler will flash loan the funds (thetakerAount) from morpho to the settler itself and call teh 1inchfillContractOrderfunctionbeforehand, we extract the signer from the lending operation to validate the signature (we need this to ensure that the correct entity recevies the collateral and debt)we call teh 1inch contract and it execute theisValidSignaturefunctionthe sttlement contract works as contract signer for users (for this cas e only) as it combines signature and expected signer (the signer from the lending operations) to be forwarded for validationthe settler extracts the signer from the signature and matches itMargin:preInteractionis called, in our examples, this is deposit thetakingAmount(here we need the flash loaned funds as the taker has not yet transferred anything), then borrow themakingAmountnote that the interaction now produced the making amount without the user holding themMaker->Takerthe 1inch router can now pull the funds to fill the maker to taker transferTaker fill without inventory:takerInteractionis executed that swaps the received funds (via uniswap V3 in our case) to obtain thetakerAmountthat is pending for flash loan repaymentMaker->Taker: After the filfilment, the 1inch router executes the final token transfer that ensures that the funds indeed were receivedFlash settlement: the amounts received are validated and we refund the excess (amount received from uni V3 minus falsh-repayment amount to the taker defined address) and repay the flash loanThe user now holds a leveraged position in Aave V3 that has bee conditionally opened and the filler fulfilled that order without holding inventory.
Solution
We use Solidity & Yul assembly for smart contracts.Advanced features like flash loans are used (Morpho Blue)Use lending operations and delgations actions from Aave V3 (deposit & borrow on behalf of a user)Use uniswap router as filler option for ordersWe use the 1inch limit order protocol :Dthe flash loan wraps the overall filling process (as we otherwise cannot create the position in one go)we use the lending operations as preInteraction for 1incha takerInteraction is added to allow inventory-free filling using DEXsthat is also where we use Uniswap V3 routing (ofc a proper live version would use the 1inch path-finder swaps here)