Skip to content

Commit

Permalink
[ETHEREUM-CONTRACTS] [GDA] Fixes for GDA (#1729)
Browse files Browse the repository at this point in the history
* [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]>
  • Loading branch information
7 people authored Jan 5, 2024
1 parent 4ece1a3 commit a13efce
Show file tree
Hide file tree
Showing 91 changed files with 1,909 additions and 1,172 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ jobs:
cloudfront_distribution_id: E3JEO5R14CT8IH

upgrade-contracts:
name: Upgrade ethereum-contracts on canary testnet (protocol release version "test")
name: Upgrade ethereum-contracts on canary testnet (protocol release version "canary")

needs: [all-packages-tested]

Expand Down Expand Up @@ -306,6 +306,6 @@ jobs:
npx truffle exec --network ${{ matrix.network }} ops-scripts/info-print-contract-addresses.js : addresses.vars
tasks/etherscan-verify-framework.sh ${{ matrix.network }} addresses.vars
env:
RELEASE_VERSION: master
RELEASE_VERSION: canary
AVALANCHE_FUJI_MNEMONIC: ${{ secrets.BUILD_AGENT_MNEMONIC }}
AVALANCHE_FUJI_PROVIDER_URL: ${{ secrets.AVALANCHE_FUJI_PROVIDER_URL }}
10 changes: 6 additions & 4 deletions .github/workflows/handler.deploy-to-testnets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ jobs:
DEFAULT_MNEMONIC: ${{ secrets.BUILD_AGENT_MNEMONIC }}
PROVIDER_URL_TEMPLATE: ${{ secrets.PROVIDER_URL_TEMPLATE }}

defaults:
run:
shell: nix develop -c bash -xe {0}

strategy:
fail-fast: false
matrix:
Expand All @@ -39,12 +43,10 @@ jobs:
if: ${{ github.event.inputs.only_network != '' && github.event.inputs.only_network != matrix.network }}
run: echo "DO_SKIP=1" >> "$GITHUB_ENV"

- name: Use Node.js 18.x
- uses: cachix/install-nix-action@v19
if: env.DO_SKIP != 1
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: "yarn"
github_access_token: ${{ secrets.GITHUB_TOKEN }}

- name: Build
if: env.DO_SKIP != 1
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/handler.run-ethereum-contracts-script.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,21 @@ jobs:
run-ethereum-contracts-script:
runs-on: ubuntu-latest

defaults:
run:
shell: nix develop -c bash -xe {0}

env:
RELEASE_VERSION: ${{ github.event.inputs.release_version }}
RESOLVER_ADMIN_TYPE: ${{ github.event.inputs.admin_type }}
GOVERNANCE_ADMIN_TYPE: ${{ github.event.inputs.admin_type }}

steps:
- uses: actions/checkout@v3

- name: Use Node.js 18.x
uses: actions/setup-node@v3

- uses: cachix/install-nix-action@v19
with:
node-version: 18.x
cache: "yarn"
github_access_token: ${{ secrets.GITHUB_TOKEN }}

- name: Build
run: |
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<h1 align="center">Welcome to superfluid protocol-monorepo 👋</h1>

<p>
<a href="#superfluid-financeethereum-contracts" target="_blank">
<a href="#superfluid-finance/ethereum-contracts" target="_blank">
<img alt="npm" src="https://img.shields.io/npm/v/@superfluid-finance/ethereum-contracts?label=ethereum-contracts">
</a>
<a href="#superfluid-financesubgraph" target="_blank">
<a href="#superfluid-finance/subgraph" target="_blank">
<img alt="GitHub package.json version (subfolder of monorepo)" src="https://img.shields.io/github/package-json/v/superfluid-finance/protocol-monorepo?filename=packages%2Fsubgraph%2Fpackage.json&label=subgraph">
</a>
<a href="#superfluid-financejs-sdk" target="_blank">
<a href="#superfluid-finance/js-sdk" target="_blank">
<img alt="npm" src="https://img.shields.io/npm/v/@superfluid-finance/js-sdk?label=js-sdk">
</a>
<a href="#superfluid-financesdk-core" target="_blank">
<a href="#superfluid-finance/sdk-core" target="_blank">
<img alt="npm" src="https://img.shields.io/npm/v/@superfluid-finance/sdk-core?label=sdk-core">
</a>
<a href="#superfluid-financesdk-redux" target="_blank">
<a href="#superfluid-finance/sdk-redux" target="_blank">
<img alt="npm" src="https://img.shields.io/npm/v/@superfluid-finance/sdk-redux?label=sdk-redux">
</a>
<a href="#superfluid-financehot-fuzz" target="_blank">
<a href="#superfluid-finance/hot-fuzz" target="_blank">
<img alt="GitHub package.json version (subfolder of monorepo)" src="https://img.shields.io/github/package-json/v/superfluid-finance/protocol-monorepo?filename=packages%2Fhot-fuzz%2Fpackage.json&label=hot-fuzz">
</a>
<br>
Expand Down
2 changes: 1 addition & 1 deletion packages/automation-contracts/autowrap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
"dependencies": {
"@openzeppelin/contracts": "4.9.3",
"@superfluid-finance/ethereum-contracts": "1.8.1",
"@superfluid-finance/metadata": "1.1.17"
"@superfluid-finance/metadata": "1.1.21"
}
}
2 changes: 1 addition & 1 deletion packages/automation-contracts/scheduler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
"dependencies": {
"@openzeppelin/contracts": "4.9.3",
"@superfluid-finance/ethereum-contracts": "1.8.1",
"@superfluid-finance/metadata": "1.1.17"
"@superfluid-finance/metadata": "1.1.21"
}
}
7 changes: 7 additions & 0 deletions packages/ethereum-contracts/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
## Unreleased

