I hereby claim:
- I am erin-koen on github.
- I am eek637 (https://keybase.io/eek637) on keybase.
- I have a public key ASDKimc8bOEIcqP7Oa4CLzVHf8wRWu7XpoB41E3qKKJKrAo
To claim this, I am signing this object:
Verifying my Blockstack ID is secured with the address 1ENdTF2NUiYBM2ZV5J1mbNd3CowT9YLqro https://explorer.blockstack.org/address/1ENdTF2NUiYBM2ZV5J1mbNd3CowT9YLqro |
I hereby claim:
To claim this, I am signing this object:
export class UniswapBot { | |
public static async create(hubAddress: string, tokenOneSymbol: string, tokenTwoSymbol: string) { | |
const environment = createEnvironment(); | |
const hub = new Hub(environment, hubAddress); | |
const routes = await hub.getRoutes(); | |
const manager = await hub.getManager(); | |
const account = (await environment.client.getAccounts())[0]; | |
if (!sameAddress(manager, account)) { | |
throw new Error('You are not the manager of this fund.'); |
public async getBalances() { | |
// find the fund's accounting address | |
const accountingAddress = (await this.hub.getRoutes()).accounting; | |
// and instantiate a js representation of the contract | |
const accounting = new Accounting(this.environment, accountingAddress); | |
// to call the getFundHoldings method | |
const fundHoldings = await accounting.getFundHoldings(); |
public async getPrice(baseCurrency: TokenDefinition, quoteCurrency: TokenDefinition, baseQuantity: BigNumber) { | |
// Every uniswap exchange is WETH/someToken, and identified by the non-weth token | |
const exchangeToken = baseCurrency.symbol === 'WETH' ? quoteCurrency : baseCurrency; | |
// call the method to find the address | |
const exchangeAddress = await this.uniswapFactoryContract.getExchange(exchangeToken.address); | |
// instantiate the exchange contract | |
const exchange = new UniswapExchange(this.environment, exchangeAddress); |
public async makeTransaction(priceInfo: PriceQueryResult){ | |
// adjust the target amount of token to buy | |
const slippage = 0.97; | |
// use the price query results to construct the uniswap order argument object | |
const orderArgs = { | |
makerQuantity: priceInfo.sizeInQuote.integerValue().multipliedBy(slippage), | |
takerQuantity: priceInfo.sizeInBase.integerValue(), | |
makerAsset: priceInfo.quoteCurrency.address, | |
takerAsset: priceInfo.baseCurrency.address, |
{ | |
... | |
"scripts": { | |
"dev": "cross-env NODE_ENV=development ts-node --require dotenv-extended/config --transpile-only src" | |
}, | |
"dependencies": { | |
"@melonproject/melonjs": "^1.0.1", | |
"axios": "^0.19.2", | |
"bignumber.js": "^9.0.0", | |
"web3-core": "^2.0.0-alpha.1", |
import { DeployedEnvironment } from '@melonproject/melonjs'; | |
import { Eth } from 'web3-eth'; | |
import { HttpProvider, WebsocketProvider, HttpProviderOptions, WebsocketProviderOptions } from 'web3-providers'; | |
import deployment from '../deployments/mainnet-deployment.json'; | |
function createProvider(endpoint: string, options?: HttpProviderOptions | WebsocketProviderOptions) { | |
if (endpoint.startsWith('https://') || endpoint.startsWith('http://')) { | |
return new HttpProvider(endpoint, options as HttpProviderOptions); | |
} |
export class UniswapBot { | |
public static async create(hubAddress: string, tokenOneSymbol: string, tokenTwoSymbol: string) { | |
const environment = createEnvironment(); | |
const hub = new Hub(environment, hubAddress); | |
const routes = await hub.getRoutes(); | |
const manager = await hub.getManager(); | |
const account = (await environment.client.getAccounts())[0]; |
async function run(bot: UniswapBot) { | |
try { | |
console.log('CONSULTING THE ORACLE ==> '); | |
const transaction = await bot.makeMeRich(); | |
if (!transaction) { | |
console.log('NO TRADING BY ORDER OF THE ORACLE'); | |
} else { | |
console.log('THE ORACLE SAYS TO TRADE'); |