paint-brush
How Microservices Power Blockchain Integration by@apieconomy

How Microservices Power Blockchain Integration

tldt arrow

Too Long; Didn't Read

The described artifact is a microservice that facilitates leveraged trading. It utilizes the Dai stablecoin system and a recursive re-collateralization process on the Ethereum blockchain. The maximum achievable leverage ratio is determined by the collateral requirement and practical limitations like transaction fees. Users interact with the artifact through the exchange interface and a separate browser-based wallet.
featured image - How Microservices Power Blockchain Integration
The API Economy Trends Report HackerNoon profile picture

Authors:

(1) Johannes Rude Jensen, University of Copenhagen, eToroX Labs ([email protected]);

(2) Victor von Wachter, University of Copenhagen ([email protected]);

(3) Omri Ross, University of Copenhagen, eToroX Labs ([email protected]).

Abstract and Introduction

1 Literature Review

2 Methodology and Artefact Requirements

3 The Implementation and Integration of the Artefact

4 Artefact Evaluation

5 Discussion

6 Conclusion and Future Work, and References

3 The Implementation and Integration of the Artefact

The present iteration of the artefact comprises a managed microservice running in isolation from the core platform infrastructure. The microservice runs a customized open-source library acting as a wrapper around the Dai stablecoin system smart contracts, enabling traders to interact with the smart contract systems directly through the exchange interface. Using the exchange interface, traders can open, manage, monitor, and close a leveraged position on the blockchain. We utilize the Dai stablecoin system to achieve the effect of a leveraged trade, by performing a process referred to as ‘recursive re-collateralization’ of a vault. For this demonstration of the artefact, we use the native asset class for Ethereum, ‘ETH’, with a collateral requirement of 1.5 meaning that the value of the Dai withdrawn from the vault, must not exceed 66.66% of the collateral value.


To open a leveraged position, the microservice calculates and submits a single transaction on the Ethereum blockchain, executing a sequence of three operations: (I) Open a ‘vault’ by collateralizing ETH and withdrawing the maximum amount Dai possible (II) exchange Dai for ETH on the Oasis exchange[4] (III) re-collateralize ETH in the same vault and withdraw Dai. This sequence is repeated recursively from step II, until the desired degree of leverage is obtained. The cumulative leverage of a given position converges to a finite value defined by the collateral requirement of the collateral asset. Because the ratio is constant, the recursive operation converges to a geometric series. We can compute the cumulative leverage ratio for an asset as:



Let 𝑟 represent the collateral requirement and L represent the theoretical maximum leverage ratio. As follows, the maximum theoretical leverage ratio for ETH is 3X (Figure 3.). It follows that the maximum leverage ratio approaches infinity as the collateral ratio approaches 1. However, owing to the computational costs[5] on the Ethereum network combined with the transaction fees and liquidity limitations on Oasis or UniSwap[6], successive re-collateralizations rapidly become prohibitively expensive. We estimate the practically feasible maximum leverage for a standard trade to appear around a leverage ratio of 20X for assets with a collateral requirement of 1.1 (90%)[7].


Figure 3. Max. leverage ratio over collateral requirements and the max. leverage ratio for ETH


The microservice operates under similar premises as a standard user on the exchange, utilizing the API calls to open trigger transactions from a separate, browser-based wallet, in which the user is required to maintain the initial collateral amount required to fund the leveraged position. We discern between five ‘layers’ of the integration (Table 3.).


Table 3. The five components in the integration


The microservice runs the key operations required to open a vault with a user-defined leverage multiple by submitting a transaction with the correctly encoded input data to be signed by the user’s browser-based wallet. Once the vault is open, the microservice monitors the position by reading the state of the blockchain and reporting to the exchange operation where P/L calculations are conducted against a rate database which defines the margin-call values for the account. Reading the state of the blockchain also enables the microservice to report liquidated positions to the user. The user can re-collateralize or close a position by submitting transactions through the interface, encoding a transaction through the browser-based wallet.


Figure 2. Integration taxonomy emphasizing key operations


This paper is available on arxiv under CC BY 4.0 DEED license.


[4] https://oasis.app/trade/instant


[5] Referred to as “gas cost”: https://etherscan.io/chart/gasprice


[6] https://app.uniswap.org/#/swap


[7] Noting that no asset class in the Dai Stablecoin system currently has a collateral ratio below 1.25 (75%)