Description

The project uses 1inch exchange and aave flashloans and credit delegation to create leveraged positions on behalf of a user and to use the resulting liquidity to trade using 1inch limit order protocol. A usage of 1inch limit order protocol predicate feature together with Chainlink allows 1inch limit order protocol automatically close margin positions. An example: 1. User has $1k USDC in his wallet 2. User creates 1inch limit order with stop loss: 80%, take profit: 100% predicates and sends it to 1inch limit order protocol contract. These predicates are just a functions inside SolarisMargin contract that use Chainlink to get the current price of WETH. 3. User opens 3x long USDT position against WETH. Also user should approve credit delegation and collateral atokens transfer for the SolarisMarginContract a) SolarisMargin contract takes flashloan $2k USDC onBehalf of a user b) SolarisMargin exchanges $3k USDC to $3k WETH on 1inch.exchange c) SolarisMargin deposits $3k WETH to Aaave and borrows $2k USDC from Aave on behalf of a user d) SolarisMargin repays $2k USDC flashloan + fees 4. Order is filled by 1inch contract when stop loss or take profit predicate is true: - takerAmount is sent to SolarisMargin contract - callback function is executed. Inside callback the leveraged position is closed and profit is transferred to a user - makerAmount is sent to a taker

Solaris showcase

How it's made

First of all we learned how to create limit orders in which a maker is a smart contract. The next step was to learn how to create a leveraged position on behalf of a user using Aave And the final step was to implement a function that checks stop loss/take profit predicates using Chainlink oracles Also we wanted to use Compound and 88mph as liquidity sources and add more price feeds from Tellor or Uniswap v3 but haven't enough time. So it will be the next step for us.

Technologies used

1inchAaveChainlinkEthereumHardhatInfuraPolygonscaffold-ethSolidityTruffle