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

misc fixes #8

Merged
merged 2 commits into from
Apr 7, 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
42 changes: 21 additions & 21 deletions src/erc-20-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export function handleAddCollateral(event: AddCollateralEvent): void {
addCollateral.transactionHash = event.transaction.hash

// update entities
const pool = Pool.load(addressToBytes(event.transaction.to!))
const pool = Pool.load(addressToBytes(event.address))
if (pool != null) {
// update pool state
updatePool(pool)
Expand Down Expand Up @@ -144,7 +144,7 @@ export function handleAddQuoteToken(event: AddQuoteTokenEvent): void {
addQuoteToken.transactionHash = event.transaction.hash

// update entities
const pool = Pool.load(addressToBytes(event.transaction.to!))
const pool = Pool.load(addressToBytes(event.address))
if (pool != null) {
// update pool state
updatePool(pool)
Expand Down Expand Up @@ -193,7 +193,7 @@ export function handleAddQuoteToken(event: AddQuoteTokenEvent): void {
export function handleApproveLpTransferors(
event: ApproveLpTransferorsEvent
): void {
const poolId = addressToBytes(event.transaction.to!)
const poolId = addressToBytes(event.address)
const entity = loadOrCreateTransferors(poolId, event.params.lender)
approveTransferors(entity, event.params.transferors)

Expand Down Expand Up @@ -231,7 +231,7 @@ export function handleAuctionSettle(event: AuctionSettleEvent): void {
auctionSettle.transactionHash = event.transaction.hash

// update entities
const pool = Pool.load(addressToBytes(event.transaction.to!))
const pool = Pool.load(addressToBytes(event.address))
if (pool != null) {
// pool doesn't need to be updated here as it was already updated in the concurrent Settle event

Expand Down Expand Up @@ -288,7 +288,7 @@ export function handleBucketBankruptcy(event: BucketBankruptcyEvent): void {
bucketBankruptcy.transactionHash = event.transaction.hash

// update entities
const pool = Pool.load(addressToBytes(event.transaction.to!))
const pool = Pool.load(addressToBytes(event.address))
if (pool != null) {
// update pool state
updatePool(pool)
Expand Down Expand Up @@ -329,7 +329,7 @@ export function handleBucketTake(event: BucketTakeEvent): void {
bucketTake.transactionHash = event.transaction.hash

// update entities
const pool = Pool.load(addressToBytes(event.transaction.to!))
const pool = Pool.load(addressToBytes(event.address))
if (pool != null) {
// update pool state
updatePool(pool)
Expand Down Expand Up @@ -414,7 +414,7 @@ export function handleBucketTakeLPAwarded(
bucketTakeLpAwarded.transactionHash = event.transaction.hash

// update entities
const pool = Pool.load(addressToBytes(event.transaction.to!))
const pool = Pool.load(addressToBytes(event.address))
if (pool != null) {
// pool doesn't need to be updated as it was already updated in the concurrent BucketTake event

Expand Down Expand Up @@ -475,7 +475,7 @@ export function handleDrawDebt(event: DrawDebtEvent): void {
drawDebt.transactionHash = event.transaction.hash

// update entities
const pool = Pool.load(addressToBytes(event.transaction.to!))
const pool = Pool.load(addressToBytes(event.address))
if (pool != null) {
// update pool state
pool.currentDebt = pool.currentDebt.plus(wadToDecimal(event.params.amountBorrowed))
Expand Down Expand Up @@ -532,7 +532,7 @@ export function handleKick(event: KickEvent): void {
kick.kicker = event.transaction.from

// update entities
const pool = Pool.load(addressToBytes(event.transaction.to!))
const pool = Pool.load(addressToBytes(event.address))
if (pool != null) {
// update pool state
updatePool(pool)
Expand Down Expand Up @@ -611,7 +611,7 @@ export function handleMoveQuoteToken(event: MoveQuoteTokenEvent): void {
// update entities
const fromIndex = event.params.from.toU32()
const toIndex = event.params.to.toU32()
const pool = Pool.load(addressToBytes(event.transaction.to!))
const pool = Pool.load(addressToBytes(event.address))
if (pool != null) {
// update pool state
updatePool(pool)
Expand Down Expand Up @@ -687,7 +687,7 @@ export function handleRemoveCollateral(event: RemoveCollateralEvent): void {
removeCollateral.transactionHash = event.transaction.hash

// update entities
const pool = Pool.load(addressToBytes(event.transaction.to!))
const pool = Pool.load(addressToBytes(event.address))
if (pool != null) {
// update pool state
updatePool(pool)
Expand Down Expand Up @@ -748,7 +748,7 @@ export function handleRemoveQuoteToken(event: RemoveQuoteTokenEvent): void {
removeQuote.transactionHash = event.transaction.hash

// update entities
const pool = Pool.load(addressToBytes(event.transaction.to!))
const pool = Pool.load(addressToBytes(event.address))
if (pool != null) {
// update pool state
updatePool(pool)
Expand Down Expand Up @@ -808,7 +808,7 @@ export function handleRepayDebt(event: RepayDebtEvent): void {
repayDebt.transactionHash = event.transaction.hash

// update entities
const pool = Pool.load(addressToBytes(event.transaction.to!))
const pool = Pool.load(addressToBytes(event.address))
if (pool != null) {
// update pool state
pool.currentDebt = pool.currentDebt.minus(wadToDecimal(event.params.quoteRepaid))
Expand Down Expand Up @@ -860,7 +860,7 @@ export function handleReserveAuction(event: ReserveAuctionEvent): void {
reserveAuctionEvent.transactionHash = event.transaction.hash

// update entities
const pool = Pool.load(addressToBytes(event.transaction.to!))
const pool = Pool.load(addressToBytes(event.address))
if (pool != null) {
// update pool state
updatePool(pool)
Expand Down Expand Up @@ -931,7 +931,7 @@ export function handleReserveAuction(event: ReserveAuctionEvent): void {
}

export function handleRevokeLpAllowance(event: RevokeLpAllowanceEvent): void {
const poolId = addressToBytes(event.transaction.to!)
const poolId = addressToBytes(event.address)
const lender = event.transaction.from
const entity = loadOrCreateAllowances(poolId, lender, event.params.spender)
revokeAllowances(entity, event.params.indexes)
Expand All @@ -948,7 +948,7 @@ export function handleRevokeLpAllowance(event: RevokeLpAllowanceEvent): void {
export function handleRevokeLpTransferors(
event: RevokeLpTransferorsEvent
): void {
const poolId = addressToBytes(event.transaction.to!)
const poolId = addressToBytes(event.address)
const entity = loadOrCreateTransferors(poolId, event.params.lender)
revokeTransferors(entity, event.params.transferors)

Expand All @@ -962,7 +962,7 @@ export function handleRevokeLpTransferors(
}

export function handleSetLpAllowance(event: SetLpAllowanceEvent): void {
const poolId = addressToBytes(event.transaction.to!)
const poolId = addressToBytes(event.address)
const lender = event.transaction.from
const entity = loadOrCreateAllowances(poolId, lender, event.params.spender)
setAllowances(entity, event.params.indexes, event.params.amounts)
Expand Down Expand Up @@ -992,7 +992,7 @@ export function handleTake(event: TakeEvent): void {
take.transactionHash = event.transaction.hash

// update entities
const pool = Pool.load(addressToBytes(event.transaction.to!))
const pool = Pool.load(addressToBytes(event.address))
if (pool != null) {
// update pool state
updatePool(pool)
Expand Down Expand Up @@ -1074,7 +1074,7 @@ export function handleSettle(event: SettleEvent): void {
settle.transactionHash = event.transaction.hash

// update entities
const pool = Pool.load(addressToBytes(event.transaction.to!))
const pool = Pool.load(addressToBytes(event.address))
if (pool != null) {
// update pool state
updatePool(pool)
Expand Down Expand Up @@ -1128,7 +1128,7 @@ export function handleTransferLPs(event: TransferLPsEvent): void {
entity.transactionHash = event.transaction.hash

// update Lends for old and new owners, creating entities where necessary
const poolId = addressToBytes(event.transaction.to!)
const poolId = addressToBytes(event.address)
const pool = Pool.load(poolId)!
const oldOwnerAccount = Account.load(entity.owner)!
const newOwnerAccount = loadOrCreateAccount(entity.newOwner)
Expand Down Expand Up @@ -1177,7 +1177,7 @@ export function handleUpdateInterestRate(event: UpdateInterestRateEvent): void {
updateInterestRate.blockTimestamp = event.block.timestamp
updateInterestRate.transactionHash = event.transaction.hash

const pool = Pool.load(addressToBytes(event.transaction.to!))
const pool = Pool.load(addressToBytes(event.address))
if (pool != null) {
// update pool state
updatePool(pool)
Expand Down
2 changes: 1 addition & 1 deletion src/position-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export function handleTransfer(event: TransferEvent): void {
entity.to = event.params.to
entity.tokenId = event.params.tokenId

entity.token = loadOrCreateLPToken(event.transaction.to!).id
entity.token = loadOrCreateLPToken(event.address).id

entity.blockNumber = event.block.number
entity.blockTimestamp = event.block.timestamp
Expand Down
1 change: 1 addition & 0 deletions src/rewards-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export function handleMoveStakedLiquidity(event: MoveStakedLiquidityEvent): void
let entity = new MoveStakedLiquidity(
event.transaction.hash.concatI32(event.logIndex.toI32())
)
entity.tokenId = event.params.tokenId
entity.fromIndexes = bigIntArrayToIntArray(event.params.fromIndexes)
entity.toIndexes = bigIntArrayToIntArray(event.params.toIndexes)

Expand Down
4 changes: 4 additions & 0 deletions subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ dataSources:
abis:
- name: PositionManager
file: ./abis/PositionManager.json
- name: ERC20
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we just access those ABIs via the factory instead of duplicating here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added them to the manifest to resolve an indexing error where it reported a missing ABI. IIRC, it was erroring out upon mint. Seemed like it didn't involve the AssemblyScript at all. Happy to try another approach if you have a suggestion.

file: ./abis/ERC20.json
- name: ERC721
file: ./abis/ERC721.json
eventHandlers:
- event: Approval(indexed address,indexed address,indexed uint256)
handler: handleApproval
Expand Down
2 changes: 1 addition & 1 deletion tests/erc-20-pool.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe("Describe entity assertions", () => {
// For more test scenarios, see:
// https://thegraph.com/docs/en/developer/matchstick/#write-a-unit-test

test("AddCollateral created and stored", () => {
test("AddCollateral", () => {
// mock parameters
const poolAddress = Address.fromString("0x0000000000000000000000000000000000000001")
const actor = Address.fromString("0x0000000000000000000000000000000000000001")
Expand Down
26 changes: 13 additions & 13 deletions tests/utils/erc-20-pool-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function createAddCollateralEvent(
)

// update transaction target to the expected pool address
addCollateralEvent.transaction.to = pool
addCollateralEvent.address = pool

return addCollateralEvent
}
Expand Down Expand Up @@ -86,7 +86,7 @@ export function createAddQuoteTokenEvent(
)

// update transaction target to the expected pool address
addQuoteTokenEvent.transaction.to = pool
addQuoteTokenEvent.address = pool

return addQuoteTokenEvent
}
Expand Down Expand Up @@ -161,7 +161,7 @@ export function createBucketBankruptcyEvent(
)

// update transaction target to the expected pool address
bucketBankruptcyEvent.transaction.to = pool
bucketBankruptcyEvent.address = pool

return bucketBankruptcyEvent
}
Expand Down Expand Up @@ -207,7 +207,7 @@ export function createBucketTakeEvent(

// update transaction targets to the expected pool address and taker
bucketTakeEvent.transaction.from = taker
bucketTakeEvent.transaction.to = pool
bucketTakeEvent.address = pool

return bucketTakeEvent
}
Expand Down Expand Up @@ -243,7 +243,7 @@ export function createBucketTakeLPAwardedEvent(
)

// update transaction targets to the expected pool address
bucketTakeLpAwardedEvent.transaction.to = pool
bucketTakeLpAwardedEvent.address = pool

return bucketTakeLpAwardedEvent
}
Expand Down Expand Up @@ -279,7 +279,7 @@ export function createDrawDebtEvent(
)

// update transaction target to the expected pool address
drawDebtEvent.transaction.to = pool
drawDebtEvent.address = pool

return drawDebtEvent
}
Expand Down Expand Up @@ -314,7 +314,7 @@ export function createKickEvent(

// update transaction target to the expected pool address and kicker
kickEvent.transaction.from = kicker
kickEvent.transaction.to = pool
kickEvent.address = pool

return kickEvent
}
Expand Down Expand Up @@ -362,7 +362,7 @@ export function createMoveQuoteTokenEvent(
)

// update transaction target to the expected pool address
moveQuoteTokenEvent.transaction.to = pool
moveQuoteTokenEvent.address = pool

return moveQuoteTokenEvent
}
Expand Down Expand Up @@ -460,7 +460,7 @@ export function createRepayDebtEvent(
)

// update transaction target to the expected pool address
repayDebtEvent.transaction.to = pool
repayDebtEvent.address = pool

return repayDebtEvent
}
Expand Down Expand Up @@ -497,7 +497,7 @@ export function createReserveAuctionEvent(

// update transaction target to the expected pool address
reserveAuctionEvent.transaction.from = operator
reserveAuctionEvent.transaction.to = pool
reserveAuctionEvent.address = pool

return reserveAuctionEvent
}
Expand All @@ -524,7 +524,7 @@ export function createSettleEvent(

// update transaction targets to the expected pool address and taker
settleEvent.transaction.from = settler
settleEvent.transaction.to = pool
settleEvent.address = pool

return settleEvent
}
Expand Down Expand Up @@ -566,7 +566,7 @@ export function createTakeEvent(

// update transaction targets to the expected pool address and taker
takeEvent.transaction.from = taker
takeEvent.transaction.to = pool
takeEvent.address = pool

return takeEvent
}
Expand Down Expand Up @@ -626,7 +626,7 @@ export function createUpdateInterestRateEvent(
)

// update transaction target to the expected pool address
updateInterestRateEvent.transaction.to = pool
updateInterestRateEvent.address = pool

return updateInterestRateEvent
}