Skip to content

Commit

Permalink
Merge branch 'dev' into integrate-slither-to-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
0xdavinchee authored Oct 24, 2023
2 parents 22c4229 + 8ab5829 commit b449f54
Show file tree
Hide file tree
Showing 103 changed files with 2,045 additions and 732 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ jobs:
run: yarn build
working-directory: ./packages/ethereum-contracts

- name: "Build SDK-Core"
run: yarn build
working-directory: ${{ env.sdk-core-working-directory }}

- name: Get Hosted Service Networks from metadata
run: npx ts-node ./scripts/getHostedServiceNetworks.ts
working-directory: ./packages/subgraph

- name: Run schema check
run: |
./tasks/setupTestEnvironment.sh
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/call.deploy-subgraph.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ jobs:
run: "yarn codegen"
working-directory: ${{ env.subgraph-working-directory }}

- name: Get Hosted Service Networks from metadata
run: npx ts-node ./scripts/getHostedServiceNetworks.ts
working-directory: ${{ env.subgraph-working-directory }}

# - name: Ensure deployment_env property is passed
# run: |
# if [ "${{ inputs.deployment_env }}" == "" ];then
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/call.test-local-subgraph.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ jobs:
name: Run subgraph unit tests
runs-on: ubuntu-latest

env:
subgraph-working-directory: ./packages/subgraph

defaults:
run:
shell: nix develop -c bash -xe {0}
Expand All @@ -34,10 +37,14 @@ jobs:
- name: "Build contracts"
run: yarn build
working-directory: ./packages/ethereum-contracts

- name: "Build"
run: npx ts-node scripts/buildNetworkConfig.ts polygon-mainnet
working-directory: ${{ env.subgraph-working-directory }}

- name: "Run unit tests"
run: yarn matchstick
working-directory: ./packages/subgraph
working-directory: ${{ env.subgraph-working-directory }}

subgraph-end-to-end-integration:
name: Run subgraph integration tests
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/daily-slack-message.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18.x


- name: Send slack message
run: node tasks/daily-slack-bot.js
working-directory: tasks
run: |
npm install ethers --force
node daily-slack-bot.js
env:
CI_SLACK_WEBHOOK: ${{ secrets.CI_SLACK_WEBHOOK }}
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }}
Expand All @@ -27,4 +31,5 @@ jobs:
ARBISCAN_API_KEY: ${{ secrets.ARBISCAN_API_KEY }}
BSCSCAN_API_KEY: ${{ secrets.BSCSCAN_API_KEY }}
CELOSCAN_API_KEY: ${{ secrets.CELOSCAN_API_KEY }}
GNOSISSCAN_API_KEY: ${{ secrets.GNOSISSCAN_API_KEY}}
GNOSISSCAN_API_KEY: ${{ secrets.GNOSISSCAN_API_KEY}}
ZKEVM_POLYGONSCAN_API_KEY: ${{ secrets.ZKEVM_POLYGONSCAN_API_KEY }}
6 changes: 3 additions & 3 deletions flake.lock

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

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.16"
"@superfluid-finance/metadata": "1.1.18"
}
}
4 changes: 0 additions & 4 deletions packages/automation-contracts/autowrap/remappings.txt

This file was deleted.

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.16"
"@superfluid-finance/metadata": "1.1.18"
}
}
4 changes: 0 additions & 4 deletions packages/automation-contracts/scheduler/remappings.txt

This file was deleted.

11 changes: 8 additions & 3 deletions packages/ethereum-contracts/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,19 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Expose `_toUnderlyingAmount(uint256 amount)` with `toUnderlyingAmount(uint256 amount)`
- `batchCall` supports payable `OPERATION_TYPE_SUPERFLUID_CALL_APP_ACTION`: only the first `OPERATION_TYPE_SUPERFLUID_CALL_APP_ACTION` will be payable
- Added two new functions to `SuperfluidGovernanceBase.sol`: `changeSuperTokenAdmin` and `batchChangeSuperTokenAdmin`
- `Superfluid.changeSuperTokenAdmin()` function added to be called via governance for tokens with no admin override
- Added an overloaded `initialize` to `SuperToken.sol`, which additionally takes `address adminOverride` if you want to initialize the token with an admin override
- `Superfluid.changeSuperTokenAdmin()` function added to be called via governance for tokens with no admin address
- Added an overloaded `initialize` to `SuperToken.sol`, which additionally takes `address admin` if you want to initialize the token with an admin address
- `SuperToken.changeAdmin(address newAdmin)` added which is only callable by the current admin, the "admin" of a SuperToken can change the admin and update the proxy contract's pointer to a logic contract
> Note that the default admin (when address(0)) is the host contract as is currently the case
- `SuperToken.getAdminOverride()` added to retrieve the AdminOverride struct (currently only holds one property: `address admin`), but is future-proofed with 12 additional bits that can be packed in the struct
- 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

