Skip to content

Commit

Permalink
fix: change staking interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Maikol committed Apr 19, 2024
1 parent 9b6ed9b commit 76539f7
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/contracts/contracts/staking/IHorizonStaking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,5 @@ interface IHorizonStaking {

function getProvision(bytes32 provision) external view returns (Provision memory);

function getDelegatorCut(address serviceProvider, uint256256 paymentType) external returns (address, uint256);
function getDelegatorCut(address serviceProvider, uint256 paymentType) external returns (uint256 delegatorCut);
}
6 changes: 4 additions & 2 deletions packages/horizon/contracts/GraphPayments.sol
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,11 @@ contract GraphPayments is IGraphPayments, GraphPaymentsStorageV1Storage, GraphDi
graphToken.transfer(msg.sender, dataServicePayment);

// Get delegation cut
(address delegatorAddress, uint256 delegatorCut) = graphStaking.getDelegatorCut(receiver, uint256(paymentType));
uint256 delegatorCut = graphStaking.getDelegatorCut(receiver, uint256(paymentType));
uint256 delegatorPayment = (amount * delegatorCut) / MAX_PPM;
graphToken.transfer(delegatorAddress, delegatorPayment);
// TODO: Add to delegation pool
// graphStaking.addToDelegationPool(receiver, delegatorPayment);
graphToken.burn(delegatorPayment);

// Pay the rest to the receiver
uint256 receiverPayment = amount - protocolCut - dataServicePayment - delegatorPayment;
Expand Down
2 changes: 1 addition & 1 deletion packages/horizon/contracts/interfaces/IGraphPayments.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface IGraphPayments {
QueryFees
}

// Authorized collector
// Collector
struct Collector {
bool authorized;
uint256 thawEndTimestamp;
Expand Down
3 changes: 1 addition & 2 deletions packages/horizon/test/GraphDeployments.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ contract GraphDeployments is Test {

// Staking parameters

address public delegatorAddress = address(0xbdC1c9f94A729E47d6877217eC995916EAD457B7);
uint256 public delegatorCut = 50000; // 5%

// Setup
Expand Down Expand Up @@ -62,7 +61,7 @@ contract GraphDeployments is Test {

// HorizonStaking
vm.prank(deployer);
staking = new MockHorizonStaking(delegatorAddress, delegatorCut);
staking = new MockHorizonStaking(delegatorCut);

// Setup controller
vm.startPrank(governor);
Expand Down
11 changes: 3 additions & 8 deletions packages/horizon/test/GraphPayments.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ contract GraphPaymentsTest is Test {
uint256 revokeCollectorThawingPeriod;
uint256 protocolPaymentCut;

address delegatorAddress;
uint256 delegatorCut;

address sender;
address dataService;

Expand All @@ -44,9 +41,6 @@ contract GraphPaymentsTest is Test {
revokeCollectorThawingPeriod = deployments.revokeCollectorThawingPeriod();
protocolPaymentCut = deployments.protocolPaymentCut();

delegatorAddress = deployments.delegatorAddress();
delegatorCut = deployments.delegatorCut();

sender = address(0xA1);
dataService = address(0xA2);
}
Expand Down Expand Up @@ -127,7 +121,8 @@ contract GraphPaymentsTest is Test {
uint256 dataServiceBalance = token.balanceOf(dataService);
assertEq(dataServiceBalance, 30 ether);

uint256 delegatorBalance = token.balanceOf(delegatorAddress);
assertEq(delegatorBalance, 50 ether);
// TODO: test delegator cut payment
// uint256 delegatorBalance = token.balanceOf(delegationPool);
// assertEq(delegatorBalance, 50 ether);
}
}
8 changes: 3 additions & 5 deletions packages/horizon/test/mocks/MockHorizonStaking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ import { IHorizonStaking } from "@graphprotocol/contracts/contracts/staking/IHor
import { MockGRTToken } from "./MockGRTToken.sol";

contract MockHorizonStaking is IHorizonStaking {
address public delegatorAddress;
uint256 public delegatorCut;

constructor(address _delegatorAddress, uint256 _delegatorCut) {
delegatorAddress = _delegatorAddress;
constructor(uint256 _delegatorCut) {
delegatorCut = _delegatorCut;
}

Expand All @@ -37,7 +35,7 @@ contract MockHorizonStaking is IHorizonStaking {
function getServiceProvider(address serviceProvider) external view returns (ServiceProvider memory) {}
function getProvision(bytes32 provision) external view returns (Provision memory) {}

function getDelegatorCut(address serviceProvider, uint256 paymentType) external returns (address, uint256) {
return (delegatorAddress, delegatorCut);
function getDelegatorCut(address serviceProvider, uint256 paymentType) external returns (uint256) {
return delegatorCut;
}
}

0 comments on commit 76539f7

Please sign in to comment.