Skip to main content

Class: SdkRouter

Classdesc

SDK class encapsulating router functions.

Hierarchy

Methods

addLiquidityForRouter

addLiquidityForRouter(params): Promise<TransactionRequest>

Returns the transaction request for adding liquidity to a router.

Parameters

NameTypeDescription
paramsObjectaddLiquidityForRouter parameters object.
params.amountstringThe amount of the token to add.
params.domainIdstringThe domain ID.
params.routerstringThe address of the router.
params.tokenAddressstringThe address of the token.

Returns

Promise<TransactionRequest>

providers.TransactionRequest object.


approveIfNeeded

approveIfNeeded(domainId, assetId, amount, infiniteApprove?): Promise<undefined | TransactionRequest>

Returns the transaction request for an allowance approval.

Parameters

NameTypeDefault valueDescription
domainIdstringundefinedThe domain ID.
assetIdstringundefinedThe address of the token.
amountstringundefinedThe amount of the token.
infiniteApprovebooleantrue(optional) Whether to approve an infinite amount.

Returns

Promise<undefined | TransactionRequest>

providers.TransactionRequest object.

Inherited from

SdkShared.approveIfNeeded


calculateCanonicalKey

calculateCanonicalKey(domainId, canonicalId): string

Returns the hash of the canonical ID + canonical domain.

Remarks

This key is used as the unique identifier for a canonical token, across all domains.

Parameters

NameTypeDescription
domainIdstringThe canonical domain ID of the token.
canonicalIdstringThe canonical ID of the token.

Returns

string

Inherited from

SdkShared.calculateCanonicalKey


changeSignerAddress

changeSignerAddress(signerAddress): Promise<void>

Switches the signer address in the SDK config.

Parameters

NameTypeDescription
signerAddressstringThe new signer address.

Returns

Promise<void>

Inherited from

SdkShared.changeSignerAddress


getAssetsData

getAssetsData(): Promise<AssetData[]>

Fetches the list of registered assets.

Returns

Promise<AssetData[]>

Array of objects containing assets registered to the network, in the form of:

{
"local": "0x2983bf5c334743aa6657ad70a55041d720d225db",
"adopted": "0x82af49447d8a07e3bd95bd0d56f35241523fbab1",
"canonical_id": "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
"canonical_domain": "6648936",
"domain": "1634886255",
"key": "0x12acadfa38ab02479ae587196a9043ee4d8bf52fcb96b7f8d2ba240f03bcd08a",
"id": "0x2983bf5c334743aa6657ad70a55041d720d225db"
},

Inherited from

SdkShared.getAssetsData


getAssetsDataByDomainAndKey

getAssetsDataByDomainAndKey(domainId, key): Promise<undefined | AssetData>

Retrieve the asset data for a specific domain and key.

Parameters

NameTypeDescription
domainIdstringThe domain ID.
keystringThe canonical hash of the canonical token.

Returns

Promise<undefined | AssetData>

The object containing asset data.

Inherited from

SdkShared.getAssetsDataByDomainAndKey


getCanonicalTokenId

getCanonicalTokenId(domainId, tokenAddress): Promise<[string, string]>

Returns the canonical ID and canonical domain of a token.

Parameters

NameTypeDescription
domainIdstringThe canonical domain ID of the token.
tokenAddressstringThe address of the token.

Returns

Promise<[string, string]>

Inherited from

SdkShared.getCanonicalTokenId


getSupported

getSupported(): Promise<ConnextSupport[]>

Fetches the list of supported networks and assets.

Returns

Promise<ConnextSupport[]>

Array of objects containing networks and assets supported by the protocol, in the form of:

{   
"name": "arbitrum",
"chainId": 42161,
"domainId": "1634886255",
"assets": [
"0x82af49447d8a07e3bd95bd0d56f35241523fbab1",
"0xff970a61a04b1ca14834a43f5de4533ebddb5cc8"
]
},

Inherited from

SdkShared.getSupported


isNextAsset

isNextAsset(tokenAddress): Promise<undefined | boolean>

Returns whether the specified token is a Connext-issued (local) token.

Parameters

NameTypeDescription
tokenAddressstringThe address of the token.

Returns

Promise<undefined | boolean>

Boolean or undefined if the specified token is not registered.

Inherited from

SdkShared.isNextAsset


parseConnextTransactionReceipt

parseConnextTransactionReceipt(transactionReceipt): any

Parses a providers.TransactionReceipt for the logs.

Parameters

NameTypeDescription
transactionReceiptTransactionReceiptproviders.TransactionReceipt object.

Returns

any

Array of providers.Log objects.

Inherited from

SdkShared.parseConnextTransactionReceipt


removeRouterLiquidity

removeRouterLiquidity(params): Promise<TransactionRequest>

Returns the transaction request for removing liquidity from a router.

Remarks

This function is permissioned to the router owner only.

Parameters

NameTypeDescription
paramsObjectremoveRouterLiquidity parameters object.
params.amountstringThe amount of the token to add.
params.domainIdstringThe domain ID.
params.recipientstringThe address where the removed funds will be delivered.
params.tokenAddressstringThe address of the token.

Returns

Promise<TransactionRequest>

providers.TransactionRequest object.


removeRouterLiquidityFor

removeRouterLiquidityFor(params): Promise<TransactionRequest>

Parameters

NameType
paramsObject
params.amountstring
params.domainIdstring
params.recipientstring
params.routerstring
params.tokenAddressstring

Returns

Promise<TransactionRequest>


create

Static create(_config): Promise<SdkRouter>

Create a singleton instance of the SdkRouter class.

Parameters

NameTypeDefault valueDescription
_configObjectundefinedSdkConfig object.
_config.chainsRecord<string, { providers: string[] }>undefinedChain config, at minimum with providers for each chain.
_config.signerAddressstringundefinedSigner address for transactions.
_config.logLevel"fatal" | "error" | "warn" | "info" | "debug" | "trace" | "silent""info"(optional) Logging severity level.
_config.network"testnet" | "mainnet""mainnet"(optional) Blockchain environment to interact with.

Returns

Promise<SdkRouter>

providers.TransactionRequest object.

@example:

import { SdkRouter } from "@connext/sdk";

const config = {
signerAddress: "<wallet_address>",
network: "mainnet",
chains: {
6648936: { // the domain ID for Ethereum Mainnet
providers: ["https://rpc.ankr.com/eth"],
},
1869640809: { // the domain ID for Optimism
providers: ["https://mainnet.optimism.io"]
},
1886350457: { // the domain ID for Polygon
providers: ["https://polygon-rpc.com"]
},
},
}

const sdkRouter = await SdkRouter.create(config);
note

See the Supported Chains page for all domain IDs and the Deployments page for all asset addresses.


domainToChainName

Static domainToChainName(domainId): string

Returns the chain name for a specified domain.

Parameters

NameTypeDescription
domainIdstringThe domain ID.

Returns

string

The chain name.

Inherited from

SdkShared.domainToChainName


getBlockNumberFromUnixTimestamp

Static getBlockNumberFromUnixTimestamp(domainId, unixTimestamp): Promise<number>

Parameters

NameTypeDescription
domainIdstringThe domain ID.
unixTimestampnumberThe unix timestamp.

Returns

Promise<number>

Inherited from

SdkShared.getBlockNumberFromUnixTimestamp