@mimic-fi/v1-uniswap-connector

0.0.4 • Public • Published

Uniswap Connector

CI npm version

This repository contains an implementation of the Vault's SwapConnector. The SwapConnector is part of the core architecture and is in charge of providing an interface to swap tokens to the Vault. This can be achieved using any type of on-chain exchange, then this repo provides a simple implementation using Uniswap V2.

Deployment

In order to deploy this smart contract locally you can simply do:

import { deploy } from "@mimic-fi/v1-helpers";

const uniswapV2Router = "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D";
const connector = await deploy(
  "@mimic-fi/v1-uniswap-connector/artifacts/contracts/UniswapConnector.sol/UniswapConnector",
  [uniswapV2Router]
);

Development

In order to use a SwapConnector you can simply do:

import "@mimic-fi/v1-vault/contracts/interfaces/ISwapConnector.sol";

contract MyContract {
  ISwapConnector connector;

  function getAmountOut(address tokenIn, address tokenOut, uint256 amountIn)
    external
    returns (uint256)
  {
    return connector.getAmountOut(tokenIn, tokenOut, amountIn);
  }

  function swap(
    address tokenIn,
    address tokenOut,
    uint256 amountIn,
    uint256 minAmountOut,
    uint256 deadline,
    bytes memory data
  ) external {
    return
      connector.swap(tokenIn, tokenOut, amountIn, minAmountOut, deadline, data);
  }
}

Readme

Keywords

none

Package Sidebar

Install

npm i @mimic-fi/v1-uniswap-connector

Weekly Downloads

0

Version

0.0.4

License

GPL-3.0

Unpacked Size

26.7 kB

Total Files

5

Last publish

Collaborators

  • facuspagnuolo
  • lkndjrt2