Skip to content

Commit

Permalink
Prepare code for Base Sepolia deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
ginesdt committed Jun 21, 2024
1 parent ca6addc commit 82a7679
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 42 deletions.
22 changes: 7 additions & 15 deletions contracts/streamtide.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ contract MVPCLR is OwnableUpgradeable {

uint256 public roundStart;
uint256 public roundDuration;
uint256 public matchingPool;
uint256 roundId;
uint256 public lastActiveRoundId;


mapping(address => bool) public isAdmin;
Expand All @@ -52,24 +50,24 @@ contract MVPCLR is OwnableUpgradeable {

address public multisigAddress;

function construct(address _multisigAddress) external initializer {
function construct(address _multisigAddress, uint _lastRound) external initializer {
__Ownable_init(); // Add this line to initialize the OwnableUpgradeable contract
multisigAddress = _multisigAddress;
roundId = 0;
lastActiveRoundId = 0;
roundId = _lastRound;
}

function setMultisigAddress(address _multisigAddress) external onlyMultisig {
multisigAddress = _multisigAddress;
}

function fillUpMatchingPool() public payable onlyAdmin {
require(!roundIsClosed(), "Round Closed");
require(msg.value > 0, "MVPCLR:fillUpMatchingPool - No value provided");
emit MatchingPoolDonation(msg.sender, msg.value, roundId);
}

function fillUpMatchingPoolToken(address from, address token, uint amount) public onlyAdmin {
require(!roundIsClosed());
require(!roundIsClosed(), "Round Closed");
require(amount > 0, "MVPCLR:fillUpMatchingPoolToken - No amount provided");

IERC20(token).transferFrom(from, address(this), amount);
Expand All @@ -79,8 +77,7 @@ contract MVPCLR is OwnableUpgradeable {

function closeRound() public onlyAdmin {
roundDuration = 0;
// roundId = 0;
emit RoundClosed(lastActiveRoundId); // Added event emission
emit RoundClosed(roundId); // Added event emission
}

function roundIsClosed() public view returns (bool) {
Expand All @@ -89,14 +86,12 @@ contract MVPCLR is OwnableUpgradeable {

function startRound(uint256 _roundDuration) public payable onlyAdmin {
require(roundIsClosed(), "MVPCLR: startRound - Previous round not yet closed");
lastActiveRoundId += 1;
roundId = lastActiveRoundId;
roundId++;
require(_roundDuration < 31536000, "MVPCLR: round duration too long");
roundDuration = _roundDuration;
roundStart = getBlockTimestamp();
emit RoundStarted(roundStart, roundId, roundDuration);
emit MatchingPoolDonation(msg.sender, msg.value, roundId); // Emit event for the added funds

}

function addAdmin(address _admin) public onlyOwner {
Expand Down Expand Up @@ -151,8 +146,6 @@ contract MVPCLR is OwnableUpgradeable {
}

require(totalAmount <= msg.value, "CLR:donate - Total amount donated is greater than the value sent");
// transfer the donated funds to the contract
// payable(address(this)).transfer(msg.value);
}


Expand All @@ -171,7 +164,6 @@ contract MVPCLR is OwnableUpgradeable {
emit Distribute(patrons[i], amounts[i], roundId, token);
totalAmount += amounts[i]; // Add the amount to totalAmount
}
// matchingPool -= totalAmount; // Subtract the total distributed amount from the matching pool
emit DistributeRound(roundId, totalAmount, token);
}

Expand All @@ -183,7 +175,7 @@ contract MVPCLR is OwnableUpgradeable {

// receive donation for the matching pool
receive() external payable {
require(roundStart == 0 || getBlockTimestamp() < roundStart + roundDuration, "CLR:receive closed");
require(!roundIsClosed(), "Round Closed");
emit MatchingPoolDonation(_msgSender(), msg.value, roundId);
}

Expand Down
2 changes: 1 addition & 1 deletion migrations/2_streamtide_contracts.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module.exports = async(deployer, network, accounts) => {
const streamtideForwarderAddr = status.getValue(sk.streamtideForwarderAddr);

const streamtideForwarder = await Streamtide.at(streamtideForwarderAddr);
await streamtideForwarder.construct(parameters.multiSig);
await streamtideForwarder.construct(parameters.multiSig, parameters.lastRound);
});

var smartContracts = edn.encode(
Expand Down
22 changes: 22 additions & 0 deletions migrations/4_add_patrons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const {readSmartContractsFile, getSmartContractAddress} = require ("./utils.js");
const {smart_contracts_path, env, parameters} = require ('../truffle.js');

const smartContracts = readSmartContractsFile(smart_contracts_path);
const streamtideFwdAddr = getSmartContractAddress(smartContracts, ":streamtide-fwd");

const Streamtide = artifacts.require("MVPCLR");

module.exports = async(deployer, network, accounts) => {
const address = accounts [0];
const gas = 4e6;
const opts = {gas: gas, from: address};

await deployer;

const streamtideFwd = await Streamtide.at(streamtideFwdAddr);

if (Array.isArray(parameters.patrons) && parameters.patrons.length) {
console.log ("Adding patrons: " + parameters.patrons);
await streamtideFwd.addPatrons(parameters.patrons, Object.assign(opts, {gas: 5000000}));
}
}
8 changes: 4 additions & 4 deletions src/streamtide/shared/smart_contracts_dev.cljs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(ns streamtide.shared.smart-contracts-dev)
(def smart-contracts
{:migrations {:name "Migrations" :address "0x641E3c77eC2582999b8f6de0AF9BF1D465Fd4CB2"}
:streamtide {:name "MVPCLR" :address "0xAF61d3cA9f88E472372c76fb04Bc47cc79b4A87A"}
:streamtide-fwd {:name "MutableForwarder" :address "0x0b982d6CfA88Cd81143b1E76671ABDF3a453bc40" :forwards-to :streamtide}})
(def smart-contracts
{:migrations {:name "Migrations" :address "0x29e669154Cb6E916492333c66888614D3871C9f1"}
:streamtide {:name "MVPCLR" :address "0x011F1698Da63C94887DB950d894ea78951e40c03"}
:streamtide-fwd {:name "MutableForwarder" :address "0x00befa8671b2B7ED8fF5CdA9d608C56855DB11AA" :forwards-to :streamtide}})
6 changes: 3 additions & 3 deletions src/streamtide/shared/smart_contracts_qa.cljs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(ns streamtide.shared.smart-contracts-qa)
(def smart-contracts
{:migrations {:name "Migrations" :address "0x3616f333628b61CEbfddCfbe001A90c4C8feEF02"}
:streamtide {:name "MVPCLR" :address "0x3b038Bb1fdB38CF7CC19c7917D6979A1f5454897"}
:streamtide-fwd {:name "MutableForwarder" :address "0x26561312D23e9AfF9FbB6387D8911729705C56e3" :forwards-to :streamtide}})
{:migrations {:name "Migrations" :address "0xb2B33a219a48324C3BC47aD141FE164D7F3F4535"}
:streamtide {:name "MVPCLR" :address "0x25f9C724ebFBDab03be68B317F4ef18508Ea661a"}
:streamtide-fwd {:name "MutableForwarder" :address "0x2D1A3e2CAec7402eBCE45c787D878F70cB504802" :forwards-to :streamtide}})
16 changes: 8 additions & 8 deletions src/streamtide/ui/config.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
:graphql {:url "https://api.streamtide.qa.district0x.io/graphql"}
:smart-contracts {:contracts smart-contracts-qa/smart-contracts}
:verifiers {:discord {:client-id "1135876901093781544"}}
:web3-chain {:chain-id "421614"
:rpc-urls ["https://sepolia-rollup.arbitrum.io/rpc"]
:chain-name "Arbitrum Sepolia"
:web3-chain {:chain-id "84532"
:rpc-urls ["https://sepolia.base.org"]
:chain-name "Base Sepolia"
:native-currency {:name "ETH"
:symbol "ETH"
:decimals 18}
:block-explorer-urls ["https://sepolia.arbiscan.io/"]}
:block-explorer-urls ["https://sepolia-explorer.base.org"]}
:notifiers {:web-push {:public-key "BGtkUrXx0vlsFpfmf8rDNqswKAlrSUQUE8xN4Jf6F3rtQCpbdR-vakwnUnhnVWYl1kdfUXzjfNini19ZyGVtaMM"}}
:thirdweb {:client-id "f478f4123340f16303e57df57b6e26ef"}
})
Expand All @@ -47,13 +47,13 @@
:graphql {:url "https://api.streamtide.io/graphql"}
:smart-contracts {:contracts smart-contracts-prod/smart-contracts}
:verifiers {:discord {:client-id "1135876901093781544"}}
:web3-chain {:chain-id "42161"
:rpc-urls ["https://arb1.arbitrum.io/rpc"]
:chain-name "Arbitrum One"
:web3-chain {:chain-id "8453"
:rpc-urls ["https://mainnet.base.org"]
:chain-name "Base Mainnet"
:native-currency {:name "ETH"
:symbol "ETH"
:decimals 18}
:block-explorer-urls ["https://explorer.arbitrum.io"]}
:block-explorer-urls ["https://base.blockscout.com"]}
:notifiers {:web-push {:public-key "BGtkUrXx0vlsFpfmf8rDNqswKAlrSUQUE8xN4Jf6F3rtQCpbdR-vakwnUnhnVWYl1kdfUXzjfNini19ZyGVtaMM"}}
:thirdweb {:client-id "f478f4123340f16303e57df57b6e26ef"}
})
Expand Down
31 changes: 20 additions & 11 deletions truffle.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,33 @@ const smartContractsPaths = {

let parameters = {
"dev" : {
multiSig: "0x4c3F13898913F15F12F902d6480178484063A6Fb",
admins: ["0xaFcF1a2bc71AcF041c93012A2E552e31026dFEAB"]
multiSig: "0x694D22629793B210e0C90324b4F9e571A25BD633",
admins: ["0x694D22629793B210e0C90324b4F9e571A25BD633"],
lastRound: 15,
patrons: [
"0xFB55734bACBca7d943994cA51c8049e0577A5c7f",
"0x694D22629793B210e0C90324b4F9e571A25BD633",
"0x11b23AE13EBACc03Fa0af256fdED729439A45ab5"]
},
"qa" : {
multiSig: "0x11b23AE13EBACc03Fa0af256fdED729439A45ab5",
admins: [
"0x11b23AE13EBACc03Fa0af256fdED729439A45ab5",
"0xb078844477A5420cB627C1961B30ED33E0126973",
"0x0A0A8610F57fE41EC26D5163d1Eb986cE598dc5F",
"0x0940f7D6E7ad832e0085533DD2a114b424d5E83A"]
"0x0940f7D6E7ad832e0085533DD2a114b424d5E83A",
"0xF256222EB43fdB2CFAD1f8Be72575F6b01Dae295"
],
lastRound: 6
},
"prod" : {
multiSig: "0xf7190fa8c89F7c57ff77b8Bc0Da85e9a2daF70Ad",
admins: [
"0xf7190fa8c89F7c57ff77b8Bc0Da85e9a2daF70Ad",
"0xb078844477A5420cB627C1961B30ED33E0126973",
"0x0A0A8610F57fE41EC26D5163d1Eb986cE598dc5F",
"0x0940f7D6E7ad832e0085533DD2a114b424d5E83A"]
"0x0940f7D6E7ad832e0085533DD2a114b424d5E83A"],
lastRound: 0
}
};

Expand All @@ -40,22 +49,22 @@ module.exports = {
parameters : parameters [STREAMTIDE_ENV],
networks: {
"ganache": {
host: 'localhost',
host: '127.0.0.1',
port: 8545,
gas: 6e6, // gas limit
gasPrice: 20e9, // 20 gwei, default for ganache
network_id: '*'
},
"alchemy-arbitrum-sepolia": {
provider: () => new HDWalletProvider(process.env.ARBITRUM_SEPOLIA_PRIV_KEY, "https://arb-sepolia.g.alchemy.com/v2/" + process.env.ALCHEMY_API_KEY),
network_id: 421614,
"alchemy-base-sepolia": {
provider: () => new HDWalletProvider(process.env.BASE_SEPOLIA_PRIV_KEY, "https://base-sepolia.g.alchemy.com/v2/" + process.env.ALCHEMY_API_KEY),
network_id: 84532,
gas: 6e6,
gasPrice: 1e9,
skipDryRun: true
},
"alchemy-arbitrum-mainnet": {
provider: () => new HDWalletProvider(process.env.ARBITRUM_PRIV_KEY, "https://arb-mainnet.g.alchemy.com/v2/" + process.env.ALCHEMY_API_KEY),
network_id: 42161,
"alchemy-base-mainnet": {
provider: () => new HDWalletProvider(process.env.BASE_PRIV_KEY, "https://base-mainnet.g.alchemy.com/v2/" + process.env.ALCHEMY_API_KEY),
network_id: 8453,
gas: 6e7,
gasPrice: 3e8,
skipDryRun: true
Expand Down

0 comments on commit 82a7679

Please sign in to comment.