Skip to content

Commit

Permalink
Merge pull request #153 from sarcophagus-org/update-cursed-fee-bond
Browse files Browse the repository at this point in the history
free curse fee bond during unwrap instead of first rewrap
  • Loading branch information
sethhrbek authored Nov 21, 2023
2 parents 7c82d52 + 849b639 commit e92eded
Show file tree
Hide file tree
Showing 54 changed files with 3,287 additions and 2,864 deletions.
11 changes: 3 additions & 8 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,18 @@ MAINNET_DEPLOYER_PRIVATE_KEY=
POLYGON_PROVIDER=
POLYGON_DEPLOYER_PRIVATE_KEY=

BASE_PROVIDER=
BASE_DEPLOYER_PRIVATE_KEY=

BASE_GOERLI_PROVIDER=
BASE_GOERLI_DEPLOYER_PRIVATE_KEY=

POLYGON_MUMBAI_PROVIDER=
POLYGON_MUMBAI_DEPLOYER_PRIVATE_KEY=

GOERLI_PROVIDER=
GOERLI_DEPLOYER_PRIVATE_KEY=
ARBITRUM_PROVIDER=
ARBITRUM_DEPLOYER_PRIVATE_KEY=

SEPOLIA_PROVIDER=
SEPOLIA_DEPLOYER_PRIVATE_KEY=

ETHERSCAN_API_KEY=
POLYGONSCAN_API_KEY=
BASESCAN_API_KEY=
ARBISCAN_API_KEY=

