Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
run: yarn

- name: Run coverage
run: forge coverage --match-path "test/{Swarm*,ServiceProvider,FleetIdentity,collections/*,tipping/*}*.t.sol" --ir-minimum --report lcov --report-file coverage.lcov
run: forge coverage --match-path "test/{Swarm*,ServiceProvider,FleetIdentity,collections/*,tipping/*,arcade/*}*.t.sol" --ir-minimum --report lcov --report-file coverage.lcov

- name: Upload coverage report
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -177,6 +177,39 @@ jobs:

echo "Coverage check passed: $COVERAGE% >= $THRESHOLD%"

- name: Check line coverage threshold (arcade)
run: |
# Extract line coverage from lcov report for src/arcade/ contracts only
LINES_FOUND=$(awk '
/^SF:.*src\/arcade\// { in_section = 1 }
/^end_of_record/ { in_section = 0 }
in_section && /^LF:/ { sum += substr($0, 4) }
END { print sum+0 }
' coverage.lcov)

LINES_HIT=$(awk '
/^SF:.*src\/arcade\// { in_section = 1 }
/^end_of_record/ { in_section = 0 }
in_section && /^LH:/ { sum += substr($0, 4) }
END { print sum+0 }
' coverage.lcov)

if [ "$LINES_FOUND" -eq 0 ]; then
echo "Error: No lines found in coverage report for src/arcade/"
exit 1
fi

COVERAGE=$(awk "BEGIN {printf \"%.2f\", ($LINES_HIT / $LINES_FOUND) * 100}")
echo "Arcade line coverage: $COVERAGE% ($LINES_HIT / $LINES_FOUND lines)"

THRESHOLD=95
if awk "BEGIN {exit !($COVERAGE < $THRESHOLD)}"; then
echo "Error: Line coverage ($COVERAGE%) is below the required threshold ($THRESHOLD%)"
exit 1
fi

echo "Coverage check passed: $COVERAGE% >= $THRESHOLD%"

Specification-PDF:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && github.base_ref == 'main'
Expand Down
4 changes: 4 additions & 0 deletions ops/verify_zksync_contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
"UserCollection1155": "src/collections/UserCollection1155.sol:UserCollection1155",
"FundraiserFactory": "src/fundraising/FundraiserFactory.sol:FundraiserFactory",
"Fundraiser": "src/fundraising/Fundraiser.sol:Fundraiser",
"ArcadeEscrow": "src/arcade/ArcadeEscrow.sol:ArcadeEscrow",
}

# Some zkSync forge broadcasts record deployments as calls to ContractDeployer
Expand Down Expand Up @@ -126,6 +127,9 @@
"DeployFundraiserFactory.s.sol": [
"FundraiserFactory",
],
"DeployArcadeEscrow.s.sol": [
"ArcadeEscrow",
],
}


Expand Down
67 changes: 67 additions & 0 deletions script/DeployArcadeEscrow.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// SPDX-License-Identifier: BSD-3-Clause-Clear

pragma solidity ^0.8.26;

import {Script, console} from "forge-std/Script.sol";

import {ArcadeEscrow} from "../src/arcade/ArcadeEscrow.sol";

