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

proxy.gno

7.58 Kb · 180 lines
  1package position
  2
  3// Mint creates a new liquidity position NFT.
  4//
  5// Parameters:
  6//   - cur: current realm context; callers use cross(cur) when crossing into this realm
  7//   - token0: path of the first token in the pool
  8//   - token1: path of the second token in the pool
  9//   - fee: pool fee tier used to identify the pool
 10//   - tickLower: lower tick boundary of the position's price range
 11//   - tickUpper: upper tick boundary of the position's price range
 12//   - amount0Desired: desired amount of token0 to provide
 13//   - amount1Desired: desired amount of token1 to provide
 14//   - amount0Min: minimum acceptable amount of token0 after price/slippage calculation
 15//   - amount1Min: minimum acceptable amount of token1 after price/slippage calculation
 16//   - deadline: transaction expiration timestamp
 17//   - mintTo: recipient address of the position NFT
 18//   - referrer: referrer identifier used for reward tracking
 19//
 20// Returns:
 21//   - positionId: newly minted position NFT token ID
 22//   - liquidity: liquidity minted into the position, represented as a decimal string
 23//   - amount0: actual amount of token0 added to the position, represented as a decimal string
 24//   - amount1: actual amount of token1 added to the position, represented as a decimal string
 25//
 26// Halt check: reverts while the Position halt scope is active.
 27func Mint(
 28	cur realm,
 29	token0 string,
 30	token1 string,
 31	fee uint32,
 32	tickLower int32,
 33	tickUpper int32,
 34	amount0Desired string,
 35	amount1Desired string,
 36	amount0Min string,
 37	amount1Min string,
 38	deadline int64,
 39	mintTo address,
 40	referrer string,
 41) (uint64, string, string, string) {
 42	return getImplementation().Mint(0, cur, token0, token1, fee, tickLower, tickUpper, amount0Desired, amount1Desired, amount0Min, amount1Min, deadline, mintTo, referrer)
 43}
 44
 45// IncreaseLiquidity adds liquidity to an existing position.
 46//
 47// Parameters:
 48//   - cur: current realm context; callers use cross(cur) when crossing into this realm
 49//   - positionId: position NFT token ID to increase
 50//   - amount0DesiredStr: desired token0 amount, represented as a decimal string
 51//   - amount1DesiredStr: desired token1 amount, represented as a decimal string
 52//   - amount0MinStr: minimum acceptable token0 amount for slippage protection
 53//   - amount1MinStr: minimum acceptable token1 amount for slippage protection
 54//   - deadline: transaction expiration timestamp
 55//
 56// Returns:
 57//   - positionId: position NFT token ID that received the liquidity
 58//   - liquidity: liquidity amount added to the position (the delta), represented as a decimal string
 59//   - amount0: actual token0 amount added, represented as a decimal string
 60//   - amount1: actual token1 amount added, represented as a decimal string
 61//   - poolKey: canonical pool key for the position
 62//
 63// Halt check: reverts while the Position halt scope is active.
 64func IncreaseLiquidity(
 65	cur realm,
 66	positionId uint64,
 67	amount0DesiredStr string,
 68	amount1DesiredStr string,
 69	amount0MinStr string,
 70	amount1MinStr string,
 71	deadline int64,
 72) (uint64, string, string, string, string) {
 73	return getImplementation().IncreaseLiquidity(0, cur, positionId, amount0DesiredStr, amount1DesiredStr, amount0MinStr, amount1MinStr, deadline)
 74}
 75
 76// DecreaseLiquidity removes liquidity from a position.
 77//
 78// Parameters:
 79//   - cur: current realm context; callers use cross(cur) when crossing into this realm
 80//   - positionId: position NFT token ID to decrease
 81//   - liquidityStr: liquidity amount to remove, represented as a decimal string
 82//   - amount0MinStr: minimum acceptable token0 amount for slippage protection
 83//   - amount1MinStr: minimum acceptable token1 amount for slippage protection
 84//   - deadline: transaction expiration timestamp
 85//
 86// The accrued swap fees are collected first, so the returned fee amounts are
 87// net of the withdrawal fee while the returned principal is not subject to it.
 88//
 89// Returns:
 90//   - positionId: position NFT token ID that had liquidity removed
 91//   - liquidity: removed liquidity amount, represented as a decimal string
 92//   - fee0: token0 fees collected, net of the withdrawal fee
 93//   - fee1: token1 fees collected, net of the withdrawal fee
 94//   - amount0: principal amount of token0 returned to the caller
 95//   - amount1: principal amount of token1 returned to the caller
 96//   - poolKey: canonical pool key for the position
 97//
 98// Halt check: reverts while the Withdraw halt scope is active.
 99func DecreaseLiquidity(
100	cur realm,
101	positionId uint64,
102	liquidityStr string,
103	amount0MinStr string,
104	amount1MinStr string,
105	deadline int64,
106) (uint64, string, string, string, string, string, string) {
107	return getImplementation().DecreaseLiquidity(0, cur, positionId, liquidityStr, amount0MinStr, amount1MinStr, deadline)
108}
109
110// Reposition changes the tick range of a position.
111//
112// Parameters:
113//   - cur: current realm context; callers use cross(cur) when crossing into this realm
114//   - positionId: position NFT token ID to reposition
115//   - tickLower: new lower tick boundary of the position's price range
116//   - tickUpper: new upper tick boundary of the position's price range
117//   - amount0DesiredStr: desired token0 amount for the new range, represented as a decimal string
118//   - amount1DesiredStr: desired token1 amount for the new range, represented as a decimal string
119//   - amount0MinStr: minimum acceptable token0 amount for slippage protection
120//   - amount1MinStr: minimum acceptable token1 amount for slippage protection
121//   - deadline: transaction expiration timestamp
122//
123// Returns:
124//   - positionId: position NFT token ID that was repositioned
125//   - liquidity: new liquidity amount, represented as a decimal string
126//   - tickLower: new lower tick boundary
127//   - tickUpper: new upper tick boundary
128//   - amount0: actual token0 amount added to the new range, represented as a decimal string
129//   - amount1: actual token1 amount added to the new range, represented as a decimal string
130//
131// Halt check: reverts while the Position halt scope is active.
132func Reposition(
133	cur realm,
134	positionId uint64,
135	tickLower int32,
136	tickUpper int32,
137	amount0DesiredStr string,
138	amount1DesiredStr string,
139	amount0MinStr string,
140	amount1MinStr string,
141	deadline int64,
142) (uint64, string, int32, int32, string, string) {
143	return getImplementation().Reposition(0, cur, positionId, tickLower, tickUpper, amount0DesiredStr, amount1DesiredStr, amount0MinStr, amount1MinStr, deadline)
144}
145
146// CollectFee collects accumulated fees from a position.
147//
148// Parameters:
149//   - cur: current realm context; callers use cross(cur) when crossing into this realm
150//   - positionId: position NFT token ID whose fees are collected
151//
152// Returns:
153//   - positionId: position NFT token ID whose fees were collected
154//   - tokensCollected0: token0 fees paid out to the caller, net of the withdrawal fee
155//   - tokensCollected1: token1 fees paid out to the caller, net of the withdrawal fee
156//   - poolKey: canonical pool key for the position
157//   - totalAmount0: token0 fees collected before the withdrawal fee
158//   - totalAmount1: token1 fees collected before the withdrawal fee
159//
160// Halt check: reverts while the Withdraw halt scope is active.
161func CollectFee(
162	cur realm,
163	positionId uint64,
164) (uint64, string, string, string, string, string) {
165	return getImplementation().CollectFee(0, cur, positionId)
166}
167
168// SetPositionOperator sets an operator for a position.
169//
170// Parameters:
171//   - cur: current realm context; callers use cross(cur) when crossing into this realm
172//   - positionId: position NFT token ID whose operator is changed
173//   - operator: operator address to approve; the zero address removes the operator
174func SetPositionOperator(
175	cur realm,
176	positionId uint64,
177	operator address,
178) {
179	getImplementation().SetPositionOperator(0, cur, positionId, operator)
180}