Skip to content

Commit

Permalink
PBO delegation pool new interface
Browse files Browse the repository at this point in the history
  • Loading branch information
axiongsupra committed Dec 18, 2024
1 parent f9652d1 commit ea5bed1
Showing 1 changed file with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ 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::{Coin, balance};
use supra_framework::account;
use supra_framework::supra_account;
use supra_framework::supra_coin::SupraCoin;
Expand Down Expand Up @@ -249,6 +249,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 +745,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_no_coin(
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!(
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 ea5bed1

Please sign in to comment.