### 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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ contract ConstantFlowAgreementV1 is
/// @dev Maximum flow rate
uint256 public constant MAXIMUM_FLOW_RATE = uint256(uint96(type(int96).max));

bytes32 private constant CFAV1_PPP_CONFIG_KEY =
keccak256("org.superfluid-finance.agreements.ConstantFlowAgreement.v1.PPPConfiguration");

bytes32 private constant SUPERTOKEN_MINIMUM_DEPOSIT_KEY =
keccak256("org.superfluid-finance.superfluid.superTokenMinimumDeposit");

// An arbitrarily chosen safety limit for the external calls to protect against out-of-gas grief exploits.
// solhint-disable-next-line var-name-mixedcase
uint64 constant public CFA_HOOK_GAS_LIMIT = 250000;
Expand Down Expand Up @@ -184,8 +178,11 @@ contract ConstantFlowAgreementV1 is
// base case: 0 flow rate
if (flowRate == 0) return 0;
ISuperfluidGovernance gov = ISuperfluidGovernance(ISuperfluid(_host).getGovernance());
uint256 minimumDeposit = gov.getConfigAsUint256(ISuperfluid(_host), token, SUPERTOKEN_MINIMUM_DEPOSIT_KEY);
uint256 pppConfig = gov.getConfigAsUint256(ISuperfluid(_host), token, CFAV1_PPP_CONFIG_KEY);
uint256 minimumDeposit = gov.getConfigAsUint256(
ISuperfluid(_host), token, SuperfluidGovernanceConfigs.SUPERTOKEN_MINIMUM_DEPOSIT_KEY
);
uint256 pppConfig =
gov.getConfigAsUint256(ISuperfluid(_host), token, SuperfluidGovernanceConfigs.CFAV1_PPP_CONFIG_KEY);
(uint256 liquidationPeriod, ) = SuperfluidGovernanceConfigs.decodePPPConfig(pppConfig);
return _getDepositRequiredForFlowRatePure(minimumDeposit, liquidationPeriod, flowRate);
}
Expand Down Expand Up @@ -1199,7 +1196,7 @@ contract ConstantFlowAgreementV1 is
// https://github.com/superfluid-finance/protocol-monorepo/wiki/About-App-Credit
// Allow apps to take an additional amount of app credit (minimum deposit)
uint256 minimumDeposit = gov.getConfigAsUint256(
ISuperfluid(msg.sender), token, SUPERTOKEN_MINIMUM_DEPOSIT_KEY);
ISuperfluid(msg.sender), token, SuperfluidGovernanceConfigs.SUPERTOKEN_MINIMUM_DEPOSIT_KEY);

