Skip to content

Commit

Permalink
reduce policy and pool services size
Browse files Browse the repository at this point in the history
  • Loading branch information
rapidddenis committed Sep 6, 2024
1 parent c0f9c5d commit 8541e5d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
3 changes: 0 additions & 3 deletions contracts/pool/IPoolService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ interface IPoolService is IService {
event LogPoolServiceWalletFunded(NftId poolNftId, address poolOwner, Amount amount);
event LogPoolServiceWalletDefunded(NftId poolNftId, address poolOwner, Amount amount);

event LogPoolServiceBundleCreated(NftId instanceNftId, NftId poolNftId, NftId bundleNftId);
event LogPoolServiceBundleClosed(NftId instanceNftId, NftId poolNftId, NftId bundleNftId);

event LogPoolServiceBundleStaked(NftId instanceNftId, NftId poolNftId, NftId bundleNftId, Amount amount, Amount netAmount);
Expand All @@ -36,8 +35,6 @@ interface IPoolService is IService {

error ErrorPoolServicePoolNotExternallyManaged(NftId poolNftId);
error ErrorPoolServicePolicyPoolMismatch(NftId policyNftId, NftId productNftId, NftId expectedProductNftId);
error ErrorPoolServiceBundleOwnerRoleAlreadySet(NftId poolNftId);
error ErrorPoolServiceInvalidTransferAmount(Amount expectedAmount, Amount actualAmount);
error ErrorPoolServiceBundlePoolMismatch(NftId bundleNftId, NftId poolNftId);
error ErrorPoolServiceMaxBalanceAmountExceeded(NftId poolNftId, Amount maxBalanceAmount, Amount currentBalanceAmount, Amount transferAmount);
error ErrorPoolServiceFeesWithdrawAmountExceedsLimit(Amount amount, Amount limit);
Expand Down
6 changes: 3 additions & 3 deletions contracts/pool/PoolService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,13 @@ contract PoolService is
(NftId poolNftId, IInstance instance) = _getAndVerifyActivePool();
InstanceReader instanceReader = instance.getInstanceReader();
NftId productNftId = getRegistry().getParentNftId(poolNftId);
NftId policyProductNftId = getRegistry().getParentNftId(policyNftId);

// check policy matches with calling pool
IPolicy.PolicyInfo memory policyInfo = instanceReader.getPolicyInfo(policyNftId);
if(policyInfo.productNftId != productNftId) {
if(policyProductNftId != productNftId) {
revert ErrorPoolServicePolicyPoolMismatch(
policyNftId,
policyInfo.productNftId,
policyProductNftId,
productNftId);
}

Expand Down
14 changes: 8 additions & 6 deletions contracts/product/PolicyService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ contract PolicyService is
(IInstance instance,,) = _getAndVerifyCallerForPolicy(applicationNftId);

// check policy is in state applied
if (instance.getInstanceReader().getPolicyState(applicationNftId) != APPLIED()) {
revert ErrorPolicyServicePolicyStateNotApplied(applicationNftId);
}
// commented to reduce contract size, the only "APPLIED -> DECLINED" transition exists
//if (instance.getInstanceReader().getPolicyState(applicationNftId) != APPLIED()) {
// revert ErrorPolicyServicePolicyStateNotApplied(applicationNftId);
//}

// effects
// store updated policy info
Expand Down Expand Up @@ -117,10 +118,11 @@ contract PolicyService is
) = _getAndVerifyCallerForPolicy(applicationNftId);

// check policy is in state applied
// commented to reduce contract size, the only "APPLIED -> COLLATERALIZED" transition exists
InstanceReader instanceReader = instance.getInstanceReader();
if (instanceReader.getPolicyState(applicationNftId) != APPLIED()) {
revert ErrorPolicyServicePolicyStateNotApplied(applicationNftId);
}
//if (instanceReader.getPolicyState(applicationNftId) != APPLIED()) {
// revert ErrorPolicyServicePolicyStateNotApplied(applicationNftId);
//}

PolicyServiceStorage storage $ = _getPolicyServiceStorage();

Expand Down
2 changes: 1 addition & 1 deletion contracts/staking/Staking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ contract Staking is
}

StakingStorage storage $ = _getStakingStorage();
address dipToken = _getStakingStorage()._tokenRegistry.getDipTokenAddress();
address dipToken = $._tokenRegistry.getDipTokenAddress();
$._tokenHandler = TokenHandlerDeployerLib.deployTokenHandler(
address(getRegistry()),
address(this),
Expand Down

0 comments on commit 8541e5d

Please sign in to comment.