-
-
Save ravachol70/4df4d3d8a562dcf0da96a060dd10e928 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| this bot assumes you've already enabled borrowing on compound.finance, | |
| that you already approved transfers on behalf of DAI and USDC | |
| (can do here https://chiragkhatri.me/compound-liquidator), and that you have | |
| DAI and USDC on your Ether address, while having nothing lent or borrowed yet. | |
| Author: Jarett Dunn jare@coindexlabs.com | |
| */ | |
| let request = require('request-promise') | |
| const CoinbasePro = require('coinbase-pro'); | |
| const publicClient = new CoinbasePro.PublicClient(); | |
| const Web3 = require('web3') | |
| const httpProvider = "http://localhost:8545" | |
| var web3 = new Web3(new Web3.providers.HttpProvider(httpProvider)); | |
| //coinbase credscom | |
| const key = ''; | |
| const secret = ''; | |
| const passphrase = ''; | |
| const privateKey = ""; | |
| const address = ""; | |
| const web3Pass = "" | |
| var state = 'none' | |
| let SdkManager = require('@radarrelay/sdk').SdkManager | |
| let EventName = require('@radarrelay/sdk').EventName | |
| let WebsocketRequestTopic = require('@radarrelay/types').WebsocketRequestTopic | |
| let UserOrderType = require('@radarrelay/types').UserOrderType | |
| try { | |
| web3.eth.personal.unlockAccount(address, web3Pass, 505000); | |
| } catch (err) { | |
| console.log(err) | |
| } | |
| async function setupRadar() { | |
| const rr = SdkManager.Setup({ | |
| radarRestEndpoint: 'https://api.kovan.radarrelay.com/v2', | |
| radarWebsocketEndpoint: 'wss://ws.kovan.radarrelay.com/v2', | |
| rpcUrl: 'http://localhost:8545', | |
| }); | |
| // -------------------------------- | |
| // Listen to loading progress | |
| rr.events.on(EventName.Loading, data => { | |
| process.stdout.write('....'); | |
| if (data.progress === 100) { | |
| process.stdout.write('🚀'); | |
| } | |
| }); | |
| // Initialize the SDK | |
| await SdkManager.InitializeAsync(rr); | |
| const usdcDaiMarket = await rr.markets.getAsync('USDC-DAI'); | |
| let curEthBal = await rr.account.getEthBalanceAsync(); | |
| let curUsdcBal = await rr.account.getTokenBalanceAsync(usdcDaiMarket.baseTokenAddress); | |
| console.log(curEthBal) | |
| console.log(curUsdcBal) | |
| const receipt = await rr.account.setUnlimitedTokenAllowanceAsync(usdcDaiMarket.quoteTokenAddress, { | |
| transactionOpts: {}, //gasPrice: new BigNumber(1) }, | |
| awaitTransactionMined: true | |
| }); | |
| const subscription = usdcDaiMarket.subscribe(WebsocketRequestTopic.BOOK, (mssg => { | |
| console.log(mssg) | |
| })); | |
| } | |
| setupRadar() | |
| const apiURI = 'https://api.pro.coinbase.com'; | |
| const authedClient = new CoinbasePro.AuthenticatedClient( | |
| key, | |
| secret, | |
| passphrase, | |
| apiURI | |
| ); | |
| let daidep | |
| let usdcdep | |
| async function getDeps() { | |
| let depositAddressParams = { | |
| currency: 'DAI', | |
| }; | |
| authedClient.depositCrypto(depositAddressParams, function(e, r, d) { | |
| daidep = (d.address) | |
| }); | |
| depositAddressParams = { | |
| currency: 'USDC', | |
| }; | |
| authedClient.depositCrypto(depositAddressParams, function(e, r, d) { | |
| usdcdep = (d.address) | |
| }); | |
| } | |
| getDeps() | |
| setInterval(function() { | |
| getDeps() | |
| }, 500 * 1000) | |
| let daiBal | |
| let usdcBal | |
| setInterval(function() { | |
| authedClient.getAccounts(function(e, r, d) { | |
| for (var a in d) { | |
| if (d[a].currency == 'DAI') { | |
| daiBal = parseFloat(d[a].balance) | |
| } | |
| if (d[a].currency == 'USDC') { | |
| usdcBal = parseFloat(d[a].balance) | |
| } | |
| } | |
| }); | |
| }, 10000); | |
| //create account | |
| // console.log(web3.eth.accounts.create(web3.utils.randomHex(32))); | |
| web3.eth.accounts.wallet.add({ | |
| privateKey: privateKey, | |
| address: address | |
| }); | |
| try { | |
| web3.eth.personal.unlockAccount(address, web3Pass, 505000); | |
| } catch (err) { | |
| console.log(err) | |
| } | |
| setInterval(function() { | |
| try { | |
| web3.eth.personal.unlockAccount(address, web3Pass, 505000); | |
| } catch (err) { | |
| console.log(err) | |
| } | |
| getEth() | |
| }, 500000) | |
| let ethusd = 180 | |
| async function getEth() { | |
| try { | |
| let resp = request('https://api.coinmarketcap.com/v1/ticker/ethereum/?convert=USD', function(e, r, d) { | |
| try { | |
| d = JSON.parse(d) | |
| ethusd = d[0].price_usd | |
| } catch (err) { | |
| ethusd = 180 | |
| } | |
| }) | |
| } catch (err) {} | |
| } | |
| let compounds = {} | |
| let compounds2 = {} | |
| let ddexes = {} | |
| let etheth; | |
| //dai-usdc | |
| async function compoundPrices() { | |
| try { | |
| let resp = request("https://api.compound.finance/api/v2/ctoken", function(e, r, d) { | |
| d = JSON.parse(d) | |
| for (var cToken in d.cToken) { | |
| compounds[d.cToken[cToken].underlying_symbol] = { | |
| 'id': d.cToken[cToken].underlying_symbol, | |
| 'name': d.cToken[cToken].name, | |
| 'price': d.cToken[cToken].underlying_price.value | |
| } | |
| } | |
| setTimeout(function() { | |
| prevstate = state | |
| if (compounds['DAI'].price * ethusd / (compounds['USDC'].price * ethusd) > 1.009) { | |
| state = 'sellusdc' | |
| } else if (compounds['DAI'].price * ethusd / (compounds['USDC'].price * ethusd) < 1 - .009) { | |
| state = 'selldai' | |
| } else { | |
| state = 'none' | |
| } | |
| if (maining == false) { | |
| console.log('state: ' + state) | |
| mainLoop() | |
| } | |
| }, 12000) | |
| }) | |
| } catch (err) { | |
| } | |
| } | |
| let prevstate = 'none' | |
| console.log(state) | |
| setInterval(function() { | |
| compoundPrices() | |
| getTicker() | |
| }, 5000) | |
| let ticker = {} | |
| async function getTicker() { | |
| try { | |
| publicClient.getProductTicker('DAI-USDC', function(e, r, d) { | |
| ticker = (d) | |
| }); | |
| } catch (err) {} | |
| } | |
| state = "none" | |
| compoundPrices() | |
| getTicker() | |
| let daiAbi = [{ | |
| "constant": true, | |
| "inputs": [], | |
| "name": "name", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "string" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "spender", | |
| "type": "address" | |
| }, { | |
| "name": "amount", | |
| "type": "uint256" | |
| }], | |
| "name": "approve", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "bool" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "repayAmount", | |
| "type": "uint256" | |
| }], | |
| "name": "repayBorrow", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "reserveFactorMantissa", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "account", | |
| "type": "address" | |
| }], | |
| "name": "borrowBalanceCurrent", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "totalSupply", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "exchangeRateStored", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "src", | |
| "type": "address" | |
| }, { | |
| "name": "dst", | |
| "type": "address" | |
| }, { | |
| "name": "amount", | |
| "type": "uint256" | |
| }], | |
| "name": "transferFrom", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "bool" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "borrower", | |
| "type": "address" | |
| }, { | |
| "name": "repayAmount", | |
| "type": "uint256" | |
| }], | |
| "name": "repayBorrowBehalf", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "pendingAdmin", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "address" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "decimals", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "owner", | |
| "type": "address" | |
| }], | |
| "name": "balanceOfUnderlying", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "getCash", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "newComptroller", | |
| "type": "address" | |
| }], | |
| "name": "_setComptroller", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "totalBorrows", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "comptroller", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "address" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "reduceAmount", | |
| "type": "uint256" | |
| }], | |
| "name": "_reduceReserves", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "initialExchangeRateMantissa", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "accrualBlockNumber", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "underlying", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "address" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [{ | |
| "name": "owner", | |
| "type": "address" | |
| }], | |
| "name": "balanceOf", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [], | |
| "name": "totalBorrowsCurrent", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "redeemAmount", | |
| "type": "uint256" | |
| }], | |
| "name": "redeemUnderlying", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "totalReserves", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "symbol", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "string" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [{ | |
| "name": "account", | |
| "type": "address" | |
| }], | |
| "name": "borrowBalanceStored", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "mintAmount", | |
| "type": "uint256" | |
| }], | |
| "name": "mint", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [], | |
| "name": "accrueInterest", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "dst", | |
| "type": "address" | |
| }, { | |
| "name": "amount", | |
| "type": "uint256" | |
| }], | |
| "name": "transfer", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "bool" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "borrowIndex", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "supplyRatePerBlock", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "liquidator", | |
| "type": "address" | |
| }, { | |
| "name": "borrower", | |
| "type": "address" | |
| }, { | |
| "name": "seizeTokens", | |
| "type": "uint256" | |
| }], | |
| "name": "seize", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "newPendingAdmin", | |
| "type": "address" | |
| }], | |
| "name": "_setPendingAdmin", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [], | |
| "name": "exchangeRateCurrent", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [{ | |
| "name": "account", | |
| "type": "address" | |
| }], | |
| "name": "getAccountSnapshot", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }, { | |
| "name": "", | |
| "type": "uint256" | |
| }, { | |
| "name": "", | |
| "type": "uint256" | |
| }, { | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "borrowAmount", | |
| "type": "uint256" | |
| }], | |
| "name": "borrow", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "redeemTokens", | |
| "type": "uint256" | |
| }], | |
| "name": "redeem", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [{ | |
| "name": "owner", | |
| "type": "address" | |
| }, { | |
| "name": "spender", | |
| "type": "address" | |
| }], | |
| "name": "allowance", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [], | |
| "name": "_acceptAdmin", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "newInterestRateModel", | |
| "type": "address" | |
| }], | |
| "name": "_setInterestRateModel", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "interestRateModel", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "address" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "borrower", | |
| "type": "address" | |
| }, { | |
| "name": "repayAmount", | |
| "type": "uint256" | |
| }, { | |
| "name": "cTokenCollateral", | |
| "type": "address" | |
| }], | |
| "name": "liquidateBorrow", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "admin", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "address" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "borrowRatePerBlock", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "newReserveFactorMantissa", | |
| "type": "uint256" | |
| }], | |
| "name": "_setReserveFactor", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "isCToken", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "bool" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "inputs": [{ | |
| "name": "underlying_", | |
| "type": "address" | |
| }, { | |
| "name": "comptroller_", | |
| "type": "address" | |
| }, { | |
| "name": "interestRateModel_", | |
| "type": "address" | |
| }, { | |
| "name": "initialExchangeRateMantissa_", | |
| "type": "uint256" | |
| }, { | |
| "name": "name_", | |
| "type": "string" | |
| }, { | |
| "name": "symbol_", | |
| "type": "string" | |
| }, { | |
| "name": "decimals_", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "constructor" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": false, | |
| "name": "interestAccumulated", | |
| "type": "uint256" | |
| }, { | |
| "indexed": false, | |
| "name": "borrowIndex", | |
| "type": "uint256" | |
| }, { | |
| "indexed": false, | |
| "name": "totalBorrows", | |
| "type": "uint256" | |
| }], | |
| "name": "AccrueInterest", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": false, | |
| "name": "minter", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "mintAmount", | |
| "type": "uint256" | |
| }, { | |
| "indexed": false, | |
| "name": "mintTokens", | |
| "type": "uint256" | |
| }], | |
| "name": "Mint", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": false, | |
| "name": "redeemer", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "redeemAmount", | |
| "type": "uint256" | |
| }, { | |
| "indexed": false, | |
| "name": "redeemTokens", | |
| "type": "uint256" | |
| }], | |
| "name": "Redeem", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": false, | |
| "name": "borrower", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "borrowAmount", | |
| "type": "uint256" | |
| }, { | |
| "indexed": false, | |
| "name": "accountBorrows", | |
| "type": "uint256" | |
| }, { | |
| "indexed": false, | |
| "name": "totalBorrows", | |
| "type": "uint256" | |
| }], | |
| "name": "Borrow", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": false, | |
| "name": "payer", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "borrower", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "repayAmount", | |
| "type": "uint256" | |
| }, { | |
| "indexed": false, | |
| "name": "accountBorrows", | |
| "type": "uint256" | |
| }, { | |
| "indexed": false, | |
| "name": "totalBorrows", | |
| "type": "uint256" | |
| }], | |
| "name": "RepayBorrow", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": false, | |
| "name": "liquidator", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "borrower", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "repayAmount", | |
| "type": "uint256" | |
| }, { | |
| "indexed": false, | |
| "name": "cTokenCollateral", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "seizeTokens", | |
| "type": "uint256" | |
| }], | |
| "name": "LiquidateBorrow", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": false, | |
| "name": "oldPendingAdmin", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "newPendingAdmin", | |
| "type": "address" | |
| }], | |
| "name": "NewPendingAdmin", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": false, | |
| "name": "oldAdmin", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "newAdmin", | |
| "type": "address" | |
| }], | |
| "name": "NewAdmin", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": false, | |
| "name": "oldComptroller", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "newComptroller", | |
| "type": "address" | |
| }], | |
| "name": "NewComptroller", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": false, | |
| "name": "oldInterestRateModel", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "newInterestRateModel", | |
| "type": "address" | |
| }], | |
| "name": "NewMarketInterestRateModel", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": false, | |
| "name": "oldReserveFactorMantissa", | |
| "type": "uint256" | |
| }, { | |
| "indexed": false, | |
| "name": "newReserveFactorMantissa", | |
| "type": "uint256" | |
| }], | |
| "name": "NewReserveFactor", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": false, | |
| "name": "admin", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "reduceAmount", | |
| "type": "uint256" | |
| }, { | |
| "indexed": false, | |
| "name": "newTotalReserves", | |
| "type": "uint256" | |
| }], | |
| "name": "ReservesReduced", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": false, | |
| "name": "error", | |
| "type": "uint256" | |
| }, { | |
| "indexed": false, | |
| "name": "info", | |
| "type": "uint256" | |
| }, { | |
| "indexed": false, | |
| "name": "detail", | |
| "type": "uint256" | |
| }], | |
| "name": "Failure", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": true, | |
| "name": "from", | |
| "type": "address" | |
| }, { | |
| "indexed": true, | |
| "name": "to", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "amount", | |
| "type": "uint256" | |
| }], | |
| "name": "Transfer", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": true, | |
| "name": "owner", | |
| "type": "address" | |
| }, { | |
| "indexed": true, | |
| "name": "spender", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "amount", | |
| "type": "uint256" | |
| }], | |
| "name": "Approval", | |
| "type": "event" | |
| }] | |
| let daiUnderlyingAbi = [{ | |
| "constant": true, | |
| "inputs": [], | |
| "name": "name", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "bytes32" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [], | |
| "name": "stop", | |
| "outputs": [], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "guy", | |
| "type": "address" | |
| }, { | |
| "name": "wad", | |
| "type": "uint256" | |
| }], | |
| "name": "approve", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "bool" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "owner_", | |
| "type": "address" | |
| }], | |
| "name": "setOwner", | |
| "outputs": [], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "totalSupply", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "src", | |
| "type": "address" | |
| }, { | |
| "name": "dst", | |
| "type": "address" | |
| }, { | |
| "name": "wad", | |
| "type": "uint256" | |
| }], | |
| "name": "transferFrom", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "bool" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "decimals", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "guy", | |
| "type": "address" | |
| }, { | |
| "name": "wad", | |
| "type": "uint256" | |
| }], | |
| "name": "mint", | |
| "outputs": [], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "wad", | |
| "type": "uint256" | |
| }], | |
| "name": "burn", | |
| "outputs": [], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "name_", | |
| "type": "bytes32" | |
| }], | |
| "name": "setName", | |
| "outputs": [], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [{ | |
| "name": "src", | |
| "type": "address" | |
| }], | |
| "name": "balanceOf", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "stopped", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "bool" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "authority_", | |
| "type": "address" | |
| }], | |
| "name": "setAuthority", | |
| "outputs": [], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "owner", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "address" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "symbol", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "bytes32" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "guy", | |
| "type": "address" | |
| }, { | |
| "name": "wad", | |
| "type": "uint256" | |
| }], | |
| "name": "burn", | |
| "outputs": [], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "wad", | |
| "type": "uint256" | |
| }], | |
| "name": "mint", | |
| "outputs": [], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "dst", | |
| "type": "address" | |
| }, { | |
| "name": "wad", | |
| "type": "uint256" | |
| }], | |
| "name": "transfer", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "bool" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "dst", | |
| "type": "address" | |
| }, { | |
| "name": "wad", | |
| "type": "uint256" | |
| }], | |
| "name": "push", | |
| "outputs": [], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "src", | |
| "type": "address" | |
| }, { | |
| "name": "dst", | |
| "type": "address" | |
| }, { | |
| "name": "wad", | |
| "type": "uint256" | |
| }], | |
| "name": "move", | |
| "outputs": [], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [], | |
| "name": "start", | |
| "outputs": [], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "authority", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "address" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "guy", | |
| "type": "address" | |
| }], | |
| "name": "approve", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "bool" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [{ | |
| "name": "src", | |
| "type": "address" | |
| }, { | |
| "name": "guy", | |
| "type": "address" | |
| }], | |
| "name": "allowance", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "src", | |
| "type": "address" | |
| }, { | |
| "name": "wad", | |
| "type": "uint256" | |
| }], | |
| "name": "pull", | |
| "outputs": [], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "inputs": [{ | |
| "name": "symbol_", | |
| "type": "bytes32" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "constructor" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": true, | |
| "name": "guy", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "wad", | |
| "type": "uint256" | |
| }], | |
| "name": "Mint", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": true, | |
| "name": "guy", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "wad", | |
| "type": "uint256" | |
| }], | |
| "name": "Burn", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": true, | |
| "name": "authority", | |
| "type": "address" | |
| }], | |
| "name": "LogSetAuthority", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": true, | |
| "name": "owner", | |
| "type": "address" | |
| }], | |
| "name": "LogSetOwner", | |
| "type": "event" | |
| }, { | |
| "anonymous": true, | |
| "inputs": [{ | |
| "indexed": true, | |
| "name": "sig", | |
| "type": "bytes4" | |
| }, { | |
| "indexed": true, | |
| "name": "guy", | |
| "type": "address" | |
| }, { | |
| "indexed": true, | |
| "name": "foo", | |
| "type": "bytes32" | |
| }, { | |
| "indexed": true, | |
| "name": "bar", | |
| "type": "bytes32" | |
| }, { | |
| "indexed": false, | |
| "name": "wad", | |
| "type": "uint256" | |
| }, { | |
| "indexed": false, | |
| "name": "fax", | |
| "type": "bytes" | |
| }], | |
| "name": "LogNote", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": true, | |
| "name": "src", | |
| "type": "address" | |
| }, { | |
| "indexed": true, | |
| "name": "guy", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "wad", | |
| "type": "uint256" | |
| }], | |
| "name": "Approval", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": true, | |
| "name": "src", | |
| "type": "address" | |
| }, { | |
| "indexed": true, | |
| "name": "dst", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "wad", | |
| "type": "uint256" | |
| }], | |
| "name": "Transfer", | |
| "type": "event" | |
| }] | |
| let daiAddress = '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359' | |
| let usdcAbi = [{ | |
| "constant": true, | |
| "inputs": [], | |
| "name": "name", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "string" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "spender", | |
| "type": "address" | |
| }, { | |
| "name": "amount", | |
| "type": "uint256" | |
| }], | |
| "name": "approve", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "bool" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "repayAmount", | |
| "type": "uint256" | |
| }], | |
| "name": "repayBorrow", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "reserveFactorMantissa", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "account", | |
| "type": "address" | |
| }], | |
| "name": "borrowBalanceCurrent", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "totalSupply", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "exchangeRateStored", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "src", | |
| "type": "address" | |
| }, { | |
| "name": "dst", | |
| "type": "address" | |
| }, { | |
| "name": "amount", | |
| "type": "uint256" | |
| }], | |
| "name": "transferFrom", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "bool" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "borrower", | |
| "type": "address" | |
| }, { | |
| "name": "repayAmount", | |
| "type": "uint256" | |
| }], | |
| "name": "repayBorrowBehalf", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "pendingAdmin", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "address" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "decimals", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "owner", | |
| "type": "address" | |
| }], | |
| "name": "balanceOfUnderlying", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "getCash", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "newComptroller", | |
| "type": "address" | |
| }], | |
| "name": "_setComptroller", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "totalBorrows", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "comptroller", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "address" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "reduceAmount", | |
| "type": "uint256" | |
| }], | |
| "name": "_reduceReserves", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "initialExchangeRateMantissa", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "accrualBlockNumber", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "underlying", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "address" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [{ | |
| "name": "owner", | |
| "type": "address" | |
| }], | |
| "name": "balanceOf", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [], | |
| "name": "totalBorrowsCurrent", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "redeemAmount", | |
| "type": "uint256" | |
| }], | |
| "name": "redeemUnderlying", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "totalReserves", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "symbol", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "string" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [{ | |
| "name": "account", | |
| "type": "address" | |
| }], | |
| "name": "borrowBalanceStored", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "mintAmount", | |
| "type": "uint256" | |
| }], | |
| "name": "mint", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [], | |
| "name": "accrueInterest", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "dst", | |
| "type": "address" | |
| }, { | |
| "name": "amount", | |
| "type": "uint256" | |
| }], | |
| "name": "transfer", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "bool" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "borrowIndex", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "supplyRatePerBlock", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "liquidator", | |
| "type": "address" | |
| }, { | |
| "name": "borrower", | |
| "type": "address" | |
| }, { | |
| "name": "seizeTokens", | |
| "type": "uint256" | |
| }], | |
| "name": "seize", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "newPendingAdmin", | |
| "type": "address" | |
| }], | |
| "name": "_setPendingAdmin", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [], | |
| "name": "exchangeRateCurrent", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [{ | |
| "name": "account", | |
| "type": "address" | |
| }], | |
| "name": "getAccountSnapshot", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }, { | |
| "name": "", | |
| "type": "uint256" | |
| }, { | |
| "name": "", | |
| "type": "uint256" | |
| }, { | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "borrowAmount", | |
| "type": "uint256" | |
| }], | |
| "name": "borrow", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "redeemTokens", | |
| "type": "uint256" | |
| }], | |
| "name": "redeem", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [{ | |
| "name": "owner", | |
| "type": "address" | |
| }, { | |
| "name": "spender", | |
| "type": "address" | |
| }], | |
| "name": "allowance", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [], | |
| "name": "_acceptAdmin", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "newInterestRateModel", | |
| "type": "address" | |
| }], | |
| "name": "_setInterestRateModel", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "interestRateModel", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "address" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "borrower", | |
| "type": "address" | |
| }, { | |
| "name": "repayAmount", | |
| "type": "uint256" | |
| }, { | |
| "name": "cTokenCollateral", | |
| "type": "address" | |
| }], | |
| "name": "liquidateBorrow", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "admin", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "address" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "borrowRatePerBlock", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "newReserveFactorMantissa", | |
| "type": "uint256" | |
| }], | |
| "name": "_setReserveFactor", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "isCToken", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "bool" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "inputs": [{ | |
| "name": "underlying_", | |
| "type": "address" | |
| }, { | |
| "name": "comptroller_", | |
| "type": "address" | |
| }, { | |
| "name": "interestRateModel_", | |
| "type": "address" | |
| }, { | |
| "name": "initialExchangeRateMantissa_", | |
| "type": "uint256" | |
| }, { | |
| "name": "name_", | |
| "type": "string" | |
| }, { | |
| "name": "symbol_", | |
| "type": "string" | |
| }, { | |
| "name": "decimals_", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "constructor" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": false, | |
| "name": "interestAccumulated", | |
| "type": "uint256" | |
| }, { | |
| "indexed": false, | |
| "name": "borrowIndex", | |
| "type": "uint256" | |
| }, { | |
| "indexed": false, | |
| "name": "totalBorrows", | |
| "type": "uint256" | |
| }], | |
| "name": "AccrueInterest", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": false, | |
| "name": "minter", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "mintAmount", | |
| "type": "uint256" | |
| }, { | |
| "indexed": false, | |
| "name": "mintTokens", | |
| "type": "uint256" | |
| }], | |
| "name": "Mint", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": false, | |
| "name": "redeemer", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "redeemAmount", | |
| "type": "uint256" | |
| }, { | |
| "indexed": false, | |
| "name": "redeemTokens", | |
| "type": "uint256" | |
| }], | |
| "name": "Redeem", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": false, | |
| "name": "borrower", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "borrowAmount", | |
| "type": "uint256" | |
| }, { | |
| "indexed": false, | |
| "name": "accountBorrows", | |
| "type": "uint256" | |
| }, { | |
| "indexed": false, | |
| "name": "totalBorrows", | |
| "type": "uint256" | |
| }], | |
| "name": "Borrow", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": false, | |
| "name": "payer", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "borrower", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "repayAmount", | |
| "type": "uint256" | |
| }, { | |
| "indexed": false, | |
| "name": "accountBorrows", | |
| "type": "uint256" | |
| }, { | |
| "indexed": false, | |
| "name": "totalBorrows", | |
| "type": "uint256" | |
| }], | |
| "name": "RepayBorrow", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": false, | |
| "name": "liquidator", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "borrower", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "repayAmount", | |
| "type": "uint256" | |
| }, { | |
| "indexed": false, | |
| "name": "cTokenCollateral", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "seizeTokens", | |
| "type": "uint256" | |
| }], | |
| "name": "LiquidateBorrow", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": false, | |
| "name": "oldPendingAdmin", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "newPendingAdmin", | |
| "type": "address" | |
| }], | |
| "name": "NewPendingAdmin", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": false, | |
| "name": "oldAdmin", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "newAdmin", | |
| "type": "address" | |
| }], | |
| "name": "NewAdmin", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": false, | |
| "name": "oldComptroller", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "newComptroller", | |
| "type": "address" | |
| }], | |
| "name": "NewComptroller", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": false, | |
| "name": "oldInterestRateModel", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "newInterestRateModel", | |
| "type": "address" | |
| }], | |
| "name": "NewMarketInterestRateModel", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": false, | |
| "name": "oldReserveFactorMantissa", | |
| "type": "uint256" | |
| }, { | |
| "indexed": false, | |
| "name": "newReserveFactorMantissa", | |
| "type": "uint256" | |
| }], | |
| "name": "NewReserveFactor", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": false, | |
| "name": "admin", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "reduceAmount", | |
| "type": "uint256" | |
| }, { | |
| "indexed": false, | |
| "name": "newTotalReserves", | |
| "type": "uint256" | |
| }], | |
| "name": "ReservesReduced", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": false, | |
| "name": "error", | |
| "type": "uint256" | |
| }, { | |
| "indexed": false, | |
| "name": "info", | |
| "type": "uint256" | |
| }, { | |
| "indexed": false, | |
| "name": "detail", | |
| "type": "uint256" | |
| }], | |
| "name": "Failure", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": true, | |
| "name": "from", | |
| "type": "address" | |
| }, { | |
| "indexed": true, | |
| "name": "to", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "amount", | |
| "type": "uint256" | |
| }], | |
| "name": "Transfer", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": true, | |
| "name": "owner", | |
| "type": "address" | |
| }, { | |
| "indexed": true, | |
| "name": "spender", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "amount", | |
| "type": "uint256" | |
| }], | |
| "name": "Approval", | |
| "type": "event" | |
| }] | |
| let usdcUnderlyingAbi = [{ | |
| "constant": true, | |
| "inputs": [], | |
| "name": "name", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "string" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "_spender", | |
| "type": "address" | |
| }, { | |
| "name": "_value", | |
| "type": "uint256" | |
| }], | |
| "name": "approve", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "bool" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "_to", | |
| "type": "address" | |
| }, { | |
| "name": "_amount", | |
| "type": "uint256" | |
| }], | |
| "name": "issueTo", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "bool" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "totalSupply", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "newIssuer", | |
| "type": "address" | |
| }], | |
| "name": "addIssuer", | |
| "outputs": [], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "_from", | |
| "type": "address" | |
| }, { | |
| "name": "_to", | |
| "type": "address" | |
| }, { | |
| "name": "_value", | |
| "type": "uint256" | |
| }], | |
| "name": "transferFrom", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "bool" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "decimals", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [{ | |
| "name": "", | |
| "type": "address" | |
| }], | |
| "name": "issuers", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "bool" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [], | |
| "name": "unpause", | |
| "outputs": [], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "_value", | |
| "type": "uint256" | |
| }], | |
| "name": "burn", | |
| "outputs": [], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "removedIssuer", | |
| "type": "address" | |
| }], | |
| "name": "removeIssuer", | |
| "outputs": [], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "paused", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "bool" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "_spender", | |
| "type": "address" | |
| }, { | |
| "name": "_subtractedValue", | |
| "type": "uint256" | |
| }], | |
| "name": "decreaseApproval", | |
| "outputs": [{ | |
| "name": "success", | |
| "type": "bool" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [{ | |
| "name": "_owner", | |
| "type": "address" | |
| }], | |
| "name": "balanceOf", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [], | |
| "name": "renounceOwnership", | |
| "outputs": [], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "_from", | |
| "type": "address" | |
| }, { | |
| "name": "_value", | |
| "type": "uint256" | |
| }], | |
| "name": "burnFrom", | |
| "outputs": [], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [], | |
| "name": "pause", | |
| "outputs": [], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "owner", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "address" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "symbol", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "string" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "_to", | |
| "type": "address" | |
| }, { | |
| "name": "_value", | |
| "type": "uint256" | |
| }], | |
| "name": "transfer", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "bool" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "_amount", | |
| "type": "uint256" | |
| }], | |
| "name": "issue", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "bool" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "_spender", | |
| "type": "address" | |
| }, { | |
| "name": "_addedValue", | |
| "type": "uint256" | |
| }], | |
| "name": "increaseApproval", | |
| "outputs": [{ | |
| "name": "success", | |
| "type": "bool" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [{ | |
| "name": "_owner", | |
| "type": "address" | |
| }, { | |
| "name": "_spender", | |
| "type": "address" | |
| }], | |
| "name": "allowance", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "_newOwner", | |
| "type": "address" | |
| }], | |
| "name": "transferOwnership", | |
| "outputs": [], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "inputs": [{ | |
| "name": "initialSupply", | |
| "type": "uint256" | |
| }, { | |
| "name": "tokenName", | |
| "type": "string" | |
| }, { | |
| "name": "tokenSymbol", | |
| "type": "string" | |
| }, { | |
| "name": "tokenDecimals", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "constructor" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": true, | |
| "name": "to", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "amount", | |
| "type": "uint256" | |
| }], | |
| "name": "Mint", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": true, | |
| "name": "newIssuer", | |
| "type": "address" | |
| }], | |
| "name": "IssuerAdded", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": true, | |
| "name": "removedIssuer", | |
| "type": "address" | |
| }], | |
| "name": "IssuerRemoved", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [], | |
| "name": "Pause", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [], | |
| "name": "Unpause", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": true, | |
| "name": "previousOwner", | |
| "type": "address" | |
| }], | |
| "name": "OwnershipRenounced", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": true, | |
| "name": "previousOwner", | |
| "type": "address" | |
| }, { | |
| "indexed": true, | |
| "name": "newOwner", | |
| "type": "address" | |
| }], | |
| "name": "OwnershipTransferred", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": true, | |
| "name": "burner", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "value", | |
| "type": "uint256" | |
| }], | |
| "name": "Burn", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": true, | |
| "name": "owner", | |
| "type": "address" | |
| }, { | |
| "indexed": true, | |
| "name": "spender", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "value", | |
| "type": "uint256" | |
| }], | |
| "name": "Approval", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": true, | |
| "name": "from", | |
| "type": "address" | |
| }, { | |
| "indexed": true, | |
| "name": "to", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "value", | |
| "type": "uint256" | |
| }], | |
| "name": "Transfer", | |
| "type": "event" | |
| }] | |
| let usdsAddress = '0xa4bdb11dc0a2bec88d24a3aa1e6bb17201112ebe' | |
| let trollAbi = [{ | |
| "constant": true, | |
| "inputs": [], | |
| "name": "pendingAdmin", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "address" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "newPendingAdmin", | |
| "type": "address" | |
| }], | |
| "name": "_setPendingAdmin", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "comptrollerImplementation", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "address" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [], | |
| "name": "_acceptImplementation", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "pendingComptrollerImplementation", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "address" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "newPendingImplementation", | |
| "type": "address" | |
| }], | |
| "name": "_setPendingImplementation", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [], | |
| "name": "_acceptAdmin", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "admin", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "address" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "inputs": [], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "constructor" | |
| }, { | |
| "payable": true, | |
| "stateMutability": "payable", | |
| "type": "fallback" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": false, | |
| "name": "oldPendingImplementation", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "newPendingImplementation", | |
| "type": "address" | |
| }], | |
| "name": "NewPendingImplementation", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": false, | |
| "name": "oldImplementation", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "newImplementation", | |
| "type": "address" | |
| }], | |
| "name": "NewImplementation", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": false, | |
| "name": "oldPendingAdmin", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "newPendingAdmin", | |
| "type": "address" | |
| }], | |
| "name": "NewPendingAdmin", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": false, | |
| "name": "oldAdmin", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "newAdmin", | |
| "type": "address" | |
| }], | |
| "name": "NewAdmin", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": false, | |
| "name": "error", | |
| "type": "uint256" | |
| }, { | |
| "indexed": false, | |
| "name": "info", | |
| "type": "uint256" | |
| }, { | |
| "indexed": false, | |
| "name": "detail", | |
| "type": "uint256" | |
| }], | |
| "name": "Failure", | |
| "type": "event" | |
| }] | |
| let cDAI = "0xf5dce57282a584d2746faf1593d3121fcac444dc" | |
| let cDaiInstance = new web3.eth.Contract(daiAbi, cDAI); | |
| let cUsdc = '0x39aa39c021dfbae8fac545936693ac917d5e7563' | |
| let DAI2 = '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359' | |
| let USDC2 = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' | |
| let cUsdcInstance = new web3.eth.Contract(usdcAbi, cUsdc); | |
| let usdcabi2 = [{ | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "newImplementation", | |
| "type": "address" | |
| }], | |
| "name": "upgradeTo", | |
| "outputs": [], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "newImplementation", | |
| "type": "address" | |
| }, { | |
| "name": "data", | |
| "type": "bytes" | |
| }], | |
| "name": "upgradeToAndCall", | |
| "outputs": [], | |
| "payable": true, | |
| "stateMutability": "payable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "implementation", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "address" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "newAdmin", | |
| "type": "address" | |
| }], | |
| "name": "changeAdmin", | |
| "outputs": [], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "admin", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "address" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "inputs": [{ | |
| "name": "_implementation", | |
| "type": "address" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "constructor" | |
| }, { | |
| "payable": true, | |
| "stateMutability": "payable", | |
| "type": "fallback" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": false, | |
| "name": "previousAdmin", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "newAdmin", | |
| "type": "address" | |
| }], | |
| "name": "AdminChanged", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": false, | |
| "name": "implementation", | |
| "type": "address" | |
| }], | |
| "name": "Upgraded", | |
| "type": "event" | |
| }] | |
| let daiabi2 = [{ | |
| "constant": true, | |
| "inputs": [], | |
| "name": "name", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "bytes32" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [], | |
| "name": "stop", | |
| "outputs": [], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "guy", | |
| "type": "address" | |
| }, { | |
| "name": "wad", | |
| "type": "uint256" | |
| }], | |
| "name": "approve", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "bool" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "owner_", | |
| "type": "address" | |
| }], | |
| "name": "setOwner", | |
| "outputs": [], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "totalSupply", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "src", | |
| "type": "address" | |
| }, { | |
| "name": "dst", | |
| "type": "address" | |
| }, { | |
| "name": "wad", | |
| "type": "uint256" | |
| }], | |
| "name": "transferFrom", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "bool" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "decimals", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "guy", | |
| "type": "address" | |
| }, { | |
| "name": "wad", | |
| "type": "uint256" | |
| }], | |
| "name": "mint", | |
| "outputs": [], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "wad", | |
| "type": "uint256" | |
| }], | |
| "name": "burn", | |
| "outputs": [], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "name_", | |
| "type": "bytes32" | |
| }], | |
| "name": "setName", | |
| "outputs": [], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [{ | |
| "name": "src", | |
| "type": "address" | |
| }], | |
| "name": "balanceOf", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "stopped", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "bool" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "authority_", | |
| "type": "address" | |
| }], | |
| "name": "setAuthority", | |
| "outputs": [], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "owner", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "address" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "symbol", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "bytes32" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "guy", | |
| "type": "address" | |
| }, { | |
| "name": "wad", | |
| "type": "uint256" | |
| }], | |
| "name": "burn", | |
| "outputs": [], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "wad", | |
| "type": "uint256" | |
| }], | |
| "name": "mint", | |
| "outputs": [], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "dst", | |
| "type": "address" | |
| }, { | |
| "name": "wad", | |
| "type": "uint256" | |
| }], | |
| "name": "transfer", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "bool" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "dst", | |
| "type": "address" | |
| }, { | |
| "name": "wad", | |
| "type": "uint256" | |
| }], | |
| "name": "push", | |
| "outputs": [], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "src", | |
| "type": "address" | |
| }, { | |
| "name": "dst", | |
| "type": "address" | |
| }, { | |
| "name": "wad", | |
| "type": "uint256" | |
| }], | |
| "name": "move", | |
| "outputs": [], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [], | |
| "name": "start", | |
| "outputs": [], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "authority", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "address" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "guy", | |
| "type": "address" | |
| }], | |
| "name": "approve", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "bool" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "constant": true, | |
| "inputs": [{ | |
| "name": "src", | |
| "type": "address" | |
| }, { | |
| "name": "guy", | |
| "type": "address" | |
| }], | |
| "name": "allowance", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint256" | |
| }], | |
| "payable": false, | |
| "stateMutability": "view", | |
| "type": "function" | |
| }, { | |
| "constant": false, | |
| "inputs": [{ | |
| "name": "src", | |
| "type": "address" | |
| }, { | |
| "name": "wad", | |
| "type": "uint256" | |
| }], | |
| "name": "pull", | |
| "outputs": [], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "function" | |
| }, { | |
| "inputs": [{ | |
| "name": "symbol_", | |
| "type": "bytes32" | |
| }], | |
| "payable": false, | |
| "stateMutability": "nonpayable", | |
| "type": "constructor" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": true, | |
| "name": "guy", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "wad", | |
| "type": "uint256" | |
| }], | |
| "name": "Mint", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": true, | |
| "name": "guy", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "wad", | |
| "type": "uint256" | |
| }], | |
| "name": "Burn", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": true, | |
| "name": "authority", | |
| "type": "address" | |
| }], | |
| "name": "LogSetAuthority", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": true, | |
| "name": "owner", | |
| "type": "address" | |
| }], | |
| "name": "LogSetOwner", | |
| "type": "event" | |
| }, { | |
| "anonymous": true, | |
| "inputs": [{ | |
| "indexed": true, | |
| "name": "sig", | |
| "type": "bytes4" | |
| }, { | |
| "indexed": true, | |
| "name": "guy", | |
| "type": "address" | |
| }, { | |
| "indexed": true, | |
| "name": "foo", | |
| "type": "bytes32" | |
| }, { | |
| "indexed": true, | |
| "name": "bar", | |
| "type": "bytes32" | |
| }, { | |
| "indexed": false, | |
| "name": "wad", | |
| "type": "uint256" | |
| }, { | |
| "indexed": false, | |
| "name": "fax", | |
| "type": "bytes" | |
| }], | |
| "name": "LogNote", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": true, | |
| "name": "src", | |
| "type": "address" | |
| }, { | |
| "indexed": true, | |
| "name": "guy", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "wad", | |
| "type": "uint256" | |
| }], | |
| "name": "Approval", | |
| "type": "event" | |
| }, { | |
| "anonymous": false, | |
| "inputs": [{ | |
| "indexed": true, | |
| "name": "src", | |
| "type": "address" | |
| }, { | |
| "indexed": true, | |
| "name": "dst", | |
| "type": "address" | |
| }, { | |
| "indexed": false, | |
| "name": "wad", | |
| "type": "uint256" | |
| }], | |
| "name": "Transfer", | |
| "type": "event" | |
| }] | |
| let minABI = [ | |
| // balanceOf | |
| { | |
| "constant": true, | |
| "inputs": [{ | |
| "name": "_owner", | |
| "type": "address" | |
| }], | |
| "name": "balanceOf", | |
| "outputs": [{ | |
| "name": "balance", | |
| "type": "uint256" | |
| }], | |
| "type": "function" | |
| }, | |
| // decimals | |
| { | |
| "constant": true, | |
| "inputs": [], | |
| "name": "decimals", | |
| "outputs": [{ | |
| "name": "", | |
| "type": "uint8" | |
| }], | |
| "type": "function" | |
| } | |
| ]; | |
| let i1 = new web3.eth.Contract(minABI, DAI2); | |
| let i2 = new web3.eth.Contract(minABI, USDC2); | |
| let decs = {} | |
| async function balances() { | |
| let balance = await cDaiInstance.methods.balanceOf(address).call() | |
| // Get decimals | |
| let decimals = await cDaiInstance.methods.decimals().call() | |
| // calculate a balance | |
| balance = balance / (10 ** decimals); | |
| bs['cDAI'] = balance; | |
| decs['cDAI'] = parseFloat(decimals) | |
| balance = await cUsdcInstance.methods.balanceOf(address).call() | |
| // Get decimals | |
| decimals = await cUsdcInstance.methods.decimals().call() | |
| // calculate a balance | |
| balance = balance / (10 ** decimals); | |
| bs['cUSDC'] = balance; | |
| decs['cUSDC'] = parseFloat(decimals) | |
| balance = await i1.methods.balanceOf(address).call() | |
| // Get decimals | |
| decimals = await i1.methods.decimals().call() | |
| // calculate a balance | |
| balance = balance / (10 ** decimals); | |
| bs['DAI'] = balance; | |
| decs['DAI'] = parseFloat(decimals) | |
| balance = await i2.methods.balanceOf(address).call() | |
| // Get decimals | |
| decimals = await i2.methods.decimals().call() | |
| // calculate a balance | |
| balance = balance / (10 ** decimals); | |
| bs['USDC'] = balance; | |
| decs['USDC'] = parseFloat(decimals) | |
| } | |
| let bs = {} | |
| balances() | |
| setInterval(function() { | |
| balances() | |
| }, 3000) | |
| let comptroller = "0x3d9819210a31b4961b30ef54be2aed79b9c9cd3b"; | |
| let borrowed | |
| const troll = new web3.eth.Contract(trollAbi, comptroller); | |
| let firstrun = true; | |
| let maining = false | |
| async function mainLoop() { | |
| console.log('mainloop') | |
| maining = true | |
| if ((prevstate == 'none' && state == 'selldai' || prevstate == 'none' && state == 'sellusdc') && !firstrun) { | |
| if (borrowed.token == 'DAI') { | |
| await cDaiInstance.methods.repayBorrow(Math.floor(borrowed.amount)).send({ | |
| from: address, | |
| gasPrice: "0x51F4D5C00" | |
| }); | |
| } | |
| firstrun = true | |
| if (borrowed.token == 'USDC') { | |
| await cUsdcInstance.methods.repayBorrow(Math.floor(borrowed.amount)).send({ | |
| from: address, | |
| gasPrice: "0x51F4D5C00" | |
| }); | |
| } | |
| } | |
| if (state == 'sellusdc') { // && bs['DAI'] >= 1){ | |
| //var amt = web3.utils.toWei((bs['DAI'] ).toString()) | |
| var amt2 = Math.floor(4.32 * 10 ** decs['USDC'] * 0.75 * 0.8) | |
| console.log('...minting...') | |
| // await cDaiInstance.methods.mint(amt).send({from: address, gasLimit: '0x493E0',gasPrice: "0x51F4D5C00"}); | |
| if (firstrun) { | |
| //await cUsdcInstance.methods.borrow(amt2).send({from: address, gasLimit: '0x' + ((1000000).toString(16)),gasPrice: "0x51F4D5C00"}); | |
| firstrun = false; | |
| borrowed = { | |
| 'token': 'USDC', | |
| 'amount': amt2 | |
| } | |
| } | |
| var count = web3.eth.getTransactionCount(address); | |
| var abiArray = usdcUnderlyingAbi; | |
| var contractAddress = usdsAddress; | |
| var contract = new web3.eth.Contract(abiArray, contractAddress); | |
| balances() | |
| var rawTransaction = { | |
| "from": address, | |
| "nonce": '0x' + count.toString(16), | |
| "gasPrice": "0x51F4D5C00", | |
| "gasLimit": "0x7458", | |
| "to": contractAddress, | |
| "value": "0x0", | |
| "data": contract.methods.transfer.getData(usdcdep, bs['USDC'], { | |
| from: address | |
| }), | |
| "chainId": 1 | |
| }; | |
| var privKey = new Buffer(privateKey, 'hex'); | |
| var tx = new Tx(rawTransaction); | |
| tx.sign(privKey); | |
| var serializedTx = tx.serialize(); | |
| /* | |
| web3.eth.sendRawTransaction('0x' + serializedTx.toString('hex'), function(err, hash) { | |
| if (!err){ | |
| console.log(hash); | |
| //state = 'exchange' | |
| console.log('exchange') | |
| setTimeout(function(){ | |
| doExchange() | |
| }, 5000) | |
| } | |
| else | |
| console.log(err); | |
| }); | |
| */ | |
| } else if (state == 'selldai' && bs['USDC'] >= 1) { | |
| var amt = bs['USDC'] * (10 ** decs['USDC']) | |
| var amt2 = Math.floor(bs['USDC'] * 10 ** decs['DAI'] * 0.75 * 0.8) | |
| await cUsdcInstance.methods.mint(amt).send({ | |
| from: address, | |
| gasLimit: '0x493E0', | |
| gasPrice: "0x51F4D5C00" | |
| }); | |
| if (firstrun) { | |
| await cDaiInstance.methods.borrow(amt2).send({ | |
| from: address, | |
| gasLimit: '0x' + ((1000000).toString(16)), | |
| gasPrice: "0x51F4D5C00" | |
| }); | |
| firstrun = false; | |
| borrowed = { | |
| 'token': 'DAI', | |
| 'amount': amt2 | |
| } | |
| } | |
| var count = web3.eth.getTransactionCount(address); | |
| var abiArray = daiUnderlyingAbi; | |
| var contractAddress = daiAddress; | |
| var contract = new web3.eth.Contract(abiArray, contractAddress); | |
| balances() | |
| var rawTransaction = { | |
| "from": address, | |
| "nonce": '0x' + count.toString(16), | |
| "gasPrice": "0x51F4D5C00", | |
| "gasLimit": "0x7458", | |
| "to": contractAddress, | |
| "value": "0x0", | |
| "data": contract.methods.transfer.getData(daidep, bs['DAI'], { | |
| from: address | |
| }), | |
| "chainId": 1 | |
| }; | |
| var privKey = new Buffer(privateKey, 'hex'); | |
| var tx = new Tx(rawTransaction); | |
| tx.sign(privKey); | |
| var serializedTx = tx.serialize(); | |
| /* | |
| web3.eth.sendRawTransaction('0x' + serializedTx.toString('hex'), function(err, hash) { | |
| if (!err){ | |
| console.log(hash); | |
| //state = 'exchange' | |
| console.log('exchange') | |
| setTimeout(function(){ | |
| doExchange() | |
| }, 5000) | |
| } | |
| else | |
| console.log(err); | |
| }); */ | |
| } else { | |
| setTimeout(function() { | |
| mainLoop(); | |
| }, 45000) | |
| } | |
| } | |
| async function doExchange() { | |
| if (daiBal < 1 && usdcBal < 1) { | |
| setTimeout(function() { | |
| doExchange() | |
| }, 15000) | |
| } else if (usdcBal >= 1) { | |
| // Sell 1 BTC @ 110 USD | |
| const sellParams = { | |
| price: ticker['DAI-USDC'].bid, // USD | |
| size: usdcBal, // BTC | |
| product_id: 'DAI-USDC', | |
| post_only: false | |
| }; | |
| authedClient.sell(sellParams, callback); | |
| setTimeout(function() { | |
| state = 'selusdc' | |
| console.log(state) | |
| setTimeout(function() { | |
| maining = false; | |
| }, 60000) | |
| const withdrawAddressParams = { | |
| amount: daiBal, | |
| currency: 'DAI', | |
| crypto_address: '0x8545d4515e27c092bd25d30EB1deb4fDF100AF92', | |
| }; | |
| authedClient.withdrawCrypto(withdrawAddressParams, function(e, r, d) { | |
| console.log(e) | |
| console.log(d) | |
| }); | |
| }, 15000); | |
| } else if (daiBal >= 1) { | |
| // Buy 1 BTC @ 100 USD | |
| const buyParams = { | |
| price: ticker['DAI-USDC'].ask, // USD | |
| size: daiBal, // BTC | |
| product_id: 'DAI-USDC', | |
| post_only: false | |
| }; | |
| authedClient.buy(buyParams, callback); | |
| setTimeout(function() { | |
| setTimeout(function() { | |
| maining = false; | |
| }, 60000) | |
| state = 'selldai' | |
| console.log(state) | |
| const withdrawAddressParams = { | |
| amount: usdcBal, | |
| currency: 'USDC', | |
| crypto_address: '0x8545d4515e27c092bd25d30EB1deb4fDF100AF92', | |
| }; | |
| authedClient.withdrawCrypto(withdrawAddressParams, function(e, r, d) { | |
| console.log(e) | |
| console.log(d) | |
| }); | |
| }, 15000); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment