Skip to content

Commit

Permalink
move cloneVaultId to refund _register
Browse files Browse the repository at this point in the history
  • Loading branch information
YouStillAlive committed Dec 20, 2023
1 parent 688a57e commit 6862aeb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions contracts/AdvancedProviders/RefundProvider/RefundProvider.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ contract RefundProvider is RefundState, IERC721Receiver {
tokenSignature
);
provider.registerPool(dataPoolID, params);
// clone token data to refund poolId
lockDealNFT.cloneVaultId(poolId, dataPoolID);

// Hold main coin | Project Owner
uint256 collateralPoolId = lockDealNFT.safeMintAndTransfer(
Expand Down Expand Up @@ -98,6 +96,9 @@ contract RefundProvider is RefundState, IERC721Receiver {
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 @@ -106,9 +107,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
4 changes: 2 additions & 2 deletions test/Builder/SimpleRefundBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('Simple Refund Builder tests', function () {
const tokenVaultId = vaultId + 1;
vaultId += 1;
await Promise.all([
_checkRefundProviderData(poolId, poolId + 1, await userData.userPools[0].user , constants.AddressZero, 0),
_checkRefundProviderData(poolId, poolId + 1, await userData.userPools[0].user, token, tokenVaultId),
_checkSimpleProviderData(provider, name, poolId + 1, params[1], tokenVaultId),
_checkCollateralData(collateralId)
])
Expand All @@ -66,7 +66,7 @@ describe('Simple Refund Builder tests', function () {

const allChecks = poolIdsAndUsers.map( async (i) => {
return Promise.all([
_checkRefundProviderData(i.poolId, i.poolId + 1, await userData.userPools[i.user].user , constants.AddressZero, 0),
_checkRefundProviderData(i.poolId, i.poolId + 1, await userData.userPools[i.user].user, token, tokenVaultId),
_checkSimpleProviderData(provider, name, i.poolId + 1, params[1], tokenVaultId),
])
})
Expand Down

0 comments on commit 6862aeb

Please sign in to comment.