spec/Order.js

  1. /*
  2. * Copyright (C) 2021-2022 Algodex VASP (BVI) Corp.
  3. *
  4. * This Source Code Form is subject to the terms of the Mozilla Public
  5. * License, v. 2.0. If a copy of the MPL was not distributed with this
  6. * file, You can obtain one at https://mozilla.org/MPL/2.0/.
  7. */
  8. // eslint-disable-next-line no-unused-vars
  9. const algosdk = require('algosdk');
  10. /**
  11. * # Order
  12. *
  13. * @example
  14. * const validate = ajv.getSchema('Asset')
  15. *
  16. * @typedef {Object} Order
  17. * @property {string} address Order Address
  18. * @property {number} amount Amount in order
  19. * @property {number} total Total of order
  20. * @property {("maker"|"taker"|"market"|"both"|"execute"|"close")} execution Execution of order
  21. * @property {Asset} asset Algorand Asset
  22. * @property {number} price Asset Price
  23. * @property {Object} [contract] Composed Contract State
  24. * @property {number} contract.price Asset BaseUnit Price
  25. * @property {number} contract.amount Asset BaseUnit Amount
  26. * @property {number} contract.total Asset BaseUnit Total
  27. * @property {number} contract.N Numerator
  28. * @property {number} contract.D Denominator
  29. * @property {algosdk.SuggestedParams} [contract.params] Suggested Params
  30. * @property {algosdk.Algodv2} [client] Algosdk Client
  31. * @namespace Order
  32. */
  33. // "type": "sell",
  34. // "price": 235.000000,
  35. // "amount": 0.1,
  36. // "total": 23.50000,
  37. // "execution": "both",
  38. // "address": "WYWRYK42XADLY3O62N52BOLT27DMPRA3WNBT2OBRT65N6OEZQWD4OSH6PI",
  39. // "appId": 22045503,
  40. // "version": 6
  41. /**
  42. * JSON Schema Specification
  43. * @type {Schema}
  44. * @name Schema
  45. * @memberOf Order
  46. */
  47. module.exports = {
  48. '$schema': 'http://json-schema.org/draft-07/schema',
  49. '$id': 'https://schemas.algodex.com/v1/Order.json',
  50. 'title': 'Order',
  51. 'description': 'Algorand standard asset',
  52. 'type': 'object',
  53. 'properties': {
  54. 'type': {
  55. 'type': 'string',
  56. 'enum': ['buy', 'sell'],
  57. },
  58. 'price': {
  59. 'type': 'number',
  60. 'multipleOf': 1,
  61. },
  62. 'amount': {
  63. 'type': 'number',
  64. 'multipleOf': 1,
  65. },
  66. 'total': {
  67. 'type': 'number',
  68. 'multipleOf': 1,
  69. },
  70. 'execution': {
  71. 'type': 'string',
  72. 'enum': ['taker', 'both', 'maker', 'market'],
  73. },
  74. 'address': {
  75. 'type': 'string',
  76. 'pattern': '[A-Z0-9]{58}',
  77. 'description': 'An account public key',
  78. },
  79. 'appId': {
  80. 'type': 'number',
  81. 'multipleOf': 1,
  82. },
  83. 'version': {
  84. 'type': 'number',
  85. 'multipleOf': 1,
  86. },
  87. },
  88. };
  89. JAVASCRIPT
    Copied!