Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PBO delegation pool new interface #140

Merged
merged 4 commits into from
Dec 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(
axiongsupra marked this conversation as resolved.
Show resolved Hide resolved
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