Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: diamond storage #94

Merged
merged 77 commits into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
0fc5f06
feat: add basic diamond contracts
Jan 7, 2022
d5a6e02
feat: more
Jan 7, 2022
181941d
refactor: remove inheritance, add app storage
Jan 7, 2022
6bdaff1
fix: compile
Jan 7, 2022
42d3578
fix: diamond deploy with args
Jan 8, 2022
43864b0
feat: add starter ts files
Jan 10, 2022
569db8d
fix: basic diamond deploy script in ts
Jan 11, 2022
576babb
feat: supportedInterfaces
Jan 11, 2022
a622b22
chore: rmv unnecessary func, set facet objs
Jan 11, 2022
c36dceb
refactor: diamond tests to seperate test dir
Jan 12, 2022
d6dd3ce
refactor: old test to testOld
Jan 13, 2022
a086d7b
fix: all outdate Hub => HubFacet imports
Jan 13, 2022
96bcb5b
fix: hub point to diamond
Jan 14, 2022
dfd7115
refactor: hubFacet state to appStorage
Jan 15, 2022
6d4fbc1
chore: remove initialize()
Jan 16, 2022
bf5e81a
Merge branch 'main' into diamond
Jan 16, 2022
f979775
fix: linting
Jan 17, 2022
ab8aa8b
Merge branch 'main' into diamond
Jan 18, 2022
befed39
fix: hubFacet test deploys
Jan 18, 2022
60e0c7f
feat: deactivate
Jan 18, 2022
4aef430
fix: more Hub => HubFacet imports
Jan 18, 2022
7ac4f60
feat: add meTokenRegistry facet and lib
Jan 20, 2022
e39a326
chore(deploy): deploy and register
zgorizzo69 Jan 20, 2022
5053657
feat(deploy): deploy and register
zgorizzo69 Jan 20, 2022
7e4ae99
fix(deploy): get storage from the diamond silly
zgorizzo69 Jan 20, 2022
3896c74
feat: one Foundry test works
Jan 24, 2022
ad9c482
chore: almost all FOundry tests work
Jan 24, 2022
7dbb1b9
refactor: rmv all variables stored in facet
Jan 25, 2022
e366478
feat: feesFacet
Jan 25, 2022
8451f24
test(fail): fail with get tcode
zgorizzo69 Jan 25, 2022
2ce3c11
feat: foundryFacet
Jan 25, 2022
e56575c
fix(test): update hubsetup
zgorizzo69 Jan 25, 2022
193ed33
fix(test): update allcurves
zgorizzo69 Jan 25, 2022
3753529
feat: funcs to lib
Jan 26, 2022
64eacc9
fix(test): remove foundry
zgorizzo69 Jan 26, 2022
4ba4625
fix(test): remove curves
zgorizzo69 Jan 26, 2022
072f3b9
fix(test): fix all curves
zgorizzo69 Jan 26, 2022
07662c8
fix(test): clean and comment test
zgorizzo69 Jan 26, 2022
6e7a27f
Merge pull request #105 from meTokens/diamond-test-2
Jan 27, 2022
988230f
Merge pull request #103 from meTokens/diamond-tests
Jan 27, 2022
920bdfc
Merge branch 'main' into diamond
Jan 27, 2022
269aef7
fix: copy over diamond-test-2 allCurves/hubSetup files
Jan 27, 2022
c1c9745
fix(test): correct typing
zgorizzo69 Jan 27, 2022
c57b09d
fix(test): fix allcurves
zgorizzo69 Jan 27, 2022
6f5cd3c
fix: hubSetup with generic curve
Jan 27, 2022
7c4a679
feat: diamond ownership
Jan 28, 2022
6145581
chore: facet imports
Jan 28, 2022
ece205c
feat: deploy new facets & register on rinkeby
Jan 30, 2022
5e91f38
fix: finally test suite doesn't break, 224 pass
Jan 30, 2022
43e0f48
fix: func ordering
Feb 1, 2022
022d88b
refactor: ownership, modifiers
Feb 1, 2022
31887a3
fix: some tests pass again
Feb 1, 2022
8bced12
fix(test): add metoken factory
zgorizzo69 Feb 1, 2022
31dc103
fix(test): set correct max refund ratio to 1Million
zgorizzo69 Feb 1, 2022
4f13f97
fix(test): cleaned test
zgorizzo69 Feb 1, 2022
92c0c16
fix(test): correct precision for init diamond
zgorizzo69 Feb 2, 2022
592545f
test(fix): adapt tests
zgorizzo69 Feb 4, 2022
f265356
test(metoken): clean and remove unecessary tests
zgorizzo69 Feb 5, 2022
3259a38
fix(test): fix hub
zgorizzo69 Feb 5, 2022
0fc8495
fix(struct): reorganize structs to avoid inefficiency
zgorizzo69 Feb 6, 2022
212587c
fix: rename -
parv3213 Feb 7, 2022
d851e3b
Merge pull request #109 from meTokens/diamond-tests
Feb 7, 2022
ca5512f
Merge pull request #110 from meTokens/fix/rename-functions
Feb 7, 2022
8d7c0d4
Merge branch 'main' into diamond
Feb 8, 2022
af7ba3c
fix: tests pass (mostly) after old contract removal
Feb 9, 2022
57d4ccb
fix: remaining tests
Feb 10, 2022
2857b0d
Merge pull request #112 from meTokens/test/diamond-fix
Feb 10, 2022
30e39fc
feat(meta): replace msg.sender
zgorizzo69 Feb 10, 2022
5a0b12f
feat: etherscan verify diamond
Feb 10, 2022
f1957f4
fix: contract deployment
Feb 10, 2022
bc88291
fix: bancor verification
Feb 11, 2022
92d32a4
Merge pull request #113 from meTokens/feat/meta
Feb 12, 2022
204b720
Revert "feat(meta): replace msg.sender"
Feb 16, 2022
dd32ab8
Merge pull request #117 from meTokens/revert-113-feat/meta
Feb 16, 2022
32b4767
Merge branch 'main' into diamond
Feb 16, 2022
55edaa7
chore: rm old deploy scripts
Feb 16, 2022
89ca216
fix: facet imports
Feb 16, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(test): clean and comment test
  • Loading branch information