REPORT_GAS=true
19 changes: 16 additions & 3 deletions contracts/facets/AdminFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ contract AdminFacet {
error CannotSetZeroValue();

/// @notice Caller must be the admin address
error CallerIsNotAdmin();
error CallerIsNotAdminOrOwner();

/// @notice Provided address cannot be zero address
error ZeroAddress();

/// @notice Modifier to enforce caller is admin or contract owner
modifier onlyAdmin {
AppStorage storage s = LibAppStorage.getAppStorage();
if (msg.sender != s.admin) {
revert CallerIsNotAdmin();
if (msg.sender != s.admin && msg.sender != LibDiamond.contractOwner()) {
revert CallerIsNotAdminOrOwner();
}
_;
}
Expand Down Expand Up @@ -105,4 +106,16 @@ contract AdminFacet {
s.admin = newAdmin;
emit AdminTransferred(msg.sender, newAdmin);
}

/// @notice Transfers diamond owner to new owner.
/// @param newOwner to set
function transferDiamondOwner(address newOwner) external {
LibDiamond.enforceIsContractOwner();
LibDiamond.setContractOwner(newOwner);
}

/// @notice Returns current owner of Diamond contract.
function getDiamondOwner() external view returns (address) {
return LibDiamond.contractOwner();
}
}
4 changes: 0 additions & 4 deletions contracts/facets/EmbalmerFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -439,10 +439,6 @@ contract EmbalmerFacet {
if (!sarcophagus.isRewrapped) {
// Pay archaeologists the curse fee to their rewards
s.archaeologistRewards[archaeologistAddresses[i]] += cursedArchaeologist.curseFee;

// Unlock the curseFee cursed bond by debiting the cursed bond and crediting free bond
s.archaeologistProfiles[archaeologistAddresses[i]].cursedBond -= ((cursedArchaeologist.curseFee * cursedBondPercentage) / 10000);
s.archaeologistProfiles[archaeologistAddresses[i]].freeBond += ((cursedArchaeologist.curseFee * cursedBondPercentage) / 10000);
}
}
unchecked {
Expand Down
11 changes: 6 additions & 5 deletions contracts/libraries/LibBonds.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,17 @@ library LibBonds {
uint256 diggingFeeAmount = cursedArchaeologist.diggingFeePerSecond *
(sarcophagus.resurrectionTime - sarcophagus.previousRewrapTime);

// Include curse fee in bond amount being released
uint256 cursedBondAmount = ((diggingFeeAmount + cursedArchaeologist.curseFee) * sarcophagus.cursedBondPercentage) / 10000;

s.archaeologistProfiles[archaeologistAddress].cursedBond -= cursedBondAmount;
s.archaeologistProfiles[archaeologistAddress].freeBond += cursedBondAmount;

// If sarcophagus has not be been rewrapped yet, pay out the curseFee
if (!sarcophagus.isRewrapped) {
diggingFeeAmount += cursedArchaeologist.curseFee;
}

uint256 cursedBondAmount = (diggingFeeAmount * sarcophagus.cursedBondPercentage) / 10000;

s.archaeologistProfiles[archaeologistAddress].cursedBond -= cursedBondAmount;
s.archaeologistProfiles[archaeologistAddress].freeBond += cursedBondAmount;

s.archaeologistRewards[archaeologistAddress] += diggingFeeAmount;
}
}
1 change: 0 additions & 1 deletion contracts/storage/LibAppStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import "../libraries/LibTypes.sol";

/**
* Global diamond storage struct to be shared across facets
* TODO: Implement diamond storage pattern and consider splitting storage into facet specific structs
*/
struct AppStorage {
// SARCO token contract
Expand Down
14 changes: 5 additions & 9 deletions deploy/001_sarcophagus_facets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

// DAO agent address is the deployer for all networks except mainnet
// In which case it is the Sarcophagus Aragon Agent
let daoAgentAddress = deployer;
const daoAgentAddress = deployer;

// Get the address of the SarcoToken contract
if (
Expand All @@ -23,23 +23,18 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
log: true,
});
sarcoTokenAddress = sarcoTokenMock.address;
} else if (["goerli", "goerli-fork"].includes(hre.hardhatArguments.network)) {
sarcoTokenAddress = "0x4633b43990b41B57b3678c6F3Ac35bA75C3D8436";
} else if (["sepolia"].includes(hre.hardhatArguments.network)) {
sarcoTokenAddress = "0xfa1FA4d51FB2babf59e402c83327Ab5087441289";
} else if (
["mainnet", "mainnet-fork"].includes(hre.hardhatArguments.network)
) {
sarcoTokenAddress = "0x7697b462a7c4ff5f8b55bdbc2f4076c2af9cf51a";

// Mainnet DAO Agent Address
daoAgentAddress = "0x2627e4c6beecbcb7ba0a5bb9861ec870dc86eb59";
} else if (["polygonMumbai"].includes(hre.hardhatArguments.network)) {
sarcoTokenAddress = "0x2BC9019e6d9e6a26D7D8d8CDDa4e5dE9B787D7bb";
} else if (["polygon"].includes(hre.hardhatArguments.network)) {
sarcoTokenAddress = "0x80Ae3B3847E4e8Bd27A389f7686486CAC9C3f3e8";
} else if (["baseGoerli"].includes(hre.hardhatArguments.network)) {
sarcoTokenAddress = "0x2BC9019e6d9e6a26D7D8d8CDDa4e5dE9B787D7bb";
} else if (["arbitrum"].includes(hre.hardhatArguments.network)) {
sarcoTokenAddress = "0x82155Ab6b6c1113CFb352c7573B010a88f5974bD";
} else {
throw Error(
`Sarcophagus is not set up for this network: ${hre.hardhatArguments.network}`
Expand All @@ -63,14 +58,15 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

await diamond.deploy("Sarcophagus_V2", {
from: deployer,
owner: daoAgentAddress,
owner: deployer,
facets: [
"EmbalmerFacet",
"ArchaeologistFacet",
"ThirdPartyFacet",
"ViewStateFacet",
"AdminFacet",
],
// Comment out if upgrading
execute: {
contract: "AppStorageInit",
methodName: "init",
Expand Down
1 change: 1 addition & 0 deletions deployments/arbitrum/.chainId
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
42161
Loading

0 comments on commit e92eded

Please sign in to comment.