### Breaking

- `TokenInfo` and `ERC20WithTokenInfo` interface/abstract contract are removed from the codebase, including the bundled ABI contracts
- Migration: Use `IERC20Metadata` instead, as this replaces the previous contracts
- `build/typechain-ethers-v5` is removed from the npm package
Expand All @@ -25,13 +26,19 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Note that the admin is stored in the EIP-1967 admin storage slot (`0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`)
- `SuperToken.getAdmin()` added to retrieve the admin address
- `SuperTokenFactory.createERC20Wrapper()` overloads added to create a SuperToken AND explicitly initialize a SuperToken with an admin
- New explicit functions: `deployTestFrameworkWithEthersV5` and `deployTestFrameworkWithEthersV6` in `deploy-test-framework.js`
- `deployTestFramework` is still there, but it is considered deprecated now

### Changed

- Reuse config keys from `SuperfluidGovernanceConfigs` instead of duplicating them in `ConstantFlowAgreementV1`.
- Deprecating `registerAppWithKey` and `registerAppByFactory`: DO NOT USE for new deployments
- Simplification of Super App registration: use `registerApp` in all cases going forward.
- Use `registerApp(uint256 configWord)` to be called by the super app in the constructor or `registerApp(ISuperApp app, uint256 configWord)` to be called by any address with a valid app registration config key

### Fixes
- [`dev-scripts/deploy-test-framework.js`](dev-scripts/deploy-test-framework.js) compatible with both ethers-v5 and ethers-v6 now

## [v1.8.1] - 2023-08-28

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@ contract GeneralDistributionAgreementV1 is AgreementBase, TokenMonad, IGeneralDi
uint256 private constant _POOL_SUBS_BITMAP_STATE_SLOT_ID = 1;
/// @dev Pool member state slot id starting point for pool connections
uint256 private constant _POOL_CONNECTIONS_DATA_STATE_SLOT_ID_START = 1 << 128;
/// @dev CFAv1 PPP Config Key
bytes32 private constant CFAV1_PPP_CONFIG_KEY =
keccak256("org.superfluid-finance.agreements.ConstantFlowAgreement.v1.PPPConfiguration");

