To create SDK instance you should provide config parameter, this is an object containing the rpc, wallets, http client settings, and your personal integrator wallet address.
RpcProviders is Rpc data to connect to blockchains you will use. You have to pass rpcProvider for each blockchain you will use with sdk, as presented in example below:
typeRpcProviders=Partial<Record<EvmBlockchainName,RpcProvider<string>> &Record<TronBlockchainName,RpcProvider<TronWebProvider>> &Record<SolanaBlockchainName,RpcProvider<string>>>;interfaceRpcProvider<T> {/** * Rpc links. Copy it from your rpc provider website * (like Infura, Quicknode, Getblock, Moralis, etc). */readonly rpcList:T[];}
Providing wallet options
If at the time when you initiating SDK, users have already logged into your platform, you can provide walletProvider object, but it is no necessary, until you want to swap with SDK:
You can also pass your own http client as httpClient parameter (e.g. HttpClient in Angular) if you have it, to not duplicate http clients and decrease bundle size.
Your wallet address as integrator
This is one of the most important steps, please send to the Rubic team the providerAddress - the wallet address to which the fees will be credited. To make it work properly, you need to contact us so that we can whitelist you.
Update SDK configuration
When user finally connects the walet, you have to notify SDK about it.
You should do it on every address and network change events
SDK object
When SDK was initiated, you are able to refer it's fields and methods.
interfaceSDK {/** * On-chain manager object. Use it to calculate and create on-chain trades. */publicreadonly onChainManager:OnChainManager;/** * Cross-chain trades manager object. Use it to calculate and create cross-chain trades. */publicreadonly crossChainManager:CrossChainManager;/** * On-chain status manager object. Use it for special providers, which requires more than one trade. */publicreadonly onChainStatusManager:OnChainStatusManager;/** * Cross-chain status manager object. Use it to get trade statuses on source and target network. */publicreadonly crossChainStatusManager:CrossChainStatusManager;/** * Cross-chain symbiosis manager object. Use it to get pending trades in symbiosis and revert them. */publicreadonly crossChainSymbiosisManager:CrossChainSymbiosisManager;/** * Deflation token manager object. Use it to check specific token for fees or deflation. */publicreadonly deflationTokenManager:DeflationTokenManager;/** * Use it to create limit order. */publicreadonly limitOrderManager:LimitOrderManager;/** * Can be used to get `Web3Public` instance by blockchain name to get public information from blockchain. */publicgetweb3PublicService():Web3PublicService {returnInjector.web3PublicService; }/** * Can be used to send transactions and execute smart contracts methods. */publicgetweb3PrivateService():Web3PrivateService {returnInjector.web3PrivateService; }/** * Use it to get gas price information. */publicgetgasPriceApi():GasPriceApi {returnInjector.gasPriceApi; }/** * Use it to get coingecko price information. */publicgetcoingeckoApi():CoingeckoApi {returnInjector.coingeckoApi; }/** * Updates sdk configuration and sdk entities dependencies. */publicasyncupdateConfiguration(configuration:Configuration):Promise<void> {const [web3PublicService,web3PrivateService,httpClient] =awaitPromise.all([SDK.createWeb3PublicService(configuration),SDK.createWeb3PrivateService(configuration),SDK.createHttpClient(configuration) ]);Injector.createInjector(web3PublicService, web3PrivateService, httpClient); }publicupdateWalletProvider(walletProvider:WalletProvider):void {Injector.web3PrivateService.updateWeb3PrivateStorage(walletProvider); }publicupdateWalletProviderCore( chainType:keyofWalletProvider, walletProviderCore:WalletProviderCore ):void {Injector.web3PrivateService.updateWeb3Private(chainType, walletProviderCore); }publicupdateWalletAddress(chainType:keyofWalletProvider, address:string):void {Injector.web3PrivateService.updateWeb3PrivateAddress(chainType, address); }}