zgorizzo69 committed Jan 26, 2022
commit 07662c8036218f7a06e0081b9a11522bfa25c3e6
6 changes: 0 additions & 6 deletions contracts/DiamondInit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {IDiamondCut} from "./interfaces/IDiamondCut.sol";
import {IDiamondLoupe} from "./interfaces/IDiamondLoupe.sol";
import {LibDiamond} from "./libs/LibDiamond.sol";
import "./libs/Details.sol";
import "hardhat/console.sol";

contract DiamondInit {
struct Args {
Expand All @@ -32,11 +31,6 @@ contract DiamondInit {
s.foundry = _args.foundry;
s.vaultRegistry = _args.vaultRegistry;
s.curveRegistry = _args.curveRegistry;
console.log(
"## DiamondInit s.curveRegistry:%s vaultRegistry:%s",
address(s.curveRegistry),
address(s.vaultRegistry)
);
s.migrationRegistry = _args.migrationRegistry;
// s.mintFee = _args.mintFee;
// s.burnBuyerFee = _args.burnBuyerFee;
Expand Down
33 changes: 0 additions & 33 deletions contracts/facets/HubFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import "../interfaces/IVault.sol";
import "../interfaces/IRegistry.sol";
import "../interfaces/ICurve.sol";
import "../interfaces/IFoundry.sol";
import "hardhat/console.sol";

contract HubFacet {
event Register(
Expand Down Expand Up @@ -52,11 +51,6 @@ contract HubFacet {
bytes memory _encodedVaultArgs
) external {
// TODO: access control
console.log(
"## s.curveRegistry:%s vaultRegistry:%s",
address(s.curveRegistry),
address(s.vaultRegistry)
);
require(
s.curveRegistry.isApproved(address(_curve)),
"_curve !approved"
Expand Down Expand Up @@ -108,35 +102,14 @@ contract HubFacet {
uint256 _targetRefundRatio,
bytes memory _encodedCurveDetails
) external {
console.log(
"## initUpdate id:%s target:%s _targetRefundRatio:%s",
_id,
_targetCurve,
_targetRefundRatio
);
Details.Hub storage hub_ = s.hubs[_id];
console.log(
"## initUpdate msg.sender:%s Details hub_owner:%s",
msg.sender,
hub_.owner
);
require(msg.sender == hub_.owner, "!owner");
console.log(
"## initUpdate hub_.updating:%s hub_.endTime:%s",
hub_.updating,
hub_.endTime
);
if (hub_.updating && block.timestamp > hub_.endTime) {
this.finishUpdate(_id);
}
require(!hub_.updating, "already updating");

require(block.timestamp >= hub_.endCooldown, "Still cooling down");
console.log(
"## initUpdate block.timestamp:%s _encodedCurveDetails.length :%s",
block.timestamp,
_encodedCurveDetails.length
);
// Make sure at least one of the values is different
require(
(_targetRefundRatio != 0) || (_encodedCurveDetails.length > 0),
Expand Down Expand Up @@ -165,12 +138,6 @@ contract HubFacet {
s.curveRegistry.isApproved(_targetCurve),
"_targetCurve !approved"
);
console.log(
"## 2 initUpdate s.curveRegistry :%s _targetCurve:%s hub_.curve:%s",
address(s.curveRegistry),
_targetCurve,
hub_.curve
);
require(_targetCurve != hub_.curve, "targetCurve==curve");
ICurve(_targetCurve).register(_id, _encodedCurveDetails);
hub_.targetCurve = _targetCurve;
Expand Down
115 changes: 49 additions & 66 deletions test/contracts/curves/allCurves.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ const setup = async () => {
["address"],
[DAI]
);
/* const weightedAverage = await deploy<WeightedAverage>("WeightedAverage");
foundry = await deploy<Foundry>("Foundry", {
WeightedAverage: weightedAverage.address,
}); */
// hub = await deploy<HubFacet>("HubFacet");

// Setting up curve info to test

Expand Down Expand Up @@ -106,8 +101,7 @@ const setup = async () => {
["uint256", "uint32"],
[baseY6, reserveWeight6]
);
console.log("8888888888");
// Create hub and register first hub
// Create and register first hub we also link the hubCurve of type "bancorABDK" to this hub (hubID = 1)
let hubCurve: ICurve;
({
token,
Expand All @@ -129,9 +123,7 @@ const setup = async () => {
5000,
"bancorABDK"
));
const firstHubId = await hub.count();
console.log("99999999999");
let hubArgs: [
let addArgs: [
string,
HubFacet,
Diamond,
Expand All @@ -144,7 +136,8 @@ const setup = async () => {
string,
string,
number,
string
string,
ICurve | undefined
] = [
tokenAddr,
hub,
Expand All @@ -159,29 +152,13 @@ const setup = async () => {
encodedVaultArgs,
5000,
account0.address,
];
let hubDetails = await addHubSetup(...hubArgs);
/* const bancorABDK = await deploy<BancorABDK>(
"BancorABDK",
undefined,
hub.address
);
];

// we create a new curve of type "bancorABDK" and register it to a new hub (hubID = 2)
// along with encoded details for the curve and the vault
let hubDetails = await addHubSetup(...addArgs);

const newBancorABDK = await deploy<BancorABDK>(
"BancorABDK",
undefined,
hub.address
);

await curveRegistry.approve(bancorABDK.address);
await curveRegistry.approve(newBancorABDK.address);*/
console.log(
`

curve:${hubCurve.address} for hubid:${firstHubId} newCurve:${hubDetails.hubCurve.address} for hubid:${hubDetails.hubId}

`
);
let curve = {
signers: [account0, account1, account2],
curve: hubDetails.hubCurve,
Expand All @@ -201,134 +178,140 @@ const setup = async () => {
curves.push(curve);

// Second ABDK Curve
hubArgs[9] = encodedCurveDetails2;
hubDetails = await addHubSetup(...hubArgs);

addArgs[13] = hubDetails.hubCurve;
addArgs[9] = encodedCurveDetails2;
// we register a new hub with the same curve deployed before but with new encoded curve details
hubDetails = await addHubSetup(...addArgs);
curves.push({
...curve,
curve: hubDetails.hubCurve,
hubId: hubDetails.hubId,
baseY: toETHNumber(baseY2),
reserveWeight: reserveWeight2,
targetReserveWeight: targetReserveWeight2,
});

// Third ABDK curve
hubArgs[9] = encodedCurveDetails3;
hubDetails = await addHubSetup(...hubArgs);
addArgs[9] = encodedCurveDetails3;
// we register a new hub with the same curve deployed before but with new encoded curve details
hubDetails = await addHubSetup(...addArgs);
curves.push({
...curve,
curve: hubDetails.hubCurve,
hubId: hubDetails.hubId,
baseY: toETHNumber(baseY3),
reserveWeight: reserveWeight3,
targetReserveWeight: targetReserveWeight3,
});

// Fourth ABDK curve
hubArgs[9] = encodedCurveDetails4;
hubDetails = await addHubSetup(...hubArgs);
addArgs[9] = encodedCurveDetails4;
// we register a new hub with the same curve deployed before but with new encoded curve details
hubDetails = await addHubSetup(...addArgs);
curves.push({
...curve,
curve: hubDetails.hubCurve,
hubId: hubDetails.hubId,
baseY: toETHNumber(baseY4),
reserveWeight: reserveWeight4,
targetReserveWeight: targetReserveWeight4,
});

// fifth ABDK curve
hubArgs[9] = encodedCurveDetails5;
hubDetails = await addHubSetup(...hubArgs);
addArgs[9] = encodedCurveDetails5;
// we register a new hub with the same curve deployed before but with new encoded curve details
hubDetails = await addHubSetup(...addArgs);
curves.push({
...curve,
curve: hubDetails.hubCurve,
hubId: hubDetails.hubId,
baseY: toETHNumber(baseY5),
reserveWeight: reserveWeight5,
targetReserveWeight: targetReserveWeight5,
});

// sixth ABDK curve
hubArgs[9] = encodedCurveDetails6;
hubDetails = await addHubSetup(...hubArgs);
addArgs[9] = encodedCurveDetails6;
// we register a new hub with the same curve deployed before but with new encoded curve details
hubDetails = await addHubSetup(...addArgs);
curves.push({
...curve,
curve: hubDetails.hubCurve,
hubId: hubDetails.hubId,
baseY: toETHNumber(baseY6),
reserveWeight: reserveWeight6,
targetReserveWeight: targetReserveWeight6,
});

// Bancor Power
hubArgs[4] = "BancorPower";
addArgs[4] = "BancorPower";

// First Power curve
hubArgs[9] = encodedCurveDetails1;
hubDetails = await addHubSetup(...hubArgs);
addArgs[9] = encodedCurveDetails1;
// we create a new curve of type "BancorPower" and register it to the hub
// along with encoded details for this curve
hubDetails = await addHubSetup(...addArgs);
// we set this new curve as the default curve
curve = { ...curve, curve: hubDetails.hubCurve };
curves.push({
...curve,
curve: hubDetails.hubCurve,
hubId: hubDetails.hubId,
baseY: toETHNumber(baseY1),
reserveWeight: reserveWeight1,
targetReserveWeight: targetReserveWeight1,
});

// Second Power curve
hubArgs[9] = encodedCurveDetails2;
hubDetails = await addHubSetup(...hubArgs);
addArgs[13] = curve.curve;
addArgs[9] = encodedCurveDetails2;
// we register a new hub with the same curve deployed before but with new encoded curve details
hubDetails = await addHubSetup(...addArgs);
curves.push({
...curve,
curve: hubDetails.hubCurve,
hubId: hubDetails.hubId,
baseY: toETHNumber(baseY2),
reserveWeight: reserveWeight2,
targetReserveWeight: targetReserveWeight2,
});

// third power curve
hubArgs[9] = encodedCurveDetails3;
hubDetails = await addHubSetup(...hubArgs);
addArgs[9] = encodedCurveDetails3;
// we register a new hub with the same curve deployed before but with new encoded curve details
hubDetails = await addHubSetup(...addArgs);
curves.push({
...curve,
curve: hubDetails.hubCurve,
hubId: hubDetails.hubId,
baseY: toETHNumber(baseY3),
reserveWeight: reserveWeight3,
targetReserveWeight: targetReserveWeight3,
});

// fourth power curve
hubArgs[9] = encodedCurveDetails4;
hubDetails = await addHubSetup(...hubArgs);
addArgs[9] = encodedCurveDetails4;
// we register a new hub with the same curve deployed before but with new encoded curve details
hubDetails = await addHubSetup(...addArgs);
curves.push({
...curve,
curve: hubDetails.hubCurve,
hubId: hubDetails.hubId,
baseY: toETHNumber(baseY4),
reserveWeight: reserveWeight4,
targetReserveWeight: targetReserveWeight4,
});

// fifth power curve
hubArgs[9] = encodedCurveDetails5;
hubDetails = await addHubSetup(...hubArgs);
addArgs[9] = encodedCurveDetails5;
// we register a new hub with the same curve deployed before but with new encoded curve details
hubDetails = await addHubSetup(...addArgs);
curves.push({
...curve,
curve: hubDetails.hubCurve,
hubId: hubDetails.hubId,
baseY: toETHNumber(baseY5),
reserveWeight: reserveWeight5,
targetReserveWeight: targetReserveWeight5,
});

// sixth power curve
hubArgs[9] = encodedCurveDetails6;
hubDetails = await addHubSetup(...hubArgs);
addArgs[9] = encodedCurveDetails6;
// we register a new hub with the same curve deployed before but with new encoded curve details
hubDetails = await addHubSetup(...addArgs);
curves.push({
...curve,
curve: hubDetails.hubCurve,
hubId: hubDetails.hubId,
baseY: toETHNumber(baseY6),
reserveWeight: reserveWeight6,
Expand Down
Loading