Git Product home page Git Product logo

silverportal's Introduction

# Silver Portal

⚠️ This is an experimental prototype for testnet use only.

The basic idea

Silver Portal lets you swap ether and bitcoin, trustlessly.

To swap ETH for BTC, you first send ETH to the exchange contract. A market maker sends you the corresponding BTC. They post a proof to the contract, claiming the ether. If the market maker fails to send you your bitcoin, you get your ether back after an escrow period.

The other direction is even easier. You send BTC to the market maker's Bitcoin address, then post a proof to the contract to claim your ETH.

The details

  1. How do you prove a Bitcoin transaction on Ethereum? Using Bitcoin Mirror, effectively a Bitcoin light client implemented as a smart contract.

  2. How do you provide ETH liquidity? Post an ask. You send N ETH in a transaction that says: here's my Bitcoin address. Anyone can buy my ether for bitcoin at price M.

  3. How do you provide BTC liquidity? Post a bid: a promise to buy N ETH at price M. You post a stake, say 10% of N, to make it binding. If someone hits your bid and you ghost, you get slashed. They get their eth back plus your stake.

  4. How do you withdraw liquidity? You can withdraw liquidity at any time, minus any liquidity that's in escrow due to a pending transaction. More on that below.

  5. How do you trade ether for bitcoin? You send a transaction that says: here's my bitcoin address. I'm buying N bitcoin from this particular bid, sending N × M ETH into escrow. The market maker has to send you N bitcoin within a time limit.

  6. How do you trade bitcoin for ether? Roughly the same way. You send a transaction that says: I'm buying N ETH. The transaction includes a percentage of N ETH as your stake. If you fail to send bitcoin within the escrow period, the market maker slashes you and keeps your stake. You send bitcoin, wait for confirmation blocks, then post proof. This returns your stake plus the ETH you bought.

  7. Why do we need all this staking and slashing? To avoid exploitation. For example, an attacker could spam "I'm selling ETH for BTC" transactions to lock up liquidity, then only complete the transaction an hour later if the price moves in their favor. Trades must be binding.

  8. Why does buying ETH involve two transactions? Why can't you just send Bitcoin first, then post a proof? In that case, two people might hit the same ask at the same time, with only be enough ETH in the contract for one of them. A malicious MM could watch the bitcoin mempool. As soon as they see your buy, they also send themselves bitcoin and claim the ETH ahead of you, keeping their BTC and stealing yours. The two-step process fixes this.

  9. What kinds of Bitcoin addresses are supported? Currently, only P2SH (pay to script hash) destination addresses are supported. You can send Bitcoin from any address, but to receive you must use an address starting with 3 on mainnet or 2 on testnet.

The risks

Every defi construct should state risks. Here are some of ours.

  1. Honest-majority assumption re: Bitcoin hashpower. This is inherent to any cross-chain protocol. A successful 51% attack on Bitcoin would allow an attacker to drain ether from the portal. Silver Portal is an exchange, not a bridge, but Vitalik's post on the security limitations of cross-chain bridges still applies. In our case, only current liquidity is at risk, not the entire value of a bridged asset.

  2. Smart contract risk. These are experimental contracts. They have not been audited and are currently for testnet use only. Risk can be reduced over time through auditing, verification, and experience, but will never be zero.

  3. Censorship or extreme congestion. Ethereum is designed for liveness and censorship resistance. If either of those properties fail, you may have sent bitcoin and be unable to prove it within the escrow window.

  4. Price exposure. If you're providing liquidity, the standard market risks apply.

  5. (Mild) counterparty risk. If you're swapping ether for bitcoin and there's an extreme price movement in your favor, the other party might accept being slashed rather than complete the trade. They may also fail to complete unintentionally. Either way, you'll simply get your ETH back plus slashing proceeds after the escrow period.

silverportal's People

Contributors

dcposch avatar kahuang 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.