Skip to content

Commit 0399ff3

Browse files
authored
fix: Incorrect fair launch auction price calculation (#114)
* fix: Incorrect fair launch auction price calculation * Upgrade to v4.1.5
1 parent 8f987cf commit 0399ff3

File tree

4 files changed

+175
-3
lines changed

4 files changed

+175
-3
lines changed

contracts/registry/libraries/LibPCOLicenseClaimer.sol

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ library LibPCOLicenseClaimer {
4545

4646
uint256 timeElapsed = block.timestamp - ds.auctionStart;
4747
uint256 auctionDuration = ds.auctionEnd - ds.auctionStart;
48-
uint256 priceDecrease = (ds.startingBid * timeElapsed) /
49-
auctionDuration;
48+
uint256 priceDecrease = ((ds.startingBid - ds.endingBid) *
49+
timeElapsed) / auctionDuration;
5050
return ds.startingBid - priceDecrease;
5151
}
5252
}

hardhat.config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import "./tasks/initialize-defender";
2121
import "./tasks/initialize-eoa";
2222
import "./tasks/upgrades/4_1_0";
2323
import "./tasks/upgrades/4_1_1";
24+
import "./tasks/upgrades/4_1_5";
2425
import "hardhat-gas-reporter";
2526
import "@nomiclabs/hardhat-etherscan";
2627
import "solidity-docgen";

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@geo-web/contracts",
33
"license": "MIT",
4-
"version": "4.1.4",
4+
"version": "4.1.5",
55
"description": "GeoWeb solidity contracts, artifacts, & types",
66
"author": "GeoWebCore",
77
"homepage": "https://www.geoweb.network/",

tasks/upgrades/4_1_5.ts

