diff --git a/aptos-move/framework/supra-framework/sources/pbo_delegation_pool.move b/aptos-move/framework/supra-framework/sources/pbo_delegation_pool.move index 0a94b098908d1..c3d2b7dc33fa8 100644 --- a/aptos-move/framework/supra-framework/sources/pbo_delegation_pool.move +++ b/aptos-move/framework/supra-framework/sources/pbo_delegation_pool.move @@ -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 = b"supra_framework::pbo_delegation_pool"; @@ -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 @@ -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
, + amount: u64, + operator_commission_percentage: u64, + delegation_pool_creation_seed: vector, + delegator_address: vector
, + principle_stake: vector, + unlock_numerators: vector, + unlock_denominator: u64, + unlock_start_time: u64, + unlock_duration: u64 + ) acquires DelegationPool, GovernanceRecords, BeneficiaryForOperator, NextCommissionPercentage { + assert!( + coin::balance(signer::address_of(owner)) >= amount, + error::invalid_argument(EBALANCE_NOT_SUFFICIENT) + ); + let coin = coin::withdraw(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.