🟧
JS SDK Types
Symbiosis JS SDK Types

Types

Symbiosis JS SDK defines the following types:
Type
Use
ChainId
The type lists identifiers of supported blockchains.
ChainConfig
The type defines the network configuration to build cross-chain routes.
NerveConfig
The type defines a liquidity pool consisting of a stablecoin and an sToken pair.
AdvisorConfig and Config
The types define details of the Advisor service. Symbiosis maintains and uses the Advisor service to calculate fees for cross-chain operations (cross-chain swap, cross-chain swaps, interchain communicating messaging, bridging, reverting).
TokenConstructor
The type defines a set of parameters used to create an instance of Token class.
PendingRequestState and PendingRequest
The types are used for reverting stuck cross-chain operations.

ChainId type

ChainId type lists named constants with the integer identifiers of supported blockchains.
export enum ChainId {
ETH_MAINNET = 1,
ETH_RINKEBY = 4,
BSC_MAINNET = 56,
BSC_TESTNET = 97,
MATIC_MAINNET = 137,
MATIC_MUMBAI = 80001,
AVAX_MAINNET = 43114,
AVAX_TESTNET = 43113,
HECO_MAINNET = 128,
HECO_TESTNET = 256,
OKEX_MAINNET = 66,
OKEX_TESTNET = 65,
}

ChainConfig type

ChainConfig type defines the network configuration used to build cross-chain routes.
export type ChainConfig = {
id: ChainId
rpc: string
publicRpc: string
filterBlockOffset: number
stables: TokenConstructor[]
nerves: NerveConfig[]
router: string
dexFee: number
metaRouter: string
bridge: string
synthesis: string
portal: string
fabric: string
waitForBlocksCount: number
}
Property
Description
id
The blockchain identifier
rpc
The HTTP RPC of the blockchain. Used to retrieve information about liquidity pools' reserves for this blockchain.
publicRpc (deprecated in JS SDK v.2.3.0)
The Public HTTP RPC of the blockchain.
filterBlockOffset
The range of blocks within which to get log from the blockchain. Used:
  1. 1.
    To get stuck transactions,
  2. 2.
    To get a status of the current swap/bridging/revering operation.
stables
The list of stablecoins used to build cross-chain routes. This list should contain one stablecoin of this blockchain and N sToken that connect this blockchain to other blockchains.
nerves
The list of Nerve-like stablecoin liquidity pools. Each pools contains a stablecoin and an sToken pair.
router
The address of a DEX router for this blockchain. For example, it can be UniSwap for Ethereum.
dexFee
The liquidity provider fee for the chosen DEX. It's an integer value (for example, 30 that equals 0.3%)
metaRouter
The address of the Metarouter contract. ------------------ IMPORTANT The metaRouter contract can work only with ERC20 tokens that have been approved for the metaRouterGateway contract. ERC20 tokens shouldn't be approved for metaRouter. ------------------ For more information on the contracts and the reason why it works this way, please refer to Metarouter V3 | Symbiosis
bridge
The address of the BridgeV2 contract. ------------------ For more information on the contracts and the reason why it works this way, please refer to Metarouter V3 | Symbiosis
synthesis
The address of the Synthesis contract. ------------------ For more information on the contracts and the reason why it works this way, please refer to Metarouter V3 | Symbiosis
portal
The address of the Portal contract. ------------------ For more information on the contracts and the reason why it works this way, please refer to Metarouter V3 | Symbiosis
fabric
The address of the Fabric contract that stores a list of an sToken and a stablecoin pairs.
waitForBlocksCount (deprecated in JS SDK v.2.3.0)
The number of blocks for the destination blockchain to wait for a transaction to be mined.

NerveConfig type

NerveConfig type defines a liquidity pool consisting of a stablecoin and an sToken pair.
export type NerveConfig = {
address: string
tokens: string[]
decimals: number[]
}

AdvisorConfig and Config types

AdvisorConfig and Config types define details of the Advisor service.
Symbiosis maintains and uses the Advisor service to calculate fees for cross-chain operations (cross-chain swap, cross-chain swaps, interchain communicating messaging, bridging, reverting).

AdvisorConfig type

This type contains the address of the Advisor service.
export type AdvisorConfig = {
url: string
}

Config type

