Skip to content

Commit

Permalink
fix merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
d10r committed Jan 11, 2024
2 parents 0a509ca + 2f4bdc6 commit 494eb4a
Show file tree
Hide file tree
Showing 172 changed files with 17,620 additions and 2,980 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/call.deploy-dry-run.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Reusable Workflow | Deploy Framework and Update Tokens on a Forked Network

on:
workflow_call:
inputs:
network:
required: true
type: string
network-id:
required: true
type: string
provider-url:
required: true
type: string

jobs:
deploy-to-forked-network:
name: Deploy Framework and Update Tokens on a Forked Network
runs-on: ubuntu-latest
env:
ethereum-contracts-working-directory: ./packages/ethereum-contracts

steps:
- uses: actions/checkout@v3

- name: Install and Build
run: |
yarn install --frozen-lockfile
yarn build-for-contracts-dev
- name: Start ganache
run: npx ganache --port 47545 --mnemonic --fork.url ${{ github.event.inputs.provider-url }} --network-id ${{ github.event.inputs.network-id }} --chain.chainId ${{ github.event.inputs.network-id }}

- name: Deploy framework
run: |
echo "${{ github.event.inputs.environments }}" | sed 's/;/\n/' > .env
npx truffle exec --network ${{ github.event.inputs.network }} ops-scripts/deploy-test-environment.js
working-directory: ${{ env.ethereum-contracts-working-directory }}

- name: Validate deployment before token upgrade
run: |
npx hardhat run ops-scripts/validate-deployment.ts --network ${{ github.event.inputs.network }}
working-directory: ${{ env.ethereum-contracts-working-directory }}

- name: Update Super Token Logic for all tokens
run: |
npx truffle exec --network ${{ github.event.inputs.network }} ops-scripts/gov-upgrade-super-token-logic.js : ALL
working-directory: ${{ env.ethereum-contracts-working-directory }}

- name: Validate deployment post token upgrade
run: |
npx hardhat run ops-scripts/validate-deployment.ts --network ${{ github.event.inputs.network }}
working-directory: ${{ env.ethereum-contracts-working-directory }}
11 changes: 6 additions & 5 deletions .github/workflows/call.test-ethereum-contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,12 @@ jobs:
#
# Upstream issue: https://github.com/NomicFoundation/hardhat/issues/4310
# Though more likely, it is an issue to https://github.com/sc-forks/solidity-coverage
# env:
# # NOTE: 4 workers would overwhelm the free-tier github runner
# IS_COVERAGE_TEST: true
# HARDHAT_TEST_JOBS: 2
# HARDHAT_RUN_PARALLEL: true
env:
# NOTE: 4 workers would overwhelm the free-tier github runner
NODE_OPTIONS: --max_old_space_size=4096
IS_COVERAGE_TEST: true
HARDHAT_TEST_JOBS: 2
HARDHAT_RUN_PARALLEL: false

