sewinter / yak-aggregator

Onchain dex aggregator for Avalanche

Home Page:https://yieldyak.com/swap

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

🐃 YY Swap

Dex aggregator for Avalanche. Use at your own risk.

UI available from https://yieldyak.com/swap

Overview

The Avalanche C-Chain is saturated with 10+ exchanges competing ~200M of liquidity. This creates the following issues for traders:

  • Split liquidity: Traders are more likely to get affected by price impact and negative slippage since liquidity is split across many exchanges.
  • Disconnected assets: Traders need to approve and swap on multiple platforms to swap between certain assets in the Avalanche ecosystem.
  • No simple way to determine best price for swap: With all the options there is no clear way of knowing which exchange will offer the best price for a particular trade.

How it works

YY Swap solves these problems by finding and executing the most profitable trades for users.

  • Multi-path trades (e.g. Pangolin > Gondola > Zero)
  • Gas-cost considerations
  • Easy to build on top of

Mainnet Deployments and Supported Platforms

Routers

YakRouter is the user-facing interface to check prices and make trades.

Name Address
YakRouter 0xC4729E56b831d74bBc18797e0e17A295fA77488c

Query

Query YakRouter for the best trade execution.

Parameters

  • amountIn[BigNumber]: Amount of tokens being sold
  • tokenIn[String]: ERC20 token being sold (pass WAVAX address for AVAX)
  • tokenOut[String]: ERC20 token being bought (pass WAVAX address for AVAX)
  • steps[BigNumber]: Number of steps within which best path will be searched (max is 4)
  • gasPrice[BigNumber]: Gas price in gwei (should be 225 GWEI now, but is planned be dynamic in the future)
findBestPathWithGas
router.findBestPathWithGas(
    amountIn, 
    tokenIn, 
    tokenOut, 
    steps, 
    gasPrice
)

Swap

Swap YakRouter to execute a trade.

Parameters

  • trade[Array]: Array of paramters used for swapping
    • amountIn[BigNumber]: Amount of tokens being sold
    • amountOut[BigNumber]: Minimum amount of tokens bought
    • path[Array]: Tokens being traded (in respective order)
    • adapters[Array]: Adapters through which tokens will be traded (in respective order)
  • to[String]: Address where output tokens should be sent to
  • fee[BigNumber]: Optional fee in bps taken before the trades
swapNoSplit
router.swapNoSplit(trade, to, fee)
swapNoSplitToAVAX
router.swapNoSplitToAVAX(trade, to, fee);
swapNoSplitFromAVAX
router.swapNoSplitFromAVAX(trade, to, fee, { value: amountIn });

Adapters

Adapters act as a common interface for YakRouter to interact with external contracts.

Adapters must offer methods: query and swap.

Local Development and testing

Install Dependencies

yarn install

Set Environmental Variables

cp .env.sample > .env
  • AVALANCHE_FORK_RPC is Avalanche C-Chain RPC provider that will be used for the tests [ testing ]
  • AVALANCHE_DEPLOY_RPC is Avalanche C-Chain RPC provider that will be used deployment [ deployment ]
  • PK_DEPLOYER is private-key for the account that will deploy contracts [ deployment ]

Actions

Test

npx hardhat test {path to the test/tests | empty to run all}

Deploy

npx hardhat deploy --network {your network tag}

Verify

npx hardhat verifyContract --deployment-file-path {path to deployment file} --network {your network tag}

Audits and Security

This project is in alpha stage and is unaudited. Use at your own risk. Report bugs to Telegram admins


Project is licensed under GPL-3, although some parts of it might be less restrictive. Copyright© 2021 Yield Yak

About

Onchain dex aggregator for Avalanche

https://yieldyak.com/swap

License:GNU General Public License v3.0


Languages

Language:JavaScript 57.6%Language:Solidity 42.4%Language:Shell 0.0%