/// @dev SuperToken minimum deposit key
bytes32 private constant SUPERTOKEN_MINIMUM_DEPOSIT_KEY =
keccak256("org.superfluid-finance.superfluid.superTokenMinimumDeposit");

Expand All @@ -105,19 +102,21 @@ contract GeneralDistributionAgreementV1 is AgreementBase, TokenMonad, IGeneralDi
superfluidPoolBeacon = superfluidPoolBeacon_;
}

function realtimeBalanceVectorAt(ISuperfluidToken token, address account, uint256 time)
function realtimeBalanceOf(ISuperfluidToken token, address account, uint256 time)
public
view
returns (int256 available, int256 fromPools, int256 buffer)
override
returns (int256 rtb, uint256 buf, uint256 owedBuffer)
{
UniversalIndexData memory universalIndexData = _getUIndexData(abi.encode(token), account);

if (_isPool(token, account)) {
available = ISuperfluidPool(account).getDisconnectedBalance(uint32(time));
rtb = ISuperfluidPool(account).getDisconnectedBalance(uint32(time));
} else {
available = Value.unwrap(_getBasicParticleFromUIndex(universalIndexData).rtb(Time.wrap(uint32(time))));
rtb = Value.unwrap(_getBasicParticleFromUIndex(universalIndexData).rtb(Time.wrap(uint32(time))));
}

int256 fromPools;
{
(uint32[] memory slotIds, bytes32[] memory pidList) = _listPoolConnectionIds(token, account);
for (uint256 i = 0; i < slotIds.length; ++i) {
Expand All @@ -126,24 +125,12 @@ contract GeneralDistributionAgreementV1 is AgreementBase, TokenMonad, IGeneralDi
_getPoolMemberData(token, account, ISuperfluidPool(pool));
assert(exist);
assert(poolMemberData.pool == pool);
fromPools = fromPools + ISuperfluidPool(pool).getClaimable(account, uint32(time));
fromPools += ISuperfluidPool(pool).getClaimable(account, uint32(time));
}
}
rtb += fromPools;

buffer = universalIndexData.totalBuffer.toInt256();
}

function realtimeBalanceOf(ISuperfluidToken token, address account, uint256 time)
public
view
override
returns (int256 rtb, uint256 buf, uint256 owedBuffer)
{
(int256 available, int256 fromPools, int256 buffer) = realtimeBalanceVectorAt(token, account, time);
rtb = available + fromPools;

buf = uint256(buffer); // upcasting to uint256 is safe
owedBuffer = 0;
buf = uint256(universalIndexData.totalBuffer.toInt256()); // upcasting to uint256 is safe
}

/// @dev ISuperAgreement.realtimeBalanceOf implementation
Expand Down Expand Up @@ -322,10 +309,15 @@ contract GeneralDistributionAgreementV1 is AgreementBase, TokenMonad, IGeneralDi
ISuperfluid.Context memory currentContext = AgreementLibrary.authorizeTokenAccess(token, ctx);
address msgSender = currentContext.msgSender;
newCtx = ctx;
if (doConnect) {
if (!isMemberConnected(token, address(pool), msgSender)) {
assert(SuperfluidPool(address(pool)).operatorConnectMember(msgSender, true, uint32(block.timestamp)));
bool isConnected = _isMemberConnected(token, address(pool), msgSender);
if (doConnect != isConnected) {
assert(
SuperfluidPool(address(pool)).operatorConnectMember(
msgSender, doConnect, uint32(currentContext.timestamp)
)
);

if (doConnect) {
uint32 poolSlotID =
_findAndFillPoolConnectionsBitmap(token, msgSender, bytes32(uint256(uint160(address(pool)))));

Expand All @@ -336,33 +328,24 @@ contract GeneralDistributionAgreementV1 is AgreementBase, TokenMonad, IGeneralDi
_getPoolMemberHash(msgSender, pool),
_encodePoolMemberData(PoolMemberData({ poolID: poolSlotID, pool: address(pool) }))
);
}
} else {
if (isMemberConnected(token, address(pool), msgSender)) {
assert(SuperfluidPool(address(pool)).operatorConnectMember(msgSender, false, uint32(block.timestamp)));
} else {
(, PoolMemberData memory poolMemberData) = _getPoolMemberData(token, msgSender, pool);
token.terminateAgreement(_getPoolMemberHash(msgSender, pool), 1);

_clearPoolConnectionsBitmap(token, msgSender, poolMemberData.poolID);
}

emit PoolConnectionUpdated(token, pool, msgSender, doConnect, currentContext.userData);
}

emit PoolConnectionUpdated(token, pool, msgSender, doConnect, currentContext.userData);
}

