Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9bca614

Browse files
committed
v1.1.0: Publishing as @ubcdigital/swapable
1 parent 832e81a commit 9bca614

4 files changed

Lines changed: 49 additions & 98 deletions

File tree

.github/FUNDING.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
github: UsingBlockchain
22
patreon: usingblockchainltd
3-
custom: ["https://www.paypal.me/usingblockchainltd"]
3+
custom: ["https://www.paypal.me/usingblockchainltd", "https://www.buymeacoffee.com/UBCDigital"]

README.md

Lines changed: 44 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -2,89 +2,53 @@
22

33
# Swapable: Automated Liquidity Pools
44

5-
[![npm version](https://badge.fury.io/js/swapable.svg)](https://badge.fury.io/js/swapable)
6-
[![Build Status](https://travis-ci.com/usingblockchain/swapable.svg?branch=main)](https://travis-ci.com/usingblockchain/swapable)
5+
[![npm-badge][npm-badge]][npm-url]
6+
[![size-badge][size-badge]][npm-url]
7+
[![dl-badge][dl-badge]][npm-url]
8+
[![Build Status](https://travis-ci.com/UsingBlockchain/symbol-taxonomy.svg?branch=main)](https://travis-ci.com/UsingBlockchain/symbol-taxonomy)
79

8-
This repository contains the source code for **swapable**, an open standard for peer-to-peer automated liquidity pool enabling the formation of smart **digital markets** on top of Symbol from NEM, and compatible networks.
10+
This repository contains the source code for **swapable**, an open standard for peer-to-peer automated liquidity pools on top of Symbol from NEM, and compatible networks.
11+
12+
This library empowers the creation and operations of **automated liquidity pools** using Symbol from NEM and compatible networks.
913

1014
- [Reference documentation][ref-docs]
15+
- [Introduction](#introduction)
16+
- [Contracts found here](#contracts-found-here)
1117
- [Installation](#installation)
12-
- [Usage](#usage)
1318
- [Sponsor Us](#sponsor-us)
1419
- [Disclaimer](#disclaimer)
1520
- [Licensing](#license)
1621

22+
## Introduction
23+
24+
This library empowers the creation and operations of automated liquidity pools using Symbol from NEM and compatible networks.
25+
26+
Swapable assets consist in combining two cryptocurrencies in a liquidity pool to define an invariant `k` using a constant product formula of: `x * y = k` where `x` and `y` represent the cryptocurrencies that are paired in said liquidity pool. The shares of liquidity providers are determined with another asset that we call the **pool shares mosaic** and which is issued at the time of creation of a liquidity pool, i.e. each liquidity pool will have its own pool shares mosaic.
27+
28+
A swapable asset may be paired with any other cryptocurrency provided that they reside on the same blockchain network.
29+
30+
Liquidity providers add liquidity into pools and Traders can swap currencies. A fee is added to each trade at the rate of 0.30% which are then added to token reserves. Providers can withdraw their shares of the total reserve at any time.
31+
32+
When liquidity is added by a provider, they will be assigned some **Pool Shares**. Those shares can then be burned at any time by providers in order to take back their part of pooled assets.
33+
34+
An automated liquidity pool is represented by the following properties:
35+
36+
- **A target account**: Consists of a public account which holds the funds of said pool. This account SHOULD be converted to a multi-signature account, i.e cosignatories can be the operators of a DAO (see @ubcdigital/governable).
37+
38+
- **A pool shares mosaic**: Consists of a digital asset that is created only for the purpose of keeping track liquidity provider shares in pools. These assets can be burned for pooled assets at any time but are not exchangeable for other cryptocurrencies. Using Symbol from NEM, this asset is represented by a **non-transferrable** mosaic.
39+
40+
## Contracts found here
41+
42+
| Contract Name | Description |
43+
| --- | --- |
44+
| **CreatePool** | Contract for *creating* a new liquidity pool. This contract is typically executed by liquidity providers and require the input of two different cryptocurrencies marked `x` and `y` which form the liquidity pool, a.k.a the market pair. |
45+
| **AddLiquidity** | Contract for *adding liquidity* to an already existing liquidity pool. This contract is typically executed by liquidity providers and requires the input of two cryptocurrencies that have previously been paired in a liquidity pool with the `CreatePool` contract. |
46+
| **RemoveLiquidity** | Contract for *removing liquidity* from an already existing liquidity pool. This contract is typically executed by liquidity providers and requires the input of two cryptocurrencies that have previously been paired in a liquidity pool with the `CreatePool` contract. |
47+
| **Swap** | Contract for *swapping currencies*. This contract is typically executed by traders and requires the input of one cryptocurrency and one output denominator. Prior to the execution of *swaps* between `x` and `y`, a liquidity pool must exist that provides liquidity for the market pair `x:y`, i.e. using the `CreatePool` contract. |
48+
1749
## Installation
1850

19-
`npm install swapable`
20-
21-
## Usage
22-
23-
:warning: The following example usage for the `swapable` library is subject to change.
24-
:warning: This command execution creates at least one- or more than one - network-wide
25-
**account restriction**. Restrictions can potentially lock you out of your account, so
26-
please use this only with caution and only if you understand the risks.
27-
28-
```javascript
29-
import { AggregateTransaction, PublicAccount, SignedTransaction } from 'symbol-sdk'
30-
import { MnemonicPassPhrase } from 'symbol-hd-wallets'
31-
import { Swapable, NetworkConfig, TransactionParameters } from 'swapable'
32-
import { TransactionURI } from 'symbol-uri-scheme'
33-
34-
// - The following settings are network specific and may need changes
35-
const networkType = NetworkType.TEST_NET
36-
const sourceNetwork = '57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6'
37-
const symbolMosaicId = '6BED913FA20223F8';
38-
const transactionParams = new TransactionParameters(
39-
1573430400, // epochAdjustment
40-
Deadline.create(), // transaction(s) deadline
41-
750000, // maxFee
42-
)
43-
44-
// - You should use secure storage practices for mnemonic pass phrases.
45-
const keyRing = MnemonicPassPhrase.createRandom()
46-
47-
// - Initializes a so-called "network reader". The URL used here should
48-
// typically refer to a running REST gateway on your node.
49-
const reader = new Symbol.Reader(
50-
'http://dual-001.symbol.ninja:3000',
51-
networkType,
52-
sourceNetwork,
53-
1615853185,
54-
new MosaicId(symbolMosaicId),
55-
'306FA94E0AB682964416C8172F858939533E5998906B8AFAD4A4585C7CDD722C',
56-
)
57-
58-
// - Initializes a key provider and distributed organization instance.
59-
const signer = new Symbol.Signer()
60-
const swapable = new Swapable.AutomatedPool(
61-
'SWP:XYM',
62-
reader,
63-
signer,
64-
keyRing,
65-
)
66-
67-
// offline creation of the `CreatePool` contract
68-
const poolId = swapable.create(
69-
swapable.getTarget().publicAccount, // actor
70-
provider, // liquidity provider
71-
new AssetAmount(Symbol_Testnet_SWP, 10),
72-
new AssetAmount(Symbol_Testnet_XYM, 10),
73-
transactionParams,
74-
)
75-
76-
// get the transaction URI for `CreatePool` execution
77-
const resultURI: TransactionURI = swapable.result
78-
79-
// It is important to denote that given the **aggregate** nature of digital
80-
// contracts, multiple parties MAY be involved in the transaction and
81-
// it is therefor required to issue a HashLockTransaction before announcing
82-
// the aggregate bonded transaction that represents the contract.
83-
84-
// :warning: It is recommended to sign the resulting transactions
85-
// using a hardware wallet rather than any type of software generated
86-
// wallets.
87-
```
51+
`npm i -g @ubcdigital/swapable`
8852

8953
## Sponsor us
9054

@@ -93,25 +57,7 @@ const resultURI: TransactionURI = swapable.result
9357
| Paypal | [https://paypal.me/usingblockchainltd](https://paypal.me/usingblockchainltd) |
9458
| Patreon | [https://patreon.com/usingblockchainltd](https://patreon.com/usingblockchainltd) |
9559
| Github | [https://github.com/sponsors/UsingBlockchain](https://github.com/sponsors/UsingBlockchain) |
96-
97-
## Donations / Pot de vin
98-
99-
Donations can also be made with cryptocurrencies and will be used for running the project!
100-
101-
NEM (XEM): NB72EM6TTSX72O47T3GQFL345AB5WYKIDODKPPYW
102-
Symbol (XYM): NDQALDK4XWLOUYKPE7RDEWUI25YNRQ7VCGXMPCI
103-
Ethereum (ETH): 0x7a846fd5Daa4b904caF7C59f866bb906153305D2
104-
Bitcoin (BTC): 3EVqgUqYFRYbf9RjhyjBgKXcEwAQxhaf6o
105-
106-
## Credits
107-
108-
| Name | Contributions |
109-
| --- | --- |
110-
| Using Blockchain Ltd (@UsingBlockchain) <[email protected]> | Product Owner |
111-
| Grégory Saive (@eVias) | Lead Engineering |
112-
| Rebecca Natterer | Lead Product Designer |
113-
| Mansour Zebian | Lead Product Marketing |
114-
| Pascal Severin (@offdev) | Alpha Contributor |
60+
| :coffee: :coffee: :coffee: | [https://www.buymeacoffee.com/UBCDigital](https://www.buymeacoffee.com/UBCDigital) |
11561

11662
## Disclaimer
11763

@@ -121,8 +67,13 @@ Donations can also be made with cryptocurrencies and will be used for running th
12167

12268
## License
12369

124-
Copyright 2020-2021 Using Blockchain Ltd, Reg No.: 12658136, United Kingdom, All rights reserved.
70+
Copyright 2020-2021 [Using Blockchain Ltd][ref-ltd], Reg No.: 12658136, United Kingdom, All rights reserved.
12571

12672
Licensed under the [AGPL v3 License](LICENSE).
12773

12874
[ref-docs]: https://swapable.symbol.ninja/
75+
[ref-ltd]: https://using-blockchain.org
76+
[npm-url]: https://www.npmjs.com/package/@ubcdigital/swapable
77+
[npm-badge]: https://img.shields.io/npm/v/@ubcdigital/swapable
78+
[size-badge]: https://img.shields.io/bundlephobia/min/@ubcdigital/swapable
79+
[dl-badge]: https://img.shields.io/npm/dt/@ubcdigital/swapable

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "swapable",
3-
"version": "1.0.3",
2+
"name": "@ubcdigital/swapable",
3+
"version": "1.1.0",
44
"license": "AGPL-3.0",
55
"description": "Swapable: Automated Liquidity Pools",
66
"keywords": [

0 commit comments

Comments
 (0)