Skip to content

Commit

Permalink
add admin util
Browse files Browse the repository at this point in the history
  • Loading branch information
jolestar committed Jan 21, 2025
1 parent 3123432 commit 69f9bb8
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
5 changes: 5 additions & 0 deletions apps/rooch_dex/Move.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@ app_admin = "_"
std = "0x1"
moveos_std = "0x2"
rooch_framework = "0x3"

[dev-addresses]
rooch_dex = "0x42"
app_admin = "0x43"

30 changes: 30 additions & 0 deletions apps/rooch_dex/sources/admin_util.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module rooch_dex::admin_util {

use moveos_std::object::{Object};
use moveos_std::signer;
use app_admin::admin::AdminCap;
use rooch_dex::liquid_xp::LiquidXP;
use rooch_dex::liquidity_incentive::{Self, FarmingAsset};

struct Witness{}

//any account with AdminCap can call this function to create LiquidXP incentive
public entry fun create_xp_incentive_pool<X: key+store, Y: key+store>(
release_per_second: u128,
coin_amount: u256,
start_time_in_seconds: u64,
_admin_cap: &mut Object<AdminCap>,
){
let module_signer = signer::module_signer<Witness>();
liquidity_incentive::create_pool<X, Y, LiquidXP>(&module_signer, release_per_second, coin_amount, start_time_in_seconds);
}

public entry fun add_xp_incentive<X: key+store, Y: key+store>(
farming_asset_obj: &mut Object<FarmingAsset<X, Y, LiquidXP>>,
amount: u256,
_admin_cap: &mut Object<AdminCap>,
){
let module_signer = signer::module_signer<Witness>();
liquidity_incentive::add_incentive(&module_signer, farming_asset_obj, amount);
}
}
2 changes: 1 addition & 1 deletion apps/rooch_dex/sources/liquidity_incentive.move
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ module rooch_dex::liquidity_incentive {
coin: Coin<RewardToken>,
start_time: u64,
) {
let end_time = (coin::value(&coin) / (release_per_second as u256) as u64);
let end_time = start_time + (coin::value(&coin) / (release_per_second as u256) as u64);
let coin_store = coin_store::create_coin_store<RewardToken>();
coin_store::deposit(&mut coin_store, coin);
if (swap_utils::sort_token_type<X, Y>()) {
Expand Down
2 changes: 1 addition & 1 deletion crates/testsuite/features/dex.feature
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Feature: RoochDAO Apps contract tests
Then assert: "{{$.account[-1].FSC.balance}} != 0"

#Create incentive pool
Then cmd: "move run --function default::liquidity_incentive::create_pool --type-args 0x3::gas_coin::RGas --type-args default::fixed_supply_coin::FSC --type-args default::liquid_xp::LiquidXP --args u128:10000 --args u256:10000000000 --args u64:0 --json"
Then cmd: "move run --function default::admin_util::create_xp_incentive_pool --type-args 0x3::gas_coin::RGas --type-args default::fixed_supply_coin::FSC --args u128:10000 --args u256:10000000000 --args u64:0 --args object:{{$.object[0].data[0].id}} --json"
Then assert: "{{$.move[-1].execution_info.status.type}} == executed"

Then cmd: "object -t 'default::liquidity_incentive::FarmingAsset<0x3::gas_coin::RGas,default::fixed_supply_coin::FSC,default::liquid_xp::LiquidXP>'"
Expand Down

0 comments on commit 69f9bb8

Please sign in to comment.