Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/fvm-solidity"]
path = lib/fvm-solidity
url = https://github.com/filecoin-project/fvm-solidity
[submodule "lib/safe-smart-account"]
path = lib/safe-smart-account
url = https://github.com/safe-fndn/safe-smart-account
5 changes: 4 additions & 1 deletion foundry.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
"rev": "bf647bd6046f2f7da30d0c2bf435e5c76a780c1b"
}
},
"lib/fvm-solidity": {
"rev": "ea1fe65367d7539236be111916a6e2781bcf7a1b"
},
"lib/safe-smart-account": {
"tag": {
"name": "v1.5.0",
"rev": "77901a5a1ad835b74ad3b72f73a8412cfe491c57"
}
}
}
}
3 changes: 2 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ bytecode_hash = "none"
# For dependencies
remappings = [
'forge-std/=lib/forge-std/src/',
'fvm-solidity/=lib/fvm-solidity/src/',
'@safe/=lib/safe-smart-account/contracts/',
#'@fvm-solidity/=lib/pdp/lib/fvm-solidity/src/',
]

[lint]
severity = ["high", "med", "low", "info", "gas", "code-size"]
exclude_lints = [
"incorrect-shift",
"multi-contract-file",
"unsafe-typecast",
"unwrapped-modifier-logic",
]
1 change: 1 addition & 0 deletions lib/fvm-solidity
Submodule fvm-solidity added at ea1fe6
21 changes: 21 additions & 0 deletions src/lib/FVMRewardMethod.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
pragma solidity ^0.8.36;

// FRC-0042 method numbers for the f02 (Reward actor) stream-splitting methods proposed by
// FIP-1270 (https://github.com/filecoin-project/FIPs/pull/1270) and tracked upstream at
// filecoin-project/builtin-actors#1764. The actor does not exist yet; these numbers are the
// FRC-0042 hash of each method name, defined here so FVMRewards and its mock agree on them.
uint64 constant REGISTER_STREAM = 386660827;
uint64 constant REMOVE_STREAM = 1623858416;
uint64 constant SET_WEIGHT_RECORDS = 3362570548;
uint64 constant STEP_WEIGHT_RECORDS = 3951753085;
uint64 constant SET_DISTRIBUTION = 3872725033;
uint64 constant CANCEL_PENDING = 187585191;
uint64 constant SET_SHARES = 2414422607;
uint64 constant CLAIM = 4045527845;
uint64 constant GET_STATE = 1397113977;

/// @dev The activation timelock SWA writes to f02 are queued under: the mainnet default,
/// 7 days in epochs (30s/epoch); migration-set per network, so the real actor also exposes it
/// as mutable state rather than a hardcoded constant.
uint64 constant SWA_TIMELOCK = 20160;
37 changes: 37 additions & 0 deletions src/lib/FVMRewardTypes.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
pragma solidity ^0.8.36;

/// @notice A stream's Distribution kind (FIP-1270 Section 2.4).
/// @dev IMPLICIT streams store no writer (f02 resolves the recipient from protocol state).
/// EXPLICIT streams are paid out per a wallet-to-share map written by their designated writer.
enum DistributionKind {
IMPLICIT,
EXPLICIT
}

/// @notice A stream's weight schedule: clamp(vStart + slope * (epoch - tStart), floor, cap).
/// @dev WAD-scaled (1e18 == 1.0 == 100%); fields must fit int64 to be wire-encodable.
struct WeightRecord {
int256 vStart;
int256 slope;
uint64 tStart;
int256 floor;
int256 cap;
}

/// @notice One entry in an EXPLICIT stream's wallet-to-share map.
/// @dev Shares across a stream's map must sum to SHARE_TOTAL (1e18); a single share must
/// therefore fit uint64.
struct Share {
address wallet;
uint256 share;
}

/// @notice The kinds of queueable SWA discretionary writes a pending slot may hold.
enum PendingOp {
SET_WEIGHT,
STEP_WEIGHT,
REGISTER,
REMOVE,
SET_DISTRIBUTION
}
Loading