├── .gitignore ├── LICENSE ├── README.md ├── sheetScripts ├── README.md └── convex.gs └── tvl ├── README.md ├── abi.js ├── package.json └── tvl.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | config.json 3 | package-lock.json -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 convex-eth 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Convex Utilities -------------------------------------------------------------------------------- /sheetScripts/README.md: -------------------------------------------------------------------------------- 1 | # Google SpreadSheet Script 2 | 3 | ## TODO 4 | - Base Trade Fees are not included in APR functions 5 | 6 | ## How to use 7 | 8 | ### Setup 9 | ``` 10 | var ETHERSCAN_KEY = "INSERT_KEY_HERE"; 11 | ``` 12 | Replace INSERT_KEY_HERE with an etherscan API key. 13 | 14 | 15 | ### Balance 16 | Curve LP Balance: 17 | ``` 18 | =convexBalance("poolname", YourEthAddress) 19 | ``` 20 | where poolname is the name of the pool and YourEthAddress is your wallet address. To find pool names look in the json data at the bottom of the script. 21 | 22 | 23 | Staked CVX: 24 | ``` 25 | =convexStakedCVX(YourEthAddress) 26 | ``` 27 | 28 | Staked cvxCRV: 29 | ``` 30 | =convexStakedCvxCRV(YourEthAddress) 31 | ``` 32 | 33 | 34 | Sushi CVX/ETH: 35 | ``` 36 | =convexLpCVXETH(YourEthAddress) 37 | ``` 38 | 39 | Sushi cvxCrv/Crv: 40 | ``` 41 | =convexLpCvxCRVCRV(YourEthAddress) 42 | ``` 43 | 44 | 45 | ### APR 46 | 47 | Curve LP APR: 48 | ``` 49 | =convexAPR("poolname") 50 | ``` 51 | 52 | Staked CVX APR: 53 | ``` 54 | =convexStakedCVXAPR() 55 | ``` 56 | 57 | Staked cvxCRV APR: 58 | ``` 59 | =convexStakedCvxCRVAPR(YourEthAddress) 60 | ``` 61 | 62 | 63 | Sushi CVX/ETH APR: 64 | ``` 65 | =convexLpCVXETHAPR(YourEthAddress) 66 | ``` 67 | 68 | Sushi cvxCrv/Crv APR: 69 | ``` 70 | =convexLpcvxCRVCRVAPR(YourEthAddress) 71 | ``` -------------------------------------------------------------------------------- /sheetScripts/convex.gs: -------------------------------------------------------------------------------- 1 | var ETHERSCAN_KEY = "INSERT_KEY_HERE"; 2 | 3 | 4 | /// ------ Balances ------- /// 5 | 6 | function convexBalance(poolName, address) { 7 | var pool = pools.find(pool => pool.name == poolName) 8 | 9 | var bal = convexBASE(address, pool) 10 | if (isNaN(bal)) { 11 | Utilities.sleep(randomInt(500, 2000)); 12 | return convexBalance(poolName, address); 13 | } 14 | return bal; 15 | } 16 | 17 | function convexStakedCVX(address) { 18 | var stakeContract = "0xCF50b810E57Ac33B91dCF525C6ddd9881B139332"; 19 | var balance = balanceOf(address, stakeContract, 18); 20 | if (isNaN(balance)) { 21 | Utilities.sleep(randomInt(500, 1000)); 22 | return convexStakedCVX(address); 23 | } 24 | return balance; 25 | } 26 | 27 | function convexLockedCVX(address) { 28 | var lockContract = "0xD18140b4B819b895A3dba5442F959fA44994AF50"; 29 | var balance = lockedBalanceOf(address, lockContract, 18); 30 | if (isNaN(balance)) { 31 | Utilities.sleep(randomInt(500, 1000)); 32 | return convexLockedCVX(address); 33 | } 34 | return balance; 35 | } 36 | 37 | function convexStakedCvxCRV(address) { 38 | var stakeContract = "0x3Fe65692bfCD0e6CF84cB1E7d24108E434A7587e"; 39 | var balance = balanceOf(address, stakeContract, 18); 40 | if (isNaN(balance)) { 41 | Utilities.sleep(randomInt(500, 1000)); 42 | return convexStakedCvxCRV(address); 43 | } 44 | return balance; 45 | } 46 | 47 | function convexLpCVXETH(address) { 48 | var balance = masterChefBalance(address, 1); 49 | if (isNaN(balance)) { 50 | Utilities.sleep(randomInt(500, 1000)); 51 | return convexLpCVXETH(address); 52 | } 53 | return balance; 54 | } 55 | 56 | function convexLpCvxCRVCRV(address) { 57 | var balance = masterChefBalance(address, 2); 58 | if (isNaN(balance)) { 59 | Utilities.sleep(randomInt(500, 1000)); 60 | return convexLpCvxCRVCRV(address); 61 | } 62 | return balance; 63 | } 64 | 65 | //// ----------- APRs ----------- /// 66 | 67 | function convexAPR(poolName) { 68 | return convexAPRWithPrice(poolName, -1, -1); 69 | } 70 | 71 | function convexAPRWithPrice(poolName, crvPrice, cvxPrice) { 72 | var pool = pools.find(pool => pool.name == poolName) 73 | var curveSwap = pool.swap; 74 | var stakeContract = pool.crvRewards; 75 | 76 | //get reward rate 77 | var rate = rewardRate(stakeContract); 78 | 79 | //get virtual price 80 | var virtualPrice = 1; 81 | if(pool.isV2 == undefined || pool.isV2 == false){ 82 | virtualPrice = curveLpValue(1, curveSwap); 83 | }else{ 84 | virtualPrice = curveV2LpValue(pool,pool.currency); 85 | } 86 | 87 | //get supply 88 | var supply = supplyOf(stakeContract); 89 | 90 | //virtual supply 91 | supply = supply * virtualPrice; 92 | 93 | //crv per underlying per second 94 | var crvPerUnderlying = rate / supply; 95 | 96 | //crv per year 97 | var crvPerYear = crvPerUnderlying * 86400 * 365; 98 | var cvxPerYear = getCVXMintAmount(crvPerYear); 99 | 100 | if (cvxPrice <= 0) 101 | cvxPrice = getPrice(cvxAddress, pool.currency); 102 | 103 | if (crvPrice <= 0) 104 | crvPrice = getPrice(crvAddress, pool.currency); 105 | 106 | var apr = (crvPerYear * crvPrice); 107 | apr += (cvxPerYear * cvxPrice); 108 | Logger.log("apr of crv/cvx: " +apr); 109 | if (pool.extras != undefined && pool.extras.length > 0) { 110 | for (var i in pool.extras) { 111 | var ex = pool.extras[i]; 112 | var exrate = rewardRate(ex.contract); 113 | var perUnderlying = exrate / supply; 114 | var perYear = perUnderlying * 86400 * 365; 115 | var price = getPrice(ex.token, pool.currency); 116 | Logger.log("extra per year: " +perYear +" price: " +price +" apr: " +(perYear*price) ); 117 | apr += (perYear * price); 118 | } 119 | } 120 | 121 | if (isNaN(apr)) { 122 | Utilities.sleep(randomInt(500, 1000)); 123 | return convexAPRWithPrice(poolName, crvPrice, cvxPrice); 124 | } 125 | 126 | return apr; 127 | } 128 | 129 | //locked CVX APR 130 | function convexLockedCVXAPR() { 131 | var stakeContract = "0xD18140b4B819b895A3dba5442F959fA44994AF50"; 132 | var rate = rewardRateOf(stakeContract,cvxCrvAddress); 133 | var supply = boostedSupply(stakeContract); 134 | var cvxPrice = getPrice(cvxAddress, "USD"); 135 | supply *= cvxPrice; 136 | rate /= supply; 137 | 138 | var crvPerYear = rate * 86400 * 365; 139 | var crvPrice = getPrice(crvAddress, "USD"); 140 | var apr = crvPerYear * crvPrice; 141 | 142 | if (isNaN(apr)) { 143 | Utilities.sleep(randomInt(500, 1000)); 144 | return convexLockedCVXAPR(); 145 | } 146 | return apr; 147 | } 148 | 149 | 150 | //staked CVX APR 151 | function convexStakedCVXAPR() { 152 | var stakeContract = "0xCF50b810E57Ac33B91dCF525C6ddd9881B139332"; 153 | var rate = rewardRate(stakeContract); 154 | var supply = supplyOf(stakeContract); 155 | var cvxPrice = getPrice(cvxAddress, "USD"); 156 | supply *= cvxPrice; 157 | rate /= supply; 158 | 159 | var crvPerYear = rate * 86400 * 365; 160 | var crvPrice = getPrice(crvAddress, "USD"); 161 | var apr = crvPerYear * crvPrice; 162 | 163 | if (isNaN(apr)) { 164 | Utilities.sleep(randomInt(500, 1000)); 165 | return convexStakedCVXAPR(); 166 | } 167 | return apr; 168 | } 169 | 170 | 171 | //staked cvxCRV apr 172 | function convexStakedCvxCRVAPR() { 173 | var stakeContract = "0x3Fe65692bfCD0e6CF84cB1E7d24108E434A7587e"; 174 | var theepoolstakeContract = "0x7091dbb7fcbA54569eF1387Ac89Eb2a5C9F6d2EA"; 175 | var curveSwap = "0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7"; 176 | 177 | var rate = rewardRate(stakeContract); 178 | var threerate = rewardRate(theepoolstakeContract); 179 | var supply = supplyOf(stakeContract); 180 | 181 | var virtualPrice = curveLpValue(1, curveSwap); 182 | var crvPrice = getPrice(crvAddress, "USD"); 183 | var cvxPrice = getPrice(cvxAddress, "USD"); 184 | 185 | supply *= crvPrice; 186 | rate /= supply; 187 | threerate /= supply; 188 | 189 | var crvPerYear = rate * 86400 * 365; 190 | var cvxPerYear = getCVXMintAmount(crvPerYear); 191 | var threepoolPerYear = threerate * 86400 * 365; 192 | 193 | var apr = (crvPerYear * crvPrice) + (cvxPerYear * cvxPrice) + (threepoolPerYear * virtualPrice); 194 | 195 | if (isNaN(apr)) { 196 | Utilities.sleep(randomInt(500, 1000)); 197 | return convexStakedCvxCRVAPR(); 198 | } 199 | return apr; 200 | } 201 | 202 | function convexLpCVXETHAPR() { 203 | 204 | var stakeContract = "0x9e01aaC4b3e8781a85b21d9d9F848e72Af77B362"; 205 | var rate = rewardRate(stakeContract); 206 | var supply = supplyOf(stakeContract); 207 | var slpBalance = balanceOf("0x05767d9EF41dC40689678fFca0608878fb3dE906", cvxAddress, 18); 208 | var slpSupply = supplyOf("0x05767d9EF41dC40689678fFca0608878fb3dE906"); 209 | var slpBToS = (slpBalance * 2) / slpSupply; //approx value of slp in cvx terms by multiplying cvx balance by 2 210 | 211 | supply *= slpBToS; 212 | var cvxPrice = getPrice(cvxAddress, "USD"); 213 | 214 | supply = supply * cvxPrice; 215 | rate /= supply; 216 | 217 | var cvxPerYear = rate * 86400 * 365; 218 | 219 | var apr = (cvxPerYear * cvxPrice); 220 | 221 | var totalAlloc = totalAllocPoint(); 222 | var info = poolInfo(1); 223 | var alloc = info.result.slice(130); 224 | alloc = parseInt(alloc, 16) 225 | 226 | var sushiRate = sushiPerBlock() * (alloc / totalAlloc); 227 | 228 | var sushiPrice = getPrice("0x6B3595068778DD592e39A122f4f5a5cF09C90fE2", "USD"); 229 | 230 | sushiRate /= supply; 231 | var sushiPerYear = sushiRate * 6400 * 365; 232 | var sushiApr = (sushiPerYear * sushiPrice); 233 | //Logger.log("sushi apr: " +sushiApr); 234 | 235 | apr += sushiApr; 236 | 237 | //TODO: base trade fees 238 | 239 | if (isNaN(apr)) { 240 | Utilities.sleep(randomInt(500, 1000)); 241 | return convexLpCVXETHAPR(); 242 | } 243 | 244 | Logger.log("cvx slp apr: " + apr); 245 | return apr; 246 | } 247 | 248 | function convexLpcvxCRVCRVAPR() { 249 | 250 | var stakeContract = "0x1FD97b5E5a257B0B9b9A42A96BB8870Cbdd1Eb79"; 251 | var rate = rewardRate(stakeContract); 252 | var supply = supplyOf(stakeContract); 253 | var slpBalance = balanceOf("0x33F6DDAEa2a8a54062E021873bCaEE006CdF4007", cvxCrvAddress, 18); 254 | var slpSupply = supplyOf("0x33F6DDAEa2a8a54062E021873bCaEE006CdF4007"); 255 | var slpBToS = (slpBalance * 2) / slpSupply; //approx value of slp in cvxcrv terms by multiplying cvxcrv balance by 2 256 | 257 | supply *= slpBToS; 258 | var cvxcrvPrice = getPrice(cvxCrvAddress, "USD"); 259 | var cvxPrice = getPrice(cvxAddress, "USD"); 260 | 261 | supply = supply * cvxcrvPrice; 262 | rate /= supply; 263 | 264 | var cvxPerYear = rate * 86400 * 365; 265 | 266 | var apr = (cvxPerYear * cvxPrice); 267 | //Logger.log("cvx apr: " +apr); 268 | 269 | var totalAlloc = totalAllocPoint(); 270 | var info = poolInfo(1); 271 | var alloc = info.result.slice(130); 272 | alloc = parseInt(alloc, 16) 273 | 274 | var sushiRate = sushiPerBlock() * (alloc / totalAlloc); 275 | 276 | var sushiPrice = getPrice("0x6B3595068778DD592e39A122f4f5a5cF09C90fE2", "USD"); 277 | 278 | sushiRate /= supply; 279 | var sushiPerYear = sushiRate * 6400 * 365; 280 | var sushiApr = (sushiPerYear * sushiPrice); 281 | //Logger.log("sushi apr: " +sushiApr); 282 | 283 | apr += sushiApr; 284 | 285 | //TODO: base trade fees 286 | 287 | if (isNaN(apr)) { 288 | Utilities.sleep(randomInt(500, 1000)); 289 | return convexLpcvxCRVCRVAPR(); 290 | } 291 | 292 | Logger.log("cvxcrv slp apr: " + apr); 293 | return apr; 294 | } 295 | 296 | ////--------------- Util -------------------/// 297 | 298 | let crvAddress = "0xD533a949740bb3306d119CC777fa900bA034cd52"; 299 | let cvxAddress = "0x4e3FBD56CD56c3e72c1403e103b45Db9da5B9D2B"; 300 | let cvxCrvAddress = "0x62B9c7356A2Dc64a1969e19C23e4f579F9810Aa7"; 301 | 302 | let cliffSize = 100000; // * 1e18; //new cliff every 100,000 tokens 303 | let cliffCount = 1000; // 1,000 cliffs 304 | let maxSupply = 100000000; // * 1e18; //100 mil max supply 305 | 306 | function getCVXMintAmount(crvEarned) { 307 | //first get total supply 308 | var cvxSupply = supplyOf(cvxAddress); 309 | //get current cliff 310 | var currentCliff = cvxSupply / cliffSize; 311 | //if current cliff is under the max 312 | if (currentCliff < cliffCount) { 313 | //get remaining cliffs 314 | var remaining = cliffCount - currentCliff; 315 | 316 | //multiply ratio of remaining cliffs to total cliffs against amount CRV received 317 | var cvxEarned = crvEarned * remaining / cliffCount; 318 | 319 | //double check we have not gone over the max supply 320 | var amountTillMax = maxSupply - cvxSupply; 321 | if (cvxEarned > amountTillMax) { 322 | cvxEarned = amountTillMax; 323 | } 324 | return cvxEarned; 325 | } 326 | return 0; 327 | } 328 | 329 | function convertRate(rewards, compareTo) { 330 | var crvRate = getPrice(crvAddress, compareTo); 331 | var cvxRate = getPrice(cvxAddress, compareTo); 332 | 333 | rewards[0] = (rewards[0] * crvRate); 334 | rewards[1] = (rewards[1] * cvxRate); 335 | return rewards[0] + rewards[1]; 336 | } 337 | 338 | function balanceOf(address, contract, decimals) { 339 | var balanceOfHex = "70a08231"; 340 | address = padHex(address); 341 | var url = "https://api.etherscan.io/api?module=proxy&action=eth_call&to=" + contract + "&data=0x" + balanceOfHex + address + "&tag=latest&apikey=" + ETHERSCAN_KEY; 342 | var response = UrlFetchApp.fetch(url); 343 | var json = response.getContentText(); 344 | var data = JSON.parse(json); 345 | // var hexValue = data.result; 346 | // var decimal = Math.pow(10,18); 347 | var balance = Number(data.result) / Math.pow(10, decimals); 348 | 349 | return balance; 350 | } 351 | 352 | function lockedBalanceOf(address, contract, decimals) { 353 | var lockedBalanceOfHex = "59355736"; 354 | address = padHex(address); 355 | var url = "https://api.etherscan.io/api?module=proxy&action=eth_call&to=" + contract + "&data=0x" + lockedBalanceOfHex + address + "&tag=latest&apikey=" + ETHERSCAN_KEY; 356 | var response = UrlFetchApp.fetch(url); 357 | var json = response.getContentText(); 358 | var data = JSON.parse(json); 359 | // var hexValue = data.result; 360 | // var decimal = Math.pow(10,18); 361 | var balance = Number(data.result) / Math.pow(10, decimals); 362 | 363 | return balance; 364 | } 365 | 366 | function earned(address, contract) { 367 | var earned = "008cc262"; 368 | address = padHex(address); 369 | var url = "https://api.etherscan.io/api?module=proxy&action=eth_call&to=" + contract + "&data=0x" + earned + address + "&tag=latest&apikey=" + ETHERSCAN_KEY; 370 | var response = UrlFetchApp.fetch(url); 371 | var json = response.getContentText(); 372 | var data = JSON.parse(json); 373 | var hexValue = data.result; 374 | var decimal = Math.pow(10, 18); 375 | var supply = parseInt(hexValue, 16) / decimal; 376 | return supply; 377 | } 378 | 379 | function supplyOf(contract) { 380 | var totalSupply = "18160ddd"; 381 | var url = "https://api.etherscan.io/api?module=proxy&action=eth_call&to=" + contract + "&data=0x" + totalSupply + "&tag=latest&apikey=" + ETHERSCAN_KEY; 382 | var response = UrlFetchApp.fetch(url); 383 | var json = response.getContentText(); 384 | var data = JSON.parse(json); 385 | var hexValue = data.result; 386 | var decimal = Math.pow(10, 18); 387 | var supply = parseInt(hexValue, 16) / decimal; 388 | return supply; 389 | } 390 | 391 | function boostedSupply(contract) { 392 | var boostedSupply = "75aadf61"; 393 | var url = "https://api.etherscan.io/api?module=proxy&action=eth_call&to=" + contract + "&data=0x" + boostedSupply + "&tag=latest&apikey=" + ETHERSCAN_KEY; 394 | var response = UrlFetchApp.fetch(url); 395 | var json = response.getContentText(); 396 | var data = JSON.parse(json); 397 | var hexValue = data.result; 398 | var decimal = Math.pow(10, 18); 399 | var supply = parseInt(hexValue, 16) / decimal; 400 | return supply; 401 | } 402 | 403 | function curveLpValue(amount, swapAddress) { 404 | var virtualPriceHash = "bb7b8b80"; 405 | 406 | var swapurl = "https://api.etherscan.io/api?module=proxy&action=eth_call&to=" + swapAddress + "&data=0x" + virtualPriceHash + "&tag=latest&apikey=" + ETHERSCAN_KEY; 407 | var swapresponse = UrlFetchApp.fetch(swapurl); 408 | var json = swapresponse.getContentText(); 409 | var data = JSON.parse(json); 410 | var hexValue = data.result.slice(0, 66); 411 | var priceDecimal = Math.pow(10, 18); 412 | var pricePerShare = parseInt(hexValue, 16) / priceDecimal; 413 | 414 | return amount * pricePerShare; 415 | } 416 | 417 | function curveV2LpValue(pool, currencyType){ 418 | //get amount of tokens 419 | var supply = supplyOf(pool.lptoken); 420 | //Logger.log("supply: " +supply); 421 | var total = 0; 422 | for(var i=0; i < pool.coins.length; i++){ 423 | var bal = balanceOf(pool.swap,pool.coins[i],pool.coinDecimals[i]) 424 | //Logger.log("bal: " +i +" = " +bal); 425 | var price = getPrice(pool.coins[i],currencyType); 426 | //Logger.log("price: " +i +" = " +price); 427 | total += (bal*price); 428 | } 429 | 430 | var value = total / supply; 431 | if (isNaN(value)) { 432 | Utilities.sleep(randomInt(500, 1000)); 433 | return curveV2LpValue(pool,currencyType); 434 | } 435 | 436 | return value; 437 | } 438 | 439 | function convexBASE(address, pool) { 440 | var curveSwap = pool.swap; 441 | var depositToken = pool.token; 442 | var stakeContract = pool.crvRewards; 443 | 444 | var stakedBalance = balanceOf(address, stakeContract, 18); 445 | var heldBalance = balanceOf(address, depositToken, 18); 446 | 447 | if(pool.isV2 != undefined && pool.isV2 == true){ 448 | return curveV2LpValue(pool,pool.currency) * (stakedBalance+heldBalance); 449 | } 450 | return curveLpValue(stakedBalance + heldBalance, curveSwap); 451 | } 452 | 453 | 454 | function rewardRate(contract) { 455 | var rewardRate = "7b0a47ee"; 456 | var url = "https://api.etherscan.io/api?module=proxy&action=eth_call&to=" + contract + "&data=0x" + rewardRate + "&tag=latest&apikey=" + ETHERSCAN_KEY; 457 | var response = UrlFetchApp.fetch(url); 458 | var json = response.getContentText(); 459 | var data = JSON.parse(json); 460 | var hexValue = data.result; 461 | var decimal = Math.pow(10, 18); 462 | var rate = parseInt(hexValue, 16) / decimal; 463 | return rate; 464 | } 465 | 466 | function rewardRateOf(contract, token) { 467 | var rewardData = "48e5d9f8"; 468 | var tokenPad = padHex(token); 469 | var url = "https://api.etherscan.io/api?module=proxy&action=eth_call&to=" + contract + "&data=0x" + rewardData +tokenPad + "&tag=latest&apikey=" + ETHERSCAN_KEY; 470 | var response = UrlFetchApp.fetch(url); 471 | var json = response.getContentText(); 472 | // Logger.log("json: " +json); 473 | var data = JSON.parse(json); 474 | var result = data.result; 475 | result = "0x"+result.slice(130,194) 476 | var decimal = Math.pow(10, 18); 477 | var rate = parseInt(result, 16) / decimal; 478 | // Logger.log("rate: " +rate); 479 | return rate; 480 | } 481 | 482 | function totalAllocPoint() { 483 | var sushiChef = "0xEF0881eC094552b2e128Cf945EF17a6752B4Ec5d" 484 | var sig = "17caf6f1"; 485 | var url = "https://api.etherscan.io/api?module=proxy&action=eth_call&to=" + sushiChef + "&data=0x" + sig + "&tag=latest&apikey=" + ETHERSCAN_KEY; 486 | var response = UrlFetchApp.fetch(url); 487 | var json = response.getContentText(); 488 | var data = JSON.parse(json); 489 | var hexValue = data.result; 490 | return parseInt(hexValue, 16); 491 | } 492 | 493 | function sushiPerBlock() { 494 | var sushiChef = "0xEF0881eC094552b2e128Cf945EF17a6752B4Ec5d" 495 | var sig = "b0bcf42a"; 496 | var url = "https://api.etherscan.io/api?module=proxy&action=eth_call&to=" + sushiChef + "&data=0x" + sig + "&tag=latest&apikey=" + ETHERSCAN_KEY; 497 | var response = UrlFetchApp.fetch(url); 498 | var json = response.getContentText(); 499 | var data = JSON.parse(json); 500 | var hexValue = data.result; 501 | var decimal = Math.pow(10, 18); 502 | var rate = parseInt(hexValue, 16) / decimal; 503 | return rate; 504 | } 505 | 506 | function poolInfo(pid) { 507 | var sushiChef = "0xEF0881eC094552b2e128Cf945EF17a6752B4Ec5d" 508 | var sig = "1526fe27"; //poolInfo(uint256) 509 | pid = padHex("" + pid); 510 | var url = "https://api.etherscan.io/api?module=proxy&action=eth_call&to=" + sushiChef + "&data=0x" + sig + pid + "&tag=latest&apikey=" + ETHERSCAN_KEY; 511 | var response = UrlFetchApp.fetch(url); 512 | var json = response.getContentText(); 513 | var data = JSON.parse(json); 514 | return data; 515 | } 516 | 517 | 518 | function masterChefBalance(address, pid) { 519 | var stakeContract = "0xEF0881eC094552b2e128Cf945EF17a6752B4Ec5d"; 520 | address = padHex(address) 521 | var pidpad = padHex("" + pid); 522 | 523 | var userInfoHex = "93f1a40b"; //uint256,address 524 | var url = "https://api.etherscan.io/api?module=proxy&action=eth_call&to=" + stakeContract + "&data=0x" + userInfoHex + pidpad + address + "&tag=latest" + ETHERSCAN_KEY; 525 | var response = UrlFetchApp.fetch(url); 526 | var json = response.getContentText(); 527 | var data = JSON.parse(json); 528 | var hexValue = data.result; 529 | var amountHex = hexValue.substring(hexValue.length - 128, 66); 530 | var priceDecimal = Math.pow(10, 18); 531 | var lpTokenBalance = parseInt(amountHex, 16) / priceDecimal; 532 | Logger.log(lpTokenBalance); 533 | 534 | var balance = 0; 535 | if (pid == 2) { 536 | var tSupply = supplyOf("0x33F6DDAEa2a8a54062E021873bCaEE006CdF4007", 18); 537 | var sharePerc = lpTokenBalance / tSupply; 538 | Logger.log("share: " + sharePerc); 539 | var contractTokenBalance = balanceOf("0x33F6DDAEa2a8a54062E021873bCaEE006CdF4007", "0x62B9c7356A2Dc64a1969e19C23e4f579F9810Aa7", 18); 540 | //var contractTokenBalanceCrv = balanceOf("0x33F6DDAEa2a8a54062E021873bCaEE006CdF4007", crvAddress, 18); 541 | Logger.log("cvxcrv on lp: " + contractTokenBalance); 542 | // Logger.log("crv on lp: " +contractTokenBalanceCrv); 543 | balance = contractTokenBalance * sharePerc; 544 | // var crvBalance = contractTokenBalanceCrv * sharePerc; 545 | } else if (pid == 1) { 546 | var tSupply = supplyOf("0x05767d9EF41dC40689678fFca0608878fb3dE906", 18); 547 | var sharePerc = lpTokenBalance / tSupply; 548 | Logger.log("share: " + sharePerc); 549 | var contractTokenBalance = balanceOf("0x05767d9EF41dC40689678fFca0608878fb3dE906", "0x4e3FBD56CD56c3e72c1403e103b45Db9da5B9D2B", 18); 550 | // var contractTokenBalanceWeth = balanceOf("0x05767d9EF41dC40689678fFca0608878fb3dE906", "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", 18); 551 | Logger.log("cvx on lp: " + contractTokenBalance); 552 | // Logger.log("weth on lp: " +contractTokenBalanceWeth); 553 | balance = contractTokenBalance * sharePerc; 554 | //var wethBalance = contractTokenBalanceCrv * sharePerc; 555 | } 556 | 557 | 558 | return balance * 2; //can just approx value in cvx or cvxcrv by doubling 559 | 560 | } 561 | 562 | 563 | function padHex(hexstring, intSize = 256) { 564 | hexstring = hexstring.replace("0x", ""); 565 | 566 | var length = (intSize / 4) - hexstring.length; 567 | for (var i = 0; i < length; i++) { 568 | hexstring = "0" + hexstring; 569 | } 570 | return hexstring; 571 | } 572 | 573 | function numberToPaddedHex(number, intSize = 256) { 574 | var hexstr = number.toString(16); 575 | return padHex(hexstr, intSize); 576 | } 577 | 578 | function BigNumber(number) { 579 | return number.toLocaleString('fullwide', { 580 | useGrouping: false 581 | }) 582 | } 583 | 584 | function randomInt(min, max) { 585 | return Math.floor(min + (Math.random() * Math.floor(max - min))); 586 | } 587 | 588 | function getPrice(contract_address, vsCoin) { 589 | var url = "https://api.coingecko.com/api/v3/simple/token_price/ethereum?contract_addresses=" + contract_address + "&vs_currencies=" + vsCoin; 590 | Logger.log(url); 591 | try { 592 | var response = UrlFetchApp.fetch(url); 593 | var json = response.getContentText(); 594 | var data = JSON.parse(json); 595 | if (isNaN(data[contract_address.toLowerCase()][vsCoin.toLowerCase()])) { 596 | Utilities.sleep(randomInt(2000, 6000)); 597 | return getPrice(contract_address, vsCoin); 598 | } else { 599 | return data[contract_address.toLowerCase()][vsCoin.toLowerCase()]; 600 | } 601 | } catch (e) { 602 | Utilities.sleep(randomInt(2000, 6000)); 603 | return getPrice(contract_address, vsCoin); 604 | } 605 | } 606 | 607 | 608 | 609 | const pools = [{ 610 | "lptoken": "0x845838DF265Dcd2c412A1Dc9e959c7d08537f8a2", 611 | "token": "0x32512Bee3848bfcBb7bEAf647aa697a100f3b706", 612 | "gauge": "0x7ca5b0a2910B33e9759DC7dDB0413949071D7575", 613 | "crvRewards": "0xf34DFF761145FF0B05e917811d488B441F33a968", 614 | "stash": "0x0000000000000000000000000000000000000000", 615 | "swap": "0xA2B47E3D5c44877cca798226B7B8118F9BFb7A56", 616 | "currency": "USD", 617 | "name": "compound", 618 | "id": 0 619 | }, 620 | { 621 | "lptoken": "0x9fC689CCaDa600B6DF723D9E47D84d76664a1F23", 622 | "token": "0xA1c3492b71938E144ad8bE4c2fB6810b01A43dD8", 623 | "gauge": "0xBC89cd85491d81C6AD2954E6d0362Ee29fCa8F53", 624 | "crvRewards": "0x8B55351ea358e5Eda371575B031ee24F462d503e", 625 | "stash": "0x0000000000000000000000000000000000000000", 626 | "swap": "0x52EA46506B9CC5Ef470C5bf89f17Dc28bB35D85C", 627 | "currency": "USD", 628 | "name": "usdt", 629 | "id": 1 630 | }, 631 | { 632 | "lptoken": "0xdF5e0e81Dff6FAF3A7e52BA697820c5e32D806A8", 633 | "token": "0x0928F6753880A03628eB0be07b77992c8af37874", 634 | "gauge": "0xFA712EE4788C042e2B7BB55E6cb8ec569C4530c1", 635 | "crvRewards": "0xd802a8351A76ED5eCd89A7502Ca615F2225A585d", 636 | "stash": "0x0000000000000000000000000000000000000000", 637 | "swap": "0x45F783CCE6B7FF23B2ab2D70e416cdb7D6055f51", 638 | "currency": "USD", 639 | "name": "ypool", 640 | "id": 2 641 | }, 642 | { 643 | "lptoken": "0x3B3Ac5386837Dc563660FB6a0937DFAa5924333B", 644 | "token": "0x59bB786F222d3f0f00B0dA31B799Fff80D552940", 645 | "gauge": "0x69Fb7c45726cfE2baDeE8317005d3F94bE838840", 646 | "crvRewards": "0x602c4cD53a715D8a7cf648540FAb0d3a2d546560", 647 | "stash": "0x0000000000000000000000000000000000000000", 648 | "swap": "0x79a8C46DeA5aDa233ABaFFD40F3A0A2B1e5A4F27", 649 | "currency": "USD", 650 | "name": "busd", 651 | "id": 3 652 | }, 653 | { 654 | "lptoken": "0xC25a3A3b969415c80451098fa907EC722572917F", 655 | "token": "0x11D200ef1409cecA8D6d23e6496550f707772F11", 656 | "gauge": "0xA90996896660DEcC6E997655E065b23788857849", 657 | "crvRewards": "0x22eE18aca7F3Ee920D01F25dA85840D12d98E8Ca", 658 | "stash": "0xD2f2B9504Ef708b9f3Bc53f1525353bAaE1B17e4", 659 | "swap": "0xA5407eAE9Ba41422680e2e00537571bcC53efBfD", 660 | "currency": "USD", 661 | "name": "susd", 662 | "extras": [{ 663 | "contract": "0x81fCe3E10D12Da6c7266a1A169c4C96813435263", 664 | "token": "0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f", 665 | "name": "SNX" 666 | }], 667 | "id": 4 668 | }, 669 | { 670 | "lptoken": "0xD905e2eaeBe188fc92179b6350807D8bd91Db0D8", 671 | "token": "0x2eA94b0d3349A284488ACF2934E494b2f58ef647", 672 | "gauge": "0x64E3C23bfc40722d3B649844055F1D51c1ac041d", 673 | "crvRewards": "0xe3DaafC8C14147d5B4A7a56F0BfdED240158e51e", 674 | "stash": "0x0000000000000000000000000000000000000000", 675 | "swap": "0x06364f10B501e868329afBc005b3492902d6C763", 676 | "currency": "USD", 677 | "name": "pax", 678 | "id": 5 679 | }, 680 | { 681 | "lptoken": "0x49849C98ae39Fff122806C06791Fa73784FB3675", 682 | "token": "0x74b79021Ea6De3f0D1731fb8BdfF6eE7DF10b8Ae", 683 | "gauge": "0xB1F2cdeC61db658F091671F5f199635aEF202CAC", 684 | "crvRewards": "0x8E299C62EeD737a5d5a53539dF37b5356a27b07D", 685 | "stash": "0x0000000000000000000000000000000000000000", 686 | "swap": "0x93054188d876f558f4a66B2EF1d97d16eDf0895B", 687 | "currency": "BTC", 688 | "name": "ren", 689 | "id": 6 690 | }, 691 | { 692 | "lptoken": "0x075b1bb99792c9E1041bA13afEf80C91a1e70fB3", 693 | "token": "0xbA723E335eC2939D52a2efcA2a8199cb4CB93cC3", 694 | "gauge": "0x705350c4BcD35c9441419DdD5d2f097d7a55410F", 695 | "crvRewards": "0xd727A5A6D1C7b31Ff9Db4Db4d24045B7dF0CFF93", 696 | "stash": "0x7B3EE538398829c96E4B187216c7aB2946A620C4", 697 | "swap": "0x7fC77b5c7614E1533320Ea6DDc2Eb61fa00A9714", 698 | "currency": "BTC", 699 | "name": "sbtc", 700 | "id": 7 701 | }, 702 | { 703 | "lptoken": "0xb19059ebb43466C323583928285a49f558E572Fd", 704 | "token": "0x33c00bF8CFDf42929E0884d230A55F963221f8f3", 705 | "gauge": "0x4c18E409Dc8619bFb6a1cB56D114C3f592E0aE79", 706 | "crvRewards": "0x618BD6cBA676a46958c63700C04318c84a7b7c0A", 707 | "stash": "0x0000000000000000000000000000000000000000", 708 | "swap": "0x4CA9b3063Ec5866A4B82E437059D2C43d1be596F", 709 | "currency": "BTC", 710 | "name": "hbtc", 711 | "id": 8 712 | }, 713 | { 714 | "lptoken": "0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490", 715 | "token": "0x30D9410ED1D5DA1F6C8391af5338C93ab8d4035C", 716 | "gauge": "0xbFcF63294aD7105dEa65aA58F8AE5BE2D9d0952A", 717 | "crvRewards": "0x689440f2Ff927E1f24c72F1087E1FAF471eCe1c8", 718 | "stash": "0x0000000000000000000000000000000000000000", 719 | "swap": "0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7", 720 | "currency": "USD", 721 | "name": "3pool", 722 | "id": 9 723 | }, 724 | { 725 | "lptoken": "0xD2967f45c4f384DEEa880F807Be904762a3DeA07", 726 | "token": "0x15c2471ef46Fa721990730cfa526BcFb45574576", 727 | "gauge": "0xC5cfaDA84E902aD92DD40194f0883ad49639b023", 728 | "crvRewards": "0x7A7bBf95C44b144979360C3300B54A7D34b44985", 729 | "stash": "0x0000000000000000000000000000000000000000", 730 | "swap": "0x4f062658EaAF2C1ccf8C8e36D6824CDf41167956", 731 | "currency": "USD", 732 | "name": "gusd", 733 | "id": 10 734 | }, 735 | { 736 | "lptoken": "0x5B5CFE992AdAC0C9D48E05854B2d91C73a003858", 737 | "token": "0xe4de776C0eA0974bfA39B8cbB9491091C8cDc1ff", 738 | "gauge": "0x2db0E83599a91b508Ac268a6197b8B14F5e72840", 739 | "crvRewards": "0x353e489311b21355461353fEC2d02B73EF0eDe7f", 740 | "stash": "0x0000000000000000000000000000000000000000", 741 | "swap": "0x3eF6A01A0f81D6046290f3e2A8c5b843e738E604", 742 | "currency": "USD", 743 | "name": "husd", 744 | "id": 11 745 | }, 746 | { 747 | "lptoken": "0x97E2768e8E73511cA874545DC5Ff8067eB19B787", 748 | "token": "0x47941F99F4371CC26637CaEdBbd8Ba5F4bfE5149", 749 | "gauge": "0xC2b1DF84112619D190193E48148000e3990Bf627", 750 | "crvRewards": "0xa50e9071aCaD20b31cd2bbe4dAa816882De82BBe", 751 | "stash": "0x0000000000000000000000000000000000000000", 752 | "swap": "0x3E01dD8a5E1fb3481F0F589056b428Fc308AF0Fb", 753 | "currency": "USD", 754 | "name": "usdk", 755 | "id": 12 756 | }, 757 | { 758 | "lptoken": "0x4f3E8F405CF5aFC05D68142F3783bDfE13811522", 759 | "token": "0x3689f325E88c2363274E5F3d44b6DaB8f9e1f524", 760 | "gauge": "0xF98450B5602fa59CC66e1379DFfB6FDDc724CfC4", 761 | "crvRewards": "0x4a2631d090e8b40bBDe245e687BF09e5e534A239", 762 | "stash": "0x0000000000000000000000000000000000000000", 763 | "swap": "0x0f9cb53Ebe405d49A0bbdBD291A65Ff571bC83e1", 764 | "currency": "USD", 765 | "name": "usdn", 766 | "id": 13 767 | }, 768 | { 769 | "lptoken": "0x1AEf73d49Dedc4b1778d0706583995958Dc862e6", 770 | "token": "0xd34d466233c5195193dF712936049729140DBBd7", 771 | "gauge": "0x5f626c30EC1215f4EdCc9982265E8b1F411D1352", 772 | "crvRewards": "0xDBFa6187C79f4fE4Cda20609E75760C5AaE88e52", 773 | "stash": "0x2eEa402ff31c580630b8545A33EDc00881E6949c", 774 | "swap": "0x8474DdbE98F5aA3179B3B3F5942D724aFcdec9f6", 775 | "currency": "USD", 776 | "name": "musd", 777 | "id": 14 778 | }, 779 | { 780 | "lptoken": "0xC2Ee6b0334C261ED60C72f6054450b61B8f18E35", 781 | "token": "0x8b876C2C02B1f2Ac6Ec207B7f2f06034A4316A87", 782 | "gauge": "0x4dC4A289a8E33600D8bD4cf5F6313E43a37adec7", 783 | "crvRewards": "0xedfCCF611D7c40F43e77a1340cE2C29EEEC27205", 784 | "stash": "0x3a076e8F088bFa7a43e1209B2E460927071e15F2", 785 | "swap": "0xC18cC39da8b11dA8c3541C598eE022258F9744da", 786 | "currency": "USD", 787 | "name": "rsv", 788 | "extras": [{ 789 | "contract": "0x94C259DC4C6dF248B0b5D23C055CB7574A587d67", 790 | "token": "0x8762db106b2c2a0bccb3a80d1ed41273552616e8", 791 | "name": "rsr" 792 | }], 793 | "id": 15 794 | }, 795 | { 796 | "lptoken": "0x64eda51d3Ad40D56b9dFc5554E06F94e1Dd786Fd", 797 | "token": "0x36CED690A1516861f26755b978EE62c1157CFFF9", 798 | "gauge": "0x6828bcF74279eE32f2723eC536c22c51Eed383C6", 799 | "crvRewards": "0x081A6672f07B615B402e7558a867C97FA080Ce35", 800 | "stash": "0x21FdcdeBf375e67219c1Bfa266BCfDaA36a2b4Fe", 801 | "swap": "0xC25099792E9349C7DD09759744ea681C7de2cb66", 802 | "currency": "BTC", 803 | "name": "tbtc", 804 | "id": 16 805 | }, 806 | { 807 | "lptoken": "0x3a664Ab939FD8482048609f652f9a0B0677337B9", 808 | "token": "0x06f4fFa5C3636AaA5C30B3DB97bfd1cd9Ac24A19", 809 | "gauge": "0xAEA6c312f4b3E04D752946d329693F7293bC2e6D", 810 | "crvRewards": "0x1992b82A8cCFC8f89785129D6403b13925d6226E", 811 | "stash": "0x07815651B8F1c5bE84797840543F304b7F1aeC2a", 812 | "swap": "0x8038C01A0390a8c547446a0b2c18fc9aEFEcc10c", 813 | "currency": "USD", 814 | "name": "dusd", 815 | "extras": [{ 816 | "contract": "0x666F8eEE6FD6839853993977CC86a7A51425673C", 817 | "token": "0x20c36f062a31865bED8a5B1e512D9a1A20AA333A", 818 | "name": "dfd" 819 | }], 820 | "id": 17 821 | }, 822 | { 823 | "lptoken": "0xDE5331AC4B3630f94853Ff322B66407e0D6331E8", 824 | "token": "0x21Cce64289407081744F087950b9DB32906470fC", 825 | "gauge": "0xd7d147c6Bb90A718c3De8C0568F9B560C79fa416", 826 | "crvRewards": "0x2d3C90AEB11D1393CA839Afc9587515B1325D77A", 827 | "stash": "0x930CfB64130a90d42eD37d4616792C9dEB791faf", 828 | "swap": "0x7F55DDe206dbAD629C080068923b36fe9D6bDBeF", 829 | "currency": "BTC", 830 | "name": "pbtc", 831 | "extras": [{ 832 | "contract": "0xAF138B29205c2246B069Ed8f0b213b205FBc14E0", 833 | "token": "0x89Ab32156e46F46D02ade3FEcbe5Fc4243B9AAeD", 834 | "name": "PNT" 835 | }], 836 | "id": 18 837 | }, 838 | { 839 | "lptoken": "0x410e3E86ef427e30B9235497143881f717d93c2A", 840 | "token": "0x2E1f902b9067b5fDd7AF29ef05D4fF6212588388", 841 | "gauge": "0xdFc7AdFa664b08767b735dE28f9E84cd30492aeE", 842 | "crvRewards": "0x61D741045cCAA5a215cF4E5e55f20E1199B4B843", 843 | "stash": "0xd852eFBEd0f49a065194ca92c9F305DE6DdCbF35", 844 | "swap": "0x071c661B4DeefB59E2a3DdB20Db036821eeE8F4b", 845 | "currency": "BTC", 846 | "name": "bbtc", 847 | "id": 19 848 | }, 849 | { 850 | "lptoken": "0x2fE94ea3d5d4a175184081439753DE15AeF9d614", 851 | "token": "0xc1C030139eEc070Ed8FD092CC8C273C638A18bBe", 852 | "gauge": "0x11137B10C210b579405c21A07489e28F3c040AB1", 853 | "crvRewards": "0xeeeCE77e0bc5e59c77fc408789A9A172A504bD2f", 854 | "stash": "0x9a669fb0191D977e588b20CdA3C52EDbC6c9926c", 855 | "swap": "0xd81dA8D904b52208541Bade1bD6595D8a251F8dd", 856 | "currency": "BTC", 857 | "name": "obtc", 858 | "extras": [{ 859 | "contract": "0xAE97D3766924526084dA88ba9B2bd7aF989Bf6fC", 860 | "token": "0x3c9d6c1C73b31c837832c72E04D3152f051fc1A9", 861 | "name": "BOR" 862 | }], 863 | "id": 20 864 | }, 865 | { 866 | "lptoken": "0x94e131324b6054c0D789b190b2dAC504e4361b53", 867 | "token": "0x67c4f788FEB82FAb27E3007daa3d7b90959D5b89", 868 | "gauge": "0x3B7020743Bc2A4ca9EaF9D0722d42E20d6935855", 869 | "crvRewards": "0xd4Be1911F8a0df178d6e7fF5cE39919c273E2B7B", 870 | "stash": "0x6249fD91fE9FF597399c1B192D5A25Cd22Eba6dd", 871 | "swap": "0x890f4e345B1dAED0367A877a1612f86A1f86985f", 872 | "currency": "USD", 873 | "name": "ust", 874 | "id": 21 875 | }, 876 | { 877 | "lptoken": "0x194eBd173F6cDacE046C53eACcE9B953F28411d1", 878 | "token": "0xd7E2b9494c529b42Dea53EF6a237C16502E6A927", 879 | "gauge": "0x90Bb609649E0451E5aD952683D64BD2d1f245840", 880 | "crvRewards": "0xcB8F69E0064d8cdD29cbEb45A14cf771D904BcD3", 881 | "stash": "0x007Cc4b4E9d9D088a9ae0e5261995D69e93B8E4C", 882 | "swap": "0x0Ce6a5fF5217e38315f87032CF90686C96627CAA", 883 | "currency": "EUR", 884 | "name": "eurs", 885 | "id": 22 886 | }, 887 | { 888 | "lptoken": "0xA3D87FffcE63B53E0d54fAa1cc983B7eB0b74A9c", 889 | "token": "0xAF1d4C576bF55f6aE493AEebAcC3a227675e5B98", 890 | "gauge": "0x3C0FFFF15EA30C35d7A85B85c0782D6c94e1d238", 891 | "crvRewards": "0x192469CadE297D6B21F418cFA8c366b63FFC9f9b", 892 | "stash": "0x1e6f5B8b4CAc5806D182B33A35d0fFF5F4004e86", 893 | "swap": "0xc5424B857f758E906013F3555Dad202e4bdB4567", 894 | "currency": "ETH", 895 | "name": "seth", 896 | "id": 23 897 | }, 898 | { 899 | "lptoken": "0xFd2a8fA60Abd58Efe3EeE34dd494cD491dC14900", 900 | "token": "0x23F224C37C3A69A058d86a54D3f561295A93d542", 901 | "gauge": "0xd662908ADA2Ea1916B3318327A97eB18aD588b5d", 902 | "crvRewards": "0xE82c1eB4BC6F92f85BF7EB6421ab3b882C3F5a7B", 903 | "stash": "0x5D4CF00939aa5F7C2cEb10c88615E9bcb0dd67fa", 904 | "swap": "0xDeBF20617708857ebe4F679508E7b7863a8A8EeE", 905 | "currency": "USD", 906 | "name": "aave", 907 | "extras": [{ 908 | "contract": "0x00469d388b06127221D6310843A43D079eb2bB18", 909 | "token": "0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9", 910 | "name": "stkAave" 911 | }], 912 | "id": 24 913 | }, 914 | { 915 | "lptoken": "0x06325440D014e39736583c165C2963BA99fAf14E", 916 | "token": "0x9518c9063eB0262D791f38d8d6Eb0aca33c63ed0", 917 | "gauge": "0x182B723a58739a9c974cFDB385ceaDb237453c28", 918 | "crvRewards": "0x0A760466E1B4621579a82a39CB56Dda2F4E70f03", 919 | "stash": "0x9710fD4e5CA524f1049EbeD8936c07C81b5EAB9f", 920 | "swap": "0xDC24316b9AE028F1497c275EB9192a3Ea0f67022", 921 | "currency": "ETH", 922 | "name": "steth", 923 | "extras": [{ 924 | "contract": "0x008aEa5036b819B4FEAEd10b2190FBb3954981E8", 925 | "token": "0x5a98fcbea516cf06857215779fd812ca3bef1b32", 926 | "name": "LDO" 927 | }], 928 | "id": 25 929 | }, 930 | { 931 | "lptoken": "0x02d341CcB60fAaf662bC0554d13778015d1b285C", 932 | "token": "0x09CCD0892b696AB21436e51588a7a7f8b649733d", 933 | "gauge": "0x462253b8F74B72304c145DB0e4Eebd326B22ca39", 934 | "crvRewards": "0xF86AE6790654b70727dbE58BF1a863B270317fD0", 935 | "stash": "0xd2D46004b981FdE1e4D39d0C24E1Be1e93689DD9", 936 | "swap": "0xEB16Ae0052ed37f479f7fe63849198Df1765a733", 937 | "currency": "USD", 938 | "name": "saave", 939 | "extras": [{ 940 | "contract": "0x20165075174b51a2f9Efbf7d6D8F3c72BBc63064", 941 | "token": "0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9", 942 | "name": "stkAave" 943 | }], 944 | "id": 26 945 | }, 946 | { 947 | "lptoken": "0xaA17A236F2bAdc98DDc0Cf999AbB47D47Fc0A6Cf", 948 | "token": "0x7E96955b66c89B931BBDAf187740Cc0fF2602F21", 949 | "gauge": "0x6d10ed2cF043E6fcf51A0e7b4C2Af3Fa06695707", 950 | "crvRewards": "0x8798b81b0261934aa850C8de8622472bfdc143F4", 951 | "stash": "0x423C444589CE5dB1E6F99820A5f95b3a57976598", 952 | "swap": "0xA96A65c051bF88B4095Ee1f2451C2A9d43F53Ae2", 953 | "currency": "ETH", 954 | "name": "ankreth", 955 | "extras": [{ 956 | "contract": "0x177252Ac74f1D77513971aA85AF7009C43EcdEe2", 957 | "token": "0xe0ad1806fd3e7edf6ff52fdb822432e847411033", 958 | "name": "onx" 959 | }, 960 | { 961 | "contract": "0xc095Cec98a9f8Ad6D2baA282A8e6bE246f98BD25", 962 | "token": "0x8290333cef9e6d528dd5618fb97a76f268f3edd4", 963 | "name": "ankr" 964 | } 965 | ], 966 | "id": 27 967 | }, 968 | { 969 | "lptoken": "0x7Eb40E450b9655f4B3cC4259BCC731c63ff55ae6", 970 | "token": "0x7a5dC1FA2e1B10194bD2e2e9F1A224971A681444", 971 | "gauge": "0x055be5DDB7A925BfEF3417FC157f53CA77cA7222", 972 | "crvRewards": "0x24DfFd1949F888F91A0c8341Fc98a3F280a782a8", 973 | "stash": "0xBE25313c53360780e03233Cc70a4409367EC15aE", 974 | "swap": "0x42d7025938bEc20B69cBae5A77421082407f053A", 975 | "currency": "USD", 976 | "name": "usdp", 977 | "id": 28 978 | }, 979 | { 980 | "lptoken": "0x5282a4eF67D9C33135340fB3289cc1711c13638C", 981 | "token": "0x912EC00eaEbf3820a9B0AC7a5E15F381A1C91f22", 982 | "gauge": "0xF5194c3325202F456c95c1Cf0cA36f8475C1949F", 983 | "crvRewards": "0x3E03fFF82F77073cc590b656D42FceB12E4910A8", 984 | "stash": "0x3aEaAB3eF0b5a484d8A2380215eA0A64d3101A6D", 985 | "swap": "0x2dded6Da1BF5DBdF597C45fcFaa3194e53EcfeAF", 986 | "currency": "USD", 987 | "name": "ironbank", 988 | "id": 29 989 | }, 990 | { 991 | "lptoken": "0xcee60cFa923170e4f8204AE08B4fA6A3F5656F3a", 992 | "token": "0xD37969740d78C94C648d74671B8BE31eF43c30aB", 993 | "gauge": "0xFD4D8a17df4C27c1dD245d153ccf4499e806C87D", 994 | "crvRewards": "0x9700152175dc22E7d1f3245fE3c1D2cfa3602548", 995 | "stash": "0x63201dc22e52985153E038086c448252d44Bed40", 996 | "swap": "0xF178C0b5Bb7e7aBF4e12A4838C7b7c5bA2C623c0", 997 | "currency": "LINK", 998 | "name": "link", 999 | "id": 30 1000 | }, 1001 | { 1002 | "lptoken": "0xEcd5e75AFb02eFa118AF914515D6521aaBd189F1", 1003 | "token": "0x0A2eA49EB5F9e23058deffD509D13DDd553c2A19", 1004 | "gauge": "0x359FD5d6417aE3D8D6497d9B2e7A890798262BA4", 1005 | "crvRewards": "0x308b48F037AAa75406426dACFACA864ebd88eDbA", 1006 | "stash": "0x12566645C209C1518BD25BdD3B0fd0bAe0910344", 1007 | "swap": "0xEcd5e75AFb02eFa118AF914515D6521aaBd189F1", 1008 | "currency": "USD", 1009 | "name": "tusd", 1010 | "id": 31 1011 | }, 1012 | { 1013 | "lptoken": "0xd632f22692FaC7611d2AA1C0D552930D43CAEd3B", 1014 | "token": "0xbE0F6478E0E4894CFb14f32855603A083A57c7dA", 1015 | "gauge": "0x72E158d38dbd50A483501c24f792bDAAA3e7D55C", 1016 | "crvRewards": "0xB900EF131301B307dB5eFcbed9DBb50A3e209B2e", 1017 | "stash": "0x10a63847e6cdD2b07e0a22D1f30eB037a72eB790", 1018 | "swap": "0xd632f22692FaC7611d2AA1C0D552930D43CAEd3B", 1019 | "currency": "USD", 1020 | "name": "frax", 1021 | "extras": [{ 1022 | "contract": "0xcDEC6714eB482f28f4889A0c122868450CDBF0b0", 1023 | "token": "0x3432b6a60d23ca0dfca7761b7ab56459d9c964d0", 1024 | "name": "FXS" 1025 | }], 1026 | "id": 32 1027 | }, 1028 | { 1029 | "lptoken": "0xEd279fDD11cA84bEef15AF5D39BB4d4bEE23F0cA", 1030 | "token": "0xFB9B2f06FDb404Fd3E2278E9A9edc8f252F273d0", 1031 | "gauge": "0x9B8519A9a00100720CCdC8a120fBeD319cA47a14", 1032 | "crvRewards": "0x2ad92A7aE036a038ff02B96c88de868ddf3f8190", 1033 | "stash": "0x06D972728A9d05CA6F27EDc01e20b50A60b1Deed", 1034 | "swap": "0xEd279fDD11cA84bEef15AF5D39BB4d4bEE23F0cA", 1035 | "currency": "USD", 1036 | "extras": [{ 1037 | "contract": "0x55d59b791f06dc519B176791c4E037E8Cf2f6361", 1038 | "token": "0x6DEA81C8171D0bA574754EF6F8b412F2Ed88c54D", 1039 | "name": "LQTY" 1040 | }], 1041 | "name": "lusd", 1042 | "id": 33 1043 | }, 1044 | { 1045 | "lptoken": "0x4807862AA8b2bF68830e4C8dc86D0e9A998e085a", 1046 | "token": "0x02D784f98A312aF3e2771297Feff1Da8273e4F29", 1047 | "gauge": "0xd4B22fEdcA85E684919955061fDf353b9d38389b", 1048 | "crvRewards": "0xbD223812d360C9587921292D0644D18aDb6a2ad0", 1049 | "stash": "0xBE3ED241c90F39cC50450C4937523FCC8d3e9bbc", 1050 | "swap": "0x4807862AA8b2bF68830e4C8dc86D0e9A998e085a", 1051 | "currency": "USD", 1052 | "name": "busdv2", 1053 | "id": 34 1054 | }, 1055 | { 1056 | "lptoken": "0x53a901d48795C58f485cBB38df08FA96a24669D5", 1057 | "token": "0x7ADd8D0E923CB692DF6bC65d96d510f0E2fC37af", 1058 | "gauge": "0x824F13f1a2F29cFEEa81154b46C0fc820677A637", 1059 | "crvRewards": "0x61dB6c2321f784c8fAb8d5eF80f58F27C831dCc8", 1060 | "stash": "0x644C8d1eD4b6aA68738a93C5c13c7fC19e126587", 1061 | "swap": "0xF9440930043eb3997fc70e1339dBb11F341de7A8", 1062 | "currency": "ETH", 1063 | "extras": [{ 1064 | "contract": "0x681A790debE586A64eea055BF0983CD6629d8359", 1065 | "token": "0xef3A930e1FfFFAcd2fc13434aC81bD278B0ecC8d", 1066 | "name": "FIS" 1067 | }], 1068 | "name": "reth", 1069 | "id": 35 1070 | }, 1071 | { 1072 | "lptoken": "0x43b4FdFD4Ff969587185cDB6f0BD875c5Fc83f8c", 1073 | "token": "0xCA3D9F45FfA69ED454E66539298709cb2dB8cA61", 1074 | "gauge": "0x9582C4ADACB3BCE56Fea3e590F05c3ca2fb9C477", 1075 | "crvRewards": "0x02E2151D4F351881017ABdF2DD2b51150841d5B3", 1076 | "stash": "0x521e6EEfDa35f7228f8f83462552bDB41D64d86B", 1077 | "swap": "0x43b4FdFD4Ff969587185cDB6f0BD875c5Fc83f8c", 1078 | "currency": "USD", 1079 | "extras": [{ 1080 | "contract": "0xd731495bb78a4250bC094686788F3fF890dEe0f4", 1081 | "token": "0xdbdb4d16eda451d0503b854cf79d55697f90c8df", 1082 | "name": "ALCX" 1083 | }], 1084 | "name": "alusd", 1085 | "id": 36 1086 | }, 1087 | { 1088 | "lptoken": "0xcA3d75aC011BF5aD07a98d02f18225F9bD9A6BDF", 1089 | "token": "0x18684099414dcEF486F4FA5b4e44e6eA53C8c554", 1090 | "gauge": "0x6955a55416a06839309018A8B0cB72c4DDC11f15", 1091 | "crvRewards": "0x5Edced358e6C0B435D53CC30fbE6f5f0833F404F", 1092 | "stash": "0x35e86E54eCb0227fe33382c35E12856cF227E9ce", 1093 | "swap": "0x80466c64868E1ab14a1Ddf27A676C3fcBE638Fe5", 1094 | "currency": "USD", 1095 | "name": "tricrypto", 1096 | "isV2": true, 1097 | "coins": [ 1098 | "0xdAC17F958D2ee523a2206206994597C13D831ec7", 1099 | "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599", 1100 | "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" 1101 | ], 1102 | "coinDecimals": [ 1103 | 6, 8, 18 1104 | ], 1105 | "id": 37 1106 | }, 1107 | { 1108 | "lptoken": "0xc4AD29ba4B3c580e6D59105FFf484999997675Ff", 1109 | "token": "0x903C9974aAA431A765e60bC07aF45f0A1B3b61fb", 1110 | "gauge": "0xDeFd8FdD20e0f34115C7018CCfb655796F6B2168", 1111 | "crvRewards": "0x9D5C5E364D81DaB193b72db9E9BE9D8ee669B652", 1112 | "stash": "0xDb1A0Bb8C14Bc7B4eDA5ca95B4A6C6013a7b359D", 1113 | "swap": "0xD51a44d3FaE010294C616388b506AcdA1bfAAE46", 1114 | "currency": "USD", 1115 | "name": "tricrypto2", 1116 | "isV2": true, 1117 | "coins": [ 1118 | "0xdAC17F958D2ee523a2206206994597C13D831ec7", 1119 | "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599", 1120 | "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" 1121 | ], 1122 | "coinDecimals": [ 1123 | 6, 8, 18 1124 | ], 1125 | "id": 38 1126 | }, 1127 | { 1128 | "lptoken": "0xFD5dB7463a3aB53fD211b4af195c5BCCC1A03890", 1129 | "token": "0x2b2175AC371Ec2900AC39fb87452340F65CC9895", 1130 | "gauge": "0xe8060Ad8971450E624d5289A10017dD30F5dA85F", 1131 | "crvRewards": "0xD814BFC091111E1417a669672144aFFAA081c3CE", 1132 | "stash": "0x353460EACDAaEC993eCdA986440F4c343BBf6c05", 1133 | "swap": "0xFD5dB7463a3aB53fD211b4af195c5BCCC1A03890", 1134 | "currency": "EUR", 1135 | "name": "eurt", 1136 | "id": 39 1137 | }, 1138 | { 1139 | "lptoken": "0x5a6A4D54456819380173272A5E8E9B9904BdF41B", 1140 | "token": "0xabB54222c2b77158CC975a2b715a3d703c256F05", 1141 | "gauge": "0xd8b712d29381748dB89c36BCa0138d7c75866ddF", 1142 | "crvRewards": "0xFd5AbF66b003881b88567EB9Ed9c651F14Dc4771", 1143 | "stash": "0xEd3D937A12fEed5298827B3adf05caaFfb0efDda", 1144 | "swap": "0x5a6A4D54456819380173272A5E8E9B9904BdF41B", 1145 | "currency": "USD", 1146 | "name": "mim", 1147 | "extras": [{ 1148 | "contract": "0x69a92f1656cd2e193797546cFe2EaF32EACcf6f7", 1149 | "token": "0x090185f2135308bad17527004364ebcc2d37e5f6", 1150 | "name": "SPELL" 1151 | }], 1152 | "id": 40 1153 | }, 1154 | { 1155 | "lptoken": "0x9D0464996170c6B9e75eED71c68B99dDEDf279e8", 1156 | "token": "0x8FDF7cabfEc73d5FfD1447867834b4cf39B745B7", 1157 | "gauge": "0x903dA6213a5A12B61c821598154EfAd98C3B20E4", 1158 | "crvRewards": "0x0392321e86F42C2F94FBb0c6853052487db521F0", 1159 | "stash": "0xF025A9FbcaA41E03e7a443716fe2182d13cf80a4", 1160 | "swap": "0x9D0464996170c6B9e75eED71c68B99dDEDf279e8", 1161 | "currency": "ETH", 1162 | "name": "cvxcrv", 1163 | "extras": [ 1164 | { 1165 | "contract": "0xbE4DEa8E5d1E53FAd661610E47501f858F25852D", 1166 | "token": "0x4e3fbd56cd56c3e72c1403e103b45db9da5b9d2b", 1167 | "chefHook": "0x93E85b8C3995B407fB2f1198d83F4e500242B3A2", 1168 | "chefToken": "0xe79d9a5eF6E19C3f1003f4F27a1423259460f6D0", 1169 | "name": "CVX" 1170 | } 1171 | ], 1172 | "id": 41 1173 | }, 1174 | { 1175 | "lptoken": "0x8818a9bb44Fbf33502bE7c15c500d0C783B73067", 1176 | "token": "0xF527FF4d2f8D84ec51D31C6F533B8cC78AFf6918", 1177 | "gauge": "0xeFF437A56A22D7dD86C1202A308536ED8C7da7c1", 1178 | "crvRewards": "0xbA8fE590498ed24D330Bb925E69913b1Ac35a81E", 1179 | "stash": "0xc87E93D6138c08a99b581f6dE4424c1e4b71A03F", 1180 | "swap": "0x8818a9bb44Fbf33502bE7c15c500d0C783B73067", 1181 | "currency": "JPY", 1182 | "name": "fixedforex:jpy", 1183 | "extras": [ 1184 | { 1185 | "contract": "", 1186 | "token": "0x4e3fbd56cd56c3e72c1403e103b45db9da5b9d2b", 1187 | "name": "CVX" 1188 | } 1189 | ], 1190 | "id": 42 1191 | }, 1192 | { 1193 | "lptoken": "0xD6Ac1CB9019137a896343Da59dDE6d097F710538", 1194 | "token": "0xe6b9b86a593E6c33fa3F0887753cdC39EA49B246", 1195 | "gauge": "0x63d9f3aB7d0c528797A12a0684E50C397E9e79dC", 1196 | "crvRewards": "0x51a16DA36c79E28dD3C8c0c19214D8aF413984Aa", 1197 | "stash": "0xA335f705e0e33e986Bae79244F2Cd73899932290", 1198 | "swap": "0xD6Ac1CB9019137a896343Da59dDE6d097F710538", 1199 | "currency": "GBP", 1200 | "name": "fixedforex:gbp", 1201 | "extras": [ 1202 | { 1203 | "contract": "", 1204 | "token": "0x4e3fbd56cd56c3e72c1403e103b45db9da5b9d2b", 1205 | "name": "CVX" 1206 | } 1207 | ], 1208 | "id": 43 1209 | }, 1210 | { 1211 | "lptoken": "0x3F1B0278A9ee595635B61817630cC19DE792f506", 1212 | "token": "0xBec1Fa170974F0B38Eb76D8ca87053AbD5cedffF", 1213 | "gauge": "0x05ca5c01629a8E5845f12ea3A03fF7331932233A", 1214 | "crvRewards": "0xb1Fae59F23CaCe4949Ae734E63E42168aDb0CcB3", 1215 | "stash": "0xCc96f06fa34d934a90089793b27d36801842A599", 1216 | "swap": "0x3F1B0278A9ee595635B61817630cC19DE792f506", 1217 | "currency": "AUD", 1218 | "name": "fixedforex:aud", 1219 | "extras": [ 1220 | { 1221 | "contract": "", 1222 | "token": "0x4e3fbd56cd56c3e72c1403e103b45db9da5b9d2b", 1223 | "name": "CVX" 1224 | } 1225 | ], 1226 | "id": 44 1227 | }, 1228 | { 1229 | "lptoken": "0x19b080FE1ffA0553469D20Ca36219F17Fcf03859", 1230 | "token": "0x864510e93c38C771adC1B67308cE0b7c4AA1AA9e", 1231 | "gauge": "0x99fb76F75501039089AAC8f20f487bf84E51d76F", 1232 | "crvRewards": "0xCd0559ADb6fAa2fc83aB21Cf4497c3b9b45bB29f", 1233 | "stash": "0x65d3834Ca2F62AB3f484cD50bB8a2Ba784cc69AA", 1234 | "swap": "0x19b080FE1ffA0553469D20Ca36219F17Fcf03859", 1235 | "currency": "EUR", 1236 | "name": "fixedforex:eur", 1237 | "extras": [ 1238 | { 1239 | "contract": "", 1240 | "token": "0x4e3fbd56cd56c3e72c1403e103b45db9da5b9d2b", 1241 | "name": "CVX" 1242 | } 1243 | ], 1244 | "id": 45 1245 | }, 1246 | { 1247 | "lptoken": "0x9c2C8910F113181783c249d8F6Aa41b51Cde0f0c", 1248 | "token": "0xcd555A686486160D815C89D92EE69A88E356f34C", 1249 | "gauge": "0x2fA53e8fa5fAdb81f4332C8EcE39Fe62eA2f919E", 1250 | "crvRewards": "0xa5A5905efc55B05059eE247d5CaC6DD6791Cfc33", 1251 | "stash": "0x44789Fa0e02ed06E3cA4A1405CBef7EA2F11D282", 1252 | "swap": "0x9c2C8910F113181783c249d8F6Aa41b51Cde0f0c", 1253 | "currency": "CHF", 1254 | "name": "fixedforex:chf", 1255 | "extras": [ 1256 | { 1257 | "contract": "", 1258 | "token": "0x4e3fbd56cd56c3e72c1403e103b45db9da5b9d2b", 1259 | "name": "CVX" 1260 | } 1261 | ], 1262 | "id": 46 1263 | }, 1264 | { 1265 | "lptoken": "0x8461A004b50d321CB22B7d034969cE6803911899", 1266 | "token": "0xAA4e7d24230B1F3AF324C7574ABD5D28525807cA", 1267 | "gauge": "0x1750a3a3d80A3F5333BBe9c4695B0fAd41061ab1", 1268 | "crvRewards": "0x8F18C0AF0d7d511E8Bdc6B3c64926B04EDfE4892", 1269 | "stash": "0xb75b7297f29d5f6211f112D24b1edF9Dc77eD834", 1270 | "swap": "0x8461A004b50d321CB22B7d034969cE6803911899", 1271 | "currency": "KRW", 1272 | "name": "fixedforex:krw", 1273 | "extras": [ 1274 | { 1275 | "contract": "", 1276 | "token": "0x4e3fbd56cd56c3e72c1403e103b45db9da5b9d2b", 1277 | "name": "CVX" 1278 | } 1279 | ], 1280 | "id": 47 1281 | } 1282 | ]; 1283 | 1284 | 1285 | 1286 | 1287 | 1288 | 1289 | 1290 | 1291 | 1292 | 1293 | 1294 | -------------------------------------------------------------------------------- /tvl/README.md: -------------------------------------------------------------------------------- 1 | # Convex TVL 2 | 3 | Use Curve's registry contract to calculate convex TVL. 4 | 5 | ## How to use 6 | - Create a config.json file with an infura key 7 | ``` 8 | { 9 | INFURA_KEY:"xyz123" 10 | } 11 | ``` 12 | - npm i 13 | - node tvl.js -------------------------------------------------------------------------------- /tvl/abi.js: -------------------------------------------------------------------------------- 1 | 2 | const CRV_ABI = [{"name":"Transfer","inputs":[{"type":"address","name":"_from","indexed":true},{"type":"address","name":"_to","indexed":true},{"type":"uint256","name":"_value","indexed":false}],"anonymous":false,"type":"event"},{"name":"Approval","inputs":[{"type":"address","name":"_owner","indexed":true},{"type":"address","name":"_spender","indexed":true},{"type":"uint256","name":"_value","indexed":false}],"anonymous":false,"type":"event"},{"name":"UpdateMiningParameters","inputs":[{"type":"uint256","name":"time","indexed":false},{"type":"uint256","name":"rate","indexed":false},{"type":"uint256","name":"supply","indexed":false}],"anonymous":false,"type":"event"},{"name":"SetMinter","inputs":[{"type":"address","name":"minter","indexed":false}],"anonymous":false,"type":"event"},{"name":"SetAdmin","inputs":[{"type":"address","name":"admin","indexed":false}],"anonymous":false,"type":"event"},{"outputs":[],"inputs":[{"type":"string","name":"_name"},{"type":"string","name":"_symbol"},{"type":"uint256","name":"_decimals"}],"stateMutability":"nonpayable","type":"constructor"},{"name":"update_mining_parameters","outputs":[],"inputs":[],"stateMutability":"nonpayable","type":"function"},{"name":"start_epoch_time_write","outputs":[{"type":"uint256","name":""}],"inputs":[],"stateMutability":"nonpayable","type":"function"},{"name":"future_epoch_time_write","outputs":[{"type":"uint256","name":""}],"inputs":[],"stateMutability":"nonpayable","type":"function"},{"name":"available_supply","outputs":[{"type":"uint256","name":""}],"inputs":[],"stateMutability":"view","type":"function"},{"name":"mintable_in_timeframe","outputs":[{"type":"uint256","name":""}],"inputs":[{"type":"uint256","name":"start"},{"type":"uint256","name":"end"}],"stateMutability":"view","type":"function"},{"name":"set_minter","outputs":[],"inputs":[{"type":"address","name":"_minter"}],"stateMutability":"nonpayable","type":"function"},{"name":"set_admin","outputs":[],"inputs":[{"type":"address","name":"_admin"}],"stateMutability":"nonpayable","type":"function"},{"name":"totalSupply","outputs":[{"type":"uint256","name":""}],"inputs":[],"stateMutability":"view","type":"function"},{"name":"allowance","outputs":[{"type":"uint256","name":""}],"inputs":[{"type":"address","name":"_owner"},{"type":"address","name":"_spender"}],"stateMutability":"view","type":"function"},{"name":"transfer","outputs":[{"type":"bool","name":""}],"inputs":[{"type":"address","name":"_to"},{"type":"uint256","name":"_value"}],"stateMutability":"nonpayable","type":"function"},{"name":"transferFrom","outputs":[{"type":"bool","name":""}],"inputs":[{"type":"address","name":"_from"},{"type":"address","name":"_to"},{"type":"uint256","name":"_value"}],"stateMutability":"nonpayable","type":"function"},{"name":"approve","outputs":[{"type":"bool","name":""}],"inputs":[{"type":"address","name":"_spender"},{"type":"uint256","name":"_value"}],"stateMutability":"nonpayable","type":"function"},{"name":"mint","outputs":[{"type":"bool","name":""}],"inputs":[{"type":"address","name":"_to"},{"type":"uint256","name":"_value"}],"stateMutability":"nonpayable","type":"function"},{"name":"burn","outputs":[{"type":"bool","name":""}],"inputs":[{"type":"uint256","name":"_value"}],"stateMutability":"nonpayable","type":"function"},{"name":"set_name","outputs":[],"inputs":[{"type":"string","name":"_name"},{"type":"string","name":"_symbol"}],"stateMutability":"nonpayable","type":"function"},{"name":"name","outputs":[{"type":"string","name":""}],"inputs":[],"stateMutability":"view","type":"function"},{"name":"symbol","outputs":[{"type":"string","name":""}],"inputs":[],"stateMutability":"view","type":"function"},{"name":"decimals","outputs":[{"type":"uint256","name":""}],"inputs":[],"stateMutability":"view","type":"function"},{"name":"balanceOf","outputs":[{"type":"uint256","name":""}],"inputs":[{"type":"address","name":"arg0"}],"stateMutability":"view","type":"function"},{"name":"minter","outputs":[{"type":"address","name":""}],"inputs":[],"stateMutability":"view","type":"function"},{"name":"admin","outputs":[{"type":"address","name":""}],"inputs":[],"stateMutability":"view","type":"function"},{"name":"mining_epoch","outputs":[{"type":"int128","name":""}],"inputs":[],"stateMutability":"view","type":"function"},{"name":"start_epoch_time","outputs":[{"type":"uint256","name":""}],"inputs":[],"stateMutability":"view","type":"function"},{"name":"rate","outputs":[{"type":"uint256","name":""}],"inputs":[],"stateMutability":"view","type":"function"}]; 3 | 4 | const MULTICALL_ABI = [{"constant":true,"inputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct Multicall.Call[]","name":"calls","type":"tuple[]"}],"name":"aggregate","outputs":[{"internalType":"uint256","name":"blockNumber","type":"uint256"},{"internalType":"bytes[]","name":"returnData","type":"bytes[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"blockNumber","type":"uint256"}],"name":"getBlockHash","outputs":[{"internalType":"bytes32","name":"blockHash","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getCurrentBlockCoinbase","outputs":[{"internalType":"address","name":"coinbase","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getCurrentBlockDifficulty","outputs":[{"internalType":"uint256","name":"difficulty","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getCurrentBlockGasLimit","outputs":[{"internalType":"uint256","name":"gaslimit","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getCurrentBlockTimestamp","outputs":[{"internalType":"uint256","name":"timestamp","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"getEthBalance","outputs":[{"internalType":"uint256","name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getLastBlockHash","outputs":[{"internalType":"bytes32","name":"blockHash","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"}]; 5 | 6 | const REGISTRY_ABI=[{"name":"PoolAdded","inputs":[{"name":"pool","type":"address","indexed":true},{"name":"rate_method_id","type":"bytes","indexed":false}],"anonymous":false,"type":"event"},{"name":"PoolRemoved","inputs":[{"name":"pool","type":"address","indexed":true}],"anonymous":false,"type":"event"},{"stateMutability":"nonpayable","type":"constructor","inputs":[{"name":"_address_provider","type":"address"},{"name":"_gauge_controller","type":"address"}],"outputs":[]},{"stateMutability":"view","type":"function","name":"find_pool_for_coins","inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"}],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"find_pool_for_coins","inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"i","type":"uint256"}],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"get_n_coins","inputs":[{"name":"_pool","type":"address"}],"outputs":[{"name":"","type":"uint256[2]"}]},{"stateMutability":"view","type":"function","name":"get_coins","inputs":[{"name":"_pool","type":"address"}],"outputs":[{"name":"","type":"address[8]"}]},{"stateMutability":"view","type":"function","name":"get_underlying_coins","inputs":[{"name":"_pool","type":"address"}],"outputs":[{"name":"","type":"address[8]"}]},{"stateMutability":"view","type":"function","name":"get_decimals","inputs":[{"name":"_pool","type":"address"}],"outputs":[{"name":"","type":"uint256[8]"}]},{"stateMutability":"view","type":"function","name":"get_underlying_decimals","inputs":[{"name":"_pool","type":"address"}],"outputs":[{"name":"","type":"uint256[8]"}]},{"stateMutability":"view","type":"function","name":"get_rates","inputs":[{"name":"_pool","type":"address"}],"outputs":[{"name":"","type":"uint256[8]"}]},{"stateMutability":"view","type":"function","name":"get_gauges","inputs":[{"name":"_pool","type":"address"}],"outputs":[{"name":"","type":"address[10]"},{"name":"","type":"int128[10]"}]},{"stateMutability":"view","type":"function","name":"get_balances","inputs":[{"name":"_pool","type":"address"}],"outputs":[{"name":"","type":"uint256[8]"}]},{"stateMutability":"view","type":"function","name":"get_underlying_balances","inputs":[{"name":"_pool","type":"address"}],"outputs":[{"name":"","type":"uint256[8]"}]},{"stateMutability":"view","type":"function","name":"get_virtual_price_from_lp_token","inputs":[{"name":"_token","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"get_A","inputs":[{"name":"_pool","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"get_parameters","inputs":[{"name":"_pool","type":"address"}],"outputs":[{"name":"A","type":"uint256"},{"name":"future_A","type":"uint256"},{"name":"fee","type":"uint256"},{"name":"admin_fee","type":"uint256"},{"name":"future_fee","type":"uint256"},{"name":"future_admin_fee","type":"uint256"},{"name":"future_owner","type":"address"},{"name":"initial_A","type":"uint256"},{"name":"initial_A_time","type":"uint256"},{"name":"future_A_time","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"get_fees","inputs":[{"name":"_pool","type":"address"}],"outputs":[{"name":"","type":"uint256[2]"}]},{"stateMutability":"view","type":"function","name":"get_admin_balances","inputs":[{"name":"_pool","type":"address"}],"outputs":[{"name":"","type":"uint256[8]"}]},{"stateMutability":"view","type":"function","name":"get_coin_indices","inputs":[{"name":"_pool","type":"address"},{"name":"_from","type":"address"},{"name":"_to","type":"address"}],"outputs":[{"name":"","type":"int128"},{"name":"","type":"int128"},{"name":"","type":"bool"}]},{"stateMutability":"view","type":"function","name":"estimate_gas_used","inputs":[{"name":"_pool","type":"address"},{"name":"_from","type":"address"},{"name":"_to","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"is_meta","inputs":[{"name":"_pool","type":"address"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"view","type":"function","name":"get_pool_name","inputs":[{"name":"_pool","type":"address"}],"outputs":[{"name":"","type":"string"}]},{"stateMutability":"view","type":"function","name":"get_coin_swap_count","inputs":[{"name":"_coin","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"get_coin_swap_complement","inputs":[{"name":"_coin","type":"address"},{"name":"_index","type":"uint256"}],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"get_pool_asset_type","inputs":[{"name":"_pool","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"function","name":"add_pool","inputs":[{"name":"_pool","type":"address"},{"name":"_n_coins","type":"uint256"},{"name":"_lp_token","type":"address"},{"name":"_rate_info","type":"bytes32"},{"name":"_decimals","type":"uint256"},{"name":"_underlying_decimals","type":"uint256"},{"name":"_has_initial_A","type":"bool"},{"name":"_is_v1","type":"bool"},{"name":"_name","type":"string"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"add_pool_without_underlying","inputs":[{"name":"_pool","type":"address"},{"name":"_n_coins","type":"uint256"},{"name":"_lp_token","type":"address"},{"name":"_rate_info","type":"bytes32"},{"name":"_decimals","type":"uint256"},{"name":"_use_rates","type":"uint256"},{"name":"_has_initial_A","type":"bool"},{"name":"_is_v1","type":"bool"},{"name":"_name","type":"string"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"add_metapool","inputs":[{"name":"_pool","type":"address"},{"name":"_n_coins","type":"uint256"},{"name":"_lp_token","type":"address"},{"name":"_decimals","type":"uint256"},{"name":"_name","type":"string"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"add_metapool","inputs":[{"name":"_pool","type":"address"},{"name":"_n_coins","type":"uint256"},{"name":"_lp_token","type":"address"},{"name":"_decimals","type":"uint256"},{"name":"_name","type":"string"},{"name":"_base_pool","type":"address"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"remove_pool","inputs":[{"name":"_pool","type":"address"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"set_pool_gas_estimates","inputs":[{"name":"_addr","type":"address[5]"},{"name":"_amount","type":"uint256[2][5]"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"set_coin_gas_estimates","inputs":[{"name":"_addr","type":"address[10]"},{"name":"_amount","type":"uint256[10]"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"set_gas_estimate_contract","inputs":[{"name":"_pool","type":"address"},{"name":"_estimator","type":"address"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"set_liquidity_gauges","inputs":[{"name":"_pool","type":"address"},{"name":"_liquidity_gauges","type":"address[10]"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"set_pool_asset_type","inputs":[{"name":"_pool","type":"address"},{"name":"_asset_type","type":"uint256"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"batch_set_pool_asset_type","inputs":[{"name":"_pools","type":"address[32]"},{"name":"_asset_types","type":"uint256[32]"}],"outputs":[]},{"stateMutability":"view","type":"function","name":"address_provider","inputs":[],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"gauge_controller","inputs":[],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"pool_list","inputs":[{"name":"arg0","type":"uint256"}],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"pool_count","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"coin_count","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"get_coin","inputs":[{"name":"arg0","type":"uint256"}],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"get_pool_from_lp_token","inputs":[{"name":"arg0","type":"address"}],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"get_lp_token","inputs":[{"name":"arg0","type":"address"}],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"last_updated","inputs":[],"outputs":[{"name":"","type":"uint256"}]}]; 7 | 8 | const BOOSTER_ABI=[{"inputs":[{"internalType":"address","name":"_staker","type":"address"},{"internalType":"address","name":"_minter","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"poolid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Deposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"poolid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"FEE_DENOMINATOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MaxFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_lptoken","type":"address"},{"internalType":"address","name":"_gauge","type":"address"},{"internalType":"uint256","name":"_stashVersion","type":"uint256"}],"name":"addPool","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"address","name":"_gauge","type":"address"}],"name":"claimRewards","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"crv","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"bool","name":"_stake","type":"bool"}],"name":"deposit","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"bool","name":"_stake","type":"bool"}],"name":"depositAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"distributionAddressId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"earmarkFees","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"earmarkIncentive","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"}],"name":"earmarkRewards","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feeDistro","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeManager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"gaugeMap","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isShutdown","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lockFees","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lockIncentive","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lockRewards","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"platformFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"poolInfo","outputs":[{"internalType":"address","name":"lptoken","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"gauge","type":"address"},{"internalType":"address","name":"crvRewards","type":"address"},{"internalType":"address","name":"stash","type":"address"},{"internalType":"bool","name":"shutdown","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolManager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"registry","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardArbitrator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"address","name":"_address","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"rewardClaimed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardFactory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_arb","type":"address"}],"name":"setArbitrator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_rfactory","type":"address"},{"internalType":"address","name":"_sfactory","type":"address"},{"internalType":"address","name":"_tfactory","type":"address"}],"name":"setFactories","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"setFeeInfo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_feeM","type":"address"}],"name":"setFeeManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lockFees","type":"uint256"},{"internalType":"uint256","name":"_stakerFees","type":"uint256"},{"internalType":"uint256","name":"_callerFees","type":"uint256"},{"internalType":"uint256","name":"_platform","type":"uint256"}],"name":"setFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"}],"name":"setGaugeRedirect","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"setOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_poolM","type":"address"}],"name":"setPoolManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_rewards","type":"address"},{"internalType":"address","name":"_stakerRewards","type":"address"}],"name":"setRewardContracts","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_treasury","type":"address"}],"name":"setTreasury","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_voteDelegate","type":"address"}],"name":"setVoteDelegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"}],"name":"shutdownPool","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"shutdownSystem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"staker","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stakerIncentive","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stakerRewards","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stashFactory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenFactory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"treasury","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_voteId","type":"uint256"},{"internalType":"address","name":"_votingAddress","type":"address"},{"internalType":"bool","name":"_support","type":"bool"}],"name":"vote","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"voteDelegate","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_gauge","type":"address[]"},{"internalType":"uint256[]","name":"_weight","type":"uint256[]"}],"name":"voteGaugeWeight","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"voteOwnership","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"voteParameter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdraw","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"}],"name":"withdrawAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"withdrawTo","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]; 9 | 10 | const SWAP_ABI=[{"name":"Transfer","inputs":[{"name":"sender","type":"address","indexed":true},{"name":"receiver","type":"address","indexed":true},{"name":"value","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"Approval","inputs":[{"name":"owner","type":"address","indexed":true},{"name":"spender","type":"address","indexed":true},{"name":"value","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"TokenExchange","inputs":[{"name":"buyer","type":"address","indexed":true},{"name":"sold_id","type":"int128","indexed":false},{"name":"tokens_sold","type":"uint256","indexed":false},{"name":"bought_id","type":"int128","indexed":false},{"name":"tokens_bought","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"AddLiquidity","inputs":[{"name":"provider","type":"address","indexed":true},{"name":"token_amounts","type":"uint256[2]","indexed":false},{"name":"fees","type":"uint256[2]","indexed":false},{"name":"invariant","type":"uint256","indexed":false},{"name":"token_supply","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"RemoveLiquidity","inputs":[{"name":"provider","type":"address","indexed":true},{"name":"token_amounts","type":"uint256[2]","indexed":false},{"name":"fees","type":"uint256[2]","indexed":false},{"name":"token_supply","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"RemoveLiquidityOne","inputs":[{"name":"provider","type":"address","indexed":true},{"name":"token_amount","type":"uint256","indexed":false},{"name":"coin_amount","type":"uint256","indexed":false},{"name":"token_supply","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"RemoveLiquidityImbalance","inputs":[{"name":"provider","type":"address","indexed":true},{"name":"token_amounts","type":"uint256[2]","indexed":false},{"name":"fees","type":"uint256[2]","indexed":false},{"name":"invariant","type":"uint256","indexed":false},{"name":"token_supply","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"RampA","inputs":[{"name":"old_A","type":"uint256","indexed":false},{"name":"new_A","type":"uint256","indexed":false},{"name":"initial_time","type":"uint256","indexed":false},{"name":"future_time","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"StopRampA","inputs":[{"name":"A","type":"uint256","indexed":false},{"name":"t","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"stateMutability":"nonpayable","type":"constructor","inputs":[],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"initialize","inputs":[{"name":"_name","type":"string"},{"name":"_symbol","type":"string"},{"name":"_coins","type":"address[4]"},{"name":"_rate_multipliers","type":"uint256[4]"},{"name":"_A","type":"uint256"},{"name":"_fee","type":"uint256"}],"outputs":[]},{"stateMutability":"view","type":"function","name":"decimals","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"function","name":"transfer","inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"function","name":"transferFrom","inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"nonpayable","type":"function","name":"approve","inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"outputs":[{"name":"","type":"bool"}]},{"stateMutability":"view","type":"function","name":"get_balances","inputs":[],"outputs":[{"name":"","type":"uint256[2]"}],},{"stateMutability":"view","type":"function","name":"admin_fee","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"A","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"A_precise","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"get_virtual_price","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"calc_token_amount","inputs":[{"name":"_amounts","type":"uint256[2]"},{"name":"_is_deposit","type":"bool"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"function","name":"add_liquidity","inputs":[{"name":"_amounts","type":"uint256[2]"},{"name":"_min_mint_amount","type":"uint256"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"function","name":"add_liquidity","inputs":[{"name":"_amounts","type":"uint256[2]"},{"name":"_min_mint_amount","type":"uint256"},{"name":"_receiver","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"get_dy","inputs":[{"name":"i","type":"int128"},{"name":"j","type":"int128"},{"name":"dx","type":"uint256"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"function","name":"exchange","inputs":[{"name":"i","type":"int128"},{"name":"j","type":"int128"},{"name":"_dx","type":"uint256"},{"name":"_min_dy","type":"uint256"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"function","name":"exchange","inputs":[{"name":"i","type":"int128"},{"name":"j","type":"int128"},{"name":"_dx","type":"uint256"},{"name":"_min_dy","type":"uint256"},{"name":"_receiver","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"function","name":"remove_liquidity","inputs":[{"name":"_burn_amount","type":"uint256"},{"name":"_min_amounts","type":"uint256[2]"}],"outputs":[{"name":"","type":"uint256[2]"}]},{"stateMutability":"nonpayable","type":"function","name":"remove_liquidity","inputs":[{"name":"_burn_amount","type":"uint256"},{"name":"_min_amounts","type":"uint256[2]"},{"name":"_receiver","type":"address"}],"outputs":[{"name":"","type":"uint256[2]"}]},{"stateMutability":"nonpayable","type":"function","name":"remove_liquidity_imbalance","inputs":[{"name":"_amounts","type":"uint256[2]"},{"name":"_max_burn_amount","type":"uint256"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"function","name":"remove_liquidity_imbalance","inputs":[{"name":"_amounts","type":"uint256[2]"},{"name":"_max_burn_amount","type":"uint256"},{"name":"_receiver","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"calc_withdraw_one_coin","inputs":[{"name":"_burn_amount","type":"uint256"},{"name":"i","type":"int128"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"calc_withdraw_one_coin","inputs":[{"name":"_burn_amount","type":"uint256"},{"name":"i","type":"int128"},{"name":"_previous","type":"bool"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"function","name":"remove_liquidity_one_coin","inputs":[{"name":"_burn_amount","type":"uint256"},{"name":"i","type":"int128"},{"name":"_min_received","type":"uint256"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"function","name":"remove_liquidity_one_coin","inputs":[{"name":"_burn_amount","type":"uint256"},{"name":"i","type":"int128"},{"name":"_min_received","type":"uint256"},{"name":"_receiver","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"function","name":"ramp_A","inputs":[{"name":"_future_A","type":"uint256"},{"name":"_future_time","type":"uint256"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"stop_ramp_A","inputs":[],"outputs":[]},{"stateMutability":"view","type":"function","name":"admin_balances","inputs":[{"name":"i","type":"uint256"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"function","name":"withdraw_admin_fees","inputs":[],"outputs":[]},{"stateMutability":"view","type":"function","name":"coins","inputs":[{"name":"arg0","type":"uint256"}],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"balances","inputs":[{"name":"arg0","type":"uint256"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"fee","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"initial_A","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"future_A","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"initial_A_time","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"future_A_time","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"name","inputs":[],"outputs":[{"name":"","type":"string"}]},{"stateMutability":"view","type":"function","name":"symbol","inputs":[],"outputs":[{"name":"","type":"string"}]},{"stateMutability":"view","type":"function","name":"balanceOf","inputs":[{"name":"arg0","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"allowance","inputs":[{"name":"arg0","type":"address"},{"name":"arg1","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"totalSupply","inputs":[],"outputs":[{"name":"","type":"uint256"}]}]; 11 | 12 | const FOREX_PRICE_ABI=[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"acceptGovernance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_forex","type":"address"},{"internalType":"address","name":"_cy","type":"address"}],"name":"addForex","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"applyGovernance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"cy","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"forex","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"governance","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"oracle","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingGovernance","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_forex","type":"address"}],"name":"price","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_forex","type":"address"}],"name":"removeForex","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_oracle","type":"address"}],"name":"setOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_governance","type":"address"}],"name":"transferGovernance","outputs":[],"stateMutability":"nonpayable","type":"function"}]; 13 | 14 | const CONTROLLER_ABI=[ 15 | { 16 | "name": "CommitOwnership", 17 | "inputs": [ 18 | { 19 | "type": "address", 20 | "name": "admin", 21 | "indexed": false 22 | } 23 | ], 24 | "anonymous": false, 25 | "type": "event" 26 | }, 27 | { 28 | "name": "ApplyOwnership", 29 | "inputs": [ 30 | { 31 | "type": "address", 32 | "name": "admin", 33 | "indexed": false 34 | } 35 | ], 36 | "anonymous": false, 37 | "type": "event" 38 | }, 39 | { 40 | "name": "AddType", 41 | "inputs": [ 42 | { 43 | "type": "string", 44 | "name": "name", 45 | "indexed": false 46 | }, 47 | { 48 | "type": "int128", 49 | "name": "type_id", 50 | "indexed": false 51 | } 52 | ], 53 | "anonymous": false, 54 | "type": "event" 55 | }, 56 | { 57 | "name": "NewTypeWeight", 58 | "inputs": [ 59 | { 60 | "type": "int128", 61 | "name": "type_id", 62 | "indexed": false 63 | }, 64 | { 65 | "type": "uint256", 66 | "name": "time", 67 | "indexed": false 68 | }, 69 | { 70 | "type": "uint256", 71 | "name": "weight", 72 | "indexed": false 73 | }, 74 | { 75 | "type": "uint256", 76 | "name": "total_weight", 77 | "indexed": false 78 | } 79 | ], 80 | "anonymous": false, 81 | "type": "event" 82 | }, 83 | { 84 | "name": "NewGaugeWeight", 85 | "inputs": [ 86 | { 87 | "type": "address", 88 | "name": "gauge_address", 89 | "indexed": false 90 | }, 91 | { 92 | "type": "uint256", 93 | "name": "time", 94 | "indexed": false 95 | }, 96 | { 97 | "type": "uint256", 98 | "name": "weight", 99 | "indexed": false 100 | }, 101 | { 102 | "type": "uint256", 103 | "name": "total_weight", 104 | "indexed": false 105 | } 106 | ], 107 | "anonymous": false, 108 | "type": "event" 109 | }, 110 | { 111 | "name": "VoteForGauge", 112 | "inputs": [ 113 | { 114 | "type": "uint256", 115 | "name": "time", 116 | "indexed": false 117 | }, 118 | { 119 | "type": "address", 120 | "name": "user", 121 | "indexed": false 122 | }, 123 | { 124 | "type": "address", 125 | "name": "gauge_addr", 126 | "indexed": false 127 | }, 128 | { 129 | "type": "uint256", 130 | "name": "weight", 131 | "indexed": false 132 | } 133 | ], 134 | "anonymous": false, 135 | "type": "event" 136 | }, 137 | { 138 | "name": "NewGauge", 139 | "inputs": [ 140 | { 141 | "type": "address", 142 | "name": "addr", 143 | "indexed": false 144 | }, 145 | { 146 | "type": "int128", 147 | "name": "gauge_type", 148 | "indexed": false 149 | }, 150 | { 151 | "type": "uint256", 152 | "name": "weight", 153 | "indexed": false 154 | } 155 | ], 156 | "anonymous": false, 157 | "type": "event" 158 | }, 159 | { 160 | "outputs": [], 161 | "inputs": [ 162 | { 163 | "type": "address", 164 | "name": "_token" 165 | }, 166 | { 167 | "type": "address", 168 | "name": "_voting_escrow" 169 | } 170 | ], 171 | "stateMutability": "nonpayable", 172 | "type": "constructor" 173 | }, 174 | { 175 | "name": "commit_transfer_ownership", 176 | "outputs": [], 177 | "inputs": [ 178 | { 179 | "type": "address", 180 | "name": "addr" 181 | } 182 | ], 183 | "stateMutability": "nonpayable", 184 | "type": "function" 185 | }, 186 | { 187 | "name": "apply_transfer_ownership", 188 | "outputs": [], 189 | "inputs": [], 190 | "stateMutability": "nonpayable", 191 | "type": "function" 192 | }, 193 | { 194 | "name": "gauge_types", 195 | "outputs": [ 196 | { 197 | "type": "int128", 198 | "name": "" 199 | } 200 | ], 201 | "inputs": [ 202 | { 203 | "type": "address", 204 | "name": "_addr" 205 | } 206 | ], 207 | "stateMutability": "view", 208 | "type": "function" 209 | }, 210 | { 211 | "name": "add_gauge", 212 | "outputs": [], 213 | "inputs": [ 214 | { 215 | "type": "address", 216 | "name": "addr" 217 | }, 218 | { 219 | "type": "int128", 220 | "name": "gauge_type" 221 | } 222 | ], 223 | "stateMutability": "nonpayable", 224 | "type": "function" 225 | }, 226 | { 227 | "name": "add_gauge", 228 | "outputs": [], 229 | "inputs": [ 230 | { 231 | "type": "address", 232 | "name": "addr" 233 | }, 234 | { 235 | "type": "int128", 236 | "name": "gauge_type" 237 | }, 238 | { 239 | "type": "uint256", 240 | "name": "weight" 241 | } 242 | ], 243 | "stateMutability": "nonpayable", 244 | "type": "function" 245 | }, 246 | { 247 | "name": "checkpoint", 248 | "outputs": [], 249 | "inputs": [], 250 | "stateMutability": "nonpayable", 251 | "type": "function" 252 | }, 253 | { 254 | "name": "checkpoint_gauge", 255 | "outputs": [], 256 | "inputs": [ 257 | { 258 | "type": "address", 259 | "name": "addr" 260 | } 261 | ], 262 | "stateMutability": "nonpayable", 263 | "type": "function" 264 | }, 265 | { 266 | "name": "gauge_relative_weight", 267 | "outputs": [ 268 | { 269 | "type": "uint256", 270 | "name": "" 271 | } 272 | ], 273 | "inputs": [ 274 | { 275 | "type": "address", 276 | "name": "addr" 277 | } 278 | ], 279 | "stateMutability": "view", 280 | "type": "function" 281 | }, 282 | { 283 | "name": "gauge_relative_weight", 284 | "outputs": [ 285 | { 286 | "type": "uint256", 287 | "name": "" 288 | } 289 | ], 290 | "inputs": [ 291 | { 292 | "type": "address", 293 | "name": "addr" 294 | }, 295 | { 296 | "type": "uint256", 297 | "name": "time" 298 | } 299 | ], 300 | "stateMutability": "view", 301 | "type": "function" 302 | }, 303 | { 304 | "name": "gauge_relative_weight_write", 305 | "outputs": [ 306 | { 307 | "type": "uint256", 308 | "name": "" 309 | } 310 | ], 311 | "inputs": [ 312 | { 313 | "type": "address", 314 | "name": "addr" 315 | } 316 | ], 317 | "stateMutability": "nonpayable", 318 | "type": "function" 319 | }, 320 | { 321 | "name": "gauge_relative_weight_write", 322 | "outputs": [ 323 | { 324 | "type": "uint256", 325 | "name": "" 326 | } 327 | ], 328 | "inputs": [ 329 | { 330 | "type": "address", 331 | "name": "addr" 332 | }, 333 | { 334 | "type": "uint256", 335 | "name": "time" 336 | } 337 | ], 338 | "stateMutability": "nonpayable", 339 | "type": "function" 340 | }, 341 | { 342 | "name": "add_type", 343 | "outputs": [], 344 | "inputs": [ 345 | { 346 | "type": "string", 347 | "name": "_name" 348 | } 349 | ], 350 | "stateMutability": "nonpayable", 351 | "type": "function" 352 | }, 353 | { 354 | "name": "add_type", 355 | "outputs": [], 356 | "inputs": [ 357 | { 358 | "type": "string", 359 | "name": "_name" 360 | }, 361 | { 362 | "type": "uint256", 363 | "name": "weight" 364 | } 365 | ], 366 | "stateMutability": "nonpayable", 367 | "type": "function" 368 | }, 369 | { 370 | "name": "change_type_weight", 371 | "outputs": [], 372 | "inputs": [ 373 | { 374 | "type": "int128", 375 | "name": "type_id" 376 | }, 377 | { 378 | "type": "uint256", 379 | "name": "weight" 380 | } 381 | ], 382 | "stateMutability": "nonpayable", 383 | "type": "function" 384 | }, 385 | { 386 | "name": "change_gauge_weight", 387 | "outputs": [], 388 | "inputs": [ 389 | { 390 | "type": "address", 391 | "name": "addr" 392 | }, 393 | { 394 | "type": "uint256", 395 | "name": "weight" 396 | } 397 | ], 398 | "stateMutability": "nonpayable", 399 | "type": "function" 400 | }, 401 | { 402 | "name": "vote_for_gauge_weights", 403 | "outputs": [], 404 | "inputs": [ 405 | { 406 | "type": "address", 407 | "name": "_gauge_addr" 408 | }, 409 | { 410 | "type": "uint256", 411 | "name": "_user_weight" 412 | } 413 | ], 414 | "stateMutability": "nonpayable", 415 | "type": "function" 416 | }, 417 | { 418 | "name": "get_gauge_weight", 419 | "outputs": [ 420 | { 421 | "type": "uint256", 422 | "name": "" 423 | } 424 | ], 425 | "inputs": [ 426 | { 427 | "type": "address", 428 | "name": "addr" 429 | } 430 | ], 431 | "stateMutability": "view", 432 | "type": "function" 433 | }, 434 | { 435 | "name": "get_type_weight", 436 | "outputs": [ 437 | { 438 | "type": "uint256", 439 | "name": "" 440 | } 441 | ], 442 | "inputs": [ 443 | { 444 | "type": "int128", 445 | "name": "type_id" 446 | } 447 | ], 448 | "stateMutability": "view", 449 | "type": "function" 450 | }, 451 | { 452 | "name": "get_total_weight", 453 | "outputs": [ 454 | { 455 | "type": "uint256", 456 | "name": "" 457 | } 458 | ], 459 | "inputs": [], 460 | "stateMutability": "view", 461 | "type": "function" 462 | }, 463 | { 464 | "name": "get_weights_sum_per_type", 465 | "outputs": [ 466 | { 467 | "type": "uint256", 468 | "name": "" 469 | } 470 | ], 471 | "inputs": [ 472 | { 473 | "type": "int128", 474 | "name": "type_id" 475 | } 476 | ], 477 | "stateMutability": "view", 478 | "type": "function" 479 | }, 480 | { 481 | "name": "admin", 482 | "outputs": [ 483 | { 484 | "type": "address", 485 | "name": "" 486 | } 487 | ], 488 | "inputs": [], 489 | "stateMutability": "view", 490 | "type": "function" 491 | }, 492 | { 493 | "name": "future_admin", 494 | "outputs": [ 495 | { 496 | "type": "address", 497 | "name": "" 498 | } 499 | ], 500 | "inputs": [], 501 | "stateMutability": "view", 502 | "type": "function" 503 | }, 504 | { 505 | "name": "token", 506 | "outputs": [ 507 | { 508 | "type": "address", 509 | "name": "" 510 | } 511 | ], 512 | "inputs": [], 513 | "stateMutability": "view", 514 | "type": "function" 515 | }, 516 | { 517 | "name": "voting_escrow", 518 | "outputs": [ 519 | { 520 | "type": "address", 521 | "name": "" 522 | } 523 | ], 524 | "inputs": [], 525 | "stateMutability": "view", 526 | "type": "function" 527 | }, 528 | { 529 | "name": "n_gauge_types", 530 | "outputs": [ 531 | { 532 | "type": "int128", 533 | "name": "" 534 | } 535 | ], 536 | "inputs": [], 537 | "stateMutability": "view", 538 | "type": "function" 539 | }, 540 | { 541 | "name": "n_gauges", 542 | "outputs": [ 543 | { 544 | "type": "int128", 545 | "name": "" 546 | } 547 | ], 548 | "inputs": [], 549 | "stateMutability": "view", 550 | "type": "function" 551 | }, 552 | { 553 | "name": "gauge_type_names", 554 | "outputs": [ 555 | { 556 | "type": "string", 557 | "name": "" 558 | } 559 | ], 560 | "inputs": [ 561 | { 562 | "type": "int128", 563 | "name": "arg0" 564 | } 565 | ], 566 | "stateMutability": "view", 567 | "type": "function" 568 | }, 569 | { 570 | "name": "gauges", 571 | "outputs": [ 572 | { 573 | "type": "address", 574 | "name": "" 575 | } 576 | ], 577 | "inputs": [ 578 | { 579 | "type": "uint256", 580 | "name": "arg0" 581 | } 582 | ], 583 | "stateMutability": "view", 584 | "type": "function" 585 | }, 586 | { 587 | "name": "vote_user_slopes", 588 | "outputs": [ 589 | { 590 | "type": "uint256", 591 | "name": "slope" 592 | }, 593 | { 594 | "type": "uint256", 595 | "name": "power" 596 | }, 597 | { 598 | "type": "uint256", 599 | "name": "end" 600 | } 601 | ], 602 | "inputs": [ 603 | { 604 | "type": "address", 605 | "name": "arg0" 606 | }, 607 | { 608 | "type": "address", 609 | "name": "arg1" 610 | } 611 | ], 612 | "stateMutability": "view", 613 | "type": "function" 614 | }, 615 | { 616 | "name": "vote_user_power", 617 | "outputs": [ 618 | { 619 | "type": "uint256", 620 | "name": "" 621 | } 622 | ], 623 | "inputs": [ 624 | { 625 | "type": "address", 626 | "name": "arg0" 627 | } 628 | ], 629 | "stateMutability": "view", 630 | "type": "function" 631 | }, 632 | { 633 | "name": "last_user_vote", 634 | "outputs": [ 635 | { 636 | "type": "uint256", 637 | "name": "" 638 | } 639 | ], 640 | "inputs": [ 641 | { 642 | "type": "address", 643 | "name": "arg0" 644 | }, 645 | { 646 | "type": "address", 647 | "name": "arg1" 648 | } 649 | ], 650 | "stateMutability": "view", 651 | "type": "function" 652 | }, 653 | { 654 | "name": "points_weight", 655 | "outputs": [ 656 | { 657 | "type": "uint256", 658 | "name": "bias" 659 | }, 660 | { 661 | "type": "uint256", 662 | "name": "slope" 663 | } 664 | ], 665 | "inputs": [ 666 | { 667 | "type": "address", 668 | "name": "arg0" 669 | }, 670 | { 671 | "type": "uint256", 672 | "name": "arg1" 673 | } 674 | ], 675 | "stateMutability": "view", 676 | "type": "function" 677 | }, 678 | { 679 | "name": "time_weight", 680 | "outputs": [ 681 | { 682 | "type": "uint256", 683 | "name": "" 684 | } 685 | ], 686 | "inputs": [ 687 | { 688 | "type": "address", 689 | "name": "arg0" 690 | } 691 | ], 692 | "stateMutability": "view", 693 | "type": "function" 694 | }, 695 | { 696 | "name": "points_sum", 697 | "outputs": [ 698 | { 699 | "type": "uint256", 700 | "name": "bias" 701 | }, 702 | { 703 | "type": "uint256", 704 | "name": "slope" 705 | } 706 | ], 707 | "inputs": [ 708 | { 709 | "type": "int128", 710 | "name": "arg0" 711 | }, 712 | { 713 | "type": "uint256", 714 | "name": "arg1" 715 | } 716 | ], 717 | "stateMutability": "view", 718 | "type": "function" 719 | }, 720 | { 721 | "name": "time_sum", 722 | "outputs": [ 723 | { 724 | "type": "uint256", 725 | "name": "" 726 | } 727 | ], 728 | "inputs": [ 729 | { 730 | "type": "uint256", 731 | "name": "arg0" 732 | } 733 | ], 734 | "stateMutability": "view", 735 | "type": "function" 736 | }, 737 | { 738 | "name": "points_total", 739 | "outputs": [ 740 | { 741 | "type": "uint256", 742 | "name": "" 743 | } 744 | ], 745 | "inputs": [ 746 | { 747 | "type": "uint256", 748 | "name": "arg0" 749 | } 750 | ], 751 | "stateMutability": "view", 752 | "type": "function" 753 | }, 754 | { 755 | "name": "time_total", 756 | "outputs": [ 757 | { 758 | "type": "uint256", 759 | "name": "" 760 | } 761 | ], 762 | "inputs": [], 763 | "stateMutability": "view", 764 | "type": "function" 765 | }, 766 | { 767 | "name": "points_type_weight", 768 | "outputs": [ 769 | { 770 | "type": "uint256", 771 | "name": "" 772 | } 773 | ], 774 | "inputs": [ 775 | { 776 | "type": "int128", 777 | "name": "arg0" 778 | }, 779 | { 780 | "type": "uint256", 781 | "name": "arg1" 782 | } 783 | ], 784 | "stateMutability": "view", 785 | "type": "function" 786 | }, 787 | { 788 | "name": "time_type_weight", 789 | "outputs": [ 790 | { 791 | "type": "uint256", 792 | "name": "" 793 | } 794 | ], 795 | "inputs": [ 796 | { 797 | "type": "uint256", 798 | "name": "arg0" 799 | } 800 | ], 801 | "stateMutability": "view", 802 | "type": "function" 803 | } 804 | ]; 805 | 806 | 807 | module.exports = { 808 | CRV_ABI, 809 | MULTICALL_ABI, 810 | REGISTRY_ABI, 811 | BOOSTER_ABI, 812 | CONTROLLER_ABI, 813 | SWAP_ABI, 814 | FOREX_PRICE_ABI 815 | } -------------------------------------------------------------------------------- /tvl/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tvl", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "tvl.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "axios": "^0.21.1", 13 | "big-number": "^2.0.0", 14 | "ethers": "^5.4.0", 15 | "fs": "0.0.1-security", 16 | "got": "^11.8.2", 17 | "jsonfile": "^6.1.0" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tvl/tvl.js: -------------------------------------------------------------------------------- 1 | const { 2 | ethers 3 | } = require("ethers"); 4 | const jsonfile = require('jsonfile'); 5 | const { 6 | CRV_ABI, 7 | REGISTRY_ABI, 8 | BOOSTER_ABI, 9 | MULTICALL_ABI, 10 | SWAP_ABI, 11 | FOREX_PRICE_ABI 12 | } = require('./abi'); 13 | var BN = require('big-number'); 14 | const { default: got } = require("got/dist/source"); 15 | 16 | const config = jsonfile.readFileSync('./config.json'); 17 | 18 | //Setup ethers providers 19 | var provider; 20 | if(config.USE_PROVIDER == "infura"){ 21 | provider = new ethers.providers.InfuraProvider(config.NETWORK, config.INFURA_KEY); 22 | }else if(config.USE_PROVIDER == "alchemy"){ 23 | provider = new ethers.providers.AlchemyProvider (config.NETWORK, config.ALCHEMY_KEY); 24 | }else{ 25 | provider = new ethers.providers.JsonRpcProvider(config.GETH_NODE, config.NETWORK); 26 | } 27 | 28 | const addressZero = "0x0000000000000000000000000000000000000000" 29 | const boosterAddress = "0xF403C135812408BFbE8713b5A23a04b3D48AAE31"; 30 | const currentRegistryAddress = "0x90E00ACe148ca3b23Ac1bC8C240C2a7Dd9c2d7f5"; 31 | const cvxAddress = "0x4e3FBD56CD56c3e72c1403e103b45Db9da5B9D2B"; 32 | const cvxRewardsAddress = "0xCF50b810E57Ac33B91dCF525C6ddd9881B139332"; 33 | const cvxcrvAddress = "0x62B9c7356A2Dc64a1969e19C23e4f579F9810Aa7"; 34 | 35 | const boosterContract = new ethers.Contract(boosterAddress, BOOSTER_ABI, provider); 36 | const boosterInstance = boosterContract.connect(provider); 37 | 38 | const cvxRewardsContract = new ethers.Contract(cvxRewardsAddress, CRV_ABI, provider); 39 | const cvxRewardsInstance = cvxRewardsContract.connect(provider); 40 | 41 | const cvxcrvContract = new ethers.Contract(cvxcrvAddress, CRV_ABI, provider); 42 | const cvxcrvInstance = cvxcrvContract.connect(provider); 43 | 44 | const multicallContract = new ethers.Contract("0x5e227AD1969Ea493B43F840cfF78d08a6fc17796", MULTICALL_ABI, provider); 45 | const multicallInstance = multicallContract.connect(provider); 46 | 47 | const fixedForexPriceContract = new ethers.Contract("0x5C08bC10F45468F18CbDC65454Cbd1dd2cB1Ac65", FOREX_PRICE_ABI, provider); 48 | const fixedForexPriceInstance = fixedForexPriceContract.connect(provider); 49 | 50 | var precomputePrices = [ 51 | "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", 52 | "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", 53 | "0xfE18be6b3Bd88A2D2A7f928d00292E7a9963CfC6", 54 | "0xeb4c2781e4eba804ce9a9803c67d0893436bb27d", 55 | "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599", 56 | "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", 57 | "0xdac17f958d2ee523a2206206994597c13d831ec7", 58 | "0x6b175474e89094c44da98b954eedeac495271d0f", 59 | "0x57Ab1ec28D129707052df4dF418D58a2D46d5f51", 60 | "0x6c3f90f043a72fa612cbac8115ee7e52bde6e490", 61 | cvxAddress, 62 | cvxcrvAddress, 63 | ] 64 | 65 | var fixedForexTokens = [ 66 | "0x5555f75e3d5278082200Fb451D1b6bA946D8e13b", //jpy 67 | "0x69681f8fde45345C3870BCD5eaf4A05a60E7D227", //gbp 68 | "0xfafdf0c4c1cb09d430bf88c75d88bb46dae09967", //aud 69 | "0x96e61422b6a9ba0e068b6c5add4ffabc6a4aae27", //eur 70 | "0x1cc481ce2bd2ec7bf67d1be64d4878b16078f309", //chf 71 | "0x95dfdc8161832e4ff7816ac4b6367ce201538253", //kwr 72 | ] 73 | 74 | var allCoins = {}; 75 | 76 | const getTVL = async () => { 77 | var poolSum = {}; 78 | var coinPrices = {}; 79 | var snapshotBlock = await provider.getBlockNumber(); 80 | console.log('snapshotBlock block:' + snapshotBlock) 81 | 82 | 83 | for(var i in precomputePrices){ 84 | coinPrices[precomputePrices[i].toLowerCase()] = await coingeckoPrice(precomputePrices[i]); 85 | } 86 | 87 | for(var i in fixedForexTokens){ 88 | var price = await fixedForexPriceContract.price(fixedForexTokens[i]); 89 | coinPrices[fixedForexTokens[i].toLowerCase()] = Number(price.toString()) / 1e18; 90 | } 91 | console.log(coinPrices); 92 | 93 | let boosteriface = new ethers.utils.Interface(BOOSTER_ABI); 94 | var poolLength = await boosterInstance.poolLength({ 95 | blockTag: snapshotBlock 96 | }); 97 | var poolInfo = []; 98 | calldata = []; 99 | for (var i = 0; i < poolLength; i++) { 100 | calldata.push([boosterAddress, boosteriface.encodeFunctionData("poolInfo(uint256)", [i])]); 101 | } 102 | var returnData = await multicallInstance.aggregate(calldata, { 103 | blockTag: snapshotBlock 104 | }); 105 | for (var i = 0; i < poolLength; i++) { 106 | var pdata = boosteriface.decodeFunctionResult("poolInfo(uint256)", returnData[1][i]); 107 | poolInfo.push(pdata); 108 | } 109 | 110 | let registryiface = new ethers.utils.Interface(REGISTRY_ABI); 111 | let tokeniface = new ethers.utils.Interface(CRV_ABI); 112 | 113 | await Promise.all([...Array(Number(poolLength)).keys()].map(async i => { 114 | console.log("getting supplies and balances for pool " + i + "..."); 115 | 116 | calldata = []; 117 | calldata.push([poolInfo[i].token, tokeniface.encodeFunctionData("totalSupply()", [])]); 118 | calldata.push([poolInfo[i].lptoken, tokeniface.encodeFunctionData("totalSupply()", [])]); 119 | calldata.push([currentRegistryAddress, registryiface.encodeFunctionData("get_pool_from_lp_token(address)", [poolInfo[i].lptoken])]); 120 | var returnData = await multicallInstance.aggregate(calldata, { 121 | blockTag: snapshotBlock 122 | }); 123 | 124 | var convexsupply = tokeniface.decodeFunctionResult("totalSupply()", returnData[1][0])[0]; 125 | var totalsupply = tokeniface.decodeFunctionResult("totalSupply()", returnData[1][1])[0]; 126 | var pool = registryiface.decodeFunctionResult("get_pool_from_lp_token(address)", returnData[1][2])[0]; 127 | 128 | //console.log("convexsupply: " +convexsupply); 129 | //console.log("totalsupply: " +totalsupply); 130 | var share = new BN(convexsupply.toString()).multiply(1e18).divide(totalsupply.toString()); 131 | share = Number(share) / 1e18; 132 | //console.log("share: " +share); 133 | console.log("pool address: " +pool); 134 | 135 | var coins = []; 136 | var decimals = []; 137 | var balances = []; 138 | 139 | if(pool == addressZero){ 140 | console.log("pool " +i +" not in registry yet.") 141 | 142 | var swapContract = new ethers.Contract(poolInfo[i].lptoken, SWAP_ABI, provider); 143 | var swapInstance = swapContract.connect(provider); 144 | 145 | 146 | //get coins 147 | for(var c=0; c < 10; c++){ 148 | try{ 149 | var coin = await swapContract.coins(c); 150 | coins.push(coin); 151 | }catch(error){ 152 | //console.log("error: " +error); 153 | break; 154 | } 155 | } 156 | if(coins.length == 0){ 157 | return; 158 | } 159 | for(var d=0; d < coins.length; d++){ 160 | var tokenContract = new ethers.Contract(coins[d], CRV_ABI, provider); 161 | var tokenInstance = tokenContract.connect(provider); 162 | 163 | var dec = await tokenContract.decimals(); 164 | decimals.push(dec); 165 | 166 | var bal = await tokenContract.balanceOf(poolInfo[i].lptoken); 167 | balances.push(bal); 168 | } 169 | 170 | // console.log(coins); 171 | // console.log(decimals); 172 | // console.log(balances); 173 | 174 | }else{ 175 | //get data from registry 176 | calldata = []; 177 | calldata.push([currentRegistryAddress, registryiface.encodeFunctionData("get_underlying_coins(address)", [pool])]); 178 | calldata.push([currentRegistryAddress, registryiface.encodeFunctionData("get_coins(address)", [pool])]); 179 | calldata.push([currentRegistryAddress, registryiface.encodeFunctionData("get_underlying_balances(address)", [pool])]); 180 | calldata.push([currentRegistryAddress, registryiface.encodeFunctionData("get_underlying_decimals(address)", [pool])]); 181 | calldata.push([currentRegistryAddress, registryiface.encodeFunctionData("get_decimals(address)", [pool])]); 182 | 183 | var returnData = await multicallInstance.aggregate(calldata, { 184 | blockTag: snapshotBlock 185 | }); 186 | var underlyingcoins = registryiface.decodeFunctionResult("get_underlying_coins(address)", returnData[1][0])[0]; 187 | var maincoins = registryiface.decodeFunctionResult("get_coins(address)", returnData[1][1])[0]; 188 | balances = registryiface.decodeFunctionResult("get_underlying_balances(address)", returnData[1][2])[0]; 189 | var underlyingDecimals = registryiface.decodeFunctionResult("get_underlying_decimals(address)", returnData[1][3])[0]; 190 | var mainDecimals = registryiface.decodeFunctionResult("get_decimals(address)", returnData[1][4])[0]; 191 | 192 | 193 | //there is a pool with 0 for underlying decimals, revert to normal decimals 194 | 195 | for (var d = 0; d < underlyingDecimals.length; d++) { 196 | if (underlyingDecimals[d].toString() == "0") { 197 | decimals.push(mainDecimals[d]) 198 | } else { 199 | decimals.push(underlyingDecimals[d]); 200 | } 201 | } 202 | 203 | //fix some other discrepancies 204 | for (var c = 0; c < underlyingcoins.length; c++) { 205 | 206 | //there are pools (ex. ren) that return underlying coins of 0x0 address. replace those with normal coin address 207 | if (underlyingcoins[c] == "0x0000000000000000000000000000000000000000") { 208 | coins.push(maincoins[c]); 209 | } else { 210 | coins.push(underlyingcoins[c]); 211 | } 212 | 213 | //balances returned do not always match the decimals returns 214 | if (maincoins[c] == "0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643") { //cDai 215 | decimals[c] = 18; 216 | } 217 | if (maincoins[c] == "0x39AA39c021dfbaE8faC545936693aC917d5E7563") { //cUsdc 218 | decimals[c] = 18; 219 | } 220 | if (maincoins[c] == "0xdAC17F958D2ee523a2206206994597C13D831ec7" || maincoins[c] == "0xC581b735A1688071A1746c968e0798D642EDE491") { //usdt 221 | decimals[c] = 6; 222 | } 223 | if (underlyingcoins[c] == "0xD71eCFF9342A5Ced620049e616c5035F1dB98620") { 224 | decimals[c] = 18; 225 | } 226 | if (pool == "0x45F783CCE6B7FF23B2ab2D70e416cdb7D6055f51" //ypool 227 | || 228 | pool == "0x79a8C46DeA5aDa233ABaFFD40F3A0A2B1e5A4F27" //busd 229 | || 230 | pool == "0x06364f10B501e868329afBc005b3492902d6C763" //pax 231 | || 232 | pool == "0x2dded6Da1BF5DBdF597C45fcFaa3194e53EcfeAF" //iron 233 | || 234 | pool == "0xDeBF20617708857ebe4F679508E7b7863a8A8EeE" //aave 235 | || 236 | pool == "0xEB16Ae0052ed37f479f7fe63849198Df1765a733" //saave 237 | ) { 238 | decimals[c] = 18; 239 | } 240 | } 241 | } 242 | 243 | //format decimals 244 | var formattedBalances = []; 245 | for (var b = 0; b < balances.length; b++) { 246 | var dec = Math.pow(10, Number(decimals[b])); 247 | var formattedBal = new BN(balances[b].toString()).multiply(1e5).divide(dec.toString()); 248 | formattedBal = Number(formattedBal) / 1e5; 249 | formattedBal *= share; 250 | formattedBalances.push(formattedBal); 251 | } 252 | 253 | //sum pools together 254 | for (var c = 0; c < coins.length; c++) { 255 | if (coins[c] == "0x0000000000000000000000000000000000000000") break; 256 | var coinPrice = 0; 257 | 258 | if (coinPrices[coins[c].toLowerCase()] == undefined) { 259 | coinPrice = await coingeckoPrice(coins[c]); 260 | coinPrices[coins[c].toLowerCase()] = coinPrice; 261 | } else { 262 | coinPrice = coinPrices[coins[c].toLowerCase()]; 263 | } 264 | 265 | if (poolSum[i] == undefined) { 266 | poolSum[i] = formattedBalances[c] * coinPrice; 267 | } else { 268 | poolSum[i] = poolSum[i] + (formattedBalances[c] * coinPrice); 269 | } 270 | } 271 | 272 | })); 273 | 274 | //staked cvx 275 | var cvxStakedSupply = await cvxRewardsInstance.totalSupply({ 276 | blockTag: snapshotBlock 277 | }); 278 | var formattedCvx = new BN(cvxStakedSupply.toString()).multiply(1e5).divide(Math.pow(10, 18).toString()); 279 | stakedCvxPrice = Number(formattedCvx) / 1e5 * coinPrices[cvxAddress.toLowerCase()]; 280 | 281 | //cvxcrv 282 | var cvxcrvSupply = await cvxcrvInstance.totalSupply({ 283 | blockTag: snapshotBlock 284 | }); 285 | var formattedCvxCrv = new BN(cvxcrvSupply.toString()).multiply(1e5).divide(Math.pow(10, 18).toString()); 286 | stakedCvxCrvPrice = Number(formattedCvxCrv) / 1e5 * coinPrices[cvxcrvAddress.toLowerCase()]; 287 | 288 | console.log(poolSum); 289 | console.log("staked cvx: " +stakedCvxPrice); 290 | console.log("staked cvxcrv: " +stakedCvxCrvPrice); 291 | 292 | var totalusd = 0; 293 | for (i in poolSum) { 294 | totalusd += (Number(poolSum[i]) / 1e6); 295 | } 296 | totalusd += (Number(stakedCvxPrice) / 1e6); 297 | totalusd += (Number(stakedCvxCrvPrice) / 1e6); 298 | console.log("total usd: " + totalusd + "m"); 299 | 300 | return poolSum; 301 | } 302 | const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); 303 | const coingeckoPrice = async (coinAddress) => { 304 | if (coinAddress == "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE") { 305 | var url = "https://api.coingecko.com/api/v3/simple/price?ids=ethereum&vs_currencies=USD"; 306 | } else { 307 | var url = "https://api.coingecko.com/api/v3/simple/token_price/ethereum?contract_addresses=" + coinAddress + "&vs_currencies=USD"; 308 | } 309 | try{ 310 | //console.log("get price: " +url); 311 | var response = await got(url); 312 | var data = JSON.parse(response.body); 313 | if (data.ethereum != undefined) { 314 | return Number(data.ethereum.usd); 315 | } else { 316 | if(data[coinAddress.toLowerCase()] == undefined 317 | || data[coinAddress.toLowerCase()].usd == undefined){ 318 | return Number(0); 319 | } 320 | return Number(data[coinAddress.toLowerCase()].usd); 321 | } 322 | }catch(error){ 323 | 324 | //TODO: seed a price list at the start for common tokens 325 | 326 | console.log("coingecko error, waiting 1 min..." +url); 327 | await delay(60000); 328 | console.log("...retry now"); 329 | var retry = await coingeckoPrice(coinAddress); 330 | return retry; 331 | } 332 | } 333 | 334 | getTVL(); --------------------------------------------------------------------------------