@@ -11,6 +11,7 @@ use solend_program::{
1111 instruction:: set_lending_market_owner_and_config,
1212 state:: { validate_reserve_config, RateLimiterConfig } ,
1313} ;
14+ use solend_sdk:: instruction:: upgrade_reserve_to_v2_1_0;
1415use solend_sdk:: {
1516 instruction:: {
1617 liquidate_obligation_and_redeem_reserve_collateral, redeem_reserve_collateral,
@@ -768,6 +769,20 @@ fn main() {
768769 . help ( "Risk authority address" ) ,
769770 )
770771 )
772+ . subcommand (
773+ SubCommand :: with_name ( "upgrade-reserve" )
774+ . about ( "Migrate reserve to version 2.1.0" )
775+ . arg (
776+ Arg :: with_name ( "reserve" )
777+ . long ( "reserve" )
778+ . validator ( is_pubkey)
779+ . value_name ( "PUBKEY" )
780+ . takes_value ( true )
781+ . required ( true )
782+ . help ( "Reserve address" ) ,
783+ )
784+
785+ )
771786 . subcommand (
772787 SubCommand :: with_name ( "update-reserve" )
773788 . about ( "Update a reserve config" )
@@ -1324,6 +1339,11 @@ fn main() {
13241339 risk_authority_pubkey,
13251340 )
13261341 }
1342+ ( "upgrade-reserve" , Some ( arg_matches) ) => {
1343+ let reserve_pubkey = pubkey_of ( arg_matches, "reserve" ) . unwrap ( ) ;
1344+
1345+ command_upgrade_reserve_to_v2_1_0 ( & mut config, reserve_pubkey)
1346+ }
13271347 ( "update-reserve" , Some ( arg_matches) ) => {
13281348 let reserve_pubkey = pubkey_of ( arg_matches, "reserve" ) . unwrap ( ) ;
13291349 let lending_market_owner_keypair =
@@ -1973,6 +1993,29 @@ fn command_set_lending_market_owner_and_config(
19731993 Ok ( ( ) )
19741994}
19751995
1996+ fn command_upgrade_reserve_to_v2_1_0 ( config : & mut Config , reserve_pubkey : Pubkey ) -> CommandResult {
1997+ let recent_blockhash = config. rpc_client . get_latest_blockhash ( ) ?;
1998+
1999+ let message = Message :: new_with_blockhash (
2000+ & [
2001+ ComputeBudgetInstruction :: set_compute_unit_price ( 30101 ) ,
2002+ upgrade_reserve_to_v2_1_0 (
2003+ config. lending_program_id ,
2004+ reserve_pubkey,
2005+ config. fee_payer . pubkey ( ) ,
2006+ ) ,
2007+ ] ,
2008+ Some ( & config. fee_payer . pubkey ( ) ) ,
2009+ & recent_blockhash,
2010+ ) ;
2011+
2012+ let transaction = Transaction :: new ( & vec ! [ config. fee_payer. as_ref( ) ] , message, recent_blockhash) ;
2013+
2014+ send_transaction ( config, transaction) ?;
2015+
2016+ Ok ( ( ) )
2017+ }
2018+
19762019#[ allow( clippy:: too_many_arguments, clippy:: unnecessary_unwrap) ]
19772020fn command_update_reserve (
19782021 config : & mut Config ,
0 commit comments