Skip to content

Commit

Permalink
Merge pull request #3 from bonedaddy/misc
Browse files Browse the repository at this point in the history
cleanup code, update docs
  • Loading branch information
bonedaddy authored Mar 21, 2021
2 parents f31e9a1 + a8b1486 commit c2337d2
Show file tree
Hide file tree
Showing 8 changed files with 228 additions and 14 deletions.
37 changes: 36 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
# go-defi

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

# packages

* cli
* config
* database
* sushiswap
* uniswap
* testenv
* utils

## 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.

10 changes: 10 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,18 @@ module github.com/bonedaddy/go-defi
go 1.15

require (
github.com/bonedaddy/go-indexed v0.0.23
github.com/ethereum/go-ethereum v1.10.1
github.com/pkg/errors v0.8.1
github.com/shopspring/decimal v1.2.0
github.com/stretchr/testify v1.7.0
github.com/urfave/cli/v2 v2.3.0
github.com/vrischmann/envconfig v1.3.1-0.20201228145200-1b7b4cd0c1d5
go.bobheadxi.dev/zapx/zapx v0.6.8
go.uber.org/zap v1.16.0
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
gopkg.in/yaml.v2 v2.3.0
gorm.io/driver/postgres v1.0.8
gorm.io/driver/sqlite v1.1.4
gorm.io/gorm v1.21.4
)
172 changes: 172 additions & 0 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion testenv/testenv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ import (
func TestTestenv(t *testing.T) {
testenv, err := NewBlockchain(context.Background())
require.NoError(t, err)
testenv.SendETH(testenv.Auth.From, utils.OneEthInWei)
testenv.SendETH(testenv.Auth.From, utils.ToWei("100.0", 18))
}
8 changes: 0 additions & 8 deletions utils/amounts.go

This file was deleted.

8 changes: 4 additions & 4 deletions utils/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import (
"github.com/ethereum/go-ethereum/crypto"
)

// reusable ethereum key authorization tooling

// Authorizer wraps ethereum transactopts
// Authorizer wraps the bind.TransactOpts type making it safe for concurrent use.
// A number of fields within bind.TransactOpts are not concurrency safe, and as such you must leverage
// the embedded mutex type befopre using the transactor.
type Authorizer struct {
sync.Mutex // bind.TransactOpts is not thread safe
*bind.TransactOpts
}

// NewAuthorizer returns an Authorizer object
// NewAuthorizer returns an Authorizer object using a keyfile as the account source
func NewAuthorizer(keyFile, keyPass string) (*Authorizer, error) {
fileBytes, err := ioutil.ReadFile(keyFile)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions utils/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import (
)

// Blockchain is a generalized interface for interacting with the ethereum blockchain
// it satisfies all functions required by the ethclient, and simulated backend types.
// This allows you to use ethclient and the simulated backend interchangeably which is
// particularly useful for testing
type Blockchain interface {
// CodeAt returns the code of the given account. This is needed to differentiate
// between contract internal errors and the local chain being out of sync.
Expand Down
2 changes: 2 additions & 0 deletions utils/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package utils provides a set of interfaces, helper functions, and authentication management helpers
package utils

0 comments on commit c2337d2

Please sign in to comment.