Skip to content

Commit 77188e2

Browse files
authored
Merge pull request #39 from aave/mike/improve/263
feat(pool_token_logic): transfer out remaining balance of underlying token when drop_reserve
2 parents a08f62b + 1604c74 commit 77188e2

File tree

3 files changed

+1342
-0
lines changed

3 files changed

+1342
-0
lines changed

aave-core/sources/aave-periphery/collector.move

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,12 @@ module aave_pool::collector {
137137
public fun get_collector_name(): vector<u8> {
138138
COLLECTOR_NAME
139139
}
140+
141+
#[test_only]
142+
/// @notice Returns the collector resource account signer for testing
143+
public fun get_collector_account_with_signer(): signer acquires CollectorData {
144+
// derive resource account signer
145+
let collector_data = borrow_global<CollectorData>(@aave_pool);
146+
account::create_signer_with_capability(&collector_data.resource_account)
147+
}
140148
}

aave-core/sources/aave-pool/pool_token_logic.move

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,26 @@ module aave_pool::pool_token_logic {
302302
error_config::get_eunderlying_claimable_rights_not_zero()
303303
);
304304

305+
// Check for remaining underlying assets in the resource account and transfer to treasury
306+
let remaining_underlying_balance =
307+
fungible_asset_manager::balance_of(
308+
a_token_factory::get_token_account_address(a_token_address),
309+
asset
310+
);
311+
312+
if (remaining_underlying_balance > 0) {
313+
// Get treasury address from aToken
314+
let treasury_address =
315+
a_token_factory::get_reserve_treasury_address(a_token_address);
316+
317+
// Transfer remaining underlying assets to treasury using a_token_factory
318+
a_token_factory::transfer_underlying_to(
319+
treasury_address,
320+
(remaining_underlying_balance as u256),
321+
a_token_address
322+
);
323+
};
324+
305325
// Remove the ReserveList from the smart table
306326
let active_reserve_count = pool::number_of_active_reserves();
307327
pool::delete_reserve_data(asset);

0 commit comments

Comments
 (0)