// NOTE: we do not provide additionalAppCreditAmount when cbStates.appCreditGranted is 0
// (closing streams)
Expand Down Expand Up @@ -1351,7 +1348,7 @@ contract ConstantFlowAgreementV1 is
(uint256 liquidationPeriod, ) = _decode3PsData(token);
ISuperfluidGovernance gov = ISuperfluidGovernance(ISuperfluid(msg.sender).getGovernance());
minimumDeposit = gov.getConfigAsUint256(
ISuperfluid(msg.sender), token, SUPERTOKEN_MINIMUM_DEPOSIT_KEY);
ISuperfluid(msg.sender), token, SuperfluidGovernanceConfigs.SUPERTOKEN_MINIMUM_DEPOSIT_KEY);
// rounding up the number for app credit too
// CAVEAT:
// - Now app could create a flow rate that is slightly higher than the incoming flow rate.
Expand Down Expand Up @@ -1640,7 +1637,8 @@ contract ConstantFlowAgreementV1 is
returns(uint256 liquidationPeriod, uint256 patricianPeriod)
{
ISuperfluidGovernance gov = ISuperfluidGovernance(ISuperfluid(_host).getGovernance());
uint256 pppConfig = gov.getConfigAsUint256(ISuperfluid(_host), token, CFAV1_PPP_CONFIG_KEY);
uint256 pppConfig =
gov.getConfigAsUint256(ISuperfluid(_host), token, SuperfluidGovernanceConfigs.CFAV1_PPP_CONFIG_KEY);
(liquidationPeriod, patricianPeriod) = SuperfluidGovernanceConfigs.decodePPPConfig(pppConfig);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ library SuperAppDefinitions {
/**************************************************************************
/ App Jail Reasons
/**************************************************************************/

uint256 constant internal APP_RULE_REGISTRATION_ONLY_IN_CONSTRUCTOR = 1;
uint256 constant internal APP_RULE_NO_REGISTRATION_FOR_EOA = 2;
uint256 constant internal APP_RULE_NO_REVERT_ON_TERMINATION_CALLBACK = 10;
uint256 constant internal APP_RULE_NO_CRITICAL_SENDER_ACCOUNT = 11;
uint256 constant internal APP_RULE_NO_CRITICAL_RECEIVER_ACCOUNT = 12;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ import { IConstantInflowNFT } from "./IConstantInflowNFT.sol";
*/
interface ISuperToken is ISuperfluidToken, IERC20Metadata, IERC777 {

struct AdminOverride {
address admin;
/// @note we use a struct so the 12 remaining
/// packed bytes may be used later on
}

/**************************************************************************
* Errors
*************************************************************************/
Expand Down Expand Up @@ -48,30 +42,30 @@ interface ISuperToken is ISuperfluidToken, IERC20Metadata, IERC777 {
) external;

/**
* @dev Initialize the contract with admin override
* @dev Initialize the contract with an admin
*/
function initializeWithAdminOverride(
function initializeWithAdmin(
IERC20 underlyingToken,
uint8 underlyingDecimals,
string calldata n,
string calldata s,
address adminOverride
address admin
) external;

/**
* @notice Changes the admin override for the SuperToken
* @notice Changes the admin for the SuperToken
* @dev Only the current admin can call this function
* if adminOverride is address(0), it is implicitly the host address
* @param newAdmin New admin override address
* if admin is address(0), it is implicitly the host address
* @param newAdmin New admin address
*/
function changeAdmin(address newAdmin) external;

event AdminChanged(address indexed oldAdmin, address indexed newAdmin);

/**
* @dev Returns the admin override struct for the SuperToken
* @dev Returns the admin address for the SuperToken
*/
function getAdminOverride() external view returns (AdminOverride memory);
function getAdmin() external view returns (address admin);

/**************************************************************************
* Immutable variables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ interface ISuperTokenFactory {
* @param upgradability Upgradability mode
* @param name Super token name
* @param symbol Super token symbol
* @param adminOverride Admin address override
* @param admin Admin address
* @return superToken The deployed and initialized wrapper super token
*/
function createERC20Wrapper(
Expand All @@ -64,7 +64,7 @@ interface ISuperTokenFactory {
Upgradability upgradability,
string calldata name,
string calldata symbol,
address adminOverride
address admin
)
external
returns (ISuperToken superToken);
Expand Down Expand Up @@ -94,15 +94,15 @@ interface ISuperTokenFactory {
* @param upgradability Upgradability mode
* @param name Super token name
* @param symbol Super token symbol
* @param adminOverride Admin address override
* @param admin Admin address
* @return superToken The deployed and initialized wrapper super token
*/
function createERC20Wrapper(
IERC20Metadata underlyingToken,
Upgradability upgradability,
string calldata name,
string calldata symbol,
address adminOverride
address admin
)
external
returns (ISuperToken superToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,13 @@ interface ISuperfluid {
// uses SuperAppDefinitions' App Jail Reasons as _code
error APP_RULE(uint256 _code); // 0xa85ba64f

error HOST_INVALID_OR_EXPIRED_SUPER_APP_REGISTRATION_KEY(); // 0x19ab84d1
error HOST_NOT_A_SUPER_APP(); // 0x163cbe43
error HOST_NO_APP_REGISTRATION_PERMISSIONS(); // 0x5b93ebf0
error HOST_NO_APP_REGISTRATION_PERMISSION(); // 0xb56455f0
error HOST_RECEIVER_IS_NOT_SUPER_APP(); // 0x96aa315e
error HOST_SENDER_IS_NOT_SUPER_APP(); // 0xbacfdc40
error HOST_SOURCE_APP_NEEDS_HIGHER_APP_LEVEL(); // 0x44725270
error HOST_SUPER_APP_IS_JAILED(); // 0x02384b64
error HOST_SUPER_APP_ALREADY_REGISTERED(); // 0x01b0a935
error HOST_UNAUTHORIZED_SUPER_APP_FACTORY(); // 0x289533c5

/**************************************************************************
* Time
Expand Down Expand Up @@ -234,8 +232,8 @@ interface ISuperfluid {
event SuperTokenLogicUpdated(ISuperToken indexed token, address code);

/**
* @notice Change the SuperToken admin override
* @dev The admin override is the only account allowed to update the token logic
* @notice Change the SuperToken admin address
* @dev The admin is the only account allowed to update the token logic
* For backward compatibility, the "host" is the default "admin" if unset (address(0)).
*/
function changeSuperTokenAdmin(ISuperToken token, address newAdmin) external;
Expand All @@ -245,35 +243,39 @@ interface ISuperfluid {
*************************************************************************/

/**
* @dev Message sender (must be a contract) declares itself as a super app.
* @custom:deprecated you should use `registerAppWithKey` or `registerAppByFactory` instead,
* because app registration is currently governance permissioned on mainnets.
* @dev Message sender (must be a contract) registers itself as a super app.
* @param configWord The super app manifest configuration, flags are defined in
* `SuperAppDefinitions`
* @notice On some mainnet deployments, pre-authorization by governance may be needed for this to succeed.
* See https://github.com/superfluid-finance/protocol-monorepo/wiki/Super-App-White-listing-Guide
*/
function registerApp(uint256 configWord) external;

/**
* @dev Registers an app (must be a contract) as a super app.
* @param app The super app address
* @param configWord The super app manifest configuration, flags are defined in
* `SuperAppDefinitions`
* @notice On some mainnet deployments, pre-authorization by governance may be needed for this to succeed.
* See https://github.com/superfluid-finance/protocol-monorepo/wiki/Super-App-White-listing-Guide
*/
function registerApp(ISuperApp app, uint256 configWord) external;

/**
* @dev App registered event
* @param app Address of jailed app
*/
event AppRegistered(ISuperApp indexed app);

/**
* @dev Message sender declares itself as a super app.
* @param configWord The super app manifest configuration, flags are defined in `SuperAppDefinitions`
* @param registrationKey The registration key issued by the governance, needed to register on a mainnet.
* @notice See https://github.com/superfluid-finance/protocol-monorepo/wiki/Super-App-White-listing-Guide
* On testnets or in dev environment, a placeholder (e.g. empty string) can be used.
* While the message sender must be the super app itself, the transaction sender (tx.origin)
* must be the deployer account the registration key was issued for.
* @dev DO NOT USE for new deployments
* @custom:deprecated you should use `registerApp(uint256 configWord) instead.
*/
function registerAppWithKey(uint256 configWord, string calldata registrationKey) external;

/**
* @dev Message sender (must be a contract) declares app as a super app
* @param configWord The super app manifest configuration, flags are defined in `SuperAppDefinitions`
* @notice On mainnet deployments, only factory contracts pre-authorized by governance can use this.
* See https://github.com/superfluid-finance/protocol-monorepo/wiki/Super-App-White-listing-Guide
* @dev DO NOT USE for new deployments
* @custom:deprecated you should use `registerApp(ISuperApp app, uint256 configWord) instead.
*/
function registerAppByFactory(ISuperApp app, uint256 configWord) external;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ contract SuperAppMockWithRegistrationKey {
}

// An Super App that uses registerAppWithKey
contract SuperAppMockUsingDeprecatedRegisterApp {
contract SuperAppMockUsingRegisterApp {
constructor(ISuperfluid host, uint256 configWord) {
// @note this is deprecated keeping this here for testing/coverage
host.registerApp(configWord);
Expand Down
Loading

0 comments on commit b449f54

Please sign in to comment.