@@ -24,6 +24,10 @@ pub use analytics::{
2424} ;
2525pub use errors:: ContractError ;
2626pub use types:: {
27+ ArbitrationConfig , ArbitratorReputation , ArbitratorVote , DisclosureGrant , DisputeResolution ,
28+ InsurancePolicy , MultiSigConfig , Proposal , ProposalAction , ProposalStatus , Subscription ,
29+ SubscriptionTier , TierConfig , TierStatus , TierThresholds , TemplateTerms , TemplateVersion ,
30+ Trade , TradePrivacy , TradeStatus , TradeTemplate , UserTier , UserTierInfo , VotingSummary ,
2731 ArbitrationConfig , CrossChainInfo , DisputeResolution , InsurancePolicy , KycStatus ,
2832 OptionalMetadata , Trade , TradeStatus , UserCompliance , MAX_INSURANCE_PREMIUM_BPS ,
2933 MAX_METADATA_SIZE ,
@@ -1000,6 +1004,80 @@ impl StellarEscrowContract {
10001004 Ok ( ( ) )
10011005 }
10021006
1007+ /// Query a user's current tier info.
1008+ pub fn get_user_tier ( env : Env , user : Address ) -> Option < UserTierInfo > {
1009+ storage:: get_user_tier ( & env, & user)
1010+ }
1011+
1012+ /// Query the current tier fee configuration.
1013+ pub fn get_tier_config ( env : Env ) -> Option < TierConfig > {
1014+ storage:: get_tier_config ( & env)
1015+ }
1016+
1017+ /// Query the effective fee bps for a user's next trade.
1018+ pub fn get_effective_fee_bps ( env : Env , user : Address ) -> Result < u32 , ContractError > {
1019+ let base = get_fee_bps ( & env) ?;
1020+ Ok ( tiers:: effective_fee_bps ( & env, & user, base) )
1021+ }
1022+
1023+ /// Query the volume thresholds required to reach Silver and Gold tiers.
1024+ pub fn get_tier_thresholds ( _env : Env ) -> TierThresholds {
1025+ tiers:: get_tier_thresholds ( )
1026+ }
1027+
1028+ /// Query additional trading volume a user needs to reach the next tier.
1029+ /// Returns 0 if the user is already at Gold or has a custom fee.
1030+ pub fn get_volume_to_next_tier ( env : Env , user : Address ) -> u64 {
1031+ let info = storage:: get_user_tier ( & env, & user) . unwrap_or ( UserTierInfo {
1032+ tier : UserTier :: Bronze ,
1033+ total_volume : 0 ,
1034+ custom_fee_bps : None ,
1035+ } ) ;
1036+ tiers:: volume_to_next_tier ( & info)
1037+ }
1038+
1039+ /// Query a complete tier status snapshot for a user: current tier, cumulative
1040+ /// volume, volume needed to reach the next tier, and effective fee bps.
1041+ pub fn get_user_tier_status ( env : Env , user : Address ) -> Result < TierStatus , ContractError > {
1042+ require_initialized ( & env) ?;
1043+ tiers:: get_tier_status ( & env, & user)
1044+ }
1045+
1046+ // -------------------------------------------------------------------------
1047+ // Trade Templates
1048+ // -------------------------------------------------------------------------
1049+
1050+ /// Create a reusable trade template (owner = seller).
1051+ pub fn create_template (
1052+ env : Env ,
1053+ owner : Address ,
1054+ name : soroban_sdk:: String ,
1055+ terms : TemplateTerms ,
1056+ ) -> Result < u64 , ContractError > {
1057+ require_initialized ( & env) ?;
1058+ owner. require_auth ( ) ;
1059+ templates:: create_template ( & env, & owner, name, terms)
1060+ }
1061+
1062+ /// Update a template with new terms, bumping its version.
1063+ pub fn update_template (
1064+ env : Env ,
1065+ caller : Address ,
1066+ template_id : u64 ,
1067+ name : soroban_sdk:: String ,
1068+ terms : TemplateTerms ,
1069+ ) -> Result < ( ) , ContractError > {
1070+ require_initialized ( & env) ?;
1071+ caller. require_auth ( ) ;
1072+ templates:: update_template ( & env, & caller, template_id, name, terms)
1073+ }
1074+
1075+ /// Deactivate a template so it can no longer be used to create trades.
1076+ pub fn deactivate_template (
1077+ env : Env ,
1078+ caller : Address ,
1079+ template_id : u64 ,
1080+ ) -> Result < ( ) , ContractError > {
10031081 pub fn set_bridge_oracle ( env : Env , oracle : Address ) -> Result < ( ) , ContractError > {
10041082 require_initialized ( & env) ?;
10051083 storage:: get_admin ( & env) ?. require_auth ( ) ;
0 commit comments