Skip to content

Commit

Permalink
Make per byte fee dependent on destination
Browse files Browse the repository at this point in the history
  • Loading branch information
seunlanlege committed Oct 12, 2024
1 parent 4e82eff commit 3b6a835
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
5 changes: 3 additions & 2 deletions interfaces/IDispatcher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,14 @@ interface IDispatcher {
function feeToken() external view returns (address);

/**
* @dev Returns the address of the per byte fee configured for this state machine.
* @dev Returns the address of the per byte fee configured for the destination state machine.
*
* @notice Hyperbridge collects it's dispatch fees per every byte of the outgoing message.
*
* @param dest - The destination chain for the per byte fee.
* @return perByteFee - The per byte fee for outgoing messages.
*/
function perByteFee() external view returns (uint256);
function perByteFee(bytes memory dest) external view returns (uint256);

/**
* @dev Dispatch a POST request to Hyperbridge
Expand Down
9 changes: 2 additions & 7 deletions interfaces/IIsmpModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,12 @@ abstract contract BaseIsmpModule is IIsmpModule {

// @dev returns the quoted fee for a dispatch
function quote(DispatchPost memory post) public view returns (uint256) {
return post.fee + (post.body.length * IDispatcher(host()).perByteFee());
return post.fee + (post.body.length * IDispatcher(host()).perByteFee(post.dest));
}

// @dev returns the quoted fee for a dispatch
function quote(DispatchPostResponse memory res) public view returns (uint256) {
return res.fee + (res.response.length * IDispatcher(host()).perByteFee());
}

// @dev returns the quoted fee for a dispatch
function quote(DispatchGet memory get) public view returns (uint256) {
return get.fee + (get.context.length * IDispatcher(host()).perByteFee());
return res.fee + (res.response.length * IDispatcher(host()).perByteFee(res.request.source));
}

function onAccept(IncomingPostRequest calldata) external virtual onlyHost {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@polytope-labs/ismp-solidity",
"version": "0.7.2",
"version": "0.7.3",
"description": "Hyperbridge Solidity SDK for the Interoperable state machine protocol",
"author": "Polytope Labs <[email protected]>",
"license": "Apache-2.0",
Expand Down

0 comments on commit 3b6a835

Please sign in to comment.