Commit Graph

60 Commits

Author SHA1 Message Date
sairajzero
bdd79a1a76 Adding support for BTC withdrawal 2022-09-30 05:52:30 +05:30
sairajzero
1e8f2c17e7 Fix: invoking 'collectAndCall' for withdraws 2022-09-26 01:34:26 +05:30
sairajzero
dd232c5a71 Fixes: sinkID and sinkPrivKey usage 2022-09-25 02:28:08 +05:30
sairajzero
078a3af051 Update market.js
- Removed floID field returned by get-transact API (as its already filtered by floID)
2022-05-25 04:14:09 +05:30
sairajzero
166778e7f8 get-transact API
- Get user's deposit and withdraw history (private request: ie, requires signing)
- Update floTokenAPI
2022-05-25 03:55:55 +05:30
sairajzero
a77f7d77d6 Error codes
- Added error codes for floExchangeAPI
2022-05-12 01:40:31 +05:30
sairajzero
8722b6cb60 Issue Fix
- Trigger coupling on cancel orders
2022-05-08 01:54:10 +05:30
sairajzero
838a12b361 Bug fix
- Fixed: Timeout not called upon initial coupling
- 'Cannot sell below purchased price' incorrectly shown when its actually valid order placement
- UI: parsing of get-rates API (latest update)
2022-05-07 23:17:02 +05:30
sairajzero
09953d252a Optimised blockchainReCheck
- Check if a new block has come at start of blockchainReCheck
- Checks for confirmation of txns only when a new block in the blockchain
2022-05-07 01:23:55 +05:30
sairajzero
d444e96259 checkSellRequirement: sell-chip's base
- Check for sell-chips's base price when placing sell order.
- Returns 'Cannot sell below purchased price' when not enough sell-chips above the base for placing order
2022-05-07 01:04:49 +05:30
sairajzero
fb9ac8080b Fixed: price storeHistory
- price.storeHistory interval will trigger only when node is master
2022-05-07 00:15:34 +05:30
sairajzero
54470b42d7 get-rates API improved
- get-rates API will now give a countDown timer
- this will be time at which next price update will happen unless a trade occurs
- Update: _constants.js for previous update
2022-05-07 00:03:36 +05:30
sairajzero
d3c5682994 Improved Triggers for coupling process
- moved periodic-process start/stop to market.js
- price.getRates() will update price only when updatePrice is true (ie, regular fn call wont update price unnecessarily)
- Trigger coupling for asset on successful order placement
- Return (or wait) if a coupling instance is running for asset
- Reset timeout when price is updated and/or trade has happened.
- Next coupling instance will be set for timeout upon completion of one instance
- Stop all coupling instances on app pause (i.e., node is not master)
2022-05-06 23:43:44 +05:30
sairajzero
55bd121021 API for ordered list for sell/buy
- The API for Listing sell/buy orders now returns ordered list of the queue (approx).
- list-buyorders, list-sellorders and list-trades API now accepts optional GET parameter 'asset'.
  . If passed, then orders/trades of only given asset will be returned.
  . If asset is not passed, then returns all asset by default as before.
- list buy/sell order API return max of 100 best orders
- list trade API return max of 1000 recent trades
2022-05-02 22:53:57 +05:30
sairajzero
7092213826 Bug fixes
- Fixed: Trade balance not updated correctly
- Fixed: sell-chips were not checked correctly on placing sell orders
- Fixed: sell-chips not added when distributed
- Fixed: sell-chips (FLO) not added when deposited by launch-seller
- Fixed various bugs
- initialPrice will be added to priceHistory table (initially)
2022-04-27 00:29:51 +05:30
sairajzero
f9551c856d Updating sell-requirement
- Users can only sell when enough sell-chips (for asset) are available.
- sell-chips are obtained by
  . buying assets
  . receiving asset from distributor
  . deposit (FLO only) as launch-seller (maximum of 1 million)
