@hyperbridge/core 1.4.0 → 1.5.1
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.
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// Copyright (C) Polytope Labs Ltd.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
// you may not use this file except in compliance with the License.
|
|
6
|
+
// You may obtain a copy of the License at
|
|
7
|
+
//
|
|
8
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//
|
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
// See the License for the specific language governing permissions and
|
|
14
|
+
// limitations under the License.
|
|
15
|
+
pragma solidity ^0.8.24;
|
|
16
|
+
|
|
17
|
+
import {TokenInfo} from "./IntentGatewayV2.sol";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @title IIntentPriceOracle
|
|
21
|
+
* @author Polytope Labs (hello@polytope.technology)
|
|
22
|
+
* @notice Interface for tracking cumulative weighted average spreads for same-token swaps
|
|
23
|
+
* @dev Only supports same-token swaps across chains
|
|
24
|
+
*/
|
|
25
|
+
interface IIntentPriceOracle {
|
|
26
|
+
/**
|
|
27
|
+
* @notice Event emitted when spread is recorded for a filled order
|
|
28
|
+
* @param commitment The order commitment hash
|
|
29
|
+
* @param destinationToken The destination token address
|
|
30
|
+
* @param spreadBps The spread in basis points
|
|
31
|
+
*/
|
|
32
|
+
event SpreadRecorded(bytes32 indexed commitment, address indexed destinationToken, int256 spreadBps);
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @notice Event emitted when token decimals are updated
|
|
36
|
+
* @param sourceChain The source chain state machine ID
|
|
37
|
+
* @param token The token address
|
|
38
|
+
* @param decimals The number of decimals
|
|
39
|
+
*/
|
|
40
|
+
event TokenDecimalsUpdated(bytes sourceChain, address indexed token, uint8 decimals);
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @notice Records the spread for a filled order and computes weighted average
|
|
44
|
+
* @param commitment The order commitment hash
|
|
45
|
+
* @param sourceChain The source chain identifier (bytes format)
|
|
46
|
+
* @param inputs The input tokens that were escrowed
|
|
47
|
+
* @param outputs The output tokens provided by the filler (actual amounts)
|
|
48
|
+
*/
|
|
49
|
+
function recordSpread(
|
|
50
|
+
bytes32 commitment,
|
|
51
|
+
bytes memory sourceChain,
|
|
52
|
+
TokenInfo[] calldata inputs,
|
|
53
|
+
TokenInfo[] calldata outputs
|
|
54
|
+
) external;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @notice Gets the decimals for a token on a specific source chain
|
|
58
|
+
* @param sourceChain The source chain identifier
|
|
59
|
+
* @param token The token address
|
|
60
|
+
* @return decimals The number of decimals (defaults to 18 if not set)
|
|
61
|
+
*/
|
|
62
|
+
function decimals(bytes memory sourceChain, address token) external view returns (uint8 decimals);
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @notice Gets the cumulative weighted average spread data for a token on a source chain
|
|
66
|
+
* @param sourceChain The source chain identifier
|
|
67
|
+
* @param token The token address
|
|
68
|
+
* @return data The cumulative spread data
|
|
69
|
+
*/
|
|
70
|
+
function spread(bytes memory sourceChain, address token) external view returns (int256 data);
|
|
71
|
+
}
|
package/package.json
CHANGED