+171
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
/*
2+
v4.1.5 Upgrade
3+
4+
RegistryDiamond
5+
===============
6+
7+
Facets to deploy:
8+
- PCOLicenseClaimerFacetV2
9+
10+
Function selectors to REPLACE:
11+
- All of IPCOLicenseClaimerFacet -> PCOLicenseClaimerFacetV2
12+
13+
===============
14+
*/
15+
16+
import { HardhatRuntimeEnvironment } from "hardhat/types";
17+
import { Contract } from "ethers";
18+
const {
19+
FacetCutAction,
20+
getSelectors,
21+
} = require("../../scripts/libraries/diamond.js");
22+
import { task } from "hardhat/config";
23+
import { AdminClient } from "defender-admin-client";
24+
import { DiamondWritable } from "../../typechain-types/DiamondWritable";
25+
26+
async function deployFacets(
27+
hre: HardhatRuntimeEnvironment,
28+
registryDiamond: Contract,
29+
pcoLicenseClaimerV2?: Contract
30+
) {
31+
const facetCuts = [];
32+
33+
const PCOLicenseClaimerFacetV2 = await hre.ethers.getContractFactory(
34+
"PCOLicenseClaimerFacetV2"
35+
);
36+
const pcoLicenseClaimerFacetV2 =
37+
pcoLicenseClaimerV2 ?? (await PCOLicenseClaimerFacetV2.deploy());
38+
await pcoLicenseClaimerFacetV2.deployed();
39+
console.log(
40+
`PCOLicenseClaimerFacetV2 deployed: ${pcoLicenseClaimerFacetV2.address}`
41+
);
42+
43+
const pcoLicenseClaimer = await hre.ethers.getContractAt(
44+
"IPCOLicenseClaimer",
45+
pcoLicenseClaimerFacetV2.address
46+
);
47+
48+
facetCuts.push({
49+
target: pcoLicenseClaimerFacetV2.address,
50+
action: FacetCutAction.Replace,
51+
selectors: getSelectors(pcoLicenseClaimer),
52+
});
53+
54+
return facetCuts;
55+
}
56+
57+
export async function upgrade(
58+
hre: HardhatRuntimeEnvironment,
59+
registryDiamond: Contract
60+
) {
61+
const facetCuts = await deployFacets(hre, registryDiamond);
62+
63+
const target = hre.ethers.constants.AddressZero;
64+
const data = "0x";
65+
66+
// Cut diamond
67+
const diamond = await hre.ethers.getContractAt(
68+
`IRegistryDiamond`,
69+
registryDiamond.address
70+
);
71+
await diamond.diamondCut(facetCuts, target, data);
72+
console.log(`Diamond cut: ${diamond.address}`);
73+
}
74+
75+
task("upgrade:4.1.5")
76+
.addParam("registryDiamondAddress", "RegistryDiamond address")
77+
.addOptionalParam("pcoLicenseClaimerV2Address", "PCOLicenseClaimerV2 address")
78+
.setAction(
79+
async (
80+
{
81+
registryDiamondAddress,
82+
pcoLicenseClaimerV2Address,
83+
}: {
84+
registryDiamondAddress: string;
85+
pcoLicenseClaimerV2Address?: string;
86+
},
87+
hre
88+
) => {
89+
const { diamondAdmin } = await hre.getNamedAccounts();
90+
91+
// Create Defender client
92+
// const adminClient = new AdminClient({
93+
// apiKey: process.env.DEFENDER_API_KEY!,
94+
// apiSecret: process.env.DEFENDER_API_SECRET!,
95+
// });
96+
97+
const registryDiamond = await hre.ethers.getContractAt(
98+
"IRegistryDiamond",
99+
registryDiamondAddress
100+
);
101+
102+
const pcoLicenseClaimerFacetV2 = pcoLicenseClaimerV2Address
103+
? await hre.ethers.getContractAt(
104+
"IPCOLicenseClaimer",
105+
pcoLicenseClaimerV2Address
106+
)
107+
: undefined;
108+
109+
const facetCuts = await deployFacets(
110+
hre,
111+
registryDiamond,
112+
pcoLicenseClaimerFacetV2
113+
);
114+
115+
const target = hre.ethers.constants.AddressZero;
116+
const data = "0x";
117+
118+
console.log(facetCuts, target, data);
119+
120+
// Cut diamond
121+
// await adminClient.createProposal({
122+
// contract: {
123+
// address: registryDiamond.address,
124+
// network: NETWORKS[hre.network.config.chainId!] as any,
125+
// }, // Target contract
126+
// title: "Upgrade RegistryDiamond v4.1.0", // Title of the proposal
127+
// description: "Cut RegistryDiamond to upgrade to v4.1.0", // Description of the proposal
128+
// type: "custom", // Use 'custom' for custom admin actions
129+
// functionInterface: {
130+
// name: "diamondCut",
131+
// inputs: [
132+
// {
133+
// components: [
134+
// {
135+
// internalType: "address",
136+
// name: "target",
137+
// type: "address",
138+
// },
139+
// {
140+
// internalType: "enum IDiamondWritable.FacetCutAction",
141+
// name: "action",
142+
// type: "uint8",
143+
// },
144+
// {
145+
// internalType: "bytes4[]",
146+
// name: "selectors",
147+
// type: "bytes4[]",
148+
// },
149+
// ],
150+
// internalType: "struct IDiamondWritable.FacetCut[]",
151+
// name: "facetCuts",
152+
// type: "tuple[]",
153+
// },
154+
// {
155+
// internalType: "address",
156+
// name: "target",
157+
// type: "address",
158+
// },
159+
// {
160+
// internalType: "bytes",
161+
// name: "data",
162+
// type: "bytes",
163+
// },
164+
// ],
165+
// }, // Function ABI
166+
// functionInputs: [encodedFacetCuts, target, data], // Arguments to the function
167+
// via: diamondAdmin, // Address to execute proposal
168+
// viaType: "Gnosis Safe", // 'Gnosis Safe', 'Gnosis Multisig', or 'EOA'
169+
// });
170+
}
171+
);

0 commit comments

Comments
 (0)