Last active
February 4, 2023 03:00
-
-
Save floatbeta/6feddb30deebd84c5788d3c50a9256db to your computer and use it in GitHub Desktop.
Liquidity Lock Smart Contract for MoltenChain.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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