Skip to content

Commit

Permalink
prepare migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
FedokDL committed Dec 16, 2024
1 parent 8218533 commit 2685c4a
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 3 deletions.
7 changes: 5 additions & 2 deletions smart-contracts/deploy/2_change_bid_price.migration.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { Deployer } from '@solarity/hardhat-migrate';

import { parseConfig } from './helpers/config-parser';

import { Marketplace__factory } from '@/generated-types/ethers';

module.exports = async function (deployer: Deployer) {
// const marketplaceFacet = await deployer.deployed(Marketplace__factory, '0xb8C55cD613af947E73E262F0d3C54b7211Af16CF');
const marketplaceFacet = await deployer.deployed(Marketplace__factory, '0xDE819AaEE474626E3f34Ef0263373357e5a6C71b');
const config = parseConfig();

const marketplaceFacet = await deployer.deployed(Marketplace__factory, config.lumerinProtocol);

console.log(await marketplaceFacet.getMinMaxBidPricePerSecond());

Expand Down
39 changes: 39 additions & 0 deletions smart-contracts/deploy/3_delegate_protocol.migration copy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Deployer } from '@solarity/hardhat-migrate';

import { parseConfig } from './helpers/config-parser';

import {
DelegatorFactory__factory,
ERC1967Proxy__factory,
ProvidersDelegator__factory,
} from '@/generated-types/ethers';
import { wei } from '@/scripts/utils/utils';

module.exports = async function (deployer: Deployer) {
const config = parseConfig();

const providersDelegatorImpl = await deployer.deploy(ProvidersDelegator__factory);
const delegatorFactoryImpl = await deployer.deploy(DelegatorFactory__factory);
const proxy = await deployer.deploy(ERC1967Proxy__factory, [await delegatorFactoryImpl.getAddress(), '0x']);

const delegatorFactory = await deployer.deployed(DelegatorFactory__factory, await proxy.getAddress());

await delegatorFactory.DelegatorFactory_init(config.lumerinProtocol, providersDelegatorImpl);

await delegatorFactory.deployProxy(
'0x19ec1E4b714990620edf41fE28e9a1552953a7F4',
wei(0.2, 25),
'First Subnet',
'Custom endpoint',
60 * 60 * 1,
60 * 30,
);
};

// npx hardhat migrate --only 3

// npx hardhat migrate --network arbitrum_sepolia --only 3 --verify
// npx hardhat migrate --network arbitrum_sepolia --only 3 --verify --continue

// npx hardhat migrate --network arbitrum --only 3 --verify
// npx hardhat migrate --network arbitrum --only 3 --verify --continue
65 changes: 65 additions & 0 deletions smart-contracts/deploy/4_update_session_facet.migration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { Deployer } from '@solarity/hardhat-migrate';
import { Fragment } from 'ethers';
import { ethers } from 'hardhat';

import { parseConfig } from './helpers/config-parser';

import {
ISessionRouter__factory,
IStatsStorage__factory,
LinearDistributionIntervalDecrease__factory,
LumerinDiamond__factory,
SessionRouter__factory,
} from '@/generated-types/ethers';
import { FacetAction } from '@/test/helpers/deployers';

module.exports = async function (deployer: Deployer) {
const config = parseConfig();

const ldid = await deployer.deploy(LinearDistributionIntervalDecrease__factory);
const newSessionRouterFacet = await deployer.deploy(SessionRouter__factory, {
libraries: {
LinearDistributionIntervalDecrease: ldid,
},
});

const lumerinDiamond = await deployer.deployed(LumerinDiamond__factory, config.lumerinProtocol);

// ONLY FOR TESTS
// const testSigner = await ethers.getImpersonatedSigner(await lumerinDiamond.owner());
// END

const oldSessionRouterFacet = '0xCc48cB2DbA21A5D36C16f6f64e5B5E138EA1ba13';
const oldSelectors = await lumerinDiamond.facetFunctionSelectors(oldSessionRouterFacet);

// ONLY FOR TESTS - remove or add `.connect(testSigner)`
await lumerinDiamond['diamondCut((address,uint8,bytes4[])[])']([
{
facetAddress: oldSessionRouterFacet,
action: FacetAction.Remove,
functionSelectors: [...oldSelectors],
},
{
facetAddress: newSessionRouterFacet,
action: FacetAction.Add,
functionSelectors: ISessionRouter__factory.createInterface()
.fragments.filter(Fragment.isFunction)
.map((f) => f.selector),
},
{
facetAddress: newSessionRouterFacet,
action: FacetAction.Add,
functionSelectors: IStatsStorage__factory.createInterface()
.fragments.filter(Fragment.isFunction)
.map((f) => f.selector),
},
]);
};

// npx hardhat migrate --only 4

// npx hardhat migrate --network arbitrum_sepolia --only 4 --verify
// npx hardhat migrate --network arbitrum_sepolia --only 4 --verify --continue

// npx hardhat migrate --network arbitrum --only 4 --verify
// npx hardhat migrate --network arbitrum --only 4 --verify --continue
1 change: 1 addition & 0 deletions smart-contracts/deploy/data/config_arbitrum_mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"marketplaceMaxBidPricePerSecond": "10000000000000000",
"delegateRegistry": "0x00000000000000447e69651d841bD8D104Bed493",
"owner": "0x1FE04BC15Cf2c5A2d41a0b3a96725596676eBa1E",
"lumerinProtocol": "0xDE819AaEE474626E3f34Ef0263373357e5a6C71b",
"pools": [
{
"payoutStart": 1707393600,
Expand Down
1 change: 1 addition & 0 deletions smart-contracts/deploy/data/config_arbitrum_sepolia.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"marketplaceMaxBidPricePerSecond": "20000000000000000000",
"delegateRegistry": "0x00000000000000447e69651d841bD8D104Bed493",
"owner": "0x1FE04BC15Cf2c5A2d41a0b3a96725596676eBa1E",
"lumerinProtocol": "0xb8C55cD613af947E73E262F0d3C54b7211Af16CF",
"pools": [
{
"payoutStart": 1707393600,
Expand Down
3 changes: 2 additions & 1 deletion smart-contracts/deploy/helpers/config-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ export type Config = {
marketplaceMaxBidPricePerSecond: string;
delegateRegistry: string;
owner: string;
lumerinProtocol: string;
};

export function parseConfig(): Config {
const configPath = `deploy/data/config_arbitrum_mainnet.json`;
const configPath = `deploy/data/config_arbitrum_sepolia.json`;

return JSON.parse(readFileSync(configPath, 'utf-8')) as Config;
}
3 changes: 3 additions & 0 deletions smart-contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ const config: HardhatUserConfig = {
// url: `https://arbitrum-sepolia.infura.io/v3/${process.env.INFURA_KEY}`,
// },
// forking: {
// url: `https://arb-sepolia.g.alchemy.com/v2/${process.env.ALCHEMY_KEY}`,
// },
// forking: {
// url: `https://arbitrum-mainnet.infura.io/v3/${process.env.INFURA_KEY}`,
// },
},
Expand Down

0 comments on commit 2685c4a

Please sign in to comment.