This type defines the configuration for the Advisor service.
export type Config = {
advisor: AdvisorConfig
chains: ChainConfig[]
minSwapAmountInUsd: number
maxSwapAmountInUsd: number
}
Property
Description
advisor
The configuration to access the Advisor service.
chains
A list of networks' configurations.
minSwapAmountInUsd
The minimum sum of cross-chain swap in the USD equivalent.
maxSwapAmountInUsd
The maximal sum of cross-chain swap in the USD equivalent.

TokenConstructor type

TokenConstructor type defines a set of parameters used to create an instance of Token class.
export type TokenConstructor = {
name?: string
symbol?: string
address: string
decimals: number
chainId: ChainId
isNative?: boolean
isStable?: boolean
chainFromId?: ChainId
icons?: Icons
userToken?: boolean
}
Property
Description
name
The cryptocurrency name
symbols
The cryptocurrency ticker symbol
address
The cryptocurrency address
decimals
The decimals for the cryptocurrency
isNative
A flag indicating that the cryptocurrency is a native cryptocurrency or an ЕРС20 token
isStable
A flag indicating that the cryptocurrency is a stablecoin used in cross-chain swaps.
chainFromId
The network identifier the sToken was received from
icons
A list of icons for the cryptocurrency
userToken
A flag indicating that the cryptocurrency was added manually by a user.
export class Token {
....
/**
* Constructs an instance of the base class `Token`.
* @param params TokenConstructor
*/
constructor(params: TokenConstructor) {
validateSolidityTypeInstance(JSBI.BigInt(params.decimals), SolidityType.uint8)
this.decimals = params.decimals
this.symbol = params.symbol
this.name = params.name
this.chainId = params.chainId
this.address = validateAndParseAddress(params.address)
this.isNative = !!params.isNative
this.icons = params.icons
this.chainFromId = params.chainFromId
this.isStable = params.isStable
this.userToken = params.userToken
}
...
}
export class TokenAmount extends Fraction {
...
public constructor(token: Token, amount: BigintIsh) {
const parsedAmount = parseBigintIsh(amount)
validateSolidityTypeInstance(parsedAmount, SolidityType.uint256)
super(parsedAmount, JSBI.exponentiate(TEN, JSBI.BigInt(token.decimals)))
this.token = token
}
...
}

PendingRequestState and PendingRequest types

PendingRequestState and PendingRequest types are used for reverting stuck cross-chain operations.
enum PendingRequestState {
Default = 0,
Reverted,
}
export type PendingRequestType = 'burn' | 'synthesize'
export interface PendingRequest {
fromTokenAmount: TokenAmount
transactionHash: string
state: PendingRequestState
internalId: string
externalId: string
type: PendingRequestType
from: string
to: string
revertableAddress: string
chainIdFrom: ChainId
chainIdTo: ChainId
status: string
transactionHashReverted: string | undefined // deprecated
}
Property
Description
fromTokenAmount
The amount of tokens that were in the stuck cross-chain operation.
transactionHash
The hash of the stuck transaction
state
The state of the revert:
  1. 1.
    Default means there was no attempt to revert the operation,
  2. 2.
    Reverted means there was an attempt to revert the operation.
internalId
The internal identifier of the cross-chain operation. The identifier of the minting/burning request is calculated without the destination network id, the recipient contract address (Portal or Synthesis), and the address that can perform a revert.
internalID = keccak256(
abi.encodePacked(this, requestCount, block.chainid)
);
externalId
The external identifier of the cross-chain operation. The identifier is derived from the internalId and calculated together with the destination network id, the destination contract address, and the address that can perform a revert.
externalID = keccak256(abi.encodePacked(internalID, _receiveSide, _revertableAddress, _chainID)
type
The type of the operation:
  1. 1.
    burn means that the operation burns sTokens,
  2. 2.
    synthesize means that the operation mints sTokens.
from
The sender's address
to
The recipient's address
revertableAddress
The address which can revert the operation
chainIdFrom
The identifier of the origin blockchain
chainIdTo
The identifier of the destination blockchain
status (deprecated)
transactionHashReverted (deprecated)
Copy link
On this page
Types
ChainId type
ChainConfig type
NerveConfig type
AdvisorConfig and Config types
AdvisorConfig type
Config type
TokenConstructor type
PendingRequestState and PendingRequest types