@keetanetwork/anchor 0.0.116 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/queue/index.d.ts.map +1 -1
- package/lib/queue/index.js +36 -43
- package/lib/queue/index.js.map +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/services/fx/client.d.ts +5 -1
- package/services/fx/client.d.ts.map +1 -1
- package/services/fx/client.js +13 -2
- package/services/fx/client.js.map +1 -1
- package/services/fx/common.d.ts +5 -2
- package/services/fx/common.d.ts.map +1 -1
- package/services/fx/common.js.map +1 -1
- package/services/fx/server.d.ts +2 -2
- package/services/fx/server.d.ts.map +1 -1
- package/services/fx/server.js +49 -11
- package/services/fx/server.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/services/fx/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,IAAI,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAElE,OAAO,EACN,oBAAoB,EACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,KAAK,EACX,eAAe,EACf,sBAAsB,EACtB,aAAa,EACb,4BAA4B,EAC5B,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EACX,eAAe,EACf,sBAAsB,EACtB,aAAa,EACb,4BAA4B,EAC5B,MAAM,oBAAoB,CAAC;AAE5B;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,GAAG,aAAa,CAM7E;AAED,MAAM,MAAM,eAAe,GAAG;IAC7B;;OAEG;IACH,IAAI,EAAE,qBAAqB,CAAC,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import type { ServiceSearchCriteria } from '../../lib/resolver.js';\nimport type { ToJSONSerializable } from '../../lib/utils/json.js';\nimport { createAssert, createIs } from 'typia';\nimport {\n\tKeetaAnchorUserError\n} from '../../lib/error.js';\nimport type { HTTPSignedField } from '../../lib/http-server/common.js';\nimport type {\n\tKeetaNetAccount,\n\tKeetaNetStorageAccount,\n\tKeetaNetToken,\n\tKeetaNetTokenPublicKeyString\n} from '../../lib/asset.js';\n\nexport type {\n\tKeetaNetAccount,\n\tKeetaNetStorageAccount,\n\tKeetaNetToken,\n\tKeetaNetTokenPublicKeyString\n} from '../../lib/asset.js';\n\n/**\n * Parses a cost token from its serialized public key string form,\n * reconstituting a KeetaNetToken instance.\n */\nexport function parseFXCostToken(input: KeetaNetToken | string): KeetaNetToken {\n\tif (KeetaNetLib.Account.isInstance(input)) {\n\t\treturn(input);\n\t}\n\n\treturn(KeetaNetLib.Account.fromPublicKeyString(input).assertKeyType(KeetaNetLib.Account.AccountKeyAlgorithm.TOKEN));\n}\n\nexport type ConversionInput = {\n\t/**\n\t * The currency code to convert from (i.e., what the user has).\n\t */\n\tfrom: ServiceSearchCriteria<'fx'>['inputCurrencyCode'] | KeetaNetToken;\n\t/**\n\t * The currency code to convert to (i.e., what the user wants).\n\t */\n\tto: ServiceSearchCriteria<'fx'>['outputCurrencyCode'] | KeetaNetToken;\n\t/**\n\t * The amount to convert. This is a bigint representing the\n\t * amount in the currency specified by either `from` or `to`, as\n\t * specified by the `affinity` property.\n\t */\n\tamount: bigint;\n\t/**\n\t * Indicates whether the amount specified is in terms of the `from`\n\t * currency (i.e., the user has this much) or the `to` currency\n\t * (i.e., the user wants this much).\n\t */\n\taffinity: 'from' | 'to';\n\n\t/**\n\t * Optional preferred token in which the fee/cost should be\n\t * denominated. Must be one of the operator's advertised\n\t * acceptedCostAssets, if specified.\n\t */\n\tpreferredCostAsset?: KeetaNetTokenPublicKeyString;\n};\n\nexport type ConversionInputCanonical = {\n\t[k in keyof ConversionInput]: k extends 'amount' ? bigint : k extends 'from' ? KeetaNetToken : k extends 'to' ? KeetaNetToken : ConversionInput[k] extends undefined ? never : ConversionInput[k];\n};\n\nexport type ConversionInputCanonicalJSON = ToJSONSerializable<ConversionInputCanonical>;\n\nexport type KeetaFXAnchorClientCreateExchangeRequest = {\n\tblock: InstanceType<typeof KeetaNetLib.Block>;\n} & ({\n\tquote: KeetaFXAnchorQuote;\n} | {\n\trequest: ConversionInputCanonical;\n});\n\nexport type KeetaFXAnchorClientCreateExchangeRequestJSON = {\n\tblock: string;\n} & ({\n\tquote: KeetaFXAnchorQuoteJSON;\n\trequest?: undefined;\n} | {\n\tquote?: undefined;\n\trequest: ConversionInputCanonicalJSON;\n})\n\nexport type KeetaFXAnchorEstimate = {\n\t/**\n\t * Conversion request that was provided\n\t */\n\trequest: ConversionInputCanonical;\n\n\t/**\n\t * Amount after the conversion as specified by either `from` or `to`, as specified by the `affinity` property in the request.\n\t */\n\tconvertedAmount: bigint;\n\n\t/**\n\t * Outer bound of the converted amount.\n\t * if affinity is 'to', this is the maximum amount the user would need to send, if its 'from', this is the minimum amount the user would receive.\n\t */\n\tconvertedAmountBound?: bigint;\n\n\t/**\n\t * The expected cost of the fx request, in the form of a\n\t * token and a range of minimum and maximum expected costs\n\t */\n\texpectedCost: {\n\t\tmin: bigint;\n\t\tmax: bigint;\n\t\ttoken: KeetaNetToken;\n\t};\n} & (\n\t{\n\t\t/**\n\t\t * Indicates that the exchange cannot be performed if false, and no quote can be issued\n\t\t */\n\t\tcanPerformExchange: false;\n\t} | ({\n\t\t/**\n\t\t * Indicates that the exchange can be performed if true or undefined, but a quote may or may not be required before proceeding with the exchange\n\t\t */\n\t\tcanPerformExchange?: true;\n\t} & ({\n\t\t/**\n\t\t * Indicates that a quote is required before proceeding with the exchange\n\t\t */\n\t\trequiresQuote: false;\n\n\t\t/**\n\t\t * Liquidity provider account if the user is not going to request a quote before the exchange\n\t\t */\n\t\taccount: KeetaNetAccount | KeetaNetStorageAccount;\n\t} | {\n\t\t/**\n\t\t * Indicates that a quote is required before proceeding with the exchange, defaults to true\n\t\t */\n\t\trequiresQuote?: true;\n\t}))\n);\n\nexport type KeetaFXAnchorEstimateResponse = ({\n\tok: true;\n\testimate: ToJSONSerializable<KeetaFXAnchorEstimate>;\n} | {\n\tok: false;\n\terror: string;\n});\n\nexport type KeetaFXAnchorMarketPriceRatio = {\n\t/**\n\t * Amount of the base (destination) token in the price ratio\n\t */\n\tbase: string;\n\t/**\n\t * Amount of the quote (source) token in the price ratio\n\t */\n\tquote: string;\n};\n\nexport type KeetaFXAnchorMarketPricesRequest = {\n\t/**\n\t * Source tokens to price against the base asset\n\t */\n\tquoteAssets: KeetaNetTokenPublicKeyString[];\n\t/**\n\t * Destination token against which quote asset prices are expressed\n\t */\n\tbase: KeetaNetTokenPublicKeyString;\n};\n\nexport type KeetaFXAnchorMarketPrices = {\n\t/**\n\t * The destination token against which quote asset prices are expressed\n\t */\n\tbase: KeetaNetTokenPublicKeyString;\n\t/**\n\t * Current market prices for each requested quote asset, keyed by token public key\n\t */\n\tquoteAssets: {\n\t\t[quoteAsset in KeetaNetTokenPublicKeyString]?: {\n\t\t\tvalueRatio: KeetaFXAnchorMarketPriceRatio;\n\t\t};\n\t};\n};\n\nexport type KeetaFXAnchorMarketPricesResponse = ({\n\tok: true;\n} & KeetaFXAnchorMarketPrices) | {\n\tok: false;\n\terror: string;\n};\n\nexport type KeetaFXAnchorQuote = {\n\t/**\n\t * Conversion request that was provided\n\t */\n\trequest: ConversionInputCanonical;\n\n\t/**\n\t * The public key of the liquidity provider account\n\t */\n\taccount: KeetaNetAccount | KeetaNetStorageAccount;\n\n\t/**\n\t * Amount after the conversion as specified by either `from` or `to`, as specified by the `affinity` property in the request.\n\t */\n\tconvertedAmount: bigint;\n\n\t/**\n\t * The cost of the fx request, in the form of a\n\t * token and amount that should be included with the swap\n\t */\n\tcost: {\n\t\tamount: bigint;\n\t\ttoken: KeetaNetToken;\n\t};\n\n\t/**\n\t * Signature information to verify the quote\n\t */\n\tsigned: HTTPSignedField;\n};\n\nexport type KeetaFXAnchorQuoteJSON = ToJSONSerializable<KeetaFXAnchorQuote>;\n\nexport type KeetaFXAnchorQuoteResponse = ({\n\tok: true;\n\tquote: ToJSONSerializable<KeetaFXAnchorQuote>\n} | {\n\tok: false;\n\terror: string;\n});\n\n/**\n * Transport summary of a completed exchange's conversion, sufficient to\n * reconstruct the swap without re-reading the on-chain blocks.\n */\nexport type KeetaFXAnchorConversionSummary = {\n\t/**\n\t * Token and amount the user sent (the principal being converted from).\n\t */\n\tfrom: {\n\t\ttoken: KeetaNetTokenPublicKeyString;\n\t\tamount: string;\n\t};\n\t/**\n\t * Token and amount the user received (the converted-to currency).\n\t */\n\tto: {\n\t\ttoken: KeetaNetTokenPublicKeyString;\n\t\tamount: string;\n\t};\n\t/**\n\t * Liquidity provider account that settled the exchange.\n\t */\n\tliquidityProvider: string;\n\t/**\n\t * Fee charged for the exchange, when the server computed it.\n\t */\n\tcost?: {\n\t\ttoken: KeetaNetTokenPublicKeyString;\n\t\tamount: string;\n\t};\n};\n\nexport type KeetaFXAnchorExchange = {\n\t/**\n\t * ID used to identify the conversion request\n\t */\n\texchangeID: string\n} & ({\n\t/**\n\t * Status of the exchange request\n\t */\n\tstatus: 'pending' | 'failed';\n} | {\n\t/**\n\t * Status of the exchange request\n\t */\n\tstatus: 'completed';\n\t/**\n\t * Blockhash where the exchange was completed -- the user-supplied\n\t * blockhash for their portion of the exchange transaction can be\n\t * used to look up the transaction on-chain as well, but we return\n\t * a value here so that it can be looked up without needing to store\n\t * that initial block.\n\t */\n\tblockhash: string;\n\t/**\n\t * Summary of the conversion that settled, when the server recorded it.\n\t */\n\tconversion?: KeetaFXAnchorConversionSummary;\n});\n\nexport type KeetaFXAnchorExchangeResponse = (KeetaFXAnchorExchange & {\n\tok: true;\n}) | (Partial<KeetaFXAnchorExchange> & {\n\tok: false;\n\terror: string;\n});\n\nexport const isKeetaFXAnchorEstimateResponse: (input: unknown) => input is KeetaFXAnchorEstimateResponse = createIs<KeetaFXAnchorEstimateResponse>();\nexport const isKeetaFXAnchorQuoteResponse: (input: unknown) => input is KeetaFXAnchorQuoteResponse = createIs<KeetaFXAnchorQuoteResponse>();\nexport const isKeetaFXAnchorExchangeResponse: (input: unknown) => input is KeetaFXAnchorExchangeResponse = createIs<KeetaFXAnchorExchangeResponse>();\nexport const isKeetaFXAnchorMarketPricesResponse: (input: unknown) => input is KeetaFXAnchorMarketPricesResponse = createIs<KeetaFXAnchorMarketPricesResponse>();\nexport const assertKeetaNetTokenPublicKeyString: (input: unknown) => KeetaNetTokenPublicKeyString = createAssert<KeetaNetTokenPublicKeyString>();\nexport const assertConversionInputCanonicalJSON: (input: unknown) => ConversionInputCanonicalJSON = createAssert<ConversionInputCanonicalJSON>();\nexport const assertKeetaFXAnchorClientCreateExchangeRequestJSON: (input: unknown) => KeetaFXAnchorClientCreateExchangeRequestJSON = createAssert<KeetaFXAnchorClientCreateExchangeRequestJSON>();\n\nclass KeetaFXAnchorQuoteValidationFailedError extends KeetaAnchorUserError {\n\tstatic override readonly name: string = 'KeetaFXAnchorQuoteValidationFailedError';\n\tprivate readonly KeetaFXAnchorQuoteValidationFailedErrorObjectTypeID!: string;\n\tprivate static readonly KeetaFXAnchorQuoteValidationFailedErrorObjectTypeID = 'a8f3c2d1-9b4e-4f2a-8c1d-5e6f7a8b9c0d';\n\n\tconstructor(message?: string) {\n\t\tsuper(message ?? 'Quote validation failed');\n\t\tthis.statusCode = 400;\n\n\t\tObject.defineProperty(this, 'KeetaFXAnchorQuoteValidationFailedErrorObjectTypeID', {\n\t\t\tvalue: KeetaFXAnchorQuoteValidationFailedError.KeetaFXAnchorQuoteValidationFailedErrorObjectTypeID,\n\t\t\tenumerable: false\n\t\t});\n\t}\n\n\tstatic isInstance(input: unknown): input is KeetaFXAnchorQuoteValidationFailedError {\n\t\treturn(this.hasPropWithValue(input, 'KeetaFXAnchorQuoteValidationFailedErrorObjectTypeID', KeetaFXAnchorQuoteValidationFailedError.KeetaFXAnchorQuoteValidationFailedErrorObjectTypeID));\n\t}\n\n\tstatic async fromJSON(input: unknown): Promise<InstanceType<typeof this>> {\n\t\tconst { message, other } = this.extractErrorProperties(input, this);\n\t\tconst error = new this(message);\n\t\terror.restoreFromJSON(other);\n\t\treturn(error);\n\t}\n}\n\nclass KeetaFXAnchorQuoteRequiredError extends KeetaAnchorUserError {\n\tstatic override readonly name: string = 'KeetaFXAnchorQuoteRequiredError';\n\tprivate readonly KeetaFXAnchorQuoteRequiredErrorObjectTypeID!: string;\n\tprivate static readonly KeetaFXAnchorQuoteRequiredErrorObjectTypeID = '9f22067f-52b3-40f2-84c1-ad9285260980';\n\n\tconstructor(message?: string) {\n\t\tsuper(message ?? 'Quote required to perform exchange');\n\t\tthis.statusCode = 400;\n\n\t\tObject.defineProperty(this, 'KeetaFXAnchorQuoteRequiredErrorObjectTypeID', {\n\t\t\tvalue: KeetaFXAnchorQuoteRequiredError.KeetaFXAnchorQuoteRequiredErrorObjectTypeID,\n\t\t\tenumerable: false\n\t\t});\n\t}\n\n\tstatic isInstance(input: unknown): input is KeetaFXAnchorQuoteRequiredError {\n\t\treturn(this.hasPropWithValue(input, 'KeetaFXAnchorQuoteRequiredErrorObjectTypeID', KeetaFXAnchorQuoteRequiredError.KeetaFXAnchorQuoteRequiredErrorObjectTypeID));\n\t}\n\n\tstatic async fromJSON(input: unknown): Promise<InstanceType<typeof this>> {\n\t\tconst { message, other } = this.extractErrorProperties(input, this);\n\t\tconst error = new this(message);\n\t\terror.restoreFromJSON(other);\n\t\treturn(error);\n\t}\n}\n\nclass KeetaFXAnchorQuoteIssuanceDisabledError extends KeetaAnchorUserError {\n\tstatic override readonly name: string = 'KeetaFXAnchorQuoteIssuanceDisabledError';\n\tprivate readonly KeetaFXAnchorQuoteIssuanceDisabledErrorObjectTypeID!: string;\n\tprivate static readonly KeetaFXAnchorQuoteIssuanceDisabledErrorObjectTypeID = 'a0f70c0b-6e17-41f0-825a-d086983209e1';\n\n\tconstructor(message?: string) {\n\t\tsuper(message ?? 'Anchor cannot issue quotes');\n\t\tthis.statusCode = 501;\n\n\t\tObject.defineProperty(this, 'KeetaFXAnchorQuoteIssuanceDisabledErrorObjectTypeID', {\n\t\t\tvalue: KeetaFXAnchorQuoteIssuanceDisabledError.KeetaFXAnchorQuoteIssuanceDisabledErrorObjectTypeID,\n\t\t\tenumerable: false\n\t\t});\n\t}\n\n\tstatic isInstance(input: unknown): input is KeetaFXAnchorQuoteIssuanceDisabledError {\n\t\treturn(this.hasPropWithValue(input, 'KeetaFXAnchorQuoteIssuanceDisabledErrorObjectTypeID', KeetaFXAnchorQuoteIssuanceDisabledError.KeetaFXAnchorQuoteIssuanceDisabledErrorObjectTypeID));\n\t}\n\n\tstatic async fromJSON(input: unknown): Promise<InstanceType<typeof this>> {\n\t\tconst { message, other } = this.extractErrorProperties(input, this);\n\t\tconst error = new this(message);\n\t\terror.restoreFromJSON(other);\n\t\treturn(error);\n\t}\n}\n\nclass KeetaFXAnchorResponseMismatchError extends KeetaAnchorUserError {\n\tstatic override readonly name: string = 'KeetaFXAnchorResponseMismatchError';\n\tprivate readonly KeetaFXAnchorResponseMismatchErrorObjectTypeID!: string;\n\tprivate static readonly KeetaFXAnchorResponseMismatchErrorObjectTypeID = '3c6b1e52-8f0d-4a97-b2e4-71d95c0a6f38';\n\n\tconstructor(message?: string) {\n\t\tsuper(message ?? 'FX provider response does not match the request');\n\t\tthis.statusCode = 502;\n\n\t\tObject.defineProperty(this, 'KeetaFXAnchorResponseMismatchErrorObjectTypeID', {\n\t\t\tvalue: KeetaFXAnchorResponseMismatchError.KeetaFXAnchorResponseMismatchErrorObjectTypeID,\n\t\t\tenumerable: false\n\t\t});\n\t}\n\n\tstatic isInstance(input: unknown): input is KeetaFXAnchorResponseMismatchError {\n\t\treturn(this.hasPropWithValue(input, 'KeetaFXAnchorResponseMismatchErrorObjectTypeID', KeetaFXAnchorResponseMismatchError.KeetaFXAnchorResponseMismatchErrorObjectTypeID));\n\t}\n}\n\nclass KeetaFXAnchorExchangeLimitExceededError extends KeetaAnchorUserError {\n\tstatic override readonly name: string = 'KeetaFXAnchorExchangeLimitExceededError';\n\tprivate readonly KeetaFXAnchorExchangeLimitExceededErrorObjectTypeID!: string;\n\tprivate static readonly KeetaFXAnchorExchangeLimitExceededErrorObjectTypeID = 'd2a47f90-5c1b-4e38-9a6d-0b8e3f71c5a4';\n\n\tconstructor(message?: string) {\n\t\tsuper(message ?? 'FX exchange exceeds the limits set by the caller');\n\t\tthis.statusCode = 400;\n\n\t\tObject.defineProperty(this, 'KeetaFXAnchorExchangeLimitExceededErrorObjectTypeID', {\n\t\t\tvalue: KeetaFXAnchorExchangeLimitExceededError.KeetaFXAnchorExchangeLimitExceededErrorObjectTypeID,\n\t\t\tenumerable: false\n\t\t});\n\t}\n\n\tstatic isInstance(input: unknown): input is KeetaFXAnchorExchangeLimitExceededError {\n\t\treturn(this.hasPropWithValue(input, 'KeetaFXAnchorExchangeLimitExceededErrorObjectTypeID', KeetaFXAnchorExchangeLimitExceededError.KeetaFXAnchorExchangeLimitExceededErrorObjectTypeID));\n\t}\n}\n\nexport const Errors: {\n\tQuoteValidationFailed: typeof KeetaFXAnchorQuoteValidationFailedError;\n\tQuoteRequired: typeof KeetaFXAnchorQuoteRequiredError;\n\tQuoteIssuanceDisabled: typeof KeetaFXAnchorQuoteIssuanceDisabledError;\n\tResponseMismatch: typeof KeetaFXAnchorResponseMismatchError;\n\tExchangeLimitExceeded: typeof KeetaFXAnchorExchangeLimitExceededError;\n} = {\n\t/**\n\t * The quote validation failed\n\t */\n\tQuoteValidationFailed: KeetaFXAnchorQuoteValidationFailedError,\n\n\t/**\n\t * Quote is required to perform the exchange\n\t */\n\tQuoteRequired: KeetaFXAnchorQuoteRequiredError,\n\n\t/**\n\t * The anchor cannot issue quotes\n\t */\n\tQuoteIssuanceDisabled: KeetaFXAnchorQuoteIssuanceDisabledError,\n\n\t/**\n\t * The FX provider answered with terms that do not match the request:\n\t * another conversion, a fee in a token the client does not accept, or\n\t * an estimate bound on the wrong side of its converted amount\n\t */\n\tResponseMismatch: KeetaFXAnchorResponseMismatchError,\n\n\t/**\n\t * The exchange would send, receive, or charge more than the limits the\n\t * caller gave to `createExchange`\n\t */\n\tExchangeLimitExceeded: KeetaFXAnchorExchangeLimitExceededError\n};\n"]}
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/services/fx/common.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,IAAI,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAInE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,EACN,oBAAoB,EACpB,MAAM,oBAAoB,CAAC;AAgB5B;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAA6B;IAC7D,IAAI,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3C,OAAM,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;IAED,OAAM,CAAC,WAAW,CAAC,OAAO,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,aAAa,CAAC,WAAW,CAAC,OAAO,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAC;AACrH,CAAC;AAmRD,MAAM,CAAC,MAAM,+BAA+B;;;;;;;;;;;;;;sFAAwG,CAAC;AACrJ,MAAM,CAAC,MAAM,4BAA4B;;;;;;;sFAAkG,CAAC;AAC5I,MAAM,CAAC,MAAM,+BAA+B;;;;;;;;;;sFAAwG,CAAC;AACrJ,MAAM,CAAC,MAAM,mCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;sFAAgH,CAAC;AACjK,MAAM,CAAC,MAAM,kCAAkC;;;;;;;;;;;OAAkG,CAAC;AAClJ,MAAM,CAAC,MAAM,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAAiG,CAAC;AACj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B;QAC3B,KAAK,CAAC,OAAO,IAAI,kDAAkD,CAAC,CAAC;QACrE,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC;QAEtB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,qDAAqD,EAAE;YAClF,KAAK,EAAE,uCAAuC,CAAC,mDAAmD;YAClG,UAAU,EAAE,KAAK;SACjB,CAAC,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,KAAc;QAC/B,OAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,qDAAqD,EAAE,uCAAuC,CAAC,mDAAmD,CAAC,CAAC,CAAC;IAC1L,CAAC;;AAGF,MAAM,CAAC,MAAM,MAAM,GAMf;IACH;;OAEG;IACH,qBAAqB,EAAE,uCAAuC;IAE9D;;OAEG;IACH,aAAa,EAAE,+BAA+B;IAE9C;;OAEG;IACH,qBAAqB,EAAE,uCAAuC;IAE9D;;;;OAIG;IACH,gBAAgB,EAAE,kCAAkC;IAEpD;;;OAGG;IACH,qBAAqB,EAAE,uCAAuC;CAC9D,CAAC","sourcesContent":["import { lib as KeetaNetLib } from '@keetanetwork/keetanet-client';\n\nimport type { ServiceSearchCriteria } from '../../lib/resolver.js';\nimport type { ToJSONSerializable } from '../../lib/utils/json.js';\nimport { createAssert, createIs } from 'typia';\nimport {\n\tKeetaAnchorUserError\n} from '../../lib/error.js';\nimport type { HTTPSignedField } from '../../lib/http-server/common.js';\nimport type {\n\tKeetaNetAccount,\n\tKeetaNetStorageAccount,\n\tKeetaNetToken,\n\tKeetaNetTokenPublicKeyString\n} from '../../lib/asset.js';\n\nexport type {\n\tKeetaNetAccount,\n\tKeetaNetStorageAccount,\n\tKeetaNetToken,\n\tKeetaNetTokenPublicKeyString\n} from '../../lib/asset.js';\n\n/**\n * Parses a cost token from its serialized public key string form,\n * reconstituting a KeetaNetToken instance.\n */\nexport function parseFXCostToken(input: KeetaNetToken | string): KeetaNetToken {\n\tif (KeetaNetLib.Account.isInstance(input)) {\n\t\treturn(input);\n\t}\n\n\treturn(KeetaNetLib.Account.fromPublicKeyString(input).assertKeyType(KeetaNetLib.Account.AccountKeyAlgorithm.TOKEN));\n}\n\nexport type ConversionInput = {\n\t/**\n\t * The currency code to convert from (i.e., what the user has).\n\t */\n\tfrom: ServiceSearchCriteria<'fx'>['inputCurrencyCode'] | KeetaNetToken;\n\t/**\n\t * The currency code to convert to (i.e., what the user wants).\n\t */\n\tto: ServiceSearchCriteria<'fx'>['outputCurrencyCode'] | KeetaNetToken;\n\t/**\n\t * The amount to convert. This is a bigint representing the\n\t * amount in the currency specified by either `from` or `to`, as\n\t * specified by the `affinity` property.\n\t */\n\tamount: bigint;\n\t/**\n\t * Indicates whether the amount specified is in terms of the `from`\n\t * currency (i.e., the user has this much) or the `to` currency\n\t * (i.e., the user wants this much).\n\t */\n\taffinity: 'from' | 'to';\n\n\t/**\n\t * Optional preferred token in which the fee/cost should be\n\t * denominated. Must be one of the operator's advertised\n\t * acceptedCostAssets, if specified.\n\t */\n\tpreferredCostAsset?: KeetaNetTokenPublicKeyString;\n};\n\nexport type ConversionInputCanonical = {\n\t[k in keyof ConversionInput]: k extends 'amount' ? bigint : k extends 'from' ? KeetaNetToken : k extends 'to' ? KeetaNetToken : ConversionInput[k] extends undefined ? never : ConversionInput[k];\n};\n\nexport type ConversionInputCanonicalJSON = ToJSONSerializable<ConversionInputCanonical>;\n\nexport type KeetaFXAnchorClientCreateExchangeRequest = {\n\tblock: InstanceType<typeof KeetaNetLib.Block>;\n} & ({\n\tquote: KeetaFXAnchorQuote;\n} | {\n\trequest: ConversionInputCanonical;\n});\n\nexport type KeetaFXAnchorClientCreateExchangeRequestJSON = {\n\tblock: string;\n} & ({\n\tquote: KeetaFXAnchorQuoteJSON;\n\trequest?: undefined;\n} | {\n\tquote?: undefined;\n\trequest: ConversionInputCanonicalJSON;\n})\n\nexport type KeetaFXAnchorEstimate = {\n\t/**\n\t * Conversion request that was provided\n\t */\n\trequest: ConversionInputCanonical;\n\n\t/**\n\t * Amount after the conversion as specified by either `from` or `to`, as specified by the `affinity` property in the request.\n\t */\n\tconvertedAmount: bigint;\n\n\t/**\n\t * Outer bound of the converted amount.\n\t * if affinity is 'to', this is the maximum amount the user would need to send, if its 'from', this is the minimum amount the user would receive.\n\t */\n\tconvertedAmountBound?: bigint;\n\n\t/**\n\t * The expected cost of the fx request, in the form of a\n\t * token and a range of minimum and maximum expected costs\n\t */\n\texpectedCost: {\n\t\tmin: bigint;\n\t\tmax: bigint;\n\t\ttoken: KeetaNetToken;\n\t};\n} & (\n\t{\n\t\t/**\n\t\t * Indicates that the exchange cannot be performed if false, and no quote can be issued\n\t\t */\n\t\tcanPerformExchange: false;\n\t} | ({\n\t\t/**\n\t\t * Indicates that the exchange can be performed if true or undefined, but a quote may or may not be required before proceeding with the exchange\n\t\t */\n\t\tcanPerformExchange?: true;\n\t} & ({\n\t\t/**\n\t\t * Indicates that a quote is required before proceeding with the exchange\n\t\t */\n\t\trequiresQuote: false;\n\n\t\t/**\n\t\t * Liquidity provider account if the user is not going to request a quote before the exchange\n\t\t */\n\t\taccount: KeetaNetAccount | KeetaNetStorageAccount;\n\t} | {\n\t\t/**\n\t\t * Indicates that a quote is required before proceeding with the exchange, defaults to true\n\t\t */\n\t\trequiresQuote?: true;\n\t}))\n);\n\nexport type KeetaFXAnchorEstimateResponse = ({\n\tok: true;\n\testimate: ToJSONSerializable<KeetaFXAnchorEstimate>;\n} | {\n\tok: false;\n\terror: string;\n});\n\n/**\n * Base-unit exchange rate: a client converts with amount * base / quote. Not a whole-token price.\n */\nexport type KeetaFXAnchorMarketPriceRatio = {\n\t/**\n\t * Amount of the base (destination) token in the price ratio, in base units\n\t */\n\tbase: string;\n\t/**\n\t * Amount of the quote (source) token in the price ratio, in base units\n\t */\n\tquote: string;\n};\n\nexport type KeetaFXAnchorMarketPricesRequest = {\n\t/**\n\t * Source tokens to price against the base asset\n\t */\n\tquoteAssets: KeetaNetTokenPublicKeyString[];\n\t/**\n\t * Destination token against which quote asset prices are expressed\n\t */\n\tbase: KeetaNetTokenPublicKeyString;\n};\n\nexport type KeetaFXAnchorMarketPrices = {\n\t/**\n\t * The destination token against which quote asset prices are expressed\n\t */\n\tbase: KeetaNetTokenPublicKeyString;\n\t/**\n\t * Current market prices for each requested quote asset, keyed by token public key\n\t */\n\tquoteAssets: {\n\t\t[quoteAsset in KeetaNetTokenPublicKeyString]?: {\n\t\t\tvalueRatio: KeetaFXAnchorMarketPriceRatio;\n\t\t};\n\t};\n};\n\nexport type KeetaFXAnchorMarketPricesResponse = ({\n\tok: true;\n} & KeetaFXAnchorMarketPrices) | {\n\tok: false;\n\terror: string;\n};\n\nexport type KeetaFXAnchorQuote = {\n\t/**\n\t * Conversion request that was provided\n\t */\n\trequest: ConversionInputCanonical;\n\n\t/**\n\t * The public key of the liquidity provider account\n\t */\n\taccount: KeetaNetAccount | KeetaNetStorageAccount;\n\n\t/**\n\t * Amount after the conversion as specified by either `from` or `to`, as specified by the `affinity` property in the request.\n\t */\n\tconvertedAmount: bigint;\n\n\t/**\n\t * The cost of the fx request, in the form of a\n\t * token and amount that should be included with the swap\n\t */\n\tcost: {\n\t\tamount: bigint;\n\t\ttoken: KeetaNetToken;\n\t};\n\n\t/**\n\t * Signature information to verify the quote\n\t */\n\tsigned: HTTPSignedField;\n};\n\nexport type KeetaFXAnchorQuoteJSON = ToJSONSerializable<KeetaFXAnchorQuote>;\n\nexport type KeetaFXAnchorQuoteResponse = ({\n\tok: true;\n\tquote: ToJSONSerializable<KeetaFXAnchorQuote>\n} | {\n\tok: false;\n\terror: string;\n});\n\n/**\n * Transport summary of a completed exchange's conversion, sufficient to\n * reconstruct the swap without re-reading the on-chain blocks.\n */\nexport type KeetaFXAnchorConversionSummary = {\n\t/**\n\t * Token and amount the user sent (the principal being converted from).\n\t */\n\tfrom: {\n\t\ttoken: KeetaNetTokenPublicKeyString;\n\t\tamount: string;\n\t};\n\t/**\n\t * Token and amount the user received (the converted-to currency).\n\t */\n\tto: {\n\t\ttoken: KeetaNetTokenPublicKeyString;\n\t\tamount: string;\n\t};\n\t/**\n\t * Liquidity provider account that settled the exchange.\n\t */\n\tliquidityProvider: string;\n\t/**\n\t * Fee charged for the exchange, when the server computed it.\n\t */\n\tcost?: {\n\t\ttoken: KeetaNetTokenPublicKeyString;\n\t\tamount: string;\n\t};\n};\n\nexport type KeetaFXAnchorExchange = {\n\t/**\n\t * ID used to identify the conversion request\n\t */\n\texchangeID: string\n} & ({\n\t/**\n\t * Status of the exchange request\n\t */\n\tstatus: 'pending' | 'failed';\n} | {\n\t/**\n\t * Status of the exchange request\n\t */\n\tstatus: 'completed';\n\t/**\n\t * Blockhash where the exchange was completed -- the user-supplied\n\t * blockhash for their portion of the exchange transaction can be\n\t * used to look up the transaction on-chain as well, but we return\n\t * a value here so that it can be looked up without needing to store\n\t * that initial block.\n\t */\n\tblockhash: string;\n\t/**\n\t * Summary of the conversion that settled, when the server recorded it.\n\t */\n\tconversion?: KeetaFXAnchorConversionSummary;\n});\n\nexport type KeetaFXAnchorExchangeResponse = (KeetaFXAnchorExchange & {\n\tok: true;\n}) | (Partial<KeetaFXAnchorExchange> & {\n\tok: false;\n\terror: string;\n});\n\nexport const isKeetaFXAnchorEstimateResponse: (input: unknown) => input is KeetaFXAnchorEstimateResponse = createIs<KeetaFXAnchorEstimateResponse>();\nexport const isKeetaFXAnchorQuoteResponse: (input: unknown) => input is KeetaFXAnchorQuoteResponse = createIs<KeetaFXAnchorQuoteResponse>();\nexport const isKeetaFXAnchorExchangeResponse: (input: unknown) => input is KeetaFXAnchorExchangeResponse = createIs<KeetaFXAnchorExchangeResponse>();\nexport const isKeetaFXAnchorMarketPricesResponse: (input: unknown) => input is KeetaFXAnchorMarketPricesResponse = createIs<KeetaFXAnchorMarketPricesResponse>();\nexport const assertKeetaNetTokenPublicKeyString: (input: unknown) => KeetaNetTokenPublicKeyString = createAssert<KeetaNetTokenPublicKeyString>();\nexport const assertConversionInputCanonicalJSON: (input: unknown) => ConversionInputCanonicalJSON = createAssert<ConversionInputCanonicalJSON>();\nexport const assertKeetaFXAnchorClientCreateExchangeRequestJSON: (input: unknown) => KeetaFXAnchorClientCreateExchangeRequestJSON = createAssert<KeetaFXAnchorClientCreateExchangeRequestJSON>();\n\nclass KeetaFXAnchorQuoteValidationFailedError extends KeetaAnchorUserError {\n\tstatic override readonly name: string = 'KeetaFXAnchorQuoteValidationFailedError';\n\tprivate readonly KeetaFXAnchorQuoteValidationFailedErrorObjectTypeID!: string;\n\tprivate static readonly KeetaFXAnchorQuoteValidationFailedErrorObjectTypeID = 'a8f3c2d1-9b4e-4f2a-8c1d-5e6f7a8b9c0d';\n\n\tconstructor(message?: string) {\n\t\tsuper(message ?? 'Quote validation failed');\n\t\tthis.statusCode = 400;\n\n\t\tObject.defineProperty(this, 'KeetaFXAnchorQuoteValidationFailedErrorObjectTypeID', {\n\t\t\tvalue: KeetaFXAnchorQuoteValidationFailedError.KeetaFXAnchorQuoteValidationFailedErrorObjectTypeID,\n\t\t\tenumerable: false\n\t\t});\n\t}\n\n\tstatic isInstance(input: unknown): input is KeetaFXAnchorQuoteValidationFailedError {\n\t\treturn(this.hasPropWithValue(input, 'KeetaFXAnchorQuoteValidationFailedErrorObjectTypeID', KeetaFXAnchorQuoteValidationFailedError.KeetaFXAnchorQuoteValidationFailedErrorObjectTypeID));\n\t}\n\n\tstatic async fromJSON(input: unknown): Promise<InstanceType<typeof this>> {\n\t\tconst { message, other } = this.extractErrorProperties(input, this);\n\t\tconst error = new this(message);\n\t\terror.restoreFromJSON(other);\n\t\treturn(error);\n\t}\n}\n\nclass KeetaFXAnchorQuoteRequiredError extends KeetaAnchorUserError {\n\tstatic override readonly name: string = 'KeetaFXAnchorQuoteRequiredError';\n\tprivate readonly KeetaFXAnchorQuoteRequiredErrorObjectTypeID!: string;\n\tprivate static readonly KeetaFXAnchorQuoteRequiredErrorObjectTypeID = '9f22067f-52b3-40f2-84c1-ad9285260980';\n\n\tconstructor(message?: string) {\n\t\tsuper(message ?? 'Quote required to perform exchange');\n\t\tthis.statusCode = 400;\n\n\t\tObject.defineProperty(this, 'KeetaFXAnchorQuoteRequiredErrorObjectTypeID', {\n\t\t\tvalue: KeetaFXAnchorQuoteRequiredError.KeetaFXAnchorQuoteRequiredErrorObjectTypeID,\n\t\t\tenumerable: false\n\t\t});\n\t}\n\n\tstatic isInstance(input: unknown): input is KeetaFXAnchorQuoteRequiredError {\n\t\treturn(this.hasPropWithValue(input, 'KeetaFXAnchorQuoteRequiredErrorObjectTypeID', KeetaFXAnchorQuoteRequiredError.KeetaFXAnchorQuoteRequiredErrorObjectTypeID));\n\t}\n\n\tstatic async fromJSON(input: unknown): Promise<InstanceType<typeof this>> {\n\t\tconst { message, other } = this.extractErrorProperties(input, this);\n\t\tconst error = new this(message);\n\t\terror.restoreFromJSON(other);\n\t\treturn(error);\n\t}\n}\n\nclass KeetaFXAnchorQuoteIssuanceDisabledError extends KeetaAnchorUserError {\n\tstatic override readonly name: string = 'KeetaFXAnchorQuoteIssuanceDisabledError';\n\tprivate readonly KeetaFXAnchorQuoteIssuanceDisabledErrorObjectTypeID!: string;\n\tprivate static readonly KeetaFXAnchorQuoteIssuanceDisabledErrorObjectTypeID = 'a0f70c0b-6e17-41f0-825a-d086983209e1';\n\n\tconstructor(message?: string) {\n\t\tsuper(message ?? 'Anchor cannot issue quotes');\n\t\tthis.statusCode = 501;\n\n\t\tObject.defineProperty(this, 'KeetaFXAnchorQuoteIssuanceDisabledErrorObjectTypeID', {\n\t\t\tvalue: KeetaFXAnchorQuoteIssuanceDisabledError.KeetaFXAnchorQuoteIssuanceDisabledErrorObjectTypeID,\n\t\t\tenumerable: false\n\t\t});\n\t}\n\n\tstatic isInstance(input: unknown): input is KeetaFXAnchorQuoteIssuanceDisabledError {\n\t\treturn(this.hasPropWithValue(input, 'KeetaFXAnchorQuoteIssuanceDisabledErrorObjectTypeID', KeetaFXAnchorQuoteIssuanceDisabledError.KeetaFXAnchorQuoteIssuanceDisabledErrorObjectTypeID));\n\t}\n\n\tstatic async fromJSON(input: unknown): Promise<InstanceType<typeof this>> {\n\t\tconst { message, other } = this.extractErrorProperties(input, this);\n\t\tconst error = new this(message);\n\t\terror.restoreFromJSON(other);\n\t\treturn(error);\n\t}\n}\n\nclass KeetaFXAnchorResponseMismatchError extends KeetaAnchorUserError {\n\tstatic override readonly name: string = 'KeetaFXAnchorResponseMismatchError';\n\tprivate readonly KeetaFXAnchorResponseMismatchErrorObjectTypeID!: string;\n\tprivate static readonly KeetaFXAnchorResponseMismatchErrorObjectTypeID = '3c6b1e52-8f0d-4a97-b2e4-71d95c0a6f38';\n\n\tconstructor(message?: string) {\n\t\tsuper(message ?? 'FX provider response does not match the request');\n\t\tthis.statusCode = 502;\n\n\t\tObject.defineProperty(this, 'KeetaFXAnchorResponseMismatchErrorObjectTypeID', {\n\t\t\tvalue: KeetaFXAnchorResponseMismatchError.KeetaFXAnchorResponseMismatchErrorObjectTypeID,\n\t\t\tenumerable: false\n\t\t});\n\t}\n\n\tstatic isInstance(input: unknown): input is KeetaFXAnchorResponseMismatchError {\n\t\treturn(this.hasPropWithValue(input, 'KeetaFXAnchorResponseMismatchErrorObjectTypeID', KeetaFXAnchorResponseMismatchError.KeetaFXAnchorResponseMismatchErrorObjectTypeID));\n\t}\n}\n\nclass KeetaFXAnchorExchangeLimitExceededError extends KeetaAnchorUserError {\n\tstatic override readonly name: string = 'KeetaFXAnchorExchangeLimitExceededError';\n\tprivate readonly KeetaFXAnchorExchangeLimitExceededErrorObjectTypeID!: string;\n\tprivate static readonly KeetaFXAnchorExchangeLimitExceededErrorObjectTypeID = 'd2a47f90-5c1b-4e38-9a6d-0b8e3f71c5a4';\n\n\tconstructor(message?: string) {\n\t\tsuper(message ?? 'FX exchange exceeds the limits set by the caller');\n\t\tthis.statusCode = 400;\n\n\t\tObject.defineProperty(this, 'KeetaFXAnchorExchangeLimitExceededErrorObjectTypeID', {\n\t\t\tvalue: KeetaFXAnchorExchangeLimitExceededError.KeetaFXAnchorExchangeLimitExceededErrorObjectTypeID,\n\t\t\tenumerable: false\n\t\t});\n\t}\n\n\tstatic isInstance(input: unknown): input is KeetaFXAnchorExchangeLimitExceededError {\n\t\treturn(this.hasPropWithValue(input, 'KeetaFXAnchorExchangeLimitExceededErrorObjectTypeID', KeetaFXAnchorExchangeLimitExceededError.KeetaFXAnchorExchangeLimitExceededErrorObjectTypeID));\n\t}\n}\n\nexport const Errors: {\n\tQuoteValidationFailed: typeof KeetaFXAnchorQuoteValidationFailedError;\n\tQuoteRequired: typeof KeetaFXAnchorQuoteRequiredError;\n\tQuoteIssuanceDisabled: typeof KeetaFXAnchorQuoteIssuanceDisabledError;\n\tResponseMismatch: typeof KeetaFXAnchorResponseMismatchError;\n\tExchangeLimitExceeded: typeof KeetaFXAnchorExchangeLimitExceededError;\n} = {\n\t/**\n\t * The quote validation failed\n\t */\n\tQuoteValidationFailed: KeetaFXAnchorQuoteValidationFailedError,\n\n\t/**\n\t * Quote is required to perform the exchange\n\t */\n\tQuoteRequired: KeetaFXAnchorQuoteRequiredError,\n\n\t/**\n\t * The anchor cannot issue quotes\n\t */\n\tQuoteIssuanceDisabled: KeetaFXAnchorQuoteIssuanceDisabledError,\n\n\t/**\n\t * The FX provider answered with terms that do not match the request:\n\t * another conversion, a fee in a token the client does not accept, or\n\t * an estimate bound on the wrong side of its converted amount\n\t */\n\tResponseMismatch: KeetaFXAnchorResponseMismatchError,\n\n\t/**\n\t * The exchange would send, receive, or charge more than the limits the\n\t * caller gave to `createExchange`\n\t */\n\tExchangeLimitExceeded: KeetaFXAnchorExchangeLimitExceededError\n};\n"]}
|
package/services/fx/server.d.ts
CHANGED
|
@@ -38,8 +38,8 @@ export type KeetaFXAnchorMarketPricesConfig = {
|
|
|
38
38
|
*/
|
|
39
39
|
cacheControl?: KeetaFXAnchorMarketPricesCacheControl;
|
|
40
40
|
/**
|
|
41
|
-
* Reference quote amount
|
|
42
|
-
*
|
|
41
|
+
* Reference quote amount in base units. When omitted, it starts at 1000n and grows by 1000x until the converted amount is precise.
|
|
42
|
+
* That can take up to 13 estimates per quote asset, so set `cacheControl` when estimates call an external API. Ignored when `get` is provided.
|
|
43
43
|
*/
|
|
44
44
|
referenceAmount?: bigint;
|
|
45
45
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/services/fx/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,qBAAqB,MAAM,gCAAgC,CAAC;AAC7E,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,qCAAqC,CAAC;AAC3F,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAChF,OAAO,KAAK,QAAQ,MAAM,+BAA+B,CAAC;AAY1D,OAAO,KAAK,EACX,4BAA4B,EAC5B,8BAA8B,EAC9B,qBAAqB,EAGrB,yBAAyB,EACzB,gCAAgC,EAEhC,kBAAkB,EAClB,sBAAsB,EAEtB,eAAe,EAEf,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,OAAO,MAAM,4BAA4B,CAAC;AAGtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAuC,MAAM,0BAA0B,CAAC;AAGvG,OAAO,KAAK,EAAE,6BAA6B,EAAE,yBAAyB,EAAE,yCAAyC,EAAE,MAAM,0BAA0B,CAAC;AACpJ,OAAO,EAAE,gCAAgC,EAAE,MAAM,6BAA6B,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAsB,MAAM,yBAAyB,CAAC;AAEpF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAM7D,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/services/fx/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,q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AAW,CAAC,yBAAyB,CAAC,UAAU,CAAC,CAAC,CAAC;IACtE,QAAQ,CAAC,OAAO,EAAE,yBAAyB,CAAC,SAAS,CAAC,CAAa;IACnE,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,yBAAyB,CAAC,QAAQ,CAAC,CAAC,CAAC;IAClE,QAAQ,CAAC,WAAW,EAAE,yBAAyB,CAAC,aAAa,CAAC,CAAC;IAC/D,QAAQ,CAAC,EAAE,EAAE,yBAAyB,CAAC,IAAI,CAAC,CAAC;IAC7C,QAAQ,CAAC,QAAQ,EAAE,0BAA0B,CAAC;IAC9C,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAC,yBAAyB,CAAC,oBAAoB,CAAC,EAAE,SAAS,CAAC,CAAC;IAEjG,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC;IAC3B,SAAS,CAAC,cAAc,UAAS;gBAErB,MAAM,EAAE,yBAAyB;cAqE7B,UAAU,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,qBAAqB,CAAC,MAAM,CAAC;cA2T3E,oBAAoB,IAAI,OAAO,CAAC,WAAW,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAa1G,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAK3B"}
|
package/services/fx/server.js
CHANGED
|
@@ -55,6 +55,22 @@ function getPostRequest(postData) {
|
|
|
55
55
|
* misconfigurations so it is enabled by default for now.
|
|
56
56
|
*/
|
|
57
57
|
const PARANOID = true;
|
|
58
|
+
/**
|
|
59
|
+
* Starting reference amount, in quote asset base units, for prices derived
|
|
60
|
+
* from estimates when no `referenceAmount` is configured.
|
|
61
|
+
*/
|
|
62
|
+
const MARKET_PRICE_DEFAULT_REFERENCE_AMOUNT = 1000n;
|
|
63
|
+
/**
|
|
64
|
+
* Smallest converted amount, in base asset base units, that a derived
|
|
65
|
+
* price aims for: about six significant digits.
|
|
66
|
+
*/
|
|
67
|
+
const MARKET_PRICE_MINIMUM_CONVERTED_AMOUNT = 1000000n;
|
|
68
|
+
const MARKET_PRICE_SCALE_FACTOR = 1000n;
|
|
69
|
+
/**
|
|
70
|
+
* Up to 1000 * 1000^12 = 10^39 base units, enough for an 18 decimal
|
|
71
|
+
* place quote asset priced in a 0 decimal place base asset.
|
|
72
|
+
*/
|
|
73
|
+
const MARKET_PRICE_MAX_SCALE_STEPS = 12;
|
|
58
74
|
;
|
|
59
75
|
async function formatQuoteSignable(unsignedQuote) {
|
|
60
76
|
const retval = [
|
|
@@ -871,17 +887,38 @@ class BaseKeetaNetFXAnchorHTTPServer extends KeetaAnchorMetadataServer {
|
|
|
871
887
|
if (config.get !== undefined) {
|
|
872
888
|
return (await config.get(request));
|
|
873
889
|
}
|
|
874
|
-
const referenceAmount = config.referenceAmount ?? 1000n;
|
|
875
890
|
const onQuoteError = config.onQuoteError ?? 'omit';
|
|
891
|
+
const estimate = async (quoteAsset, amount) => {
|
|
892
|
+
const rateAndFee = await this.getUnsignedQuoteData({
|
|
893
|
+
from: quoteAsset,
|
|
894
|
+
to: request.base,
|
|
895
|
+
amount: amount.toString(),
|
|
896
|
+
affinity: 'from'
|
|
897
|
+
}, 'estimate');
|
|
898
|
+
return ({ referenceAmount: amount, convertedAmount: rateAndFee.convertedAmount });
|
|
899
|
+
};
|
|
876
900
|
const quoteAssetEntries = await Promise.all(request.quoteAssets.map(async (quoteAsset) => {
|
|
877
|
-
let
|
|
901
|
+
let sample;
|
|
878
902
|
try {
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
903
|
+
if (config.referenceAmount !== undefined) {
|
|
904
|
+
sample = await estimate(quoteAsset, config.referenceAmount);
|
|
905
|
+
}
|
|
906
|
+
else {
|
|
907
|
+
sample = await estimate(quoteAsset, MARKET_PRICE_DEFAULT_REFERENCE_AMOUNT);
|
|
908
|
+
for (let step = 0; step < MARKET_PRICE_MAX_SCALE_STEPS && sample.convertedAmount < MARKET_PRICE_MINIMUM_CONVERTED_AMOUNT; step++) {
|
|
909
|
+
try {
|
|
910
|
+
sample = await estimate(quoteAsset, sample.referenceAmount * MARKET_PRICE_SCALE_FACTOR);
|
|
911
|
+
}
|
|
912
|
+
catch (error) {
|
|
913
|
+
/*
|
|
914
|
+
* A larger amount can fall outside the
|
|
915
|
+
* provider's limits; keep the last good ratio.
|
|
916
|
+
*/
|
|
917
|
+
this.logger.debug('GET /api/getMarketPrices', `Stopped scaling reference amount for quote asset ${quoteAsset} against base ${request.base}:`, error);
|
|
918
|
+
break;
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
}
|
|
885
922
|
}
|
|
886
923
|
catch (error) {
|
|
887
924
|
this.logger.error('GET /api/getMarketPrices', `Failed to derive price for quote asset ${quoteAsset} against base ${request.base}:`, error);
|
|
@@ -890,8 +927,9 @@ class BaseKeetaNetFXAnchorHTTPServer extends KeetaAnchorMetadataServer {
|
|
|
890
927
|
}
|
|
891
928
|
return (null);
|
|
892
929
|
}
|
|
893
|
-
|
|
894
|
-
|
|
930
|
+
const { referenceAmount, convertedAmount } = sample;
|
|
931
|
+
if (referenceAmount === 0n || convertedAmount === 0n) {
|
|
932
|
+
const error = new Error(`Invalid market price ratio for quote asset ${quoteAsset} against base ${request.base}: quote=${referenceAmount.toString()} base=${convertedAmount.toString()}`);
|
|
895
933
|
this.logger.error('GET /api/getMarketPrices', error.message);
|
|
896
934
|
if (onQuoteError === 'throw') {
|
|
897
935
|
throw (error);
|
|
@@ -901,7 +939,7 @@ class BaseKeetaNetFXAnchorHTTPServer extends KeetaAnchorMetadataServer {
|
|
|
901
939
|
return [quoteAsset, {
|
|
902
940
|
valueRatio: {
|
|
903
941
|
quote: referenceAmount.toString(),
|
|
904
|
-
base:
|
|
942
|
+
base: convertedAmount.toString()
|
|
905
943
|
}
|
|
906
944
|
}];
|
|
907
945
|
}));
|