/// @inheritdoc IGeneralDistributionAgreementV1
function isMemberConnected(ISuperfluidToken token, address pool, address member)
public
view
override
returns (bool)
{
function _isMemberConnected(ISuperfluidToken token, address pool, address member) internal view returns (bool) {
(bool exist,) = _getPoolMemberData(token, member, ISuperfluidPool(pool));
return exist;
}

function isMemberConnected(ISuperfluidPool pool, address member) public view override returns (bool) {
return isMemberConnected(pool.superToken(), address(pool), member);
function isMemberConnected(ISuperfluidPool pool, address member) external view override returns (bool) {
return _isMemberConnected(pool.superToken(), address(pool), member);
}

function appendIndexUpdateByPool(ISuperfluidToken token, BasicParticle memory p, Time t) external returns (bool) {
Expand Down Expand Up @@ -404,12 +387,15 @@ contract GeneralDistributionAgreementV1 is AgreementBase, TokenMonad, IGeneralDi
revert GDA_ONLY_SUPER_TOKEN_POOL();
}

// you cannot distribute if admin is not equal to the ctx.msgSender
if (!pool.distributionFromAnyAddress()) {
if (pool.admin() != currentContext.msgSender) {
revert GDA_DISTRIBUTE_FROM_ANY_ADDRESS_NOT_ALLOWED();
}
}

// the from address must be the same as the ctx.msgSender
// there is no ACL support
if (from != currentContext.msgSender) {
revert GDA_DISTRIBUTE_FOR_OTHERS_NOT_ALLOWED();
}
Expand Down Expand Up @@ -467,7 +453,10 @@ contract GeneralDistributionAgreementV1 is AgreementBase, TokenMonad, IGeneralDi

newCtx = ctx;

if (!pool.distributionFromAnyAddress()) {
// we must check if the requestedFlowRate is greater than 0 here
// otherwise we will block liquidators from closing streams in pools
// where the pool config has distributionFromAnyAddress set to false
if (requestedFlowRate > 0 && !pool.distributionFromAnyAddress()) {
if (pool.admin() != flowVars.currentContext.msgSender) {
revert GDA_DISTRIBUTE_FROM_ANY_ADDRESS_NOT_ALLOWED();
}
Expand All @@ -479,7 +468,7 @@ contract GeneralDistributionAgreementV1 is AgreementBase, TokenMonad, IGeneralDi
address(pool),
flowVars.distributionFlowHash,
FlowRate.wrap(requestedFlowRate),
Time.wrap(uint32(block.timestamp))
Time.wrap(uint32(flowVars.currentContext.timestamp))
);

// handle distribute flow on behalf of someone else
Expand Down Expand Up @@ -515,14 +504,7 @@ contract GeneralDistributionAgreementV1 is AgreementBase, TokenMonad, IGeneralDi
}

{
_adjustBuffer(
abi.encode(token),
address(pool),
from,
flowVars.distributionFlowHash,
flowVars.oldFlowRate,
actualFlowRate
);
_adjustBuffer(token, address(pool), from, flowVars.distributionFlowHash, actualFlowRate);
}

// ensure sender has enough balance to execute transaction
Expand Down Expand Up @@ -636,7 +618,6 @@ contract GeneralDistributionAgreementV1 is AgreementBase, TokenMonad, IGeneralDi
_getFlowDistributionData(ISuperfluidToken(data.token), data.distributionFlowHash);
int256 signedSingleDeposit = flowDistributionData.buffer.toInt256();

bytes memory liquidationTypeData;
bool isCurrentlyPatricianPeriod;

{
Expand All @@ -652,10 +633,9 @@ contract GeneralDistributionAgreementV1 is AgreementBase, TokenMonad, IGeneralDi
// critical case
if (totalRewardLeft >= 0) {
int256 rewardAmount = (signedSingleDeposit * totalRewardLeft) / data.signedTotalGDADeposit;
liquidationTypeData = abi.encode(2, isCurrentlyPatricianPeriod ? 0 : 1);
data.token.makeLiquidationPayoutsV2(
data.distributionFlowHash,
liquidationTypeData,
abi.encode(2, isCurrentlyPatricianPeriod ? 0 : 1),
data.liquidator,
isCurrentlyPatricianPeriod,
data.sender,
Expand All @@ -677,15 +657,9 @@ contract GeneralDistributionAgreementV1 is AgreementBase, TokenMonad, IGeneralDi
}
}

function _adjustBuffer(
bytes memory eff,
address pool,
address from,
bytes32 flowHash,
FlowRate, // oldFlowRate,
FlowRate newFlowRate
) internal returns (bytes memory) {
address token = abi.decode(eff, (address));
function _adjustBuffer(ISuperfluidToken token, address pool, address from, bytes32 flowHash, FlowRate newFlowRate)
internal
{
// not using oldFlowRate in this model
// surprising effect: reducing flow rate may require more buffer when liquidation_period adjusted upward
ISuperfluidGovernance gov = ISuperfluidGovernance(ISuperfluid(_host).getGovernance());
Expand Down Expand Up @@ -718,7 +692,7 @@ contract GeneralDistributionAgreementV1 is AgreementBase, TokenMonad, IGeneralDi
ISuperfluidToken(token).updateAgreementData(flowHash, data);
}

UniversalIndexData memory universalIndexData = _getUIndexData(eff, from);
UniversalIndexData memory universalIndexData = _getUIndexData(abi.encode(token), from);
universalIndexData.totalBuffer =
// new buffer
(universalIndexData.totalBuffer.toInt256() + Value.unwrap(bufferDelta)).toUint256();
Expand All @@ -736,8 +710,6 @@ contract GeneralDistributionAgreementV1 is AgreementBase, TokenMonad, IGeneralDi
universalIndexData.totalBuffer
);
}

return eff;
}

// Solvency Related Getters
Expand Down Expand Up @@ -810,7 +782,7 @@ contract GeneralDistributionAgreementV1 is AgreementBase, TokenMonad, IGeneralDi
data = new bytes32[](2);
data[0] = bytes32(
(uint256(int256(FlowRate.unwrap(p.flow_rate()))) << 160) | (uint256(Time.unwrap(p.settled_at())) << 128)
| (buffer << 32) | (isPool_ ? 1 : 0)
| (uint256(buffer.toUint96()) << 32) | (isPool_ ? 1 : 0)
);
data[1] = bytes32(uint256(Value.unwrap(p._settled_value)));
}
Expand All @@ -823,7 +795,7 @@ contract GeneralDistributionAgreementV1 is AgreementBase, TokenMonad, IGeneralDi
data = new bytes32[](2);
data[0] = bytes32(
(uint256(int256(uIndexData.flowRate)) << 160) | (uint256(uIndexData.settledAt) << 128)
| (uint256(uIndexData.totalBuffer) << 32) | (uIndexData.isPool ? 1 : 0)
| (uint256(uIndexData.totalBuffer.toUint96()) << 32) | (uIndexData.isPool ? 1 : 0)
);
data[1] = bytes32(uint256(uIndexData.settledValue));
}
Expand Down
Loading

0 comments on commit a13efce

Please sign in to comment.