Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

type.gno

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