-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
1,055 additions
and
242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,5 @@ docs/ | |
|
||
# Dotenv file | ||
.env | ||
|
||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"solidity.compileUsingRemoteVersion": "v0.8.25+commit.b61c2a91", | ||
"solidity.packageDefaultDependenciesContractsDirectory": "src", | ||
"solidity.packageDefaultDependenciesDirectory": "lib", | ||
"editor.formatOnSave": true, | ||
"[solidity]": { | ||
"editor.defaultFormatter": "JuanBlanco.solidity" | ||
}, | ||
"solidity.formatter": "forge", | ||
"solidity.remappings": [ | ||
"@openzeppelin/=project/contracts/lib/openzeppelin-contracts/", | ||
"@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", | ||
"@symbiotic/=lib/core/src/" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
[profile.default] | ||
solc = "0.8.25" | ||
via_ir = true | ||
src = "src" | ||
out = "out" | ||
libs = ["lib"] | ||
ffi = true | ||
ast = true | ||
build_info = true | ||
extra_output = ["storageLayout"] | ||
|
||
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options | ||
remappings = [ | ||
'@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/', | ||
'@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/', | ||
] |
Submodule core
updated
63 files
Submodule forge-std
updated
15 files
+4 −0 | src/StdChains.sol | |
+104 −0 | src/StdJson.sol | |
+104 −0 | src/StdToml.sol | |
+17 −0 | src/Vm.sol | |
+1 −1 | test/StdAssertions.t.sol | |
+14 −12 | test/StdChains.t.sol | |
+10 −10 | test/StdCheats.t.sol | |
+12 −12 | test/StdError.t.sol | |
+1 −1 | test/StdJson.t.sol | |
+4 −14 | test/StdMath.t.sol | |
+5 −5 | test/StdStorage.t.sol | |
+1 −1 | test/StdStyle.t.sol | |
+1 −1 | test/StdToml.t.sol | |
+12 −12 | test/StdUtils.t.sol | |
+2 −2 | test/Vm.t.sol |
Submodule openzeppelin-contracts
updated
448 files
Submodule openzeppelin-contracts-upgradeable
updated
379 files
Submodule openzeppelin-foundry-upgrades
updated
30 files
Submodule rewards
updated
17 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/ | ||
@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/ | ||
@symbiotic/=lib/core/src/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity 0.8.25; | ||
|
||
import {Script} from "forge-std/Script.sol"; | ||
import {SimpleMiddleware} from "src/SimpleMiddleware.sol"; | ||
import {IRegistry} from "@symbiotic/interfaces/common/IRegistry.sol"; | ||
import {INetworkRegistry} from "@symbiotic/interfaces/INetworkRegistry.sol"; | ||
import {IOperatorRegistry} from "@symbiotic/interfaces/IOperatorRegistry.sol"; | ||
import {IOptInService} from "@symbiotic/interfaces/service/IOptInService.sol"; | ||
import {IVault} from "@symbiotic/interfaces/vault/IVault.sol"; | ||
import {IBaseDelegator} from "@symbiotic/interfaces/delegator/IBaseDelegator.sol"; | ||
|
||
contract NetworkSetup is Script { | ||
function run( | ||
address networkRegistry, | ||
address[] memory vaults, | ||
uint256 subnetworksCnt, | ||
uint256[][] calldata networkLimits | ||
) external { | ||
require(vaults.length == networkLimits.length, "inconsistent length"); | ||
vm.startBroadcast(); | ||
INetworkRegistry(networkRegistry).registerNetwork(); | ||
for (uint256 i = 0; i < vaults.length; ++i) { | ||
require(subnetworksCnt == networkLimits[i].length, "inconsistent length"); | ||
address delegator = IVault(vaults[i]).delegator(); | ||
for (uint96 j = 0; j < subnetworksCnt; ++j) { | ||
IBaseDelegator(delegator).setMaxNetworkLimit(j, networkLimits[i][j]); | ||
} | ||
} | ||
vm.stopBroadcast(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity 0.8.25; | ||
|
||
import {Script} from "forge-std/Script.sol"; | ||
import {SimpleMiddleware} from "src/SimpleMiddleware.sol"; | ||
|
||
contract Setup is Script { | ||
function run( | ||
address network, | ||
address owner, | ||
uint48 epochDuration, | ||
address[] memory vaults, | ||
address[] memory operators, | ||
bytes32[] memory keys, | ||
address operatorRegistry, | ||
address vaultRegistry, | ||
address operatorNetworkOptIn | ||
) external { | ||
require(operators.length == keys.length, "inconsistent length"); | ||
vm.startBroadcast(); | ||
|
||
uint48 minSlashingWindow = epochDuration; // we dont use this | ||
|
||
SimpleMiddleware middleware = new SimpleMiddleware( | ||
network, operatorRegistry, vaultRegistry, operatorNetworkOptIn, owner, epochDuration, minSlashingWindow | ||
); | ||
|
||
for (uint256 i = 0; i < vaults.length; ++i) { | ||
middleware.registerVault(vaults[i]); | ||
} | ||
|
||
for (uint256 i = 0; i < operators.length; ++i) { | ||
middleware.registerOperator(operators[i], keys[i]); | ||
} | ||
|
||
vm.stopBroadcast(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.25; | ||
|
||
import {Checkpoints} from "@openzeppelin/contracts/utils/structs/Checkpoints.sol"; | ||
import {Time} from "@openzeppelin/contracts/utils/types/Time.sol"; | ||
import {EnumerableMap} from "@openzeppelin/contracts/utils/structs/EnumerableMap.sol"; | ||
|
||
library MapWithTimeData { | ||
using EnumerableMap for EnumerableMap.AddressToUintMap; | ||
|
||
error AlreadyAdded(); | ||
error NotEnabled(); | ||
error AlreadyEnabled(); | ||
|
||
uint256 private constant ENABLED_TIME_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFF; | ||
uint256 private constant DISABLED_TIME_MASK = | ||
0xFFFFFFFFFFFFFFFFFFFFFFFF << 48; | ||
|
||
function add( | ||
EnumerableMap.AddressToUintMap storage self, | ||
address addr | ||
) internal { | ||
if (!self.set(addr, uint256(0))) { | ||
revert AlreadyAdded(); | ||
} | ||
} | ||
|
||
function disable( | ||
EnumerableMap.AddressToUintMap storage self, | ||
address addr | ||
) internal { | ||
uint256 value = self.get(addr); | ||
|
||
if (uint48(value) == 0 || uint48(value >> 48) != 0) { | ||
revert NotEnabled(); | ||
} | ||
|
||
value |= uint256(Time.timestamp()) << 48; | ||
self.set(addr, value); | ||
} | ||
|
||
function enable( | ||
EnumerableMap.AddressToUintMap storage self, | ||
address addr | ||
) internal { | ||
uint256 value = self.get(addr); | ||
|
||
if (uint48(value) != 0 && uint48(value >> 48) == 0) { | ||
revert AlreadyEnabled(); | ||
} | ||
|
||
value = uint256(Time.timestamp()); | ||
self.set(addr, value); | ||
} | ||
|
||
function atWithTimes( | ||
EnumerableMap.AddressToUintMap storage self, | ||
uint256 idx | ||
) | ||
internal | ||
view | ||
returns (address key, uint48 enabledTime, uint48 disabledTime) | ||
{ | ||
uint256 value; | ||
(key, value) = self.at(idx); | ||
enabledTime = uint48(value); | ||
disabledTime = uint48(value >> 48); | ||
} | ||
|
||
function getTimes( | ||
EnumerableMap.AddressToUintMap storage self, | ||
address addr | ||
) internal view returns (uint48 enabledTime, uint48 disabledTime) { | ||
uint256 value = self.get(addr); | ||
enabledTime = uint48(value); | ||
disabledTime = uint48(value >> 48); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.25; | ||
|
||
import {Checkpoints} from "@openzeppelin/contracts/utils/structs/Checkpoints.sol"; | ||
import {Time} from "@openzeppelin/contracts/utils/types/Time.sol"; | ||
|
||
import {IVault} from "@symbiotic/interfaces/vault/IVault.sol"; | ||
|
||
abstract contract SimpleKeyRegistry32 { | ||
using Checkpoints for Checkpoints.Trace208; | ||
|
||
error DuplicateKey(); | ||
|
||
mapping(address => Checkpoints.Trace208) private operatorToIdx; | ||
mapping(bytes32 => address) private keyToOperator; | ||
mapping(uint208 => bytes32) private idxToKey; | ||
uint208 private totalKeys; | ||
|
||
uint208 internal constant EMPTY_KEY_IDX = 0; | ||
|
||
function getOperatorByKey(bytes32 key) public view returns (address) { | ||
return keyToOperator[key]; | ||
} | ||
|
||
function getCurrentOperatorKey( | ||
address operator | ||
) public view returns (bytes32) { | ||
uint208 keyIdx = operatorToIdx[operator].latest(); | ||
|
||
if (keyIdx == EMPTY_KEY_IDX) { | ||
return bytes32(0); | ||
} | ||
|
||
return idxToKey[keyIdx]; | ||
} | ||
|
||
function getOperatorKeyAt( | ||
address operator, | ||
uint48 timestamp | ||
) public view returns (bytes32) { | ||
uint208 keyIdx = operatorToIdx[operator].upperLookup(timestamp); | ||
|
||
if (keyIdx == EMPTY_KEY_IDX) { | ||
return bytes32(0); | ||
} | ||
|
||
return idxToKey[keyIdx]; | ||
} | ||
|
||
function updateKey(address operator, bytes32 key) internal { | ||
if (keyToOperator[key] != address(0)) { | ||
revert DuplicateKey(); | ||
} | ||
|
||
uint208 newIdx = ++totalKeys; | ||
idxToKey[newIdx] = key; | ||
operatorToIdx[operator].push(Time.timestamp(), newIdx); | ||
keyToOperator[key] = operator; | ||
} | ||
} |
Oops, something went wrong.