🟧
JS SDK Types
Symbiosis JS SDK defines the following types:
  • ChainId type contains the list of identifiers of supported blockchains.
  • ChainConfig type defines the network configuration used to build cross-chain routes.
  • NerveConfig type defines a liquidity pool consisting of a stablecoin and an sToken pair.
  • AdvisorConfig and Config types define details of Advisor service. The Advisor service calculates fees for cross-chain operations (cross-chain swap, bridging, revert).
  • TokenConstructor type defines a set of parameters used to create an instance of Token class.
  • PendingRequestState and PendingRequest types are used for reverting stuck trades.

ChainId type

ChainId type contains a list of named constants with the integer identifiers of supported blockchains.
1
export enum ChainId {
2
ETH_MAINNET = 1,
3
ETH_RINKEBY = 4,
4
BSC_MAINNET = 56,
5
BSC_TESTNET = 97,
6
MATIC_MAINNET = 137,
7
MATIC_MUMBAI = 80001,
8
AVAX_MAINNET = 43114,
9
AVAX_TESTNET = 43113,
10
HECO_MAINNET = 128,
11
HECO_TESTNET = 256,
12
OKEX_MAINNET = 66,
13
OKEX_TESTNET = 65,
14
}
Copied!

ChainConfig type

ChainConfig type defines the network configuration used to build cross-chain routes.
1
export type ChainConfig = {
2
id: ChainId
3
rpc: string
4
publicRpc: string
5
filterBlockOffset: number
6
stables: TokenConstructor[]
7
nerves: NerveConfig[]
8
router: string
9
dexFee: number
10
metaRouter: string
11
bridge: string
12
synthesis: string
13
portal: string
14
fabric: string
15
waitForBlocksCount: number
16
}
Copied!
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 logs 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 sTokens that connect this blockchain to other blockchains.
nerves
The list of Nerve-like stablecoin liquidity pools that contain 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. ------------------ More information on the contracts and the reason why it works this way can be found here.
bridge
The address of the BridgeV2 contract. More information on the contract can be found here.
synthesis
The address of the Synthesis contract. More information on the contract can be found here.
portal
The address of the Portal contract. More information on the contract can be found here.
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.
1
export type NerveConfig = {
2
address: string
3
tokens: string[]
4
decimals: number[]
5
}
Copied!

AdvisorConfig and Config types

AdvisorConfig and Config types define details of Advisor service. The Advisor service calculates cross-chain operations fees such as cross-chain swaps, bridging, and reverts.
AdvisorConfig type contains the address of the Advisor service.
1
export type AdvisorConfig = {
2
url: string
3
}
Copied!
Config type defines the configuration for the Advisor service.
1
export type Config = {
2
advisor: AdvisorConfig
3
chains: ChainConfig[]
4
minSwapAmountInUsd: number
5
maxSwapAmountInUsd: number
6
}
Copied!
Element
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.
1
export type TokenConstructor = {
2
name?: string
3
symbol?: string
4
address: string
5
decimals: number
6
chainId: ChainId
7
isNative?: boolean
8
isStable?: boolean
9
chainFromId?: ChainId
10
icons?: Icons
11
userToken?: boolean
12
}
Copied!
Property
Description
name
The cryptocurrency name
symbols
The cryptocurrency ticker symbol
address
The cryptocurrency address
decimals
Decimals
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 of the cryptocurrency
userToken
A flag indicating that the cryptocurrency was added manually by a user.

TokenAmount type

TokenAmount type is a basic type representing the amount of swap/bridging/revert operation. It consists of an object of Token type and amount of this cryptocurrency.
1
export class Token {
2
....
3
​
4
/**
5
* Constructs an instance of the base class `Token`.
6
* @param params TokenConstructor
7
*/
8
constructor(params: TokenConstructor) {
9
validateSolidityTypeInstance(JSBI.BigInt(params.decimals), SolidityType.uint8)
10
​
11
this.decimals = params.decimals
12
this.symbol = params.symbol
13
this.name = params.name
14
this.chainId = params.chainId
15
this.address = validateAndParseAddress(params.address)
16
this.isNative = !!params.isNative
17
this.icons = params.icons
18
this.chainFromId = params.chainFromId
19
this.isStable = params.isStable
20
this.userToken = params.userToken
21
}
22
...
23
}
Copied!
1
export class TokenAmount extends Fraction {
2
​
3
...
4
​
5
public constructor(token: Token, amount: BigintIsh) {
6
const parsedAmount = parseBigintIsh(amount)
7
validateSolidityTypeInstance(parsedAmount, SolidityType.uint256)
8
​
9
super(parsedAmount, JSBI.exponentiate(TEN, JSBI.BigInt(token.decimals)))
10
this.token = token
11
​
12
}
13
​
14
...
15
}
Copied!

PendingRequestState and PendingRequest types

PendingRequestState and PendingRequest types are used for reverting stuck trades.
1
enum PendingRequestState {
2
Default = 0,
3
Reverted,
4
}
5
​
6
export type PendingRequestType = 'burn' | 'synthesize'
7
​
8
export interface PendingRequest {
9
fromTokenAmount: TokenAmount
10
transactionHash: string
11
state: PendingRequestState
12
internalId: string
13
externalId: string
14
type: PendingRequestType
15
from: string
16
to: string
17
revertableAddress: string
18
chainIdFrom: ChainId
19
chainIdTo: ChainId
20
status: string
21
transactionHashReverted: string | undefined // deprecated
22
}
Copied!
Property
Description
fromTokenAmount
The amount of tokens that were in the stuck operation of swapping or bridging
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 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.
1
internalID = keccak256(
2
abi.encodePacked(this, requestCount, block.chainid)
3
);
Copied!
externalId
The external identifier of the operation. The identifier is derived from the internalId and calculated with the destination network id, the destination contract address, and the address that can perform a revert.
1
externalID = keccak256(abi.encodePacked(internalID, _receiveSide, _revertableAddress, _chainID));
Copied!
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)
​