Data Types
Types
RpcConfig
A type representing a configuration for RPC.
Type
Record<string, IChainWithProvider>
- an object with chain IDs as keys and either arrays of RPC URLs or fallback transport configurations (from viem) as values. This structure allows for flexible and efficient management of RPC connections across multiple blockchain networks.
SwitchChainHook
A type representing a hook function that switches the blockchain chain.
Type
(chainId: number) => Promise<WalletClient | undefined | void>
- a function that takes a chain ID as an argument and returns a promise that resolves to aWalletClient
object,undefined
, orvoid
.
This hook is used to switch the blockchain chain and retrieve a WalletClient
object for the new chain. The hook function should handle the chain switching logic and return a promise that resolves to the WalletClient
object,undefined
or void
if the chain switching fails.
UpdateRouteHook
A type representing a hook function that updates the route execution state.
Type
(executionState: IRouteType) => void
- a function that takes the current execution state of the route as an argument and updates the route execution state accordingly.
This hook is used to update the route execution state in real-time, allowing for dynamic changes to the route execution process. The hook function should handle the logic for updating the route execution state based on the provided execution state.
Interfaces
IChainWithProvider
An interface representing the object with chain and provider.
Properties
chain
:Chain
- an object representing the chain.provider?
:Transport
- a transport configuration for the RPC connection.
IExecutionConfig
An interface representing the configuration for the execution of a route.
Properties
switchChainHook?
:SwitchChainHook
- a hook function that switches the blockchain chain.updateRouteStatusHook?
:UpdateRouteHook
- a hook function that updates the route execution state.txLink?
:string
- a link to the transaction.
This configuration object is used to customize the execution of a route. The switchChainHook
property allows for custom chain switching logic, while the updateRouteStatusHook
property enables real-time updates to the route execution state. The txLink
property provides a link to the transaction for easy access.
ILancaClientConfig
An interface representing a configuration for LancaClient.
Properties
integratorAddress?
:Address
- integrator address.feeBps?
:number
- fee tier.chains?
:RpcConfig
- configuration for the supported blockchain networks. This property is optional and allows users to specify the RPC (Remote Procedure Call) settings for different chains that the client will interact with. Proper configuration of this property ensures that the client can communicate effectively with the desired blockchain networks.
ILancaToken
An interface representing a token in a blockchain.
Properties
address
:Address
- the unique address of the token on the blockchain. This is the contract address that identifies the token and is used for transactions and interactions.chainId
:string
- the identifier for the blockchain network on which the token resides. This helps in distinguishing tokens that may have the same name or symbol but exist on different chains.decimals
:number
- the number of decimal places that the token supports. This value indicates the smallest unit of the token and is crucial for accurate calculations and transactions involving fractional amounts.logoURL
:string
- the URL pointing to the token's logo image. This is used for visual representation in user interfaces, helping users easily identify the token.name
:string
- the full name of the token. This is a human-readable representation of the token, providing clarity about its purpose or function.symbol
:string
- the abbreviated symbol of the token, typically consisting of a few letters. This is used for quick identification and trading of the token on exchanges.priceUsd
:number
- the current price of the token expressed in USD. This value provides users with an understanding of the token's market value and is essential for trading and investment decisions.
ILancaChain
An interface representing a blockchain chain.
Properties
id
:string
- the unique identifier for the blockchain chain. This ID is used to reference the chain in various operations and configurations.explorerURL
:string
- the URL of the blockchain explorer for the chain. This link allows users to view transactions, blocks, and other on-chain data, providing transparency and insight into the blockchain's activity.logoURL
:string
- the URL pointing to the logo image of the blockchain chain. This is used for branding and visual representation in applications, helping users recognize the chain easily.name
:string
- The full name of the blockchain chain. This human-readable name provides context about the chain's purpose, features, or community, making it easier for users to understand its significance.
ITxStep
An interface representing a transaction step.
Properties
type?
:StepType
- transaction step typestatus
:Status
- transaction step statustxHash?
:Hash
- the unique hash of the transaction associated with this step. This property is optional and can be included to provide a reference for users to look up the transaction on a blockchain explorer or to verify its status.error?
:string
- a message describing any error that occurred during this transaction step. This property is optional and is particularly useful for debugging and informing users about issues that may have prevented the step from completing successfully.
IFee
An interface representing a transaction fee.
Properties
type
:string
- transaction fee typeamount
:string
- transaction fee amounttoken
:ILancaToken
- fee token
IRouteTool
An interface representing a routing tool used for facilitating token swaps or transactions across different decentralized exchanges (DEXs). This interface provides essential information about the tool, enabling users and applications to utilize it effectively for routing transactions.
Properties
name
:string
- the name of the routing tool. This property provides a human-readable identifier for the tool, helping users understand which routing mechanism or service is being utilized.amountOutMin?
:string
- the minimum output amount expected from the transaction. This property is optional and allows users to set a threshold for the minimum amount of tokens they wish to receive from the swap. Setting this value helps protect users from unfavorable market conditions and slippage.logoURL
:string
- the URL pointing to the logo image of the routing tool. This property is used for visual representation in user interfaces, allowing users to easily identify the tool being used for the transaction.data?
:object
- an object containing additional parameters specific to the routing tool. This property is optional and can include various parameters that are necessary for the tool's operation:dexRouter
:Address
- the address of the DEX router that will facilitate the token swap. This address is crucial for directing the transaction to the correct smart contract on the blockchain.dexCallData
:Hex
- the calldata to be sent to the DexSwap contract. This hexadecimal string contains the encoded function call and parameters required for executing the swap on the DEX, ensuring that the transaction is processed correctly.
ISwapDirectionData
An interface representing the direction for a token swap. This interface encapsulates the details of the source token and its associated blockchain chain, providing essential information for executing a swap.
Properties
token
:ILancaToken
- the source token involved in the swap. This property provides details about the token being exchanged, including its address, symbol, and other relevant attributes.chain
:ILancaChain
- the blockchain chain on which the source token resides. This property identifies the network where the token is located, ensuring that the swap is executed on the correct chain.amount
:string
- the amount of the source token to be swapped. This value represents the quantity of tokens that the user intends to exchange, which is crucial for calculating the swap's output.
IRouteInternalStep
An interface representing an internal routing step within a transaction process. This interface provides information about the source and destination tokens and chains involved in the routing.
Properties
from
:ISwapDirectionData
- information about the source token and chain. This property contains details about the token being swapped and the chain it originates from.to
:ISwapDirectionData
- information about the destination token and chain. This property provides details about the token that will be received after the swap and the chain it will be sent to.tool
:IRouteTool
- the routing tool used for this internal step. This property specifies the mechanism or service that facilitates the swap, including any relevant parameters.
IRouteBaseStep
An interface representing a basic routing step in the transaction process. This interface serves as a foundation for more complex routing steps.
Properties
type
:StepType
- the type of the routing step. This property categorizes the step within the routing process, providing context about its function.execution?
:ITxStep
- the current state of execution for this step. This property is optional and can be used to track the progress and status of the step, including any errors that may have occurred.
IRouteStep
An interface representing a routing step that extends IRouteBaseStep
. This interface provides detailed information about the routing process, including the source and destination tokens and any internal steps involved.
Properties
from
:ISwapDirectionData
- information about the source token and chain. This property contains details about the token being swapped and the chain it originates from.to
:ISwapDirectionData
- information about the destination token and chain. This property provides details about the token that will be received after the swap and the chain it will be sent to.internalSteps
:IRouteInternalStep[]
- an array of internal routing steps. This property contains the sequence of internal steps that will be executed as part of the routing process, detailing how the swap will be carried out.fees?
:IFee[]
- an array of fee objects associated with this routing step. This property is optional and provides information about the transaction fees that will be incurred during the swap.
IRouteType
An interface representing a routing type. This interface encapsulates the overall routing process, including the source and destination tokens and the steps involved in the routing.
Properties
from
:ISwapDirectionData
- information about the source token and chain. This property contains details about the token being swapped and the chain it originates from.to
:ISwapDirectionData
- information about the destination token and chain. This property provides details about the token that will be received after the swap and the chain it will be sent to.steps
:Array<IRouteStep | IRouteBaseStep>
- an array of routing steps. This property contains the sequence of steps that will be executed during the routing process, detailing how the swap will be carried out.
Enums
Status
An enumeration representing the status of a transaction. This enumeration provides a set of predefined values to indicate the current state of a transaction.
Values
SUCCESS
- indicates that the transaction was successful and completed without issues.FAILED
- indicates that the transaction has failed, typically due to an error or issue during execution.PENDING
- indicates that the transaction is currently pending and has not yet been completed.NOT_STARTED
- indicates that the transaction has not yet been initiated.
StepType
An enumeration representing the type of a routing step. This enumeration provides predefined values to categorize the various steps involved in the routing process.
Values
SRC_SWAP
- represents a step for swapping tokens on the source chain. This step involves exchanging the source token for another token within the same blockchain network.BRIDGE
- represents a step for transitioning between chains. This step facilitates the movement of tokens from one blockchain network to another, often involving a bridging mechanism.DST_SWAP
- represents a step for swapping tokens on the destination chain. This step occurs after the tokens have been bridged and involves exchanging the tokens for the desired token on the target blockchain network.ALLOWANCE
- represents a step for setting the allowance for token transfers. This step is necessary when a user needs to grant permission for a smart contract to spend a specified amount of their tokens on their behalf.SWITCH_CHAIN
- represents a step for switching chains. This step indicates that the transaction process involves changing the active blockchain network, which may be necessary for executing certain operations or swaps.