Setting up the SDK

To install the Yelay SDK, use the following npm command:

npm install "@spool.fi/spool-v2-sdk"

To use the Yelay SDK, you need to create an instance of the SpoolSdk class. To accomplish this, call the following function with these parameters:

import { SpoolSdk } from '@spool.fi/spool-v2-sdk';

const yelaySDK = new SpoolSdk(
  config: SDKConfig,
  signerOrProvider: Signer | Provider
)

The first parameter is the SDKConfig, where you can select the appropriate config from the set of predefined configs, each made for one of the supported chains (see examples below).

Example 1: SDKConfig on Ethereum mainnet

Initiate SDKConfig by calling the predefined config getMainnetConfig and passing in the URL to your Subgraph.

import { getMainnetConfig, SpoolSdk } from '@spool.fi/spool-v2-sdk';

const provider = new Wallet(pk, rpc);

const yelaySDK = new SpoolSdk(
  getMainnetConfig(
    'https://subgraph.satsuma-prod.com/link-to-the-subgraph',
  ),
  provider,
);

Decentralized subgraph option

In order to access public Yelay subgraph used by the SDK, follow these instructions:

  • First you must create an API key:

    • go to https://thegraph.com/studio/apikeys

    • connect an Ethereum address

    • sign the message to log in (Doesn't cost any Ether)

    • create API key

    • API key name: spool-v2

    • copy key as API_KEY

    • you can now query the Yelay subgraph for:

      • mainnet: https://gateway-arbitrum.network.thegraph.com/api/$API_KEY/subgraphs/id/41A5vZJ2fypeqtD8o5rD1HB7GjVkvP55NR3EeZDXkk2s (it says arbitrum in the URL but the data is just published on arbitrum, it's indexing mainnet)

      • sepolia: 'https://gateway-testnet-arbitrum.network.thegraph.com/api/$API_KEY/subgraphs/id/J5s1Q5ECEuvcyr8hfCVJxdebmwiQTGWbNGXu8GLfnSBj'

  • This will give you 100k queries for free every month.

  • Beyond that, payment is necessary. you can upgrade your plan here: https://thegraph.com/studio/billing/upgrade/ costs are about 4$ per 100k queries.

  • Alternatively, you may use a third party subgraph hosting service, such as Alchemy: https://www.alchemy.com/pricing.

  • Note that deployment of the subgraph to a third party hosting service must be completed for the Yelay subgraph to work there. The code is hosted here: https://github.com/spoolfi/spool-v2-core-subgraph/. There are detailed instructions in the README.

Example 2: test Yelay integration on Sepolia testnet

Yelay UI on Sepolia: https://sepolia.dev.spool.fi/sep/smart-vaults

SDKConfig:

import { getSepoliaConfig, SpoolSdk } from '@spool.fi/spool-v2-sdk';

const provider = new Wallet(pk, rpc);

const yelaySDK = new SpoolSdk(
  getSepoliaConfig(
    'https://subgraph.satsuma-prod.com/link-to-the-subgraph', // to get the link please contact the Spool team in Discord by tagging @web3lling
  ),
  provider,
);

Important! On Sepolia, each integrator could initiate running DoHardWork by themselves. Please, reach out to your respective Yelay's technical account manager or the Yelay team on Discord in order to whitelist your account if you want to run DHW on Sepolia.

Please follow these instructions: https://github.com/SpoolFi/spool-v2-testnet-utils/

Sepolia setup has been equipped with 4 ‘mock’ strategies for each asset group:

"strategies": {
    "mock": {
        "beacon": "0xb3752bbb715acae2a3e9c28200b5a0b319f583ef",
        "mock-dai": "0xcc239fff84045cc1c81203695ee5d2e05530f026",
        "mock-usdc": "0x07ffa21cbf983e2f2246750108d9248133c85a98",
        "mock-usdt": "0x68b19781cbe5724b1666d944c729aa15d6925e0b",
        "mock-weth": "0x7fd3f41f2de554d8528db74294a4382f4718f3ad"
    }
}

Example 3: SDKConfig on Arbitrum

import { SDKConfig } from '@spool.fi/spool-v2-sdk'; 
const contractAddresses: Record<number, ContractAddresses> = {
    42161: {
        ISmartVaultManager:'0x72d545d9eb856bd0076b20626ac0bc76d787e098',
        IDepositSwap: '0xab90bd85a5e3dc33ebacfced59ea9f31c3eb21a3',
        ISmartVaultFactory: '0x25be35117497169f771e657e6d7bee14898e54ce', // use 0xaB79c24b134A8be2f5DC801b338Bcb63F375f563 for high performance fees
        IDepositManager: '0x4A98260e9552b09703bf4493B43c72A6b75Be47E',
        IRewardManager: '0x378e4288826d094372d5f61f6f5451026fb481fe',
        IStrategyRegistry: '0x874de028d3cad13d6c33513d92ce1e75d849199d',
        ISpoolLens: '0x902cbdd00a233d2057a8327cad5475d643dba1dd',
        IMetaVaultFactory: '0x0',
        ISpoolAccessControl: '0x68306356f6dde2b8a731cD02F7466e75977EfCF9', // optional
    },
}; 

const config: SDKConfig = new SDKConfig(
    decentralisedSubgraphLink, // to get the link please contact the Spool team in Discord by tagging @web3lling
    'https://pricefeed.v2.spool.fi/',
    'https://rewards.v2.spool.fi/arbitrum/',
    'https://fastwithdraw.v2.spool.fi/arbitrum',
    contractAddresses, );

Ethers Provider and Signer

If you intend to use only the view-only functions, only the Provider object can be used.

If you are planning to call state-changing transactions, you will require a Signer to sign transactions.

Creating an instance of Provider

const rpc = new StaticJsonRpcProvider('your_rpc_url_here');

Creating an instance of Signer

const pk = 'your_private_key_here'
const rpc = new StaticJsonRpcProvider('your_rpc_url_here');
const signer = new Wallet(pk, rpc);

Please replace the placeholder values with the actual values required for your use case.

Last updated