Code Monkey home page Code Monkey logo

1inch-trading-bot's Introduction

1inch-trading-bot

Trading bot on multichain using 1inch api
This bot can be used to swap from One Crypto Asset to Another using 1inch Exchange

1inchApiV5 support chain list:

Eth         Network = "eth"
Bsc         Network = "bsc"
Matic       Network = "matic"
Optimism    Network = "optimism"
Arbitrum    Network = "arbitrum"
GnosisChain Network = "gnosis"
Avalanche   Network = "avalanche"
Fantom      Network = "fantom"
Klaytn      Network = "klaytn"
Auror       Network = "auror"

Usage:

  1. Clone the repo
git clone https://github.com/jerrychan807/1inch-trading-bot.git
  1. Install go packages
go mod tidy
  1. Edit Swap paramters in main.go
  • network: Network to use (matic, bsc, eth...)
  • privateKey: Private Key of the account to use
  • tokenAddr : Contract Address of Token to swap FROM
  • toTokenAddress : Contract Address of Token to swap TO
  • amount : Amount of Token to swap(Ethers)
  • slippage : Slippage in percentage

Example Swap 0.5 USDC to USDT

network := "matic"
rpcUrl := "https://polygon-rpc.com"
privateKey := "1ccxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx04"
tokenAddr := "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174" // USDC
toTokenAddr := "0xc2132D05D31c914a87C6611C10748AEb04B58e8F" // USDT
amount := 0.5
slippage := 1
  1. run
go run main.go

Log:

time="2023-02-15T14:35:24+08:00" level=info msg="Try to Get TokenDecimals"
time="2023-02-15T14:35:25+08:00" level=info msg=amountInWei amountInWei=500000 amountInWeiStr=500000 usedTokenDecimals=6
time="2023-02-15T14:35:26+08:00" level=info msg="Allowance for 1inchRouter" Allowance=0
time="2023-02-15T14:35:26+08:00" level=info walletAddr=0x302c98exxxxxxxxxxxxxx45438C8
time="2023-02-15T14:35:27+08:00" level=info Data=0x095ea7b30000000000000000000000001111111254eeb25477b68fb85ed929f73a960582ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff ToAddr=0x2791bca1f2de4661ed88a30c99a7a9449aa84174
time="2023-02-15T14:35:34+08:00" level=info msg="approveTxHash Successfully" approveTxHash=0x4cb48264721926738bc847dbba2eb9e762ffba2178b6e4535af6596356df95c8
time="2023-02-15T14:35:34+08:00" level=info walletAddr=0x302cxxxxxxxxxxxxxxxxxxx45438C8
time="2023-02-15T14:35:42+08:00" level=info msg="swapTxHash Successfully" swapTxHash=0x9754ac23dbe6020157a68a270580b8929db8d791d2dc13d4d794b97bdf15c518

20230215145054

Refs:

1inch-trading-bot's People

Contributors

jerrychan807 avatar

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.