repayAccountPrimeDebtAtSettlement() user lost residual cash
in `repayAccountPrimeDebtAtSettlement()` Incorrect calculation of `primeCashRefund` value (always == 0) Resulting in the loss of the user's residual cash\\nwhen settle Vault Account will execute settleVaultAccount()->repayAccountPrimeDebtAtSettlement() In the `repayAccountPrimeDebtAtSettlement()` method the residual amount will be refunded to the user The code is as follows.\\n```\\n    function repayAccountPrimeDebtAtSettlement(\\n        PrimeRate memory pr,\\n        VaultStateStorage storage primeVaultState,\\n        uint16 currencyId,\\n        address vault,\\n        address account,\\n        int256 accountPrimeCash,\\n        int256 accountPrimeStorageValue\\n    ) internal returns (int256 finalPrimeDebtStorageValue, bool didTransfer) {\\n// rest of code\\n\\n            if (netPrimeDebtRepaid < accountPrimeStorageValue) {\\n                // If the net debt change is greater than the debt held by the account, then only\\n                // decrease the total prime debt by what is held by the account. The residual amount\\n                // will be refunded to the account via a direct transfer.\\n                netPrimeDebtChange = accountPrimeStorageValue;\\n                finalPrimeDebtStorageValue = 0;\\n\\n                int256 primeCashRefund = pr.convertFromUnderlying(\\n                    pr.convertDebtStorageToUnderlying(netPrimeDebtChange.sub(accountPrimeStorageValue)) //<--------@audit always ==0\\n                );\\n                TokenHandler.withdrawPrimeCash(\\n                    account, currencyId, primeCashRefund, pr, false // ETH will be transferred natively\\n                );\\n                didTransfer = true;\\n            } else {\\n```\\n\\nFrom the above code we can see that there is a spelling error\\nnetPrimeDebtChange = accountPrimeStorageValue;\\nprimeCashRefund = netPrimeDebtChange.sub(accountPrimeStorageValue) so primeCashRefund always ==0\\nshould be `primeCashRefund = netPrimeDebtRepaid - accountPrimeStorageValue`
```\\n    function repayAccountPrimeDebtAtSettlement(\\n        PrimeRate memory pr,\\n        VaultStateStorage storage primeVaultState,\\n        uint16 currencyId,\\n        address vault,\\n        address account,\\n        int256 accountPrimeCash,\\n        int256 accountPrimeStorageValue\\n    ) internal returns (int256 finalPrimeDebtStorageValue, bool didTransfer) {\\n// rest of code\\n\\n            if (netPrimeDebtRepaid < accountPrimeStorageValue) {\\n                // If the net debt change is greater than the debt held by the account, then only\\n                // decrease the total prime debt by what is held by the account. The residual amount\\n                // will be refunded to the account via a direct transfer.\\n                netPrimeDebtChange = accountPrimeStorageValue;\\n                finalPrimeDebtStorageValue = 0;\\n\\n                int256 primeCashRefund = pr.convertFromUnderlying(\\n-                   pr.convertDebtStorageToUnderlying(netPrimeDebtChange.sub(accountPrimeStorageValue))\\n+                   pr.convertDebtStorageToUnderlying(netPrimeDebtRepaid.sub(accountPrimeStorageValue)) \\n                );\\n                TokenHandler.withdrawPrimeCash(\\n                    account, currencyId, primeCashRefund, pr, false // ETH will be transferred natively\\n                );\\n                didTransfer = true;\\n            } else {\\n```\\n
`primeCashRefund` always == 0 , user lost residual cash
```\\n    function repayAccountPrimeDebtAtSettlement(\\n        PrimeRate memory pr,\\n        VaultStateStorage storage primeVaultState,\\n        uint16 currencyId,\\n        address vault,\\n        address account,\\n        int256 accountPrimeCash,\\n        int256 accountPrimeStorageValue\\n    ) internal returns (int256 finalPrimeDebtStorageValue, bool didTransfer) {\\n// rest of code\\n\\n            if (netPrimeDebtRepaid < accountPrimeStorageValue) {\\n                // If the net debt change is greater than the debt held by the account, then only\\n                // decrease the total prime debt by what is held by the account. The residual amount\\n                // will be refunded to the account via a direct transfer.\\n                netPrimeDebtChange = accountPrimeStorageValue;\\n                finalPrimeDebtStorageValue = 0;\\n\\n                int256 primeCashRefund = pr.convertFromUnderlying(\\n                    pr.convertDebtStorageToUnderlying(netPrimeDebtChange.sub(accountPrimeStorageValue)) //<--------@audit always ==0\\n                );\\n                TokenHandler.withdrawPrimeCash(\\n                    account, currencyId, primeCashRefund, pr, false // ETH will be transferred natively\\n                );\\n                didTransfer = true;\\n            } else {\\n```\\n