Browse Source

add API option to return inverse price (#61)

mempow-testing
QuickMythril 3 years ago committed by GitHub
parent
commit
55c50a4b5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      src/main/java/org/qortal/api/resource/CrossChainResource.java

9
src/main/java/org/qortal/api/resource/CrossChainResource.java

@ -264,7 +264,12 @@ public class CrossChainResource {
description = "Maximum number of trades to include in price calculation",
example = "10",
schema = @Schema(type = "integer", defaultValue = "10")
) @QueryParam("maxtrades") Integer maxtrades) {
) @QueryParam("maxtrades") Integer maxtrades,
@Parameter(
description = "Display price in terms of foreign currency per unit QORT",
example = "false",
schema = @Schema(type = "boolean", defaultValue = "false")
) @QueryParam("inverse") Boolean inverse) {
// foreignBlockchain is required
if (foreignBlockchain == null)
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_CRITERIA);
@ -295,7 +300,7 @@ public class CrossChainResource {
}
}
return Amounts.scaledDivide(totalQort, totalForeign);
return inverse ? Amounts.scaledDivide(totalForeign, totalQort) : Amounts.scaledDivide(totalQort, totalForeign);
} catch (DataException e) {
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.REPOSITORY_ISSUE, e);
}

Loading…
Cancel
Save