uniswapv2

package
v0.0.1-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dex

type Dex struct {
	// contains filtered or unexported fields
}

Dex represents an UniswapV2 DEX (pair)

func NewDex

func NewDex(fee *uint256.Int) *Dex

NewDex creates a new UniswapV2 DEX that holds all the needed information

fee represents the uni2-fork fee in a representation like 30 = 0,3%

func (*Dex) GetAmountIn

func (d *Dex) GetAmountIn(amountOut *uint256.Int, zeroForOne bool) *uint256.Int

GetAmountIn calculates the amount you need to give to receive the amount you want to get zeroForOne is used to check if you want to get token0 for token1 or the other one

func (*Dex) GetAmountOut

func (d *Dex) GetAmountOut(amountIn *uint256.Int, zeroForOne bool) *uint256.Int

GetAmountOut calculates the amount you will receive for the amount you give in zeroForOne is used to check if you want to give in token0 or token1 to receive the other one

func (*Dex) GetReserves

func (d *Dex) GetReserves() (reserve0, reserve1 *uint256.Int)

GetReserves get the current Dex reserves

func (*Dex) SetReserves

func (d *Dex) SetReserves(reserve0, reserve1 *uint256.Int)

SetReserves sets the Dex reserves

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL