Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| export function handleLbscSet(event: LbscSetEvent): void { | ||
| const router = loadRouter(event.address) | ||
|
|
||
| router.lbsc = event.params.newLbsc | ||
|
|
||
| router.save() | ||
| } | ||
|
|
||
| export function handleShivaBuildStable(event: ShivaBuildStableEvent): void { | ||
| const marketId = event.params.market | ||
| const positionId = event.params.positionId | ||
| const loanId = event.params.loanId | ||
|
|
||
| const market = loadMarket(event, marketId) | ||
| const router = loadRouter(event.address) | ||
|
|
||
| let marketPositionId = market.id.toHexString().concat('-').concat(positionId.toHexString()) | ||
| let position = Position.load(marketPositionId) | ||
| if (!position) { | ||
| log.error('No position found. marketPositionId: {}', [marketPositionId]) | ||
| return | ||
| } | ||
|
|
||
| const lbscAddress = router.lbsc | ||
| if (!lbscAddress) { | ||
| log.error('No lbsc address found. LoanId: {}', [loanId.toHexString()]) | ||
| return |
There was a problem hiding this comment.
Persist lbsc address when reusing Router entities
The new handlers set router.lbsc in handleLbscSet and later expect handleShivaBuildStable to read that value, but loadRouter still constructs a brand‑new Router (new Router(event.address)) every time it is called. Because the stored entity is never loaded, the lbsc address written earlier is discarded and router.lbsc is always null, so positions are never linked to their StableLoan. loadRouter needs to load an existing entity (or otherwise persist the field) before the LBSC address can be read here.
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| import { Bytes, log } from "@graphprotocol/graph-ts" | ||
| import {LoanOpened as LoanOpenedEvent, LoanSettled as LoanSettledEvent} from "../generated/LBSC/LBSC" | ||
| import { StableLoan } from "../generated/schema" |
There was a problem hiding this comment.
Generate bindings for LBSC before importing
The new handler imports ../generated/LBSC/LBSC and StableLoan from the generated schema, but this commit does not add the corresponding generated files. The generated directory still lacks an LBSC binding and the current generated/schema.ts has no StableLoan class, so yarn build will fail with missing modules. Run graph codegen and commit the updated output alongside these imports.
Useful? React with 👍 / 👎.
| export function handleLoanOpened(event: LoanOpenedEvent): void { | ||
| const borrower = loadAccount(event.params.borrower) | ||
| const loanId = event.params.loanId | ||
| const stableLoanId = event.address.toHexString().concat('-').concat(loanId.toString()) | ||
|
|
||
| let stableLoan = StableLoan.load(stableLoanId) | ||
|
|
||
| if (stableLoan === null) { | ||
| stableLoan = new StableLoan(stableLoanId) | ||
| } | ||
|
|
||
| stableLoan.loanId = loanId | ||
| stableLoan.borrower = borrower.id | ||
| stableLoan.stableAmount = event.params.stableAmount |
There was a problem hiding this comment.
Persist borrower account when recording a stable loan
In handleLoanOpened the borrower is loaded but never saved before the StableLoan.borrower field is set. If a user’s first interaction with the subgraph is a loan open, there will be no Account entity for that address even though the schema marks borrower: Account!, causing GraphQL queries for loan.borrower to error. Call borrower.save() after loadAccount so the referenced entity exists.
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| kind: ethereum/events | ||
| apiVersion: 0.0.7 | ||
| language: wasm/assemblyscript | ||
| entities: | ||
| - LBSC | ||
| abis: | ||
| - name: LBSC |
There was a problem hiding this comment.
Replace nonexistent entity in LBSC data source
The LBSC data source declares entities: [LBSC], but no LBSC entity exists in schema.graphql. The handlers in this mapping only persist StableLoan (and indirectly Account) entities, so referencing an undefined type causes graph build to fail when validating the manifest. The entities list should name the actual entity types being written (StableLoan, …) instead of LBSC.
Useful? React with 👍 / 👎.
No description provided.