diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index a6cff952a4..dcfd2038eb 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -3,7 +3,7 @@ { "name": "Node.js & TypeScript", // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/devcontainers/typescript-node:1-20-bookworm", + "image": "mcr.microsoft.com/devcontainers/base:ubuntu-22.04", // Features to add to the dev container. More info: https://containers.dev/features. "features": { // If having issues with Nix then consult: @@ -19,7 +19,9 @@ "ghcr.io/lukewiwa/features/shellcheck:0": {}, "ghcr.io/devcontainers-contrib/features/curl-apt-get:1": {}, "ghcr.io/devcontainers/features/docker-in-docker:2": {}, - "ghcr.io/devcontainers-contrib/features/act:1": {} + "ghcr.io/devcontainers-contrib/features/act:1": {}, + "ghcr.io/devcontainers/features/node:1": {}, + "ghcr.io/eitsupi/devcontainer-features/jq-likes:2": {} }, // Use 'forwardPorts' to make a list of ports inside the container available locally. // "forwardPorts": [], @@ -32,6 +34,7 @@ "source /home/node/.bashrc && foundryup", "yarn global add npm-run-all", "yarn install && yarn build", + "sudo apt-get install libpq5", // for subgraph's matchstick "./tasks/fix-devcontainer.sh && nix develop . -c bash <(echo \"yarn install && yarn build\")" ] // Configure tool-specific properties. diff --git a/packages/subgraph/src/mappingHelpers.ts b/packages/subgraph/src/mappingHelpers.ts index a272e5d05b..82cf7a0cb5 100644 --- a/packages/subgraph/src/mappingHelpers.ts +++ b/packages/subgraph/src/mappingHelpers.ts @@ -536,7 +536,7 @@ export function updatePoolTotalAmountFlowedAndDistributed( return pool; } -export function getOrInitPoolMember( +export function getOrInitOrUpdatePoolMember( event: ethereum.Event, poolAddress: Address, poolMemberAddress: Address @@ -548,19 +548,19 @@ export function getOrInitPoolMember( poolMember = new PoolMember(poolMemberID); poolMember.createdAtTimestamp = event.block.timestamp; poolMember.createdAtBlockNumber = event.block.number; - poolMember.updatedAtTimestamp = event.block.timestamp; - poolMember.updatedAtBlockNumber = event.block.number; - + poolMember.units = BIG_INT_ZERO; poolMember.isConnected = false; poolMember.totalAmountClaimed = BIG_INT_ZERO; poolMember.poolTotalAmountDistributedUntilUpdatedAt = BIG_INT_ZERO; poolMember.totalAmountReceivedUntilUpdatedAt = BIG_INT_ZERO; - + poolMember.account = poolMemberAddress.toHex(); poolMember.pool = poolAddress.toHex(); } - + poolMember.updatedAtTimestamp = event.block.timestamp; + poolMember.updatedAtBlockNumber = event.block.number; + return poolMember; } diff --git a/packages/subgraph/src/mappings/gdav1.ts b/packages/subgraph/src/mappings/gdav1.ts index 81381e7464..e5a74baf36 100644 --- a/packages/subgraph/src/mappings/gdav1.ts +++ b/packages/subgraph/src/mappings/gdav1.ts @@ -19,7 +19,7 @@ import { _createTokenStatisticLogEntity, getOrInitPool, getOrInitPoolDistributor, - getOrInitPoolMember, + getOrInitOrUpdatePoolMember, getOrInitTokenStatistic, updateATSStreamedAndBalanceUntilUpdatedAt, updateAggregateDistributionAgreementData, @@ -84,7 +84,7 @@ export function handlePoolConnectionUpdated( event: PoolConnectionUpdated ): void { // Update Pool Member Entity - let poolMember = getOrInitPoolMember( + let poolMember = getOrInitOrUpdatePoolMember( event, event.params.pool, event.params.account @@ -162,6 +162,9 @@ export function handlePoolConnectionUpdated( false // isIDA ); + // Create Event Entity + _createPoolConnectionUpdatedEntity(event, poolMember.id); + // Create ATS and Token Statistic Log Entities const eventName = "PoolConnectionUpdated"; _createAccountTokenSnapshotLogEntity( @@ -172,9 +175,6 @@ export function handlePoolConnectionUpdated( ); _createTokenStatisticLogEntity(event, event.params.token, eventName); - - // Create Event Entity - _createPoolConnectionUpdatedEntity(event, poolMember.id); } export function handleBufferAdjusted(event: BufferAdjusted): void { diff --git a/packages/subgraph/src/mappings/superfluidPool.ts b/packages/subgraph/src/mappings/superfluidPool.ts index b018d2377a..15a22f6b8c 100644 --- a/packages/subgraph/src/mappings/superfluidPool.ts +++ b/packages/subgraph/src/mappings/superfluidPool.ts @@ -8,7 +8,7 @@ import { _createAccountTokenSnapshotLogEntity, _createTokenStatisticLogEntity, getOrInitPool, - getOrInitPoolMember, + getOrInitOrUpdatePoolMember, updateATSStreamedAndBalanceUntilUpdatedAt, updateAggregateDistributionAgreementData, updatePoolMemberTotalAmountUntilUpdatedAtFields, @@ -28,7 +28,7 @@ export function handleDistributionClaimed(event: DistributionClaimed): void { pool.save(); // Update PoolMember - let poolMember = getOrInitPoolMember(event, event.address, event.params.member); + let poolMember = getOrInitOrUpdatePoolMember(event, event.address, event.params.member); poolMember.totalAmountClaimed = event.params.totalClaimed; poolMember = updatePoolMemberTotalAmountUntilUpdatedAtFields(pool, poolMember); @@ -48,29 +48,16 @@ export function handleDistributionClaimed(event: DistributionClaimed): void { } export function handleMemberUnitsUpdated(event: MemberUnitsUpdated): void { - // - PoolMember - // - units - let poolMember = getOrInitPoolMember(event, event.address, event.params.member); - const hasMembershipWithUnits = membershipWithUnitsExists(poolMember.id); - let pool = getOrInitPool(event, event.address.toHex()); - - const previousUnits = poolMember.units; - const unitsDelta = event.params.newUnits.minus(previousUnits); + let poolMember = getOrInitOrUpdatePoolMember(event, event.address, event.params.member); pool = updatePoolTotalAmountFlowedAndDistributed(event, pool); - poolMember = updatePoolMemberTotalAmountUntilUpdatedAtFields(pool, poolMember); - + + const previousUnits = poolMember.units; + const unitsDelta = event.params.newUnits.minus(previousUnits); poolMember.units = event.params.newUnits; - const eventName = "MemberUnitsUpdated"; - updateTokenStatsStreamedUntilUpdatedAt(event.params.token, event.block); - _createTokenStatisticLogEntity(event, event.params.token, eventName); - - updateATSStreamedAndBalanceUntilUpdatedAt(event.params.member, event.params.token, event.block, null); - _createAccountTokenSnapshotLogEntity(event, event.params.member, event.params.token, eventName); - if (poolMember.isConnected) { pool.totalConnectedUnits = pool.totalConnectedUnits.plus(unitsDelta); } else { @@ -79,7 +66,8 @@ export function handleMemberUnitsUpdated(event: MemberUnitsUpdated): void { pool.totalUnits = pool.totalUnits.plus(unitsDelta); // 0 units to > 0 units - if (previousUnits.equals(BIG_INT_ZERO) && event.params.newUnits.gt(BIG_INT_ZERO)) { + const didPoolMemberBecomeActive = previousUnits.equals(BIG_INT_ZERO) && event.params.newUnits.gt(BIG_INT_ZERO) + if (didPoolMemberBecomeActive) { pool.totalMembers = pool.totalMembers + 1; // if the member is connected with units now, we add one to connected if (poolMember.isConnected) { @@ -92,7 +80,7 @@ export function handleMemberUnitsUpdated(event: MemberUnitsUpdated): void { updateAggregateDistributionAgreementData( event.params.member, event.params.token, - hasMembershipWithUnits, + true, // has units poolMember.isConnected, true, // only place we increment subWithUnits false, // not deleting @@ -102,8 +90,10 @@ export function handleMemberUnitsUpdated(event: MemberUnitsUpdated): void { false // isIDA ); } + // > 0 units to 0 units - if (previousUnits.gt(BIG_INT_ZERO) && poolMember.units.equals(BIG_INT_ZERO)) { + const didPoolMemberBecomeInactive = previousUnits.gt(BIG_INT_ZERO) && poolMember.units.equals(BIG_INT_ZERO) + if (didPoolMemberBecomeInactive) { pool.totalMembers = pool.totalMembers - 1; // if the member is connected with no units now, we subtract one from connected if (poolMember.isConnected) { @@ -116,7 +106,7 @@ export function handleMemberUnitsUpdated(event: MemberUnitsUpdated): void { updateAggregateDistributionAgreementData( event.params.member, event.params.token, - hasMembershipWithUnits, + false, // has units poolMember.isConnected, false, // don't increment memberWithUnits false, // not disconnecting membership @@ -132,6 +122,14 @@ export function handleMemberUnitsUpdated(event: MemberUnitsUpdated): void { // Create Event Entity _createMemberUnitsUpdatedEntity(event, poolMember.id, pool.totalUnits); + + // Other entity updates + const eventName = "MemberUnitsUpdated"; + updateTokenStatsStreamedUntilUpdatedAt(event.params.token, event.block); + _createTokenStatisticLogEntity(event, event.params.token, eventName); + + updateATSStreamedAndBalanceUntilUpdatedAt(event.params.member, event.params.token, event.block, null); + _createAccountTokenSnapshotLogEntity(event, event.params.member, event.params.token, eventName); } function _createDistributionClaimedEntity(event: DistributionClaimed, poolMemberId: string): DistributionClaimedEvent { diff --git a/packages/subgraph/tests/bugs/2024-02-29-aleph-total-supply.test.ts b/packages/subgraph/tests/bugs/2024-02-29-aleph-total-supply.test.ts index bfb7412813..45d7a15c97 100644 --- a/packages/subgraph/tests/bugs/2024-02-29-aleph-total-supply.test.ts +++ b/packages/subgraph/tests/bugs/2024-02-29-aleph-total-supply.test.ts @@ -30,7 +30,7 @@ describe("ALEPH Total Supply Bug", () => { mockedTokenName(superToken, "tokenName"); mockedTokenSymbol(superToken, "tokenSymbol"); mockedTokenDecimals(superToken, 18); - + // unused mocked function call after change in this commit (removing total supply RPC call in getOrInitSuperToken) mockedTokenTotalSupply(superToken, totalSupply); diff --git a/packages/subgraph/tests/bugs/2024-03-06-pool-member-units-changed.test.ts b/packages/subgraph/tests/bugs/2024-03-06-pool-member-units-changed.test.ts new file mode 100644 index 0000000000..f4053da76a --- /dev/null +++ b/packages/subgraph/tests/bugs/2024-03-06-pool-member-units-changed.test.ts @@ -0,0 +1,89 @@ +import { handleMemberUnitsUpdated } from "../../src/mappings/superfluidPool"; +import { createMemberUnitsUpdatedEvent } from "../gdav1/gdav1.helper"; +import { Address, BigInt } from "@graphprotocol/graph-ts"; +import { FAKE_INITIAL_BALANCE, alice, bob, charlie } from "../constants"; +import { BIG_INT_ZERO, getPoolMemberID } from "../../src/utils"; +import { assert, describe, test } from "matchstick-as"; +import { mockedGetAppManifest, mockedRealtimeBalanceOf } from "../mockedFunctions"; + +describe("PoolMember not updating when units changed", () => { + test("emit MemberUnitsUpdated event", () => { + const superTokenAddress = alice; + + const poolAddress = Address.fromString(bob); + const poolMemberAccountAddress = Address.fromString(charlie); + const poolMemberId = getPoolMemberID(poolAddress, poolMemberAccountAddress); + + mockedGetAppManifest(poolMemberAccountAddress.toHexString(), false, false, BIG_INT_ZERO); + + // Initialize pool member for the first time + const firstEvent = createMemberUnitsUpdatedEvent( + superTokenAddress, + poolMemberAccountAddress.toHexString(), + BigInt.fromI32(0), // old units + BigInt.fromI32(0) // new units + ); + firstEvent.address = poolAddress; + + mockedRealtimeBalanceOf( + superTokenAddress, + poolMemberAccountAddress.toHexString(), + firstEvent.block.timestamp, + FAKE_INITIAL_BALANCE, + BigInt.fromI32(0), + BIG_INT_ZERO + ); + + handleMemberUnitsUpdated(firstEvent); + // --- + + + const newUnits = BigInt.fromI32(100); + const blockNumber = BigInt.fromI32(200) + const timestamp = BigInt.fromI32(300) + + const secondEvent = createMemberUnitsUpdatedEvent( + superTokenAddress, + poolMemberAccountAddress.toHexString(), + BigInt.fromI32(0), // old units + newUnits + ); + secondEvent.block.timestamp = timestamp + secondEvent.address = poolAddress; + secondEvent.block.number = blockNumber; + + mockedRealtimeBalanceOf( + superTokenAddress, + poolMemberAccountAddress.toHexString(), + secondEvent.block.timestamp, + FAKE_INITIAL_BALANCE, + BigInt.fromI32(0), + BIG_INT_ZERO + ); + + // Act + handleMemberUnitsUpdated(secondEvent); + + // Assert + assert.fieldEquals( + "PoolMember", + poolMemberId, + "units", + newUnits.toString() + ); + + assert.fieldEquals( + "PoolMember", + poolMemberId, + "updatedAtTimestamp", + timestamp.toString() + ); + + assert.fieldEquals( + "PoolMember", + poolMemberId, + "updatedAtBlockNumber", + blockNumber.toString() + ); + }); +}); diff --git a/packages/subgraph/tests/bugs/2024-03-07-pool-member-total-amount-received.test.ts b/packages/subgraph/tests/bugs/2024-03-07-pool-member-total-amount-received.test.ts new file mode 100644 index 0000000000..c214de0a25 --- /dev/null +++ b/packages/subgraph/tests/bugs/2024-03-07-pool-member-total-amount-received.test.ts @@ -0,0 +1,258 @@ +import { assert, describe, test } from "matchstick-as"; +import { Pool, PoolDistributor, PoolMember } from "../../generated/schema" +import { Address, BigInt, Bytes } from "@graphprotocol/graph-ts"; +import { FAKE_INITIAL_BALANCE, alice as alice_, bob as bob_, charlie, delta, echo, maticXAddress, superfluidPool } from "../constants"; +import { BIG_INT_ZERO, getPoolMemberID } from "../../src/utils"; +import { handleInstantDistributionUpdated } from "../../src/mappings/gdav1"; +import { createInstantDistributionUpdatedEvent, createMemberUnitsUpdatedEvent } from "../gdav1/gdav1.helper"; +import { mockedGetAppManifest, mockedRealtimeBalanceOf } from "../mockedFunctions"; +import { handleMemberUnitsUpdated } from "../../src/mappings/superfluidPool"; + +/** + * Problem description + 1. Create pool + 2. Add member A and update A units to 100 + 3. Distribute 100 tokens + 4. Add member B and update B units to 100 + 4. Distribute 100 tokens + + Expected result: + member A 150 tokens + member B 50 tokens + + Actual result: + member A 100 tokens + member B 50 tokens + */ +describe("PoolMember ending up with wrong `totalAmountReceivedUntilUpdatedAt`", () => { + test("create elaborate scenario with 2 distributions and 2 pool members", () => { + return; // ignore test for CI (as the test is failing for now) + + const superTokenAddress = maticXAddress; + + // # Arrange State 1 + // ## Arrange Pool + const poolAddress = Address.fromString(superfluidPool); + const poolAdminAndDistributorAddress = Address.fromString(delta); + let pool = new Pool(poolAddress.toHexString()); + pool.createdAtTimestamp = BigInt.fromI32(1); + pool.createdAtBlockNumber = BigInt.fromI32(1); + pool.updatedAtTimestamp = BigInt.fromI32(1); + pool.updatedAtBlockNumber = BigInt.fromI32(1); + + pool.totalMembers = 1; + pool.totalConnectedMembers = 1; + pool.totalDisconnectedMembers = 0; + pool.adjustmentFlowRate = BigInt.fromI32(0); + pool.flowRate = BigInt.fromI32(0); + pool.admin = poolAdminAndDistributorAddress.toHexString(); + pool.totalBuffer = BigInt.fromI32(0); + pool.token = superTokenAddress; + pool.totalAmountDistributedUntilUpdatedAt = BigInt.fromI32(0); + pool.totalAmountFlowedDistributedUntilUpdatedAt = BigInt.fromI32(0); + pool.totalAmountInstantlyDistributedUntilUpdatedAt = BigInt.fromI32(0); + pool.totalConnectedUnits = BigInt.fromI32(100); + pool.totalDisconnectedUnits = BigInt.fromI32(0); + pool.totalUnits = BigInt.fromI32(100); + pool.save(); + // --- + + // ## Arrange PoolMember 1 + const aliceAddress = Address.fromString(alice_); + const aliceId = getPoolMemberID(poolAddress, aliceAddress); + const alice = new PoolMember(aliceId) + alice.createdAtTimestamp = BigInt.fromI32(1); + alice.createdAtBlockNumber = BigInt.fromI32(1); + alice.updatedAtTimestamp = BigInt.fromI32(1); + alice.updatedAtBlockNumber = BigInt.fromI32(1); + + alice.account = aliceAddress.toHexString(); + alice.units = BigInt.fromI32(100); + alice.totalAmountReceivedUntilUpdatedAt = BigInt.fromI32(0); + alice.poolTotalAmountDistributedUntilUpdatedAt = BigInt.fromI32(0); + alice.isConnected = true; + alice.totalAmountClaimed = BigInt.fromI32(0); + alice.pool = poolAddress.toHexString(); + alice.save(); + // # --- + + // ## Arrange Distributor + const poolDistributor = new PoolDistributor(poolAdminAndDistributorAddress.toHexString()); + poolDistributor.createdAtTimestamp = BigInt.fromI32(1); + poolDistributor.createdAtBlockNumber = BigInt.fromI32(1); + poolDistributor.updatedAtTimestamp = BigInt.fromI32(1); + poolDistributor.updatedAtBlockNumber = BigInt.fromI32(1); + poolDistributor.account = charlie; + poolDistributor.totalBuffer = BigInt.fromI32(0); + poolDistributor.flowRate = BigInt.fromI32(0); + poolDistributor.pool = poolAddress.toHexString(); + poolDistributor.totalAmountDistributedUntilUpdatedAt = BigInt.fromI32(0); + poolDistributor.totalAmountFlowedDistributedUntilUpdatedAt = BigInt.fromI32(0); + poolDistributor.totalAmountInstantlyDistributedUntilUpdatedAt = BigInt.fromI32(0); + poolDistributor.save(); + // --- + + // # First distribution (State 2) + const instantDistributionEvent = createInstantDistributionUpdatedEvent( + superTokenAddress, + poolAddress.toHexString(), + poolAdminAndDistributorAddress.toHexString(), + echo, + BigInt.fromI32(100), // requested amount + BigInt.fromI32(100), // actual amount + Bytes.fromHexString("0x") + ); + instantDistributionEvent.block.timestamp = BigInt.fromI32(1); + instantDistributionEvent.address = poolAddress; + + mockedGetAppManifest(poolAdminAndDistributorAddress.toHexString(), false, false, BIG_INT_ZERO); + mockedRealtimeBalanceOf( + superTokenAddress, + poolAdminAndDistributorAddress.toHexString(), + BigInt.fromI32(1), + FAKE_INITIAL_BALANCE, + BigInt.fromI32(0), + BIG_INT_ZERO + ); + + handleInstantDistributionUpdated(instantDistributionEvent); + + assert.fieldEquals( + "Pool", + poolAddress.toHexString(), + "totalAmountDistributedUntilUpdatedAt", + "100" + ); + assert.fieldEquals( + "PoolMember", + aliceId, + "totalAmountReceivedUntilUpdatedAt", + "0" + ); + // # --- + + // # Arrange State 3 + // ## Arrange PoolMember 2 (new member) + const bobAddress = Address.fromString(bob_); + const bobId = getPoolMemberID(poolAddress, bobAddress); + const bob = new PoolMember(bobId) + bob.createdAtTimestamp = BigInt.fromI32(1); + bob.createdAtBlockNumber = BigInt.fromI32(1); + bob.updatedAtTimestamp = BigInt.fromI32(1); + bob.updatedAtBlockNumber = BigInt.fromI32(1); + + bob.account = bobAddress.toHexString(); + bob.units = BigInt.fromI32(100); + bob.totalAmountReceivedUntilUpdatedAt = BigInt.fromI32(0); + bob.poolTotalAmountDistributedUntilUpdatedAt = BigInt.fromI32(100); + bob.isConnected = true; + bob.totalAmountClaimed = BigInt.fromI32(0); + bob.pool = poolAddress.toHexString(); + bob.save(); + // # --- + + // ## Update Pool for member 2 + pool = Pool.load(poolAddress.toHexString())!; + pool.updatedAtTimestamp = BigInt.fromI32(2); + pool.updatedAtBlockNumber = BigInt.fromI32(2); + pool.totalMembers = 2; + pool.totalConnectedMembers = 2; + pool.totalDisconnectedMembers = 0; + pool.totalConnectedUnits = BigInt.fromI32(2000); + pool.totalUnits = BigInt.fromI32(200); + pool.save(); + // --- + + // # Second distribution (we can use the first event again) (State 4) + handleInstantDistributionUpdated(instantDistributionEvent); + + assert.fieldEquals( + "Pool", + poolAddress.toHexString(), + "totalAmountDistributedUntilUpdatedAt", + "200" + ); + assert.fieldEquals( + "Pool", + poolAddress.toHexString(), + "totalUnits", + "200" + ); + // # --- + + // # Update PoolMember 2's units to get the `totalAmountReceivedUntilUpdatedAt` + const updateBobUnitsEvent = createMemberUnitsUpdatedEvent( + superTokenAddress, + bobAddress.toHexString(), + BigInt.fromI32(100), // old units + BigInt.fromI32(100) // new units + ); + // Note, the units can stay the same, we just want to trigger an update. + updateBobUnitsEvent.address = poolAddress; + updateBobUnitsEvent.block.timestamp = BigInt.fromI32(2); + + mockedGetAppManifest(bobAddress.toHexString(), false, false, BIG_INT_ZERO); + mockedRealtimeBalanceOf( + superTokenAddress, + bobAddress.toHexString(), + BigInt.fromI32(2), + FAKE_INITIAL_BALANCE, + BigInt.fromI32(0), + BIG_INT_ZERO + ); + + // Act 1 + handleMemberUnitsUpdated(updateBobUnitsEvent); + + assert.fieldEquals( + "Pool", + poolAddress.toHexString(), + "totalAmountDistributedUntilUpdatedAt", + "200" + ); + assert.fieldEquals( + "Pool", + poolAddress.toHexString(), + "totalUnits", + "200" + ); + assert.fieldEquals( + "PoolMember", + bobId, + "totalAmountReceivedUntilUpdatedAt", + "50" + ); + + // # Update PoolMember 1's units to get the `totalAmountReceivedUntilUpdatedAt` + const updateAliceUnitsEvent = createMemberUnitsUpdatedEvent( + superTokenAddress, + aliceAddress.toHexString(), + BigInt.fromI32(10), // old units + BigInt.fromI32(10) // new units + ); + // Note, the units can stay the same, we just want to trigger an update. + updateAliceUnitsEvent.address = poolAddress; + updateAliceUnitsEvent.block.timestamp = BigInt.fromI32(3); + + mockedGetAppManifest(aliceAddress.toHexString(), false, false, BIG_INT_ZERO); + mockedRealtimeBalanceOf( + superTokenAddress, + aliceAddress.toHexString(), + BigInt.fromI32(3), + FAKE_INITIAL_BALANCE, + BigInt.fromI32(0), + BIG_INT_ZERO + ); + + // Act 2 + handleMemberUnitsUpdated(updateAliceUnitsEvent); + + assert.fieldEquals( + "PoolMember", + aliceId, + "totalAmountReceivedUntilUpdatedAt", + "150" // 100 from first + 50 from second + ); + }) +}); + \ No newline at end of file diff --git a/packages/subgraph/tests/gdav1/hol/gdav1.hol.test.ts b/packages/subgraph/tests/gdav1/hol/gdav1.hol.test.ts index c0e2cfc3f7..9873aef7f1 100644 --- a/packages/subgraph/tests/gdav1/hol/gdav1.hol.test.ts +++ b/packages/subgraph/tests/gdav1/hol/gdav1.hol.test.ts @@ -19,7 +19,7 @@ import { } from "../../../src/mappings/gdav1"; import { updateMemberUnitsAndReturnMemberUnitsUpdatedEvent } from "../gdav1.helper"; import { handleDistributionClaimed, handleMemberUnitsUpdated } from "../../../src/mappings/superfluidPool"; -import { getOrInitPoolMember } from "../../../src/mappingHelpers"; +import { getOrInitOrUpdatePoolMember } from "../../../src/mappingHelpers"; import { stringToBytes } from "../../converters"; const initialFlowRate = BigInt.fromI32(100); @@ -285,7 +285,7 @@ describe("GeneralDistributionAgreementV1 Higher Order Level Entity Unit Tests", const oldUnits = BigInt.fromI32(0); const newUnits = BigInt.fromI32(100000000); const memberUnitsUpdatedEvent = createMemberUnitsUpdatedEvent(superToken, poolMember, oldUnits, newUnits); - const poolMemberEntity = getOrInitPoolMember( + const poolMemberEntity = getOrInitOrUpdatePoolMember( memberUnitsUpdatedEvent, memberUnitsUpdatedEvent.address, Address.fromString(poolMember) @@ -319,7 +319,7 @@ describe("GeneralDistributionAgreementV1 Higher Order Level Entity Unit Tests", const oldUnits = BigInt.fromI32(0); const newUnits = BigInt.fromI32(100000000); const memberUnitsUpdatedEvent = createMemberUnitsUpdatedEvent(superToken, poolMember, oldUnits, newUnits); - const poolMemberEntity = getOrInitPoolMember( + const poolMemberEntity = getOrInitOrUpdatePoolMember( memberUnitsUpdatedEvent, memberUnitsUpdatedEvent.address, Address.fromString(poolMember) @@ -362,7 +362,7 @@ describe("GeneralDistributionAgreementV1 Higher Order Level Entity Unit Tests", const oldUnits = BigInt.fromI32(0); const newUnits = BigInt.fromI32(100000000); const memberUnitsUpdatedEvent = createMemberUnitsUpdatedEvent(superToken, poolMember, oldUnits, newUnits); - const poolMemberEntity = getOrInitPoolMember( + const poolMemberEntity = getOrInitOrUpdatePoolMember( memberUnitsUpdatedEvent, memberUnitsUpdatedEvent.address, Address.fromString(poolMember) @@ -395,7 +395,7 @@ describe("GeneralDistributionAgreementV1 Higher Order Level Entity Unit Tests", const oldUnits = BigInt.fromI32(0); const newUnits = BigInt.fromI32(100000000); const memberUnitsUpdatedEvent = createMemberUnitsUpdatedEvent(superToken, poolMember, oldUnits, newUnits); - const poolMemberEntity = getOrInitPoolMember( + const poolMemberEntity = getOrInitOrUpdatePoolMember( memberUnitsUpdatedEvent, memberUnitsUpdatedEvent.address, Address.fromString(poolMember)