1//! bond_servicing: registrar and paying agent for a tokenized bond on Solana.
2//! Design and reasoning: docs/bond-processing.md, docs/technical-overview.md.
3
4pub mod constants;
5pub mod error;
6pub mod events;
7pub mod instructions;
8pub mod settlement;
9pub mod state;
10
11use anchor_lang::prelude::*;
12use spl_discriminator::SplDiscriminate;
13use spl_transfer_hook_interface::instruction::ExecuteInstruction;
14
15pub use constants::*;
16pub use instructions::*;
17pub use state::*;
18
19declare_id!("2UkTKYYzgZXZsganCqfxyY5Q5EeynUSBbErdKMpy8sHf");
20
21#[program]
22pub mod bond_servicing {
23 use super::*;
24
25 pub fn create_bond(ctx: Context<CreateBond>, terms: BondTerms) -> Result<()> {
26 instructions::create_bond::handle_create_bond(ctx, terms)
27 }
28
29 pub fn register_holder(ctx: Context<RegisterHolder>, owner: Pubkey) -> Result<()> {
30 instructions::register_holder::handle_register_holder(ctx, owner)
31 }
32
33 pub fn place(ctx: Context<Place>, amount: u64) -> Result<()> {
34 instructions::place::handle_place(ctx, amount)
35 }
36
37 #[instruction(discriminator = ExecuteInstruction::SPL_DISCRIMINATOR_SLICE)]
38 pub fn transfer_hook(ctx: Context<TransferHook>, amount: u64) -> Result<()> {
39 instructions::transfer_hook::handle_transfer_hook(ctx, amount)
40 }
41
42 pub fn open_event(ctx: Context<OpenEvent>, index: u16) -> Result<()> {
43 instructions::open_event::handle_open_event(ctx, index)
44 }
45
46 pub fn confirm_funding(ctx: Context<ConfirmFunding>) -> Result<()> {
47 instructions::confirm_funding::handle_confirm_funding(ctx)
48 }
49
50 pub fn pay_coupon(ctx: Context<PayCoupon>) -> Result<()> {
51 instructions::pay_coupon::handle_pay_coupon(ctx)
52 }
53
54 pub fn redeem_holder(ctx: Context<RedeemHolder>) -> Result<()> {
55 instructions::redeem_holder::handle_redeem_holder(ctx)
56 }
57
58 pub fn create_offer(
59 ctx: Context<CreateOffer>,
60 id: u16,
61 pro_rata: bool,
62 price_units: u64,
63 max_quantity: u64,
64 open_time: i64,
65 close_time: i64,
66 ) -> Result<()> {
67 instructions::offer::handle_create_offer(ctx, id, pro_rata, price_units, max_quantity, open_time, close_time)
68 }
69
70 pub fn confirm_offer_funding(ctx: Context<ConfirmOfferFunding>) -> Result<()> {
71 instructions::offer::handle_confirm_offer_funding(ctx)
72 }
73
74 pub fn sell_to_offer(ctx: Context<SellToOffer>, quantity: u64) -> Result<()> {
75 instructions::offer::handle_sell_to_offer(ctx, quantity)
76 }
77
78 pub fn change_tender(ctx: Context<ChangeTender>, quantity: u64, withdraw: bool) -> Result<()> {
79 instructions::offer::handle_change_tender(ctx, quantity, withdraw)
80 }
81
82 pub fn resolve_tender(ctx: Context<ResolveTender>) -> Result<()> {
83 instructions::offer::handle_resolve_tender(ctx)
84 }
85
86 pub fn settle_tender(ctx: Context<SettleTender>) -> Result<()> {
87 instructions::offer::handle_settle_tender(ctx)
88 }
89}