Skip to content

Commit

Permalink
Updated mUSD-snap
Browse files Browse the repository at this point in the history
  • Loading branch information
naddison36 committed Mar 23, 2021
1 parent 9cf4757 commit 8d17fcf
Showing 1 changed file with 27 additions and 13 deletions.
40 changes: 27 additions & 13 deletions tasks/mUSD.ts
Expand Up @@ -11,8 +11,8 @@ import { Masset } from "types/generated"
import { BN, simpleToExactAmount, applyDecimals } from "@utils/math"
import { BassetStatus } from "@utils/mstable-objects"
import { MassetLibraryAddresses, Masset__factory } from "types/generated/factories/Masset__factory"
import * as MassetV2 from "../test-fork/mUSD/MassetV2.json"
import { ONE_YEAR } from "@utils/constants"
import * as MassetV2 from "../test-fork/mUSD/MassetV2.json"

// Mainnet contract addresses
const mUsdAddress = "0xe2f2a5C287993345a840Db3B0845fbC70f5935a5"
Expand All @@ -27,6 +27,7 @@ const config = {
}

interface TxSummary {
count: number
total: BN
fees: BN
}
Expand Down Expand Up @@ -174,6 +175,10 @@ const getBalances = async (masset: Masset): Promise<Balances> => {
)
console.log(`Others ${formatUnits(otherBalances).padEnd(20)} ${otherBalances.mul(100).div(mUsdBalance)}%`)

const surplus = await masset.surplus()
console.log(`Surplus ${formatUnits(surplus)}`)
console.log(`Total ${formatUnits(mUsdBalance)}`)

return {
total: mUsdBalance,
save: savingBalance,
Expand Down Expand Up @@ -206,6 +211,7 @@ const getMints = async (mBTC: Masset, fromBlock: number, startTime: Date): Promi
})
console.log(`Count ${count}, Total ${formatUnits(total)}`)
return {
count,
total,
fees: BN.from(0),
}
Expand All @@ -232,6 +238,7 @@ const getMultiMints = async (mBTC: Masset, fromBlock: number, startTime: Date):
})
console.log(`Count ${count}, Total ${formatUnits(total)}`)
return {
count,
total,
fees: BN.from(0),
}
Expand Down Expand Up @@ -263,6 +270,7 @@ const getSwaps = async (mBTC: Masset, fromBlock: number, startTime: Date): Promi
console.log(`Count ${count}, Total ${formatUnits(total)}`)

return {
count,
total,
fees,
}
Expand Down Expand Up @@ -291,6 +299,7 @@ const getRedemptions = async (mBTC: Masset, fromBlock: number, startTime: Date):
console.log(`Count ${count}, Total ${formatUnits(total)}`)

return {
count,
total,
fees,
}
Expand Down Expand Up @@ -318,6 +327,7 @@ const getMultiRedemptions = async (mBTC: Masset, fromBlock: number, startTime: D
console.log(`Count ${count}, Total ${formatUnits(total)}`)

return {
count,
total,
fees,
}
Expand All @@ -337,27 +347,31 @@ const outputFees = (
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(" mUSD Volume\t Fees\t\t Fee %")
console.log(" # mUSD Volume\t Fees\t\t Fee %")
console.log(
`Mints ${formatUnits(mints.total).padEnd(22)} ${formatUnits(mints.fees).padEnd(20)} ${mints.fees.mul(100).div(totalFees)}%`,
`Mints ${mints.count.toString().padEnd(2)} ${formatUnits(mints.total).padEnd(22)} ${formatUnits(mints.fees).padEnd(
20,
)} ${mints.fees.mul(100).div(totalFees)}%`,
)
console.log(
`Multi Mints ${formatUnits(multiMints.total).padEnd(22)} ${formatUnits(multiMints.fees).padEnd(20)} ${multiMints.fees
.mul(100)
.div(totalFees)}%`,
`Multi Mints ${multiMints.count.toString().padEnd(2)} ${formatUnits(multiMints.total).padEnd(22)} ${formatUnits(
multiMints.fees,
).padEnd(20)} ${multiMints.fees.mul(100).div(totalFees)}%`,
)
console.log(
`Redeems ${formatUnits(redeems.total).padEnd(22)} ${formatUnits(redeems.fees).padEnd(20)} ${redeems.fees
.mul(100)
.div(totalFees)}%`,
`Redeems ${redeems.count.toString().padEnd(2)} ${formatUnits(redeems.total).padEnd(22)} ${formatUnits(redeems.fees).padEnd(
20,
)} ${redeems.fees.mul(100).div(totalFees)}%`,
)
console.log(
`Multi Redeems ${formatUnits(multiRedeems.total).padEnd(22)} ${formatUnits(multiRedeems.fees).padEnd(20)} ${multiRedeems.fees
.mul(100)
.div(totalFees)}%`,
`Multi Redeems ${multiRedeems.count.toString().padEnd(2)} ${formatUnits(multiRedeems.total).padEnd(22)} ${formatUnits(
multiRedeems.fees,
).padEnd(20)} ${multiRedeems.fees.mul(100).div(totalFees)}%`,
)
console.log(
`Swaps ${formatUnits(swaps.total).padEnd(22)} ${formatUnits(swaps.fees).padEnd(20)} ${swaps.fees.mul(100).div(totalFees)}%`,
`Swaps ${swaps.count.toString().padEnd(2)} ${formatUnits(swaps.total).padEnd(22)} ${formatUnits(swaps.fees).padEnd(
20,
)} ${swaps.fees.mul(100).div(totalFees)}%`,
)
const periodSeconds = BN.from(currentTime.valueOf() - startTime.valueOf()).div(1000)
const liquidityUtilization = totalFeeTransactions.mul(100).div(balances.total)
Expand Down

0 comments on commit 8d17fcf

Please sign in to comment.