Giter VIP home page Giter VIP logo

banco's Introduction

๐Ÿฆ banco

๐Ÿ“– Introduction

Banco uses Taproot and Elements introspection opcodes to enable an efficient and decentralized trading protocol between two or more parties using a non-interactive atomic swap construction.

Try it out at banco.vulpem.com running a Liquid Testnet instance.

Read more on the introductory blog post https://vulpem.medium.com/banco-non-interactive-swaps-00d042791e06

Why?

  • Non-interactive is a desirable property for atomic swaps. It allows the maker to create a transaction that can be fulfilled by the taker without any further interaction from the maker.

  • Easiest integration, ever The protocol can be used by any wallet that supports sending to an Elements address. No PSBT, no signatures to exchange. Simple!

  • Liquidity efficient The maker can create a transaction that can be fulfilled by the taker at any time (as long the maker does not cancel it wih a double-spend). This allows the taker to provide liquidity via automated bots that can fulfill the transaction without the risk of the capital to be locked for a long time (as it happens with time-locked contracts).

  • Decentralized The protocol is completely decentralized and does not require any trusted third party, being non-custodial for traders and capital efficient for market makers, without the need of a centralized "order-book" server. The taker simply observes the mempool for pending contracts to fulfill.

๐Ÿงฟ Protocol

๐Ÿ” TL;DR

It requires two transactions, one to fund the "trade contract" and another to either fulfill or cancel it. Anyone can fulfill the contract as soon is seen on the mempool, but only the maker can cancel it. The contract enforces that the first output has the requested value, asset and script in the spending transaction.

In-depth explanation can be found in the protocol document.

๐Ÿƒ Show me the code

๐Ÿ›๏ธ Architecture

Banco is composed of the following components and pieces:

  • banco: A web server written in Go that serves an HTMX web application to accept trades from makers. It monitors the mempool for funded trade contracts to be fulfilled. It writes trade data to an SQLite database in ./db/banco.db
  • ocean: An Elements wallet daemon that is used by Banco to fund the fulfill transactions. It supports an embedded database or PostgreSQL.

๐Ÿ“ฆ Download

The most simple way to run Banco locally is using docker. Standalone installation instructions coming soon.

git clone https://github.com/vulpemventures/banco.git
cd banco

๐ŸŒŠ Setup Ocean

Ocean is an Elements wallet daemon that is used by Banco, an automated taker bot that fulfills pending contracts in the mempool.

docker-compose up -d oceand

This will run a server on localhost:18000 and the first time you have to ocean wallet create. If you have already a mnemonic you will be able to ocean wallet restore it.

Set an alias for the ocean command to run it from your terminal:

alias ocean="docker exec -it oceand ocean"

Initialize Ocean CLI

ocean config init --no-tls

Create or restore a wallet

ocean wallet create --mnemonic <your_mnemonic> --password <your_password>
# or if your already have a mnemonic
# ocean wallet restore --mnemonic <your_mnemonic> --password <your_password>

Unlock

ocean wallet unlock --password <your_password>

๐Ÿšš Run Banco Web Server

This will run a server on localhost:8080 for the NETWORK=testnet and WATCH_INTERVAL_SECONDS=5 by default.

docker-compose up -d banco

โš™๏ธ Environment Variables

Banco uses the following environment variables:

  • WEB_DIR: The directory where the web files are located. Default is web.
  • OCEAN_URL: The URL of the Ocean node. Default is localhost:18000.
  • OCEAN_ACCOUNT_NAME: The name of the Ocean account. Default is default.
  • WATCH_INTERVAL_SECONDS: The interval in seconds for watching for pending trades to fulfill. Default is -1, which means changes are NOT watched continuously.
  • NETWORK: The network to use. Default is liquid.
  • GIN_MODE: Enable release or debug mode. Default is debug.

๐Ÿ“ฆ Development

Requirements

๐Ÿ—๏ธ Build Banco

go mod download
go build -o banco

๐Ÿงช Test

go test ./...

๐Ÿ“ Docs

go doc ./...

Run Web Server

go run .

Contribution ๐Ÿค

Pull requests and issues are welcome!

License ๐Ÿ“œ

This project is licensed under the MIT License - see the LICENSE file for details.

banco's People

Contributors

tiero avatar bordalix avatar lukechilds avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.