assertIsNotExpired
func(deadline int64)assertIsNotExpired ensures the transaction deadline has not passed.
- OID
- 0be141…5233:3
assertIsNotExpired details
assertSingleSwap
func(p *v1.SingleSwapParams)- OID
- 0be141…5233:5
assertSingleSwap details
assertIsValidSqrtPriceLimitX96
func(sqrtPriceLimitX96 string)- OID
- 0be141…5233:6
assertIsValidSqrtPriceLimitX96 details
assertIsValidSingleSwapRouteArrPath
func(routePaths string, inputToken string, outputToken string)- OID
- 0be141…5233:7
assertIsValidSingleSwapRouteArrPath details
assertIsValidRoutePaths
func(routePaths string, inputToken string, outputToken string)- OID
- 0be141…5233:8
assertIsValidRoutePaths details
assertIsExistsPools
func(routePathArr string)- OID
- 0be141…5233:9
assertIsExistsPools details
assertIsRouterImplementation
func(caller .uverse.address)- OID
- 0be141…5233:10
assertIsRouterImplementation details
assertHopFullyConsumed
func(hopIndex int, specifiedAmount int64, consumedAmount int64)assertHopFullyConsumed reverts when an exact-in hop consumed less input than specified.
- OID
- 0be141…5233:11
assertHopFullyConsumed details
validateHopFullyConsumed
func(hopIndex int, specifiedAmount int64, consumedAmount int64) .uverse.error- OID
- 0be141…5233:12
validateHopFullyConsumed 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:13
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:15
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:16
createSwapOperation details
routerImplAddr
.uverse.addressValue
<gnolang.StringValue>
init.19
func()- OID
- 0be141…5233:18
init.19 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"
errInsufficientLiquidity
untyped stringValue
"[GNOSWAP-ROUTER-020] insufficient liquidity for swap"
addDetailToError
func(message string, detail string) stringaddDetailToError adds detail to an error message.
- OID
- 0be141…5233:20
addDetailToError details
makeErrorWithDetails
func(message string, detail string) .uverse.errormakeErrorWithDetails creates an error with additional context.
- OID
- 0be141…5233:22
makeErrorWithDetails details
ExactInSwapOperation
typeValue
v1.ExactInSwapOperation
NewExactInSwapOperation
func(r *v1.routerV1, pp v1.ExactInParams) *v1.ExactInSwapOperationNewExactInSwapOperation creates an exact-input operation for router execution. Parameters: - r: router implementation used to execute pool swaps - pp: exact-input amount and route settings Returns: - operation: initialized ExactInSwapOperation
- OID
- 0be141…5233:23
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 an exact-output operation for router execution. Parameters: - r: router implementation used to execute pool swaps - pp: exact-output amount and route settings Returns: - operation: initialized ExactOutSwapOperation
- OID
- 0be141…5233:25
NewExactOutSwapOperation details
defaultSwapFeeBPS
uint64// 0.15%
Value
15
init.46
func()- OID
- 0be141…5233:27
init.46 details
registerRouterV1
func()- OID
- 0be141…5233:29
registerRouterV1 details
initStoreData
func(int, rlm .uverse.realm, routerStore router.IRouterStore) .uverse.error- OID
- 0be141…5233:30
initStoreData details
routerV1
typeValue
v1.routerV1
NewRouterV1
func(routerStore router.IRouterStore) router.IRouterNewRouterV1 creates a router v1 implementation backed by routerStore. Parameters: - routerStore: storage implementation used for swap-fee and pending protocol-fee state Returns: - router: initialized IRouter implementation backed by routerStore
- OID
- 0be141…5233:31
NewRouterV1 details
calculateRouterFee
func(amount int64, swapFee uint64) int64- OID
- 0be141…5233:33
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:35
calculateExactOutWithRouterFee details
maxSwapFeeBPS
uint64Value
1000
errExactInAmountMismatch
untyped stringErrorMessages define all error message templates used throughout the router
Value
"consumed input does not match requested (requested=%d, consumed=%d)"
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 parser for comma-separated route and quote strings. Returns: - parser: new RouteParser instance
- OID
- 0be141…5233:36
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:38
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"
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:39
getPathIndex details
MIN_SQRT_RATIO_PLUS_ONE
stringValue
"4295128740"
MAX_SQRT_RATIO_MINUS_ONE
stringValue
"1461446703485210103287273052203988822378723970341"
calculateSqrtPriceLimitToStr
func(zeroForOne bool, sqrtPriceLimitX96 *v1.Uint) stringcalculateSqrtPriceLimitToStr returns the price-limit string for a swap operation. A non-zero caller limit is formatted as-is; a zero limit uses the global TickMath boundary for the swap direction.
- OID
- 0be141…5233:41
calculateSqrtPriceLimitToStr details
rawUnknown
untyped stringValue
"UNKNOWN"
rawExactIn
untyped stringValue
"EXACT_IN"
rawExactOut
untyped stringValue
"EXACT_OUT"
zeroAddress
.uverse.addressValue
<gnolang.StringValue>
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:43
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:45
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:46
newSwapCallbackData details
newDrySwapCallbackData
func(params v1.SwapParamsI) v1.SwapCallbackDatanewDrySwapCallbackData creates callback data for a dry swap. The payer is deliberately the zero address because dry swaps do not execute callbacks or token transfers.
- OID
- 0be141…5233:47
newDrySwapCallbackData details
ExactInParams
typeExactInParams contains parameters for exact input swaps.
Value
v1.ExactInParams
NewExactInParams
func(baseParams v1.BaseSwapParams, amountIn int64, amountOutMin int64) v1.ExactInParamsNewExactInParams creates parameters for an exact-input swap. Parameters: - baseParams: shared token, route, quote, price-limit, and deadline settings - amountIn: exact input amount in token units; must be positive before execution - amountOutMin: minimum acceptable output amount in token units Returns: - params: exact-input parameters combining baseParams and amount limits
- OID
- 0be141…5233:48
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 parameters for an exact-output swap. Parameters: - baseParams: shared token, route, quote, price-limit, and deadline settings - amountOut: requested output amount in token units; must be positive before execution - amountInMax: maximum acceptable input amount in token units Returns: - params: exact-output parameters combining baseParams and amount limits
- OID
- 0be141…5233:49
NewExactOutParams details
calculateSwapAmountByQuote
func(amountSpecified int64, quote string) (int64, .uverse.error)calculateSwapAmountByQuote calculates swap amount based on quote percentage.
- OID
- 0be141…5233:50
calculateSwapAmountByQuote details
assertHopsInRange
func(hops int)assertHopsInRange ensures the number of hops is within the valid range of 1-3.
- OID
- 0be141…5233:52
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:53
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:54
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:55
getDataForMultiPath details
i256MinMax
func(x *v1.Int, y *v1.Int) (min *v1.Uint, max *v1.Uint)i256MinMax returns the absolute values of x and y in min-max order.
- OID
- 0be141…5233:56
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/gnoland/wugnot.wugnot:gno.land/r/gnoswap/gns.GNS:500,gno.land/r/gnoland/wugnot.wugnot:gno.land/r/gnoswap/gns.GNS:3000") - 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:57
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/gnoland/wugnot.wugnot:gno.land/r/gnoswap/gns.GNS: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:58
validateRoutePath details
validatePoolPathHopContinuity
func(routePoolPaths []string) .uverse.error- OID
- 0be141…5233:59
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:60
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/gnoland/wugnot.wugnot:gno.land/r/gnoswap/gns.GNS:500,gno.land/r/gnoland/wugnot.wugnot:gno.land/r/gnoswap/gns.GNS:3000" output: ["gno.land/r/gnoswap/gns.GNS:gno.land/r/gnoland/wugnot.wugnot:500", "gno.land/r/gnoswap/gns.GNS:gno.land/r/gnoland/wugnot.wugnot:3000"]
- OID
- 0be141…5233:61
parsePoolPathsByRoutePathArr details
BuildSingleHopRoutePath
func(tokenA string, tokenB string, fee uint32) stringBuildSingleHopRoutePath formats one route-direction single-hop path. Parameters: - tokenA: input token contract path - tokenB: output token contract path - fee: pool fee tier appended as a decimal value Returns: - routePath: tokenA:tokenB:fee formatted route string; panics for empty or identical tokens
- OID
- 0be141…5233:62