Skip to content

Commit

Permalink
[SUBGRAPH] Gda total amount received (#1773)
Browse files Browse the repository at this point in the history
* SuperfluidUpgradeableBeaconTest test contract

* adjustment fr

* Update GeneralDistributionAgreement.t.sol

* more testing cleanup

* we'll do it LIVE!

- deployments uncommented
- test cleanups

* formatting

* wip cleanups + test removals

- cleanup interface
- add estimateDistributionActualAmount
- remove a bunch of the gda demo specific tests

* address some review comments

* review comments cont.

* fix build

* should fix build + allow deploy

* fix deployments

- renames of supertokenpool => superfluidpool
- fix deploy-framework

* GDA wip

- clean up functions
- add isPatricianPeriod view functions
- fix distributeFlow shifting order: adjust buffer happens after flow distribution
- add basic liquidation test
- increase coverage
- make _assertGlobalInvariants virtual

* flow nft cleanup/fixes

- add metadata to ethereum-contracts
- FlowNFT's do not take baseURI in constructor, it is a constant variable now, no longer in storage
- SuperTokenFactory fixed to check existing canonical addresses against new contract canonical logic addresses
- add validate nft deployments addresses script

* workflow cleanups

- add `permissions: write-all` to broken workflows
- fix deploy-framework.js up
- fix scripts => dev-scripts

* fix up framework deployment

- add more validation to script
- proxiableUUID fixed for SuperfluidPool
- deploy-framework fix

* wip

- add trusted forwarder test
- fix info-print-contract-addresses

* cleanup

- optimization in distributeFlow
- added more test cases

* Pool NFTs WIP

- IPoolAdminNFT, IPoolMemberNFT, IPoolNFTBase added
- ISuperToken interface modified to include pool nft's
- SuperToken and SuperTokenFactoryMock modified given updates to constructor
- ConstantOutflowNFT: CFA or GDA
- PoolAdminNFT, PoolMemberNFT and PoolNFTBase initial implementation
- SuperToken constructor takes flow NFT proxies
- SuperTokenFactory constructor takes flow NFT logic contracts
  - update code path also handles nft logic upgrades
- SF deployment steps modified to deploy flow NFTs
- deployment scripts modified: deploy-framework, info-print-addresses, verify-framework
- other test files modified given new constructor
- Fix up existing TS test suite

* add erc20 to superfluidpool

* pool nft integration

- mint/burn pool member nft in superfluidpool: update member units
- mint pool admin nft in gda: create pool

* gda wip

- inc/dec allowance
- move IERC20 to ISuperfluidPool
- add helpers + basic tests for approve/transfer
- transfer WIP

* validate + make test more robust

* gda tests cleanup

* fix verification

- always use slotsBitmapLibraryAddress deployed for IDA for GDA

* flow nft on distribute flow

* testing cleanup

* fix transfer test too

* GDAv1 in SuperTokenV1Library

- remove andAssert functions
- use startPrank
- clean up tests

* full coverage

* wip

* Update deploy-framework.js

* Update ISuperToken.sol

* using lib for ISuperToken

* add tests for lib

- adding tests for library

* gda wip

- NFTs (Admin and Member) mint functions require passed pool to be registered
- more function reuse in superfluidpool
- add update function in pool member nft and call it in SuperfluidPool (similar to ConstantOutflowNFT.onUpdate)
- use uint64 max flow rate in tests instead of int32

* fix build

* function renaming + comments

* gda harness cleanup

- reduce code size of gdav1harness by combining function
- fix up tests
- add pool param to adjustBuffer
- add superToken to superfluid pool events
- new BufferAdjusted event in GDAv1

* gda subgraph hemingway bridge

- gda schema added
- getAbi.js cleaned up
- manifest file updated
- mapping skeleton added (not for aggregate yet)

* gdav1 forwarder wip

* mapping functions WIP

- schema cleanup
- event entities mapping implemented
- hol entities mapping implemented

* aggregate entities schema

* - add docs for new properties
- initialize new properties in getOrInit
- add tests for new properties in matchstick

* Delete hardhat.json

* nft's wip

- pool member nft try/catch
- pool admin nft try/catch
- make the to parameter an ISuperfluidPool type and fix expected types in tests and peripherals

* add transfer units to pool test

* nft testing wip

- move `NoNFTSuperTokenMock` to `SuperTokenMock.sol`
- pool NFT mocks and upgradability mock contracts created
- PoolNFTBase integration tests includes storage layout tests

* fix build

* wip + refactoring tests

- moved common NFT test code to ERC721.t.sol
- removed `Proxy` suffix
- added upgradability tests for PoolNFTs

* fix build

* testing wip

- discovered some refactoring possibilities
- added some helper functions
- tested nft integration

* tests refactor

- refactored flow nft tests (constant inflow, constant outflow)
- added tests for pool nft base

* pool nft tests wip + cleanup

* add assertions for nft's in gda helpers

* add GDA to SDK-Core

add gda and SuperfluidPool code to SDK-Core

* TSDoc for SuperfluidPool

* GDA in SDK-Core WIP

- add GDA to SuperfluidLoader
- deploy IDAv1Forwarder and GDAv1Forwarder in deploy-framework.js in local testing
- add gdav1 to Framework initialization
- add tsdoc to GeneralDistributionAgreementV1.ts
- connect provider or signer to view contract calls
- connect signer to write contract calls
- add gda and superfluid pool functions to supertoken
- gda tests wip

* more tests and coverage WIP

* wip

- clean up forwarder
- clean up deployer (remove duplicate functions)
- add forwarder to deployer
- add reusable function for deploying forwarders in deploy-framework
- fix interfaces.ts for sdk-core

* fix build + add tests

* force artifact creation

* undo force

* final SDK-Core tests for GDA

* make yarn dev use forge by default

* refactor tests

- move GDA helpers and asserts from GDAv1.t.sol to FoundrySuperfluidTester

* Update package.json

* tidying up

* add total connected flow rate to pool

* fix distribute tests

- minor naming refactoring
- uncomment _helperDistribute in randomPoolSeqs

* add batch liquidator + toga to Framework struct

* does not exist error

* batch liquidator modified to handle GDA

* fix code size too large

* updateMemberUnits name change, _toSemanticMoneyUnit added, set TOGA as default reward address

* toSemanticMoney

* testing wip

* fix build to unblock

* fix build

* Update SuperTokenV1Library.sol: make isMemberConnected internal

* cleanup and wip

- move nft code blocks into functions for easier reasoning in gda and pool
- remove check for if flow exists before deletion
- fix test case where lib deploy not needed
- rename test contract
- helper test functions cleanup + additions

* gda test cleanup

- remove old comments
- remove _expectedPoolData
- assert flow rate for member is correct

* add assertions for distribute claimable

* check actual flow rate

- check distributor flow rate against actual flow rate
- fix estimate flow distribution flow rate logic (adjustment flow case)

* final helper assertion for distribute flow

* fix build

* subgraph progress

* subgraph wip

- MemberUpdated => MemberUnitsUpdated
- gda aggregate entities mapping wip

* superfluidpool mapping

- finish aggregate mapping for superfluid pool

* Update mappingHelpers.ts

* subgraph tests wip

- a bit unsure why the error is occurring in the subgraph tests...

* fix subgraph tests

- ordering of event params was wrong

* clean up tests

* add gda addresses

* fix tests

* fix deployment

* contracts notes

* tests cleanup

* uncommented test

* more tests + helpers added

* more helpers and abstractions!

- added some more subgraph tests
- fix le build

* fix lint:sol errors

* fix echidna

* warnings cleanup

* break windows

* add one more test

* use supertokenv1library

- get gda hot fuzz in

* fixing warnings

* fix semantic money

* clean up build warnings

* do not ignore success flag from low level call

* disable deny_warnings for now

* fix up build and lint

* fix build

* clean up echidna

* cleanup

- prefix with `_` for internal functions
- fix `createPool` function issue
- add `_addPool` function

* fixes

- assert global invariants in helpers
- add otherAccounts/_listAccounts pattern to

* fix some of the gda invariance issues

* testing cleanup

* add a few more actions

* fix tests

* Update getAbi.js

* fix build

* Update bundled-abi-contracts-list.json

* GDA tooling (#1602)

* gov scripts for governance update and transfer: make usable for prod governance

* simplify gov init

* ocd treatment: more consistent order of cof vs cif

* nix setup hint

* store version string in Resolver, fix contract change recognition for some factory related contracts

* fix code changed detection for contracts the SuperTokenFactory depends on

* new loader contracts on gda testnets

* rev string shall always have 8 chars

* store 16 chars of git revision

* [SUPPLYCHAIN] Update lerna again after [email protected] (#1589)

* [TOOLING] ops-scripts improvements for 1.7+ (#1586)

* gov scripts for governance update and transfer: make usable for prod governance

* simplify gov init

* ocd treatment: more consistent order of cof vs cif

* nix setup hint

* store version string in Resolver, fix contract change recognition for some factory related contracts

* rev string shall always have 8 chars

* store 16 chars of git revision

* Bump webpack in /sdk-redux-examples/sdk-redux-react-typecript (#1614)

Bumps [webpack](https://github.com/webpack/webpack) from 5.75.0 to 5.88.2.
- [Release notes](https://github.com/webpack/webpack/releases)
- [Commits](webpack/webpack@v5.75.0...v5.88.2)

---
updated-dependencies:
- dependency-name: webpack
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Miao ZhiCheng <[email protected]>

* [METADATA] 1594 | Add Subgraph endpoints to metadata (#1611)

* add to metadata

* update changelog

---------

Co-authored-by: Miao ZhiCheng <[email protected]>

* Bump web3 from 1.10.0 to 1.10.1 (#1619)

Bumps [web3](https://github.com/ChainSafe/web3.js) from 1.10.0 to 1.10.1.
- [Release notes](https://github.com/ChainSafe/web3.js/releases)
- [Changelog](https://github.com/web3/web3.js/blob/v1.10.1/CHANGELOG.md)
- [Commits](web3/web3.js@v1.10.0...v1.10.1)

---
updated-dependencies:
- dependency-name: web3
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump http-cache-semantics (#1620)

Bumps [http-cache-semantics](https://github.com/kornelski/http-cache-semantics) from 4.1.0 to 4.1.1.
- [Commits](kornelski/http-cache-semantics@v4.1.0...v4.1.1)

---
updated-dependencies:
- dependency-name: http-cache-semantics
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Miao ZhiCheng <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: 0xdavinchee <[email protected]>

* gdav1 forwarder tested

* fix tests

* add required ISuperToken ABIs

* include resolver/ISuperfluid abis

* fix build

* subgraph tests wip

pool
- handleFlowDistributionUpdated
- handleInstantDistributionUpdated
- handleDistributionClaimed
- handleMemberUnitsUpdated
- handlePoolConnectionUpdated
poolMember
- handleDistributionClaimed
- handleMemberUnitsUpdated

* pool distributor tests

* more echidna actions

* clean up hot fuzz + gda

* add token actions

add some more token actions

* add TOGA as account

* fix test cases

* fix formatting

* fix formatting

* fix lint errors

* add callAgreement wrappers

* with ctx functions added

* cleanup

- reduce code size
- create SolvencyHelperLibrary
- finished supertokenv1library callback tests

* add to event

* fix gda address for avalanche-fuji

* subgraph and sdk-core changes

* wip

- reduce code size
- cleaned up deployers
- schema additions
- subgraph add userData
- more cleanup incoming

* deploy script for gda forwarder & addition to framework deploy script

* added gdaV1Forwarder addresses for testnets

* fix subgraph tests

* deployment env

* change file structure

- move gda related contracts to `agreements/gdav1` folder
- same thing with the interface files, to `interfaces/agreements/gdav1`

* unnecessary suffering

- do not use the harness pattern in the future, it was completely unnecessary => using .prop pattern suffices
- code size optimization was unnecessary

* cleanup

- remove DelegatableTokenMonad
- fix up test

* fix hot fuzz breaking

* Update bundled-abi-contracts-list.json

* remove GDAv1Internal

* Delete GDAv1Internal.sol

* more memory for the job

* rename test functions

* explicitly set parallel to false

* clean up build warnings

* pass via env:

* fix build

* fixes attempt

- move event entity creation to the end of handler
- purposefully brick handleMemberUnitsUpdated to see if this is ever being hit

* fix build

* fix contract size issue

* use correct sig + add gda address to config

* gda address can be null

* fix broken unit tests

* fix flakey tests

* more consistent naming of verification related vars

* pool config

- create pool with a poolConfig struct => this struct determines if unit transferability and distribution from any address is allowed
- tests added to ensure the new configs actually block the actions
- existing tests ensures that the configs don't break existing functionality
- fix flakey test in FoundrySuperfluidTester in _addAccount
- move SuperfluidPoolDeployerLibrary to gdaV1 folder

* cleanup

- comment cleanup
- code cleanup

* move pool config out of interface

* move struct to interface

* fix build

* fix build attempt

* fix build

* [ETHEREUM-CONTRACTS] [GDA] Fixes for GDA  (#1729)

* [ETHEREUM-CONTRACTS] BatchLiquidator: don't revert for non-transferrable SuperTokens (#1707)

* don't revert for non-transferrable SuperTokens

* add test for custom tokens revert on transfer

---------

Co-authored-by: Axe <[email protected]>

* patch getUnderlyingToken (#1718)

* Bump undici from 5.21.0 to 5.26.3 (#1719)

Bumps [undici](https://github.com/nodejs/undici) from 5.21.0 to 5.26.3.
- [Release notes](https://github.com/nodejs/undici/releases)
- [Commits](nodejs/undici@v5.21.0...v5.26.3)

---
updated-dependencies:
- dependency-name: undici
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* add error hashes, use currentContext.timestamp

* use getHost.getTimestamp()

* Bump @babel/traverse from 7.21.3 to 7.23.2 (#1723)

Bumps [@babel/traverse](https://github.com/babel/babel/tree/HEAD/packages/babel-traverse) from 7.21.3 to 7.23.2.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.23.2/packages/babel-traverse)

---
updated-dependencies:
- dependency-name: "@babel/traverse"
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* [SDK-CORE/ METADATA] SDK-Core No Governance Fix + Metadata Types (#1728)

* cleanup

* fix types

* remove tests flakiness

* remove forge.sh

* [SDK-CORE] GoodDollar sdk core fix (#1734)

* fix supertoken initialization for gooddollar

* bump version + update changelog

* use governance address from networkData

* gooddollar symbol

---------

Co-authored-by: Kaspar Kallas <[email protected]>

* [ETHEREUM-CONTRACTS] make deploy script compatible with ethers v6 (#1730)

* make deploy script compatible with ethers v6

* more meaningful jsdoc

* add new functions for dev-scripts deployment

* update deploy.sh (#1738)

* Bump browserify-sign in /packages/sdk-core/previous-versions-testing (#1740)

Bumps [browserify-sign](https://github.com/crypto-browserify/browserify-sign) from 4.2.1 to 4.2.2.
- [Changelog](https://github.com/browserify/browserify-sign/blob/main/CHANGELOG.md)
- [Commits](browserify/browserify-sign@v4.2.1...v4.2.2)

---
updated-dependencies:
- dependency-name: browserify-sign
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump browserify-sign from 4.2.1 to 4.2.2 (#1739)

Bumps [browserify-sign](https://github.com/crypto-browserify/browserify-sign) from 4.2.1 to 4.2.2.
- [Changelog](https://github.com/browserify/browserify-sign/blob/main/CHANGELOG.md)
- [Commits](browserify/browserify-sign@v4.2.1...v4.2.2)

---
updated-dependencies:
- dependency-name: browserify-sign
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* fix verification script

* change GDA forwarder address (needed to redeploy)

* change GDA forwarder address for polygon-mumbai

* fix tests to fuzz with different pool configs and fix distributeFlow blocked liquidation issue

* fix TOB-SUPERFLUID-2: Incorrect event emission in connectPool

* fix TOB-SUPERFLUID-5: Large encoded buffer amount could manipulate preceding field

* fix TOB-SUPERFLUID-6: Off-by-one gas left check

* fix broken test

* wrangle with reducing the code size of GDA...

* cleanup

* fix build + tests

* cleanup

* add update beacon proxy update paths

* fix broken deploy script, add tests, add transfer ownership of beacon in deploy script

* fix broken deploy script attempt 2

* [WORKFLOWS] Use nix in `handler.run-ethereum-contracts-script.yml` (#1745)

* handler.run-ethereum-contracts-script.yml

* add nix to handler.deploy-to-testnets.yml

* [ETHEREUM-CONTRACTS] App credit test (#1743)

* add app credit sanity test

* cleanup console.logs

* add cliName (#1748)

* doConnect != isConnected fixed

* remove extra whitespace

* add assertEq in SFGovII test and import PoolConfig in ISuperfluid for easy access

* fix build

* fuzzing fix

* EXPECT BREAKAGE IN FUZZ

* fix build but echidna should break

* undo breakage

* fix the test

* bump sdk-core version, fix sdk-core operation functions, fix subgraph mapping

* fix unit tests

* fix again

* hot fuzz additions

* [ETHEREUM-CONTRACTS] Fix canary build (#1742)

* allow listing non-standard SuperTokens

* fix canary build, fixes #1633

* distributeFlow: fix order of args to be consistent

* fix build

* add fix back in

* [ETHEREUM-CONTRACTS] new resolver and loader, updated and bumped metadata, refs #1004 (#1750)

* new resolver and loader, updated and bumped metadata, refs #1004

* updated changelog

* gda version of loader

* fix build

* new resolver and loader, refs #1004

* remove getIsListed workaround assuming resolver exists (#1751)

* fix broken unit test

* fix gda logic

* [ETHEREUM-CONTRACTS] new resolver & loader address for mainnets (#1752)

* new resolver & loader address for mainnets

* bumped metadata version

* remove unimplemented function from yaml (#1753)

* map the name from subgraph to unknown entity (#1754)

* fix mapping

* add total units

* missing import

* missing import pt 2

* [WORKFLOW] Subgraph deloy all networks (#1760)

* added VENDOR_NETWORKS variable

* decaled variable

* fix mapping (#1758)

* added new supported subgraphs (#1761)

* remove duplicate verification

* subgraph mapping addition

* type fix (#1771)

* readme fix

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Didi <[email protected]>
Co-authored-by: Axe <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Kaspar Kallas <[email protected]>
Co-authored-by: Miao ZhiCheng <[email protected]>
Co-authored-by: Momodu Afegbua <[email protected]>

* wip

* mapping

* better terminology

* fix init mapping

* divide by zero error

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Axe <[email protected]>
Co-authored-by: Miao ZhiCheng <[email protected]>
Co-authored-by: Miao, ZhiCheng <[email protected]>
Co-authored-by: didi <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Kaspar Kallas <[email protected]>
Co-authored-by: Momodu Afegbua <[email protected]>
  • Loading branch information
8 people committed Jan 23, 2024
1 parent f0120f0 commit e8b38e3
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/subgraph/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1809,6 +1809,8 @@ type PoolMember @entity {
units: BigInt!
isConnected: Boolean!
totalAmountClaimed: BigInt!
poolTotalAmountDistributedUntilUpdatedAt: BigInt!
totalAmountReceivedUntilUpdatedAt: BigInt!

account: Account!
pool: Pool!
Expand Down Expand Up @@ -2259,7 +2261,6 @@ type AccountTokenSnapshot @entity {
"""
totalCFANumberOfActiveStreams: Int!

# delete this property
"""
The count of currently open streams for an account, both incoming and outgoing for the GDA.
"""
Expand Down Expand Up @@ -2290,7 +2291,6 @@ type AccountTokenSnapshot @entity {
"""
activeCFAIncomingStreamCount: Int!

# delete this property
"""
The count of active incoming streams to this account for the GDA.
"""
Expand Down
24 changes: 24 additions & 0 deletions packages/subgraph/src/mappingHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,8 @@ export function getOrInitPoolMember(
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();
Expand Down Expand Up @@ -1608,3 +1610,25 @@ export function updateAggregateEntitiesTransferData(
tokenStatistic.totalAmountTransferredUntilUpdatedAt.plus(value);
tokenStatistic.save();
}

/**
* Updates `totalAmountReceivedUntilUpdatedAt` and `poolTotalAmountDistributedUntilUpdatedAt` fields
* Requires an explicit save on the PoolMember entity.
* Requires `pool.totalAmountDistributedUntilUpdatedAt` to be updated prior to calling this function.
* @param pool the pool entity
* @param poolMember the pool member entity
* @returns the updated pool member entity to be saved
*/
export function updatePoolMemberTotalAmountUntilUpdatedAtFields(pool: Pool, poolMember: PoolMember): PoolMember {
const amountReceivedDelta = pool.totalUnits.equals(BIG_INT_ZERO)
? BIG_INT_ZERO
: pool.totalAmountDistributedUntilUpdatedAt
.minus(poolMember.poolTotalAmountDistributedUntilUpdatedAt)
.div(pool.totalUnits)
.times(poolMember.units);
poolMember.totalAmountReceivedUntilUpdatedAt =
poolMember.totalAmountReceivedUntilUpdatedAt.plus(amountReceivedDelta);
poolMember.poolTotalAmountDistributedUntilUpdatedAt = pool.totalAmountDistributedUntilUpdatedAt;

return poolMember;
}
7 changes: 6 additions & 1 deletion packages/subgraph/src/mappings/gdav1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
updateATSStreamedAndBalanceUntilUpdatedAt,
updateAggregateDistributionAgreementData,
updatePoolDistributorTotalAmountFlowedAndDistributed,
updatePoolMemberTotalAmountUntilUpdatedAtFields,
updatePoolTotalAmountFlowedAndDistributed,
updateSenderATSStreamData,
updateTokenStatisticStreamData,
Expand Down Expand Up @@ -83,7 +84,7 @@ export function handlePoolConnectionUpdated(
event: PoolConnectionUpdated
): void {
// Update Pool Member Entity
const poolMember = getOrInitPoolMember(
let poolMember = getOrInitPoolMember(
event,
event.params.pool,
event.params.account
Expand Down Expand Up @@ -128,6 +129,10 @@ export function handlePoolConnectionUpdated(
}
pool.save();

// Update totalAmountDistributedUntilUpdatedAt
poolMember = updatePoolMemberTotalAmountUntilUpdatedAtFields(pool, poolMember);
poolMember.save();

// Update Token Stats Streamed Until Updated At
updateTokenStatsStreamedUntilUpdatedAt(event.params.token, event.block);
// Update ATS Balance and Streamed Until Updated At
Expand Down
10 changes: 8 additions & 2 deletions packages/subgraph/src/mappings/superfluidPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
getOrInitPoolMember,
updateATSStreamedAndBalanceUntilUpdatedAt,
updateAggregateDistributionAgreementData,
updatePoolMemberTotalAmountUntilUpdatedAtFields,
updatePoolTotalAmountFlowedAndDistributed,
updateTokenStatsStreamedUntilUpdatedAt,
} from "../mappingHelpers";
Expand All @@ -27,8 +28,10 @@ export function handleDistributionClaimed(event: DistributionClaimed): void {
pool.save();

// Update PoolMember
const poolMember = getOrInitPoolMember(event, event.address, event.params.member);
let poolMember = getOrInitPoolMember(event, event.address, event.params.member);
poolMember.totalAmountClaimed = event.params.totalClaimed;

poolMember = updatePoolMemberTotalAmountUntilUpdatedAtFields(pool, poolMember);
poolMember.save();

// Update Token Statistics
Expand All @@ -47,7 +50,7 @@ export function handleDistributionClaimed(event: DistributionClaimed): void {
export function handleMemberUnitsUpdated(event: MemberUnitsUpdated): void {
// - PoolMember
// - units
const poolMember = getOrInitPoolMember(event, event.address, event.params.member);
let poolMember = getOrInitPoolMember(event, event.address, event.params.member);
const hasMembershipWithUnits = membershipWithUnitsExists(poolMember.id);

const previousUnits = poolMember.units;
Expand All @@ -73,6 +76,9 @@ export function handleMemberUnitsUpdated(event: MemberUnitsUpdated): void {
pool.totalUnits = pool.totalUnits.plus(unitsDelta);
pool.save();

poolMember = updatePoolMemberTotalAmountUntilUpdatedAtFields(pool, poolMember);
poolMember.save();

// 0 units to > 0 units
if (previousUnits.equals(BIG_INT_ZERO) && event.params.newUnits.gt(BIG_INT_ZERO)) {
pool.totalMembers = pool.totalMembers + 1;
Expand Down

0 comments on commit e8b38e3

Please sign in to comment.