Skip to content

Instantly share code, notes, and snippets.

@DanielVF
Last active February 2, 2021 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DanielVF/3f0d3279480a43a3b7256526ea7e5bb0 to your computer and use it in GitHub Desktop.
Save DanielVF/3f0d3279480a43a3b7256526ea7e5bb0 to your computer and use it in GitHub Desktop.
Compound USDT change proposal
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
{"pct": [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], "supply": [147831050226, 139906249997, 132111681885, 124447345887, 116913242007, 109509370240, 102235730591, 95092323057, 88079147638, 81196204336, 74443493148, 67821014077, 61328767121, 54966752281, 48734969556, 42633418947, 36662100454, 30821014077, 25110159815, 19529537669, 14079147639, 13729368814, 13383989724, 13043010367, 12706430744, 12374250854, 12046470698, 11723090276, 11404109587, 11089528632, 10779347410, 10473565923, 10172184169, 9875202148, 9582619861, 9294437308, 9010654488, 8731271402, 8456288050, 8185704432, 7919520547, 7657736395, 7400351977, 7147367293, 6898782343, 6654597126, 6414811642, 6179425893, 5948439877, 5721853595, 5499667046, 5281880231, 5068493149, 4859505802, 4654918188, 4454730307, 4258942160, 4067553747, 3880565067, 3697976121, 3519786909, 3345997430, 3176607686, 3011617674, 2851027396, 2694836852, 2543046042, 2395654965, 2252663622, 2114072012, 1979880136, 1850087994, 1724695585, 1603702910, 1487109969, 1374916761, 1267123287, 1163729547, 1064735540, 970141266, 879946727, 794151921, 712756849, 635761510, 563165905, 494970034, 431173896, 371777492, 316780821, 266183885, 219986681, 178189212, 140791476, 107793474, 79195205, 54996670, 35197869, 19798801, 8799467, 2199866, 0], "borrow": [159817351596, 152777777776, 145738203956, 138698630135, 131659056315, 124619482494, 117579908674, 110540334854, 103500761033, 96461187213, 89421613392, 82382039572, 75342465752, 68302891931, 61263318111, 54223744290, 47184170470, 40144596650, 33105022829, 26065449009, 19025875189, 18788051749, 18550228309, 18312404869, 18074581430, 17836757990, 17598934550, 17361111110, 17123287670, 16885464230, 16647640790, 16409817351, 16171993911, 15934170471, 15696347031, 15458523591, 15220700151, 14982876711, 14745053271, 14507229832, 14269406392, 14031582952, 13793759512, 13555936072, 13318112632, 13080289192, 12842465752, 12604642313, 12366818873, 12128995433, 11891171993, 11653348553, 11415525113, 11177701673, 10939878234, 10702054794, 10464231354, 10226407914, 9988584474, 9750761034, 9512937594, 9275114154, 9037290715, 8799467275, 8561643835, 8323820395, 8085996955, 7848173515, 7610350075, 7372526635, 7134703196, 6896879756, 6659056316, 6421232876, 6183409436, 5945585996, 5707762556, 5469939117, 5232115677, 4994292237, 4756468797, 4518645357, 4280821917, 4042998477, 3805175037, 3567351598, 3329528158, 3091704718, 2853881278, 2616057838, 2378234398, 2140410958, 1902587518, 1664764079, 1426940639, 1189117199, 951293759, 713470319, 475646879, 237823439, 0], "borrow_apy": [0.3993389871711319, 0.37878127570658227, 0.35852557776875726, 0.33856745647625885, 0.3189025401298937, 0.29952652125508084, 0.2804351556583293, 0.2616242614975768, 0.24308971836618443, 0.22482746639039042, 0.20683350534002232, 0.1891038937522731, 0.1716347480683511, 0.15442224178281205, 0.1374626046053895, 0.12075212163513815, 0.10428713254670985, 0.0880640307885836, 0.07207926229260075, 0.056329326704831484, 0.040810773593610294, 0.04029049856594602, 0.03977048312511622, 0.03925072811214503, 0.03873123242655141, 0.038211996908519064, 0.03769302045866696, 0.0371743039163388, 0.03665584618325224, 0.036137647614215895, 0.03561970856313468, 0.03510202793337269, 0.03458460656217821, 0.03406744335401091, 0.033550539145282166, 0.03303389284154701, 0.03251750527838082, 0.032001375362432416, 0.03148550344691703, 0.030969889884150836, 0.030454533582421783, 0.029939435375218704, 0.029424594171920226, 0.028910010805182518, 0.028395684185474446, 0.02788161514461973, 0.027367802594175927, 0.02685424688577287, 0.026340948370144668, 0.0258279059604809, 0.025315120486528064, 0.024802590862561757, 0.02429031791749936, 0.023778300566701827, 0.023266539638257866, 0.022755034048612455, 0.022243784147816026, 0.021732790285028614, 0.021222051378318785, 0.02071156825370779, 0.02020133983034622, 0.019691366933429766, 0.019181648483188818, 0.018672185303994615, 0.018162976317156687, 0.017654021871154058, 0.017145322313578903, 0.016636876567357683, 0.01612868545480306, 0.015620747899918186, 0.015113064724193714, 0.014605634852708382, 0.014098459106131722, 0.013591536410616945, 0.013084867113078102, 0.012578451559546622, 0.012072288677785314, 0.011566379286414241, 0.011060722314268023, 0.010555318579148931, 0.010050167010961841, 0.009545268426691456, 0.009040621757312461, 0.008536227348181713, 0.008032085543776324, 0.007528195276673921, 0.0070245573618188395, 0.006521170732854964, 0.0060180362039130575, 0.0055151527097021535, 0.0050125210635392214, 0.004510140201198443, 0.004008010466486134, 0.00350613220233309, 0.0030045043461088827, 0.0025031277090994397, 0.00200200122973615, 0.0015011257184944782, 0.0010005001148665205, 0.0005001252285175006, 0.0], "supply_apy": [0.36451625946601296, 0.34197026255336804, 0.3201582047551925, 0.2990563079703352, 0.2786417549148752, 0.25889265256890215, 0.23978798965830572, 0.2213076031553869, 0.2034321406078119, 0.18614303154352418, 0.1694224496651633, 0.1532532888809175, 0.13761913014455662, 0.12250421627846753, 0.10789342582765937, 0.0937722465999633, 0.08012675350726783, 0.06694358589897953, 0.054209923983025377, 0.04191347222882702, 0.030042434317611777, 0.02928524521146869, 0.028538126825370158, 0.02780105803239019, 0.027074017520157367, 0.026356985228939145, 0.025649940432124207, 0.024952863652472734, 0.024265735223458984, 0.023588535289974066, 0.022921245241553923, 0.02226384627670641, 0.021616319403587436, 0.020978646870479567, 0.02035081025665253, 0.019732792378605923, 0.01912457585909344, 0.01852614360322602, 0.01793747832247017, 0.017358563485073697, 0.016789383788579748, 0.016229922310038614, 0.01568016335536071, 0.015140092455972809, 0.014609693523740086, 0.014088951695633067, 0.013577852857392214, 0.013076382695814903, 0.012584527171980886, 0.012102272048122309, 0.011629603832594482, 0.011166510250162132, 0.010712977408298574, 0.010268993102161117, 0.009834544453779959, 0.009409619798385727, 0.00899420679776064, 0.008588294795802698, 0.008191871049961552, 0.0078049259104862045, 0.007427447641257912, 0.007059426184694351, 0.006700850808885717, 0.006351711987959918, 0.00601199999108859, 0.00568170488284947, 0.005360817931523654, 0.005049330199619728, 0.004747232544207058, 0.004454517023914306, 0.004171175022078977, 0.003897199590920497, 0.003632581701099147, 0.0033773153968643665, 0.0031313926409659576, 0.0028948070626400035, 0.002667551615255448, 0.0024496204489488083, 0.0022410075056971124, 0.0020417065195459383, 0.0018517124198564883, 0.0016710194597358008, 0.0014996230867430071, 0.0013375185395032574, 0.0011847013152666008, 0.0010411667023879634, 0.0009069111821933262, 0.0007819305594012338, 0.0006662218310860002, 0.0005597817847113884, 0.0004626069982529568, 0.00037469524127109466, 0.0002960436065162497, 0.00022665084484541076, 0.00016651362942221581, 0.00011563169199435563, 7.40026866312693e-05, 4.162592493428541e-05, 1.8500041559121883e-05, 4.624861596802532e-06, 0.0]}
{"pct": [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], "supply": [113513127851, 107630244005, 101843274351, 96152218890, 90557077623, 85057850549, 79654537669, 74347138982, 69135654488, 64020084187, 59000428079, 54076686167, 49248858445, 44516944918, 39880945584, 35340860442, 30896689496, 26548432742, 22296090180, 18139661813, 14079147639, 13729368814, 13383989724, 13043010367, 12706430744, 12374250854, 12046470698, 11723090276, 11404109587, 11089528632, 10779347410, 10473565923, 10172184169, 9875202148, 9582619861, 9294437308, 9010654488, 8731271402, 8456288050, 8185704432, 7919520547, 7657736395, 7400351977, 7147367293, 6898782343, 6654597126, 6414811642, 6179425893, 5948439877, 5721853595, 5499667046, 5281880231, 5068493149, 4859505802, 4654918188, 4454730307, 4258942160, 4067553747, 3880565067, 3697976121, 3519786909, 3345997430, 3176607686, 3011617674, 2851027396, 2694836852, 2543046042, 2395654965, 2252663622, 2114072012, 1979880136, 1850087994, 1724695585, 1603702910, 1487109969, 1374916761, 1267123287, 1163729547, 1064735540, 970141266, 879946727, 794151921, 712756849, 635761510, 563165905, 494970034, 431173896, 371777492, 316780821, 266183885, 219986681, 178189212, 140791476, 107793474, 79195205, 54996670, 35197869, 19798801, 8799467, 2199866, 0], "borrow": [122716894975, 117532343986, 112347792997, 107163242007, 101978691018, 96794140029, 91609589039, 86425038050, 81240487061, 76055936071, 70871385082, 65686834093, 60502283103, 55317732114, 50133181125, 44948630135, 39764079146, 34579528157, 29394977167, 24210426178, 19025875189, 18788051749, 18550228309, 18312404869, 18074581430, 17836757990, 17598934550, 17361111110, 17123287670, 16885464230, 16647640790, 16409817351, 16171993911, 15934170471, 15696347031, 15458523591, 15220700151, 14982876711, 14745053271, 14507229832, 14269406392, 14031582952, 13793759512, 13555936072, 13318112632, 13080289192, 12842465752, 12604642313, 12366818873, 12128995433, 11891171993, 11653348553, 11415525113, 11177701673, 10939878234, 10702054794, 10464231354, 10226407914, 9988584474, 9750761034, 9512937594, 9275114154, 9037290715, 8799467275, 8561643835, 8323820395, 8085996955, 7848173515, 7610350075, 7372526635, 7134703196, 6896879756, 6659056316, 6421232876, 6183409436, 5945585996, 5707762556, 5469939117, 5232115677, 4994292237, 4756468797, 4518645357, 4280821917, 4042998477, 3805175037, 3567351598, 3329528158, 3091704718, 2853881278, 2616057838, 2378234398, 2140410958, 1902587518, 1664764079, 1426940639, 1189117199, 951293759, 713470319, 475646879, 237823439, 0], "borrow_apy": [0.29433879783741124, 0.28030711874568137, 0.26642755373769345, 0.25269845437295224, 0.23911818948368468, 0.22568514558527086, 0.2123977266845456, 0.1992543540901759, 0.18625346622509653, 0.1733935184409774, 0.16067298283470266, 0.14809034860279913, 0.13564411971222556, 0.12333281795600404, 0.11115498061613538, 0.09910916083164545, 0.08719392742668264, 0.07540786474047834, 0.06374957245915125, 0.05221766544933515, 0.040810773593610294, 0.04029049856594602, 0.03977048312511622, 0.03925072811214503, 0.03873123242655141, 0.038211996908519064, 0.03769302045866696, 0.0371743039163388, 0.03665584618325224, 0.036137647614215895, 0.03561970856313468, 0.03510202793337269, 0.03458460656217821, 0.03406744335401091, 0.033550539145282166, 0.03303389284154701, 0.03251750527838082, 0.032001375362432416, 0.03148550344691703, 0.030969889884150836, 0.030454533582421783, 0.029939435375218704, 0.029424594171920226, 0.028910010805182518, 0.028395684185474446, 0.02788161514461973, 0.027367802594175927, 0.02685424688577287, 0.026340948370144668, 0.0258279059604809, 0.025315120486528064, 0.024802590862561757, 0.02429031791749936, 0.023778300566701827, 0.023266539638257866, 0.022755034048612455, 0.022243784147816026, 0.021732790285028614, 0.021222051378318785, 0.02071156825370779, 0.02020133983034622, 0.019691366933429766, 0.019181648483188818, 0.018672185303994615, 0.018162976317156687, 0.017654021871154058, 0.017145322313578903, 0.016636876567357683, 0.01612868545480306, 0.015620747899918186, 0.015113064724193714, 0.014605634852708382, 0.014098459106131722, 0.013591536410616945, 0.013084867113078102, 0.012578451559546622, 0.012072288677785314, 0.011566379286414241, 0.011060722314268023, 0.010555318579148931, 0.010050167010961841, 0.009545268426691456, 0.009040621757312461, 0.008536227348181713, 0.008032085543776324, 0.007528195276673921, 0.0070245573618188395, 0.006521170732854964, 0.0060180362039130575, 0.0055151527097021535, 0.0050125210635392214, 0.004510140201198443, 0.004008010466486134, 0.00350613220233309, 0.0030045043461088827, 0.0025031277090994397, 0.00200200122973615, 0.0015011257184944782, 0.0010005001148665205, 0.0005001252285175006, 0.0], "supply_apy": [0.2695341044969606, 0.25392898887328075, 0.23876546246578867, 0.22403210729864975, 0.209717899304124, 0.19581219711078557, 0.18230472845501966, 0.16918557769872677, 0.1564451743867168, 0.14407427957879815, 0.1320639785928075, 0.12040566663137997, 0.10909104076043352, 0.09811208960239282, 0.08746108396140362, 0.07713056782542838, 0.06711334973065863, 0.05740249496794991, 0.0479913156518581, 0.0388733665510097, 0.030042434317611777, 0.02928524521146869, 0.028538126825370158, 0.02780105803239019, 0.027074017520157367, 0.026356985228939145, 0.025649940432124207, 0.024952863652472734, 0.024265735223458984, 0.023588535289974066, 0.022921245241553923, 0.02226384627670641, 0.021616319403587436, 0.020978646870479567, 0.02035081025665253, 0.019732792378605923, 0.01912457585909344, 0.01852614360322602, 0.01793747832247017, 0.017358563485073697, 0.016789383788579748, 0.016229922310038614, 0.01568016335536071, 0.015140092455972809, 0.014609693523740086, 0.014088951695633067, 0.013577852857392214, 0.013076382695814903, 0.012584527171980886, 0.012102272048122309, 0.011629603832594482, 0.011166510250162132, 0.010712977408298574, 0.010268993102161117, 0.009834544453779959, 0.009409619798385727, 0.00899420679776064, 0.008588294795802698, 0.008191871049961552, 0.0078049259104862045, 0.007427447641257912, 0.007059426184694351, 0.006700850808885717, 0.006351711987959918, 0.00601199999108859, 0.00568170488284947, 0.005360817931523654, 0.005049330199619728, 0.004747232544207058, 0.004454517023914306, 0.004171175022078977, 0.003897199590920497, 0.003632581701099147, 0.0033773153968643665, 0.0031313926409659576, 0.0028948070626400035, 0.002667551615255448, 0.0024496204489488083, 0.0022410075056971124, 0.0020417065195459383, 0.0018517124198564883, 0.0016710194597358008, 0.0014996230867430071, 0.0013375185395032574, 0.0011847013152666008, 0.0010411667023879634, 0.0009069111821933262, 0.0007819305594012338, 0.0006662218310860002, 0.0005597817847113884, 0.0004626069982529568, 0.00037469524127109466, 0.0002960436065162497, 0.00022665084484541076, 0.00016651362942221581, 0.00011563169199435563, 7.40026866312693e-05, 4.162592493428541e-05, 1.8500041559121883e-05, 4.624861596802532e-06, 0.0]}
# 1. Set your WEB3_INFURA_PROJECT_ID and ETHERSCAN_TOKEN environment varibles
# 2. Save this as a brownie script named new_rate.py
# 3. brownie run new_rate main --network mainnet-fork
from brownie import *
import math
import json
cusdt = Contract.from_explorer("0xf650C3d88D12dB855b8bf7D11Be6C55A4e07dCC9")
rates = Contract.from_explorer("0xfb564da37b41b2f6b6edcc3e56fbf523bd9f2012")
blocksPerYear = rates.blocksPerYear()
baseRatePerBlock = rates.baseRatePerBlock()
multiplierPerBlock = rates.multiplierPerBlock()
kink = rates.kink()
jumpMultiplierPerBlock = rates.jumpMultiplierPerBlock()
reserveFactorMantissa = cusdt.reserveFactorMantissa()
owner = rates.owner()
def apy(r):
n = blocksPerYear
r = r * blocksPerYear / 1e18
return math.pow((1 + r/n ),n) - 1
def write_usage_rates(name):
pct = []
borrow = []
supply = []
borrow_apy = []
supply_apy = []
for i in range(0,101):
pct.append(100-i)
br = rates.getBorrowRate(i*1e32, (100-i)*1e32, 0)
sr = rates.getSupplyRate(i*1e32, (100-i)*1e32, 0, reserveFactorMantissa)
borrow.append(br)
supply.append(sr)
borrow_apy.append(apy(br))
supply_apy.append(apy(sr))
with(open(name, "w") as f):
j = json.dumps({
"pct":pct,
"supply":supply,
"borrow":borrow,
"borrow_apy":borrow_apy,
"supply_apy":supply_apy
})
f.write(j)
print("100%% utilization rate: %f" % borrow_apy[0])
def try_jump_rate(jumpMultiplierPerYear):
"""Use exsisting deployed parameters except for jumpMultiplierPerYear."""
rates.updateJumpRateModel(
0,
"0x000000000000000000000000000000000000000000000000008e1bc9bf040000",
jumpMultiplierPerYear,
"0x0000000000000000000000000000000000000000000000000b1a2bc2ec500000",
{"from":owner}
)
br = rates.getBorrowRate(0*1e32, 100*1e32, 0)
return apy(br)
def main():
print("Rate before")
write_usage_rates("before.json")
print("Change to new rate")
# Old value: 1090000000000000000
print(try_jump_rate(1480000000000000000))
print("Rate after")
write_usage_rates("after.json")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment