Search Apps Documentation Source Content File Folder Download Copy Actions Download

type.gno

3.50 Kb · 102 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	caller     address    // address to call the function
 65}
 66
 67type MintInput struct {
 68	token0         string
 69	token1         string
 70	fee            uint32
 71	tickLower      int32
 72	tickUpper      int32
 73	amount0Desired string
 74	amount1Desired string
 75	amount0Min     string
 76	amount1Min     string
 77	deadline       int64
 78	mintTo         address
 79	caller         address
 80}
 81
 82type TokenPair struct {
 83	token0 string
 84	token1 string
 85}
 86
 87type ProcessedMintInput struct {
 88	tokenPair      TokenPair
 89	amount0Desired *u256.Uint
 90	amount1Desired *u256.Uint
 91	amount0Min     *u256.Uint
 92	amount1Min     *u256.Uint
 93	tickLower      int32
 94	tickUpper      int32
 95	poolPath       string
 96}
 97
 98// FeeGrowthInside represents fee growth inside ticks
 99type FeeGrowthInside struct {
100	feeGrowthInside0LastX128 *u256.Uint
101	feeGrowthInside1LastX128 *u256.Uint
102}