Categorygithub.com/sphantix/go-defi
modulepackage
0.0.0-20241225084627-c909cb5f3c50
Repository: https://github.com/sphantix/go-defi.git
Documentation: pkg.go.dev

# README


A golang sdk for working with DeFi protocols and general utilities for working with ethereum-compatible blockchains.

packages

  • bclient
  • bindings
  • cli
  • config
  • database
  • sushiswap
  • uniswap
  • testenv
  • utils

bclient

Provides a wrapper around the ethclient package

bindings

Provides code generated by abigen for working with smart contracts:

  • bindings/erc20 provides generated code for working with ERC20 contracts
  • bindings/oneinch/v2 provides generated code for working with OneInch V2 router contracts
  • bindings/oneinch/v3 provides generated code for working with OneInch V3 router contracts
  • unicrypt/presalefactory provides generated code for working with UniCrypt presale factories
  • uniswap/* provides generated code for working with Uniswap V2 contracts (note these can also be used for working with the corresponding sushiswap contracts)

cli

cli package

config

configuration management package

database

database management packlage

sushiswap

Wrapper around go-ethereum's ethclient package for using sushiswap v2.

uniswap

Wrapper around go-ethereum's ethclient package for using uniswap v2.

testenv

Provides a wrapper around the SimulatedBackend allowing for an in-memory blockchain. It is particularly useful for local smart contract development, or developing backend dApps.

utils

Provides utility functions including all goethereum book utils, a helper to make bind.TransactOpts safe for concurrent use, as well as a general Blockchain interface that satisfies all functions provided by simulated backend, as well as ethclient which is useful for drop-in replacement of actual RPC clients, and test environments.

examples

transaction matching

$> /go-defi txm --methods transfer --methods transferFrom --methods buy --contract.address 0x5ade7aE8660293F2ebfcEfaba91d141d72d221e8

abi generation

install abigen

$> go install github.com/ethereum/go-ethereum/cmd/abigen@latest

generate bindings

$> abigen --abi=./abi/pancake/v2pair.min.abi --pkg=pancakev2pair --out=v2pair.go --type=Pancakev2pair

# Packages

Package bclient provides a wrapper around go-ethereum's ethclient package.
No description provided by the author
Package cli provides a base cli package.
Package config provides a flexible configuration management type, allowing for the usage of YAML files or environment variables.
Package database provides a wrapper around the gorm package providing convenience functions around database management, model creation, etc..
No description provided by the author
No description provided by the author
Package sushiswap contains the required bindings as well as corresponding wrappers for those bindings for interacting with the sushiswap smart contracts.
No description provided by the author
Package txmatch provides a flexible method of filtering transactions to check for ones matching a particular abi method.
Package uniswap contains the required bindings as well as corresponding wrappers for those bindings for interacting with the uniswap smart contracts.
No description provided by the author
Package utils provides a set of interfaces, helper functions, and authentication management helpers.

# Variables

Version denotes the compile time build version.