Compare commits
2 Commits
916759a907
...
0afb017f22
Author | SHA1 | Date | |
---|---|---|---|
0afb017f22 | |||
73bb337e4b |
1
aave/contracts/IDataProvider.abi
Normal file
1
aave/contracts/IDataProvider.abi
Normal file
@ -0,0 +1 @@
|
||||
[{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"getReserveTokensAddresses","outputs":[{"internalType":"address","name":"aTokenAddress","type":"address"},{"internalType":"address","name":"stableDebtTokenAddress","type":"address"},{"internalType":"address","name":"variableDebtTokenAddress","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"address","name":"user","type":"address"}],"name":"getUserReserveData","outputs":[{"internalType":"uint256","name":"currentATokenBalance","type":"uint256"},{"internalType":"uint256","name":"currentStableDebt","type":"uint256"},{"internalType":"uint256","name":"currentVariableDebt","type":"uint256"},{"internalType":"uint256","name":"principalStableDebt","type":"uint256"},{"internalType":"uint256","name":"scaledVariableDebt","type":"uint256"},{"internalType":"uint256","name":"stableBorrowRate","type":"uint256"},{"internalType":"uint256","name":"liquidityRate","type":"uint256"},{"internalType":"uint40","name":"stableRateLastUpdated","type":"uint40"},{"internalType":"bool","name":"usageAsCollateralEnabled","type":"bool"}],"stateMutability":"view","type":"function"}]
|
1
aave/contracts/IIncentivesController.abi
Normal file
1
aave/contracts/IIncentivesController.abi
Normal file
@ -0,0 +1 @@
|
||||
[{"inputs":[{"internalType":"address[]","name":"assets","type":"address[]"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"name":"claimRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"assets","type":"address[]"},{"internalType":"address","name":"user","type":"address"}],"name":"getRewardsBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]
|
1
aave/contracts/ILendingPool.abi
Normal file
1
aave/contracts/ILendingPool.abi
Normal file
@ -0,0 +1 @@
|
||||
[{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"interestRateMode","type":"uint256"},{"internalType":"uint16","name":"referralCode","type":"uint16"},{"internalType":"address","name":"onBehalfOf","type":"address"}],"name":"borrow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"onBehalfOf","type":"address"},{"internalType":"uint16","name":"referralCode","type":"uint16"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getUserAccountData","outputs":[{"internalType":"uint256","name":"totalCollateralETH","type":"uint256"},{"internalType":"uint256","name":"totalDebtETH","type":"uint256"},{"internalType":"uint256","name":"availableBorrowsETH","type":"uint256"},{"internalType":"uint256","name":"currentLiquidationThreshold","type":"uint256"},{"internalType":"uint256","name":"ltv","type":"uint256"},{"internalType":"uint256","name":"healthFactor","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"rateMode","type":"uint256"},{"internalType":"address","name":"onBehalfOf","type":"address"}],"name":"repay","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"name":"withdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"}]
|
310
aave/contracts/dataprovider.go
Normal file
310
aave/contracts/dataprovider.go
Normal file
@ -0,0 +1,310 @@
|
||||
// Code generated - DO NOT EDIT.
|
||||
// This file is a generated binding and any manual changes will be lost.
|
||||
|
||||
package contracts
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"math/big"
|
||||
"strings"
|
||||
|
||||
ethereum "github.com/ethereum/go-ethereum"
|
||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/event"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var (
|
||||
_ = errors.New
|
||||
_ = big.NewInt
|
||||
_ = strings.NewReader
|
||||
_ = ethereum.NotFound
|
||||
_ = bind.Bind
|
||||
_ = common.Big1
|
||||
_ = types.BloomLookup
|
||||
_ = event.NewSubscription
|
||||
)
|
||||
|
||||
// DataProviderMetaData contains all meta data concerning the DataProvider contract.
|
||||
var DataProviderMetaData = &bind.MetaData{
|
||||
ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"}],\"name\":\"getReserveTokensAddresses\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"aTokenAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"stableDebtTokenAddress\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"variableDebtTokenAddress\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"getUserReserveData\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"currentATokenBalance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"currentStableDebt\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"currentVariableDebt\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"principalStableDebt\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"scaledVariableDebt\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"stableBorrowRate\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"liquidityRate\",\"type\":\"uint256\"},{\"internalType\":\"uint40\",\"name\":\"stableRateLastUpdated\",\"type\":\"uint40\"},{\"internalType\":\"bool\",\"name\":\"usageAsCollateralEnabled\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]",
|
||||
}
|
||||
|
||||
// DataProviderABI is the input ABI used to generate the binding from.
|
||||
// Deprecated: Use DataProviderMetaData.ABI instead.
|
||||
var DataProviderABI = DataProviderMetaData.ABI
|
||||
|
||||
// DataProvider is an auto generated Go binding around an Ethereum contract.
|
||||
type DataProvider struct {
|
||||
DataProviderCaller // Read-only binding to the contract
|
||||
DataProviderTransactor // Write-only binding to the contract
|
||||
DataProviderFilterer // Log filterer for contract events
|
||||
}
|
||||
|
||||
// DataProviderCaller is an auto generated read-only Go binding around an Ethereum contract.
|
||||
type DataProviderCaller struct {
|
||||
contract *bind.BoundContract // Generic contract wrapper for the low level calls
|
||||
}
|
||||
|
||||
// DataProviderTransactor is an auto generated write-only Go binding around an Ethereum contract.
|
||||
type DataProviderTransactor struct {
|
||||
contract *bind.BoundContract // Generic contract wrapper for the low level calls
|
||||
}
|
||||
|
||||
// DataProviderFilterer is an auto generated log filtering Go binding around an Ethereum contract events.
|
||||
type DataProviderFilterer struct {
|
||||
contract *bind.BoundContract // Generic contract wrapper for the low level calls
|
||||
}
|
||||
|
||||
// DataProviderSession is an auto generated Go binding around an Ethereum contract,
|
||||
// with pre-set call and transact options.
|
||||
type DataProviderSession struct {
|
||||
Contract *DataProvider // Generic contract binding to set the session for
|
||||
CallOpts bind.CallOpts // Call options to use throughout this session
|
||||
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
|
||||
}
|
||||
|
||||
// DataProviderCallerSession is an auto generated read-only Go binding around an Ethereum contract,
|
||||
// with pre-set call options.
|
||||
type DataProviderCallerSession struct {
|
||||
Contract *DataProviderCaller // Generic contract caller binding to set the session for
|
||||
CallOpts bind.CallOpts // Call options to use throughout this session
|
||||
}
|
||||
|
||||
// DataProviderTransactorSession is an auto generated write-only Go binding around an Ethereum contract,
|
||||
// with pre-set transact options.
|
||||
type DataProviderTransactorSession struct {
|
||||
Contract *DataProviderTransactor // Generic contract transactor binding to set the session for
|
||||
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
|
||||
}
|
||||
|
||||
// DataProviderRaw is an auto generated low-level Go binding around an Ethereum contract.
|
||||
type DataProviderRaw struct {
|
||||
Contract *DataProvider // Generic contract binding to access the raw methods on
|
||||
}
|
||||
|
||||
// DataProviderCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
|
||||
type DataProviderCallerRaw struct {
|
||||
Contract *DataProviderCaller // Generic read-only contract binding to access the raw methods on
|
||||
}
|
||||
|
||||
// DataProviderTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
|
||||
type DataProviderTransactorRaw struct {
|
||||
Contract *DataProviderTransactor // Generic write-only contract binding to access the raw methods on
|
||||
}
|
||||
|
||||
// NewDataProvider creates a new instance of DataProvider, bound to a specific deployed contract.
|
||||
func NewDataProvider(address common.Address, backend bind.ContractBackend) (*DataProvider, error) {
|
||||
contract, err := bindDataProvider(address, backend, backend, backend)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &DataProvider{DataProviderCaller: DataProviderCaller{contract: contract}, DataProviderTransactor: DataProviderTransactor{contract: contract}, DataProviderFilterer: DataProviderFilterer{contract: contract}}, nil
|
||||
}
|
||||
|
||||
// NewDataProviderCaller creates a new read-only instance of DataProvider, bound to a specific deployed contract.
|
||||
func NewDataProviderCaller(address common.Address, caller bind.ContractCaller) (*DataProviderCaller, error) {
|
||||
contract, err := bindDataProvider(address, caller, nil, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &DataProviderCaller{contract: contract}, nil
|
||||
}
|
||||
|
||||
// NewDataProviderTransactor creates a new write-only instance of DataProvider, bound to a specific deployed contract.
|
||||
func NewDataProviderTransactor(address common.Address, transactor bind.ContractTransactor) (*DataProviderTransactor, error) {
|
||||
contract, err := bindDataProvider(address, nil, transactor, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &DataProviderTransactor{contract: contract}, nil
|
||||
}
|
||||
|
||||
// NewDataProviderFilterer creates a new log filterer instance of DataProvider, bound to a specific deployed contract.
|
||||
func NewDataProviderFilterer(address common.Address, filterer bind.ContractFilterer) (*DataProviderFilterer, error) {
|
||||
contract, err := bindDataProvider(address, nil, nil, filterer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &DataProviderFilterer{contract: contract}, nil
|
||||
}
|
||||
|
||||
// bindDataProvider binds a generic wrapper to an already deployed contract.
|
||||
func bindDataProvider(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {
|
||||
parsed, err := abi.JSON(strings.NewReader(DataProviderABI))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil
|
||||
}
|
||||
|
||||
// Call invokes the (constant) contract method with params as input values and
|
||||
// sets the output to result. The result type might be a single field for simple
|
||||
// returns, a slice of interfaces for anonymous returns and a struct for named
|
||||
// returns.
|
||||
func (_DataProvider *DataProviderRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
|
||||
return _DataProvider.Contract.DataProviderCaller.contract.Call(opts, result, method, params...)
|
||||
}
|
||||
|
||||
// Transfer initiates a plain transaction to move funds to the contract, calling
|
||||
// its default method if one is available.
|
||||
func (_DataProvider *DataProviderRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
|
||||
return _DataProvider.Contract.DataProviderTransactor.contract.Transfer(opts)
|
||||
}
|
||||
|
||||
// Transact invokes the (paid) contract method with params as input values.
|
||||
func (_DataProvider *DataProviderRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
|
||||
return _DataProvider.Contract.DataProviderTransactor.contract.Transact(opts, method, params...)
|
||||
}
|
||||
|
||||
// Call invokes the (constant) contract method with params as input values and
|
||||
// sets the output to result. The result type might be a single field for simple
|
||||
// returns, a slice of interfaces for anonymous returns and a struct for named
|
||||
// returns.
|
||||
func (_DataProvider *DataProviderCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
|
||||
return _DataProvider.Contract.contract.Call(opts, result, method, params...)
|
||||
}
|
||||
|
||||
// Transfer initiates a plain transaction to move funds to the contract, calling
|
||||
// its default method if one is available.
|
||||
func (_DataProvider *DataProviderTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
|
||||
return _DataProvider.Contract.contract.Transfer(opts)
|
||||
}
|
||||
|
||||
// Transact invokes the (paid) contract method with params as input values.
|
||||
func (_DataProvider *DataProviderTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
|
||||
return _DataProvider.Contract.contract.Transact(opts, method, params...)
|
||||
}
|
||||
|
||||
// GetReserveTokensAddresses is a free data retrieval call binding the contract method 0xd2493b6c.
|
||||
//
|
||||
// Solidity: function getReserveTokensAddresses(address asset) view returns(address aTokenAddress, address stableDebtTokenAddress, address variableDebtTokenAddress)
|
||||
func (_DataProvider *DataProviderCaller) GetReserveTokensAddresses(opts *bind.CallOpts, asset common.Address) (struct {
|
||||
ATokenAddress common.Address
|
||||
StableDebtTokenAddress common.Address
|
||||
VariableDebtTokenAddress common.Address
|
||||
}, error) {
|
||||
var out []interface{}
|
||||
err := _DataProvider.contract.Call(opts, &out, "getReserveTokensAddresses", asset)
|
||||
|
||||
outstruct := new(struct {
|
||||
ATokenAddress common.Address
|
||||
StableDebtTokenAddress common.Address
|
||||
VariableDebtTokenAddress common.Address
|
||||
})
|
||||
if err != nil {
|
||||
return *outstruct, err
|
||||
}
|
||||
|
||||
outstruct.ATokenAddress = *abi.ConvertType(out[0], new(common.Address)).(*common.Address)
|
||||
outstruct.StableDebtTokenAddress = *abi.ConvertType(out[1], new(common.Address)).(*common.Address)
|
||||
outstruct.VariableDebtTokenAddress = *abi.ConvertType(out[2], new(common.Address)).(*common.Address)
|
||||
|
||||
return *outstruct, err
|
||||
|
||||
}
|
||||
|
||||
// GetReserveTokensAddresses is a free data retrieval call binding the contract method 0xd2493b6c.
|
||||
//
|
||||
// Solidity: function getReserveTokensAddresses(address asset) view returns(address aTokenAddress, address stableDebtTokenAddress, address variableDebtTokenAddress)
|
||||
func (_DataProvider *DataProviderSession) GetReserveTokensAddresses(asset common.Address) (struct {
|
||||
ATokenAddress common.Address
|
||||
StableDebtTokenAddress common.Address
|
||||
VariableDebtTokenAddress common.Address
|
||||
}, error) {
|
||||
return _DataProvider.Contract.GetReserveTokensAddresses(&_DataProvider.CallOpts, asset)
|
||||
}
|
||||
|
||||
// GetReserveTokensAddresses is a free data retrieval call binding the contract method 0xd2493b6c.
|
||||
//
|
||||
// Solidity: function getReserveTokensAddresses(address asset) view returns(address aTokenAddress, address stableDebtTokenAddress, address variableDebtTokenAddress)
|
||||
func (_DataProvider *DataProviderCallerSession) GetReserveTokensAddresses(asset common.Address) (struct {
|
||||
ATokenAddress common.Address
|
||||
StableDebtTokenAddress common.Address
|
||||
VariableDebtTokenAddress common.Address
|
||||
}, error) {
|
||||
return _DataProvider.Contract.GetReserveTokensAddresses(&_DataProvider.CallOpts, asset)
|
||||
}
|
||||
|
||||
// GetUserReserveData is a free data retrieval call binding the contract method 0x28dd2d01.
|
||||
//
|
||||
// Solidity: function getUserReserveData(address asset, address user) view returns(uint256 currentATokenBalance, uint256 currentStableDebt, uint256 currentVariableDebt, uint256 principalStableDebt, uint256 scaledVariableDebt, uint256 stableBorrowRate, uint256 liquidityRate, uint40 stableRateLastUpdated, bool usageAsCollateralEnabled)
|
||||
func (_DataProvider *DataProviderCaller) GetUserReserveData(opts *bind.CallOpts, asset common.Address, user common.Address) (struct {
|
||||
CurrentATokenBalance *big.Int
|
||||
CurrentStableDebt *big.Int
|
||||
CurrentVariableDebt *big.Int
|
||||
PrincipalStableDebt *big.Int
|
||||
ScaledVariableDebt *big.Int
|
||||
StableBorrowRate *big.Int
|
||||
LiquidityRate *big.Int
|
||||
StableRateLastUpdated *big.Int
|
||||
UsageAsCollateralEnabled bool
|
||||
}, error) {
|
||||
var out []interface{}
|
||||
err := _DataProvider.contract.Call(opts, &out, "getUserReserveData", asset, user)
|
||||
|
||||
outstruct := new(struct {
|
||||
CurrentATokenBalance *big.Int
|
||||
CurrentStableDebt *big.Int
|
||||
CurrentVariableDebt *big.Int
|
||||
PrincipalStableDebt *big.Int
|
||||
ScaledVariableDebt *big.Int
|
||||
StableBorrowRate *big.Int
|
||||
LiquidityRate *big.Int
|
||||
StableRateLastUpdated *big.Int
|
||||
UsageAsCollateralEnabled bool
|
||||
})
|
||||
if err != nil {
|
||||
return *outstruct, err
|
||||
}
|
||||
|
||||
outstruct.CurrentATokenBalance = *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)
|
||||
outstruct.CurrentStableDebt = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int)
|
||||
outstruct.CurrentVariableDebt = *abi.ConvertType(out[2], new(*big.Int)).(**big.Int)
|
||||
outstruct.PrincipalStableDebt = *abi.ConvertType(out[3], new(*big.Int)).(**big.Int)
|
||||
outstruct.ScaledVariableDebt = *abi.ConvertType(out[4], new(*big.Int)).(**big.Int)
|
||||
outstruct.StableBorrowRate = *abi.ConvertType(out[5], new(*big.Int)).(**big.Int)
|
||||
outstruct.LiquidityRate = *abi.ConvertType(out[6], new(*big.Int)).(**big.Int)
|
||||
outstruct.StableRateLastUpdated = *abi.ConvertType(out[7], new(*big.Int)).(**big.Int)
|
||||
outstruct.UsageAsCollateralEnabled = *abi.ConvertType(out[8], new(bool)).(*bool)
|
||||
|
||||
return *outstruct, err
|
||||
|
||||
}
|
||||
|
||||
// GetUserReserveData is a free data retrieval call binding the contract method 0x28dd2d01.
|
||||
//
|
||||
// Solidity: function getUserReserveData(address asset, address user) view returns(uint256 currentATokenBalance, uint256 currentStableDebt, uint256 currentVariableDebt, uint256 principalStableDebt, uint256 scaledVariableDebt, uint256 stableBorrowRate, uint256 liquidityRate, uint40 stableRateLastUpdated, bool usageAsCollateralEnabled)
|
||||
func (_DataProvider *DataProviderSession) GetUserReserveData(asset common.Address, user common.Address) (struct {
|
||||
CurrentATokenBalance *big.Int
|
||||
CurrentStableDebt *big.Int
|
||||
CurrentVariableDebt *big.Int
|
||||
PrincipalStableDebt *big.Int
|
||||
ScaledVariableDebt *big.Int
|
||||
StableBorrowRate *big.Int
|
||||
LiquidityRate *big.Int
|
||||
StableRateLastUpdated *big.Int
|
||||
UsageAsCollateralEnabled bool
|
||||
}, error) {
|
||||
return _DataProvider.Contract.GetUserReserveData(&_DataProvider.CallOpts, asset, user)
|
||||
}
|
||||
|
||||
// GetUserReserveData is a free data retrieval call binding the contract method 0x28dd2d01.
|
||||
//
|
||||
// Solidity: function getUserReserveData(address asset, address user) view returns(uint256 currentATokenBalance, uint256 currentStableDebt, uint256 currentVariableDebt, uint256 principalStableDebt, uint256 scaledVariableDebt, uint256 stableBorrowRate, uint256 liquidityRate, uint40 stableRateLastUpdated, bool usageAsCollateralEnabled)
|
||||
func (_DataProvider *DataProviderCallerSession) GetUserReserveData(asset common.Address, user common.Address) (struct {
|
||||
CurrentATokenBalance *big.Int
|
||||
CurrentStableDebt *big.Int
|
||||
CurrentVariableDebt *big.Int
|
||||
PrincipalStableDebt *big.Int
|
||||
ScaledVariableDebt *big.Int
|
||||
StableBorrowRate *big.Int
|
||||
LiquidityRate *big.Int
|
||||
StableRateLastUpdated *big.Int
|
||||
UsageAsCollateralEnabled bool
|
||||
}, error) {
|
||||
return _DataProvider.Contract.GetUserReserveData(&_DataProvider.CallOpts, asset, user)
|
||||
}
|
21
aave/contracts/dataprovider.sol
Normal file
21
aave/contracts/dataprovider.sol
Normal file
@ -0,0 +1,21 @@
|
||||
pragma solidity >=0.6.0;
|
||||
|
||||
interface IDataProvider {
|
||||
function getReserveTokensAddresses(address asset) external view returns (
|
||||
address aTokenAddress,
|
||||
address stableDebtTokenAddress,
|
||||
address variableDebtTokenAddress
|
||||
);
|
||||
|
||||
function getUserReserveData(address asset, address user) external view returns (
|
||||
uint256 currentATokenBalance,
|
||||
uint256 currentStableDebt,
|
||||
uint256 currentVariableDebt,
|
||||
uint256 principalStableDebt,
|
||||
uint256 scaledVariableDebt,
|
||||
uint256 stableBorrowRate,
|
||||
uint256 liquidityRate,
|
||||
uint40 stableRateLastUpdated,
|
||||
bool usageAsCollateralEnabled
|
||||
);
|
||||
}
|
232
aave/contracts/incentivescontroller.go
Normal file
232
aave/contracts/incentivescontroller.go
Normal file
@ -0,0 +1,232 @@
|
||||
// Code generated - DO NOT EDIT.
|
||||
// This file is a generated binding and any manual changes will be lost.
|
||||
|
||||
package contracts
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"math/big"
|
||||
"strings"
|
||||
|
||||
ethereum "github.com/ethereum/go-ethereum"
|
||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/event"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var (
|
||||
_ = errors.New
|
||||
_ = big.NewInt
|
||||
_ = strings.NewReader
|
||||
_ = ethereum.NotFound
|
||||
_ = bind.Bind
|
||||
_ = common.Big1
|
||||
_ = types.BloomLookup
|
||||
_ = event.NewSubscription
|
||||
)
|
||||
|
||||
// IncentivesControllerMetaData contains all meta data concerning the IncentivesController contract.
|
||||
var IncentivesControllerMetaData = &bind.MetaData{
|
||||
ABI: "[{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"assets\",\"type\":\"address[]\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"}],\"name\":\"claimRewards\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"assets\",\"type\":\"address[]\"},{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"getRewardsBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]",
|
||||
}
|
||||
|
||||
// IncentivesControllerABI is the input ABI used to generate the binding from.
|
||||
// Deprecated: Use IncentivesControllerMetaData.ABI instead.
|
||||
var IncentivesControllerABI = IncentivesControllerMetaData.ABI
|
||||
|
||||
// IncentivesController is an auto generated Go binding around an Ethereum contract.
|
||||
type IncentivesController struct {
|
||||
IncentivesControllerCaller // Read-only binding to the contract
|
||||
IncentivesControllerTransactor // Write-only binding to the contract
|
||||
IncentivesControllerFilterer // Log filterer for contract events
|
||||
}
|
||||
|
||||
// IncentivesControllerCaller is an auto generated read-only Go binding around an Ethereum contract.
|
||||
type IncentivesControllerCaller struct {
|
||||
contract *bind.BoundContract // Generic contract wrapper for the low level calls
|
||||
}
|
||||
|
||||
// IncentivesControllerTransactor is an auto generated write-only Go binding around an Ethereum contract.
|
||||
type IncentivesControllerTransactor struct {
|
||||
contract *bind.BoundContract // Generic contract wrapper for the low level calls
|
||||
}
|
||||
|
||||
// IncentivesControllerFilterer is an auto generated log filtering Go binding around an Ethereum contract events.
|
||||
type IncentivesControllerFilterer struct {
|
||||
contract *bind.BoundContract // Generic contract wrapper for the low level calls
|
||||
}
|
||||
|
||||
// IncentivesControllerSession is an auto generated Go binding around an Ethereum contract,
|
||||
// with pre-set call and transact options.
|
||||
type IncentivesControllerSession struct {
|
||||
Contract *IncentivesController // Generic contract binding to set the session for
|
||||
CallOpts bind.CallOpts // Call options to use throughout this session
|
||||
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
|
||||
}
|
||||
|
||||
// IncentivesControllerCallerSession is an auto generated read-only Go binding around an Ethereum contract,
|
||||
// with pre-set call options.
|
||||
type IncentivesControllerCallerSession struct {
|
||||
Contract *IncentivesControllerCaller // Generic contract caller binding to set the session for
|
||||
CallOpts bind.CallOpts // Call options to use throughout this session
|
||||
}
|
||||
|
||||
// IncentivesControllerTransactorSession is an auto generated write-only Go binding around an Ethereum contract,
|
||||
// with pre-set transact options.
|
||||
type IncentivesControllerTransactorSession struct {
|
||||
Contract *IncentivesControllerTransactor // Generic contract transactor binding to set the session for
|
||||
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
|
||||
}
|
||||
|
||||
// IncentivesControllerRaw is an auto generated low-level Go binding around an Ethereum contract.
|
||||
type IncentivesControllerRaw struct {
|
||||
Contract *IncentivesController // Generic contract binding to access the raw methods on
|
||||
}
|
||||
|
||||
// IncentivesControllerCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
|
||||
type IncentivesControllerCallerRaw struct {
|
||||
Contract *IncentivesControllerCaller // Generic read-only contract binding to access the raw methods on
|
||||
}
|
||||
|
||||
// IncentivesControllerTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
|
||||
type IncentivesControllerTransactorRaw struct {
|
||||
Contract *IncentivesControllerTransactor // Generic write-only contract binding to access the raw methods on
|
||||
}
|
||||
|
||||
// NewIncentivesController creates a new instance of IncentivesController, bound to a specific deployed contract.
|
||||
func NewIncentivesController(address common.Address, backend bind.ContractBackend) (*IncentivesController, error) {
|
||||
contract, err := bindIncentivesController(address, backend, backend, backend)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &IncentivesController{IncentivesControllerCaller: IncentivesControllerCaller{contract: contract}, IncentivesControllerTransactor: IncentivesControllerTransactor{contract: contract}, IncentivesControllerFilterer: IncentivesControllerFilterer{contract: contract}}, nil
|
||||
}
|
||||
|
||||
// NewIncentivesControllerCaller creates a new read-only instance of IncentivesController, bound to a specific deployed contract.
|
||||
func NewIncentivesControllerCaller(address common.Address, caller bind.ContractCaller) (*IncentivesControllerCaller, error) {
|
||||
contract, err := bindIncentivesController(address, caller, nil, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &IncentivesControllerCaller{contract: contract}, nil
|
||||
}
|
||||
|
||||
// NewIncentivesControllerTransactor creates a new write-only instance of IncentivesController, bound to a specific deployed contract.
|
||||
func NewIncentivesControllerTransactor(address common.Address, transactor bind.ContractTransactor) (*IncentivesControllerTransactor, error) {
|
||||
contract, err := bindIncentivesController(address, nil, transactor, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &IncentivesControllerTransactor{contract: contract}, nil
|
||||
}
|
||||
|
||||
// NewIncentivesControllerFilterer creates a new log filterer instance of IncentivesController, bound to a specific deployed contract.
|
||||
func NewIncentivesControllerFilterer(address common.Address, filterer bind.ContractFilterer) (*IncentivesControllerFilterer, error) {
|
||||
contract, err := bindIncentivesController(address, nil, nil, filterer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &IncentivesControllerFilterer{contract: contract}, nil
|
||||
}
|
||||
|
||||
// bindIncentivesController binds a generic wrapper to an already deployed contract.
|
||||
func bindIncentivesController(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {
|
||||
parsed, err := abi.JSON(strings.NewReader(IncentivesControllerABI))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil
|
||||
}
|
||||
|
||||
// Call invokes the (constant) contract method with params as input values and
|
||||
// sets the output to result. The result type might be a single field for simple
|
||||
// returns, a slice of interfaces for anonymous returns and a struct for named
|
||||
// returns.
|
||||
func (_IncentivesController *IncentivesControllerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
|
||||
return _IncentivesController.Contract.IncentivesControllerCaller.contract.Call(opts, result, method, params...)
|
||||
}
|
||||
|
||||
// Transfer initiates a plain transaction to move funds to the contract, calling
|
||||
// its default method if one is available.
|
||||
func (_IncentivesController *IncentivesControllerRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
|
||||
return _IncentivesController.Contract.IncentivesControllerTransactor.contract.Transfer(opts)
|
||||
}
|
||||
|
||||
// Transact invokes the (paid) contract method with params as input values.
|
||||
func (_IncentivesController *IncentivesControllerRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
|
||||
return _IncentivesController.Contract.IncentivesControllerTransactor.contract.Transact(opts, method, params...)
|
||||
}
|
||||
|
||||
// Call invokes the (constant) contract method with params as input values and
|
||||
// sets the output to result. The result type might be a single field for simple
|
||||
// returns, a slice of interfaces for anonymous returns and a struct for named
|
||||
// returns.
|
||||
func (_IncentivesController *IncentivesControllerCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
|
||||
return _IncentivesController.Contract.contract.Call(opts, result, method, params...)
|
||||
}
|
||||
|
||||
// Transfer initiates a plain transaction to move funds to the contract, calling
|
||||
// its default method if one is available.
|
||||
func (_IncentivesController *IncentivesControllerTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
|
||||
return _IncentivesController.Contract.contract.Transfer(opts)
|
||||
}
|
||||
|
||||
// Transact invokes the (paid) contract method with params as input values.
|
||||
func (_IncentivesController *IncentivesControllerTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
|
||||
return _IncentivesController.Contract.contract.Transact(opts, method, params...)
|
||||
}
|
||||
|
||||
// GetRewardsBalance is a free data retrieval call binding the contract method 0x8b599f26.
|
||||
//
|
||||
// Solidity: function getRewardsBalance(address[] assets, address user) view returns(uint256)
|
||||
func (_IncentivesController *IncentivesControllerCaller) GetRewardsBalance(opts *bind.CallOpts, assets []common.Address, user common.Address) (*big.Int, error) {
|
||||
var out []interface{}
|
||||
err := _IncentivesController.contract.Call(opts, &out, "getRewardsBalance", assets, user)
|
||||
|
||||
if err != nil {
|
||||
return *new(*big.Int), err
|
||||
}
|
||||
|
||||
out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)
|
||||
|
||||
return out0, err
|
||||
|
||||
}
|
||||
|
||||
// GetRewardsBalance is a free data retrieval call binding the contract method 0x8b599f26.
|
||||
//
|
||||
// Solidity: function getRewardsBalance(address[] assets, address user) view returns(uint256)
|
||||
func (_IncentivesController *IncentivesControllerSession) GetRewardsBalance(assets []common.Address, user common.Address) (*big.Int, error) {
|
||||
return _IncentivesController.Contract.GetRewardsBalance(&_IncentivesController.CallOpts, assets, user)
|
||||
}
|
||||
|
||||
// GetRewardsBalance is a free data retrieval call binding the contract method 0x8b599f26.
|
||||
//
|
||||
// Solidity: function getRewardsBalance(address[] assets, address user) view returns(uint256)
|
||||
func (_IncentivesController *IncentivesControllerCallerSession) GetRewardsBalance(assets []common.Address, user common.Address) (*big.Int, error) {
|
||||
return _IncentivesController.Contract.GetRewardsBalance(&_IncentivesController.CallOpts, assets, user)
|
||||
}
|
||||
|
||||
// ClaimRewards is a paid mutator transaction binding the contract method 0x3111e7b3.
|
||||
//
|
||||
// Solidity: function claimRewards(address[] assets, uint256 amount, address to) returns(uint256)
|
||||
func (_IncentivesController *IncentivesControllerTransactor) ClaimRewards(opts *bind.TransactOpts, assets []common.Address, amount *big.Int, to common.Address) (*types.Transaction, error) {
|
||||
return _IncentivesController.contract.Transact(opts, "claimRewards", assets, amount, to)
|
||||
}
|
||||
|
||||
// ClaimRewards is a paid mutator transaction binding the contract method 0x3111e7b3.
|
||||
//
|
||||
// Solidity: function claimRewards(address[] assets, uint256 amount, address to) returns(uint256)
|
||||
func (_IncentivesController *IncentivesControllerSession) ClaimRewards(assets []common.Address, amount *big.Int, to common.Address) (*types.Transaction, error) {
|
||||
return _IncentivesController.Contract.ClaimRewards(&_IncentivesController.TransactOpts, assets, amount, to)
|
||||
}
|
||||
|
||||
// ClaimRewards is a paid mutator transaction binding the contract method 0x3111e7b3.
|
||||
//
|
||||
// Solidity: function claimRewards(address[] assets, uint256 amount, address to) returns(uint256)
|
||||
func (_IncentivesController *IncentivesControllerTransactorSession) ClaimRewards(assets []common.Address, amount *big.Int, to common.Address) (*types.Transaction, error) {
|
||||
return _IncentivesController.Contract.ClaimRewards(&_IncentivesController.TransactOpts, assets, amount, to)
|
||||
}
|
6
aave/contracts/incentivescontroller.sol
Normal file
6
aave/contracts/incentivescontroller.sol
Normal file
@ -0,0 +1,6 @@
|
||||
pragma solidity >=0.6.0;
|
||||
|
||||
interface IIncentivesController {
|
||||
function claimRewards(address[] calldata assets, uint256 amount, address to) external returns (uint256);
|
||||
function getRewardsBalance(address[] calldata assets, address user) external view returns (uint256);
|
||||
}
|
329
aave/contracts/lendingpool.go
Normal file
329
aave/contracts/lendingpool.go
Normal file
@ -0,0 +1,329 @@
|
||||
// Code generated - DO NOT EDIT.
|
||||
// This file is a generated binding and any manual changes will be lost.
|
||||
|
||||
package contracts
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"math/big"
|
||||
"strings"
|
||||
|
||||
ethereum "github.com/ethereum/go-ethereum"
|
||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/event"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var (
|
||||
_ = errors.New
|
||||
_ = big.NewInt
|
||||
_ = strings.NewReader
|
||||
_ = ethereum.NotFound
|
||||
_ = bind.Bind
|
||||
_ = common.Big1
|
||||
_ = types.BloomLookup
|
||||
_ = event.NewSubscription
|
||||
)
|
||||
|
||||
// LendingPoolMetaData contains all meta data concerning the LendingPool contract.
|
||||
var LendingPoolMetaData = &bind.MetaData{
|
||||
ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"interestRateMode\",\"type\":\"uint256\"},{\"internalType\":\"uint16\",\"name\":\"referralCode\",\"type\":\"uint16\"},{\"internalType\":\"address\",\"name\":\"onBehalfOf\",\"type\":\"address\"}],\"name\":\"borrow\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"onBehalfOf\",\"type\":\"address\"},{\"internalType\":\"uint16\",\"name\":\"referralCode\",\"type\":\"uint16\"}],\"name\":\"deposit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"}],\"name\":\"getUserAccountData\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"totalCollateralETH\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"totalDebtETH\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"availableBorrowsETH\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"currentLiquidationThreshold\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"ltv\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"healthFactor\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"rateMode\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"onBehalfOf\",\"type\":\"address\"}],\"name\":\"repay\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"}],\"name\":\"withdraw\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]",
|
||||
}
|
||||
|
||||
// LendingPoolABI is the input ABI used to generate the binding from.
|
||||
// Deprecated: Use LendingPoolMetaData.ABI instead.
|
||||
var LendingPoolABI = LendingPoolMetaData.ABI
|
||||
|
||||
// LendingPool is an auto generated Go binding around an Ethereum contract.
|
||||
type LendingPool struct {
|
||||
LendingPoolCaller // Read-only binding to the contract
|
||||
LendingPoolTransactor // Write-only binding to the contract
|
||||
LendingPoolFilterer // Log filterer for contract events
|
||||
}
|
||||
|
||||
// LendingPoolCaller is an auto generated read-only Go binding around an Ethereum contract.
|
||||
type LendingPoolCaller struct {
|
||||
contract *bind.BoundContract // Generic contract wrapper for the low level calls
|
||||
}
|
||||
|
||||
// LendingPoolTransactor is an auto generated write-only Go binding around an Ethereum contract.
|
||||
type LendingPoolTransactor struct {
|
||||
contract *bind.BoundContract // Generic contract wrapper for the low level calls
|
||||
}
|
||||
|
||||
// LendingPoolFilterer is an auto generated log filtering Go binding around an Ethereum contract events.
|
||||
type LendingPoolFilterer struct {
|
||||
contract *bind.BoundContract // Generic contract wrapper for the low level calls
|
||||
}
|
||||
|
||||
// LendingPoolSession is an auto generated Go binding around an Ethereum contract,
|
||||
// with pre-set call and transact options.
|
||||
type LendingPoolSession struct {
|
||||
Contract *LendingPool // Generic contract binding to set the session for
|
||||
CallOpts bind.CallOpts // Call options to use throughout this session
|
||||
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
|
||||
}
|
||||
|
||||
// LendingPoolCallerSession is an auto generated read-only Go binding around an Ethereum contract,
|
||||
// with pre-set call options.
|
||||
type LendingPoolCallerSession struct {
|
||||
Contract *LendingPoolCaller // Generic contract caller binding to set the session for
|
||||
CallOpts bind.CallOpts // Call options to use throughout this session
|
||||
}
|
||||
|
||||
// LendingPoolTransactorSession is an auto generated write-only Go binding around an Ethereum contract,
|
||||
// with pre-set transact options.
|
||||
type LendingPoolTransactorSession struct {
|
||||
Contract *LendingPoolTransactor // Generic contract transactor binding to set the session for
|
||||
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
|
||||
}
|
||||
|
||||
// LendingPoolRaw is an auto generated low-level Go binding around an Ethereum contract.
|
||||
type LendingPoolRaw struct {
|
||||
Contract *LendingPool // Generic contract binding to access the raw methods on
|
||||
}
|
||||
|
||||
// LendingPoolCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
|
||||
type LendingPoolCallerRaw struct {
|
||||
Contract *LendingPoolCaller // Generic read-only contract binding to access the raw methods on
|
||||
}
|
||||
|
||||
// LendingPoolTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
|
||||
type LendingPoolTransactorRaw struct {
|
||||
Contract *LendingPoolTransactor // Generic write-only contract binding to access the raw methods on
|
||||
}
|
||||
|
||||
// NewLendingPool creates a new instance of LendingPool, bound to a specific deployed contract.
|
||||
func NewLendingPool(address common.Address, backend bind.ContractBackend) (*LendingPool, error) {
|
||||
contract, err := bindLendingPool(address, backend, backend, backend)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &LendingPool{LendingPoolCaller: LendingPoolCaller{contract: contract}, LendingPoolTransactor: LendingPoolTransactor{contract: contract}, LendingPoolFilterer: LendingPoolFilterer{contract: contract}}, nil
|
||||
}
|
||||
|
||||
// NewLendingPoolCaller creates a new read-only instance of LendingPool, bound to a specific deployed contract.
|
||||
func NewLendingPoolCaller(address common.Address, caller bind.ContractCaller) (*LendingPoolCaller, error) {
|
||||
contract, err := bindLendingPool(address, caller, nil, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &LendingPoolCaller{contract: contract}, nil
|
||||
}
|
||||
|
||||
// NewLendingPoolTransactor creates a new write-only instance of LendingPool, bound to a specific deployed contract.
|
||||
func NewLendingPoolTransactor(address common.Address, transactor bind.ContractTransactor) (*LendingPoolTransactor, error) {
|
||||
contract, err := bindLendingPool(address, nil, transactor, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &LendingPoolTransactor{contract: contract}, nil
|
||||
}
|
||||
|
||||
// NewLendingPoolFilterer creates a new log filterer instance of LendingPool, bound to a specific deployed contract.
|
||||
func NewLendingPoolFilterer(address common.Address, filterer bind.ContractFilterer) (*LendingPoolFilterer, error) {
|
||||
contract, err := bindLendingPool(address, nil, nil, filterer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &LendingPoolFilterer{contract: contract}, nil
|
||||
}
|
||||
|
||||
// bindLendingPool binds a generic wrapper to an already deployed contract.
|
||||
func bindLendingPool(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {
|
||||
parsed, err := abi.JSON(strings.NewReader(LendingPoolABI))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil
|
||||
}
|
||||
|
||||
// Call invokes the (constant) contract method with params as input values and
|
||||
// sets the output to result. The result type might be a single field for simple
|
||||
// returns, a slice of interfaces for anonymous returns and a struct for named
|
||||
// returns.
|
||||
func (_LendingPool *LendingPoolRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
|
||||
return _LendingPool.Contract.LendingPoolCaller.contract.Call(opts, result, method, params...)
|
||||
}
|
||||
|
||||
// Transfer initiates a plain transaction to move funds to the contract, calling
|
||||
// its default method if one is available.
|
||||
func (_LendingPool *LendingPoolRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
|
||||
return _LendingPool.Contract.LendingPoolTransactor.contract.Transfer(opts)
|
||||
}
|
||||
|
||||
// Transact invokes the (paid) contract method with params as input values.
|
||||
func (_LendingPool *LendingPoolRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
|
||||
return _LendingPool.Contract.LendingPoolTransactor.contract.Transact(opts, method, params...)
|
||||
}
|
||||
|
||||
// Call invokes the (constant) contract method with params as input values and
|
||||
// sets the output to result. The result type might be a single field for simple
|
||||
// returns, a slice of interfaces for anonymous returns and a struct for named
|
||||
// returns.
|
||||
func (_LendingPool *LendingPoolCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
|
||||
return _LendingPool.Contract.contract.Call(opts, result, method, params...)
|
||||
}
|
||||
|
||||
// Transfer initiates a plain transaction to move funds to the contract, calling
|
||||
// its default method if one is available.
|
||||
func (_LendingPool *LendingPoolTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
|
||||
return _LendingPool.Contract.contract.Transfer(opts)
|
||||
}
|
||||
|
||||
// Transact invokes the (paid) contract method with params as input values.
|
||||
func (_LendingPool *LendingPoolTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
|
||||
return _LendingPool.Contract.contract.Transact(opts, method, params...)
|
||||
}
|
||||
|
||||
// GetUserAccountData is a free data retrieval call binding the contract method 0xbf92857c.
|
||||
//
|
||||
// Solidity: function getUserAccountData(address user) view returns(uint256 totalCollateralETH, uint256 totalDebtETH, uint256 availableBorrowsETH, uint256 currentLiquidationThreshold, uint256 ltv, uint256 healthFactor)
|
||||
func (_LendingPool *LendingPoolCaller) GetUserAccountData(opts *bind.CallOpts, user common.Address) (struct {
|
||||
TotalCollateralETH *big.Int
|
||||
TotalDebtETH *big.Int
|
||||
AvailableBorrowsETH *big.Int
|
||||
CurrentLiquidationThreshold *big.Int
|
||||
Ltv *big.Int
|
||||
HealthFactor *big.Int
|
||||
}, error) {
|
||||
var out []interface{}
|
||||
err := _LendingPool.contract.Call(opts, &out, "getUserAccountData", user)
|
||||
|
||||
outstruct := new(struct {
|
||||
TotalCollateralETH *big.Int
|
||||
TotalDebtETH *big.Int
|
||||
AvailableBorrowsETH *big.Int
|
||||
CurrentLiquidationThreshold *big.Int
|
||||
Ltv *big.Int
|
||||
HealthFactor *big.Int
|
||||
})
|
||||
if err != nil {
|
||||
return *outstruct, err
|
||||
}
|
||||
|
||||
outstruct.TotalCollateralETH = *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)
|
||||
outstruct.TotalDebtETH = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int)
|
||||
outstruct.AvailableBorrowsETH = *abi.ConvertType(out[2], new(*big.Int)).(**big.Int)
|
||||
outstruct.CurrentLiquidationThreshold = *abi.ConvertType(out[3], new(*big.Int)).(**big.Int)
|
||||
outstruct.Ltv = *abi.ConvertType(out[4], new(*big.Int)).(**big.Int)
|
||||
outstruct.HealthFactor = *abi.ConvertType(out[5], new(*big.Int)).(**big.Int)
|
||||
|
||||
return *outstruct, err
|
||||
|
||||
}
|
||||
|
||||
// GetUserAccountData is a free data retrieval call binding the contract method 0xbf92857c.
|
||||
//
|
||||
// Solidity: function getUserAccountData(address user) view returns(uint256 totalCollateralETH, uint256 totalDebtETH, uint256 availableBorrowsETH, uint256 currentLiquidationThreshold, uint256 ltv, uint256 healthFactor)
|
||||
func (_LendingPool *LendingPoolSession) GetUserAccountData(user common.Address) (struct {
|
||||
TotalCollateralETH *big.Int
|
||||
TotalDebtETH *big.Int
|
||||
AvailableBorrowsETH *big.Int
|
||||
CurrentLiquidationThreshold *big.Int
|
||||
Ltv *big.Int
|
||||
HealthFactor *big.Int
|
||||
}, error) {
|
||||
return _LendingPool.Contract.GetUserAccountData(&_LendingPool.CallOpts, user)
|
||||
}
|
||||
|
||||
// GetUserAccountData is a free data retrieval call binding the contract method 0xbf92857c.
|
||||
//
|
||||
// Solidity: function getUserAccountData(address user) view returns(uint256 totalCollateralETH, uint256 totalDebtETH, uint256 availableBorrowsETH, uint256 currentLiquidationThreshold, uint256 ltv, uint256 healthFactor)
|
||||
func (_LendingPool *LendingPoolCallerSession) GetUserAccountData(user common.Address) (struct {
|
||||
TotalCollateralETH *big.Int
|
||||
TotalDebtETH *big.Int
|
||||
AvailableBorrowsETH *big.Int
|
||||
CurrentLiquidationThreshold *big.Int
|
||||
Ltv *big.Int
|
||||
HealthFactor *big.Int
|
||||
}, error) {
|
||||
return _LendingPool.Contract.GetUserAccountData(&_LendingPool.CallOpts, user)
|
||||
}
|
||||
|
||||
// Borrow is a paid mutator transaction binding the contract method 0xa415bcad.
|
||||
//
|
||||
// Solidity: function borrow(address asset, uint256 amount, uint256 interestRateMode, uint16 referralCode, address onBehalfOf) returns()
|
||||
func (_LendingPool *LendingPoolTransactor) Borrow(opts *bind.TransactOpts, asset common.Address, amount *big.Int, interestRateMode *big.Int, referralCode uint16, onBehalfOf common.Address) (*types.Transaction, error) {
|
||||
return _LendingPool.contract.Transact(opts, "borrow", asset, amount, interestRateMode, referralCode, onBehalfOf)
|
||||
}
|
||||
|
||||
// Borrow is a paid mutator transaction binding the contract method 0xa415bcad.
|
||||
//
|
||||
// Solidity: function borrow(address asset, uint256 amount, uint256 interestRateMode, uint16 referralCode, address onBehalfOf) returns()
|
||||
func (_LendingPool *LendingPoolSession) Borrow(asset common.Address, amount *big.Int, interestRateMode *big.Int, referralCode uint16, onBehalfOf common.Address) (*types.Transaction, error) {
|
||||
return _LendingPool.Contract.Borrow(&_LendingPool.TransactOpts, asset, amount, interestRateMode, referralCode, onBehalfOf)
|
||||
}
|
||||
|
||||
// Borrow is a paid mutator transaction binding the contract method 0xa415bcad.
|
||||
//
|
||||
// Solidity: function borrow(address asset, uint256 amount, uint256 interestRateMode, uint16 referralCode, address onBehalfOf) returns()
|
||||
func (_LendingPool *LendingPoolTransactorSession) Borrow(asset common.Address, amount *big.Int, interestRateMode *big.Int, referralCode uint16, onBehalfOf common.Address) (*types.Transaction, error) {
|
||||
return _LendingPool.Contract.Borrow(&_LendingPool.TransactOpts, asset, amount, interestRateMode, referralCode, onBehalfOf)
|
||||
}
|
||||
|
||||
// Deposit is a paid mutator transaction binding the contract method 0xe8eda9df.
|
||||
//
|
||||
// Solidity: function deposit(address asset, uint256 amount, address onBehalfOf, uint16 referralCode) returns()
|
||||
func (_LendingPool *LendingPoolTransactor) Deposit(opts *bind.TransactOpts, asset common.Address, amount *big.Int, onBehalfOf common.Address, referralCode uint16) (*types.Transaction, error) {
|
||||
return _LendingPool.contract.Transact(opts, "deposit", asset, amount, onBehalfOf, referralCode)
|
||||
}
|
||||
|
||||
// Deposit is a paid mutator transaction binding the contract method 0xe8eda9df.
|
||||
//
|
||||
// Solidity: function deposit(address asset, uint256 amount, address onBehalfOf, uint16 referralCode) returns()
|
||||
func (_LendingPool *LendingPoolSession) Deposit(asset common.Address, amount *big.Int, onBehalfOf common.Address, referralCode uint16) (*types.Transaction, error) {
|
||||
return _LendingPool.Contract.Deposit(&_LendingPool.TransactOpts, asset, amount, onBehalfOf, referralCode)
|
||||
}
|
||||
|
||||
// Deposit is a paid mutator transaction binding the contract method 0xe8eda9df.
|
||||
//
|
||||
// Solidity: function deposit(address asset, uint256 amount, address onBehalfOf, uint16 referralCode) returns()
|
||||
func (_LendingPool *LendingPoolTransactorSession) Deposit(asset common.Address, amount *big.Int, onBehalfOf common.Address, referralCode uint16) (*types.Transaction, error) {
|
||||
return _LendingPool.Contract.Deposit(&_LendingPool.TransactOpts, asset, amount, onBehalfOf, referralCode)
|
||||
}
|
||||
|
||||
// Repay is a paid mutator transaction binding the contract method 0x573ade81.
|
||||
//
|
||||
// Solidity: function repay(address asset, uint256 amount, uint256 rateMode, address onBehalfOf) returns(uint256)
|
||||
func (_LendingPool *LendingPoolTransactor) Repay(opts *bind.TransactOpts, asset common.Address, amount *big.Int, rateMode *big.Int, onBehalfOf common.Address) (*types.Transaction, error) {
|
||||
return _LendingPool.contract.Transact(opts, "repay", asset, amount, rateMode, onBehalfOf)
|
||||
}
|
||||
|
||||
// Repay is a paid mutator transaction binding the contract method 0x573ade81.
|
||||
//
|
||||
// Solidity: function repay(address asset, uint256 amount, uint256 rateMode, address onBehalfOf) returns(uint256)
|
||||
func (_LendingPool *LendingPoolSession) Repay(asset common.Address, amount *big.Int, rateMode *big.Int, onBehalfOf common.Address) (*types.Transaction, error) {
|
||||
return _LendingPool.Contract.Repay(&_LendingPool.TransactOpts, asset, amount, rateMode, onBehalfOf)
|
||||
}
|
||||
|
||||
// Repay is a paid mutator transaction binding the contract method 0x573ade81.
|
||||
//
|
||||
// Solidity: function repay(address asset, uint256 amount, uint256 rateMode, address onBehalfOf) returns(uint256)
|
||||
func (_LendingPool *LendingPoolTransactorSession) Repay(asset common.Address, amount *big.Int, rateMode *big.Int, onBehalfOf common.Address) (*types.Transaction, error) {
|
||||
return _LendingPool.Contract.Repay(&_LendingPool.TransactOpts, asset, amount, rateMode, onBehalfOf)
|
||||
}
|
||||
|
||||
// Withdraw is a paid mutator transaction binding the contract method 0x69328dec.
|
||||
//
|
||||
// Solidity: function withdraw(address asset, uint256 amount, address to) returns(uint256)
|
||||
func (_LendingPool *LendingPoolTransactor) Withdraw(opts *bind.TransactOpts, asset common.Address, amount *big.Int, to common.Address) (*types.Transaction, error) {
|
||||
return _LendingPool.contract.Transact(opts, "withdraw", asset, amount, to)
|
||||
}
|
||||
|
||||
// Withdraw is a paid mutator transaction binding the contract method 0x69328dec.
|
||||
//
|
||||
// Solidity: function withdraw(address asset, uint256 amount, address to) returns(uint256)
|
||||
func (_LendingPool *LendingPoolSession) Withdraw(asset common.Address, amount *big.Int, to common.Address) (*types.Transaction, error) {
|
||||
return _LendingPool.Contract.Withdraw(&_LendingPool.TransactOpts, asset, amount, to)
|
||||
}
|
||||
|
||||
// Withdraw is a paid mutator transaction binding the contract method 0x69328dec.
|
||||
//
|
||||
// Solidity: function withdraw(address asset, uint256 amount, address to) returns(uint256)
|
||||
func (_LendingPool *LendingPoolTransactorSession) Withdraw(asset common.Address, amount *big.Int, to common.Address) (*types.Transaction, error) {
|
||||
return _LendingPool.Contract.Withdraw(&_LendingPool.TransactOpts, asset, amount, to)
|
||||
}
|
21
aave/contracts/lendingpool.sol
Normal file
21
aave/contracts/lendingpool.sol
Normal file
@ -0,0 +1,21 @@
|
||||
pragma solidity >=0.6.0;
|
||||
|
||||
interface ILendingPool {
|
||||
|
||||
function deposit(address asset, uint256 amount, address onBehalfOf, uint16 referralCode) external;
|
||||
|
||||
function borrow(address asset, uint256 amount, uint256 interestRateMode, uint16 referralCode, address onBehalfOf) external;
|
||||
|
||||
function repay(address asset, uint256 amount, uint256 rateMode, address onBehalfOf) external returns (uint256);
|
||||
|
||||
function withdraw(address asset, uint256 amount, address to) external returns (uint256);
|
||||
|
||||
function getUserAccountData(address user) external view returns (
|
||||
uint256 totalCollateralETH,
|
||||
uint256 totalDebtETH,
|
||||
uint256 availableBorrowsETH,
|
||||
uint256 currentLiquidationThreshold,
|
||||
uint256 ltv,
|
||||
uint256 healthFactor
|
||||
);
|
||||
}
|
62
aave/dataprovider.go
Normal file
62
aave/dataprovider.go
Normal file
@ -0,0 +1,62 @@
|
||||
package aave
|
||||
|
||||
import (
|
||||
"git.lehouerou.net/laurent/evm"
|
||||
"git.lehouerou.net/laurent/evm/aave/contracts"
|
||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/shopspring/decimal"
|
||||
)
|
||||
|
||||
type DataProvider struct {
|
||||
client evm.Client
|
||||
contract *contracts.DataProvider
|
||||
}
|
||||
|
||||
func NewDataProvider(client evm.Client, address common.Address) (*DataProvider, error) {
|
||||
contract, err := contracts.NewDataProvider(address, client)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "init contract")
|
||||
}
|
||||
|
||||
return &DataProvider{
|
||||
client: client,
|
||||
contract: contract,
|
||||
}, nil
|
||||
}
|
||||
|
||||
type UserReserveData struct {
|
||||
CurrentATokenBalance decimal.Decimal
|
||||
CurrentStableDebt decimal.Decimal
|
||||
CurrentVariableDebt decimal.Decimal
|
||||
PrincipalStableDebt decimal.Decimal
|
||||
ScaledVariableDebt decimal.Decimal
|
||||
StableBorrowRate decimal.Decimal
|
||||
LiquidityRate decimal.Decimal
|
||||
StableRateLastUpdated decimal.Decimal
|
||||
UsageAsCollateralEnabled bool
|
||||
}
|
||||
|
||||
func (d *DataProvider) UserReserveData(asset common.Address, address common.Address) (UserReserveData, error) {
|
||||
token, err := d.client.TokenService().TokenByAddress(asset)
|
||||
if err != nil {
|
||||
return UserReserveData{}, errors.Wrap(err, "get token")
|
||||
}
|
||||
rd, err := d.contract.GetUserReserveData(&bind.CallOpts{}, asset, address)
|
||||
if err != nil {
|
||||
return UserReserveData{}, errors.Wrap(err, "calling contract")
|
||||
}
|
||||
|
||||
return UserReserveData{
|
||||
CurrentATokenBalance: token.ValueFromBigInt(rd.CurrentATokenBalance),
|
||||
CurrentStableDebt: token.ValueFromBigInt(rd.CurrentStableDebt),
|
||||
CurrentVariableDebt: token.ValueFromBigInt(rd.CurrentVariableDebt),
|
||||
PrincipalStableDebt: token.ValueFromBigInt(rd.PrincipalStableDebt),
|
||||
ScaledVariableDebt: token.ValueFromBigInt(rd.ScaledVariableDebt),
|
||||
StableBorrowRate: token.ValueFromBigInt(rd.StableBorrowRate),
|
||||
LiquidityRate: token.ValueFromBigInt(rd.LiquidityRate),
|
||||
StableRateLastUpdated: token.ValueFromBigInt(rd.StableRateLastUpdated),
|
||||
UsageAsCollateralEnabled: rd.UsageAsCollateralEnabled,
|
||||
}, nil
|
||||
}
|
89
aave/lendingpool.go
Normal file
89
aave/lendingpool.go
Normal file
@ -0,0 +1,89 @@
|
||||
package aave
|
||||
|
||||
import (
|
||||
"context"
|
||||
"math/big"
|
||||
|
||||
"git.lehouerou.net/laurent/evm"
|
||||
"git.lehouerou.net/laurent/evm/aave/contracts"
|
||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/shopspring/decimal"
|
||||
)
|
||||
|
||||
type LendingPool struct {
|
||||
client evm.Client
|
||||
contract *contracts.LendingPool
|
||||
}
|
||||
|
||||
func NewLendingPool(client evm.Client, address common.Address) (*LendingPool, error) {
|
||||
contract, err := contracts.NewLendingPool(address, client)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "init contract")
|
||||
}
|
||||
|
||||
return &LendingPool{
|
||||
client: client,
|
||||
contract: contract,
|
||||
}, nil
|
||||
}
|
||||
|
||||
type UserAccountData struct {
|
||||
TotalCollateralETH decimal.Decimal
|
||||
TotalDebtETH decimal.Decimal
|
||||
AvailableBorrowsETH decimal.Decimal
|
||||
CurrentLiquidationThreshold decimal.Decimal
|
||||
CurrentLtv decimal.Decimal
|
||||
MaxLtv decimal.Decimal
|
||||
HealthFactor decimal.Decimal
|
||||
}
|
||||
|
||||
func (uad UserAccountData) BorrowAmountToLtv(ltv decimal.Decimal) decimal.Decimal {
|
||||
return uad.TotalCollateralETH.Mul(ltv).Div(decimal.NewFromInt(100)).Sub(uad.TotalDebtETH)
|
||||
}
|
||||
|
||||
func (lp *LendingPool) UserAccountDataForAddress(address common.Address) (UserAccountData, error) {
|
||||
uad, err := lp.contract.GetUserAccountData(&bind.CallOpts{}, address)
|
||||
if err != nil {
|
||||
return UserAccountData{}, errors.Wrap(err, "calling contract")
|
||||
}
|
||||
res := UserAccountData{
|
||||
TotalCollateralETH: decimal.NewFromBigInt(uad.TotalCollateralETH, -8),
|
||||
TotalDebtETH: decimal.NewFromBigInt(uad.TotalDebtETH, -8),
|
||||
AvailableBorrowsETH: decimal.NewFromBigInt(uad.AvailableBorrowsETH, -8),
|
||||
CurrentLiquidationThreshold: decimal.NewFromBigInt(uad.CurrentLiquidationThreshold, -2),
|
||||
MaxLtv: decimal.NewFromBigInt(uad.Ltv, -2),
|
||||
HealthFactor: decimal.NewFromBigInt(uad.HealthFactor, -18),
|
||||
}
|
||||
res.CurrentLtv = res.TotalDebtETH.Div(res.TotalCollateralETH).Mul(decimal.NewFromInt(100))
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (lp *LendingPool) Borrow(ctx context.Context, asset common.Address, amount decimal.Decimal) (evm.Transaction, error) {
|
||||
token, err := lp.client.TokenService().TokenByAddress(asset)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "getting token")
|
||||
}
|
||||
return lp.client.Execute(ctx, func(ctx context.Context, opts *evm.TransactOpts) (*types.Transaction, error) {
|
||||
return lp.contract.Borrow(opts.TransactOpts, asset, token.ValueToBigInt(amount), big.NewInt(2), 0, lp.client.PublicAddress())
|
||||
})
|
||||
}
|
||||
|
||||
func (lp *LendingPool) Repay(ctx context.Context, asset common.Address, amount decimal.Decimal) (evm.Transaction, error) {
|
||||
token, err := lp.client.TokenService().TokenByAddress(asset)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "getting token")
|
||||
}
|
||||
balance, err := token.Balance()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "getting token balance")
|
||||
}
|
||||
if balance.LessThan(amount) {
|
||||
return nil, errors.Wrapf(err, "balance of %s insufficient. need %s have %s", token.Symbol(), amount, balance)
|
||||
}
|
||||
return lp.client.Execute(ctx, func(ctx context.Context, opts *evm.TransactOpts) (*types.Transaction, error) {
|
||||
return lp.contract.Repay(opts.TransactOpts, asset, token.ValueToBigInt(amount), big.NewInt(2), lp.client.PublicAddress())
|
||||
})
|
||||
}
|
@ -62,6 +62,7 @@ var tokens = map[string]string{
|
||||
"xJOE": "0x57319d41f71e81f3c65f2a47ca4e001ebafd4f33",
|
||||
"WETH.e": "0x49d5c2bdffac6ce2bfdb6640f4f80f226bc10bab",
|
||||
"WBTC.e": "0x50b7545627a5162F82A992c33b87aDc75187B218",
|
||||
"USDC.e": "0xa7d7079b0fead91f3e65f86e8915cb59c1a4c664",
|
||||
}
|
||||
|
||||
func NewTokenMapper() evm.TokenMapper {
|
||||
@ -72,5 +73,6 @@ func NewTokenMapper() evm.TokenMapper {
|
||||
|
||||
tm.AddAlias("ETH", "WETH.e")
|
||||
tm.AddAlias("BTC", "WBTC.e")
|
||||
tm.AddAlias("USDC", "USDC.e")
|
||||
return tm
|
||||
}
|
||||
|
@ -3,8 +3,10 @@ package beefy
|
||||
import (
|
||||
"git.lehouerou.net/laurent/evm"
|
||||
"git.lehouerou.net/laurent/evm/beefy/contracts"
|
||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/shopspring/decimal"
|
||||
)
|
||||
|
||||
type VaultV6 struct {
|
||||
@ -29,3 +31,11 @@ func NewVaultV6(client evm.Client, address common.Address) (*VaultV6, error) {
|
||||
Token: token,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (v *VaultV6) PricePerFullShare() (decimal.Decimal, error) {
|
||||
ppfs, err := v.contract.GetPricePerFullShare(&bind.CallOpts{})
|
||||
if err != nil {
|
||||
return decimal.Zero, errors.Wrap(err, "calling contract")
|
||||
}
|
||||
return v.ValueFromBigInt(ppfs), nil
|
||||
}
|
||||
|
50
curve/Pool.go
Normal file
50
curve/Pool.go
Normal file
@ -0,0 +1,50 @@
|
||||
package curve
|
||||
|
||||
import (
|
||||
"git.lehouerou.net/laurent/evm"
|
||||
"git.lehouerou.net/laurent/evm/curve/contracts"
|
||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/shopspring/decimal"
|
||||
)
|
||||
|
||||
type Pool struct {
|
||||
client evm.Client
|
||||
contract *contracts.Pool
|
||||
|
||||
lptoken evm.Token
|
||||
tokens []evm.Token
|
||||
}
|
||||
|
||||
func NewPool(client evm.Client, address common.Address) (*Pool, error) {
|
||||
contract, err := contracts.NewPool(address, client)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "init contract")
|
||||
}
|
||||
|
||||
lptokenaddress, err := contract.LpToken(&bind.CallOpts{})
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "getting lp token address")
|
||||
}
|
||||
lptoken, err := client.TokenService().TokenByAddress(lptokenaddress)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "getting lp token")
|
||||
}
|
||||
return &Pool{
|
||||
client: client,
|
||||
contract: contract,
|
||||
lptoken: lptoken,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (p *Pool) VirtualPrice() (decimal.Decimal, error) {
|
||||
price, err := p.contract.GetVirtualPrice(&bind.CallOpts{})
|
||||
if err != nil {
|
||||
return decimal.Zero, errors.Wrap(err, "calling contract")
|
||||
}
|
||||
|
||||
return decimal.NewFromBigInt(price, -18), nil
|
||||
}
|
||||
|
||||
//func (p *Pool) CalculateTokenAmount(amounts []decimal.Decimal)
|
1
curve/contracts/pool.abi
Normal file
1
curve/contracts/pool.abi
Normal file
File diff suppressed because one or more lines are too long
3341
curve/contracts/pool.go
Normal file
3341
curve/contracts/pool.go
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user