Skip to main content

Quick start

Composable SDK provides solidity libraries for building DeFi apps. Using the SDK you can build a cross-layer app that can interact with AMMs and oracles.

Installation

To install it in your project, simply run yarn add @composable-finance/sdk-contracts (or npm install @composable-finance/sdk-contracts).

Usage

All libraries provided by the SDK can be imported into your solidity contract easily. This allows you to call different methods embedded into these files as shown below

import "@composable-finance/sdk-contracts/utils/Operations.sol";import "@composable-finance/sdk-contracts/cross-layer/libraries/Swap.sol";import "@composable-finance/sdk-contracts/cross-layer/libraries/Oracle.sol";import "@composable-finance/sdk-contracts/cross-layer/libraries/Transferal.sol";import "@composable-finance/sdk-contracts/cross-layer/interfaces/IVaultBase.sol";import "@composable-finance/sdk-contracts/cross-layer/libraries/ExchangeLiquidity.sol";

...
// check if vault is paused// vault address is taken automatically from the Config, based on the layer where your contract is deployedfunction isPaused() public view returns (bool) {    return Transferal.isPaused();}
// initiate transfer// there are 2 libraries used here: Operations and Transferalfunction depositToken(    uint256 amount,    address tokenAddress,    address destinationAddress,    uint256 remoteNetworkID,    uint256 transferDelay) public {    address vaultAddress = Transferal.getVaultAddress();    Operations.safeApprove(tokenAddress, vaultAddress, amount);    return Transferal.depositToken(amount, tokenAddress, destinationAddress, remoteNetworkID, transferDelay);}

Libraries

Available libraries are:

  • Swap
  • Liquidity
  • Transferal
  • Oracle
  • Operations