- Updated coupling for the requirement
- Improved getBestSeller and getBestBuyer: Directly fetch from SQL query
- Removed group.js (moved required functions to market.js)
- Updated SQL schema
2022-04-17 03:44:34 +05:30
sairajzero
9caf3fc9ec Distributor feature and Balance structure change
- Distributor feature allows to mark floIDs as distributors for certain asset.
- Added 2 APIs: add-distributor, remove-distributor
- Changing structure for token balance in exchange system. (requirement for new rule update).
2022-04-13 01:06:01 +05:30
sairajzero
deb746ef9e Increase decimal toFixed(8) 2022-03-30 20:38:08 +05:30
sairajzero
6451f02546 rate-history API 2022-03-30 05:38:55 +05:30
sairajzero
01dcd9b2d1 Bug fix
Fixed: Unable to process null returned from SQL SUM()
2022-03-22 14:11:55 +05:30
sairajzero
6add4625c8 Renaming files
Renamed tokenAPI to floTokenAPI
Renamed exchangeAPI to floExchangeAPI
2022-03-21 16:24:25 +05:30
sairajzero
ef0599d915 get-balance API
Added: get-balance API to fetch total balance
- accepts 2 parameters: floID and token. Requires atleast one of them for the API to work
/get-balance?floID=<floID>&token=<token> : responses balance of a specific token for a floID
/get-balance?floID=<floID> : responses all token balance for a floID
/get-balance?token=<token> : reponses balance of a specific token for every floID

Note (optional): in GET request
- floID=<floID> can be replaced with addr=<floID>
- token=<token> can be replaced with asset=<asset>
Both responses the same result as above
2022-03-18 00:50:39 +05:30
sairajzero
2b2c231f0b Bug fix
- Fixed: txid not stored in DB when retrying withdraw FLO
- UI: disabled all registration/signup buttons (as there is not need for signup)
2022-03-17 18:49:41 +05:30
sairajzero
eed495ab83 Bug fixes
- Fixed: transferToken not processed by server
- blockchainReCheck stops and adds itself to Timeout callback when sinkID is not loaded (uses MINI_PERIOD_INTERVAL = PERIOD_INTERVAL/10 for timeout ms)
- Fixed: confirmDepositFLO - asset attribute missing in SQL syntax
- When sinkID is not loaded, cancel check for confirmDepositFLO and confirmDepositToken
- Fixed: Incorrect receiver (sinkID) bug in confirmDepositFLO.checkTx
- Uncommented loaded, received, retrived sink logs
- Changed (SQL schema) sign field in RequestLog table to VARCHAR(160)
- Fixed: minor syntax errors and typos bugs
2022-03-17 03:06:00 +05:30
sairajzero
eeb3c70a10 Optimised request.js code 2022-03-16 02:11:36 +05:30
sairajzero
1823a46a98 Transfer transactions now support one-to-many
- receiver parameter now requires an object in the format
{floID1: amount1, floID2: amount2 ...}
- Transaction hash (id) for both trade and transfer transactions are now generated using SHA of JSON-string object
- Updated schema for one-to-many TransferTransactions
2022-03-16 00:33:22 +05:30
sairajzero
f59c6b3f2a Removing need for user registration
- Users can directly login or request without the need for user registration.
- Users can sign the requests either directly with own privateKey or by using a proxy
- Request's timestamp will be checked for Sign expiry.
- Request's sign will be checked for duplication.
- Cash table update will try to insert if record is not there
- Request Log table will also store a boolean value for sign by proxy or not
- Updated the SQL schema for the above changes.
2022-03-15 04:06:43 +05:30
sairajzero
3296b16710 Get transaction details
- Transaction details can be fetched using the following API
/get-transaction?txid=<txid>
- Get rates now accepts parameter 'asset' (optional) to return rate of particular asset.
/get-rates?asset=<asset>
/get-rates
- Get transactions (trade) API is changed to the following
/list-trades
2022-03-12 03:31:01 +05:30
sairajzero
0520791696 Adding transfer token feature
Transfer tokens
- Added transferToken: Users can directly transfer tokens (including FLO) to other registered users.
- Updated schema changes for the above requirement.
- Trade transactions and transfer transactions will generate a txid (using SHA256).

Other changes
- changed all signing type to lowercase
2022-03-12 02:25:31 +05:30
sairajzero
f9f89d91d3 BugFix: consumeAsset - not working when using entire coin 2022-02-24 17:59:09 +05:30
sairajzero
53b47057ff Minor fixes
- Sell requirement checks for respective asset for minimum buy
- Minimum buy is set to 0 (for exchange startup)
- Fixed: buy/sell orders sorted incorrectly by time_placed (should be FCFS. ie, ASC)
2022-02-18 20:11:34 +05:30
sairajzero
4416ab5ad3 Adding Blockchain refresh interval
- Added blockchain refresh interval
- Updating some constants
- Disabled various console.debug
2022-02-18 19:24:09 +05:30
sairajzero
15d36eb088 All Constants moved to _constants.js 2022-02-17 23:52:31 +05:30
sairajzero
a2dcfb27ce Bug fixes
- Fixed: Buy/sell order placement not working in UI
- Fixed: Buy order placement not checking the cash balance properly
- Fixed: Re-sync not working properly
  . (Master) Typo in SQL syntax
  . (Master) Incorrect index of data sent by master
  . (Slave) Invalid request send when requesting re-sync
