Skip to content
This repository has been archived by the owner on Oct 6, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' into indexfund-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
SovereignAndrey authored Jul 28, 2023
2 parents 173bd0c + 746ff55 commit 19ad89d
Show file tree
Hide file tree
Showing 29 changed files with 595 additions and 297 deletions.
2 changes: 1 addition & 1 deletion compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -x;
# Shuttle `tasks/index.ts` file to temp file before cleaning/compiling starts
mv -n ./tasks/index.ts ./tasks/temp_index.ts && touch ./tasks/index.ts;
# Clean and compile all contracts.
hardhat clean && hardhat compile;
hardhat compile;
# Shuttle `tasks/index.ts` file from temp file to orig location after cleaning/compiling ends
# Run regardless of above line's failure or sucesss
mv ./tasks/temp_index.ts ./tasks/index.ts;
Expand Down
14 changes: 1 addition & 13 deletions contract-address.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,6 @@
"implementation": "",
"proxy": ""
},
"libraries": {
"angelCoreStruct": "",
"stringArray": ""
},
"multiSig": {
"charityApplications": {
"implementation": "",
Expand Down Expand Up @@ -261,10 +257,6 @@
"implementation": "0x59c7E6B2c565Ff92B762523BD6B778CE66dC0302",
"proxy": "0x9A676e781A523b5d0C0e43731313A708CB607508"
},
"libraries": {
"angelCoreStruct": "",
"stringArray": ""
},
"multiSig": {
"charityApplications": {
"implementation": "0x9687796759CAbecC1674A4Aaf23889fC9EC2FCA2",
Expand Down Expand Up @@ -418,10 +410,6 @@
"implementation": "0x73cF9763985f5617AaF635A8707d89E3B697e112",
"proxy": "0xf6B32b4a0371050321fC01672FDfad76aF55603f"
},
"libraries": {
"angelCoreStruct": "",
"stringArray": ""
},
"multiSig": {
"charityApplications": {
"implementation": "0xA89d149De8F8785c2a6c7ea99B6cC3De5A4c29Af",
Expand All @@ -433,7 +421,7 @@
},
"endowment": {
"emitter": {
"implementation": "0xf1bBE8aCdd30E2998D1Db8eEaACE95E86DFE7a0a",
"implementation": "0x366478C1e2895017FaCb12Ea682CfcBF85720BAC",
"proxy": "0x8a87385765871bD85d96B7675A3F1Fb663146E4d"
},
"factory": "0xc4150f28a33a04B79B60560Bd4684d521edB99AE",
Expand Down
3 changes: 2 additions & 1 deletion contracts/accessory/gift-cards/GiftCards.sol
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ contract GiftCards is Storage, Initializable, OwnableUpgradeable, ReentrancyGuar
AccountMessages.DepositRequest({
id: endowmentId,
lockedPercentage: lockedPercentage,
liquidPercentage: liquidPercentage
liquidPercentage: liquidPercentage,
donationMatch: msg.sender
}),
tokenAddress,
amount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ contract AccountsDepositWithdrawEndowments is
uint256 liquidSplitPercent = details.liquidPercentage;

require(registrar_config.indexFundContract != address(0), "No Index Fund");

if (msg.sender != registrar_config.indexFundContract) {
if (tempEndowment.endowType == LibAccounts.EndowmentType.Charity) {
// use the Registrar default split for Charities
Expand All @@ -139,27 +138,28 @@ contract AccountsDepositWithdrawEndowments is
uint256 lockedAmount = (amount.mul(lockedSplitPercent)).div(LibAccounts.PERCENT_BASIS);
uint256 liquidAmount = (amount.mul(liquidSplitPercent)).div(LibAccounts.PERCENT_BASIS);

//donation matching flow
//execute donor match will always be called on an EOA
// donation matching flow
if (lockedAmount > 0) {
address donationMatch = details.donationMatch;
if (donationMatch == address(0)) {
donationMatch = msg.sender;
}

if (
tempEndowment.endowType == LibAccounts.EndowmentType.Charity &&
registrar_config.donationMatchCharitesContract != address(0)
) {
IDonationMatching(registrar_config.donationMatchCharitesContract).executeDonorMatch(
details.id,
lockedAmount,
tx.origin,
donationMatch,
registrar_config.haloToken
);
} else if (
tempEndowment.endowType == LibAccounts.EndowmentType.Normal &&
tempEndowment.donationMatchContract != address(0)
) {
} else if (tempEndowment.donationMatchContract != address(0)) {
IDonationMatching(tempEndowment.donationMatchContract).executeDonorMatch(
details.id,
lockedAmount,
tx.origin,
donationMatch,
tempEndowment.daoToken
);
}
Expand Down Expand Up @@ -330,7 +330,8 @@ contract AccountsDepositWithdrawEndowments is
AccountMessages.DepositRequest({
id: beneficiaryEndowId,
lockedPercentage: 0,
liquidPercentage: 100
liquidPercentage: 100,
donationMatch: address(this) // all liquid so won't trigger a match
}),
tokens[t].addr,
(amountLeftover - withdrawFeeEndow)
Expand Down
1 change: 1 addition & 0 deletions contracts/core/accounts/message.sol
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ library AccountMessages {
uint32 id;
uint256 lockedPercentage;
uint256 liquidPercentage;
address donationMatch;
}

struct InvestRequest {
Expand Down
3 changes: 2 additions & 1 deletion contracts/multisigs/CharityApplications.sol
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ contract CharityApplications is MultiSigGeneric, StorageApplications, ICharityAp
AccountMessages.DepositRequest({
id: endowmentId,
lockedPercentage: 100 - config.seedSplitToLiquid,
liquidPercentage: config.seedSplitToLiquid
liquidPercentage: config.seedSplitToLiquid,
donationMatch: address(this)
}),
config.seedAsset,
config.seedAmount
Expand Down
4 changes: 0 additions & 4 deletions eth-sdk/eth-sdk.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ export default defineConfig({
implementation: parseAddress(mumbaiData.indexFund.implementation),
proxy: parseAddress(mumbaiData.indexFund.proxy),
},
libraries: {
angelCoreStruct: parseAddress(mumbaiData.libraries.angelCoreStruct),
stringArray: parseAddress(mumbaiData.libraries.stringArray),
},
multiSig: {
apTeam: {
implementation: parseAddress(mumbaiData.multiSig.apTeam.implementation),
Expand Down
11 changes: 4 additions & 7 deletions tasks/deploy/deployAccountsDiamond.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {deployAccountsDiamond} from "contracts/core/accounts/scripts/deploy";
import {task} from "hardhat/config";
import {confirmAction, getAddresses, isLocalNetwork, logger, verify} from "utils";
import {updateRegistrarConfig} from "../helpers";

type TaskArgs = {
apTeamMultisig?: string;
Expand Down Expand Up @@ -38,12 +37,10 @@ task("AccountsDiamond", "It will deploy accounts diamond contracts")
return;
}

await updateRegistrarConfig(
registrar,
apTeam,
{accountsContract: deployData.diamond.address},
hre
);
await hre.run("manage:registrar:updateConfig", {
accountsContract: deployData.diamond.address,
yes: true,
});
await hre.run("manage:CharityApplications:updateConfig", {
accountsDiamond: deployData.diamond.address,
yes: true,
Expand Down
48 changes: 20 additions & 28 deletions tasks/deploy/deployAngelProtocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ import {deployEndowmentMultiSig} from "contracts/normalized_endowment/endowment-
// import {deployImplementation} from "contracts/normalized_endowment/scripts/deployImplementation";

import {deployGasFwd} from "contracts/core/gasFwd/scripts/deploy";
import {
getOrDeployThirdPartyContracts,
updateRegistrarConfig,
updateRegistrarNetworkConnections,
} from "../helpers";
import {getOrDeployThirdPartyContracts, updateRegistrarNetworkConnections} from "../helpers";

task("deploy:AngelProtocol", "Will deploy complete Angel Protocol")
.addFlag("skipVerify", "Skip contract verification")
Expand Down Expand Up @@ -97,29 +93,25 @@ task("deploy:AngelProtocol", "Will deploy complete Angel Protocol")

const endowmentMultiSig = await deployEndowmentMultiSig(hre);

await updateRegistrarConfig(
registrar?.address,
apTeamMultisig?.address,
{
accountsContract: accounts?.diamond.address, //Address
splitMax: config.REGISTRAR_DATA.splitToLiquid.max, //uint256
splitMin: config.REGISTRAR_DATA.splitToLiquid.min, //uint256
splitDefault: config.REGISTRAR_DATA.splitToLiquid.defaultSplit, //uint256
collectorShare: config.REGISTRAR_UPDATE_CONFIG.collectorShare, //uint256
indexFundContract: indexFund?.address, //address
treasury: treasury.address,
uniswapRouter: thirdPartyAddresses.uniswap.swapRouter.address, //address
uniswapFactory: thirdPartyAddresses.uniswap.factory.address, //address
multisigFactory: endowmentMultiSig?.factory.address, //address
multisigEmitter: endowmentMultiSig?.emitter.address, //address
charityApplications: charityApplications?.address, //address
proxyAdmin: proxyAdmin.address, //address
usdcAddress: thirdPartyAddresses.usdcToken.address,
wMaticAddress: thirdPartyAddresses.wmaticToken.address,
gasFwdFactory: gasFwd?.factory.address,
},
hre
);
await hre.run("manage:registrar:updateConfig", {
accountsContract: accounts?.diamond.address, //Address
splitMax: config.REGISTRAR_DATA.splitToLiquid.max, //uint256
splitMin: config.REGISTRAR_DATA.splitToLiquid.min, //uint256
splitDefault: config.REGISTRAR_DATA.splitToLiquid.defaultSplit, //uint256
collectorShare: config.REGISTRAR_UPDATE_CONFIG.collectorShare, //uint256
indexFundContract: indexFund?.address, //address
treasury: treasury.address,
uniswapRouter: thirdPartyAddresses.uniswap.swapRouter.address, //address
uniswapFactory: thirdPartyAddresses.uniswap.factory.address, //address
multisigFactory: endowmentMultiSig?.factory.address, //address
multisigEmitter: endowmentMultiSig?.emitter.address, //address
charityApplications: charityApplications?.address, //address
proxyAdmin: proxyAdmin.address, //address
usdcAddress: thirdPartyAddresses.usdcToken.address,
wMaticAddress: thirdPartyAddresses.wmaticToken.address,
gasFwdFactory: gasFwd?.factory.address,
yes: true,
});

// Registrar NetworkInfo's Router address must be updated for the current network
if (router) {
Expand Down
23 changes: 4 additions & 19 deletions tasks/deploy/deployCharityApplications.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import {deployCharityApplications} from "contracts/multisigs/scripts/deployCharityApplications";
import {task} from "hardhat/config";
import {confirmAction, getAddresses, isLocalNetwork, logger, verify} from "utils";
import {updateRegistrarConfig} from "../helpers";

type TaskArgs = {
accountsDiamond?: string;
apTeamMultisig?: string;
charityApplications?: string;
registrar?: string;
skipVerify: boolean;
yes: boolean;
};
Expand All @@ -17,14 +14,6 @@ task("deploy:CharityApplications", "Will deploy CharityApplication contract")
"accountsDiamond",
"Accounts Diamond contract address. Will do a local lookup from contract-address.json if none is provided."
)
.addOptionalParam(
"apTeamMultisig",
"APTeamMultiSig contract address. Will do a local lookup from contract-address.json if none is provided."
)
.addOptionalParam(
"registrar",
"Registrar contract address. Will do a local lookup from contract-address.json if none is provided."
)
.addFlag("skipVerify", "Skip contract verification")
.addFlag("yes", "Automatic yes to prompt.")
.setAction(async (taskArgs: TaskArgs, hre) => {
Expand All @@ -37,8 +26,6 @@ task("deploy:CharityApplications", "Will deploy CharityApplication contract")
const addresses = await getAddresses(hre);

const accountsDiamond = taskArgs.accountsDiamond || addresses.accounts.diamond;
const apTeamMultiSig = taskArgs.apTeamMultisig || addresses.multiSig.apTeam.proxy;
const registrar = taskArgs.registrar || addresses.registrar.proxy;

const charityApplications = await deployCharityApplications(
accountsDiamond,
Expand All @@ -50,12 +37,10 @@ task("deploy:CharityApplications", "Will deploy CharityApplication contract")
return;
}

await updateRegistrarConfig(
registrar,
apTeamMultiSig,
{charityApplications: charityApplications.address},
hre
);
await hre.run("manage:registrar:updateConfig", {
charityApplications: charityApplications.address,
yes: true,
});

if (!isLocalNetwork(hre) && !taskArgs.skipVerify) {
await verify(hre, charityApplications);
Expand Down
32 changes: 6 additions & 26 deletions tasks/deploy/deployEndowmentMultisig.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
import {deployEndowmentMultiSig} from "contracts/normalized_endowment/endowment-multisig/scripts/deploy";
import {task} from "hardhat/config";
import {confirmAction, getAddresses, isLocalNetwork, logger, verify} from "utils";
import {updateRegistrarConfig} from "../helpers";
import {confirmAction, isLocalNetwork, logger, verify} from "utils";

type TaskArgs = {
apTeamMultisig?: string;
registrar?: string;
skipVerify: boolean;
yes: boolean;
};

task("deploy:EndowmentMultiSig", "Will deploy EndowmentMultiSig contract")
.addOptionalParam(
"apTeamMultisig",
"APTeamMultiSig contract address. Will do a local lookup from contract-address.json if none is provided."
)
.addOptionalParam(
"registrar",
"Registrar contract address. Will do a local lookup from contract-address.json if none is provided."
)
.addFlag("skipVerify", "Skip contract verification")
.addFlag("yes", "Automatic yes to prompt.")
.setAction(async (taskArgs: TaskArgs, hre) => {
Expand All @@ -28,26 +17,17 @@ task("deploy:EndowmentMultiSig", "Will deploy EndowmentMultiSig contract")
return logger.out("Confirmation denied.", logger.Level.Warn);
}

const addresses = await getAddresses(hre);

const apTeamMultiSig = taskArgs.apTeamMultisig || addresses.multiSig.apTeam.proxy;
const registrar = taskArgs.registrar || addresses.registrar.proxy;

const deployData = await deployEndowmentMultiSig(hre);

if (!deployData) {
return;
}

await updateRegistrarConfig(
registrar,
apTeamMultiSig,
{
multisigFactory: deployData.factory.address,
multisigEmitter: deployData.emitter.address,
},
hre
);
await hre.run("manage:registrar:updateConfig", {
multisigFactory: deployData.factory.address,
multisigEmitter: deployData.emitter.address,
yes: true,
});

if (!isLocalNetwork(hre) && !taskArgs.skipVerify) {
await verify(hre, deployData.emitter);
Expand Down
13 changes: 5 additions & 8 deletions tasks/deploy/deployGasFwd.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {deployGasFwd} from "contracts/core/gasFwd/scripts/deploy";
import {task} from "hardhat/config";
import {updateRegistrarConfig} from "tasks/helpers";
import {getSigners, getAddresses, isLocalNetwork, logger, verify} from "utils";
import {getAddresses, getSigners, isLocalNetwork, logger, verify} from "utils";

type TaskArgs = {
skipVerify: boolean;
Expand All @@ -23,12 +22,10 @@ task("deploy:GasFwd", "Will deploy the GasFwd implementation and factory")
return;
}

await updateRegistrarConfig(
addresses.registrar.proxy,
addresses.multiSig.apTeam.proxy,
{gasFwdFactory: gasFwdDeployment.factory.address},
hre
);
await hre.run("manage:registrar:updateConfig", {
gasFwdFactory: gasFwdDeployment.factory.address,
yes: true,
});

if (!isLocalNetwork(hre) && !taskArgs.skipVerify) {
await verify(hre, gasFwdDeployment.implementation);
Expand Down
Loading

0 comments on commit 19ad89d

Please sign in to comment.