# Asset Swap Implemantion Update
* All code in here - https://github.com/blockrockettech/asset-swap-service
### Current state of play
* TypeScript / postgres DB
* Simple `generate_quote` RPC endpoint
* Auth onto kchannels on app start
* Listen for `transaction` and `channel_info` websocket updates
* Can issue quotes for DAI <-> xDAI swaps
* Maintain a history of kchannel coin balances
* Fulfills quotes with basic validation
* Asset swap a fixed fee % from the trade
### Known unknowns / Improvements
* Signature validation after each transacting stage
* Payloads are checked but signautres are not
* Error handling in general
* Mainly around failing to send a transaction,
* channel busy flow
* Persistence of transactions, needed so they can be picked up and ressolved at a later time
* Separating the acknowledging and sending a transaction into 2 flows, so they can be handled async
* Introducing of a state machine in some form?
* Re-authenitcation of sockets
* Atm requires app restart to re-auth onto kchannels
* The auth token (JWT) is generate each time, persist and check expiry
* Fees are fixed e.g. 1%
* Also expiring of quotes - if the fees can change then I would assume they should expire
* Maybe expose additional JSON RPC methods to get quote history, quote state etc?
* May help with UX
* Deployment and hosting
* Balance manager
* Responsible for maintain asset balanaces of the asset swap service
* Fliping coins on and off chain
* Multiple liquidity providers
* Atm the asset swap service = 1 big fat bank with all the cash
* deployment / hosting
* Agree json rpc schema/payloads
* basic schema validation like using actual JSON Schema validation
* Reporting
* Would be nice to be able to query for asset balances/earnings/state etc
### General code smells
* More test coverage
* Get quote covered, others are not
* ORM for DB mapping
* Use a cloud DB ... ?
* Hard coded list of available assets to swap currently DIA <-> xDAI in either direction
* Better logging in general - standardise loggin format and storage
* Docs on how to onboard and use the service