From f3f6a76a220e427dc0e1cfdbee3e4f26372a2d03 Mon Sep 17 00:00:00 2001 From: mx <53249469+mx819812523@users.noreply.github.com> Date: Mon, 20 Jan 2025 19:17:22 +0800 Subject: [PATCH] add liquid_xp coin (#3207) * lp xp * fix: icon url character * fix: update coin info function * fix: get signer from module_signer --- apps/rooch_dex/sources/liquid_xp.move | 30 +++++++++++++++++++++++++++ apps/rooch_dex/sources/swap.move | 8 +++---- 2 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 apps/rooch_dex/sources/liquid_xp.move diff --git a/apps/rooch_dex/sources/liquid_xp.move b/apps/rooch_dex/sources/liquid_xp.move new file mode 100644 index 0000000000..0972490588 --- /dev/null +++ b/apps/rooch_dex/sources/liquid_xp.move @@ -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 = b" "; + + fun init() { + let signer = module_signer(); + let coin_info_obj = coin::register_extend( + string::utf8(b"Rooch Dex Liquid XP"), + string::utf8(b"LPXP"), + option::some(string::utf8(LPXP_URL)), + DECIMALS, + ); + let coin = coin::mint_extend(&mut coin_info_obj, TOTAL_SUPPLY); + object::to_frozen(coin_info_obj); + account_coin_store::deposit(address_of(&signer), coin); + } + +} diff --git a/apps/rooch_dex/sources/swap.move b/apps/rooch_dex/sources/swap.move index 29b2a564b8..b45e7b75db 100644 --- a/apps/rooch_dex/sources/swap.move +++ b/apps/rooch_dex/sources/swap.move @@ -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; @@ -123,8 +123,8 @@ module rooch_dex::swap { let resource_signer = module_signer(); let lp_name: string::String = string::utf8(b"RoochDex-"); - let name_x = coin::symbol(coin_info()); - let name_y = coin::symbol(coin_info()); + let name_x = symbol_by_type(); + let name_y = symbol_by_type(); string::append(&mut lp_name, name_x); string::append_utf8(&mut lp_name, b"-"); string::append(&mut lp_name, name_y); @@ -189,7 +189,7 @@ module rooch_dex::swap { /// Get the total supply of LP Tokens public fun total_lp_supply(): u128 { - (coin::supply(coin_info>()) as u128) + (supply_by_type>() as u128) } /// Get the current reserves of T0 and T1 with the latest updated timestamp