Skip to content

Instantly share code, notes, and snippets.

@floatbeta
Last active February 4, 2023 03:00
Show Gist options
  • Save floatbeta/6feddb30deebd84c5788d3c50a9256db to your computer and use it in GitHub Desktop.
Save floatbeta/6feddb30deebd84c5788d3c50a9256db to your computer and use it in GitHub Desktop.
Liquidity Lock Smart Contract for MoltenChain.
-- Define the contract
local contract = {
init = function(self)
-- Initialize variables
self.timeLocked = {}
self.lockedAmounts = {}
end,
-- Method to lock up liquidity
lock = function(self, sender, amount, lockTime)
-- Store the lock time and amount for the sender
self.timeLocked[sender] = blockchain.time() + lockTime
self.lockedAmounts[sender] = amount
-- Deduct the locked amount from the sender's balance
balance.deduct(sender, amount)
end,
-- Method to unlock the liquidity
unlock = function(self, sender)
-- Check if the lock time has passed
if blockchain.time() >= self.timeLocked[sender] then
-- Add the locked amount back to the sender's balance
balance.add(sender, self.lockedAmounts[sender])
-- Remove the lock time and amount for the sender
self.timeLocked[sender] = nil
self.lockedAmounts[sender] = nil
return true
else
return false
end
end
}
-- Register the contract
contract.register(contract)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment