Created
February 4, 2023 03:01
-
-
Save floatbeta/163391dc9797fd2ff37169a2b4bcb51b to your computer and use it in GitHub Desktop.
Deploy a liquidity pool on 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
local molten_chain = require("molten_chain") | |
local magma_token = molten_chain.new_token("MAGMA") | |
local token = molten_chain.new_token("TOKEN") | |
function deploy_liquidity_pool() | |
-- Check if MAGMA and TOKEN are valid tokens | |
if not magma_token:is_valid() or not token:is_valid() then | |
error("Invalid token") | |
end | |
-- Calculate the total supply of MAGMA and TOKEN | |
local magma_supply = magma_token:get_total_supply() | |
local token_supply = token:get_total_supply() | |
-- Check if the total supply of MAGMA and TOKEN is greater than 0 | |
if magma_supply <= 0 or token_supply <= 0 then | |
error("Insufficient supply") | |
end | |
-- Calculate the ratio of MAGMA to TOKEN | |
local magma_ratio = magma_supply / token_supply | |
-- Create a liquidity pool with the ratio of MAGMA to TOKEN | |
local liquidity_pool = molten_chain.new_liquidity_pool(magma_ratio) | |
-- Return the address of the liquidity pool | |
return liquidity_pool:get_address() | |
end | |
deploy_liquidity_pool() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment