ajna-finance / ajna-core

The Ajna protocol is a non-custodial, peer-to-peer, permissionless lending, borrowing and trading system that requires no governance or external price feeds to function.
https://www.ajna.finance/
Other
31 stars 11 forks source link

Add Helper method for updating post draw/repay debt actions, set optmizer runs to 200 #884

Closed grandizzy closed 1 year ago

grandizzy commented 1 year ago

Description of change

High level

Contract size

Pre Change

============ Deployment Bytecode Sizes ============
  ERC721Pool               -  24,350B  (99.08%)
  ERC20Pool                -  23,578B  (95.94%)

Post Change

============ Deployment Bytecode Sizes ============
  ERC721Pool         -  24,426B  (99.39%)
  ERC20Pool          -  23,624B  (96.12%)

Gas usage

Pre Change

| Function Name                        | min             | avg    | median | max     | # calls |
| addQuoteToken                        | 122500          | 179774 | 164363 | 745043  | 60004   |
| bucketTake                           | 309224          | 327865 | 327866 | 346507  | 4       |
| drawDebt                             | 253186          | 298177 | 272082 | 812414  | 136003  |
| kick                                 | 149467          | 223488 | 221980 | 1034805 | 48000   |
| kickWithDeposit                      | 199590          | 277221 | 273367 | 1000575 | 8000    |
| moveQuoteToken                       | 272093          | 272093 | 272093 | 272093  | 1       |
| removeQuoteToken                     | 146623          | 171438 | 176084 | 195785  | 4000    |
| repayDebt                            | 586918          | 614064 | 601909 | 757316  | 16002   |
| settle                               | 350544          | 350544 | 350544 | 350544  | 1       |
| take                                 | 81772           | 83349  | 83084  | 315391  | 15998   |

Post Change

| Function Name                        | min             | avg    | median | max     | # calls |
| addQuoteToken                        | 120673          | 177845 | 162532 | 711953  | 60004   |
| bucketTake                           | 307543          | 326184 | 326184 | 344825  | 4       |
| drawDebt                             | 250710          | 295582 | 269534 | 808956  | 136003  |
| kick                                 | 148535          | 222510 | 221011 | 1033120 | 48000   |
| kickWithDeposit                      | 197510          | 275111 | 271257 | 997796  | 8000    |
| moveQuoteToken                       | 277524          | 277524 | 277524 | 277524  | 1       |
| removeQuoteToken                     | 144472          | 168273 | 172636 | 194707  | 4000    |
| repayDebt                            | 584550          | 611697 | 599542 | 754949  | 16002   |
| settle                               | 348772          | 348772 | 348772 | 348772  | 1       |
| take                                 | 80713           | 82316  | 82064  | 313356  | 15998   |
ith-harvey commented 1 year ago

Sorry, maybe I'm missing something. What bug is this solving for?

grandizzy commented 1 year ago

Sorry, maybe I'm missing something. What bug is this solving for?

That's for solving A1 invariant violation in an uniform way

grandizzy commented 1 year ago

won't make the change, keeping the branch around though