Skip to content

Commit 95a6c7b

Browse files
committed
update
1 parent 2779982 commit 95a6c7b

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

target_chains/ethereum/contracts/forge-test/utils/PythTestUtils.t.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,22 +403,22 @@ contract PythUtilsTest is Test, WormholeTestUtils, PythTestUtils, IPythEvents {
403403
function testCombinePrices() public {
404404
// Test case 1: Basic price combination (ETH/USD / BTC/USD = ETH/BTC)
405405
PythStructs.Price memory ethUsd = PythStructs.Price({
406-
price: 99875005,
406+
price: 206487956502,
407407
conf: 10,
408408
expo: -8,
409409
publishTime: block.timestamp
410410
});
411411

412412
PythStructs.Price memory btcUsd = PythStructs.Price({
413-
price: 206362333702,
413+
price: 206741615681,
414414
conf: 100,
415415
expo: -8,
416416
publishTime: block.timestamp
417417
});
418418

419419
(int64 price, int32 expo) = PythUtils.combinePrices(ethUsd, btcUsd);
420-
assertApproxEqRel(price, 2016367433623696, 9e17);
421-
assertEq(expo, -18);
420+
assertApproxEqRel(price, 99875203, 9e17);
421+
assertEq(expo, -8);
422422

423423
// // Test case 2: Different exponents
424424
// PythStructs.Price memory smallPrice = PythStructs.Price({

target_chains/ethereum/sdk/solidity/PythUtils.sol

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,17 @@ library PythUtils {
6666
console.log("p1", p1);
6767
console.log("p2", p2);
6868

69-
7069
// Calculate the combined price
7170
uint256 combined = (p1 * 10**18) / p2; // Multiply by 10^18 to maintain precision
7271
console.log("combined", combined);
7372
// Calculate the new exponent
74-
int32 newExpo = -18;
75-
console.log("newExpo", newExpo);
73+
combined = combined / 10 ** (18 - p1Decimals);
74+
console.log("newExpo", p1Decimals);
7675
// Check if the combined price fits in int64
7776
if (combined > uint256(uint64(type(int64).max))) {
7877
revert();
7978
}
8079

81-
return (int64(uint64(combined)), newExpo);
80+
return (int64(uint64(combined)), price1.expo);
8281
}
8382
}

0 commit comments

Comments
 (0)