@@ -6,6 +6,7 @@ use solana_client::rpc_config::{RpcProgramAccountsConfig, RpcSendTransactionConf
6
6
use solana_client:: { rpc_config:: RpcAccountInfoConfig , rpc_filter:: RpcFilterType } ;
7
7
use solana_sdk:: bs58;
8
8
use solana_sdk:: instruction:: Instruction ;
9
+ use solana_sdk:: pubkey;
9
10
use solana_sdk:: { commitment_config:: CommitmentLevel , compute_budget:: ComputeBudgetInstruction } ;
10
11
use solend_program:: {
11
12
instruction:: set_lending_market_owner_and_config,
@@ -1237,7 +1238,6 @@ fn main() {
1237
1238
let borrow_fee_wad = ( borrow_fee * WAD as f64 ) as u64 ;
1238
1239
let flash_loan_fee_wad = ( flash_loan_fee * WAD as f64 ) as u64 ;
1239
1240
1240
- let liquidity_fee_receiver_keypair = Keypair :: new ( ) ;
1241
1241
let protocol_liquidation_fee =
1242
1242
value_of ( arg_matches, "protocol_liquidation_fee" ) . unwrap ( ) ;
1243
1243
let protocol_take_rate = value_of ( arg_matches, "protocol_take_rate" ) . unwrap ( ) ;
@@ -1254,6 +1254,11 @@ fn main() {
1254
1254
. unwrap ( ) ;
1255
1255
let source_liquidity_mint =
1256
1256
Mint :: unpack_from_slice ( source_liquidity_mint_account. data . borrow ( ) ) . unwrap ( ) ;
1257
+ let fee_receiver = get_or_create_associated_token_address_for_pubkey (
1258
+ & pubkey ! ( "9RuqAN42PTUi9ya59k9suGATrkqzvb9gk2QABJtQzGP5" ) ,
1259
+ & config,
1260
+ & source_liquidity. mint ,
1261
+ ) ;
1257
1262
1258
1263
let liquidity_amount = ui_amount_to_amount ( ui_amount, source_liquidity_mint. decimals ) ;
1259
1264
let deposit_limit = ui_amount_to_amount ( deposit_limit, source_liquidity_mint. decimals ) ;
@@ -1281,7 +1286,7 @@ fn main() {
1281
1286
} ,
1282
1287
deposit_limit,
1283
1288
borrow_limit,
1284
- fee_receiver : liquidity_fee_receiver_keypair . pubkey ( ) ,
1289
+ fee_receiver,
1285
1290
protocol_liquidation_fee,
1286
1291
protocol_take_rate,
1287
1292
added_borrow_weight_bps,
@@ -1298,7 +1303,6 @@ fn main() {
1298
1303
pyth_product_pubkey,
1299
1304
pyth_price_pubkey,
1300
1305
switchboard_feed_pubkey,
1301
- liquidity_fee_receiver_keypair,
1302
1306
source_liquidity,
1303
1307
)
1304
1308
}
@@ -1719,7 +1723,6 @@ fn command_add_reserve(
1719
1723
pyth_product_pubkey : Pubkey ,
1720
1724
pyth_price_pubkey : Pubkey ,
1721
1725
switchboard_feed_pubkey : Pubkey ,
1722
- liquidity_fee_receiver_keypair : Keypair ,
1723
1726
source_liquidity : Token ,
1724
1727
) -> CommandResult {
1725
1728
let reserve_keypair = Keypair :: new ( ) ;
@@ -1743,10 +1746,6 @@ fn command_add_reserve(
1743
1746
"Adding liquidity supply {}" ,
1744
1747
liquidity_supply_keypair. pubkey( )
1745
1748
) ;
1746
- println ! (
1747
- "Adding liquidity fee receiver {}" ,
1748
- liquidity_fee_receiver_keypair. pubkey( )
1749
- ) ;
1750
1749
println ! (
1751
1750
"Adding user collateral {}" ,
1752
1751
user_collateral_keypair. pubkey( )
@@ -1815,22 +1814,13 @@ fn command_add_reserve(
1815
1814
) ;
1816
1815
1817
1816
let message_2 = Message :: new_with_blockhash (
1818
- & [
1819
- create_account (
1820
- & config. fee_payer . pubkey ( ) ,
1821
- & liquidity_supply_keypair. pubkey ( ) ,
1822
- liquidity_supply_balance,
1823
- Token :: LEN as u64 ,
1824
- & spl_token:: id ( ) ,
1825
- ) ,
1826
- create_account (
1827
- & config. fee_payer . pubkey ( ) ,
1828
- & liquidity_fee_receiver_keypair. pubkey ( ) ,
1829
- liquidity_fee_receiver_balance,
1830
- Token :: LEN as u64 ,
1831
- & spl_token:: id ( ) ,
1832
- ) ,
1833
- ] ,
1817
+ & [ create_account (
1818
+ & config. fee_payer . pubkey ( ) ,
1819
+ & liquidity_supply_keypair. pubkey ( ) ,
1820
+ liquidity_supply_balance,
1821
+ Token :: LEN as u64 ,
1822
+ & spl_token:: id ( ) ,
1823
+ ) ] ,
1834
1824
Some ( & config. fee_payer . pubkey ( ) ) ,
1835
1825
& recent_blockhash,
1836
1826
) ;
@@ -1899,11 +1889,7 @@ fn command_add_reserve(
1899
1889
) ;
1900
1890
// send_transaction(config, transaction_1)?;
1901
1891
let transaction_2 = Transaction :: new (
1902
- & vec ! [
1903
- config. fee_payer. as_ref( ) ,
1904
- & liquidity_supply_keypair,
1905
- & liquidity_fee_receiver_keypair,
1906
- ] ,
1892
+ & vec ! [ config. fee_payer. as_ref( ) , & liquidity_supply_keypair] ,
1907
1893
message_2,
1908
1894
recent_blockhash,
1909
1895
) ;
@@ -2636,3 +2622,35 @@ fn get_or_create_associated_token_address(config: &Config, mint: &Pubkey) -> Pub
2636
2622
2637
2623
ata
2638
2624
}
2625
+
2626
+ fn get_or_create_associated_token_address_for_pubkey (
2627
+ pubkey : & Pubkey ,
2628
+ config : & Config ,
2629
+ mint : & Pubkey ,
2630
+ ) -> Pubkey {
2631
+ let ata = get_associated_token_address ( pubkey, mint) ;
2632
+
2633
+ if config. rpc_client . get_account ( & ata) . is_err ( ) {
2634
+ println ! ( "Creating ATA for mint {:?}" , mint) ;
2635
+
2636
+ let recent_blockhash = config. rpc_client . get_latest_blockhash ( ) . unwrap ( ) ;
2637
+ let transaction = Transaction :: new (
2638
+ & vec ! [ config. fee_payer. as_ref( ) ] ,
2639
+ Message :: new_with_blockhash (
2640
+ & [ create_associated_token_account (
2641
+ & config. fee_payer . pubkey ( ) ,
2642
+ pubkey,
2643
+ mint,
2644
+ & spl_associated_token_account:: id ( ) ,
2645
+ ) ] ,
2646
+ Some ( & config. fee_payer . pubkey ( ) ) ,
2647
+ & recent_blockhash,
2648
+ ) ,
2649
+ recent_blockhash,
2650
+ ) ;
2651
+
2652
+ send_transaction ( config, transaction) . unwrap ( ) ;
2653
+ }
2654
+
2655
+ ata
2656
+ }
0 commit comments