Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for BitShares Liquidity Pools (Poolmart) #3378

Merged
merged 80 commits into from
Jun 20, 2022
Merged
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
381071a
Update App.jsx
AmmarYousefM Jul 9, 2021
fa498bd
Update AccountActions.js
AmmarYousefM Jul 9, 2021
829dd04
Update AssetActions.js
AmmarYousefM Jul 9, 2021
afb43db
Create PoolActions.js
AmmarYousefM Jul 9, 2021
34e495d
Create PoolmartActions.js
AmmarYousefM Jul 9, 2021
cd48658
Update ApplicationApi.js
AmmarYousefM Jul 9, 2021
7b334a5
Create arrow-down-1.svg
AmmarYousefM Jul 9, 2021
9fca314
Create arrow-up-down.svg
AmmarYousefM Jul 9, 2021
213a12c
Create delete.svg
AmmarYousefM Jul 9, 2021
5faf7db
Update icons-loader.js
AmmarYousefM Jul 9, 2021
e0a5279
Create poolmart.svg
AmmarYousefM Jul 9, 2021
4352e26
Create pools.svg
AmmarYousefM Jul 9, 2021
0f0fb35
Update locale-en.json
AmmarYousefM Jul 9, 2021
5561521
Update _account-create.scss
AmmarYousefM Jul 9, 2021
0eb0085
Update _all.scss
AmmarYousefM Jul 9, 2021
d349a9a
Update _exchange.scss
AmmarYousefM Jul 9, 2021
db979c7
Create _poolmart.scss
AmmarYousefM Jul 9, 2021
849946f
Update _page_layout.scss
AmmarYousefM Jul 9, 2021
024a116
Update _theme-template.scss
AmmarYousefM Jul 9, 2021
66e84e6
Update AccountPage.jsx
AmmarYousefM Jul 9, 2021
2144401
Create AccountPools.jsx
AmmarYousefM Jul 9, 2021
8de6ba2
Update Asset.jsx
AmmarYousefM Jul 9, 2021
4c13501
Update Exchange.jsx
AmmarYousefM Jul 9, 2021
ba412cc
Update ExchangeHeader.jsx
AmmarYousefM Jul 9, 2021
f208698
Update MarketHistoryView.jsx
AmmarYousefM Jul 9, 2021
29cc628
Update Explorer.jsx
AmmarYousefM Jul 9, 2021
39fb0a9
Create LiquidityPools.jsx
AmmarYousefM Jul 9, 2021
5bcd2bd
Update Header.jsx
AmmarYousefM Jul 9, 2021
785ef42
Update MenuDataStructure.js
AmmarYousefM Jul 9, 2021
71c5546
Create CreatePoolModal.jsx
AmmarYousefM Jul 9, 2021
5949478
Create DeletePoolModal.jsx
AmmarYousefM Jul 9, 2021
9badc5f
Create MarketPickerHelpers.js
AmmarYousefM Jul 9, 2021
444cd86
Create PoolExchangeModal.jsx
AmmarYousefM Jul 9, 2021
359ca05
Create PoolStakeModal.jsx
AmmarYousefM Jul 9, 2021
cd69b79
Create LiquidityPools.jsx
AmmarYousefM Jul 9, 2021
b09e2a7
Create PoolmartPage.jsx
AmmarYousefM Jul 9, 2021
e938160
Update AmountSelectorStyleGuide.jsx
AmmarYousefM Jul 9, 2021
d54419a
Update BindToChainState.jsx
AmmarYousefM Jul 9, 2021
f7090d7
Update ChainTypes.js
AmmarYousefM Jul 9, 2021
2a2742c
Create LiquidityPoolsList.jsx
AmmarYousefM Jul 9, 2021
666a1b7
Update AssetStore.js
AmmarYousefM Jul 9, 2021
a50e923
Create PoolmartStore.js
AmmarYousefM Jul 9, 2021
be5cdb2
Update package.json
AmmarYousefM Jul 9, 2021
aa5a48e
Update package.json
AmmarYousefM Jul 9, 2021
157c07d
Update package.json
AmmarYousefM Jul 9, 2021
67c6a35
Update AccountActions.js
AmmarYousefM Jul 19, 2021
14418b6
Update Asset.jsx
AmmarYousefM Jul 19, 2021
2461346
Update Header.jsx
AmmarYousefM Jul 19, 2021
e1a1a19
Update BindToChainState.jsx
AmmarYousefM Jul 19, 2021
7450b92
Update BindToChainState.jsx
AmmarYousefM Jul 19, 2021
840aa9e
Merge branch 'develop' into develop
AmmarYousefM Aug 5, 2021
9737a9d
Update CreatePoolModal.jsx
AmmarYousefM Sep 30, 2021
9f84fb1
Update Exchange.jsx
AmmarYousefM Oct 12, 2021
9f75757
Update PoolExchangeModal.jsx
AmmarYousefM Nov 17, 2021
59eb785
Update PoolStakeModal.jsx
AmmarYousefM Dec 6, 2021
33796c8
Update PoolExchangeModal.jsx
AmmarYousefM Dec 6, 2021
e977171
Update AmountSelectorStyleGuide.jsx
AmmarYousefM Dec 6, 2021
6f00fe5
Update AssetActions.js
AmmarYousefM Dec 6, 2021
2d11e44
Update LiquidityPoolsList.jsx
AmmarYousefM Dec 6, 2021
4102f1f
Update AssetActions.js
AmmarYousefM Dec 6, 2021
e5f5186
Update PoolActions.js
AmmarYousefM Dec 6, 2021
ee1b9d4
Update PoolmartActions.js
AmmarYousefM Dec 6, 2021
e167104
Update DeletePoolModal.jsx
AmmarYousefM Dec 6, 2021
da10e4c
Update MarketPickerHelpers.js
AmmarYousefM Dec 6, 2021
db1b4d1
Update AccountPools.jsx
AmmarYousefM Dec 6, 2021
3c77195
Update CreatePoolModal.jsx
AmmarYousefM Dec 6, 2021
55b5c05
Update PoolStakeModal.jsx
AmmarYousefM Dec 6, 2021
5805517
Update AssetStore.js
AmmarYousefM Dec 6, 2021
b6eb895
Update CreatePoolModal.jsx
AmmarYousefM Dec 6, 2021
36061f4
Update AssetActions.js
AmmarYousefM Dec 6, 2021
879faee
Update PoolStakeModal.jsx
AmmarYousefM Dec 11, 2021
f14b97f
Update PoolStakeModal.jsx
AmmarYousefM Dec 11, 2021
0477ef2
Update BindToChainState.jsx
AmmarYousefM Jan 31, 2022
1b143b1
Update BindToChainState.jsx
AmmarYousefM Feb 8, 2022
0e5ce3c
Update BindToChainState.jsx
AmmarYousefM Feb 8, 2022
541116f
Update BindToChainState.jsx
AmmarYousefM Feb 8, 2022
40e6792
Update BindToChainState.jsx
AmmarYousefM Feb 8, 2022
21ad26a
Update BindToChainState.jsx
AmmarYousefM Feb 11, 2022
00c2b53
Merge branch 'develop' into develop
sschiessl-bcp Jun 20, 2022
3399ade
remove tab and switch wording to liquidity pools
Jun 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ const QuickTrade = Loadable({
loading: LoadingIndicator
});

