Skip to content

Commit 94928af

Browse files
feat(creator-keys): add dividend reinvestment function (#805)
1 parent f251b81 commit 94928af

185 files changed

Lines changed: 16597 additions & 364 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

creator-keys/src/events.rs

Lines changed: 110 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -754,42 +754,6 @@ pub fn keys_burned_topics(key_id: &Address) -> (Symbol, Address) {
754754
(KEYS_BURNED_EVENT_NAME, key_id.clone())
755755
}
756756

757-
#[derive(Clone, Debug, Eq, PartialEq)]
758-
#[contracttype]
759-
pub struct FeeCollectedEvent {
760-
/// Treasury address that received the fee.
761-
pub treasury: Address,
762-
/// Fee amount deducted from the trade.
763-
pub amount: i128,
764-
/// Ledger sequence number at the time of the trade.
765-
pub ledger: u32,
766-
}
767-
768-
/// Shared fee collected event topics tuple.
769-
pub fn fee_collected_topics(treasury: &Address) -> (Symbol, Address) {
770-
(FEE_COLLECTED_EVENT_NAME, treasury.clone())
771-
}
772-
773-
#[derive(Clone, Debug, Eq, PartialEq)]
774-
#[contracttype]
775-
pub struct LockupBlockedEvent {
776-
/// Creator whose keys the seller attempted to sell.
777-
pub creator_id: Address,
778-
/// Seller whose sale was rejected.
779-
pub seller: Address,
780-
/// Ledger timestamp of the seller's most recent buy.
781-
pub last_buy_timestamp: u64,
782-
/// Timestamp at which the lockup expires (exclusive).
783-
pub unlock_at: u64,
784-
/// Ledger timestamp at rejection.
785-
pub current_timestamp: u64,
786-
}
787-
788-
/// Shared lockup blocked event topics tuple.
789-
pub fn lockup_blocked_topics(creator: &Address, seller: &Address) -> (Symbol, Address, Address) {
790-
(LOCKUP_BLOCKED_EVENT_NAME, creator.clone(), seller.clone())
791-
}
792-
793757
#[derive(Clone, Debug, Eq, PartialEq)]
794758
#[contracttype]
795759
pub struct QuorumUpdatedEvent {
@@ -1196,12 +1160,6 @@ pub fn royalty_updated_topics(creator: &Address) -> (Symbol, Address) {
11961160
(ROYALTY_UPDATED_EVENT_NAME, creator.clone())
11971161
}
11981162

1199-
/// Event name for the protocol trade fee collected on a buy or sell.
1200-
pub const FEE_COLLECTED_EVENT_NAME: Symbol = symbol_short!("fee_coll");
1201-
1202-
/// Event name for a sell rejected by the anti-flash-trade lockup window.
1203-
pub const LOCKUP_BLOCKED_EVENT_NAME: Symbol = symbol_short!("lck_blk");
1204-
12051163
/// Stable fee collection event payload for downstream indexers.
12061164
///
12071165
/// Event shape:
@@ -1287,7 +1245,11 @@ pub struct StakeEvent {
12871245
}
12881246

12891247
/// Shared stake event topics tuple.
1290-
pub fn stake_topics(creator: &Address, holder: &Address, stake_id: u32) -> (Symbol, Address, Address, u32) {
1248+
pub fn stake_topics(
1249+
creator: &Address,
1250+
holder: &Address,
1251+
stake_id: u32,
1252+
) -> (Symbol, Address, Address, u32) {
12911253
(STAKE_EVENT_NAME, creator.clone(), holder.clone(), stake_id)
12921254
}
12931255

@@ -1317,7 +1279,12 @@ pub fn stake_extended_topics(
13171279
holder: &Address,
13181280
stake_id: u32,
13191281
) -> (Symbol, Address, Address, u32) {
1320-
(STAKE_EXTENDED_EVENT_NAME, creator.clone(), holder.clone(), stake_id)
1282+
(
1283+
STAKE_EXTENDED_EVENT_NAME,
1284+
creator.clone(),
1285+
holder.clone(),
1286+
stake_id,
1287+
)
13211288
}
13221289

13231290
/// Stable early-unstake event payload for downstream indexers.
@@ -1350,7 +1317,12 @@ pub fn early_unstake_topics(
13501317
holder: &Address,
13511318
stake_id: u32,
13521319
) -> (Symbol, Address, Address, u32) {
1353-
(EARLY_UNSTAKE_EVENT_NAME, creator.clone(), holder.clone(), stake_id)
1320+
(
1321+
EARLY_UNSTAKE_EVENT_NAME,
1322+
creator.clone(),
1323+
holder.clone(),
1324+
stake_id,
1325+
)
13541326
}
13551327

13561328
/// Stable stake-reward-claim event payload for downstream indexers.
@@ -1383,10 +1355,14 @@ pub fn stake_reward_claimed_topics(
13831355
holder: &Address,
13841356
stake_id: u32,
13851357
) -> (Symbol, Address, Address, u32) {
1386-
(STAKE_REWARD_CLAIMED_EVENT_NAME, creator.clone(), holder.clone(), stake_id)
1358+
(
1359+
STAKE_REWARD_CLAIMED_EVENT_NAME,
1360+
creator.clone(),
1361+
holder.clone(),
1362+
stake_id,
1363+
)
13871364
}
13881365

1389-
13901366
// ============================================================================
13911367
// Launch Penalty (#798)
13921368
// ============================================================================
@@ -1415,7 +1391,11 @@ pub fn launch_penalty_applied_topics(
14151391
creator: &Address,
14161392
seller: &Address,
14171393
) -> (Symbol, Address, Address) {
1418-
(LAUNCH_PENALTY_APPLIED_EVENT_NAME, creator.clone(), seller.clone())
1394+
(
1395+
LAUNCH_PENALTY_APPLIED_EVENT_NAME,
1396+
creator.clone(),
1397+
seller.clone(),
1398+
)
14191399
}
14201400

14211401
/// Event name for set_launch_penalty.
@@ -1437,3 +1417,85 @@ pub struct LaunchPenaltySetEvent {
14371417
pub fn launch_penalty_set_topics(creator: &Address) -> (Symbol, Address) {
14381418
(LAUNCH_PENALTY_SET_EVENT_NAME, creator.clone())
14391419
}
1420+
1421+
pub const AUCTION_CONFIGURED_EVENT_NAME: Symbol = symbol_short!("auc_cfg");
1422+
pub const AUCTION_CANCELLED_EVENT_NAME: Symbol = symbol_short!("auc_canc");
1423+
pub const AUCTION_PURCHASE_EVENT_NAME: Symbol = symbol_short!("auc_buy");
1424+
pub const CO_CREATOR_REMOVED_EVENT_NAME: Symbol = symbol_short!("co_rem");
1425+
1426+
#[derive(Clone, Debug, Eq, PartialEq)]
1427+
#[contracttype]
1428+
pub struct AuctionConfiguredEvent {
1429+
pub creator_id: Address,
1430+
pub auction_price: i128,
1431+
pub auction_supply: u32,
1432+
}
1433+
1434+
pub fn auction_configured_topics(creator: &Address) -> (Symbol, Address) {
1435+
(AUCTION_CONFIGURED_EVENT_NAME, creator.clone())
1436+
}
1437+
1438+
#[derive(Clone, Debug, Eq, PartialEq)]
1439+
#[contracttype]
1440+
pub struct AuctionPurchaseEvent {
1441+
pub buyer: Address,
1442+
pub creator_id: Address,
1443+
pub quantity: u32,
1444+
pub price_paid: i128,
1445+
pub new_supply: u32,
1446+
pub auction_sold: u32,
1447+
pub ledger: u32,
1448+
}
1449+
1450+
pub fn auction_purchase_topics(creator: &Address, buyer: &Address) -> (Symbol, Address, Address) {
1451+
(AUCTION_PURCHASE_EVENT_NAME, creator.clone(), buyer.clone())
1452+
}
1453+
1454+
#[derive(Clone, Debug, Eq, PartialEq)]
1455+
#[contracttype]
1456+
pub struct AuctionCancelledEvent {
1457+
pub creator_id: Address,
1458+
pub auction_price: i128,
1459+
pub auction_supply: u32,
1460+
}
1461+
1462+
pub fn auction_cancelled_topics(creator: &Address) -> (Symbol, Address) {
1463+
(AUCTION_CANCELLED_EVENT_NAME, creator.clone())
1464+
}
1465+
1466+
#[derive(Clone, Debug, Eq, PartialEq)]
1467+
#[contracttype]
1468+
pub struct CoCreatorRemovedEvent {
1469+
pub creator_id: Address,
1470+
pub co_creator: Address,
1471+
pub ledger: u32,
1472+
}
1473+
1474+
pub fn co_creator_removed_topics(creator: &Address) -> (Symbol, Address) {
1475+
(CO_CREATOR_REMOVED_EVENT_NAME, creator.clone())
1476+
}
1477+
1478+
/// Event name for dividend reinvestment.
1479+
pub const DIVIDEND_REINVESTED_EVENT_NAME: Symbol = symbol_short!("div_reinv");
1480+
1481+
/// Stable dividend reinvested event payload for downstream indexers.
1482+
#[derive(Clone, Debug, Eq, PartialEq)]
1483+
#[contracttype]
1484+
pub struct DividendReinvestedEvent {
1485+
pub wallet: Address,
1486+
pub key_id: Address,
1487+
pub keys_bought: u32,
1488+
pub remainder_returned: i128,
1489+
}
1490+
1491+
/// Shared dividend reinvested event topics tuple.
1492+
pub fn dividend_reinvested_topics(
1493+
key_id: &Address,
1494+
wallet: &Address,
1495+
) -> (Symbol, Address, Address) {
1496+
(
1497+
DIVIDEND_REINVESTED_EVENT_NAME,
1498+
key_id.clone(),
1499+
wallet.clone(),
1500+
)
1501+
}

0 commit comments

Comments
 (0)