# TOFTOptionsReceiverModule miss cross-chain transformation for deposit and lock amounts

TOFTOptionsReceiverModule converts only top-level cross-chain amounts to local decimals, leaving nested deposit and lock amounts unconverted, causing magnitude errors and fund loss.

- Payout: Contest reward
- Severity: high
- Program: Tapioca
- Credited: hyh
- Disclosed: 2024-02-14
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2024-02-tapioca-judging/issues/87
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-02-tapioca%3AH-7
- Tags: domain:web3 impact:funds-loss kind:contest platform:sherlock sev:high tech:evm tech:solidity technique:source-review vuln:business-logic vuln:precision-loss

**Target:** TOFTOptionsReceiverModule cross-chain receiver (tOFT module)
**Root cause:** Cross-chain decimal transformation via _toLD is applied only to mintAmount and fraction, not to nested collateralDepositData.amount or lockData.amount/fraction, so amounts with differing token decimals across chains are misrepresented.
**Steps:**
1. Read TOFTOptionsReceiverModule.mintLendXChainSGLXChainLockAndParticipateReceiver: only msg_.mintData.mintAmount is passed through _toLD.
2. Observe CrossChainMintFromBBAndLendOnSGLData.mintData.collateralDepositData.amount is used downstream without conversion.
3. Similarly in lockAndParticipateReceiver only msg_.fraction is converted; LockAndParticipateData.lockData.amount and lockData.fraction are not.
4. When source and destination token decimals differ, the nested amounts are off by orders of magnitude, causing reverts/noops or oversized/dust operations.
5. Fix: apply _toLD to collateralDepositData.amount, lockData.amount and lockData.fraction.
**How found:** Code reading of the cross-chain receiver functions, noticing _toLD applied to only some amount fields while nested struct fields (collateralDepositData.amount, lockData.amount/fraction) bypass conversion.
**Insight:** In cross-chain messaging code, audit every nested amount field in decoded structs for decimal normalization, not just the top-level amount—partial _toLD application is a recurring pattern.
