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

Fix Convert's RemoveDeposit event #530

Merged
merged 3 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6,676 changes: 6,675 additions & 1 deletion protocol/abi/Beanstalk.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion protocol/contracts/beanstalk/silo/ConvertFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ contract ConvertFacet is ReentrancyGuard {
event RemoveDeposit(
address indexed account,
address indexed token,
int128 stem,
int96 stem,
uint256 amount,
uint256 bdv
);
Expand Down
4 changes: 2 additions & 2 deletions protocol/contracts/beanstalk/silo/SiloFacet/SiloExit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ contract SiloExit is ReentrancyGuard {
function stemTipForToken(address token)
public
view
returns (int128 _stemTip)
returns (int96 _stemTip)
{
_stemTip = LibTokenSilo.stemTipForToken(
token
Expand All @@ -299,7 +299,7 @@ contract SiloExit is ReentrancyGuard {
function seasonToStem(address token, uint32 season)
public
view
returns (int128 stem)
returns (int96 stem)
{
uint256 seedsPerBdv = getSeedsPerToken(address(token));
stem = LibLegacyTokenSilo.seasonToStem(seedsPerBdv, season);
Expand Down
23 changes: 22 additions & 1 deletion protocol/hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ task("sunrise", async function () {
await beanstalkAdmin.forceSunrise();
});

task("getTime", async function () {
this.season = await ethers.getContractAt("SeasonFacet", BEANSTALK);
console.log("Current time: ", await this.season.time());
});

/*task('replant', async () => {
const account = await impersonateSigner(PUBLIUS)
await replant(account)
Expand Down Expand Up @@ -135,7 +140,15 @@ task("diamondABI", "Generates ABI file for diamond, includes all ABIs of facets"
}
}

fs.writeFileSync("./abi/Beanstalk.json", JSON.stringify(abi.filter((item, pos) => abi.map((a) => a.name).indexOf(item.name) == pos)));
const names = abi.map((a) => a.name);
fs.writeFileSync(
"./abi/Beanstalk.json",
JSON.stringify(
abi.filter((item, pos) => names.indexOf(item.name) == pos),
null,
2
)
);

console.log("ABI written to abi/Beanstalk.json");
});
Expand Down Expand Up @@ -171,6 +184,14 @@ task("bip34", async function () {
});
});

task("silov3", async function () {
await bipNewSilo();
});

task("beanstalkAdmin", async function () {
await mockBeanstalkAdmin();
});

//////////////////////// SUBTASK CONFIGURATION ////////////////////////

// Add a subtask that sets the action for the TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS task
Expand Down
59 changes: 59 additions & 0 deletions protocol/scripts/check-events.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* check-events.js
* ---------------
*
* Throughout Beanstalk, events are often copied between facets and libraries.
* This script checks that events are consistent across all individual ABIs.
*/

const path = require("path");
const fs = require("fs");
const glob = require("glob");

// The glob returns the full file path like this:
// contracts/beanstalk/barn/UnripeFacet.sol
// We want the "UnripeFacet" part.
const getFacetName = (file) => {
return file.split("/").pop().split(".")[0];
};

const pattern = path.join(".", "contracts", "beanstalk", "**", "*Facet.sol");
const files = glob.sync(pattern);
const eventNameToItem = new Map();
const eventNameToFiles = new Map();

console.log("Searching: ", pattern, files.length)

files.forEach((file) => {
const facetName = getFacetName(file);
const jsonFileName = `${facetName}.json`;
const jsonFileLoc = path.join(".", "artifacts", file, jsonFileName);

const json = JSON.parse(fs.readFileSync(jsonFileLoc));
const abi = json.abi;

abi.filter((item) => item.type == "event").forEach((item) => {
// If event already exists, compare new version to previous version
const existingEvent = eventNameToItem.get(item.name);
if (existingEvent) {
// Compare inputs, the order and length of the arrays should match
item.inputs.forEach((input, index) => {
if (input.name !== existingEvent.inputs[index].name || input.type !== existingEvent.inputs[index].type) {
console.error("Event mismatch", {
new: input,
existing: existingEvent.inputs[index]
})
throw new Error("Event mismatch")
}
})

eventNameToFiles.set(item.name, [...eventNameToFiles.get(item.name), file])
} else {
eventNameToItem.set(item.name, item);
eventNameToFiles.set(item.name, [file]);
}
});

});

console.log(eventNameToFiles)