Skip to content

Commit

Permalink
Merge pull request #106 from VenusProtocol/ignore-mint-events
Browse files Browse the repository at this point in the history
fix: properly ignore mint events
  • Loading branch information
coreyar authored Sep 4, 2023
2 parents ef5085a + ab59cef commit 9ca437a
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 33 deletions.
2 changes: 2 additions & 0 deletions subgraphs/isolated-pools/src/constants/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ import {
export const poolRegistryAddress = Address.fromString(poolRegistryAddressString);

export const poolLensAddress = Address.fromString(poolLensAddressString);

export const nullAddress = Address.fromString('0x0000000000000000000000000000000000000000');
3 changes: 2 additions & 1 deletion subgraphs/isolated-pools/src/mappings/vToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
ReservesReduced,
Transfer,
} from '../../generated/PoolRegistry/VToken';
import { nullAddress } from '../constants/addresses';
import { oneBigInt, zeroBigInt32 } from '../constants/index';
import {
createAccountVTokenBadDebt,
Expand Down Expand Up @@ -228,7 +229,7 @@ export function handleTransfer(event: Transfer): void {

// Checking if the tx is FROM the vToken contract (i.e. this will not run when minting)
// If so, it is a mint, and we don't need to run these calculations
if (accountFromAddress.toHex() != vTokenAddress.toHex()) {
if (accountFromAddress.toHex() != nullAddress.toHex()) {
getOrCreateAccount(accountFromAddress);

updateAccountVTokenTransferFrom(
Expand Down
12 changes: 12 additions & 0 deletions subgraphs/isolated-pools/tests/VToken/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,18 @@ describe('VToken', () => {
ethereum.Value.fromSignedBigInt(zeroBigInt32),
ethereum.Value.fromSignedBigInt(oneBigInt),
]);
createMockedFunction(
aaaTokenAddress,
'getAccountSnapshot',
'getAccountSnapshot(address):(uint256,uint256,uint256,uint256)',
)
.withArgs([ethereum.Value.fromAddress(from)])
.returns([
ethereum.Value.fromSignedBigInt(zeroBigInt32),
ethereum.Value.fromSignedBigInt(balanceOf),
ethereum.Value.fromSignedBigInt(zeroBigInt32),
ethereum.Value.fromSignedBigInt(oneBigInt),
]);

/** Fire Event */
handleTransfer(transferEvent);
Expand Down
3 changes: 2 additions & 1 deletion subgraphs/venus/src/mappings/vtoken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
RepayBorrow,
Transfer,
} from '../../generated/templates/VToken/VToken';
import { nullAddress } from '../constants/addresses';
import { createAccount } from '../operations/create';
import { createMarket } from '../operations/create';
import { updateCommonVTokenStats } from '../operations/update';
Expand Down Expand Up @@ -370,7 +371,7 @@ export const handleTransfer = (event: Transfer): void => {
// Checking if the tx is FROM the vToken contract (i.e. this will not run when minting)
// If so, it is a mint, and we don't need to run these calculations
let accountFromID = event.params.from.toHex();
if (accountFromID != marketID) {
if (accountFromID != nullAddress.toHex()) {
let accountFrom = Account.load(accountFromID);
if (accountFrom == null) {
createAccount(accountFromID);
Expand Down
67 changes: 36 additions & 31 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1404,11 +1404,11 @@ __metadata:
linkType: hard

"@babel/runtime@npm:^7.18.3":
version: 7.22.10
resolution: "@babel/runtime@npm:7.22.10"
version: 7.22.15
resolution: "@babel/runtime@npm:7.22.15"
dependencies:
regenerator-runtime: ^0.14.0
checksum: 524d41517e68953dbc73a4f3616b8475e5813f64e28ba89ff5fca2c044d535c2ea1a3f310df1e5bb06162e1f0b401b5c4af73fe6e2519ca2450d9d8c44cf268d
checksum: 793296df1e41599a935a3d77ec01eb6088410d3fd4dbe4e92f06c6b7bb2f8355024e6d78621a3a35f44e0e23b0b59107f23d585384df4f3123256a1e1492040e
languageName: node
linkType: hard

Expand Down Expand Up @@ -2985,15 +2985,15 @@ __metadata:
linkType: hard

"@graphql-tools/utils@npm:^10.0.0":
version: 10.0.5
resolution: "@graphql-tools/utils@npm:10.0.5"
version: 10.0.6
resolution: "@graphql-tools/utils@npm:10.0.6"
dependencies:
"@graphql-typed-document-node/core": ^3.1.1
dset: ^3.1.2
tslib: ^2.4.0
peerDependencies:
graphql: ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0
checksum: 600eb668b0a80264a56d1bfc2b431073a620de8ffea959362a1d13c4e0dd5738b627cc508ead8ecdbd7c1a2da05d5664e43443e15d3b221a809fa1a0e2740193
checksum: 1eae5ff2056930edf1b5a6aa38a2b28c2b3da0260d4d6babbd3fb25f8638b04c7ea8a481b3e1d4d965d81f2123b577646afb0fe20da87e76362d6f7f099e4be9
languageName: node
linkType: hard

Expand Down Expand Up @@ -6776,14 +6776,19 @@ __metadata:
linkType: hard

"cosmiconfig@npm:^8.1.3":
version: 8.2.0
resolution: "cosmiconfig@npm:8.2.0"
version: 8.3.3
resolution: "cosmiconfig@npm:8.3.3"
dependencies:
import-fresh: ^3.2.1
import-fresh: ^3.3.0
js-yaml: ^4.1.0
parse-json: ^5.0.0
parse-json: ^5.2.0
path-type: ^4.0.0
checksum: 836d5d8efa750f3fb17b03d6ca74cd3154ed025dffd045304b3ef59637f662bde1e5dc88f8830080d180ec60841719cf4ea2ce73fb21ec694b16865c478ff297
peerDependencies:
typescript: ">=4.9.5"
peerDependenciesMeta:
typescript:
optional: true
checksum: d678cc8f0aa68c9fc66966a409a15affda3338928edb9fc7ab9969d9a733bc7bf1396e11679d5d31f8a153d60b51faeccc91612e986137d8549f4230ab4368c9
languageName: node
linkType: hard

Expand Down Expand Up @@ -9014,8 +9019,8 @@ __metadata:
linkType: hard

"glob@npm:^10.2.5":
version: 10.3.3
resolution: "glob@npm:10.3.3"
version: 10.3.4
resolution: "glob@npm:10.3.4"
dependencies:
foreground-child: ^3.1.0
jackspeak: ^2.0.3
Expand All @@ -9024,7 +9029,7 @@ __metadata:
path-scurry: ^1.10.1
bin:
glob: dist/cjs/src/bin.js
checksum: 29190d3291f422da0cb40b77a72fc8d2c51a36524e99b8bf412548b7676a6627489528b57250429612b6eec2e6fe7826d328451d3e694a9d15e575389308ec53
checksum: 176b97c124414401cb51329a93d2ba112cef8814adbed10348481916b9521b677773eee2691cb6b24d66632d8c8bb8913533f5ac4bfb2d0ef5454a1856082361
languageName: node
linkType: hard

Expand Down Expand Up @@ -9845,7 +9850,7 @@ __metadata:
languageName: node
linkType: hard

"import-fresh@npm:^3.0.0, import-fresh@npm:^3.2.1":
"import-fresh@npm:^3.0.0, import-fresh@npm:^3.2.1, import-fresh@npm:^3.3.0":
version: 3.3.0
resolution: "import-fresh@npm:3.3.0"
dependencies:
Expand Down Expand Up @@ -10604,15 +10609,15 @@ __metadata:
linkType: hard

"jackspeak@npm:^2.0.3":
version: 2.3.0
resolution: "jackspeak@npm:2.3.0"
version: 2.3.3
resolution: "jackspeak@npm:2.3.3"
dependencies:
"@isaacs/cliui": ^8.0.2
"@pkgjs/parseargs": ^0.11.0
dependenciesMeta:
"@pkgjs/parseargs":
optional: true
checksum: 71bf716f4b5793226d4aeb9761ebf2605ee093b59f91a61451d57d998dd64bbf2b54323fb749b8b2ae8b6d8a463de4f6e3fedab50108671f247bbc80195a6306
checksum: 4313a7c0cc44c7753c4cb9869935f0b06f4cf96827515f63f58ff46b3d2f6e29aba6b3b5151778397c3f5ae67ef8bfc48871967bd10343c27e90cff198ec7808
languageName: node
linkType: hard

Expand Down Expand Up @@ -12908,7 +12913,7 @@ __metadata:
languageName: node
linkType: hard

"parse-json@npm:^5.0.0":
"parse-json@npm:^5.0.0, parse-json@npm:^5.2.0":
version: 5.2.0
resolution: "parse-json@npm:5.2.0"
dependencies:
Expand Down Expand Up @@ -15292,9 +15297,9 @@ __metadata:
linkType: hard

"ts-algebra@npm:^1.2.0":
version: 1.2.0
resolution: "ts-algebra@npm:1.2.0"
checksum: 471d3a049dbceadf2355f980e4d0a4cba413b50e66f0c8fb5eece876c238f7d2a270e1c85aa9ebd04349ae70335715f8e6d87338fd8cf755d12e285e884b3d91
version: 1.2.1
resolution: "ts-algebra@npm:1.2.1"
checksum: 99cf2abf52e845b864fdce70402e14736e1ac685564bfb46ebf16db9438b011dabe2be474adb68cb990fd2ca746d827ab414948e79a2917fe4a492fcf0e4527e
languageName: node
linkType: hard

Expand Down Expand Up @@ -15584,12 +15589,12 @@ __metadata:
linkType: hard

"typescript@npm:^5.0.4":
version: 5.1.6
resolution: "typescript@npm:5.1.6"
version: 5.2.2
resolution: "typescript@npm:5.2.2"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: b2f2c35096035fe1f5facd1e38922ccb8558996331405eb00a5111cc948b2e733163cc22fab5db46992aba7dd520fff637f2c1df4996ff0e134e77d3249a7350
checksum: 7912821dac4d962d315c36800fe387cdc0a6298dba7ec171b350b4a6e988b51d7b8f051317786db1094bd7431d526b648aba7da8236607febb26cf5b871d2d3c
languageName: node
linkType: hard

Expand All @@ -15604,12 +15609,12 @@ __metadata:
linkType: hard

"typescript@patch:typescript@^5.0.4#~builtin<compat/typescript>":
version: 5.1.6
resolution: "typescript@patch:typescript@npm%3A5.1.6#~builtin<compat/typescript>::version=5.1.6&hash=f456af"
version: 5.2.2
resolution: "typescript@patch:typescript@npm%3A5.2.2#~builtin<compat/typescript>::version=5.2.2&hash=f456af"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 21e88b0a0c0226f9cb9fd25b9626fb05b4c0f3fddac521844a13e1f30beb8f14e90bd409a9ac43c812c5946d714d6e0dee12d5d02dfc1c562c5aacfa1f49b606
checksum: 07106822b4305de3f22835cbba949a2b35451cad50888759b6818421290ff95d522b38ef7919e70fb381c5fe9c1c643d7dea22c8b31652a717ddbd57b7f4d554
languageName: node
linkType: hard

Expand Down Expand Up @@ -16903,8 +16908,8 @@ __metadata:
linkType: hard

"zod@npm:^3.21.4":
version: 3.22.1
resolution: "zod@npm:3.22.1"
checksum: 05b62cc1069da6e6349ad2325ec6b7d0c00699f0796e0fd071bcc2b44ac711679e52ad00bc563019504c7e64bbf0bf73737f31366d882a856962cd6e2882cf0e
version: 3.22.2
resolution: "zod@npm:3.22.2"
checksum: 231e2180c8eabb56e88680d80baff5cf6cbe6d64df3c44c50ebe52f73081ecd0229b1c7215b9552537f537a36d9e36afac2737ddd86dc14e3519bdbc777e82b9
languageName: node
linkType: hard

0 comments on commit 9ca437a

Please sign in to comment.