Giter VIP home page Giter VIP logo

go-compound's Introduction

go-compound

WARNING: this code deals with money both by making blockchain calls and returning information that can be used to lose/gain money. Please use cautiously and dont come complaining if you end up losing money.

go-compound is a Golang client, and library for interacting with the compound.finace API, and interacting with the compound contracts, allowing for the creation of bots trading with the Compound protocol.

Contents

  • abi contains json abi definitions for various compound smart contracts
  • bindigns contains abigen generated golang bindings for the various abi's
  • client contains a client library to build applications that use the compound.finance API and interact with the smart contracts
  • cmd contains a small command-line client
  • models contains Golang types for the various responses that the API gives. Currently it has types for CTokenService and AccountService responses.
  • pb contains protobuf definitions for the compound APIs. Do not use
  • sampler contains sampler configurations to enable console based monitoring of your compound accounts

Current Capabilities

APIs

Client Library

  • Access to APIs via Golang programs, and not having to deal with raw http calls
  • Watch account health, signalling and printing on different account health states
  • Retrieve supply interest earned for a particular token
  • Retrieve total supply interest earned
  • Retrieve borrow interest owed for a particular token
  • Borrow from any compound contract
  • Get borrow rate for any compound contract
  • Retrieve list of liquidatable addresses

CLI

  • Pretty print full AccountService::AccountResponse information, suitable for piping to jq
  • Retrieve account health
  • Retrieve supply interest earned for a particular token
  • Retrieve total supply interest earned
  • Retrieve borrow interest owed for a particular token
  • Retrieve a list of addresses that can be liquidated

Monitoring

  • Enables monitoring your account with sampler.
  • Default sampler config located in sampler/sampler.yml however you'll need to replace the addresses as needed.

Long Term Goals

  • Enable persisting retrieve data locally in a DB for fast lookups
  • Enable report generation of your holdings
  • Enable the MarketHistoryService API
  • Enable graphing of MarketHistoryService metrics
  • Enable arbitrage between uniswap and compound
    • Enable things like spotting interest rate arbitrages
    • Repayment arbitrages
    • ???

Links

Support

If you like this application feel free to send me some ETH, or whatever (shit)coins you want to get rid of 0xc7459562777DDf3A1A7afefBE515E8479Bd3FDBD.

Misc Q&A's

  • Q: on the compound token contracts, what's the different between exchangeRateCurrent and exchangeRateStored
  • A: Current calls accrueInterest - stored returns the last computed value

go-compound's People

Contributors

bonedaddy avatar davidiola avatar postables avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

go-compound's Issues

Refactor To V2

Code-base is a little disorganized and could benefit from some cleanup and refactoring. Things to do:

  • Reduce code duplication for contract calls
  • Move the ctoken definitions and their bindings to a complete separate subpackage

Build errors when attempting to import the package into a program for use.

Running into this error: undefined: abi.U256 when trying to import the package. Does this signify that I require an additional dependency?

