Designing Smart Contracts for Multi-Protocol Integration

This post was originally published on Stable pay

This is the second introductory post for StablePay, you can find the first one here if you missed it.

StablePay is a platform built on top of ethereum comprised of a set of contracts that aggregate existing value transfer protocols on the network through an open design architecture.

The contracts function as a gateway for receiving token payments, seek the best rate for trading on existing decentralized exchanges and swap the tokens (This is done via what we call a swapping provider in our platform, more on this later) into DAI to finally send them over to the receiver. Payments converted DAI is our first use case, but the platform supports receiving any token payment of your choosing, is up to the receiver to decide which tokens to accept. On the users end they can pay/donate with any token of their choosing without worrying about the exchange rate or the final target token for the receiver, they just make a normal payment like they would do on centralized platforms like Paypal or stripe. (See demo video).

Swapping provider is a concept for integrating and leveraging the growing liquidity of existing exchange protocols like Uniswap, Kyber and 0x to make good on settling payments on any token as long as the token has enough liquidity on any of these providers.

Any swapping provider can be programmed and added to the platform for any current or future protocol, as long as it guarantees to swap tokens and conforms to the StablePay swapping interface (like ERC standards) to compete with the other liquidity protocols for settling payments. We are hoping that projects add their own providers in the future and plug them into the open architecture as part of growing the value of the platform.

biswap

A swapping provider could be as simple as a contract accepting ETH that then starts a CDP with that ETH on MakerDAO, creates DAI’s and gives those DAI back to StablePay for payments, all in one transaction. This provider could manage one or several CDPs through a DAO, or take out loans in Compound, the possibilities are really open for exploring. We are sure there are plenty of more use cases we haven’t thought of for providers.

Why a platform or …developers, developers, developers?

All of these protocols are readily available today for exchanging tokens. Users can make there own payments if they wanted to, but the UX would not be the best. Users need to first approve tokens for swapping, then manually swap the tokens required with the right amount, then send the token as payment and be sure they type the address correctly. Even with a nice UI in an app or browser, doing all these steps directly on each protocol can take several transactions, and that is not even factoring bulk payments to several addresses with a mix of different tokens.

We figured that if we did it as part of our smart contracts, the user can save themselves several transactions by doing it through the StablePay platform, and also they are ensured that the settlement will be done on the chain, open for auditing and tracking. Also by using a platform of contracts, if a payment cannot be settled, the transaction is reversed and the user tokens are safe, we think that is a big point in favor of building a platform instead of building just a UI app integrating all the existing protocols.

By using the contracts, developers can just focus on calling one contract (StablePay contract) instead of interacting with many different protocols and interfaces to incorporate payments into their projects. We are dealing with the complexities of all the swapping protocols so that developers don’t have to.

How can I start receiving payments from any ERC20 tokens converted to DAI?

When the platform is ready to use on launch our StablePay widget and JS library will be the easiest way to start receiving token payments. We want the experience of integrating the widget to be quick and simple. The final experience should be very close to these steps:

1. Install a Wallet: Any Ethereum address can be used, but we recommend a secure wallet to receive your payments/donations.

2. Add the Stablepay Widget: Integrate your widget to your website with your address and tokens configuration.

3. Start receiving payments in tokens: Start accepting token payments from any user, don’t worry about volatility since you can choose to convert your payments instantly into DAI immediately without any third party intermediary.

Planned Roadmap and upcoming features.
(Updated: 10/05/2019)

We will announce on beta and launch what features we plan to have and which ones will be added as part of our roadmap.

  • Easy setup through the StablePay widget or StablePay JS library to integrate on existing web sites. Users won’t have to input the destination address or token for most payments.

To keep in touch with us and receive information about the progress of our platform, follow us on our social media channels:

Leave a Comment