Search Apps Documentation Source Content File Folder Download Copy Actions Download

type.gno

3.67 Kb ยท 106 lines
  1package v1
  2
  3import (
  4	u256 "gno.land/p/gnoswap/uint256"
  5)
  6
  7// 2 ** 128
  8var q128 = u256.MustFromDecimal("340282366920938463463374607431768211456")
  9
 10// Previously, we used a different zero address ("g1000000..."),
 11// but we changed the value because using the address
 12// below appears to have become the de facto standard practice.
 13var zeroAddress address = address("")
 14
 15type MintParams struct {
 16	token0         string     // token0 path for a specific pool
 17	token1         string     // token1 path for a specific pool
 18	fee            uint32     // fee for a specific pool
 19	tickLower      int32      // lower end of the tick range for the position
 20	tickUpper      int32      // upper end of the tick range for the position
 21	amount0Desired *u256.Uint // desired amount of token0 to be minted
 22	amount1Desired *u256.Uint // desired amount of token1 to be minted
 23	amount0Min     *u256.Uint // minimum amount of token0 to be minted
 24	amount1Min     *u256.Uint // minimum amount of token1 to be minted
 25	deadline       int64      // time by which the transaction must be included to effect the change
 26	mintTo         address    // address to mint lpToken
 27	caller         address    // address to call the function
 28}
 29
 30// newMintParams creates `MintParams` from processed input data.
 31func newMintParams(input ProcessedMintInput, mintInput MintInput) MintParams {
 32	return MintParams{
 33		token0:         input.tokenPair.token0,
 34		token1:         input.tokenPair.token1,
 35		fee:            mintInput.fee,
 36		tickLower:      input.tickLower,
 37		tickUpper:      input.tickUpper,
 38		amount0Desired: input.amount0Desired,
 39		amount1Desired: input.amount1Desired,
 40		amount0Min:     input.amount0Min,
 41		amount1Min:     input.amount1Min,
 42		deadline:       mintInput.deadline,
 43		mintTo:         mintInput.mintTo,
 44		caller:         mintInput.caller,
 45	}
 46}
 47
 48type IncreaseLiquidityParams struct {
 49	positionId     uint64     // positionId of the position to increase liquidity
 50	amount0Desired *u256.Uint // desired amount of token0 to be minted
 51	amount1Desired *u256.Uint // desired amount of token1 to be minted
 52	amount0Min     *u256.Uint // minimum amount of token0 to be minted
 53	amount1Min     *u256.Uint // minimum amount of token1 to be minted
 54	deadline       int64      // time by which the transaction must be included to effect the change
 55	caller         address    // address to call the function
 56}
 57
 58type DecreaseLiquidityParams struct {
 59	positionId   uint64     // positionId of the position to decrease liquidity
 60	liquidity    string     // amount of liquidity to decrease
 61	amount0Min   *u256.Uint // minimum amount of token0 to be minted
 62	amount1Min   *u256.Uint // minimum amount of token1 to be minted
 63	deadline     int64      // time by which the transaction must be included to effect the change
 64	unwrapResult bool       // whether to unwrap the token if it's wrapped native token
 65	caller       address    // address to call the function
 66}
 67
 68type MintInput struct {
 69	token0         string
 70	token1         string
 71	fee            uint32
 72	tickLower      int32
 73	tickUpper      int32
 74	amount0Desired string
 75	amount1Desired string
 76	amount0Min     string
 77	amount1Min     string
 78	deadline       int64
 79	mintTo         address
 80	caller         address
 81}
 82
 83type TokenPair struct {
 84	token0         string
 85	token1         string
 86	token0IsNative bool
 87	token1IsNative bool
 88	wrappedAmount  int64
 89}
 90
 91type ProcessedMintInput struct {
 92	tokenPair      TokenPair
 93	amount0Desired *u256.Uint
 94	amount1Desired *u256.Uint
 95	amount0Min     *u256.Uint
 96	amount1Min     *u256.Uint
 97	tickLower      int32
 98	tickUpper      int32
 99	poolPath       string
100}
101
102// FeeGrowthInside represents fee growth inside ticks
103type FeeGrowthInside struct {
104	feeGrowthInside0LastX128 *u256.Uint
105	feeGrowthInside1LastX128 *u256.Uint
106}