diff --git a/README.md b/README.md index b5ba35a..81a264b 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ LP farming, leveraged yield farming, and more. - **Token Swaps**: Integrated Cetus aggregator for optimal token routing - **Type Safety**: Full TypeScript support with comprehensive type definitions - **Options-Based API**: Consistent, easy-to-use interface across all methods +- **GraphQL-First Data Access**: SDK now initializes with network + optional GraphQL URL ## Installation @@ -24,13 +25,14 @@ npm install @alphafi/alphafi-sdk ```typescript import { AlphaFiSDK } from '@alphafi/alphafi-sdk'; -import { SuiClient } from '@mysten/sui/client'; // Initialize the SDK -const suiClient = new SuiClient({ url: 'https://fullnode.mainnet.sui.io:443' }); const sdk = new AlphaFiSDK({ - suiClient, network: 'mainnet', + // Optional override (defaults by network): + // testnet -> https://graphql.testnet.sui.io/graphql + // mainnet -> https://graphql.mainnet.sui.io/graphql + graphqlUrl: process.env.SUI_GRAPHQL_URL, }); const userAddress = 'your_sui_address_here'; @@ -54,8 +56,9 @@ const depositTx = await sdk.deposit({ amount: 1000000000n, // 1 SUI in base units isAmountA: true, // For LP pools: which token this amount represents }); -// Sign & execute with your wallet / client -// await suiClient.signAndExecuteTransactionBlock({ transactionBlock: depositTx, signer }); +// Sign & execute with your wallet / signer integration +// (example shown for shape only) +// await signerClient.signAndExecuteTransaction({ transaction: depositTx, signer }); // Build an unsigned withdraw transaction const withdrawTx = await sdk.withdraw({ @@ -126,12 +129,37 @@ new AlphaFiSDK(config: AlphaFiSDKConfig) #### Configuration Interface ```typescript +import type { Network } from '@alphafi/alphalend-sdk'; + interface AlphaFiSDKConfig { - suiClient: SuiClient; // Sui blockchain client - network: 'mainnet' | 'testnet' | 'devnet' | 'localnet'; + network: Network; // Target network + graphqlUrl?: string; // Optional GraphQL endpoint override + apiBaseUrl?: string; // Optional AlphaFi API base URL override } ``` +#### Migration from Previous Initialization + +If you were previously passing `suiClient` to `AlphaFiSDK`, migrate to `network` + optional +`graphqlUrl`: + +```typescript +// Old +const sdk = new AlphaFiSDK({ + suiClient, + network: 'mainnet', +}); + +// New +const sdk = new AlphaFiSDK({ + network: 'mainnet', + graphqlUrl: process.env.SUI_GRAPHQL_URL, // optional +}); +``` + +Under the hood, strategies now use a shared context-level AlphaLend client and resolve AlphaLend +constants from the active SDK network instead of hardcoded mainnet assumptions. + #### Core Methods ##### getPoolsData(strategiesType?: StrategyType[]): Promise\> @@ -389,15 +417,11 @@ for (const [poolId, poolData] of allPools) { ```typescript import { AlphaFiSDK } from '@alphafi/alphafi-sdk'; -import { SuiClient } from '@mysten/sui/client'; - -const suiClient = new SuiClient({ - url: process.env.SUI_RPC_URL || 'https://fullnode.mainnet.sui.io:443', -}); const sdk = new AlphaFiSDK({ - suiClient, network: (process.env.NETWORK as any) || 'mainnet', + graphqlUrl: process.env.SUI_GRAPHQL_URL, // optional + apiBaseUrl: process.env.ALPHAFI_API_URL, // optional }); const userAddress = process.env.USER_ADDRESS; diff --git a/package-lock.json b/package-lock.json index 709ac07..0ce5645 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,8 +9,8 @@ "version": "1.1.0", "license": "ISC", "dependencies": { - "@alphafi/alphalend-sdk": "^1.1.28", - "@alphafi/stsui-sdk": "^0.0.23", + "@alphafi/alphalend-sdk": "^2.0.0", + "@alphafi/stsui-sdk": "^1.0.0", "@apollo/client": "^4.0.11", "@cetusprotocol/aggregator-sdk": "^1.4.2", "@cetusprotocol/cetus-sui-clmm-sdk": "5.4.0", @@ -133,9 +133,9 @@ } }, "node_modules/@alphafi/alphalend-sdk": { - "version": "1.1.28", - "resolved": "https://registry.npmjs.org/@alphafi/alphalend-sdk/-/alphalend-sdk-1.1.28.tgz", - "integrity": "sha512-5dcrkcvR2+IHnkznn12v/uYT1s/3voh/q+r4h9sTBTdLzVnTUznpJKDSF3DlrZ01NUwTHtzQvncv/VaYwSdpIg==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@alphafi/alphalend-sdk/-/alphalend-sdk-2.0.0.tgz", + "integrity": "sha512-Lm8natJ2njZZFaEkDl2Ii7I2BwPPZrreZj1ArD6UyxQiLFFxLMbndx2OQjgw0e04aizBIuEcO8X3M0MN5akGPw==", "license": "ISC", "dependencies": { "@7kprotocol/sdk-ts": "^3.4.1", @@ -154,9 +154,9 @@ } }, "node_modules/@alphafi/stsui-sdk": { - "version": "0.0.23", - "resolved": "https://registry.npmjs.org/@alphafi/stsui-sdk/-/stsui-sdk-0.0.23.tgz", - "integrity": "sha512-TawhKr1fNczDLSWKGkAV66Wr1JBUAER4456n7klOlzeIhv0x+FwA+ws9Wbpuehfow7DwxuQBVkMFQXiQGEl0EA==", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@alphafi/stsui-sdk/-/stsui-sdk-1.0.0.tgz", + "integrity": "sha512-nCBIzhOw9cU1Mb04iMkACkv3ousyz9s6FyTIl9l+Bo2AIFYCbrYxhHPvOEPaYzUT8zNLOnr9q4N9yoadlIQ07Q==", "license": "ISC", "dependencies": { "@types/bn.js": "^5.1.6", diff --git a/package.json b/package.json index d28b960..d3b1c24 100644 --- a/package.json +++ b/package.json @@ -39,8 +39,8 @@ "author": "AlphaFi", "license": "ISC", "dependencies": { - "@alphafi/alphalend-sdk": "^1.1.28", - "@alphafi/stsui-sdk": "^0.0.23", + "@alphafi/alphalend-sdk": "^2.0.0", + "@alphafi/stsui-sdk": "^1.0.0", "@apollo/client": "^4.0.11", "@cetusprotocol/aggregator-sdk": "^1.4.2", "@cetusprotocol/cetus-sui-clmm-sdk": "5.4.0", diff --git a/src/core/index.ts b/src/core/index.ts index 946f2a1..053a32f 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -60,7 +60,11 @@ export class AlphaFiSDK { constructor(config: AlphaFiSDKConfig) { this.config = config; - this.strategyContext = new StrategyContext(config.network, config.suiClient, config.apiBaseUrl); + this.strategyContext = new StrategyContext( + config.network, + config.graphqlUrl, + config.apiBaseUrl, + ); this.protocol = new Protocol(this.strategyContext); this.portfolio = new Portfolio(this.protocol, this.strategyContext); } diff --git a/src/core/types.ts b/src/core/types.ts index a773481..4314f19 100644 --- a/src/core/types.ts +++ b/src/core/types.ts @@ -2,19 +2,18 @@ * Core types and configuration interfaces for the AlphaFi SDK. * These types define the structure for all SDK operations. */ - -import { SuiClient } from '@mysten/sui/client'; import { Transaction } from '@mysten/sui/transactions'; import { RouterDataV3 } from '@cetusprotocol/aggregator-sdk'; +import { Network } from '@alphafi/alphalend-sdk'; /** * Configuration required to initialize the AlphaFi SDK. */ export interface AlphaFiSDKConfig { - /** Sui blockchain client for network operations */ - suiClient: SuiClient; /** Target Sui network environment */ - network: 'mainnet' | 'testnet' | 'devnet' | 'localnet'; + network: Network; + /** Optional Sui GraphQL endpoint override for network operations */ + graphqlUrl?: string; /** Base URL for the AlphaFi API (defaults to 'https://api.alphafi.xyz') */ apiBaseUrl?: string; } diff --git a/src/models/blockchain.ts b/src/models/blockchain.ts index e65b8e4..0ed283b 100644 --- a/src/models/blockchain.ts +++ b/src/models/blockchain.ts @@ -8,36 +8,36 @@ import { graphql } from '@mysten/sui/graphql/schemas/latest'; import { Transaction } from '@mysten/sui/transactions'; import { toBase64 } from '@mysten/sui/utils'; import type { SimulationGasSummary, SimulationResult } from './types.js'; +import { Network } from '@alphafi/alphalend-sdk'; export type BlockchainOptions = { - network: 'mainnet' | 'testnet' | 'devnet' | 'localnet'; - suiClient?: SuiClient; - gqlClient?: SuiGraphQLClient; + network: Network; + txBuildClient?: SuiClient; + graphqlUrl?: string; }; export class Blockchain { - network: 'mainnet' | 'testnet' | 'devnet' | 'localnet'; - gqlClient: SuiGraphQLClient; - suiClient: SuiClient; + network: Network; + graphqlUrl: string; + gqlClient: SuiGraphQLClient; + txBuildClient: SuiClient; constructor(options: BlockchainOptions) { this.network = options.network; - this.suiClient = - options.suiClient || - new SuiClient({ - url: - options.network === 'testnet' - ? 'https://fullnode.testnet.sui.io/' - : 'https://fullnode.mainnet.sui.io/', - }); - this.gqlClient = - options.gqlClient || - new SuiGraphQLClient({ - url: - options.network === 'testnet' - ? 'https://graphql.testnet.sui.io/graphql' - : 'https://graphql.mainnet.sui.io/graphql', - }); + this.graphqlUrl = + options.graphqlUrl ?? + (options.network === 'testnet' + ? 'https://graphql.testnet.sui.io/graphql' + : 'https://graphql.mainnet.sui.io/graphql'); + this.txBuildClient = new SuiClient({ + url: + options.network === 'testnet' + ? 'https://fullnode.testnet.sui.io/' + : 'https://fullnode.mainnet.sui.io/', + }); + this.gqlClient = new SuiGraphQLClient({ + url: this.graphqlUrl, + }); } async getCoinObject(tx: Transaction, coinType: string, address: string, amount?: bigint) { @@ -126,7 +126,7 @@ export class Blockchain { sender: string, ): Promise { tx.setSenderIfNotSet(sender); - const txBytes = await tx.build({ client: this.suiClient }); + const txBytes = await tx.build({ client: this.txBuildClient }); const txBase64 = toBase64(txBytes); const query = graphql(` diff --git a/src/models/strategyContext.ts b/src/models/strategyContext.ts index a9e53a8..bdf1859 100644 --- a/src/models/strategyContext.ts +++ b/src/models/strategyContext.ts @@ -9,10 +9,9 @@ import { Blockchain } from './blockchain.js'; import { CoinInfoProvider } from './coinInfoProvider.js'; import { PoolLabel, StrategyType } from '../strategies/strategy.js'; import { Decimal } from 'decimal.js'; -import { AlphalendClient } from '@alphafi/alphalend-sdk'; +import { AlphalendClient, Network } from '@alphafi/alphalend-sdk'; import { AlphaFiReceipt, AprData, CoinInfo, DistributorObject, SlushPositionCap } from './types.js'; import { normalizeStructTag } from '@mysten/sui/utils'; -import { SuiClient } from '@mysten/sui/client/index.js'; import { ALPHAFI_RECEIPT_TYPE, CACHE_TTL, @@ -28,6 +27,7 @@ export class StrategyContext { readonly apiBaseUrl: string; blockchain: Blockchain; coinInfoProvider: CoinInfoProvider; + alphalendClient: AlphalendClient; // Singleton caches for global data private allPoolLabelsCache: SingletonCache>; // For bulk fetches @@ -44,14 +44,11 @@ export class StrategyContext { private slushPositionsCache: Cache>; private alphaFiPositionsCache: Cache>; - constructor( - network: 'mainnet' | 'testnet' | 'devnet' | 'localnet', - suiClient: SuiClient, - apiBaseUrl?: string, - ) { + constructor(network: Network, graphqlUrl?: string, apiBaseUrl?: string) { this.apiBaseUrl = apiBaseUrl ?? DEFAULT_API_BASE_URL; - this.blockchain = new Blockchain({ network, suiClient }); + this.blockchain = new Blockchain({ network, graphqlUrl }); this.coinInfoProvider = new CoinInfoProvider(); + this.alphalendClient = new AlphalendClient(network, graphqlUrl); // Initialize singleton caches with appropriate TTLs this.allPoolLabelsCache = new SingletonCache(CACHE_TTL.POOL_LABELS); @@ -515,8 +512,7 @@ export class StrategyContext { private async fetchAlphaLendTvl(): Promise> { const tvlMap = new Map(); - const alphalendClient = new AlphalendClient('mainnet', this.blockchain.suiClient); - const markets = await alphalendClient.getAllMarkets({ + const markets = await this.alphalendClient.getAllMarkets({ useCache: true, cacheTTL: CACHE_TTL.ALPHALEND_MARKETS, }); diff --git a/src/strategies/alphaVault.ts b/src/strategies/alphaVault.ts index 1c8fd4d..cb0e2cb 100644 --- a/src/strategies/alphaVault.ts +++ b/src/strategies/alphaVault.ts @@ -17,7 +17,7 @@ import { POOLS, VERSIONS, } from '../utils/constants.js'; -import { AlphalendClient, getConstants, getUserPositionCapId } from '@alphafi/alphalend-sdk'; +import { getConstants, getUserPositionCapId } from '@alphafi/alphalend-sdk'; /** * AlphaVault Strategy @@ -917,7 +917,7 @@ export class AlphaVaultStrategy extends BaseStrategy< } async claimAirdrop(tx: Transaction, address: string, transferToWallet: boolean) { - const alphalendClient = new AlphalendClient('mainnet', this.context.blockchain.suiClient); + const alphalendClient = this.context.alphalendClient; let airdropCoin; const [suiCoin, alphaCoin] = await this.context.getCoinsBySymbols(['SUI', 'ALPHA']); const airdropCoinMarketId = '1'; @@ -1010,10 +1010,9 @@ export class AlphaVaultStrategy extends BaseStrategy< if (!transferToWallet) { await alphalendClient.updatePrices(tx, ['0x2::sui::SUI']); - const alphalendConstants = getConstants('mainnet'); + const alphalendConstants = getConstants(this.context.blockchain.network); const userPositionCapId = await getUserPositionCapId( - this.context.blockchain.suiClient, - 'mainnet', + this.context.alphalendClient.blockchain, address, ); if (!userPositionCapId) { diff --git a/src/strategies/lending.ts b/src/strategies/lending.ts index 2743835..39c48e6 100644 --- a/src/strategies/lending.ts +++ b/src/strategies/lending.ts @@ -870,7 +870,7 @@ export class LendingStrategy extends BaseStrategy< private async updateSingleTokenPrice(tx: Transaction, pythPriceInfo: string, feedId: string) { const pythClient = new SuiPythClient( - this.context.blockchain.suiClient, + this.context.blockchain.txBuildClient, PYTH_STATE_ID, WORMHOLE_STATE_ID, ); diff --git a/src/strategies/looping.ts b/src/strategies/looping.ts index aa08fcc..dbf0465 100644 --- a/src/strategies/looping.ts +++ b/src/strategies/looping.ts @@ -21,7 +21,6 @@ import { VERSIONS, WORMHOLE_STATE_ID, } from '../utils/constants.js'; -import { AlphalendClient } from '@alphafi/alphalend-sdk'; import { stSuiExchangeRate, getConf as getStSuiConf } from '@alphafi/stsui-sdk'; import { SuiPriceServiceConnection, SuiPythClient } from '@pythnetwork/pyth-sui-js'; @@ -573,7 +572,7 @@ export class LoopingStrategy extends BaseStrategy< private async updateSingleTokenPrice(tx: Transaction, pythPriceInfo: string, feedId: string) { const pythClient = new SuiPythClient( - this.context.blockchain.suiClient, + this.context.blockchain.txBuildClient, PYTH_STATE_ID, WORMHOLE_STATE_ID, ); @@ -873,7 +872,7 @@ export class LoopingStrategy extends BaseStrategy< 'ALPHA', 'BLUE', ]); - const alphalendClient = new AlphalendClient('mainnet', this.context.blockchain.suiClient); + const alphalendClient = this.context.alphalendClient; await alphalendClient.updatePrices(tx, [stsuiCoin.coinType, suiCoin.coinType]); tx.moveCall({ diff --git a/src/strategies/lyf.ts b/src/strategies/lyf.ts index 5e2c6c5..aa69bd9 100644 --- a/src/strategies/lyf.ts +++ b/src/strategies/lyf.ts @@ -19,7 +19,6 @@ import { SUI_SYSTEM_STATE, VERSIONS, } from '../utils/constants.js'; -import { AlphalendClient } from '@alphafi/alphalend-sdk'; import { getConf as getStsuiConf } from '@alphafi/stsui-sdk'; /** @@ -662,7 +661,7 @@ export class LyfStrategy extends BaseStrategy< await this.collectAndSwapRewards(tx); - const alphalendClient = new AlphalendClient('mainnet', this.context.blockchain.suiClient); + const alphalendClient = this.context.alphalendClient; await alphalendClient.updatePrices(tx, [ this.poolLabel.assetA.type, this.poolLabel.assetB.type, diff --git a/src/strategies/singleAssetLooping.ts b/src/strategies/singleAssetLooping.ts index ea63ea6..3beac9a 100644 --- a/src/strategies/singleAssetLooping.ts +++ b/src/strategies/singleAssetLooping.ts @@ -8,7 +8,6 @@ import { PoolBalance, PoolData, SingleTvl } from '../models/types.js'; import { StrategyContext } from '../models/strategyContext.js'; import { DepositOptions, WithdrawOptions } from '../core/types.js'; import { Transaction, TransactionResult } from '@mysten/sui/transactions'; -import { AlphalendClient } from '@alphafi/alphalend-sdk'; import { ALPHALEND_LENDING_PROTOCOL_ID, CLOCK_PACKAGE_ID, @@ -315,7 +314,7 @@ export class SingleAssetLoopingStrategy extends BaseStrategy< 'wBTC', 'XAUm', ]); - let coinTypes = [ + const coinTypes = [ alphaCoin, stsuiCoin, suiCoin, @@ -327,14 +326,11 @@ export class SingleAssetLoopingStrategy extends BaseStrategy< suibtcCoin, xaumCoin, ].map((entry) => entry.coinType); - const alphalendClient = new AlphalendClient( - this.context.blockchain.network, - this.context.blockchain.suiClient, - ); + const alphalendClient = this.context.alphalendClient; await alphalendClient.updatePrices(tx, [this.poolLabel.asset.type]); const positionId = this.investorObject.positionCap.positionId; - let portfolio = await alphalendClient.getUserPortfolioFromPosition(positionId); - let rewards = portfolio?.rewardsToClaim; + const portfolio = await alphalendClient.getUserPortfolioFromPosition(positionId); + const rewards = portfolio?.rewardsToClaim; if (!rewards) { console.log('no rewards for pool id: ', this.poolLabel.poolId); return; @@ -490,10 +486,7 @@ export class SingleAssetLoopingStrategy extends BaseStrategy< } async deposit(tx: Transaction, options: DepositOptions) { - const alphalendClient = new AlphalendClient( - this.context.blockchain.network, - this.context.blockchain.suiClient, - ); + const alphalendClient = this.context.alphalendClient; // get Coin Object const depositCoin = await this.context.blockchain.getCoinObject( @@ -533,11 +526,8 @@ export class SingleAssetLoopingStrategy extends BaseStrategy< if (this.receiptObjects.length === 0) { throw new Error('No receipt found'); } - const alphalendClient = new AlphalendClient( - this.context.blockchain.network, - this.context.blockchain.suiClient, - ); - alphalendClient.updatePrices(tx, [this.poolLabel.asset.type]); + const alphalendClient = this.context.alphalendClient; + await alphalendClient.updatePrices(tx, [this.poolLabel.asset.type]); let xTokens = this.coinAmountToXToken(options.amount); if (options.withdrawMax) { diff --git a/src/strategies/slushLending.ts b/src/strategies/slushLending.ts index d27cc20..f0c0fb3 100644 --- a/src/strategies/slushLending.ts +++ b/src/strategies/slushLending.ts @@ -8,7 +8,6 @@ import { PoolBalance, PoolData, SingleTvl } from '../models/types.js'; import { StrategyContext } from '../models/strategyContext.js'; import { DepositOptions, WithdrawOptions } from '../core/types.js'; import { Transaction, TransactionResult } from '@mysten/sui/transactions'; -import { AlphalendClient } from '@alphafi/alphalend-sdk'; import { ALPHALEND_LENDING_PROTOCOL_ID, CLOCK_PACKAGE_ID, @@ -400,7 +399,7 @@ export class SlushLendingStrategy extends BaseStrategy< } async deposit(tx: Transaction, options: DepositOptions) { - const alphalendClient = new AlphalendClient('mainnet', this.context.blockchain.suiClient); + const alphalendClient = this.context.alphalendClient; await alphalendClient.updatePrices(tx, [this.poolLabel.asset.type]); // Get coin object @@ -452,7 +451,7 @@ export class SlushLendingStrategy extends BaseStrategy< throw new Error('No receipt found for withdraw'); } - const alphalendClient = new AlphalendClient('mainnet', this.context.blockchain.suiClient); + const alphalendClient = this.context.alphalendClient; await alphalendClient.updatePrices(tx, [this.poolLabel.asset.type]); let xTokenAmount = this.coinAmountToXToken(options.amount); diff --git a/src/strategies/slushSingleAssetLooping.ts b/src/strategies/slushSingleAssetLooping.ts index b6ae6f3..7be0e02 100644 --- a/src/strategies/slushSingleAssetLooping.ts +++ b/src/strategies/slushSingleAssetLooping.ts @@ -8,7 +8,6 @@ import { PoolBalance, PoolData, SingleTvl, UserWithdrawalStatus } from '../model import { StrategyContext } from '../models/strategyContext.js'; import { DepositOptions, WithdrawOptions } from '../core/types.js'; import { Transaction, TransactionResult } from '@mysten/sui/transactions'; -import { AlphalendClient } from '@alphafi/alphalend-sdk'; import { ALPHALEND_LENDING_PROTOCOL_ID, CLOCK_PACKAGE_ID, @@ -292,7 +291,7 @@ export class SlushSingleAssetLoopingStrategy extends BaseStrategy< } async deposit(tx: Transaction, options: DepositOptions) { - const alphalendClient = new AlphalendClient('mainnet', this.context.blockchain.suiClient); + const alphalendClient = this.context.alphalendClient; await alphalendClient.updatePrices(tx, [this.poolLabel.asset.type]); await this.collectAndSwapRewards(tx); @@ -344,7 +343,7 @@ export class SlushSingleAssetLoopingStrategy extends BaseStrategy< throw new Error('No receipt found for withdraw'); } - const alphalendClient = new AlphalendClient('mainnet', this.context.blockchain.suiClient); + const alphalendClient = this.context.alphalendClient; await alphalendClient.updatePrices(tx, [this.poolLabel.asset.type]); await this.collectAndSwapRewards(tx); @@ -372,7 +371,7 @@ export class SlushSingleAssetLoopingStrategy extends BaseStrategy< } async claimWithdraw(tx: Transaction, withdrawRequestId: string, address: string) { - const alphalendClient = new AlphalendClient('mainnet', this.context.blockchain.suiClient); + const alphalendClient = this.context.alphalendClient; await alphalendClient.updatePrices(tx, [this.poolLabel.asset.type]); await this.collectAndSwapRewards(tx); const positionCaps = await this.context.getSlushPositionCaps(address); @@ -397,7 +396,7 @@ export class SlushSingleAssetLoopingStrategy extends BaseStrategy< tx.transferObjects([coin], address); } async cancelWithdraw(tx: Transaction, withdrawRequestId: string, address: string) { - const alphalendClient = new AlphalendClient('mainnet', this.context.blockchain.suiClient); + const alphalendClient = this.context.alphalendClient; await alphalendClient.updatePrices(tx, [this.poolLabel.asset.type]); await this.collectAndSwapRewards(tx); const positionCaps = await this.context.getSlushPositionCaps(address); @@ -466,16 +465,13 @@ export class SlushSingleAssetLoopingStrategy extends BaseStrategy< xaumCoin, ].map((entry) => entry.coinType); - const alphalendClient = new AlphalendClient( - this.context.blockchain.network, - this.context.blockchain.suiClient, - ); + const alphalendClient = this.context.alphalendClient; // Get position ID from the pool object (investor is embedded) const positionId = this.poolObject.investor.positionCap.positionId; - let portfolio = await alphalendClient.getUserPortfolioFromPosition(positionId); - let rewards = portfolio?.rewardsToClaim; + const portfolio = await alphalendClient.getUserPortfolioFromPosition(positionId); + const rewards = portfolio?.rewardsToClaim; if (!rewards) { console.log('no rewards for pool id: ', this.poolLabel.poolId);