Skip to content

Lbsc support#40

Open
TomasCImach wants to merge 6 commits intotgefrom
lbsc-support
Open

Lbsc support#40
TomasCImach wants to merge 6 commits intotgefrom
lbsc-support

Conversation

@TomasCImach
Copy link
Member

No description provided.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +144 to +170
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

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

@TomasCImach
Copy link
Member Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +1 to +3
import { Bytes, log } from "@graphprotocol/graph-ts"
import {LoanOpened as LoanOpenedEvent, LoanSettled as LoanSettledEvent} from "../generated/LBSC/LBSC"
import { StableLoan } from "../generated/schema"

Choose a reason for hiding this comment

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

P0 Badge 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 👍 / 👎.

Comment on lines +7 to +20
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

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

@TomasCImach
Copy link
Member Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +237 to +243
kind: ethereum/events
apiVersion: 0.0.7
language: wasm/assemblyscript
entities:
- LBSC
abis:
- name: LBSC

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

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