Share amount could be zero
The execute_deposit function in meridian_executor::executor adds deposited tokens to the pool and shares the LP token with the depositor based on the proportion of the total deposit amount. The proportion of the LP token share is calculated as follows:
share_proportion = deposit_amount * BPS_BASE / total_deposit_amountWhen the total_deposit_amount is greater than deposit_amount * BPS_BASE, the share_proportion will be zero, resulting in the depositor receiving no LP token shares. For example, if one user deposits 100 USDC while 100 other users each deposit 10,000 USDC, the share proportion will be zero.
// Process each depositor's deposit, creating a smart account with proportional LP tokens and refund assets for each
vector::for_each(simple_map::keys(&depositor_map), |depositor_eth_address| {
// Determine the proportion of the deposit that the user contributed to the pool
let deposit_amounts = *simple_map::borrow(&depositor_map, &depositor_eth_address);
let share_proportion = math64::mul_div(*vector::borrow(&asset_amounts, 0), BPS_BASE, *vector::borrow(&deposit_amounts, 0)); // NOTE: the proportion should be the same for first vs. second asset
let depositor_lp_token_share = math64::mul_div(lp_token_amount, share_proportion, BPS_BASE);
let depositor_refund_shares = vector::map_ref(&refund_assets_amounts, |amount| math64::mul_div(*amount, share_proportion, BPS_BASE));
// Extract LP tokens & refunds from batched assets into the depositor's smart signer
let smart_signer = generate_smart_signer(depositor_eth_address);
primary_fungible_store::deposit(signer::address_of(&smart_signer), fungible_asset::extract(&mut lp_token, depositor_lp_token_share));
vector::enumerate_mut(&mut refund_assets, |index, asset| {
let refund_amount = *vector::borrow(&depositor_refund_shares, index);
primary_fungible_store::deposit(signer::address_of(&smart_signer), fungible_asset::extract(asset, refund_amount));
});
});