-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: deprecate incentive on dollar token * chore: update * chore: update * Fix set role admin (#880) * feat: add setRoleAdmin to AccessControlFacet The setRoleAdmin can be only accessed by the admin. * feat: add setRoleAdmin to AccessControl interface * test: add testSetRoleAdmin_ShouldSetAdminRoleForGivenRole test * feat: update access control for setRoleAdmin * test: fix ShouldSetAdminRoleForGivenRole and add test for revert * feat: add getRedeemCollateralBalance() method * fix: remove balanced reserves check (#883) * fix: limit AMO minter borrow amount (#882) * fix: limit AMO minter borrow amount * test: assert free collateral amount * fix: do not allow to mint dollar with zero collateral Resolves: sherlock-audit/2023-12-ubiquity-judging#207 * test: add testMintDollar_ShouldRevert_IfZeroCollateralAvailable * test: update comment in zero collateral mint test * Update block count in a week (#891) * feat: implement BlocksInWeek script task The BlocksInWeek task provides a very close approximate of number of blocks mined during one week. Supported networks: mainnnet, sepolia. Example usage: npx tsx scripts/task/task.ts BlocksInWeek --network=mainnet npx tsx scripts/task/task.ts BlocksInWeek --network=sepolia Resolves: sherlock-audit/2023-12-ubiquity-judging#230 * feat: update weekly block count to 49930 Set weekly block count to 49930 as measured in February 2024 npx tsx scripts/task/task.ts BlocksInWeek --network=mainnet ... Calculating number of blocks in the last week... Recent average block time: 12 seconds Estimated blocks in a week best case 50400 Produced 49930 blocks, 470 worst than the best case Resolves: sherlock-audit/2023-12-ubiquity-judging#230 * feat: rename task function to funcBlocksInAWeek As proposed during pull request review. * feat: use CurveStableSwapMetaNG contract * refactor: update migrations to use latest metapool * refactor: deprecate IMetaPool * refactor: remove MockTWAPOracleDollar3pool * refactor: remove TWAPOracleDollar3poolFacet * refactor: remove MockMetaPool * refactor: remove LibTWAPOracle * fix(dapp): remove TWAP oracle ABI import * refactor(frontend): use ICurveStableSwapMetaNG for TWAP * feat: check if collateral is enabled in collectRedemption (#894) Also add a unit test that verifies the check. Resolves: sherlock-audit/2023-12-ubiquity-judging#29 --------- Co-authored-by: molecula451 <[email protected]> Co-authored-by: korrrba <[email protected]> Co-authored-by: Korrrba <[email protected]>
- Loading branch information
1 parent
9f88242
commit acc5800
Showing
52 changed files
with
663 additions
and
1,003 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,6 +120,7 @@ | |
"rpcutil", | ||
"rustup", | ||
"Sablier", | ||
"sepolia", | ||
"setu", | ||
"Shouldset", | ||
"Sighash", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Dollar task scripts | ||
|
||
## BlocksInWeek | ||
|
||
BlocksInWeek task provides a close approximate of number of blocks mined in one week. | ||
|
||
Usage: | ||
|
||
Ethereum mainnet: | ||
|
||
``` | ||
npx tsx scripts/task/task.ts BlocksInWeek --network=mainnet | ||
``` | ||
|
||
Sepolia: | ||
|
||
Ethereum mainnet: | ||
|
||
``` | ||
npx tsx scripts/task/task.ts BlocksInWeek --network=sepolia | ||
``` | ||
|
||
Prerequisite: set ETHERSCAN_API_KEY in .env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { OptionDefinition } from "command-line-args"; | ||
|
||
import { Networks, TaskFuncParam } from "../../shared"; | ||
import { EtherscanProvider } from "ethers"; | ||
|
||
export const optionDefinitions: OptionDefinition[] = [ | ||
{ name: "task", defaultOption: true }, | ||
{ name: "network", alias: "n", type: String }, | ||
]; | ||
|
||
const funcBlocksInAWeek = async (params: TaskFuncParam) => { | ||
const { args, env } = params; | ||
const { network } = args; | ||
|
||
const chainId = Networks[network] ?? undefined; | ||
if (!chainId) { | ||
throw new Error(`Unsupported network: ${network} Please configure it out first`); | ||
} | ||
|
||
const provider = new EtherscanProvider(chainId, env.etherscanApiKey); | ||
|
||
console.log(`Calculating number of blocks in the last week...`); | ||
const secondsInAWeek = 604800; // 24 * 7 * 60 * 60 seconds is one week | ||
const currentBlockNumber = await provider.getBlockNumber(); | ||
const currentBlockTimestamp = (await provider.getBlock(currentBlockNumber))?.timestamp; | ||
const blockTimestampTwoBlocksAgo = (await provider.getBlock(currentBlockNumber - 2))?.timestamp; | ||
|
||
if (currentBlockTimestamp && blockTimestampTwoBlocksAgo) { | ||
const avgBlockTime = (currentBlockTimestamp - blockTimestampTwoBlocksAgo) / 2; | ||
console.log(`Recent average block time: ${avgBlockTime} seconds`); | ||
|
||
const oneWeekAgo = currentBlockTimestamp - secondsInAWeek; | ||
const estimatedBlocksInAWeek = secondsInAWeek / avgBlockTime; | ||
console.log(`Estimated blocks in a week best case ${estimatedBlocksInAWeek}`); | ||
|
||
let estimatedBlockNumber = currentBlockNumber - estimatedBlocksInAWeek; | ||
let estimatedBlockTimestamp = (await provider.getBlock(estimatedBlockNumber))?.timestamp; | ||
|
||
if (estimatedBlockTimestamp) { | ||
let deltaBlockTime = oneWeekAgo - estimatedBlockTimestamp; | ||
estimatedBlockNumber += Math.trunc(deltaBlockTime / avgBlockTime); | ||
estimatedBlockTimestamp = (await provider.getBlock(estimatedBlockNumber))?.timestamp || estimatedBlockTimestamp; | ||
deltaBlockTime -= estimatedBlockTimestamp - oneWeekAgo; | ||
|
||
console.log(`Produced ${estimatedBlocksInAWeek - deltaBlockTime / avgBlockTime} blocks, ${deltaBlockTime / avgBlockTime} worst than the best case`); | ||
} | ||
} | ||
|
||
return "succeeded"; | ||
}; | ||
export default funcBlocksInAWeek; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.