diff --git a/lazer/evm/lib/pyth-crosschain b/lazer/evm/lib/pyth-crosschain index cc16040..5ef46e4 160000 --- a/lazer/evm/lib/pyth-crosschain +++ b/lazer/evm/lib/pyth-crosschain @@ -1 +1 @@ -Subproject commit cc16040038691a5a5a499661d8de0daba8eed4c3 +Subproject commit 5ef46e4986f22faaddf45b662401178292bb2e57 diff --git a/lazer/evm/src/ExampleReceiver.sol b/lazer/evm/src/ExampleReceiver.sol index efddf0c..6a8b68b 100644 --- a/lazer/evm/src/ExampleReceiver.sol +++ b/lazer/evm/src/ExampleReceiver.sol @@ -9,6 +9,8 @@ contract ExampleReceiver { PythLazer pythLazer; uint64 public price; uint64 public timestamp; + int16 public exponent; + uint16 public publisher_count; constructor(address pythLazerAddress) { pythLazer = PythLazer(pythLazerAddress); @@ -43,7 +45,7 @@ contract ExampleReceiver { uint64 _price; (_price, pos) = PythLazerLib.parseFeedValueUint64(payload, pos); console.log("price %d", _price); - if (feedId == 2 && _timestamp > timestamp) { + if (feedId == 6 && _timestamp > timestamp) { price = _price; timestamp = _timestamp; } @@ -55,6 +57,16 @@ contract ExampleReceiver { uint64 _price; (_price, pos) = PythLazerLib.parseFeedValueUint64(payload, pos); console.log("best ask price %d", _price); + } else if (property == PythLazerLib.PriceFeedProperty.Exponent) { + int16 _exponent; + (_exponent, pos) = PythLazerLib.parseFeedValueInt16(payload, pos); + console.log("exponent %d", _exponent); + exponent = _exponent; + } else if (property == PythLazerLib.PriceFeedProperty.PublisherCount) { + uint16 _publisher_count; + (_publisher_count, pos) = PythLazerLib.parseFeedValueUint16(payload, pos); + console.log("publisher count %d", _publisher_count); + publisher_count = _publisher_count; } else { revert("unknown property"); } diff --git a/lazer/evm/test/ExampleReceiver.t.sol b/lazer/evm/test/ExampleReceiver.t.sol index a643c2d..dbe2587 100644 --- a/lazer/evm/test/ExampleReceiver.t.sol +++ b/lazer/evm/test/ExampleReceiver.t.sol @@ -9,7 +9,7 @@ contract ExampleReceiverTest is Test { function setUp() public {} function test_1() public { - address trustedSigner = 0xEfEf56cD66896f6799A90A4e4d512C330c094e44; + address trustedSigner = 0xb8d50f0bAE75BF6E03c104903d7C3aFc4a6596Da; console.log("trustedSigner %s", trustedSigner); address lazer = makeAddr("lazer"); @@ -25,14 +25,16 @@ contract ExampleReceiverTest is Test { ExampleReceiver receiver = new ExampleReceiver(address(pythLazer)); bytes memory update = - hex"2a22999a577d3cc0202197939d736bc0dcf71b9dde7b9470e4d16fa8e2120c0787a1c0d744d0c39cc372af4d1ecf2d09e84160ca905f3f597d20e2eec144a446a0459ad600001c93c7d3750006240af373971c01010000000201000000000005f5e100"; + hex"2a22999a9ee4e2a3df5affd0ad8c7c46c96d3b5ef197dd653bedd8f44a4b6b69b767fbc66341e80b80acb09ead98c60d169b9a99657ebada101f447378f227bffbc69d3d01003493c7d37500062cf28659c1e801010000000605000000000005f5e10002000000000000000001000000000000000003000104fff8"; console.logBytes(update); vm.prank(consumer); receiver.updatePrice{value: 5 * fee}(update); + assertEq(receiver.timestamp(), 1738270008001000); assertEq(receiver.price(), 100000000); - assertEq(receiver.timestamp(), 1728479312975644); + assertEq(receiver.exponent(), -8); + assertEq(receiver.publisher_count(), 1); assertEq(address(pythLazer).balance, fee); assertEq(address(receiver).balance, 0);