coblox / bobtimus

an autobot that automatically handles swaps as Bob
Apache License 2.0
1 stars 1 forks source link

Expose HTTP API to return latest rates #46

Closed D4nte closed 5 years ago

D4nte commented 5 years ago

Bobtimus should expose a HTTP API to return the latest rates.

A proposal of the JSON payload is present in https://github.com/coblox/makeshift/pull/2

You would need to use the TestnetMarketMaker.getAmountsToPublish() method to access some of the information to publish.

D4nte commented 5 years ago

Something that was not explicitly said is how do we intend to do the "webserver configuration"

To me, we do a Apache or nginx configuration that serves the HTML file containing the link and does the redirect.

bonomat commented 5 years ago

To me, we do a Apache or nginx configuration that serves the HTML file containing the link and does the redirect.

Way simpler. Bobtimus is written in node, so why not just use expressjs: https://expressjs.com/en/starter/hello-world.html

const express = require('express')
const app = express()
const port = 3000

app.get('/', (req, res) => res.send('comit+web....'))

app.listen(port, () => console.log(`Bobtimus listening on port ${port}!`))
D4nte commented 5 years ago

Can you do redirect with expressJS?

bonomat commented 5 years ago

expressJS yap:

app.get("/latestrate", (req, res) => {
    res.status(301).redirect("https://www.google.com")
})
D4nte commented 5 years ago

Proposed addition: Show a Bitcoin and Ether address at http://<bobtimus_ip/ to allow people to fund Bobtimus if a balance is too low.

bonomat commented 5 years ago

Proposed addition: Show a Bitcoin and Ether address at http://<bobtimus_ip/ to allow people to fund Bobtimus if a balance is too low.

I would not reveal that Bobtimus is running low, that could just motivate people to misuse poor Bob. Instead, I would just statically say: Please donate some testnet BTC to bc1... and robsten ETH to 0x1337

bonomat commented 5 years ago

Let's block this for now and discuss if and how we want to do it.

D4nte commented 5 years ago

Let's block this for now and discuss if and how we want to do it.

When are we going to discuss it?

da-kami commented 5 years ago

The express client will be created in the index.js - there we have the TradeEvaluationService - but it currently only exposes isTradeAcceptable. calculateAmountsToPublish is currently only implemented in TestnetMarketMaker.

Assumption: TradeEvaluationService should contain calculateAmountsToPublish, because it should not matter which rate-strategy is used, bobtimus should always be able to publish the rate if requested.

Proposal:

@bonomat @D4nte please let me know if that matches with your thoughts :)