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

Added mUSD snap #153

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion hardhat-fork.config.ts
Expand Up @@ -9,7 +9,7 @@ export default {
blockGasLimit: 9000000,
forking: {
url: process.env.NODE_URL || "",
blockNumber: 12043106,
blockNumber: 12094381,
},
},
},
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -18,6 +18,7 @@
"coverage": "yarn hardhat compile --force && node --max_old_space_size=6144 node_modules/.bin/hardhat coverage --temp 'build/contracts' --testfiles 'test/**/*.spec.ts' --show-stack-traces",
"convertTestFiles": "cd test-utils/validator-data; ts-node ./convertCsvTestFiles.ts",
"task": "yarn compile && yarn hardhat --config tasks.config.ts",
"task-fork": "yarn compile && yarn hardhat --config tasks-fork.config.ts",
"test": "yarn hardhat test",
"test:long": "LONG_TESTS=true yarn hardhat test",
"test-fork": "yarn hardhat --config hardhat-fork.config.ts test ./test-fork/**/*.spec.ts",
Expand Down
8 changes: 8 additions & 0 deletions tasks-fork.config.ts
@@ -0,0 +1,8 @@
import config from "./hardhat-fork.config"

import "./tasks/deployMbtc"
import "./tasks/mBTC"
import "./tasks/deployMV3"
import "./tasks/mUSD"

export default config
6 changes: 4 additions & 2 deletions tasks.config.ts
@@ -1,6 +1,8 @@
import { hardhatConfig } from "./hardhat.config"
import config from "./hardhat.config"

import "./tasks/deployMbtc"
import "./tasks/mBTC"
import "./tasks/deployMV3"
import "./tasks/mUSD"

export default hardhatConfig
export default config
32 changes: 9 additions & 23 deletions tasks/mBTC.ts
Expand Up @@ -25,11 +25,7 @@ interface Balances {
const getTvlCap = async (signer: Signer): Promise<BN> => {
const validator = await new ValidatorWithTVLCap__factory(signer).attach(contracts.mainnet.InvariantValidator)
const tvlStartTime = await validator.startTime()
const weeksSinceLaunch = BN.from(Date.now())
.div(1000)
.sub(tvlStartTime)
.mul(fullScale)
.div(604800)
const weeksSinceLaunch = BN.from(Date.now()).div(1000).sub(tvlStartTime).mul(fullScale).div(604800)
// // e.g. 1e19 + (15e18 * 2.04e36) = 1e19 + 3.06e55
// // startingCap + (capFactor * weeksSinceLaunch**2 / 1e36);
return startingCap.add(capFactor.mul(weeksSinceLaunch.pow(2)).div(fullScale.pow(2)))
Expand Down Expand Up @@ -73,10 +69,7 @@ const getSwapRates = async (mBTC: Masset) => {
const output = await mBTC.getSwapOutput(inputAddress, outputAddress, input)
const scaledInput = applyDecimals(input, inputToken.decimals)
const scaledOutput = applyDecimals(output, outputToken.decimals)
const percent = scaledOutput
.sub(scaledInput)
.mul(10000)
.div(scaledInput)
const percent = scaledOutput.sub(scaledInput).mul(10000).div(scaledInput)
console.log(
`${inputStr} ${inputToken.symbol.padEnd(6)} -> ${outputToken.symbol.padEnd(6)} ${formatUnits(
output,
Expand All @@ -96,10 +89,7 @@ const getBalances = async (mBTC: Masset): Promise<Balances> => {
const savingBalance = await mBTC.balanceOf(contracts.mainnet.imBTC)
const sushiPoolBalance = await mBTC.balanceOf(contracts.mainnet.sushiPool)
const mStableFundManagerBalance = await mBTC.balanceOf(contracts.mainnet.fundManager)
const otherBalances = mBtcBalance
.sub(savingBalance)
.sub(sushiPoolBalance)
.sub(mStableFundManagerBalance)
const otherBalances = mBtcBalance.sub(savingBalance).sub(sushiPoolBalance).sub(mStableFundManagerBalance)

console.log("\nmBTC Holders")
console.log(`imBTC ${formatUnits(savingBalance).padEnd(20)} ${savingBalance.mul(100).div(mBtcBalance)}%`)
Expand Down Expand Up @@ -260,11 +250,11 @@ const outputFees = (
currentTime: Date,
) => {
const totalFees = redeems.fees.add(multiRedeems.fees).add(swaps.fees)
const totalTransactions = mints.total
.add(multiMints.total)
.add(redeems.total)
.add(multiRedeems.total)
.add(swaps.total)
if (totalFees.eq(0)) {
console.log(`\nNo fees since ${startTime.toUTCString()}`)
return
}
const totalTransactions = mints.total.add(multiMints.total).add(redeems.total).add(multiRedeems.total).add(swaps.total)
const totalFeeTransactions = redeems.total.add(multiRedeems.total).add(swaps.total)
console.log(`\nFees since ${startTime.toUTCString()}`)
console.log(" mBTC Volume\t Fees\t\t Fee %")
Expand All @@ -291,11 +281,7 @@ const outputFees = (
)
const periodSeconds = BN.from(currentTime.valueOf() - startTime.valueOf()).div(1000)
const liquidityUtilization = totalFeeTransactions.mul(100).div(balances.total)
const totalApy = totalFees
.mul(100)
.mul(ONE_YEAR)
.div(balances.save)
.div(periodSeconds)
const totalApy = totalFees.mul(100).mul(ONE_YEAR).div(balances.save).div(periodSeconds)
console.log(`Total Txs ${formatUnits(totalTransactions).padEnd(22)}`)
console.log(`Savings ${formatUnits(balances.save).padEnd(22)} ${formatUnits(totalFees).padEnd(20)} APY ${totalApy}%`)
console.log(
Expand Down