project screenshot 1
project screenshot 2
project screenshot 3

All Weather Protocol

It's a crypto index fund, which integrates 1inch to zap in into sushiswap pool

All Weather Protocol

Created At

ETHGlobal Paris

Winner of

🏊 Neon EVM — Pool Prize

Project Description

This project can save LP's time to zap in.

When it comes to provide liquidity to AMM like sushiswap, you need 2 steps:

  1. find the best quotes across every AMM to swap
  2. provide swapped tokens into pool as liquidity

This project provide 1-click transaction to do those 2 steps.

In the future, I would integrate more protocols for this 1-click zap-in function.

How it's Made

Actually it's pretty simple, just put 1inch swap function + sushiswap provide liquidity

function in a single function. That's it. function _zapIn( uint256 amount, bytes calldata oneInchData ) internal override returns (uint256) { SafeERC20.safeApprove( weth, oneInchAggregatorAddress, Math.mulDiv(amount, 1, 2) ); // TODO(david): should return those token left after addLiquidityETH back to user // recurring error: "Error: VM Exception while processing transaction: reverted with reason string '1inch failed to swap'" (bool succ, bytes memory data) = address(oneInchAggregatorAddress).call( oneInchData ); require(succ, "1inch failed to swap"); // (uint256 dpxReturnedAmount, uint256 gasLeft) = abi.decode(data, (uint256, uint256)); uint256 dpxReturnedAmount = dpxToken.balanceOf(address(this)); SafeERC20.safeApprove(dpxToken, sushiSwapRouterAddress, dpxReturnedAmount); weth.withdraw(Math.mulDiv(amount, 1, 2)); // deadline means current time + 5 minutes; uint256 deadline = block.timestamp + 300; (uint amountToken, uint amountETH, uint liquidity) = IUniswapV2Router01( sushiSwapRouterAddress ).addLiquidityETH{value: address(this).balance}( address(dpxToken), dpxReturnedAmount, Math.mulDiv(dpxReturnedAmount, 95, 100), Math.mulDiv(address(this).balance, 95, 100), address(this), deadline ); IERC20(sushiSwapDpxLpTokenAddress).approve( address(sushiSwapMiniChef), liquidity ); sushiSwapMiniChef.deposit(pid, liquidity, address(this)); return liquidity; } ``

background image mobile

Join the mailing list

Get the latest news and updates