const PoolmartPage = Loadable({
loader: () =>
import(/* webpackChunkName: "poolmart" */ "./components/Poolmart/PoolmartPage"),
loading: LoadingIndicator
});

import LoginSelector from "./components/LoginSelector";
import Login from "./components/Login/Login";
import RegistrationSelector from "./components/Registration/RegistrationSelector";
Expand Down Expand Up @@ -590,6 +596,10 @@ class App extends React.Component {
path="/instant-trade/:marketID"
component={QuickTrade}
/>
<Route
path="/poolmart"
sschiessl-bcp marked this conversation as resolved.
Show resolved Hide resolved
component={PoolmartPage}
/>
<Route path="*" component={Page404} />
</Switch>
</div>
Expand Down
1 change: 0 additions & 1 deletion app/actions/AccountActions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import alt from "alt-instance";
import accountUtils from "common/account_utils";
import AccountApi from "api/accountApi";

import WalletApi from "api/WalletApi";
import ApplicationApi from "api/ApplicationApi";
import WalletDb from "stores/WalletDb";
Expand Down
75 changes: 70 additions & 5 deletions app/actions/AssetActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,19 +254,16 @@ class AssetActions {
);
let tr = WalletApi.new_transaction();
let precision = utils.get_asset_precision(createObject.precision);

big.config({DECIMAL_PLACES: createObject.precision});
let max_supply = new big(createObject.max_supply)
.times(precision)
.toString();
let max_market_fee = new big(createObject.max_market_fee || 0)
.times(precision)
.toString();

let corePrecision = utils.get_asset_precision(
ChainStore.getAsset(cer.base.asset_id).get("precision")
);

let operationJSON = {
fee: {
amount: 0,
Expand Down Expand Up @@ -304,11 +301,9 @@ class AssetActions {
is_prediction_market: is_prediction_market,
extensions: null
};

if (isBitAsset) {
operationJSON.bitasset_opts = bitasset_opts;
}

tr.add_type_operation("asset_create", operationJSON);
return dispatch => {
return WalletDb.process_transaction(tr, null, true)
Expand Down Expand Up @@ -583,6 +578,76 @@ class AssetActions {
};
}

getAssetsByIssuer(issuer, count, start, includeGateways = false){
let id = issuer + "_" + count;
console.log("getAssetsByIssuer id = ", id);
return dispatch => {
if (!inProgress[id]) {
let assets;
inProgress[id] = true;
dispatch({loading: true});

assets = Apis.instance()
.db_api()
.exec("get_assets_by_issuer", [issuer, start, count])
.then(assets => {
let bitAssetIDS = [];
let dynamicIDS = [];

assets.forEach(asset => {
ChainStore._updateObject(asset, false);
dynamicIDS.push(asset.dynamic_asset_data_id);

// if (asset.bitasset_data_id) {
// bitAssetIDS.push(asset.bitasset_data_id);
// }
});

let dynamicPromise = Apis.instance()
.db_api()
.exec("get_objects", [dynamicIDS]);

// let bitAssetPromise =
AmmarYousefM marked this conversation as resolved.
Show resolved Hide resolved
// bitAssetIDS.length > 0
// ? Apis.instance()
// .db_api()
// .exec("get_objects", [bitAssetIDS])
// : null;

Promise.all([dynamicPromise]).then(
results => {
delete inProgress[id];
dispatch({
assets: assets,
dynamic: results[0],
// bitasset_data: results[1],
loading: false
});
return assets && assets.length;
}
);
})
.catch(error => {
console.log(
"Error in AssetActions.getAssetList: ",
error
);
dispatch({loading: false});
delete inProgress[id];
});

// Fetch next 10 assets for each gateAsset on request
if (includeGateways) {
gatewayPrefixes.forEach(a => {
this.getAssetList(a + "." + start, 10);
});
}

return assets;
}
};
}

lookupAsset(symbol, searchID) {
let asset = ChainStore.getAsset(symbol);

Expand Down
115 changes: 115 additions & 0 deletions app/actions/PoolActions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import alt from "alt-instance";
import {Apis} from "bitsharesjs-ws";
import utils from "common/utils";
import WalletApi from "api/WalletApi";
import WalletDb from "stores/WalletDb";
import {ChainStore} from "bitsharesjs";
import big from "bignumber.js";
import {gatewayPrefixes} from "common/gateways";
import {price} from "bitsharesjs/es/serializer/src/operations";
let inProgress = {};

class PoolActions {
createPool(
account_id,
createObject,
flags,
permissions,
cer,
isBitAsset,
is_prediction_market,
bitasset_opts,
description
) {
// Create pool action here...
console.log(
"create pool:",
createObject,
"flags:",
flags,
"isBitAsset:",
isBitAsset,
"bitasset_opts:",
bitasset_opts
);
let tr = WalletApi.new_transaction();
let precision = utils.get_asset_precision(createObject.precision);
big.config({DECIMAL_PLACES: createObject.precision});
let max_supply = new big(createObject.max_supply)
.times(precision)
.toString();
let max_market_fee = new big(createObject.max_market_fee || 0)
.times(precision)
.toString();
let corePrecision = utils.get_asset_precision(
ChainStore.getAsset(cer.base.asset_id).get("precision")
);
let operationJSON = {
fee: {
amount: 0,
asset_id: 0
},
issuer: account_id,
symbol: createObject.symbol,
precision: parseInt(createObject.precision, 10),
common_options: {
max_supply: max_supply,
market_fee_percent: createObject.market_fee_percent * 100 || 0,
max_market_fee: max_market_fee,
issuer_permissions: permissions,
flags: flags,
core_exchange_rate: {
base: {
amount: cer.base.amount * corePrecision,
asset_id: cer.base.asset_id
},
quote: {
amount: cer.quote.amount * precision,
asset_id: "1.3.1"
}
},
whitelist_authorities: [],
blacklist_authorities: [],
whitelist_markets: [],
blacklist_markets: [],
description: description,
extensions: {
reward_percent: createObject.reward_percent * 100 || 0,
whitelist_market_fee_sharing: []
}
},
is_prediction_market: is_prediction_market,
extensions: null
};
if (isBitAsset) {
operationJSON.bitasset_opts = bitasset_opts;
}
tr.add_type_operation("asset_create", operationJSON);
return dispatch => {
return WalletDb.process_transaction(tr, null, true)
.then(result => {
// console.log("pool create result:", result);
// this.dispatch(account_id);
dispatch(true);
})
.catch(error => {
console.log("----- createAsset error ----->", error);
dispatch(false);
});
};
}

create_liquidity_pool(
my_username,
asset_a,
asset_b,
share_asset,
taker_fee_percent,
withdrawal_fee_percent
){


}
}

export default alt.createActions(PoolActions);
Loading