|
| 1 | +// SPDX-License-Identifier: Apache 2 |
| 2 | + |
| 3 | +pragma solidity ^0.8.0; |
| 4 | + |
| 5 | +import "./PulseState.sol"; |
| 6 | + |
| 7 | +interface IPulseConsumer { |
| 8 | + function pulseCallback( |
| 9 | + uint64 sequenceNumber, |
| 10 | + address provider, |
| 11 | + uint256 publishTime, |
| 12 | + bytes32[] calldata priceIds |
| 13 | + ) external; |
| 14 | +} |
| 15 | + |
| 16 | +interface IPulse { |
| 17 | + // Events |
| 18 | + event PriceUpdateRequested( |
| 19 | + uint64 indexed sequenceNumber, |
| 20 | + address indexed provider, |
| 21 | + uint256 publishTime, |
| 22 | + bytes32[] priceIds, |
| 23 | + address requester |
| 24 | + ); |
| 25 | + |
| 26 | + event PriceUpdateExecuted( |
| 27 | + uint64 indexed sequenceNumber, |
| 28 | + address indexed provider, |
| 29 | + uint256 publishTime, |
| 30 | + bytes32[] priceIds |
| 31 | + ); |
| 32 | + |
| 33 | + event ProviderRegistered( |
| 34 | + address indexed provider, |
| 35 | + uint128 feeInWei, |
| 36 | + bytes uri |
| 37 | + ); |
| 38 | + |
| 39 | + event ProviderFeeUpdated( |
| 40 | + address indexed provider, |
| 41 | + uint128 oldFeeInWei, |
| 42 | + uint128 newFeeInWei |
| 43 | + ); |
| 44 | + |
| 45 | + event ProviderWithdrawn( |
| 46 | + address indexed provider, |
| 47 | + address indexed recipient, |
| 48 | + uint128 amount |
| 49 | + ); |
| 50 | + |
| 51 | + event ProviderFeeManagerUpdated( |
| 52 | + address indexed provider, |
| 53 | + address oldFeeManager, |
| 54 | + address newFeeManager |
| 55 | + ); |
| 56 | + |
| 57 | + event ProviderUriUpdated( |
| 58 | + address indexed provider, |
| 59 | + bytes oldUri, |
| 60 | + bytes newUri |
| 61 | + ); |
| 62 | + |
| 63 | + event ProviderMaxNumPricesUpdated( |
| 64 | + address indexed provider, |
| 65 | + uint32 oldMaxNumPrices, |
| 66 | + uint32 maxNumPrices |
| 67 | + ); |
| 68 | + |
| 69 | + event PriceUpdateCallbackFailed( |
| 70 | + uint64 indexed sequenceNumber, |
| 71 | + address indexed provider, |
| 72 | + uint256 publishTime, |
| 73 | + bytes32[] priceIds, |
| 74 | + address requester, |
| 75 | + string reason |
| 76 | + ); |
| 77 | + |
| 78 | + // Core functions |
| 79 | + function requestPriceUpdatesWithCallback( |
| 80 | + address provider, |
| 81 | + uint256 publishTime, |
| 82 | + bytes32[] calldata priceIds, |
| 83 | + bytes[] calldata updateData, |
| 84 | + uint256 callbackGasLimit |
| 85 | + ) external payable returns (uint64 sequenceNumber); |
| 86 | + |
| 87 | + function executeCallback( |
| 88 | + uint64 sequenceNumber, |
| 89 | + uint256 publishTime, |
| 90 | + bytes32[] calldata priceIds, |
| 91 | + bytes[] calldata updateData, |
| 92 | + uint256 callbackGasLimit |
| 93 | + ) external; |
| 94 | + |
| 95 | + // Provider management |
| 96 | + function register(uint128 feeInWei, bytes calldata uri) external; |
| 97 | + |
| 98 | + function setProviderFee(uint128 newFeeInWei) external; |
| 99 | + |
| 100 | + function withdraw(uint128 amount) external; |
| 101 | + |
| 102 | + // Add to interface |
| 103 | + function withdrawAsFeeManager(address provider, uint128 amount) external; |
| 104 | + |
| 105 | + // Add to Provider management section |
| 106 | + function setProviderUri(bytes calldata uri) external; |
| 107 | + |
| 108 | + // Getters |
| 109 | + function getFee(address provider) external view returns (uint128 feeAmount); |
| 110 | + |
| 111 | + function getDefaultProvider() external view returns (address); |
| 112 | + |
| 113 | + // Add to interface |
| 114 | + function setFeeManager(address manager) external; |
| 115 | + |
| 116 | + // Add to interface |
| 117 | + function setProviderFeeAsFeeManager( |
| 118 | + address provider, |
| 119 | + uint128 newFeeInWei |
| 120 | + ) external; |
| 121 | + |
| 122 | + // Add to Getters section |
| 123 | + function getAccruedPythFees() |
| 124 | + external |
| 125 | + view |
| 126 | + returns (uint128 accruedPythFeesInWei); |
| 127 | + |
| 128 | + // Add to Getters section |
| 129 | + function getProviderInfo( |
| 130 | + address provider |
| 131 | + ) external view returns (PulseState.ProviderInfo memory info); |
| 132 | + |
| 133 | + function getAdmin() external view returns (address admin); |
| 134 | + |
| 135 | + function getPythFeeInWei() external view returns (uint128 pythFeeInWei); |
| 136 | + |
| 137 | + function setMaxNumPrices(uint32 maxNumPrices) external; |
| 138 | + |
| 139 | + // Add to Getters section |
| 140 | + function getRequest( |
| 141 | + address provider, |
| 142 | + uint64 sequenceNumber |
| 143 | + ) external view returns (PulseState.Request memory req); |
| 144 | +} |
0 commit comments