Calculate the excess above the target value
Allowed asset value equals total portfolio value × maximum weight. Required sale value equals max(0, current asset value − allowed asset value). Current weight equals current asset value ÷ total portfolio value. Total value must be positive, asset value must be nonnegative and no greater than total value, and the cap should lie from zero to 100%. When the asset already fits the cap, the required sale is zero.
Work through an internal reallocation
Suppose a hypothetical portfolio is worth $100,000, with $32,000 in one asset and a 20% cap. The allowed value is $20,000, so the modeled sale is $12,000. Reallocating those proceeds elsewhere inside the portfolio leaves total value at $100,000 and the selected asset at exactly 20%. A 25% cap would require selling $7,000 instead, under the same unchanged valuation and zero-cost assumptions.
Keep proceeds and transaction costs consistent
If the $12,000 proceeds leave the portfolio, total value falls to $88,000 and the remaining $20,000 position weighs about 22.73%. That is a different problem from this fixed-total calculation. Fees, taxes, market impact, and subsequent price movement can also change the denominator or realized sale value. Converting a sale value to token or share units requires an asset price. The cap is a user-entered allocation rule, not a suggested concentration limit.