forked from Qortal/qortal
add API option to return inverse price (#61)
This commit is contained in:
parent
1fbd5f7922
commit
55c50a4b5b
@ -264,7 +264,12 @@ public class CrossChainResource {
|
|||||||
description = "Maximum number of trades to include in price calculation",
|
description = "Maximum number of trades to include in price calculation",
|
||||||
example = "10",
|
example = "10",
|
||||||
schema = @Schema(type = "integer", defaultValue = "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
|
// foreignBlockchain is required
|
||||||
if (foreignBlockchain == null)
|
if (foreignBlockchain == null)
|
||||||
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_CRITERIA);
|
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) {
|
} catch (DataException e) {
|
||||||
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.REPOSITORY_ISSUE, e);
|
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.REPOSITORY_ISSUE, e);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user