Skip to content

Commit

Permalink
avoid duplicating split clones
Browse files Browse the repository at this point in the history
  • Loading branch information
YouStillAlive committed Dec 20, 2023
1 parent a0f5162 commit 2916ef9
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions contracts/AdvancedProviders/RefundProvider/RefundProvider.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ contract RefundProvider is RefundState, IERC721Receiver {
tokenSignature
);
provider.registerPool(dataPoolID, params);
// clone token data to refund poolId
lockDealNFT.cloneVaultId(poolId, poolId + 1);

// Hold main coin | Project Owner
uint256 collateralPoolId = lockDealNFT.safeMintAndTransfer(
Expand All @@ -90,15 +92,15 @@ contract RefundProvider is RefundState, IERC721Receiver {
) public override onlyProvider validProviderId(poolId) validProviderAssociation(params[0], collateralProvider) {
require(lockDealNFT.ownerOf(poolId + 1) == address(this), "Must Own poolId+1");
_registerPool(poolId, params);

// clone token data to refund poolId
lockDealNFT.cloneVaultId(poolId, poolId + 1);
}

function _registerPool(
uint256 poolId,
uint256[] memory params
) internal validParamsLength(params.length, currentParamsTargetLenght()) {
// clone token data to refund poolId
lockDealNFT.cloneVaultId(poolId, poolId + 1);

poolIdToCollateralId[poolId] = params[0];
emit UpdateParams(poolId, params);
}
Expand All @@ -107,9 +109,9 @@ contract RefundProvider is RefundState, IERC721Receiver {
function split(uint256 poolId, uint256 newPoolId, uint256 ratio) external onlyNFT {
uint256[] memory params = new uint256[](currentParamsTargetLenght());
params[0] = poolIdToCollateralId[poolId];
_registerPool(newPoolId, params);
uint256 userPoolId = poolId + 1;
lockDealNFT.safeTransferFrom(address(this), address(lockDealNFT), userPoolId, abi.encode(ratio));
_registerPool(newPoolId, params);
}

///@dev user withdraws his tokens
Expand Down

0 comments on commit 2916ef9

Please sign in to comment.