@@ -15,6 +15,7 @@ import { Allocation } from "../libraries/Allocation.sol";
1515import { LegacyAllocation } from "../libraries/LegacyAllocation.sol " ;
1616import { PPMMath } from "@graphprotocol/horizon/contracts/libraries/PPMMath.sol " ;
1717import { ProvisionTracker } from "@graphprotocol/horizon/contracts/data-service/libraries/ProvisionTracker.sol " ;
18+ import { AllocationManagerLib } from "../libraries/AllocationManagerLib.sol " ;
1819
1920/**
2021 * @title AllocationManager contract
@@ -204,34 +205,53 @@ abstract contract AllocationManager is EIP712Upgradeable, GraphDirectory, Alloca
204205 bytes memory _allocationProof ,
205206 uint32 _delegationRatio
206207 ) internal {
207- require (_allocationId != address (0 ), AllocationManagerInvalidZeroAllocationId ());
208-
209- _verifyAllocationProof (_indexer, _allocationId, _allocationProof);
210-
211- // Ensure allocation id is not reused
212- // need to check both subgraph service (on allocations.create()) and legacy allocations
213- _legacyAllocations.revertIfExists (_graphStaking (), _allocationId);
214-
215- uint256 currentEpoch = _graphEpochManager ().currentEpoch ();
216- Allocation.State memory allocation = _allocations.create (
217- _indexer,
218- _allocationId,
219- _subgraphDeploymentId,
220- _tokens,
221- _graphRewardsManager ().onSubgraphAllocationUpdate (_subgraphDeploymentId),
222- currentEpoch
208+ // require(_allocationId != address(0), AllocationManagerInvalidZeroAllocationId());
209+
210+ // _verifyAllocationProof(_indexer, _allocationId, _allocationProof);
211+
212+ // // Ensure allocation id is not reused
213+ // // need to check both subgraph service (on allocations.create()) and legacy allocations
214+ // _legacyAllocations.revertIfExists(_graphStaking(), _allocationId);
215+
216+ // uint256 currentEpoch = _graphEpochManager().currentEpoch();
217+ // Allocation.State memory allocation = _allocations.create(
218+ // _indexer,
219+ // _allocationId,
220+ // _subgraphDeploymentId,
221+ // _tokens,
222+ // _graphRewardsManager().onSubgraphAllocationUpdate(_subgraphDeploymentId),
223+ // currentEpoch
224+ // );
225+
226+ // // Check that the indexer has enough tokens available
227+ // // Note that the delegation ratio ensures overdelegation cannot be used
228+ // allocationProvisionTracker.lock(_graphStaking(), _indexer, _tokens, _delegationRatio);
229+
230+ // // Update total allocated tokens for the subgraph deployment
231+ // _subgraphAllocatedTokens[allocation.subgraphDeploymentId] =
232+ // _subgraphAllocatedTokens[allocation.subgraphDeploymentId] +
233+ // allocation.tokens;
234+
235+ // emit AllocationCreated(_indexer, _allocationId, _subgraphDeploymentId, allocation.tokens, currentEpoch);
236+
237+ AllocationManagerLib.allocate (
238+ _allocations,
239+ _legacyAllocations,
240+ allocationProvisionTracker,
241+ _subgraphAllocatedTokens,
242+ AllocationManagerLib.AllocateParams ({
243+ _allocationId: _allocationId,
244+ _allocationProof: _allocationProof,
245+ _encodeAllocationProof: _encodeAllocationProof (_indexer, _allocationId),
246+ _delegationRatio: _delegationRatio,
247+ _indexer: _indexer,
248+ _subgraphDeploymentId: _subgraphDeploymentId,
249+ _tokens: _tokens,
250+ currentEpoch: _graphEpochManager ().currentEpoch (),
251+ graphRewardsManager: _graphRewardsManager (),
252+ graphStaking: _graphStaking ()
253+ })
223254 );
224-
225- // Check that the indexer has enough tokens available
226- // Note that the delegation ratio ensures overdelegation cannot be used
227- allocationProvisionTracker.lock (_graphStaking (), _indexer, _tokens, _delegationRatio);
228-
229- // Update total allocated tokens for the subgraph deployment
230- _subgraphAllocatedTokens[allocation.subgraphDeploymentId] =
231- _subgraphAllocatedTokens[allocation.subgraphDeploymentId] +
232- allocation.tokens;
233-
234- emit AllocationCreated (_indexer, _allocationId, _subgraphDeploymentId, allocation.tokens, currentEpoch);
235255 }
236256
237257 /**
0 commit comments