Skip to content

Commit

Permalink
PBO delegation pool new interface (#140)
Browse files Browse the repository at this point in the history
* PBO delegation pool new interface

* Rename

* Update import
  • Loading branch information
axiongsupra authored Dec 20, 2024
1 parent e25cdb4 commit 1b998f1
Showing 1 changed file with 39 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,15 @@ module supra_framework::pbo_delegation_pool {
use aptos_std::smart_table::{Self, SmartTable};
use aptos_std::fixed_point64::{Self, FixedPoint64};

use supra_framework::coin::Coin;
use supra_framework::coin::{Self, Coin};
use supra_framework::account;
use supra_framework::supra_account;
use supra_framework::supra_coin::SupraCoin;
use supra_framework::coin;
use supra_framework::event::{Self, EventHandle, emit};
use supra_framework::stake::{Self, get_operator};
use supra_framework::staking_config;
use supra_framework::timestamp;
use supra_framework::multisig_account;
#[test_only]
use aptos_std::debug;

const MODULE_SALT: vector<u8> = b"supra_framework::pbo_delegation_pool";

Expand Down Expand Up @@ -249,6 +246,9 @@ module supra_framework::pbo_delegation_pool {

const ENEW_IS_SAME_AS_OLD_DELEGATOR: u64 = 37;

/// Balance is not enough.
const EBALANCE_NOT_SUFFICIENT: u64 = 38;

const MAX_U64: u64 = 18446744073709551615;

/// Maximum operator percentage fee(of double digit precision): 22.85% is represented as 2285
Expand Down Expand Up @@ -742,6 +742,41 @@ module supra_framework::pbo_delegation_pool {
staking_config::get_recurring_lockup_duration(&config) / 4
}

/// Initialize a delegation pool without actual coin but withdraw from the owner's account.
public fun initialize_delegation_pool_with_amount(
owner: &signer,
multisig_admin: option::Option<address>,
amount: u64,
operator_commission_percentage: u64,
delegation_pool_creation_seed: vector<u8>,
delegator_address: vector<address>,
principle_stake: vector<u64>,
unlock_numerators: vector<u64>,
unlock_denominator: u64,
unlock_start_time: u64,
unlock_duration: u64
) acquires DelegationPool, GovernanceRecords, BeneficiaryForOperator, NextCommissionPercentage {
assert!(
coin::balance<SupraCoin>(signer::address_of(owner)) >= amount,
error::invalid_argument(EBALANCE_NOT_SUFFICIENT)
);
let coin = coin::withdraw<SupraCoin>(owner, amount);

initialize_delegation_pool(
owner,
multisig_admin,
operator_commission_percentage,
delegation_pool_creation_seed,
delegator_address,
principle_stake,
coin,
unlock_numerators,
unlock_denominator,
unlock_start_time,
unlock_duration
)
}

/// Initialize a delegation pool of custom fixed `operator_commission_percentage`.
/// A resource account is created from `owner` signer and its supplied `delegation_pool_creation_seed`
/// to host the delegation pool resource and own the underlying stake pool.
Expand Down

0 comments on commit 1b998f1

Please sign in to comment.