Access all the addresses, contract interfaces, and chain configurations
Being the interface to a cross-chain protocol, the IonicSdk is configured to seamlessly work across chains, and allows developers to introspect each chain's available infrastructure, as well as the deployed contracts in that chain.
These values are directly available via the instantiated SDK, for the selected chain with which the SDK is instantiated.
E.g.:
import{ IonicSdk }from'@ionicprotocol/sdk';import{ ethers }from"ethers";constchainId=56;// for BSC mainnetconstprovider=newethers.providers.JsonRpcProvider('<YOUR-ENDPOINT-HERE>')constsdk=newIonicSdk(provider, chainId);console.log(sdk.oracles)>>> ["FixedNativePriceOracle","MasterPriceOracle","ChainlinkPriceOracleV2","CurveLpTokenPriceOracleNoRegistry","UniswapLpTokenPriceOracle","UniswapTwapPriceOracleV2"]
Here's an overview of the available properties of MidasSdk:
IonicSdk.provider // the passed in providerIonicSdk.chainId // the passed in chain id IonicSdk.supportedAssetsIonicSdk.chainDeploymentIonicSdk.contracts IonicSdk.artifactsIonicSdk.irmsIonicSdk.availableIrmsIonicSdk.oraclesIonicSdk.availableOraclesIonicSdk.chainSpecificAddressesIonicSdk.chainSpecificParamsIonicSdk.deployedPlugins
This object contains a set of addresses for infra specific to this chain. The chain's Native Wrapped Token address, and the main Uniswap-like router and factory addresses are amongst them. Widely used within the SDK.
Object containing the address, names, and strategies for the ERC4626 plugins deployed in a specific chain.
IonicSdk.contracts
Set of already instantiated ethers.Contract for the core Ionic Protocol contracts that are widely used across the SDK. The functionality of these contracts is mostly wrapped by other SDK functions, so these are unlikely to be widely used by developers. They are given however as instantiated contracts for ease of access from the SDK's codebase.
Type:[contractName: string]: ethers.Contract]
The main contracts are the following:
FuseFeeDistributor: the "admin" contract, in charge of collecting protocol fees, and of performing admin functionality over the protocol
FusePoolDirectory: a registry contract in charge of keeping track of deployed pools
FusePoolLens: introspection module for querying Ionic Pool's data at different levels of aggregation
FusePoolLensSecondary: secondary introspection module, in charge of querying a specific pool's information
FuseSafeLiquidator: the contract in charge of performing the liquidations on Fuse Pools
IonicSdk.artifacts
Type: object containing as keys the Contract Name, and as object an Artifact type. Once more, this is provided as a shorthand for other SDK functions.
E.g, to instantiate a cToken as an ethers.Contract, the following code is used: