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

Fixed some issues found during deployment #63

Merged
merged 5 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/mappings/position-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ export function handleMemorializePosition(
const position = loadOrCreatePosition(memorialize.tokenId)

// get lend entities for each index with extant lpb
const addressNotBytes = getPoolForToken(memorialize.tokenId)
const poolAddress = addressToBytes(addressNotBytes)
const poolAddress = memorialize.pool
const accountId = memorialize.lender

log.info("handleMemorializePosition for lender {} token {}" , [accountId.toHexString(), memorialize.tokenId.toString()])
Expand All @@ -115,7 +114,6 @@ export function handleMemorializePosition(
const bucket = Bucket.load(bucketId)!

// create PositionLend entity to track each lpb associated with the position
const positionLendId = getPositionLendId(memorialize.tokenId, BigInt.fromI32(index))
const positionLend = loadOrCreatePositionLend(memorialize.tokenId, bucketId, index)
const positionInfo = getPositionInfo(memorialize.tokenId, BigInt.fromI32(index))
//track the lpb and depositTime associated with each lend that was memorialized via RPC call
Expand Down Expand Up @@ -240,14 +238,15 @@ export function handleRedeemPosition(event: RedeemPositionEvent): void {
redeem.transactionHash = event.transaction.hash

const position = loadOrCreatePosition(redeem.tokenId)
const poolAddress = addressToBytes(getPoolForToken(redeem.tokenId))
const poolAddress = redeem.pool
const accountId = redeem.lender

log.info("handleRedeemPosition for lender {} token {}" , [accountId.toHexString(), redeem.tokenId.toString()])

// update positionLend entities for each index
const positionIndexes = position.indexes;
for (let index = 0; index < redeem.indexes.length; index++) {
for (let i = 0; i < redeem.indexes.length; i++) {
const index = redeem.indexes[i];
const bucketId = getBucketId(poolAddress, index)
const positionLend = loadOrCreatePositionLend(redeem.tokenId, bucketId, index)
positionLend.lpb = ZERO_BD
Expand Down
3 changes: 2 additions & 1 deletion src/utils/position.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Address, BigInt, Bytes, dataSource, store } from "@graphprotocol/graph-ts"
import { Address, BigInt, Bytes, dataSource, log, store } from "@graphprotocol/graph-ts"

import { Bucket, Position, PositionLend, Token } from "../../generated/schema"
import { ONE_BI, ZERO_BD, ZERO_BI, positionManagerAddressTable } from "../utils/constants"
Expand Down Expand Up @@ -98,6 +98,7 @@ export function saveOrRemovePositionLend(positionLend: PositionLend): void {
bucketPositionLends.splice(existingBucketIndex, 1)
}
bucket.positionLends = bucketPositionLends
bucket.save()

// remove positionLend from account array
const position = Position.load(bigIntToBytes(positionLend.tokenId))!
Expand Down
2 changes: 2 additions & 0 deletions subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ templates:
abis:
- name: ERC20
file: ./abis/ERC20.json
- name: ERC721
file: ./abis/ERC721.json
- name: ERC20Pool
file: ./abis/ERC20Pool.json
- name: PoolInfoUtils
Expand Down
Loading