/**
* @title DeployArcadeEscrow
* @notice Deployment script for the Arcade NODL escrow on ZkSync Era.
* @dev Design: agent-stack `docs/arcade-artifacts-backend-design.md`, section 9.3.
*
* The contract holds user funds and is not upgradeable: there is no proxy. To sponsor
* gas for `deposit`, whitelist the deployed address on the existing `WhitelistPaymaster`
* (`addWhitelistedContracts`); that is a separate admin transaction.
*
* Usage:
* forge script script/DeployArcadeEscrow.s.sol \
* --rpc-url $L2_RPC --broadcast --zksync
*
* Environment Variables:
* - DEPLOYER_PRIVATE_KEY: Private key with ETH for gas.
* - N_TOKEN_ADDR: NODL token address.
* - N_ARCADE_ADMIN: Multisig that will hold DEFAULT_ADMIN_ROLE.
* - N_ARCADE_ORACLE: arcade-forge settlement key, granted ORACLE_ROLE.
* - N_ARCADE_QUOTA: Total NODL (wei) that may be charged per period.
* - N_ARCADE_PERIOD: Optional quota period in seconds, defaults to 1 day.
* - N_ARCADE_MIN_DEPOSIT: Smallest deposit (wei) into an empty balance.
* - N_ARCADE_MAX_CHARGE: Largest single charge (wei).
* - N_ARCADE_WITHDRAW_DELAY: Optional, seconds, defaults to 1 hour.
*/
contract DeployArcadeEscrow is Script {
function run() external {
uint256 deployerPrivateKey = vm.envUint("DEPLOYER_PRIVATE_KEY");
address nodl = vm.envAddress("N_TOKEN_ADDR");
address admin = vm.envAddress("N_ARCADE_ADMIN");
address oracle = vm.envAddress("N_ARCADE_ORACLE");
uint256 quota = vm.envUint("N_ARCADE_QUOTA");
uint256 period = vm.envOr("N_ARCADE_PERIOD", uint256(1 days));
uint256 minDeposit = vm.envUint("N_ARCADE_MIN_DEPOSIT");
uint256 maxCharge = vm.envUint("N_ARCADE_MAX_CHARGE");
uint256 withdrawDelayRaw = vm.envOr("N_ARCADE_WITHDRAW_DELAY", uint256(1 hours));

// The constructor enforces the delay cap too; failing here saves a broadcast round-trip.
require(withdrawDelayRaw <= type(uint64).max, "N_ARCADE_WITHDRAW_DELAY out of range");
require(maxCharge != 0, "N_ARCADE_MAX_CHARGE is zero");
require(quota >= maxCharge, "N_ARCADE_QUOTA is below one max charge");
uint64 withdrawDelay = uint64(withdrawDelayRaw);

console.log("=== Deploying ArcadeEscrow on ZkSync ===");
console.log("NODL:", nodl);
console.log("Admin:", admin);
console.log("Oracle:", oracle);
console.log("Quota / period:", quota, period);
console.log("Min deposit:", minDeposit);
console.log("Max charge:", maxCharge);
console.log("Withdraw delay:", withdrawDelay);

vm.startBroadcast(deployerPrivateKey);
ArcadeEscrow escrow = new ArcadeEscrow(nodl, oracle, admin, quota, period, minDeposit, maxCharge, withdrawDelay);
Comment thread
aliXsed marked this conversation as resolved.
Resolved
vm.stopBroadcast();

console.log("");
console.log("ArcadeEscrow:", address(escrow));
}
}
4 changes: 2 additions & 2 deletions src/QuotaControl.sol
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ contract QuotaControl is AccessControl {
* @dev Sets a new reward quota. Can only be called by an account with the `DEFAULT_ADMIN_ROLE`.
* @param newQuota The new maximum amount of rewards distributable in each period.
*/
function setQuota(uint256 newQuota) external onlyRole(DEFAULT_ADMIN_ROLE) {
function setQuota(uint256 newQuota) external virtual onlyRole(DEFAULT_ADMIN_ROLE) {
quota = newQuota;
emit QuotaSet(newQuota);
}
Expand All @@ -106,7 +106,7 @@ contract QuotaControl is AccessControl {
* Requirements:
* - `newPeriod` must be greater than 0 and less than or equal to `MAX_PERIOD`.
*/
function setPeriod(uint256 newPeriod) external onlyRole(DEFAULT_ADMIN_ROLE) {
function setPeriod(uint256 newPeriod) external virtual onlyRole(DEFAULT_ADMIN_ROLE) {
_mustBeWithinPeriodRange(newPeriod);
period = newPeriod;
emit PeriodSet(newPeriod);
Expand Down
Loading
Loading