Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check if get actual supply exists #69

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions contracts/vaults/BalancerWeightedAuraVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,19 @@ contract BalancerWeightedAuraVault is AuraStakingMixin {

return _calculateLPTokenValue(balances, spotPrices);
}

/// @notice Weighted pools may have pre-minted BPT. If that is the case then
/// we need to call getActualSupply() instead. Legacy pools do not have the
/// getActualSupply method. See:
/// https://docs.balancer.fi/concepts/advanced/valuing-bpt/valuing-bpt.html#getting-bpt-supply
function _totalPoolSupply() internal view override returns (uint256) {
// As of this writing the documentation linked above appears inaccurate and the
// pre-minted total supply returned by a pool is not a fixed constant. Therefore,
// we use a try / catch here instead.
try IComposablePool(address(BALANCER_POOL_TOKEN)).getActualSupply() returns (uint256 totalSupply) {
return totalSupply;
} catch {
return super._totalPoolSupply();
}
}
}