Documentation ¶
Index ¶
- Variables
- func GetAmountsOut(price, lpValue, lowerPrice, upperPrice float64) (float64, float64)
- func GetInitializedTickAtPrice(price float64, tickSpace int) int64
- func GetPriceAtTick(tick int64) float64
- func GetTickAtPrice(price float64) int64
- type Pool
- type PoolManager
- type PoolOpts
- type PoolState
- type UniswapV3
- func (v3 *UniswapV3) GetPool(ctx context.Context, token0, token1 common.Address, fee int64) (*Pool, error)
- func (v3 *UniswapV3) GetPoolAddress(ctx context.Context, token0, token1 common.Address, fee int64) (common.Address, error)
- func (v3 *UniswapV3) GetPrice(ctx context.Context, token0, token1 common.Address, fee int64) (float64, error)
- func (v3 *UniswapV3) UpdateCachedPoolStates(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrPoolNotFound = errors.New("uniswap v3 factory: pool not found")
)
View Source
var (
ErrWrongToken = errors.New("uniswap v3 pool: PriceOf: token not in pool")
)
Functions ¶
func GetAmountsOut ¶
Gets the amounts out for the current price and lpValue, given the lower and upper price bounds of the position.
func GetInitializedTickAtPrice ¶
Gets the initialized tick at a price given the tickspace. 5bps -> 10, 30bps -> 60, 100bps -> 200
Types ¶
type Pool ¶
type Pool struct { Name string Address common.Address Immutables PoolOpts State PoolState // The last known Pool State // contains filtered or unexported fields }
func (*Pool) UpdateState ¶
UpdateState updates the internal pool state. Should be called every time the state changes on-chain i.e. on a new block. Note that cached pools should have their states refreshed as well. TODO: accept context
type PoolManager ¶
type UniswapV3 ¶
type UniswapV3 struct { Client *ethclient.Client PoolAddressCache db.Cacher // Holds the pool addresses for different assets and fee tiers PoolCache db.Cacher // Holds the actual pools in a chained cache (checks memory first, then leveldb on disk) Factory *univ3factory.Univ3factoryCaller Opts db.Opts // Holds options // contains filtered or unexported fields }
func New ¶
func New(client *ethclient.Client, tokenManager token.TokenManager, factoryAddress common.Address, opts db.Opts) *UniswapV3
Returns a UniswapV3 instance.
func (*UniswapV3) GetPoolAddress ¶
func (*UniswapV3) UpdateCachedPoolStates ¶
UpdateCachedPoolStates should get called once the chain state updates, i.e. on a new block. It retrieves all the pools from the cache, updates their states and writes them to cache again.
Click to show internal directories.
Click to hide internal directories.