###### tags: `discussion` # Dappio-ts update - [x] reserveWrapper.convertReserveAmountToLiquidityAmount - [x] reserveWrapper.partnerRewards refactor --> 1. one side to dual side 2. To extend the flexability for multi partnerRewards - [x] obligationWrapper.getRefreshedBorrowLimit (Both Solend + Larix) - [x] BORROWING_MULTIPLIER & calcBorrowingAPR for solend (calc the borrowing APR LM2.0) (WIP) ## Refactor dappio-ts ### Background The increasing rpc query amount by two servcies-workers features: 1. Pools Inside getAllProtocolPools(), allLpPools (Saber/ Raydium) need to be looped through. one key function under each pool use rpc request - getApr (getPoolBalance --> getAccountInfo x 2 + getMultiAccountInfo x 1 ) 2. TokenInfos Inside updateLpPrice(), allLpPools (Saber/Raydium) need to be looped through. two main functions under each pool use rpc requests - getLpPrice (getPoolBalance --> getAccountInfo x 2 + getMultiAccountInfo x 1) - getMintDecimal ![](https://i.imgur.com/8rQChKo.png) ### Refactor method Both getLpPrice & getApr uses getBalance which consumes the most of rpc querys - getAccountInfo(this.poolInfo.poolId) - getAccountInfo(this.poolInfo.ammOpenOrders) - .getMultipleAccountsInfo([ this.poolInfo.poolCoinTokenAccount, this.poolInfo.poolPcTokenAccount, ]) Generally speaking, it gets 4 data which are not inside the wrapper object 1. ammOpenOrders 2. PoolCoinTokenAccount 3. PoolPcTokenAccount 4. coinDecimals, 5. pcDecimals, Which all have already been got in wrapper but never used. What needs to be done should be 1. refactor parseV4PoolInfo --> and all above 5 variables reutrns as wapper project 2. Refactor getBalance --> just make uses of this.ammOpenOrders, this.poolCoinTokenAccount ... instead of fetech rpc data again. ## Raydium new function "getAllLedgers" added 1. Add one new file src/Raydium/ledgerInfo.ts ``` type LedgerInfo = { farmVersion: number; farmId: string; owner: string; deposited: number; rewardDebts: number[]; mints: { stakedTokenMint: string; rewardAMint: string; rewardBMint: string }; }; // Get all ledgers for certain user wallet. async function getAllLedgers( connection: Connection, ownerPubkey: PublicKey ): Promise<LedgerInfo[]> ``` To get all staked farms' ledger(nameing from Raydium SDK) info It includes two private not exported functions - getLedgerInfos: to retreive decoded ledger Acc Info - getFarmRelatedMints: Get the related mints (farmLpMint, rewardTokenAMint, rewardTokenBMint) for a certain ledger (miner) ## Raydium info updated 1. src/Raydium/info.ts Add one more ID which is not used in the SDK. This seems the new AMM program of Raydium. ``` export const LIQUIDITY_PROGRAM_ID_V5 = new PublicKey( "5quBtoiQqxF9Jv6KYKctB59NT3gtJD2Y65kdnB1Uev3h" ); ``` 2. Add some structs It does not rename the original struct, it is just a forward-looking design. What is being used are the ledger related struct ``` /* ================= state layouts ================= */ // Legacy name: STAKE_INFO_LAYOUT export const FARM_STATE_LAYOUT_V3 // Legacy name: STAKE_INFO_LAYOUT_V4 export const REAL_FARM_STATE_LAYOUT_V5 /* ================= ledger layouts ================= */ // Legacy name: USER_STAKE_INFO_ACCOUNT_LAYOUT export const FARM_LEDGER_LAYOUT_V3_1 // Legacy name: USER_STAKE_INFO_ACCOUNT_LAYOUT_V3_1 export const FARM_LEDGER_LAYOUT_V3_2 // Legacy name: USER_STAKE_INFO_ACCOUNT_LAYOUT_V4 export const FARM_LEDGER_LAYOUT_V5_1 // Legacy name: USER_STAKE_INFO_ACCOUNT_LAYOUT_V5 export const FARM_LEDGER_LAYOUT_V5_2 ```