assertIsNotExpired
func(deadline int64)assertIsNotExpired ensures the transaction deadline has not passed.
- OID
- 0be141…5233:3
assertIsNotExpired details
assertIsValidSqrtPriceLimitX96
func(sqrtPriceLimitX96 string)- OID
- 0be141…5233:5
assertIsValidSqrtPriceLimitX96 details
assertIsValidSingleSwapRouteArrPath
func(routePaths string, inputToken string, outputToken string)- OID
- 0be141…5233:6
assertIsValidSingleSwapRouteArrPath details
assertIsValidRoutePaths
func(routePaths string, inputToken string, outputToken string)- OID
- 0be141…5233:7
assertIsValidRoutePaths details
assertIsExistsPools
func(routePathArr string)- OID
- 0be141…5233:8
assertIsExistsPools details
assertIsRouterImplementation
func(caller .uverse.address)- OID
- 0be141…5233:9
assertIsRouterImplementation details
SINGLE_HOP_ROUTE
intValue
1
POOL_SEPARATOR
untyped stringswap can be done by multiple pools to separate each pool, we use POOL\_SEPARATOR
Value
"*POOL*"
RouterOperation
typeValue
v1.RouterOperation
executeSwapOperation
func(int, rlm .uverse.realm, op v1.RouterOperation) (*v1.SwapResult, .uverse.error)executeSwapOperation validates and processes a swap operation.
- OID
- 0be141…5233:10
executeSwapOperation details
BaseSwapParams
typeValue
v1.BaseSwapParams
baseSwapOperation
typecommon swap operation
Value
v1.baseSwapOperation
SwapRouteParams
typeSwapRouteParams contains all parameters needed for swap route execution
Value
v1.SwapRouteParams
buildRouteEventAttrs
func(routeArr string) []string- OID
- 0be141…5233:12
buildRouteEventAttrs details
createSwapOperation
func(r *v1.routerV1, params v1.SwapRouteParams) (v1.RouterOperation, .uverse.error)createSwapOperation creates the appropriate swap operation based on swap type.
- OID
- 0be141…5233:13
createSwapOperation details
routerImplAddr
.uverse.addressValue
<gnolang.StringValue>
init.16
func()- OID
- 0be141…5233:15
init.16 details
errSlippage
untyped stringValue
"[GNOSWAP-ROUTER-001] slippage check failed"
errInvalidRoutesAndQuotes
untyped stringValue
"[GNOSWAP-ROUTER-002] invalid routes and quotes"
errExpired
untyped stringValue
"[GNOSWAP-ROUTER-003] transaction expired"
errInvalidInput
untyped stringValue
"[GNOSWAP-ROUTER-004] invalid input data"
errInvalidPoolFeeTier
untyped stringValue
"[GNOSWAP-ROUTER-005] invalid pool fee tier"
errInvalidSwapFee
untyped stringValue
"[GNOSWAP-ROUTER-006] invalid swap fee"
errInvalidSwapType
untyped stringValue
"[GNOSWAP-ROUTER-007] invalid swap type"
errInvalidPoolPath
untyped stringValue
"[GNOSWAP-ROUTER-008] invalid pool path"
errUnAuthorizedCaller
untyped stringValue
"[GNOSWAP-ROUTER-009] unauthorized caller"
errHopsOutOfRange
untyped stringValue
"[GNOSWAP-ROUTER-010] number of hops must be 1~3"
errSameTokenSwap
untyped stringValue
"[GNOSWAP-ROUTER-011] cannot swap same token"
errInvalidRoutePath
untyped stringValue
"[GNOSWAP-ROUTER-013] invalid route path"
errInvalidRouteFirstToken
untyped stringValue
"[GNOSWAP-ROUTER-014] invalid route first token"
errInvalidRouteLastToken
untyped stringValue
"[GNOSWAP-ROUTER-015] invalid route last token"
errInvalidSwapAmount
untyped stringValue
"[GNOSWAP-ROUTER-016] invalid swap amount"
errRouteHopDisconnected
untyped stringValue
"[GNOSWAP-ROUTER-017] route hop disconnected"
errInsufficientBalance
untyped stringValue
"[GNOSWAP-ROUTER-018] insufficient balance for swap"
errSpoofedRealm
untyped stringValue
"[GNOSWAP-ROUTER-019] rlm does not match the current crossing frame"
addDetailToError
func(message string, detail string) stringaddDetailToError adds detail to an error message.
- OID
- 0be141…5233:17
addDetailToError details
makeErrorWithDetails
func(message string, detail string) .uverse.errormakeErrorWithDetails creates an error with additional context.
- OID
- 0be141…5233:19
makeErrorWithDetails details
ExactInSwapOperation
typeValue
v1.ExactInSwapOperation
NewExactInSwapOperation
func(r *v1.routerV1, pp v1.ExactInParams) *v1.ExactInSwapOperation- OID
- 0be141…5233:20
NewExactInSwapOperation details
ExactOutSwapOperation
typeExactOutSwapOperation handles swaps where the output amount is specified.
Value
v1.ExactOutSwapOperation
NewExactOutSwapOperation
func(r *v1.routerV1, pp v1.ExactOutParams) *v1.ExactOutSwapOperationNewExactOutSwapOperation creates a new exact-out swap operation.
- OID
- 0be141…5233:22
NewExactOutSwapOperation details
defaultSwapFeeBPS
uint64// 0.15%
Value
15
init.42
func()- OID
- 0be141…5233:24
init.42 details
registerRouterV1
func()- OID
- 0be141…5233:26
registerRouterV1 details
initStoreData
func(int, rlm .uverse.realm, routerStore router.IRouterStore) .uverse.error- OID
- 0be141…5233:27
initStoreData details
routerV1
typeValue
v1.routerV1
NewRouterV1
func(routerStore router.IRouterStore) router.IRouter- OID
- 0be141…5233:28
NewRouterV1 details
calculateRouterFee
func(amount int64, swapFee uint64) int64- OID
- 0be141…5233:30
calculateRouterFee details
calculateExactOutWithRouterFee
func(amount int64, swapFee uint64) int64calculate amount to fetch from pool including router fee poolAmount = userAmount / (1 - feeRate) = userAmount \* 10000 / (10000 - swapFeeBPS)
- OID
- 0be141…5233:32
calculateExactOutWithRouterFee details
errExactOutAmountExceeded
untyped stringErrorMessages define all error message templates used throughout the router
Value
"received more than requested in requested=%d, actual=%d"
errInvalidRouteLength
untyped stringErrorMessages define all error message templates used throughout the router
Value
"route length(%d) must be 1~7"
errRoutesQuotesMismatch
untyped stringErrorMessages define all error message templates used throughout the router
Value
"mismatch between routes(%d) and quotes(%d) length"
errInvalidQuote
untyped stringErrorMessages define all error message templates used throughout the router
Value
"invalid quote(%s) at index(%d)"
errInvalidQuoteValue
untyped stringErrorMessages define all error message templates used throughout the router
Value
"quote(%s) at index(%d) must be positive value"
errQuoteExceedsMax
untyped stringErrorMessages define all error message templates used throughout the router
Value
"quote(%s) at index(%d) must be less than or equal to %d"
errQuoteSumExceedsMax
untyped stringErrorMessages define all error message templates used throughout the router
Value
"quote sum exceeds 100 at index(%d)"
errInvalidQuoteSum
untyped stringErrorMessages define all error message templates used throughout the router
Value
"quote sum(%d) must be 100"
errExactInTooFewReceived
untyped stringErrorMessages define all error message templates used throughout the router
Value
"ExactIn: too few received (min:%d, got:%d)"
errExactOutTooMuchSpent
untyped stringErrorMessages define all error message templates used throughout the router
Value
"ExactOut: too much spent (max:%d, used:%d)"
errEmptyRoutes
untyped stringErrorMessages define all error message templates used throughout the router
Value
"routes cannot be empty"
SwapValidator
typeSwapValidator provides validation methods for swap operations
Value
v1.SwapValidator
RouteParser
typeRouteParser handles parsing and validation of routes and quotes
Value
v1.RouteParser
NewRouteParser
func() *v1.RouteParserNewRouteParser creates a new route parser instance.
- OID
- 0be141…5233:33
NewRouteParser details
validateRoutesAndQuotes
func(routes string, quotes string) ([]string, []string, .uverse.error)validateRoutesAndQuotes is a convenience function that parses and validates routes in one call.
- OID
- 0be141…5233:35
validateRoutesAndQuotes details
MaxQuotePercentage
untyped bigintQuoteConstraints defines the valid range for swap quote percentages
Value
(100 <untyped> bigint)
MinQuotePercentage
untyped bigintQuoteConstraints defines the valid range for swap quote percentages
Value
(0 <untyped> bigint)
PERCENTAGE_DENOMINATOR
int64QuoteConstraints defines the valid range for swap quote percentages
Value
100
ErrUnknownSwapType
untyped stringErrorMessages for DrySwapRoute operations
Value
"unknown swapType(%s)"
ErrInvalidPositiveAmount
untyped stringErrorMessages for DrySwapRoute operations
Value
"invalid amount(%s), must be positive"
ErrInvalidZeroAmountLimit
untyped stringErrorMessages for DrySwapRoute operations
Value
"invalid amountLimit(%s), should not be zero"
ErrInvalidQuoteRange
untyped stringErrorMessages for DrySwapRoute operations
Value
"quote(%d) must be %d~%d"
SwapProcessor
typeSwapProcessor handles the execution of swap operations
Value
v1.SwapProcessor
getPathIndex
func(swapType v1.SwapType, numHops int) intgetPathIndex returns the path index based on swap type and number of hops.
- OID
- 0be141…5233:36
getPathIndex details
MIN_SQRT_RATIO
string// same as TickMathGetSqrtRatioAtTick(MIN\_TICK)
Value
"4295128739"
MAX_SQRT_RATIO
string// same as TickMathGetSqrtRatioAtTick(MAX\_TICK)
Value
"1461446703485210103287273052203988822378723970342"
sqrtPriceLimitForward
map[uint32]*uint256.Uint// zeroForOne=true: sqrtRatioAtTick(minTick+1) + 1
- OID
- 0be141…5233:39
sqrtPriceLimitForward details
sqrtPriceLimitBackward
map[uint32]*uint256.Uint// zeroForOne=false: sqrtRatioAtTick(maxTick-1) - 1
- OID
- 0be141…5233:41
sqrtPriceLimitBackward details
init.77
func()- OID
- 0be141…5233:42
init.77 details
RealSwapExecutor
typeRealSwapExecutor implements SwapExecutor for actual swaps.
Value
v1.RealSwapExecutor
DrySwapExecutor
typeDrySwapExecutor implements SwapExecutor for dry swaps.
Value
v1.DrySwapExecutor
calculateSqrtPriceLimitForSwap
func(zeroForOne bool, fee uint32, sqrtPriceLimitX96 *uint256.Uint) *uint256.UintcalculateSqrtPriceLimitForSwap returns the price limit for a swap operation. If a non-zero limit is provided by the caller, it is returned as-is. Otherwise, returns the precomputed limit for the given fee tier and direction. The returned pointer is shared (read-only — callers must not mutate it).
- OID
- 0be141…5233:44
calculateSqrtPriceLimitForSwap details
mustGetSqrtPriceLimit
func(limits map[uint32]*uint256.Uint, fee uint32) *uint256.Uint- OID
- 0be141…5233:45
mustGetSqrtPriceLimit details
getMinTick
func(fee uint32) int32getMinTick returns the minimum tick value for a given fee tier. The implementation follows Uniswap V3's tick spacing rules where lower fee tiers allow for finer price granularity.
- OID
- 0be141…5233:46
getMinTick details
getMaxTick
func(fee uint32) int32getMaxTick returns the maximum tick value for a given fee tier. The max tick values are the exact negatives of min tick values.
- OID
- 0be141…5233:47
getMaxTick details
SwapDirection
typeSwapDirection represents the direction of swap execution in multi-hop swaps. It determines whether swaps are processed in forward order (first to last pool) or backward order (last to first pool).
Value
v1.SwapDirection
Forward
v1.SwapDirectionValue
<zero>
Backward
v1.SwapDirectionValue
<zero>
MultiSwapExecutor
typeMultiSwapExecutor defines the interface for multi-hop swap operation execution.
Value
v1.MultiSwapExecutor
DryMultiSwapExecutor
typeDryMultiSwapExecutor implements MultiSwapExecutor for dry run simulations.
Value
v1.DryMultiSwapExecutor
RealMultiSwapExecutor
typeRealMultiSwapExecutor implements MultiSwapExecutor for actual swap operations.
Value
v1.RealMultiSwapExecutor
MultiSwapProcessor
typeMultiSwapProcessor handles the execution flow for multi-hop swaps.
Value
v1.MultiSwapProcessor
newRealMultiSwapProcessor
func(int, rlm .uverse.realm, r *v1.routerV1, direction v1.SwapDirection, payer .uverse.address) *v1.MultiSwapProcessornewRealMultiSwapProcessor creates a processor that performs real swaps.
- OID
- 0be141…5233:48
newRealMultiSwapProcessor details
newDryMultiSwapProcessor
func(r *v1.routerV1, direction v1.SwapDirection, payer .uverse.address) *v1.MultiSwapProcessornewDryMultiSwapProcessor creates a processor that performs dry-run simulations.
- OID
- 0be141…5233:50
newDryMultiSwapProcessor details
SwapExecutor
typeSwapExecutor defines the interface for executing swaps.
Value
v1.SwapExecutor
rawUnknown
untyped stringValue
"UNKNOWN"
rawExactIn
untyped stringValue
"EXACT_IN"
rawExactOut
untyped stringValue
"EXACT_OUT"
SwapType
typeValue
v1.SwapType
Unknown
v1.SwapTypeValue
<gnolang.StringValue>
ExactIn
v1.SwapTypeValue
<gnolang.StringValue>
ExactOut
v1.SwapTypeValue
<gnolang.StringValue>
trySwapTypeFromStr
func(swapType string) (v1.SwapType, .uverse.error)trySwapTypeFromStr attempts to convert a string into a SwapType. It validates and converts string representations of swap types into their corresponding enum values.
- OID
- 0be141…5233:51
trySwapTypeFromStr details
SingleSwapParams
typeSingleSwapParams contains parameters for executing a single pool swap. It represents the simplest form of swap that occurs within a single liquidity pool.
Value
v1.SingleSwapParams
SwapParams
typeSwapParams contains parameters for executing a multi-hop swap operation.
Value
v1.SwapParams
newSwapParams
func(tokenIn string, tokenOut string, fee uint32, recipient .uverse.address, amountSpecified int64) *v1.SwapParamsnewSwapParams creates a new SwapParams instance with the provided parameters.
- OID
- 0be141…5233:53
newSwapParams details
SwapResult
typeSwapResult encapsulates the outcome of a swap operation.
Value
v1.SwapResult
SwapParamsI
typeSwapParamsI defines the common interface for swap parameters.
Value
v1.SwapParamsI
SwapCallbackData
typeSwapCallbackData contains the callback data required for swap execution. This type is used to pass necessary information during the swap callback process, ensuring proper token transfers and pool data updates.
Value
v1.SwapCallbackData
newSwapCallbackData
func(params v1.SwapParamsI, payer .uverse.address) v1.SwapCallbackDatanewSwapCallbackData creates a new SwapCallbackData from a SwapParamsI.
- OID
- 0be141…5233:54
newSwapCallbackData details
ExactInParams
typeExactInParams contains parameters for exact input swaps.
Value
v1.ExactInParams
NewExactInParams
func(baseParams v1.BaseSwapParams, amountIn int64, amountOutMin int64) v1.ExactInParamsNewExactInParams creates a new ExactInParams instance.
- OID
- 0be141…5233:55
NewExactInParams details
ExactOutParams
typeExactOutParams contains parameters for exact output swaps.
Value
v1.ExactOutParams
NewExactOutParams
func(baseParams v1.BaseSwapParams, amountOut int64, amountInMax int64) v1.ExactOutParamsNewExactOutParams creates a new ExactOutParams instance.
- OID
- 0be141…5233:56
NewExactOutParams details
calculateSwapAmountByQuote
func(amountSpecified int64, quote string) (int64, .uverse.error)calculateSwapAmountByQuote calculates swap amount based on quote percentage.
- OID
- 0be141…5233:57
calculateSwapAmountByQuote details
assertHopsInRange
func(hops int)assertHopsInRange ensures the number of hops is within the valid range of 1-3.
- OID
- 0be141…5233:59
assertHopsInRange details
getDataForSinglePath
func(poolPath string) (token0 string, token1 string, fee uint32)getDataForSinglePath extracts token addresses and fee from a single pool path. IMPORTANT: This function returns tokens in the order they appear in the route string, which represents the swap direction (tokenIn:tokenOut:fee), NOT the canonical pool ordering.
- OID
- 0be141…5233:60
getDataForSinglePath details
getDataForSinglePathWithError
func(poolPath string) (string, string, uint32, .uverse.error)getDataForSinglePathWithError extracts token addresses and fee from a single pool path with error handling.
- OID
- 0be141…5233:61
getDataForSinglePathWithError details
getDataForMultiPath
func(possiblePath string, poolIdx int) (token0 string, token1 string, fee uint32)getDataForMultiPath extracts token addresses and fee from a multi-hop path at specified index.
- OID
- 0be141…5233:62
getDataForMultiPath details
i256MinMax
func(x *int256.Int, y *int256.Int) (min *uint256.Uint, max *uint256.Uint)i256MinMax returns the absolute values of x and y in min-max order.
- OID
- 0be141…5233:63
i256MinMax details
validateRoutePaths
func(routePathArrString string, inputToken string, outputToken string) .uverse.errorvalidateRoutePaths validates multiple route paths to ensure they all start with inputToken and end with outputToken. This function processes comma-separated route paths and validates each path individually. Validates: - Each route path starts with the specified inputToken - Each route path ends with the specified outputToken - Route path format consistency (prevents swap-direction vs alphabetical pool ordering confusion) Parameters: - routePathArrString: comma-separated route paths (e.g., "gno.land/r/demo/wugnot:gno.land/r/demo/usdc:500,gno.land/r/demo/wugnot:gno.land/r/demo/gns:3000\*POOL\*gno.land/r/demo/gns:gno.land/r/demo/usdc:500") - inputToken: expected first token in all route paths - outputToken: expected last token in all route paths Examples: - Single route: "tokenA:tokenB:500" with inputToken="tokenA", outputToken="tokenB" - Multi-route: "tokenA:tokenB:500,tokenA:tokenC:3000\*POOL\*tokenC:tokenB:500" with inputToken="tokenA", outputToken="tokenB" Returns error if any route path validation fails.
- OID
- 0be141…5233:64
validateRoutePaths details
validateRoutePath
func(routePath string, inputToken string, outputToken string) .uverse.errorvalidateRoutePath validates a single route path to ensure it starts with inputToken and ends with outputToken. This function handles both single-hop and multi-hop route paths. Validates: - Route path starts with the specified inputToken - Route path ends with the specified outputToken - Proper token ordering in swap direction (not alphabetical pool ordering) Route Path Formats: - single-hop: "tokenA:tokenB:fee" (direct swap between two tokens) - multi-hop: "tokenA:tokenB:fee1\*POOL\*tokenB:tokenC:fee2" (swap through intermediate tokens) Parameters: - routePath: single route path string (e.g., "gno.land/r/demo/wugnot:gno.land/r/demo/usdc:500") - inputToken: expected first token in the route path - outputToken: expected last token in the route path Examples: - single-hop: "tokenA:tokenB:500" with inputToken="tokenA", outputToken="tokenB" - multi-hop: "tokenA:tokenB:3000\*POOL\*tokenB:tokenC:500" with inputToken="tokenA", outputToken="tokenC" Returns error with specific details if validation fails.
- OID
- 0be141…5233:65
validateRoutePath details
validatePoolPathHopContinuity
func(routePoolPaths []string) .uverse.error- OID
- 0be141…5233:66
validatePoolPathHopContinuity details
splitSingleChar
func(s string, sep uint8) []stringsplitSingleChar splits a string by a single character separator. This function is optimized for splitting strings with a single-byte separator and is more memory efficient than strings.Split for this use case.
- OID
- 0be141…5233:67
splitSingleChar details
parsePoolPathsByRoutePathArr
func(routePathArr string) ([]string, .uverse.error)parsePoolPathsByRoutePathArr parses route path array string and returns a slice of pool paths. This function converts route paths (which maintain swap direction) into canonical pool paths (which use alphabetical token ordering). The function processes comma-separated route paths and extracts individual pool information from each route, ensuring tokens are ordered alphabetically for consistent pool identification. Parameters: - routePathArr: comma-separated route paths string containing single or multi-hop routes Format examples: - Single route: "tokenA:tokenB:500" - Multiple routes: "tokenA:tokenB:500,tokenC:tokenD:3000" - Multi-hop routes: "tokenA:tokenB:500\*POOL\*tokenB:tokenC:3000" Returns: - \[]string: slice of canonical pool paths with alphabetically ordered tokens - error: parsing error if any route path is invalid Example: input: "gno.land/r/demo/wugnot:gno.land/r/demo/usdc:500,gno.land/r/demo/usdc:gno.land/r/demo/gns:3000" output: ["gno.land/r/demo/usdc:gno.land/r/demo/wugnot:500", "gno.land/r/demo/gns:gno.land/r/demo/usdc:3000"]
- OID
- 0be141…5233:68
parsePoolPathsByRoutePathArr details
BuildSingleHopRoutePath
func(tokenA string, tokenB string, fee uint32) stringBuildSingleHopPath creates a single-hop route path string. Format: "tokenA:tokenB:fee" Parameters: - tokenA: input token address - tokenB: output token address - fee: pool fee (e.g., 500, 3000, 10000) Returns: - string: formatted single-hop route path Example: - BuildSingleHopPath("gno.land/r/demo/wugnot", "gno.land/r/demo/usdc", 500) returns "gno.land/r/demo/wugnot:gno.land/r/demo/usdc:500"
- OID
- 0be141…5233:69