proxy.gno
4.86 Kb ยท 124 lines
1package router
2
3// ExactInSwapRoute executes a multi-hop swap with exact input amount.
4//
5// Parameters:
6// - inputToken: path of input token
7// - outputToken: path of output token
8// - amountIn: exact input amount
9// - routeArr: encoded route array
10// - quoteArr: encoded quote array
11// - amountOutMin: minimum output amount
12// - deadline: transaction deadline
13// - referrer: referrer address for reward tracking
14//
15// Returns:
16// - string: actual input amount
17// - string: actual output amount
18func ExactInSwapRoute(cur realm, inputToken string, outputToken string, amountIn string, routeArr string, quoteArr string, amountOutMin string, deadline int64, referrer string) (string, string) {
19 return getImplementation().ExactInSwapRoute(inputToken, outputToken, amountIn, routeArr, quoteArr, amountOutMin, deadline, referrer)
20}
21
22// ExactInSingleSwapRoute executes a single-hop swap with exact input amount.
23//
24// Parameters:
25// - inputToken: path of input token
26// - outputToken: path of output token
27// - amountIn: exact input amount
28// - routeArr: encoded route
29// - amountOutMin: minimum output amount
30// - sqrtPriceLimitX96: price limit for the swap
31// - deadline: transaction deadline
32// - referrer: referrer address for reward tracking
33//
34// Returns:
35// - string: actual input amount
36// - string: actual output amount
37func ExactInSingleSwapRoute(cur realm, inputToken string, outputToken string, amountIn string, routeArr string, amountOutMin string, sqrtPriceLimitX96 string, deadline int64, referrer string) (string, string) {
38 return getImplementation().ExactInSingleSwapRoute(inputToken, outputToken, amountIn, routeArr, amountOutMin, sqrtPriceLimitX96, deadline, referrer)
39}
40
41// ExactOutSwapRoute executes a multi-hop swap with exact output amount.
42//
43// Parameters:
44// - inputToken: path of input token
45// - outputToken: path of output token
46// - amountOut: exact output amount
47// - routeArr: encoded route array
48// - quoteArr: encoded quote array
49// - amountInMax: maximum input amount
50// - deadline: transaction deadline
51// - referrer: referrer address for reward tracking
52//
53// Returns:
54// - string: actual input amount
55// - string: actual output amount
56func ExactOutSwapRoute(cur realm, inputToken string, outputToken string, amountOut string, routeArr string, quoteArr string, amountInMax string, deadline int64, referrer string) (string, string) {
57 return getImplementation().ExactOutSwapRoute(inputToken, outputToken, amountOut, routeArr, quoteArr, amountInMax, deadline, referrer)
58}
59
60// ExactOutSingleSwapRoute executes a single-hop swap with exact output amount.
61//
62// Parameters:
63// - inputToken: path of input token
64// - outputToken: path of output token
65// - amountOut: exact output amount
66// - routeArr: encoded route
67// - amountInMax: maximum input amount
68// - sqrtPriceLimitX96: price limit for the swap
69// - deadline: transaction deadline
70// - referrer: referrer address for reward tracking
71//
72// Returns:
73// - string: actual input amount
74// - string: actual output amount
75func ExactOutSingleSwapRoute(cur realm, inputToken string, outputToken string, amountOut string, routeArr string, amountInMax string, sqrtPriceLimitX96 string, deadline int64, referrer string) (string, string) {
76 return getImplementation().ExactOutSingleSwapRoute(inputToken, outputToken, amountOut, routeArr, amountInMax, sqrtPriceLimitX96, deadline, referrer)
77}
78
79// DrySwapRoute simulates a swap route without executing it.
80//
81// Parameters:
82// - inputToken: path of input token
83// - outputToken: path of output token
84// - specifiedAmount: specified amount for the swap
85// - swapTypeStr: swap type string ("ExactIn" or "ExactOut")
86// - strRouteArr: encoded route array
87// - quoteArr: encoded quote array
88// - tokenAmountLimit: token amount limit
89//
90// Returns:
91// - string: estimated input amount
92// - string: estimated output amount
93// - bool: success status
94func DrySwapRoute(
95 inputToken, outputToken string,
96 specifiedAmount string,
97 swapTypeStr string,
98 strRouteArr, quoteArr string,
99 tokenAmountLimit string,
100) (string, string, bool) {
101 return func(cur realm) (string, string, bool) {
102 return getImplementation().DrySwapRoute(inputToken, outputToken, specifiedAmount, swapTypeStr, strRouteArr, quoteArr, tokenAmountLimit)
103 }(cross)
104}
105
106// SwapCallback is called by pools to transfer tokens during a swap.
107func SwapCallback(token0Path string, token1Path string, amount0Delta int64, amount1Delta int64, payer address) error {
108 return func(cur realm) error {
109 return getImplementation().SwapCallback(token0Path, token1Path, amount0Delta, amount1Delta, payer)
110 }(cross)
111}
112
113// GetSwapFee returns the current swap fee rate.
114func GetSwapFee() uint64 {
115 return getImplementation().GetSwapFee()
116}
117
118// SetSwapFee sets the swap fee rate.
119//
120// Parameters:
121// - fee: new swap fee in basis points
122func SetSwapFee(cur realm, fee uint64) {
123 getImplementation().SetSwapFee(fee)
124}