% go build
# github.com/postables/go-compound/bindings/crep
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/crep/crep.go:23:6: undefined: abi.U256
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/crep/crep.go:142:56: cannot use result (type interface {}) as type *[]interface {} in argument to _Bindings.Contract.BindingsCaller.contract.Call: need type assertion
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/crep/crep.go:161:41: cannot use result (type interface {}) as type *[]interface {} in argument to _Bindings.Contract.contract.Call: need type assertion
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/crep/crep.go:183:32: cannot use out (type **big.Int) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/crep/crep.go:209:32: cannot use out (type *common.Address) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/crep/crep.go:235:32: cannot use out (type **big.Int) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/crep/crep.go:261:32: cannot use out (type **big.Int) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/crep/crep.go:287:32: cannot use out (type **big.Int) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/crep/crep.go:313:32: cannot use out (type **big.Int) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/crep/crep.go:339:32: cannot use out (type **big.Int) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/crep/crep.go:339:32: too many errors
# github.com/postables/go-compound/bindings/cdai
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/cdai/cdai.go:23:6: undefined: abi.U256
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/cdai/cdai.go:142:56: cannot use result (type interface {}) as type *[]interface {} in argument to _Bindings.Contract.BindingsCaller.contract.Call: need type assertion
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/cdai/cdai.go:161:41: cannot use result (type interface {}) as type *[]interface {} in argument to _Bindings.Contract.contract.Call: need type assertion
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/cdai/cdai.go:183:32: cannot use out (type **big.Int) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/cdai/cdai.go:209:32: cannot use out (type *common.Address) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/cdai/cdai.go:235:32: cannot use out (type **big.Int) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/cdai/cdai.go:261:32: cannot use out (type **big.Int) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/cdai/cdai.go:287:32: cannot use out (type **big.Int) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/cdai/cdai.go:313:32: cannot use out (type **big.Int) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/cdai/cdai.go:339:32: cannot use out (type **big.Int) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/cdai/cdai.go:339:32: too many errors
# github.com/postables/go-compound/bindings/cusdc
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/cusdc/cusdc.go:23:6: undefined: abi.U256
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/cusdc/cusdc.go:142:56: cannot use result (type interface {}) as type *[]interface {} in argument to _Bindings.Contract.BindingsCaller.contract.Call: need type assertion
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/cusdc/cusdc.go:161:41: cannot use result (type interface {}) as type *[]interface {} in argument to _Bindings.Contract.contract.Call: need type assertion
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/cusdc/cusdc.go:183:32: cannot use out (type **big.Int) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/cusdc/cusdc.go:209:32: cannot use out (type *common.Address) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/cusdc/cusdc.go:235:32: cannot use out (type **big.Int) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/cusdc/cusdc.go:261:32: cannot use out (type **big.Int) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/cusdc/cusdc.go:287:32: cannot use out (type **big.Int) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/cusdc/cusdc.go:313:32: cannot use out (type **big.Int) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/cusdc/cusdc.go:339:32: cannot use out (type **big.Int) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/cusdc/cusdc.go:339:32: too many errors
# github.com/postables/go-compound/bindings/comptroller
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/comptroller/comptroller.go:23:6: undefined: abi.U256
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/comptroller/comptroller.go:142:56: cannot use result (type interface {}) as type *[]interface {} in argument to _Bindings.Contract.BindingsCaller.contract.Call: need type assertion
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/comptroller/comptroller.go:161:41: cannot use result (type interface {}) as type *[]interface {} in argument to _Bindings.Contract.contract.Call: need type assertion
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/comptroller/comptroller.go:183:32: cannot use out (type *common.Address) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/comptroller/comptroller.go:209:32: cannot use out (type *common.Address) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/comptroller/comptroller.go:235:32: cannot use out (type *bool) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/comptroller/comptroller.go:261:32: cannot use out (type **big.Int) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/comptroller/comptroller.go:287:32: cannot use out (type *common.Address) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/comptroller/comptroller.go:345:32: cannot use out (type *[]common.Address) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/comptroller/comptroller.go:371:32: cannot use out (type *bool) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/comptroller/comptroller.go:371:32: too many errors
# github.com/postables/go-compound/bindings/cbat
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/cbat/cbat.go:23:6: undefined: abi.U256
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/cbat/cbat.go:142:56: cannot use result (type interface {}) as type *[]interface {} in argument to _Bindings.Contract.BindingsCaller.contract.Call: need type assertion
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/cbat/cbat.go:161:41: cannot use result (type interface {}) as type *[]interface {} in argument to _Bindings.Contract.contract.Call: need type assertion
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/cbat/cbat.go:183:32: cannot use out (type **big.Int) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/cbat/cbat.go:209:32: cannot use out (type *common.Address) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/cbat/cbat.go:235:32: cannot use out (type **big.Int) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/cbat/cbat.go:261:32: cannot use out (type **big.Int) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/cbat/cbat.go:287:32: cannot use out (type **big.Int) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/cbat/cbat.go:313:32: cannot use out (type **big.Int) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/cbat/cbat.go:339:32: cannot use out (type **big.Int) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/cbat/cbat.go:339:32: too many errors
# github.com/postables/go-compound/bindings/ceth
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/ceth/ceth.go:23:6: undefined: abi.U256
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/ceth/ceth.go:142:56: cannot use result (type interface {}) as type *[]interface {} in argument to _Bindings.Contract.BindingsCaller.contract.Call: need type assertion
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/ceth/ceth.go:161:41: cannot use result (type interface {}) as type *[]interface {} in argument to _Bindings.Contract.contract.Call: need type assertion
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/ceth/ceth.go:183:32: cannot use out (type **big.Int) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/ceth/ceth.go:209:32: cannot use out (type *common.Address) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/ceth/ceth.go:235:32: cannot use out (type **big.Int) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/ceth/ceth.go:261:32: cannot use out (type **big.Int) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/ceth/ceth.go:287:32: cannot use out (type **big.Int) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/ceth/ceth.go:313:32: cannot use out (type **big.Int) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/ceth/ceth.go:339:32: cannot use out (type **big.Int) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/ceth/ceth.go:339:32: too many errors
# github.com/postables/go-compound/bindings/csai
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/csai/csai.go:23:6: undefined: abi.U256
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/csai/csai.go:142:56: cannot use result (type interface {}) as type *[]interface {} in argument to _Bindings.Contract.BindingsCaller.contract.Call: need type assertion
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/csai/csai.go:161:41: cannot use result (type interface {}) as type *[]interface {} in argument to _Bindings.Contract.contract.Call: need type assertion
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/csai/csai.go:183:32: cannot use out (type **big.Int) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/csai/csai.go:209:32: cannot use out (type *common.Address) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/csai/csai.go:235:32: cannot use out (type **big.Int) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/csai/csai.go:261:32: cannot use out (type **big.Int) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/csai/csai.go:287:32: cannot use out (type **big.Int) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/csai/csai.go:313:32: cannot use out (type **big.Int) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/csai/csai.go:339:32: cannot use out (type **big.Int) as type *[]interface {} in argument to _Bindings.contract.Call
../../../go/pkg/mod/github.com/postables/[email protected]/bindings/csai/csai.go:339:32: too many errors

This error results from calling go build on this program:

package main

import (
	// t "testing"
	// "github.com/ethereum/go-ethereum/ethclient"
	// "github.com/ethereum/go-ethereum"
	c "github.com/postables/go-compound/client"
)

var (
	api                       = "https://api.compound.finance/api/v2"
)

func main() {
	}
}

Does anyone have an idea of what could be causing this?

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.