uniswap

package
v0.0.0-...-27df293 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ERC20DeployedContract

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

type EthManager

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

func (*EthManager) AddTestCase

func (m *EthManager) AddTestCase(tc ...TestCase)

func (*EthManager) Configure

func (m *EthManager) Configure(cfg *conf.EthCaseConf, evmCfg *evm.GethConfig)

func (*EthManager) PreCreateWallets

func (m *EthManager) PreCreateWallets(walletCount int, initCount uint64) ([]*pkg.EthWallet, error)

func (*EthManager) Prepare

func (m *EthManager) Prepare(ctx context.Context) error

func (*EthManager) Run

func (m *EthManager) Run(ctx context.Context) error

type SwapStep

type SwapStep struct {
	User     *pkg.EthWallet
	TokenIn  common.Address
	TokenOut common.Address
	AmountIn *big.Int
	Router   common.Address
}

type TPSStats

type TPSStats struct {
	TPS              float64
	BlockCount       int
	TimeInterval     uint64
	TransactionCount int
	StartBlockNumber *big.Int
}

type TestCase

type TestCase interface {
	Prepare(ctx context.Context, m *pkg.WalletManager) error
	Run(ctx context.Context, m *pkg.WalletManager) error
	Name() string
}

type TestContract

type TestContract struct {
	UniswapV2Router common.Address      `json:"uniswapV2Router"`
	TokenPairs      [][2]common.Address `json:"tokenPairs"`
}

type TestData

type TestData struct {
	TestUsers     []*pkg.EthWallet `json:"testUsers"`
	TestContracts []TestContract
}

type UniswapV2AccuracyTestCase

type UniswapV2AccuracyTestCase struct {
	CaseName string
	// contains filtered or unexported fields
}

func NewUniswapV2AccuracyTestCase

func NewUniswapV2AccuracyTestCase(name string, count int, initial uint64) *UniswapV2AccuracyTestCase

func (*UniswapV2AccuracyTestCase) Name

func (ca *UniswapV2AccuracyTestCase) Name() string

func (*UniswapV2AccuracyTestCase) Prepare

func (*UniswapV2AccuracyTestCase) Run

type UniswapV2DeployedContracts

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

type UniswapV2TPSStatisticsTestCase

type UniswapV2TPSStatisticsTestCase struct {
	MaxUsers      int
	NonConflict   bool
	TestUsers     int
	DeployedUsers int

	CaseName string
	// contains filtered or unexported fields
}

func NewUniswapV2TPSStatisticsTestCase

func NewUniswapV2TPSStatisticsTestCase(name string, t, d, maxUser int, rm *rate.Limiter, needLoad, nonConflict bool) *UniswapV2TPSStatisticsTestCase

func (*UniswapV2TPSStatisticsTestCase) Name

func (*UniswapV2TPSStatisticsTestCase) Prepare

func (*UniswapV2TPSStatisticsTestCase) Run

Run TestUniswapTPS is a test case to measure the transactions per second (TPS) of Uniswap. The test case follows these steps: 1. Arrange

  • Create a deployer user with sufficient balance
  • Create multiple test users with initial balance
  • Deploy Uniswap core contracts (WETH9, UniswapV2Factory, UniswapV2Router01)
  • Deploy a set of ERC20 token contracts
  • Approve the router contract to spend tokens on behalf of test users
  • Distribute the test tokens to each test user
  • Generate all possible token pairs from the deployed ERC20 tokens
  • Add liquidity to the token pairs on Uniswap

2. Act

  • Each test user performs a series of token swaps on Uniswap
  • The swaps are performed concurrently to simulate real-world usage

3. Assert

  • Calculate and report the transactions per second (TPS) achieved during the test

Jump to

Keyboard shortcuts

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