Skip to content

Commit

Permalink
Merge develop into master (#951)
Browse files Browse the repository at this point in the history
* Logging for RewardsManager and PositionManager invariants (#925)

* added logging for positionManager

* added rewards and position logging

* clean up

* updated rewards mapping back to public so tests pass

* how modifier was being called in rewardsPoolHandler

* revised so logging pools is not required when logging positions

* cleanup

* readme cleanup

---------

Co-authored-by: Ian Harvey <[email protected]>

* Invariants Improvement: Add multiple pool support in position and rewards manager invariant testing (#927)

* Add multiple pools in position and rewards manager invariant testing

* Fix RW6 regression test

* Fix rewardsClaimed and updateRewardsClaimed in Rewards manager

* Fix compile error

* PR feedback

* Add configurable number of pools for position and rewards manager invariant testing

* Positions Invariants: Multiple positions, transfer positions (#926)

* added randomness

* added the ability to transfer positions

* increased chance of rewards being claimed in handlers

* cleanup

* responded to comments

---------

Co-authored-by: Ian Harvey <[email protected]>

* Fuzz test additions (#924)

* Add fuzz test for borrower borrows fuzzed amount and getting kick after some time

* Add fuzz test for take fuzzed amount of collateral from auction

* Add fuzz test for settle with fuzzed pool deposit

* Add fuzz test for add and remove collateral in ERC721Pool

* Fuzzed buckets used in borrow and kick fuzz test

* PR feedback

* Invariant Improvements: Position rewards logging for multiple pools (#931)

* Update position and rewards manager invariant logging for multiple pools

* Fix regression test to run for any token precision and Quote token limits

* PR feedback

* Invariants Improvements: Add Multiple position in single handler in Position (#928)

* Update Position invariants handler to memorialize and redeem multiple positions

* PR feedback

* Add partial random positions redeem in redeem position handler

* Add random time skips between epochs in rewards manager

* Add bucket bankruptcy scenario for rewards manager (#930)

* Add bucket bankruptcy scenario for rewards manager

* Fix evm reverts

* PR feedback

* Update prepare test methods to add position in NFT if there is no position in it

* Fixed RewardsManager exchangeRate emit (#941)

* stopped updatedExchangeRates emit when the rates are not updated

* removed epoch check in _updateBucketExchangeRates

---------

Co-authored-by: Ian Harvey <[email protected]>

* Invariant Improvements: Add settle invariant scenario (#933)

* Add settle invariant scenario

* Reduce Loans and skip time to make undercollateralize

* Reduce time to skip in bucket bankruptcy scenario setup to fix regression tests (#936)

* Update unit test to increase test coverage (#938)

* Add unit tests to check deposits and debt limits in pool (#939)

* Add unit test to check exp function limit

* Add unit tests to check pool deposit and debt limits

* PR cleanup

* Add missing external function calls (#946)

* Update Position Manager unit tests to test against both ERC721 subset Pool and Collection Pool (#945)

* Merge changes from private-contracts repo into develop (#950)

* Merge Develop into Master (#934)

* Logging for RewardsManager and PositionManager invariants (#925)

* added logging for positionManager

* added rewards and position logging

* clean up

* updated rewards mapping back to public so tests pass

* how modifier was being called in rewardsPoolHandler

* revised so logging pools is not required when logging positions

* cleanup

* readme cleanup

---------

Co-authored-by: Ian Harvey <[email protected]>

* Invariants Improvement: Add multiple pool support in position and rewards manager invariant testing (#927)

* Add multiple pools in position and rewards manager invariant testing

* Fix RW6 regression test

* Fix rewardsClaimed and updateRewardsClaimed in Rewards manager

* Fix compile error

* PR feedback

* Add configurable number of pools for position and rewards manager invariant testing

* Positions Invariants: Multiple positions, transfer positions (#926)

* added randomness

* added the ability to transfer positions

* increased chance of rewards being claimed in handlers

* cleanup

* responded to comments

---------

Co-authored-by: Ian Harvey <[email protected]>

* Fuzz test additions (#924)

* Add fuzz test for borrower borrows fuzzed amount and getting kick after some time

* Add fuzz test for take fuzzed amount of collateral from auction

* Add fuzz test for settle with fuzzed pool deposit

* Add fuzz test for add and remove collateral in ERC721Pool

* Fuzzed buckets used in borrow and kick fuzz test

* PR feedback

* Invariant Improvements: Position rewards logging for multiple pools (#931)

* Update position and rewards manager invariant logging for multiple pools

* Fix regression test to run for any token precision and Quote token limits

* PR feedback

* Invariants Improvements: Add Multiple position in single handler in Position (#928)

* Update Position invariants handler to memorialize and redeem multiple positions

* PR feedback

* Add partial random positions redeem in redeem position handler

* Add random time skips between epochs in rewards manager

* Add bucket bankruptcy scenario for rewards manager (#930)

* Add bucket bankruptcy scenario for rewards manager

* Fix evm reverts

* PR feedback

* Update prepare test methods to add position in NFT if there is no position in it

---------

Co-authored-by: Ian Harvey <[email protected]>
Co-authored-by: Prateek Gupta <[email protected]>

* manually merged from private-contracts/immutable-kicks

* eliminated alreadyTaken (drawio needs updating)

* annotated failing unit tests

* new limit to induce testAccruePoolInterestRevertDueToExpLimit revert

* fixed testUpdateInterestTuLimit

* fixed testAccrueInterestNewInterestLimit

* removed alreadyTaken from drawios

* updated drawio-generated html

* merged Prateek's post-merge changes

---------

Co-authored-by: grandizzy <[email protected]>
Co-authored-by: Ian Harvey <[email protected]>
Co-authored-by: Ian Harvey <[email protected]>
Co-authored-by: Prateek Gupta <[email protected]>

* Return amount repaid in repayDebt and amount take in take (#947)

* Remove multicall from position manager (#948)

* L2 license grant (#949)

* updated license

* adjustment for public chains

* Pool info utils multicall (#944)

* Add PoolInfoUtilsMulticall contract to call multiple PoolInfoUtils methods in a single call to reduce rpc calls from subgraph

* Add tests for PoolInfoutilsMulticall

* Added comments and code improvements

* altered license

---------

Co-authored-by: Ian Harvey <[email protected]>

* removed mention of momp in testPoolInfoUtilsMulticall (#952)

Co-authored-by: Ian Harvey <[email protected]>

* resolved compilation warnings and removed unused code (#953)

---------

Co-authored-by: Ian Harvey <[email protected]>
Co-authored-by: Prateek Gupta <[email protected]>
Co-authored-by: Ed Noepel <[email protected]>
Co-authored-by: grandizzy <[email protected]>
Co-authored-by: Ed Noepel <[email protected]>
  • Loading branch information
6 people authored Oct 13, 2023
1 parent 3d9e3c9 commit dc49848
Show file tree
Hide file tree
Showing 93 changed files with 5,294 additions and 4,559 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ node_modules
.env
.env.prod
.idea/
.vscode/*.log
.vscode/
__pycache__/
reports/
.gas-snapshot
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,11 @@ The licensed work is under the [Business Service License](https://github.com/ajn

Prior to the Change Date, Licensor intends to transfer ownership of the Licensed Work to a to-be-organized not-for-profit foundation or similar public benefit focused entity (the “Ajna Foundation”), whereupon the rights, duties and obligations of Licensor under the BUSL License shall, without further act or deed of the parties, be assigned to Ajna Foundation, which entity shall thereafter be, and assume all rights, duties and obligations of (but not the liabilities, if any, of), the Licensor under the Business Service License.

Licensor reserves the right to specify Additional Use Grants at their discretion and to facilitate changes enacted by the Grant Coordination process, provided always that Additional Use Grants shall not conflict with the Business License.
Licensor reserves the right to specify Additional Use Grants at their discretion and to facilitate changes enacted by the Grant Coordination process, provided always that Additional Use Grants shall not conflict with the Business License. Licensor grants third parties permission to deploy The Ajna Protocol to other public blockchains and scaling solutions, hereby referred to as the "target chain", so long as:
- No other functional and successful deployment of Ajna is available on the target chain.
- No modification to Solidity source files in the protocol is made, and no changes are made which conflict with the Business License.
- Prior to deployment, the canonical burn-wrapped AJNA token (bwAJNA) on Ethereum mainnet is bridged to the target chain.
- Upon deployment, the protocol is configured to use the bwAJNA token on the target chain.

Prior to the Change Date, Licensor shall elect the Change License governing the Licensed Work after the Change Date, which license shall be an [Open Source Initiative](https://opensource.org/licenses) compliant license, provided always that the Change License shall be GPL Version 2.0 compatible. Once elected, Licensor may change its Change License designation at any time on or before the Change Date by updating this file in the master branch of [source control](https://github.com/ajna-finance/contracts/tree/master).

Expand Down
24 changes: 0 additions & 24 deletions docs/Functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -386,19 +386,12 @@
- update scaling array state
- increment reserveAuction.totalInterestEarned accumulator
- BorrowerActions.drawDebt():
- SettlerActions._settleAuction():
- _removeAuction():
- decrement kicker locked accumulator, increment kicker claimable accumumlator
- decrement auctions count accumulator
- decrement auctions.totalBondEscrowed accumulator
- update auction queue state
- Loans.update():
- _upsert():
- insert or update loan in loans array
- remove():
- remove loan from loans array
- update borrower in address => borrower mapping
- decrement poolBalances.t0DebtInAuction accumulator
- increment poolBalances.pledgedCollateral accumulator
- increment poolBalances.t0Debt accumulator
- _updateInterestState():
Expand All @@ -416,8 +409,6 @@

emit events:
- BorrowerActions.drawDebt():
- SettlerActions._settleAuction():
- AuctionNFTSettle or AuctionSettle
- DrawDebt
- PoolCommons.updateInterestRate():
- UpdateInterestRate
Expand All @@ -435,20 +426,13 @@
- update scaling array state
- increment reserveAuction.totalInterestEarned accumulator
- BorrowerActions.repayDebt():
- SettlerActions._settleAuction():
- _removeAuction():
- decrement kicker locked accumulator, increment kicker claimable accumumlator
- decrement auctions count accumulator
- decrement auctions.totalBondEscrowed accumulator
- update auction queue state
- Loans.update():
- _upsert():
- insert or update loan in loans array
- remove():
- remove loan from loans array
- update borrower in address => borrower mapping
- decrement poolBalances.t0Debt accumulator
- decrement poolBalances.t0DebtInAuction accumulator
- decrement poolBalances.pledgedCollateral accumulator
- _updateInterestState():
- PoolCommons.updateInterestRate():
Expand All @@ -465,8 +449,6 @@

emit events:
- BorrowerActions.repayDebt():
- SettlerActions._settleAuction:
- AuctionNFTSettle or AuctionSettle
- RepayDebt
- PoolCommons.updateInterestRate():
- UpdateInterestRate
Expand Down Expand Up @@ -534,8 +516,6 @@
- increment reserveAuction.totalInterestEarned accumulator
- TakerActions.take():
- _take():
- _prepareTake():
- update liquidation.alreadyTaken state
- _rewardTake():
- update liquidation bond size accumulator
- update kicker's locked balance accumulator
Expand Down Expand Up @@ -567,7 +547,6 @@
- insufficient collateral InsufficientCollateral()
- _prepareTake():
- loan is not in auction NoAuction()
- in 1 hour cool down period TakeNotPastCooldown()
- _takeLoan():
- borrower debt less than pool min debt AmountLTMinDebt()

Expand All @@ -591,8 +570,6 @@
- increment reserveAuction.totalInterestEarned accumulator
- TakerActions.bucketTake():
- _takeBucket():
- _prepareTake():
- update liquidation.alreadyTaken state
- _rewardBucketTake():
- Buckets.addLenderLP:
- increment taker lender.lps accumulator and lender.depositTime state
Expand Down Expand Up @@ -630,7 +607,6 @@
- insufficient collateral InsufficientCollateral()
- _prepareTake():
- loan is not in auction NoAuction()
- in 1 hour cool down period TakeNotPastCooldown()
- _takeLoan():
- borrower debt less than pool min debt AmountLTMinDebt()

Expand Down
6 changes: 3 additions & 3 deletions docs/drawio/bucketTake.drawio
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<mxfile host="app.diagrams.net" modified="2023-04-19T04:56:00.459Z" agent="Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/112.0" version="21.1.9" etag="qqc42GKUYHlkn5nOCzpD" type="device">
<mxfile host="app.diagrams.net" modified="2023-10-12T20:03:03.163Z" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36" version="22.0.4" etag="l-ZvZCffyt0_a6_E5UsL" type="device">
<diagram name="Page-1" id="13e1069c-82ec-6db2-03f1-153e76fe0fe0">
<mxGraphModel dx="2534" dy="790" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1100" pageHeight="850" background="none" math="0" shadow="0">
<mxGraphModel dx="2354" dy="1390" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1100" pageHeight="850" background="none" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
Expand Down Expand Up @@ -176,7 +176,7 @@
<mxPoint x="-5" y="-4" as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="OZIXumOx-P3Wxb6WJyRX-3" value="&lt;div&gt;revert:&lt;/div&gt;InsufficientCollateral()&lt;br&gt;NoAuction()&lt;br&gt;TakeNotPastCooldown()&lt;br&gt;AmountLTMinDebt()&lt;div&gt;&lt;br&gt;&lt;/div&gt;update liquidation.alreadyTaken&lt;br&gt;update liquidation bond size&lt;br&gt;update kicker&#39;s locked balance&lt;br&gt;&lt;div&gt;update auctions.totalBondEscrowed&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;settle auction&lt;br&gt;&lt;/div&gt;" style="shape=note;whiteSpace=wrap;html=1;size=14;verticalAlign=top;align=left;spacingTop=-6;rounded=0;shadow=0;comic=0;labelBackgroundColor=none;strokeWidth=1;fontFamily=Verdana;fontSize=10;" parent="1" vertex="1">
<mxCell id="OZIXumOx-P3Wxb6WJyRX-3" value="&lt;div&gt;revert:&lt;/div&gt;InsufficientCollateral()&lt;br&gt;NoAuction()&lt;br&gt;AmountLTMinDebt()&lt;div&gt;&lt;br&gt;&lt;/div&gt;update liquidation bond size&lt;br&gt;update kicker&#39;s locked balance&lt;br&gt;&lt;div&gt;update auctions.totalBondEscrowed&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;settle auction&lt;br&gt;&lt;/div&gt;" style="shape=note;whiteSpace=wrap;html=1;size=14;verticalAlign=top;align=left;spacingTop=-6;rounded=0;shadow=0;comic=0;labelBackgroundColor=none;strokeWidth=1;fontFamily=Verdana;fontSize=10;" parent="1" vertex="1">
<mxGeometry x="335" y="290" width="294" height="150" as="geometry" />
</mxCell>
<mxCell id="OZIXumOx-P3Wxb6WJyRX-4" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.158;entryDx=0;entryDy=0;entryPerimeter=0;fontFamily=Tahoma;fontSize=12;fontColor=#666666;endArrow=classic;endFill=1;" parent="1" edge="1">
Expand Down
Loading

0 comments on commit dc49848

Please sign in to comment.