Git Product home page Git Product logo

uniswap-tutorials's Introduction

Uniswap Tutorials

Create a smart contract that implements a simple token swap using the Uniswap V3 protocol. This DeFi tutorial explores the Uniswap V3 ISwapRouter interface for executing token swaps from Uinswap liquidity pools. Follow along and learn about this important DeFi primitive.

YouTube tutorial video for Uniswap Token Swap tutorial:

https://www.youtube.com/watch?v=GwMyv7CmoRs

LINK (Goerli):

0x326C977E6efc84E512bB9C30f76E30c160eD06FB

WETH (Goerli):

0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6

USDC (Goerli):

0x07865c6E87B9F70255377e024ace6630C1Eaa37F

Uniswap SwapRouter address (Goerli):

0xE592427A0AEce92De3Edee1F18E0157C05861564

SingleSwap.sol deployed (Goerli):

0xBdfCf1e48Fb8E7C66Fd7E0541BF9b1cf67558c49

Deploy contract:

npx hardhat run --network goerli scripts/deploySingleSwap.js

GitHub direct link for Remix:

import "https://github.com/Uniswap/v3-periphery/blob/main/contracts/interfaces/ISwapRouter.sol";

uniswap-tutorials's People

Contributors

jspruance avatar

Stargazers

Vladimir avatar Snizhana Dovha avatar Kıvanç Aydoğmuş avatar  avatar  avatar Stone Gao avatar David Bogunjoko avatar Chia Yong Kang avatar DavidLI avatar Ilya Lavrov avatar  avatar Chengjie Hu avatar José Carlos Marquetti Junior avatar  avatar Anuj Kumar avatar apadanag avatar Vera LaTonya Cobbs avatar  avatar Michal Rakoczy avatar Abdullah Aslam avatar  avatar

Watchers

 avatar  avatar

uniswap-tutorials's Issues

Error while calling swapExactInputSingle()

I deploy the contract at goerli with address :0xD0dA6af343B12225AF803CF157DEF8366ae01d32.
When I try to run this script it gives me the error Error: VM Exception while processing transaction: reverted with reason string 'STF'

const { ethers, run, network } = require("hardhat")

// async main

async function main() {
  
  

  const { deployer } = await getNamedAccounts()
  const account = await ethers.getSigner(deployer)
  console.log(account.address)
  const IRC20 = await ethers.getContractAt(
    "IERC20",
    "0x326C977E6efc84E512bB9C30f76E30c160eD06FB"
    )

    const initBal=await IRC20.balanceOf(deployer)
    console.log(initBal);
    
    const AlphaVaultSwap = await ethers.getContractAt(
      "AlphaVaultSwap",
      "0xD0dA6af343B12225AF803CF157DEF8366ae01d32",
      account
      )
      const txResponse =await AlphaVaultSwap.swapExactInputSingle(100000000)
      await txResponse.wait()
    console.log(IRC20. balanceOf(deployer));
}
// main
main()
  .then(() => process.exit(0))
  .catch((error) => {
    console.error(error)
    process.exit(1)
  })

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.