- Removed counts for add, delete packets and total-add (As resync uses diff count)
2022-02-17 22:53:03 +05:30
sairajzero
cab65161ba Bug fix And UI for asset/token selection
- Fixed bugs in deposit and withdrawal
- Added UI select option for token selection on deposit and withdrawal
- Added UI style to buy/sell asset selection
2022-02-08 20:44:55 +05:30
sairajzero
ab3df761b0 Bug fixes
- Fixed: SQL schema asset foreign key incorrectly referenced
- Fixed: initial rate of asset not loading correctly from DB
- Fixed: get-rate API returning [object Object] instead of rates
- Fixed: Bug where transaction-loop happens with 0 quantity
- Improved: spendAsset to use assets NULL/Non-NULL base correctly
- Fixed: minor typos, syntax errors and SQL query errors

User-pages:
- Added: UI fields for assets in Buy/Sell orders
- Updated: UI display of correct asset in listing orders and transactions
- Updated: localStorage keys are prefixed 'exchange-'
- Fixed: Rates and Balance amount not displayed correctly

Others:
- Added: temporary code for tracing output lines in set_globals.js (commented out by default)
2022-02-07 03:12:20 +05:30
sairajzero
048ab0667b Multi asset: initial price and other improvements
- Read blockchain for asset's initial price
- Transfer all tokens to new sink on master transfer

Other Improvements:
- Slave: close existing backup sync when master WS closes
- Updated SQL schema, updated SQL syntax as required
2022-02-05 20:23:36 +05:30
sairajzero
92caef2c37 Multi-asset: coupling process 2022-02-04 02:28:02 +05:30
sairajzero
dbad25044a Multi-asset price.js 2022-02-03 05:46:26 +05:30
sairajzero
67c31d79a9 Multiple asset support
2 types of property:
1. Cash - main/central currency used for trading
2. Asset - (FLO/tokens) Can be brought or sold in the exchange market .

- Allow multiple tokens to act as asset in addition to FLO.
- Changes required for the above in deposits, withdraws, placing orders
- some code optimization in market.js
- Updated SQL schema
2022-02-02 04:17:47 +05:30
sairajzero
9fd1ae49c2 move tokenAPI to tokenAPI.js 2022-01-14 04:07:51 +05:30
sairajzero
0b70f099b0 Update App Server
- Use App server port for Websocket Server.
- pause/resume serving and market when node acts as slave/master respectively.
2021-12-30 06:49:48 +05:30
sairajzero
946087481a Move transaction process to coupling.js 2021-12-06 20:55:35 +05:30
sairajzero
9feef5bfe9 Minor fixes
- Fixed bug: sell order placement not working.
- log the current_rate
- indicate when max price-up/down has reached.
2021-12-05 00:37:45 +05:30
sairajzero
d3b27348ee Bug fix
- Fixed various bugs in the last update
- Added 'use strict'; to multiple files to prevent undeclared variables
2021-12-03 20:09:40 +05:30
sairajzero
4a898e6bff Initial price
- load init price from DB if possible, else fetch from API
- store the price history in DB every 1 hr
- get the 24hr-past-rate from DB
- update the last tx timestamp upon successful transaction
- added priceHistory table to SQL schema and backup
2021-12-03 01:45:59 +05:30
sairajzero
278fc8bcbd Price updation
- Update current_price when no seller or buyer available.
- Inc price only when sell-orders from rated sellers are available.
- User must buy a minimum FLO before placing a sell order unless they are a 'Miner'.
2021-12-02 05:26:01 +05:30
sairajzero
a7c96e9ce2 Priority case: FLO brought from outside
FLO brought from outside the source will be processed after those brought from source-market.
2021-11-25 05:10:39 +05:30
sairajzero
5ac3316008 Allow trusted IDs to add/rm user tags via API 2021-11-18 15:58:40 +05:30
sairajzero
b5cde90e89 Bug fix 2021-11-05 21:43:26 +05:30