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

Immediate debt increase #690

Open
pi0neerpat opened this issue May 7, 2024 · 2 comments
Open

Immediate debt increase #690

pi0neerpat opened this issue May 7, 2024 · 2 comments

Comments

@pi0neerpat
Copy link
Member

pi0neerpat commented May 7, 2024

After opening a HAI vault with 1,000 HAI
image

After opening a OD vault with 1,000 OD

image

For some reason our app is showing additional debt. However 1.75% APR should not have accumulated this quickly

  • difference between HAI and OD-APP debt:
    • 0.005% on od-app immediately
    • 0.003 on HAI after 24h
  • Not a frontend issue
  • Contract issue for sure.
@pi0neerpat pi0neerpat transferred this issue from open-dollar/od-app May 8, 2024
@pi0neerpat
Copy link
Member Author

Moving to contracts side since its likely not a frontend issue

@Seroxdesign
Copy link

Investigation Summary

The differences in the application of debt, interest, and tax between the Optimism and Arbitrum contracts have been identified and analyzed. Below are the key findings and conclusions:

On Optimism

  1. Debt and Interest Calculation:

    • When openLockTokenCollateralAndGenerateDebt is executed, it calls _lockTokenCollateralAndGenerateDebt.
    • _lockTokenCollateralAndGenerateDebt immediately calls ITaxCollector(_taxCollector).taxSingle(_safeInfo.collateralType);.
    • The debt and interest are applied to the account via modifySafeCollateralisation.
    • The tax fee event for HAI collaterals on Optimism is lower (around 0.003%) and occurs at the beginning of the function call.
  2. Function Call Stack:

    • The tax fee is calculated at the start of the function call sequence.

On Arbitrum

  1. Debt, Interest, and Tax Calculation:

    • When openLockTokenCollateralAndGenerateDebt is executed, it calls _lockTokenCollateralAndGenerateDebt.
    • _lockTokenCollateralAndGenerateDebt routes to _modifySAFECollateralization.
    • _modifySAFECollateralization calls ODSafeManager(_manager).modifySAFECollateralization(_safeId, _deltaCollateral, _deltaDebt, _nonSafeHandlerAddress);.
    • This sequence then calls taxSingle via TaxCollector.taxSingle, applying tax at the end of the function call.
    • The debt, interest, and tax are applied to the account with a higher tax rate (around 0.005%).
  2. Function Call Stack:

    • The tax fee is calculated at the end of the function call sequence.

Differences Based on Collateral Type and Deployment Timing

  • Optimism Contracts:

    • Deployed 116 days ago.
    • Slightly smaller tax rate (about 10% lower than Arbitrum).
    • Tax is applied at the start of the function call sequence.
  • Arbitrum Contracts:

    • Deployed 31 days ago.
    • Higher tax rate.
    • Tax is applied at the end of the function call sequence.

Example Transactions

Conclusion

The primary difference between the Optimism and Arbitrum contracts lies in the timing and rate of tax application. On Optimism, the tax is applied at the beginning of the function call with a slightly lower rate, whereas on Arbitrum, the tax is applied at the end of the function call with a higher rate. This distinction, influenced by the deployment timing and collateral types, results in a notable difference in user costs between the two networks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants