Skip to content

Commit dc49848

Browse files
ith-harveyIan Harveyprateek105EdNoepelgrandizzy
authored
Merge develop into master (#951)
* 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 <iharvey@comcast.net> * 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 <iharvey@comcast.net> * 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 <iharvey@comcast.net> * 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 <iharvey@comcast.net> * 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 <iharvey@comcast.net> * 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 <iharvey@comcast.net> Co-authored-by: Prateek Gupta <prateek105@users.noreply.github.com> * 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 <38490174+grandizzy@users.noreply.github.com> Co-authored-by: Ian Harvey <ith.harvey@gmail.com> Co-authored-by: Ian Harvey <iharvey@comcast.net> Co-authored-by: Prateek Gupta <prateek105@users.noreply.github.com> * 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 <iharvey@comcast.net> * removed mention of momp in testPoolInfoUtilsMulticall (#952) Co-authored-by: Ian Harvey <iharvey@comcast.net> * resolved compilation warnings and removed unused code (#953) --------- Co-authored-by: Ian Harvey <iharvey@comcast.net> Co-authored-by: Prateek Gupta <prateek105@users.noreply.github.com> Co-authored-by: Ed Noepel <46749157+EdNoepel@users.noreply.github.com> Co-authored-by: grandizzy <38490174+grandizzy@users.noreply.github.com> Co-authored-by: Ed Noepel <ed@noepel.net>
1 parent 3d9e3c9 commit dc49848

File tree

93 files changed

+5294
-4559
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+5294
-4559
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ node_modules
55
.env
66
.env.prod
77
.idea/
8-
.vscode/*.log
8+
.vscode/
99
__pycache__/
1010
reports/
1111
.gas-snapshot

README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,11 @@ The licensed work is under the [Business Service License](https://github.com/ajn
157157

158158
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.
159159

160-
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.
160+
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:
161+
- No other functional and successful deployment of Ajna is available on the target chain.
162+
- No modification to Solidity source files in the protocol is made, and no changes are made which conflict with the Business License.
163+
- Prior to deployment, the canonical burn-wrapped AJNA token (bwAJNA) on Ethereum mainnet is bridged to the target chain.
164+
- Upon deployment, the protocol is configured to use the bwAJNA token on the target chain.
161165

162166
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).
163167

docs/Functions.md

-24
Original file line numberDiff line numberDiff line change
@@ -386,19 +386,12 @@
386386
- update scaling array state
387387
- increment reserveAuction.totalInterestEarned accumulator
388388
- BorrowerActions.drawDebt():
389-
- SettlerActions._settleAuction():
390-
- _removeAuction():
391-
- decrement kicker locked accumulator, increment kicker claimable accumumlator
392-
- decrement auctions count accumulator
393-
- decrement auctions.totalBondEscrowed accumulator
394-
- update auction queue state
395389
- Loans.update():
396390
- _upsert():
397391
- insert or update loan in loans array
398392
- remove():
399393
- remove loan from loans array
400394
- update borrower in address => borrower mapping
401-
- decrement poolBalances.t0DebtInAuction accumulator
402395
- increment poolBalances.pledgedCollateral accumulator
403396
- increment poolBalances.t0Debt accumulator
404397
- _updateInterestState():
@@ -416,8 +409,6 @@
416409

417410
emit events:
418411
- BorrowerActions.drawDebt():
419-
- SettlerActions._settleAuction():
420-
- AuctionNFTSettle or AuctionSettle
421412
- DrawDebt
422413
- PoolCommons.updateInterestRate():
423414
- UpdateInterestRate
@@ -435,20 +426,13 @@
435426
- update scaling array state
436427
- increment reserveAuction.totalInterestEarned accumulator
437428
- BorrowerActions.repayDebt():
438-
- SettlerActions._settleAuction():
439-
- _removeAuction():
440-
- decrement kicker locked accumulator, increment kicker claimable accumumlator
441-
- decrement auctions count accumulator
442-
- decrement auctions.totalBondEscrowed accumulator
443-
- update auction queue state
444429
- Loans.update():
445430
- _upsert():
446431
- insert or update loan in loans array
447432
- remove():
448433
- remove loan from loans array
449434
- update borrower in address => borrower mapping
450435
- decrement poolBalances.t0Debt accumulator
451-
- decrement poolBalances.t0DebtInAuction accumulator
452436
- decrement poolBalances.pledgedCollateral accumulator
453437
- _updateInterestState():
454438
- PoolCommons.updateInterestRate():
@@ -465,8 +449,6 @@
465449

466450
emit events:
467451
- BorrowerActions.repayDebt():
468-
- SettlerActions._settleAuction:
469-
- AuctionNFTSettle or AuctionSettle
470452
- RepayDebt
471453
- PoolCommons.updateInterestRate():
472454
- UpdateInterestRate
@@ -534,8 +516,6 @@
534516
- increment reserveAuction.totalInterestEarned accumulator
535517
- TakerActions.take():
536518
- _take():
537-
- _prepareTake():
538-
- update liquidation.alreadyTaken state
539519
- _rewardTake():
540520
- update liquidation bond size accumulator
541521
- update kicker's locked balance accumulator
@@ -567,7 +547,6 @@
567547
- insufficient collateral InsufficientCollateral()
568548
- _prepareTake():
569549
- loan is not in auction NoAuction()
570-
- in 1 hour cool down period TakeNotPastCooldown()
571550
- _takeLoan():
572551
- borrower debt less than pool min debt AmountLTMinDebt()
573552

@@ -591,8 +570,6 @@
591570
- increment reserveAuction.totalInterestEarned accumulator
592571
- TakerActions.bucketTake():
593572
- _takeBucket():
594-
- _prepareTake():
595-
- update liquidation.alreadyTaken state
596573
- _rewardBucketTake():
597574
- Buckets.addLenderLP:
598575
- increment taker lender.lps accumulator and lender.depositTime state
@@ -630,7 +607,6 @@
630607
- insufficient collateral InsufficientCollateral()
631608
- _prepareTake():
632609
- loan is not in auction NoAuction()
633-
- in 1 hour cool down period TakeNotPastCooldown()
634610
- _takeLoan():
635611
- borrower debt less than pool min debt AmountLTMinDebt()
636612

docs/drawio/bucketTake.drawio

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<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">
1+
<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">
22
<diagram name="Page-1" id="13e1069c-82ec-6db2-03f1-153e76fe0fe0">
3-
<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">
3+
<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">
44
<root>
55
<mxCell id="0" />
66
<mxCell id="1" parent="0" />
@@ -176,7 +176,7 @@
176176
<mxPoint x="-5" y="-4" as="offset" />
177177
</mxGeometry>
178178
</mxCell>
179-
<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">
179+
<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">
180180
<mxGeometry x="335" y="290" width="294" height="150" as="geometry" />
181181
</mxCell>
182182
<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">

0 commit comments

Comments
 (0)