uniswapv3loadtest

package
v0.1.64 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Only a few fee tiers are possible in UniswapV3. They are represented in percentage.
	// https://uniswapv3book.com/docs/milestone_5/swap-fees/#accruing-swap-fees
	StableTier   feeTier = 0.05 // 500
	StandardTier feeTier = 0.3  // 3_000
	ExoticTier   feeTier = 1    // 10_000
)
View Source
var (
	// The amount of token to mint when deploying the ERC20 contract.
	MintAmount = big.NewInt(999_999_999_999_999_999)
)
View Source
var SwapAmountInput = big.NewInt(1_000)

The amount of inbound token given as swap input.

Functions

func ExactInputSingleSwap

func ExactInputSingleSwap(tops *bind.TransactOpts, swapRouter *uniswapv3.SwapRouter02, poolConfig PoolConfig, amountIn *big.Int, recipient common.Address, nonce uint64) error

ExactInputSingleSwap performs a UniswapV3 swap using the `ExactInputSingle` method which swaps a fixed amount of one token for a maximum possible amount of another token. The direction of the swap is determined by the nonce value.

func PercentageToUniswapFeeTier

func PercentageToUniswapFeeTier(p float64) *big.Int

PercentageToUniswapFeeTier takes a percentage and returns the corresponding UniswapV3 fee tier.

func SetupLiquidityPool

func SetupLiquidityPool(ctx context.Context, c *ethclient.Client, tops *bind.TransactOpts, cops *bind.CallOpts, uniswapV3Config UniswapV3Config, poolConfig PoolConfig, recipient common.Address) error

SetupLiquidityPool sets up a UniswapV3 liquidity pool, creating and initializing it if needed, and providing liquidity in case none exists.

Types

type ContractConfig

type ContractConfig[T Contract] struct {
	Address  common.Address
	Contract *T
}

ContractConfig represents a contract and its address.

func DeployERC20

func DeployERC20(ctx context.Context, c *ethclient.Client, tops *bind.TransactOpts, cops *bind.CallOpts, uniswapV3Config UniswapV3Config, tokenName, tokenSymbol string, amount *big.Int, recipient common.Address, tokenKnownAddress common.Address) (tokenConfig ContractConfig[uniswapv3.Swapper], err error)

Deploy an ERC20 token.

type PoolConfig

type PoolConfig struct {
	Token0, Token1     ContractConfig[uniswapv3.Swapper]
	ReserveA, ReserveB *big.Int
	Fees               *big.Int
}

PoolConfig represents the configuration of a UniswapV3 pool.

func NewPool

func NewPool(token0, token1 ContractConfig[uniswapv3.Swapper], fees *big.Int) *PoolConfig

Create a new `PoolConfig` object.

type UniswapV3Addresses

type UniswapV3Addresses struct {
	FactoryV3, Multicall, ProxyAdmin, TickLens, NFTDescriptorLib, NonfungibleTokenPositionDescriptor, TransparentUpgradeableProxy, NonfungiblePositionManager, Migrator, Staker, QuoterV2, SwapRouter02, WETH9 common.Address
}

UniswapV3Addresses is a subset of UniswapV3Config. It represents the addresses of the whole UniswapV3 configuration, including WETH9.

type UniswapV3Config

UniswapV3Config represents the whole UniswapV3 configuration (contracts and addresses), including WETH9.

func DeployUniswapV3

func DeployUniswapV3(ctx context.Context, c *ethclient.Client, tops *bind.TransactOpts, cops *bind.CallOpts, knownAddresses UniswapV3Addresses, ownerAddress common.Address) (config UniswapV3Config, err error)

Deploy the full UniswapV3 contract suite in 15 different steps. Source: https://github.com/Uniswap/deploy-v3

func (*UniswapV3Config) GetAddresses

func (c *UniswapV3Config) GetAddresses() UniswapV3Addresses

Return contracts addresses from the UniswapV3 configuration.

Jump to

Keyboard shortcuts

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