@@ -32,7 +32,7 @@ import { SolendStrategy } from 'Strategies/types/types'
3232import { VotingClient } from '@utils/uiTypes/VotePlugin'
3333import { AssetAccount } from '@utils/uiTypes/assets'
3434import { ConnectionContext } from '@utils/connection'
35- import { MAIN_POOL_CONFIGS , RESERVE_CONFIG } from '@hub/providers/Defi/plans/save'
35+ import { Config , ReserveConfig } from '@hub/providers/Defi/plans/save'
3636
3737const MAINNET_PROGRAM = 'So1endDq2YkqhipRh3WViPa8hdiSpxWy6z3Z6tMCpAo'
3838const DEVNET_PROGRAM = 'ALend7Ketfx5bxh6ghsCDXAoDrhvEmsXT3cynB6aPLgx'
@@ -65,38 +65,6 @@ export type CreateSolendStrategyParams = (
6565 client ?: VotingClient ,
6666) => Promise < PublicKey >
6767
68- type Config = Array < MarketConfig >
69-
70- type MarketConfig = {
71- name : string
72- isPrimary : boolean
73- description : string
74- creator : string
75- address : string
76- authorityAddress : string
77- reserves : Array < ReserveConfig >
78- }
79-
80- type ReserveConfig = {
81- liquidityToken : {
82- coingeckoID : string
83- decimals : number
84- logo : string
85- mint : string
86- name : string
87- symbol : string
88- volume24h : number
89- }
90- pythOracle : string
91- switchboardOracle : string
92- address : string
93- collateralMintAddress : string
94- collateralSupplyAddress : string
95- liquidityAddress : string
96- liquidityFeeReceiverAddress : string
97- userSupplyCap : number
98- }
99-
10068type ReserveStat = {
10169 reserve : {
10270 lendingMarket : string
@@ -173,13 +141,13 @@ export function cTokenExchangeRate(reserve: ReserveStat) {
173141 . toNumber ( )
174142}
175143
176- export async function getReserve ( ) : Promise < Config > {
144+ export async function getReserve ( ) : Promise < Config [ ] > {
177145 return await (
178146 await axios . get ( `${ SOLEND_ENDPOINT } /v1/markets/configs?scope=all` )
179147 ) . data
180148}
181149
182- export async function getReserves ( ) : Promise < Config [ 0 ] [ 'reserves' ] > {
150+ export async function getReserves ( ) : Promise < ReserveConfig [ ] > {
183151 const config = await getReserve ( )
184152 const reserves = config . flatMap ( ( market ) =>
185153 market . reserves . map ( ( reserve ) => ( {
@@ -526,37 +494,57 @@ export async function handleSolendActionV2(
526494 proposalIndex : number ,
527495 isDraft : boolean ,
528496 connection : ConnectionContext ,
529- client ?: VotingClient
497+ config : Config ,
498+ reserveConfig : ReserveConfig ,
499+ client ?: VotingClient ,
530500) {
531501 const isSol = matchedTreasury . isSol
532502 const owner = isSol
533503 ? matchedTreasury ! . pubkey
534504 : matchedTreasury ! . extensions ! . token ! . account . owner
535505
536506 const solendAction = form . action === 'Deposit' ? await SolendActionCore . buildDepositReserveLiquidityTxns (
537- MAIN_POOL_CONFIGS ,
538- RESERVE_CONFIG [ form . reserveAddress ] ,
507+ config ,
508+ {
509+ address : reserveConfig . address ,
510+ liquidityAddress : reserveConfig . liquidityAddress ,
511+ cTokenMint : reserveConfig . collateralMintAddress ,
512+ cTokenLiquidityAddress : reserveConfig . liquidityAddress ,
513+ pythOracle : reserveConfig . pythOracle ,
514+ switchboardOracle : reserveConfig . switchboardOracle ,
515+ mintAddress : reserveConfig . liquidityToken . mint ,
516+ liquidityFeeReceiverAddress : reserveConfig . liquidityFeeReceiverAddress ,
517+ } ,
539518 connection . current ,
540519 form . bnAmount . toString ( ) ,
541520 {
542521 publicKey : owner ,
543522 } ,
544523 {
545- lookupTableAddress : MAIN_POOL_CONFIGS . lookupTableAddress
546- ? new PublicKey ( MAIN_POOL_CONFIGS . lookupTableAddress )
524+ lookupTableAddress : config ? .lookupTableAddress
525+ ? new PublicKey ( config . lookupTableAddress )
547526 : undefined ,
548527 } ,
549528 ) : await SolendActionCore . buildRedeemReserveCollateralTxns (
550- MAIN_POOL_CONFIGS ,
551- RESERVE_CONFIG [ form . reserveAddress ] ,
529+ config ,
530+ {
531+ address : reserveConfig . address ,
532+ liquidityAddress : reserveConfig . liquidityAddress ,
533+ cTokenMint : reserveConfig . collateralMintAddress ,
534+ cTokenLiquidityAddress : reserveConfig . liquidityAddress ,
535+ pythOracle : reserveConfig . pythOracle ,
536+ switchboardOracle : reserveConfig . switchboardOracle ,
537+ mintAddress : reserveConfig . liquidityToken . mint ,
538+ liquidityFeeReceiverAddress : reserveConfig . liquidityFeeReceiverAddress ,
539+ } ,
552540 connection . current ,
553541 form . bnAmount . toString ( ) ,
554542 {
555543 publicKey : owner ,
556544 } ,
557545 {
558- lookupTableAddress : MAIN_POOL_CONFIGS . lookupTableAddress
559- ? new PublicKey ( MAIN_POOL_CONFIGS . lookupTableAddress )
546+ lookupTableAddress : config . lookupTableAddress
547+ ? new PublicKey ( config . lookupTableAddress )
560548 : undefined ,
561549 } ,
562550 ) ;
@@ -586,7 +574,7 @@ export async function handleSolendActionV2(
586574 form . title ||
587575 `${ form . action } ${ form . amountFmt } ${
588576 tokenPriceService . getTokenInfo (
589- RESERVE_CONFIG [ form . reserveAddress ] . mintAddress
577+ reserveConfig . liquidityToken . mint
590578 ) ?. symbol || 'tokens'
591579 } ${ form . action === 'Deposit' ? 'into' : 'from' } Save`,
592580 form . description ,
0 commit comments