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

Updates for RC4 contracts and other improvements #16

Merged
merged 22 commits into from
May 22, 2023
Merged

Updates for RC4 contracts and other improvements #16

merged 22 commits into from
May 22, 2023

Conversation

EdNoepel
Copy link
Contributor

@EdNoepel EdNoepel commented May 19, 2023

RC4 changes

  • Handle DecreaseLPAllowance.
  • Fixed RC3 LP management bug, now that MoveLiquidity event emits LP amounts.
  • Eliminated hack around RC3 bug calculating MOMP with 0 loans.
  • Handle Flashloan event and track total amount of quote token/collateral flashloaned in each pool.
  • Rework reserve auction entities now that we have separate events for kick and take.
  • Handle ResetInterestRate event.
  • Use new auctionStatus PoolInfoUtils to get auction prices, which were unavailable in RC3.

Bug fixes

  • No longer adding entities to copies of collections (which had no effect).
  • Resolved issue where plural entity name was unable to be queried.
  • Fixed bug where AuctionSettle event was not saving updates to LiquidationAuction entity.

Other improvements

  • Expose normalized contract token balances for BlockAnalytica to use in TVL calculations.
  • Add price to Bucket entity, as requested by BlockAnalytica. Using a local JSON price file to do the conversion.
  • Replace interestRate with borrowRate and lendRate after introducing a way to query lender interest margin.
  • Cleaned up Pool and some liquidation auction entities for improved DX.

@EdNoepel EdNoepel requested a review from MikeHathaway May 19, 2023 04:58
@@ -8,7 +8,7 @@
"deploy": "graph deploy --node https://api.studio.thegraph.com/deploy/ ajna",
"create-local": "graph create --node http://localhost:8020/ ajna",
"remove-local": "graph remove --node http://localhost:8020/ ajna",
"deploy-local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 ajna",
"deploy-local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 ajna -l rc4",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This arg sets the tag, making deployment non-interactive. Extremely helpful for fix/build/deploy test cycle.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvement, makes sense.

# updated upon ApproveLpTransferors and RevokeLpTransferors
type LPTransferors @entity {
# LP transferors approved by a lender for a pool, updated upon Approve/RevokeLpTransferors
type LPTransferorList @entity {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The plural entity name caused a bug trying to query the autogenerated collection.

@EdNoepel EdNoepel requested a review from 0xCommanderKeen May 19, 2023 14:12
pool.poolSize = wadToDecimal(poolLoansInfo.poolSize)
pool.loansCount = poolLoansInfo.loansCount
pool.maxBorrower = poolLoansInfo.maxBorrower
pool.inflator = wadToDecimal(poolLoansInfo.pendingInflator)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this also be setting inflatorLastUpdate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but we can't get it without adding a call to Pool.inflatorInfo. We could assume it changes with every pool action instead of most pool actions, and pass block height as an argument. But due to the limited utility, I think I'd rather remove it from the entity. Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well isn't it useful for knowing when interest rates will change? Might be important for determining plans

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the inflator is decoupled from the rate update. Inflator updates with most pool interactions. Interest rate updates every 12 hours or more, depending on MAU and TU.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in 8d343ce.

export const ZERO_BI = BigInt.zero()
export const ONE_BI = BigInt.fromI32(1)
export const TEN_BI = BigInt.fromI32(10)
export const ONE_RAY_BI = BigInt.fromString("1000000000000000000000000000")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can remove ONE_RAY_BI

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 8d343ce.

@@ -217,7 +225,7 @@ export function mintPosition(lender: Address, pool: Address, tokenId: BigInt, to
handleMint(newMintEvent)
}

export function assertPosition(lender: Address, pool: Address, tokenId: BigInt, tokenContractAddress: Address): void {
export function assertPosition(lender: Address, pool: Address, tokenId: BigInt, tokenContractAddress: Address): void {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: extra spacing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8d343ce.

Copy link
Contributor

@MikeHathaway MikeHathaway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@EdNoepel EdNoepel merged commit 92aff0d into develop May 22, 2023
@EdNoepel EdNoepel deleted the rc4 branch May 22, 2023 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants