Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add liquid_xp coin #3207

Merged
merged 5 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions apps/rooch_dex/sources/liquid_xp.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module rooch_dex::liquid_xp {

use std::option;
use std::signer::address_of;
use std::string;
use moveos_std::signer::module_signer;
use rooch_framework::account_coin_store;
use moveos_std::object;
use rooch_framework::coin;

struct LiquidXP has key, store {}

const DECIMALS: u8 = 0u8;
const TOTAL_SUPPLY: u256 = 210_000_000_000u256;
const LPXP_URL: vector<u8> = b"<?xml version=\"1.0\" encoding=\"UTF-8\"?> <svg id=\"uuid-a3a41756-333e-440b-bb04-96f732a5a49c\" data-name=\"layer 1\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 167 167\"> <defs> <style>.uuid-157feab7-fb80-4a1d-a209-a0e5b0349789 {fill: #006934; }.uuid-94747213-8e52-4821-8d7c-0dfa01b59f69 {fill: #71fcad;stroke-width: 4px; }.uuid-94747213-8e52-4821-8d7c-0dfa01b59f69, .uuid-b3f4b701-0227-4aa3-afd0-151f83261e2c, .uuid-8fedb988-c742-48d4-9105-eb39e9dece3f, .uuid-46406f08-e7b8-4556-9159-09d699e4158d, .uuid-968b5765-ac1c-4a3a-a006-62ae20c50a63 {stroke-miterlimit: 10; }.uuid-94747213-8e52-4821-8d7c-0dfa01b59f69, .uuid-b3f4b701-0227-4aa3-afd0-151f83261e2c, .uuid-46406f08-e7b8-4556-9159-09d699e4158d {stroke: #1e1815; }.uuid-b3f4b701-0227-4aa3-afd0-151f83261e2c, .uuid-8fedb988-c742-48d4-9105-eb39e9dece3f {fill: #afff9f; }.uuid-8fedb988-c742-48d4-9105-eb39e9dece3f, .uuid-968b5765-ac1c-4a3a-a006-62ae20c50a63 {stroke: #13aa67; }.uuid-46406f08-e7b8-4556-9159-09d699e4158d {fill: #39f492; }.uuid-968b5765-ac1c-4a3a-a006-62ae20c50a63 {fill: #f9f9f9; } </style> </defs> <g> <circle class=\"uuid-94747213-8e52-4821-8d7c-0dfa01b59f69\" cx=\"83.5\" cy=\"83.5\" r=\"81.5\"/> <ellipse class=\"uuid-46406f08-e7b8-4556-9159-09d699e4158d\" cx=\"87.64\" cy=\"83.6\" rx=\"75.36\" ry=\"79.32\"/> <ellipse class=\"uuid-b3f4b701-0227-4aa3-afd0-151f83261e2c\" cx=\"92.5\" cy=\"83.6\" rx=\"70.5\" ry=\"79.32\"/> <ellipse class=\"uuid-8fedb988-c742-48d4-9105-eb39e9dece3f\" cx=\"92.66\" cy=\"84.06\" rx=\"66.11\" ry=\"74.37\"/> </g> <g> <path class=\"uuid-157feab7-fb80-4a1d-a209-a0e5b0349789\" d=\"M119.89,116.37l6.95,8.89-7.24,.99-3.56-4.76-4.08,5.81-8.07,1.11,8.52-11.28-7.54-9.18,8.08-.55,3.44,4.63,3.69-5.12,7.27-.49-7.45,9.95Z\"/> <path class=\"uuid-157feab7-fb80-4a1d-a209-a0e5b0349789\" d=\"M139.44,105.62c2.93-.2,4.91,.24,5.97,1.31s1.53,2.61,1.44,4.67c-.06,1.42-.33,2.64-.81,3.68-.48,1.04-1.29,1.9-2.43,2.59s-2.73,1.16-4.75,1.41l-4.73,.57-.18,4.44-5.82,.8c.26-3.35,.45-6.47,.57-9.38s.18-6.04,.18-9.38l5.83-.4v.03s4.74-.32,4.74-.32Zm-1.95,9.03c1.25-.13,2.17-.28,2.79-.45,.62-.17,1.05-.4,1.3-.71,.25-.3,.39-.72,.41-1.27s-.07-.94-.29-1.19c-.22-.25-.63-.4-1.23-.44-.61-.05-1.55-.01-2.82,.1l-3.16,.28-.17,4,3.16-.32Z\"/> </g> <path class=\"uuid-968b5765-ac1c-4a3a-a006-62ae20c50a63\" d=\"M101.1,95.07c.04,7.54,.1,15.12,.09,22.76,0,1.22,.32,1.46,1.23,1.26,1.42-.31,2.83-.46,4.23-.76,.73-.16,.93,.16,.92,1.02-.02,2.61,0,5.22,.05,7.84,.01,.75-.16,1.05-.78,1.17-6.93,1.37-14.16,2.82-21.71,4.36-.77,.16-.87-.23-.87-.96,.02-2.86,.04-5.72,0-8.56,0-.84,.28-1.12,.94-1.21,1.7-.26,3.39-.6,5.06-.83,.79-.11,1.03-.51,1.03-1.42-.03-3.98-.06-7.96,0-11.93,.02-1.28-.6-1.09-1.3-1-10.76,1.39-22.22,2.85-34.43,4.47-1.43,.19-2-.05-1.89-1.74,.17-2.61,.19-5.22,.11-7.8-.04-1.43,.45-1.83,1.69-1.88,1.72-.07,3.44-.37,5.14-.46,1.11-.06,1.43-.51,1.44-1.72,.05-8.9,.17-17.74,.26-26.52,.08-7.62,.13-15.19,.27-22.71,.03-1.39-.25-1.96-1.65-1.91-1.65,.06-3.34-.15-5.03-.16-.93,0-1.36-.24-1.32-1.35,.1-2.78,.13-5.57,.12-8.35,0-.98,.34-1.22,1.24-1.15,8.37,.61,16.39,1.17,24.06,1.67,.9,.06,1.1,.44,1.08,1.36-.05,2.53-.07,5.08-.03,7.63,.01,.98-.28,1.27-1.14,1.2-1.58-.14-3.19-.1-4.8-.25-1.02-.1-1.31,.3-1.31,1.41,0,7.75-.07,15.55-.12,23.39-.05,8.1-.07,16.26-.17,24.47-.01,1.25,.2,1.71,1.41,1.57,5.22-.59,10.28-1.07,15.21-1.51,.89-.08,1.14-.44,1.13-1.46-.04-7.46-.05-14.88-.02-22.25,0-1.04-.27-1.33-1.14-1.26-1.55,.11-3.12,.06-4.7,.16-.76,.04-1.07-.19-1.05-1.13,.05-2.67,.04-5.34,.02-8,0-.7,.11-1.09,.85-1.07,9.78,.17,19.03-.35,27.79,.34,4.21,.33,8.01,1.99,10.91,5.92,3.65,4.95,4.46,10.95,3.88,17.53-.83,9.34-6.16,14.93-12.49,17.65-3.22,1.38-6.58,1.44-9.99,1.95-.59,.09-.69-.29-.69-.91,0-2.64,0-5.28-.05-7.9-.02-.89,.32-1.03,.91-1.09,1.92-.21,3.81-.28,5.68-.7,6.9-1.52,8.5-8.42,7.8-14.51-.59-5.12-3.1-8-7.27-8.51-3.22-.4-6.52,0-9.88-.02-.92,0-.87,.63-.86,1.38,.04,6.64,.07,13.32,.1,20.03,0,.82,0,1.64,.01,2.45h0Z\"/> </svg>";

fun init() {
let signer = module_signer<LiquidXP>();
let coin_info_obj = coin::register_extend<LiquidXP>(
string::utf8(b"Rooch Dex Liquid XP"),
string::utf8(b"LPXP"),
option::some(string::utf8(LPXP_URL)),
DECIMALS,
);
let coin = coin::mint_extend<LiquidXP>(&mut coin_info_obj, TOTAL_SUPPLY);
object::to_frozen(coin_info_obj);
account_coin_store::deposit(address_of(&signer), coin);
}

}
8 changes: 4 additions & 4 deletions apps/rooch_dex/sources/swap.move
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module rooch_dex::swap {
use moveos_std::tx_context::sender;
use moveos_std::object;
use moveos_std::account;
use rooch_framework::coin::{CoinInfo, coin_info};
use rooch_framework::coin::{CoinInfo, symbol_by_type, supply_by_type};
use moveos_std::object::{Object, ObjectID};
use rooch_framework::coin_store::{CoinStore, balance, deposit, withdraw};
use rooch_framework::coin_store;
Expand Down Expand Up @@ -123,8 +123,8 @@ module rooch_dex::swap {
let resource_signer = module_signer<RoochDexCap>();

let lp_name: string::String = string::utf8(b"RoochDex-");
let name_x = coin::symbol<X>(coin_info<X>());
let name_y = coin::symbol<Y>(coin_info<Y>());
let name_x = symbol_by_type<X>();
let name_y = symbol_by_type<Y>();
string::append(&mut lp_name, name_x);
string::append_utf8(&mut lp_name, b"-");
string::append(&mut lp_name, name_y);
Expand Down Expand Up @@ -189,7 +189,7 @@ module rooch_dex::swap {

/// Get the total supply of LP Tokens
public fun total_lp_supply<X:key+store, Y:key+store>(): u128 {
(coin::supply(coin_info<LPToken<X, Y>>()) as u128)
(supply_by_type<LPToken<X, Y>>() as u128)
}

/// Get the current reserves of T0 and T1 with the latest updated timestamp
Expand Down
Loading