- name: Clean up and merge coverage artifacts
if: inputs.run-coverage-tests == true
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
18 changes: 9 additions & 9 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 17 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,37 +42,37 @@
"@nomiclabs/hardhat-web3": "^2.0.0",
"@openzeppelin/test-helpers": "^0.5.16",
"@truffle/hdwallet-provider": "^2.1.15",
"@typechain/ethers-v5": "^11.1.1",
"@typechain/ethers-v5": "^11.1.2",
"@typechain/hardhat": "^8.0.3",
"@types/lodash": "^4.14.198",
"@types/mocha": "^10.0.1",
"@typescript-eslint/eslint-plugin": "^6.7.0",
"@typescript-eslint/parser": "^6.7.0",
"@types/lodash": "^4.14.202",
"@types/mocha": "^10.0.6",
"@typescript-eslint/eslint-plugin": "^6.18.1",
"@typescript-eslint/parser": "^6.18.1",
"cloc": "^2.11.0",
"copyfiles": "^2.4.1",
"dotenv": "^16.3.1",
"eslint": "^8.49.0",
"eslint-config-prettier": "^9.0.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-prettier": "^5.0.0",
"hardhat": "^2.17.3",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^5.1.2",
"hardhat": "^2.19.4",
"hardhat-deploy": "^0.11.37",
"husky": "^8.0.3",
"lerna": "^7.3.0",
"node-jq": "^4.0.1",
"nodemon": "^3.0.1",
"node-jq": "^4.2.2",
"nodemon": "^3.0.2",
"npm-run-all": "^4.1.5",
"nyc": "^15.1.0",
"prettier": "^3.0.3",
"prettier": "^3.1.1",
"prettier-eslint": "^15.0.1",
"solhint": "3.6.2",
"syncpack": "^10.9.3",
"truffle": "^5.11.5",
"ts-node": "^10.9.1",
"typechain": "^8.3.1",
"typedoc": "^0.25.1",
"typescript": "^5.2.2",
"ts-node": "^10.9.2",
"typechain": "^8.3.2",
"typedoc": "^0.25.6",
"typescript": "^5.3.3",
"web3": "^1.10.2"
},
"resolutions": {
Expand Down
4 changes: 2 additions & 2 deletions packages/automation-contracts/autowrap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"dependencies": {
"@openzeppelin/contracts": "4.9.3",
"@superfluid-finance/ethereum-contracts": "1.8.1",
"@superfluid-finance/metadata": "1.1.21"
"@superfluid-finance/ethereum-contracts": "1.9.0",
"@superfluid-finance/metadata": "1.1.22"
}
}
4 changes: 2 additions & 2 deletions packages/automation-contracts/scheduler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"dependencies": {
"@openzeppelin/contracts": "4.9.3",
"@superfluid-finance/ethereum-contracts": "1.8.1",
"@superfluid-finance/metadata": "1.1.21"
"@superfluid-finance/ethereum-contracts": "1.9.0",
"@superfluid-finance/metadata": "1.1.22"
}
}
3 changes: 3 additions & 0 deletions packages/ethereum-contracts/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## Unreleased

## [v1.9.0] - 2024-01-09

### Breaking

- `TokenInfo` and `ERC20WithTokenInfo` interface/abstract contract are removed from the codebase, including the bundled ABI contracts
Expand All @@ -14,6 +16,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

### Added

- New agreement: `GeneralDistributionAgreement` added which enables 1-to-N flowing distributions in addition to 1-to-N instant distributions via the `SuperfluidPool` contract
- Added 'test-slither' yarn sub-task.
- Expose `SuperToken._underlyingDecimals` with `SuperToken.getUnderlyingDecimals()`
- Expose `_toUnderlyingAmount(uint256 amount)` with `toUnderlyingAmount(uint256 amount)`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changes Since ToB 2023 Audit

Use `git diff 4ece1a3f4aff8b5a9cbf37118d261023960c0f0f.. packages/ethereum-contracts/contracts` to see the changes in the contract code since the audit commit hash.

## High Level Summary of Changes

### GeneralDistributionAgreementV1
- The representation of totalBuffer is modified to ensure proper data fitting in a 256-bit field.
- `realtimeBalanceVectorAt` removed
- `PoolConnectionUpdated` event only emitted if the connection was changed

### SuperfluidPool
The method for obtaining timestamps and checking member connections is updated to use Superfluid framework methods instead of Ethereum's native functionalities.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { AgreementBase } from "./AgreementBase.sol";
import { SafeCast } from "@openzeppelin/contracts/utils/math/SafeCast.sol";
import { AgreementLibrary } from "./AgreementLibrary.sol";
import { SafeGasLibrary } from "../libs/SafeGasLibrary.sol";
import { SolvencyHelperLibrary } from "../libs/SolvencyHelperLibrary.sol";

/**
* @title ConstantFlowAgreementV1 contract
Expand Down Expand Up @@ -164,7 +165,7 @@ contract ConstantFlowAgreementV1 is
external view override
returns (int96 flowRate)
{
(uint256 liquidationPeriod, ) = _decode3PsData(token);
(uint256 liquidationPeriod, ) = SolvencyHelperLibrary.decode3PsData(ISuperfluid(_host), token);
flowRate = _getMaximumFlowRateFromDepositPure(liquidationPeriod, deposit);
}

Expand Down Expand Up @@ -209,11 +210,12 @@ contract ConstantFlowAgreementV1 is
return true;
}

(uint256 liquidationPeriod, uint256 patricianPeriod) = _decode3PsData(token);
(uint256 liquidationPeriod, uint256 patricianPeriod) =
SolvencyHelperLibrary.decode3PsData(ISuperfluid(_host), token);
(,FlowData memory senderAccountState) = _getAccountFlowState(token, account);
int256 signedTotalCFADeposit = senderAccountState.deposit.toInt256();

return _isPatricianPeriod(
return SolvencyHelperLibrary.isPatricianPeriod(
availableBalance,
signedTotalCFADeposit,
liquidationPeriod,
Expand Down Expand Up @@ -1345,7 +1347,9 @@ contract ConstantFlowAgreementV1 is
uint256 minimumDeposit;
// STEP 1: calculate deposit required for the flow
{
(uint256 liquidationPeriod, ) = _decode3PsData(token);

(uint256 liquidationPeriod,) =
SolvencyHelperLibrary.decode3PsData(ISuperfluid(_host), token);
ISuperfluidGovernance gov = ISuperfluidGovernance(ISuperfluid(msg.sender).getGovernance());
minimumDeposit = gov.getConfigAsUint256(
ISuperfluid(msg.sender), token, SuperfluidGovernanceConfigs.SUPERTOKEN_MINIMUM_DEPOSIT_KEY);
Expand Down Expand Up @@ -1466,7 +1470,7 @@ contract ConstantFlowAgreementV1 is
(,FlowData memory senderAccountState) = _getAccountFlowState(token, flowParams.sender);

int256 signedSingleDeposit = flowData.deposit.toInt256();
// TODO: GDA deposit should be considered here too

int256 signedTotalCFADeposit = senderAccountState.deposit.toInt256();
bytes memory liquidationTypeData;
bool isCurrentlyPatricianPeriod;
Expand All @@ -1482,8 +1486,9 @@ contract ConstantFlowAgreementV1 is
// To retrieve patrician period
// Note: curly brackets are to handle stack too deep overflow issue
{
(uint256 liquidationPeriod, uint256 patricianPeriod) = _decode3PsData(token);
isCurrentlyPatricianPeriod = _isPatricianPeriod(
(uint256 liquidationPeriod, uint256 patricianPeriod) =
SolvencyHelperLibrary.decode3PsData(ISuperfluid(_host), token);
isCurrentlyPatricianPeriod = SolvencyHelperLibrary.isPatricianPeriod(
availableBalance,
signedTotalCFADeposit,
liquidationPeriod,
Expand Down Expand Up @@ -1616,51 +1621,6 @@ contract ConstantFlowAgreementV1 is
}
}

/**************************************************************************
* 3P's Pure Functions
*************************************************************************/

//
// Data packing:
//
// WORD A: | reserved | patricianPeriod | liquidationPeriod |
// | 192 | 32 | 32 |
//
// NOTE:
// - liquidation period has 32 bits length
// - patrician period also has 32 bits length

function _decode3PsData(
ISuperfluidToken token
)
internal view
returns(uint256 liquidationPeriod, uint256 patricianPeriod)
{
ISuperfluidGovernance gov = ISuperfluidGovernance(ISuperfluid(_host).getGovernance());
uint256 pppConfig =
gov.getConfigAsUint256(ISuperfluid(_host), token, SuperfluidGovernanceConfigs.CFAV1_PPP_CONFIG_KEY);
(liquidationPeriod, patricianPeriod) = SuperfluidGovernanceConfigs.decodePPPConfig(pppConfig);
}

function _isPatricianPeriod(
int256 availableBalance,
int256 signedTotalCFADeposit,
uint256 liquidationPeriod,
uint256 patricianPeriod
)
internal pure
returns (bool)
{
if (signedTotalCFADeposit == 0) {
return false;
}

int256 totalRewardLeft = availableBalance + signedTotalCFADeposit;
int256 totalCFAOutFlowrate = signedTotalCFADeposit / int256(liquidationPeriod);
// divisor cannot be zero with existing outflow
return totalRewardLeft / totalCFAOutFlowrate > int256(liquidationPeriod - patricianPeriod);
}

/**************************************************************************
* ACL Pure Functions
*************************************************************************/
Expand Down
Loading

0 comments on commit 494eb4a

Please sign in to comment.