I've deployed a LP lock contract but didn't work, anyone knows what's wrong with the code?

Hi guys, I've deployed the following LP lock contract on the BSC but didn't work. Obviously there is something I'm missing, can anyone help me out?

I meant that the contract was verified, but didn't lock the LP address (the LP contract for the token) which it was the main reason behind this contract.

CONTRACT:

Thanks!

There is no function that lock the tokens. I think you forgot the function to transfer tokens from user to contract

1 Like

thanks for answering, do you know how can I do that? can you show me some example?

Maybe this can work

contract TokenTimelock {
    using SafeERC20 for IERC20;

    // ERC20 basic token contract being held
    IERC20 private _token;

    // beneficiary of tokens after they are released
    address private _beneficiary;

    // timestamp when token release is enabled
    uint256 private _releaseTime;

    constructor (IERC20 token_, uint256 amount, address beneficiary_, uint256 releaseTime_) public {
        // solhint-disable-next-line not-rely-on-time
        require(releaseTime_ > block.timestamp, "TokenTimelock: release time is before current time");
        _token = token_;
        _beneficiary = beneficiary_;
        _releaseTime = releaseTime_;
        lockTokens(token_, amount);
    }

    /**
     * @return the token being held.
     */
    function token() public view returns (IERC20) {
        return _token;
    }

    /**
     * @return the beneficiary of the tokens.
     */
    function beneficiary() public view returns (address) {
        return _beneficiary;
    }
    
    function lockTokens(IERC20 tokenAdd, uint256 amount) internal{
        tokenAdd.safeTransferFrom(msg.sender, address(this), amount);
    }

    /**
     * @return the time when the tokens are released.
     */
    function releaseTime() public view returns (uint256) {
        return _releaseTime;
    }

    /**
     * @notice Transfers tokens held by timelock to beneficiary.
     */
    function release() public virtual {
        // solhint-disable-next-line not-rely-on-time
        require(block.timestamp >= _releaseTime, "TokenTimelock: current time is before release time");

        uint256 amount = _token.balanceOf(address(this));
        require(amount > 0, "TokenTimelock: no tokens to release");

        _token.safeTransfer(_beneficiary, amount);
    }
}
1 Like

I still would need to add the specified (LP adddress, beneficiary and time epoc) like this?

contract SimpleTokenTimelock is TokenTimelock {
constructor () public TokenTimelock(
IERC20(0xDefB2d3ad9a26D15579A43C2e78BEA900122f39d), // token
0xe9740A88cC00095141DAfdD2EA201906781c295C, // beneficiary
1648832355) {
}
}