-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into zero-shares
- Loading branch information
Showing
55 changed files
with
742 additions
and
323 deletions.
There are no files selected for viewing
Binary file removed
BIN
-42.5 KB
.yarn/cache/@synthetixio-router-npm-3.3.7-fd9738c2d3-f79d119b24.zip
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+14.1 MB
...lder-npm-2.13.6-3a1c3b690c-6fdff249d7.zip → ...lder-npm-2.15.2-1c8a995821-86716e885f.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+10.9 KB
...ects-npm-1.15.5-9d14db76ca-d467f13c1c.zip → ...ects-npm-1.15.6-50635fe51d-70c7612c4c.zip
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+58.1 KB
...nnon-npm-2.13.6-2321a8e35b-b671b0ad16.zip → ...nnon-npm-2.15.2-89689ac509-c52d4dd971.zip
Binary file not shown.
Binary file renamed
BIN
+9.59 KB
...isows-npm-1.0.3-aa8c925c69-9cacd5cf59.zip → ...isows-npm-1.0.4-84b48fd8ef-a3ee62e3d6.zip
Binary file not shown.
Binary file renamed
BIN
+82.3 KB
...table-npm-6.8.1-83abb79e20-512c4f2bfb.zip → ...table-npm-6.8.2-e33ecc3c54-2946162eb8.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-57.7 KB
.yarn/cache/typedoc-plugin-markdown-npm-3.17.1-091f1bd18a-21bfe7fba6.zip
Binary file not shown.
Binary file renamed
BIN
+4.16 MB
...viem-npm-2.9.27-886876d71c-e4a1a16226.zip → ...viem-npm-2.14.0-d5c1129d7a-04132cf4bc.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
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
30 changes: 30 additions & 0 deletions
30
markets/bfp-market/contracts/interfaces/ISplitAccountConfigurationModule.sol
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,30 @@ | ||
//SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.11 <0.9.0; | ||
|
||
import {SettlementHookConfiguration} from "../storage/SettlementHookConfiguration.sol"; | ||
|
||
interface ISplitAccountConfigurationModule { | ||
// --- Events --- // | ||
|
||
/// @notice Emitted when split account whitelist is configured. | ||
/// @param from Address of configurer | ||
/// @param hooks Number of addresses configured | ||
event SplitAccountConfigured(address indexed from, uint256 hooks); | ||
|
||
// --- Mutations --- // | ||
|
||
/// @notice Configures a list of addresses to be whitelisted for splitAccount. | ||
/// @param addresses An array of addresses to whitelist | ||
function setEndorsedSplitAccounts(address[] memory addresses) external; | ||
|
||
// --- Views --- // | ||
|
||
/// @notice Returns addresses allowed to split account. | ||
/// @return addresses list of addresses | ||
function getEndorsedSplitAccounts() external view returns (address[] memory addresses); | ||
|
||
/// @notice Returns whether the specified hook is whitelisted. | ||
/// @param addr Address of hook to assert | ||
/// @return isEndoresedForSplitAccount True if whitelisted, false otherwise | ||
function isEndorsedForSplitAccount(address addr) external view returns (bool); | ||
} |
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
66 changes: 66 additions & 0 deletions
66
markets/bfp-market/contracts/modules/SplitAccountConfigurationModule.sol
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,66 @@ | ||
//SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.11 <0.9.0; | ||
|
||
import {IERC165} from "@synthetixio/core-contracts/contracts/interfaces/IERC165.sol"; | ||
import {OwnableStorage} from "@synthetixio/core-contracts/contracts/ownership/OwnableStorage.sol"; | ||
import {ERC165Helper} from "@synthetixio/core-contracts/contracts/utils/ERC165Helper.sol"; | ||
import {ERC2771Context} from "@synthetixio/core-contracts/contracts/utils/ERC2771Context.sol"; | ||
import {ISplitAccountConfigurationModule} from "../interfaces/ISplitAccountConfigurationModule.sol"; | ||
import {SplitAccountConfiguration} from "../storage/SplitAccountConfiguration.sol"; | ||
import {ErrorUtil} from "../utils/ErrorUtil.sol"; | ||
|
||
contract SplitAccountConfigurationModule is ISplitAccountConfigurationModule { | ||
// --- Mutations --- // | ||
|
||
/** | ||
* @inheritdoc ISplitAccountConfigurationModule | ||
*/ | ||
function setEndorsedSplitAccounts(address[] memory addresses) external { | ||
OwnableStorage.onlyOwner(); | ||
|
||
SplitAccountConfiguration.GlobalData storage config = SplitAccountConfiguration.load(); | ||
uint256 existingAddresses = config.whitelistedAddresses.length; | ||
for (uint256 i = 0; i < existingAddresses; ) { | ||
delete config.whitelisted[config.whitelistedAddresses[i]]; | ||
unchecked { | ||
++i; | ||
} | ||
} | ||
delete config.whitelistedAddresses; | ||
|
||
uint256 addressesLength = addresses.length; | ||
address currentAddress; | ||
for (uint256 i = 0; i < addressesLength; ) { | ||
currentAddress = addresses[i]; | ||
if (currentAddress == address(0)) { | ||
revert ErrorUtil.ZeroAddress(); | ||
} | ||
|
||
config.whitelisted[currentAddress] = true; | ||
unchecked { | ||
++i; | ||
} | ||
} | ||
config.whitelistedAddresses = addresses; | ||
|
||
emit SplitAccountConfigured(ERC2771Context._msgSender(), addressesLength); | ||
} | ||
|
||
// --- Views --- // | ||
|
||
/** | ||
* @inheritdoc ISplitAccountConfigurationModule | ||
*/ | ||
function getEndorsedSplitAccounts() external view returns (address[] memory addresses) { | ||
SplitAccountConfiguration.GlobalData storage config = SplitAccountConfiguration.load(); | ||
return config.whitelistedAddresses; | ||
} | ||
|
||
/** | ||
* @inheritdoc ISplitAccountConfigurationModule | ||
*/ | ||
function isEndorsedForSplitAccount(address addr) external view returns (bool) { | ||
SplitAccountConfiguration.GlobalData storage config = SplitAccountConfiguration.load(); | ||
return config.whitelisted[addr]; | ||
} | ||
} |
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
25 changes: 25 additions & 0 deletions
25
markets/bfp-market/contracts/storage/SplitAccountConfiguration.sol
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,25 @@ | ||
//SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.11 <0.9.0; | ||
|
||
library SplitAccountConfiguration { | ||
// --- Constants --- // | ||
|
||
bytes32 private constant GLOBAL_DATA_SLOT_NAME = | ||
keccak256(abi.encode("io.synthetix.bfp-market.SplitAccountConfiguration")); | ||
|
||
// --- Storage --- // | ||
|
||
struct GlobalData { | ||
/// {address => isEnabled}. | ||
mapping(address => bool) whitelisted; | ||
/// Array of whitelisted addresses (use whitelisted mapping). | ||
address[] whitelistedAddresses; | ||
} | ||
|
||
function load() internal pure returns (SplitAccountConfiguration.GlobalData storage d) { | ||
bytes32 s = GLOBAL_DATA_SLOT_NAME; | ||
assembly { | ||
d.slot := s | ||
} | ||
} | ||
} |
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
Oops, something went wrong.