🟧
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 C.R.E.A.M. and AAVE.
If you want to understand what happens under the hood during cross-chain zaps, check out this article: Metarouter V3 > Interchain Communicating​
You can find full-featured examples of ANY to ANY cross-chain swaps as well as exchanging for BTC in the directory of examples ​

Exchange for BTC with the Ren Protocol

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

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.

JS SDK implements one method to add liquidity to C.R.E.A.M.: 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)