project screenshot 1
project screenshot 2
project screenshot 3

1delta Unite

Use 1inch limit orders to open margin trades via Aave/Morpho—gasless, composable, no inventory.

1delta Unite

Created At

Unite Defi

Winner of

1inch

1inch - Expand Limit Order Protocol 1st place

Project Description

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 1inch

Execute pre-action as composed lending operations.

100% Gasless possible for users.

Partial fils possibly included.

Many lenders supported (Aave, Morpho and Compounds).

Triggers possible in postInteraction.

Contract architecture

Architecture

✨ Execution flow

  1. the user defines the order and lending operations (borrow and deposit in our examples)
  2. setup for the user
    • they can decide to deposit the initial margin upfront, but it can also be part of the preInteraction (they would then only need to permit the deposit action)
    • the borrow delegation needs to be provided (either via permit (then it is in the preInteraction) or via simple approveDelegation call)
  3. the order and extension action need to be signed (this can be abbreviated, but for simplicity we do it with 2 signatures)
  4. the order and extension can be broadcast to fillers
  5. Fill: A filler can pick it up and define a takerInteraction to fill the order
    • our settler will flash loan the funds (the takerAount) from morpho to the settler itself and call teh 1inch fillContractOrder function
    • beforehand, 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 the isValidSignature function
    • the 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 validation
    • the settler extracts the signer from the signature and matches it
    • Margin: preInteraction is called, in our examples, this is deposit the takingAmount (here we need the flash loaned funds as the taker has not yet transferred anything), then borrow the makingAmount
    • note that the interaction now produced the making amount without the user holding them
    • Maker->Taker the 1inch router can now pull the funds to fill the maker to taker transfer
    • Taker fill without inventory: takerInteraction is executed that swaps the received funds (via uniswap V3 in our case) to obtain the takerAmount that is pending for flash loan repayment
    • Maker->Taker: After the filfilment, the 1inch router executes the final token transfer that ensures that the funds indeed were received
    • Flash 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 loan
  6. The user now holds a leveraged position in Aave V3 that has bee conditionally opened and the filler fulfilled that order without holding inventory.

How it's Made

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 orders

We use the 1inch limit order protocol :D

  • the 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 1inch
  • a takerInteraction is added to allow inventory-free filling using DEXs
  • that is also where we use Uniswap V3 routing (ofc a proper live version would use the 1inch path-finder swaps here)
background image mobile

Join the mailing list

Get the latest news and updates