@dhedge/backend-flatcoin-core 0.2.96 → 0.2.98
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.
|
@@ -33,7 +33,7 @@ let AvgDepositPriceService = class AvgDepositPriceService {
|
|
|
33
33
|
let potentialEthAmountHeldTotal;
|
|
34
34
|
let avgDepositPrice;
|
|
35
35
|
if (leverageOpen) {
|
|
36
|
-
const ethPriceAtDepositBlock = await this.blockchainPriceService.getUsdPriceAtBlock(this.ethAddress, leverageOpen.blockNumber);
|
|
36
|
+
const ethPriceAtDepositBlock = await this.blockchainPriceService.getUsdPriceAtBlock(this.ethAddress, +leverageOpen.blockNumber);
|
|
37
37
|
const potentialEthAmountReceived = ethers_1.BigNumber.from(leverageOpen.margin)
|
|
38
38
|
.mul(ethers_1.BigNumber.from(leverageOpen.entryPrice))
|
|
39
39
|
.div(ethPriceAtDepositBlock);
|
|
@@ -46,7 +46,7 @@ let AvgDepositPriceService = class AvgDepositPriceService {
|
|
|
46
46
|
for (const leverageAdjust of leverageAdjusts) {
|
|
47
47
|
const marginDelta = ethers_1.BigNumber.from(leverageAdjust.marginDelta);
|
|
48
48
|
if (marginDelta.gt(ethers_1.BigNumber.from(0))) {
|
|
49
|
-
const ethPriceAtDepositBlock = await this.blockchainPriceService.getUsdPriceAtBlock(this.ethAddress, leverageAdjust.blockNumber);
|
|
49
|
+
const ethPriceAtDepositBlock = await this.blockchainPriceService.getUsdPriceAtBlock(this.ethAddress, +leverageAdjust.blockNumber);
|
|
50
50
|
const potentialEthAmountReceived = marginDelta
|
|
51
51
|
.mul(ethers_1.BigNumber.from(leverageAdjust.adjustPrice))
|
|
52
52
|
.div(ethPriceAtDepositBlock);
|
|
@@ -33,7 +33,7 @@ let BlockchainPriceService = class BlockchainPriceService {
|
|
|
33
33
|
}
|
|
34
34
|
async getUsdPriceAtBlock(assetAddress, blockNumber) {
|
|
35
35
|
try {
|
|
36
|
-
return (await this.getUsdPriceAtBlockUnformatted(assetAddress, blockNumber)).mul(ethers_1.BigNumber.from('10000000000'));
|
|
36
|
+
return (await this.getUsdPriceAtBlockUnformatted(assetAddress, blockNumber)).price.price.mul(ethers_1.BigNumber.from('10000000000'));
|
|
37
37
|
}
|
|
38
38
|
catch (err) {
|
|
39
39
|
this.logger.error(`Error calling getUSDPrice with asset address ${assetAddress}:`, err);
|
|
@@ -42,9 +42,11 @@ let BlockchainPriceService = class BlockchainPriceService {
|
|
|
42
42
|
}
|
|
43
43
|
async getUsdPriceAtBlockUnformatted(assetAddress, blockNumber) {
|
|
44
44
|
try {
|
|
45
|
-
|
|
45
|
+
const priceResponse = await this.assetHandlerContract.callStatic['queryPriceFeed'](assetAddress, {
|
|
46
46
|
blockTag: blockNumber,
|
|
47
47
|
});
|
|
48
|
+
this.logger.log('priceResponse:', priceResponse);
|
|
49
|
+
return priceResponse;
|
|
48
50
|
}
|
|
49
51
|
catch (err) {
|
|
50
52
|
this.logger.error(`Error calling getUSDPrice with asset address ${assetAddress}:`, err);
|