Skip to content

Commit 7cc2996

Browse files
committed
chore: some minor improvements to GraphPayments and tests
Signed-off-by: Tomás Migone <[email protected]>
1 parent 689b6a8 commit 7cc2996

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

Diff for: packages/horizon/contracts/interfaces/IGraphPayments.sol

+2-1
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@ interface IGraphPayments {
5757
/**
5858
* @notice Collects funds from a payer.
5959
* It will pay cuts to all relevant parties and forward the rest to the receiver.
60+
* Note that the collected amount can be zero.
6061
* @param paymentType The type of payment as defined in {IGraphPayments}
6162
* @param receiver The address of the receiver
62-
* @param tokens The amount of tokens being collected
63+
* @param tokens The amount of tokens being collected.
6364
* @param dataService The address of the data service
6465
* @param dataServiceCut The data service cut in PPM
6566
*/

Diff for: packages/horizon/contracts/payments/GraphPayments.sol

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import { GraphDirectory } from "../utilities/GraphDirectory.sol";
2323
contract GraphPayments is Initializable, MulticallUpgradeable, GraphDirectory, IGraphPayments {
2424
using TokenUtils for IGraphToken;
2525
using PPMMath for uint256;
26+
27+
/// @notice Protocol payment cut in PPM
2628
uint256 public immutable PROTOCOL_PAYMENT_CUT;
2729

2830
/**

Diff for: packages/horizon/test/payments/GraphPayments.t.sol

+29
Original file line numberDiff line numberDiff line change
@@ -291,4 +291,33 @@ contract GraphPaymentsTest is HorizonStakingSharedTest {
291291
);
292292
vm.stopPrank();
293293
}
294+
295+
function testCollect_ViaMulticall(uint256 amount) public useIndexer {
296+
amount = bound(amount, 1, MAX_STAKING_TOKENS / 2); // Divide by 2 as we'll make two calls
297+
298+
address escrowAddress = address(escrow);
299+
mint(escrowAddress, amount * 2);
300+
vm.startPrank(escrowAddress);
301+
approve(address(payments), amount * 2);
302+
303+
bytes[] memory data = new bytes[](2);
304+
data[0] = abi.encodeWithSelector(
305+
payments.collect.selector,
306+
IGraphPayments.PaymentTypes.QueryFee,
307+
users.indexer,
308+
amount,
309+
subgraphDataServiceAddress,
310+
100_000 // 10%
311+
);
312+
data[1] = abi.encodeWithSelector(
313+
payments.collect.selector,
314+
IGraphPayments.PaymentTypes.IndexingFee,
315+
users.indexer,
316+
amount,
317+
subgraphDataServiceAddress,
318+
200_000 // 20%
319+
);
320+
321+
payments.multicall(data);
322+
}
294323
}

0 commit comments

Comments
 (0)