The ForceWithdraw contract provides an emergency mechanism for forcibly withdrawing tokens from a locked deal pool
. The contract allows the owner to create a new pool, withdraw an NFT representing the locked assets, and transfer the associated tokens to a designated receiver.
Install the packages:
npm i
Compile contracts:
npx hardhat compile
Run tests:
npx hardhat test
Run coverage:
npx hardhat coverage
Deploy:
npx truffle dashboard
npx hardhat run ./scripts/deploy.ts --network truffleDashboard
If NFT tokens are not closed at the correct time, the ForceWithdraw contract can be used to resolve the issue. This is especially relevant for the Veritas project, where adjustments were required to align with the updated Token Generation Event (TGE) timeline.
For more detailed information on the Veritas project and this use case, refer to the Veritas project document.
- Force Withdrawal: Allows the contract owner to forcibly withdraw tokens from a locked deal pool.
- NFT Interaction: Manages NFT-based deal locks by transferring and modifying their status.
- Token Transfer: Ensures secure token transfers using OpenZeppelin's
SafeERC20
. - Ownership Control: Returns vault ownership back to the original owner after execution.
- OpenZeppelin Contracts
Ownable.sol
: Provides ownership control mechanisms.SafeERC20.sol
: Ensures secure token transfers.ERC721Holder.sol
: Enables handling of ERC721 tokens.
- Poolz Finance
ISimpleProvider.sol
: Interface for dealing with Poolz's provider contracts.IExtendLockDealNFT.sol
: Manages locked deal NFTs.IExtendVaultManager.sol
: Handles vault-related operations.
constructor(
IExtendLockDealNFT _lockDealNFT,
ISimpleProvider _dealProvider,
uint256 _sourcePoolId
)
_lockDealNFT
: Address of the LockDealNFT contract._dealProvider
: Address of the deal provider._sourcePoolId
: ID of the source pool from which token data will be cloned.
lockDealNFT
: Reference to the LockDealNFT contract.vaultManager
: Extracts vault manager fromlockDealNFT
.dealProvider
: Stores the provider contract instance.sourcePoolId
: Stores the pool ID being withdrawn from.vaultId
: Retrieves the vault ID linked to the pool.token
: Fetches the ERC20 token linked to the vault.
Executes the force withdrawal process by:
- Validating the receiver and contract permissions.
- Creating a new pool with the specified amount.
- Withdrawing the NFT from the vault.
- Transferring the tokens to the receiver.
- Finalizing the process by restoring ownership.
- Creates a new deal pool for forced withdrawal.
- Clones the vault ID from the original pool.
- Registers the new amount in the deal provider.
- Activates the vault for the forced withdrawal process.
- Transfers the NFT to the
lockDealNFT
contract. - Deactivates the vault status after withdrawal.
- Transfers the specified token amount to the receiver.
- Transfers ownership of the vault manager back to the original owner.
InvalidOwner()
: Thrown if the contract is not the vault manager's owner.NotApprovedContract()
: Thrown if the contract is not an approved operator.ZeroAddress()
: Thrown if an invalid zero address is provided as a receiver.
- Only the contract owner can invoke force withdrawals.
- Utilizes OpenZeppelin's
SafeERC20
to prevent unsafe token transfers. - Ensures only pre-approved contracts can interact with
lockDealNFT
.
The-Poolz Contracts is released under the MIT License.