🟧
JS SDK Interchain Communicating
Symbiosis JS SDK Interchain Communicating
Symbiosis acts as Interchain Communication Protocol working with other DeFi protocols. Currently with Symbiosis you can:
  • Exchange any token from supported blockchains for BTC via the Ren Protocol,
  • Add any token from supported blockchains to lending protocols: Aave, BENQI, C.R.E.A.M.
  • Add any token from supported blockchains to farming protocols: Beefy
If you want to understand what happens under the hood during interchain communicating, check out this document: Interchain Communicating
Examples You can find full-featured examples of ANY to ANY token cross-chain swaps as well as exchanging for BTC in the directory of examples

Exchange for BTC with the Ren Protocol: newZappingRenBTC

Symbiosis uses the Ren Protocol on BINANCE and POLYGON to perform cross-chain exchanges for BTC. When the Ren Protocol receives renBTCs, it burns them and sends BTCs to the user's address on BITCOIN BLOCKCHAIN.
Technically, Symbiosis acts as the interchain communicating protocol while exchanging for BTC. But, for users, exchanging for BTC looks like a common cross-chain swap, so we added this functionality to Swapping.exactIn
Symbiosis JS SDK implements one method to exchange for BTC via the Ren Protocol: newZappingRenBTC. The method is identical to Swapping.exactIn except for one property for input:
tokenOut -> renChainId, where renChainId is the network's identifier where renBTCs should be obtained.
For example, if we want to swap ETH -> BTC, then the complete routing via BNB chain (renChainId = 56) may look like ETH -> USDC -> sUSDC -> BUSD -> renBTC -> BTC
Important Exchanging for BTC is a cross-chain operation. So, if the origin token is from BNB chain, then you should use Polygon (renChainId=137) to route the swap.
const zappingBtc = symbiosis.newZappingRenBTC()
const { transactionRequest, fee, tokenAmountOut, route, priceImpact } = await zappingBtc.exactIn(
tokenAmountIn,
renChainId,
from,
to,
revertableAddress,
slippage,
deadline,
use1Inch
)
// Send the transaction and get a receipt
const receipt = sendTransaction(transactionRequest)
// Wait for the transaction to be completed on the destination chain
const log = await zappingBtc.waitForComplete(receipt)

Adding liquidity to AAVE: newZappingAave

JS SDK implements one method to add liquidity to AAVE: newZappingAave. The method is identical to Swapping.exactIn
const zappingAave = symbiosis.newZappingAave()
const { transactionRequest, fee, tokenAmountOut, route, priceImpact } = await zappingAave.exactIn(
tokenAmountIn,
tokenOut,
from,
to,
revertableAddress,
slippage,
deadline,
use1Inch
)
// Send the transaction and get a receipt
const receipt = sendTransaction(transactionRequest)
// Wait for the transaction to be completed on the destination chain
const log = await zappingAave.waitForComplete(receipt)

Adding Liquidity to C.R.E.A.M. and BENQI: newZappingCream

JS SDK implements one method to add liquidity to C.R.E.A.M. and BENQI: newZappingCream. The method is identical to Swapping.exactIn
const zappingCream = symbiosis.newZappingCream()
const { transactionRequest, fee, tokenAmountOut, route, priceImpact } = await zappingCream.exactIn(
tokenAmountIn,
tokenOut,
from,
to,
revertableAddress,
slippage,
deadline,
use1Inch
)
// Send the transaction and get a receipt
const receipt = sendTransaction(transactionRequest)
// Wait for the transaction to be completed on the destination chain
const log = await zappingCream.waitForComplete(receipt)
Copy link
On this page
Exchange for BTC with the Ren Protocol: newZappingRenBTC
Adding liquidity to AAVE: newZappingAave
Adding Liquidity to C.R.E.A.M. and BENQI: newZappingCream