Vocabulary fixes
This commit is contained in:
@@ -65,7 +65,7 @@ impl AssetController {
|
||||
|
||||
// Add assets by type
|
||||
let asset_types = vec![
|
||||
AssetType::NFT,
|
||||
AssetType::Artwork,
|
||||
AssetType::Token,
|
||||
AssetType::RealEstate,
|
||||
AssetType::Commodity,
|
||||
@@ -209,7 +209,7 @@ impl AssetController {
|
||||
|
||||
// Add asset types for dropdown
|
||||
let asset_types = vec![
|
||||
("NFT", "NFT"),
|
||||
("Artwork", "Artwork"),
|
||||
("Token", "Token"),
|
||||
("RealEstate", "Real Estate"),
|
||||
("Commodity", "Commodity"),
|
||||
@@ -473,7 +473,7 @@ impl AssetController {
|
||||
"token_price": 75.0
|
||||
}),
|
||||
image_url: Some("https://images.unsplash.com/photo-1506744038136-46273834b3fb?auto=format&fit=crop&w=600&q=80".to_string()),
|
||||
external_url: Some("https://oceanviewholdings.zaz/resort".to_string()),
|
||||
external_url: Some("https://oceanviewholdings.zdfz/resort".to_string()),
|
||||
};
|
||||
|
||||
zanzibar_resort.add_blockchain_info(BlockchainInfo {
|
||||
@@ -486,9 +486,9 @@ impl AssetController {
|
||||
timestamp: Some(now - Duration::days(120)),
|
||||
});
|
||||
|
||||
zanzibar_resort.add_valuation(650000.0, "USD", "ZAZ Property Registry", Some("Initial tokenization valuation".to_string()));
|
||||
zanzibar_resort.add_valuation(650000.0, "USD", "ZDFZ Property Registry", Some("Initial tokenization valuation".to_string()));
|
||||
zanzibar_resort.add_valuation(700000.0, "USD", "International Property Appraisers", Some("Independent third-party valuation".to_string()));
|
||||
zanzibar_resort.add_valuation(750000.0, "USD", "ZAZ Property Registry", Some("Updated valuation after infrastructure improvements".to_string()));
|
||||
zanzibar_resort.add_valuation(750000.0, "USD", "ZDFZ Property Registry", Some("Updated valuation after infrastructure improvements".to_string()));
|
||||
|
||||
zanzibar_resort.add_transaction(
|
||||
"Tokenization",
|
||||
@@ -497,7 +497,7 @@ impl AssetController {
|
||||
Some(650000.0),
|
||||
Some("USD".to_string()),
|
||||
Some("0xabcdef123456789abcdef123456789abcdef123456789abcdef123456789abcd".to_string()),
|
||||
Some("Initial property tokenization under ZAZ Property Registry".to_string()),
|
||||
Some("Initial property tokenization under ZDFZ Property Registry".to_string()),
|
||||
);
|
||||
|
||||
zanzibar_resort.add_transaction(
|
||||
@@ -512,14 +512,14 @@ impl AssetController {
|
||||
|
||||
assets.push(zanzibar_resort);
|
||||
|
||||
// Create ZAZ Governance Token
|
||||
// Create ZDFZ Governance Token
|
||||
let mut zaz_token = Asset {
|
||||
id: "asset-zaz-governance".to_string(),
|
||||
name: "ZAZ Governance Token".to_string(),
|
||||
id: "asset-zdfz-governance".to_string(),
|
||||
name: "ZDFZ Governance Token".to_string(),
|
||||
description: "Official governance token of the Zanzibar Digital Freezone, used for voting on proposals and zone-wide decisions".to_string(),
|
||||
asset_type: AssetType::Token,
|
||||
status: AssetStatus::Active,
|
||||
owner_id: "entity-zaz-foundation".to_string(),
|
||||
owner_id: "entity-zdfz-foundation".to_string(),
|
||||
owner_name: "Zanzibar Digital Freezone Foundation".to_string(),
|
||||
created_at: now - Duration::days(365),
|
||||
updated_at: now - Duration::days(2),
|
||||
@@ -537,7 +537,7 @@ impl AssetController {
|
||||
"launch_date": (now - Duration::days(365)).to_rfc3339()
|
||||
}),
|
||||
image_url: Some("https://images.unsplash.com/photo-1431540015161-0bf868a2d407?q=80&w=3540&?auto=format&fit=crop&w=600&q=80".to_string()),
|
||||
external_url: Some("https://governance.zaz/token".to_string()),
|
||||
external_url: Some("https://governance.zdfz/token".to_string()),
|
||||
};
|
||||
|
||||
zaz_token.add_blockchain_info(BlockchainInfo {
|
||||
@@ -550,9 +550,9 @@ impl AssetController {
|
||||
timestamp: Some(now - Duration::days(365)),
|
||||
});
|
||||
|
||||
zaz_token.add_valuation(300000.0, "USD", "ZAZ Token Exchange", Some("Initial valuation at launch".to_string()));
|
||||
zaz_token.add_valuation(320000.0, "USD", "ZAZ Token Exchange", Some("Valuation after successful governance implementation".to_string()));
|
||||
zaz_token.add_valuation(350000.0, "USD", "ZAZ Token Exchange", Some("Current market valuation".to_string()));
|
||||
zaz_token.add_valuation(300000.0, "USD", "ZDFZ Token Exchange", Some("Initial valuation at launch".to_string()));
|
||||
zaz_token.add_valuation(320000.0, "USD", "ZDFZ Token Exchange", Some("Valuation after successful governance implementation".to_string()));
|
||||
zaz_token.add_valuation(350000.0, "USD", "ZDFZ Token Exchange", Some("Current market valuation".to_string()));
|
||||
|
||||
zaz_token.add_transaction(
|
||||
"Distribution",
|
||||
@@ -602,7 +602,7 @@ impl AssetController {
|
||||
"incorporation_date": (now - Duration::days(180)).to_rfc3339()
|
||||
}),
|
||||
image_url: Some("https://images.unsplash.com/photo-1464983953574-0892a716854b?auto=format&fit=crop&w=600&q=80".to_string()),
|
||||
external_url: Some("https://spicetrade.zaz".to_string()),
|
||||
external_url: Some("https://spicetrade.zdfz".to_string()),
|
||||
};
|
||||
|
||||
spice_trade_shares.add_blockchain_info(BlockchainInfo {
|
||||
@@ -615,9 +615,9 @@ impl AssetController {
|
||||
timestamp: Some(now - Duration::days(180)),
|
||||
});
|
||||
|
||||
spice_trade_shares.add_valuation(150000.0, "USD", "ZAZ Business Registry", Some("Initial company valuation at incorporation".to_string()));
|
||||
spice_trade_shares.add_valuation(175000.0, "USD", "ZAZ Business Registry", Some("Valuation after first export contracts".to_string()));
|
||||
spice_trade_shares.add_valuation(200000.0, "USD", "ZAZ Business Registry", Some("Current valuation after expansion to European markets".to_string()));
|
||||
spice_trade_shares.add_valuation(150000.0, "USD", "ZDFZ Business Registry", Some("Initial company valuation at incorporation".to_string()));
|
||||
spice_trade_shares.add_valuation(175000.0, "USD", "ZDFZ Business Registry", Some("Valuation after first export contracts".to_string()));
|
||||
spice_trade_shares.add_valuation(200000.0, "USD", "ZDFZ Business Registry", Some("Current valuation after expansion to European markets".to_string()));
|
||||
|
||||
spice_trade_shares.add_transaction(
|
||||
"Share Issuance",
|
||||
@@ -648,8 +648,8 @@ impl AssetController {
|
||||
description: "Patent for an innovative tidal energy harvesting system designed specifically for the coastal conditions of Zanzibar".to_string(),
|
||||
asset_type: AssetType::IntellectualProperty,
|
||||
status: AssetStatus::Active,
|
||||
owner_id: "entity-zaz-energy-innovations".to_string(),
|
||||
owner_name: "ZAZ Energy Innovations".to_string(),
|
||||
owner_id: "entity-zdfz-energy-innovations".to_string(),
|
||||
owner_name: "ZDFZ Energy Innovations".to_string(),
|
||||
created_at: now - Duration::days(210),
|
||||
updated_at: now - Duration::days(30),
|
||||
blockchain_info: None,
|
||||
@@ -659,7 +659,7 @@ impl AssetController {
|
||||
valuation_history: Vec::new(),
|
||||
transaction_history: Vec::new(),
|
||||
metadata: serde_json::json!({
|
||||
"patent_number": "ZAZ-PAT-2024-0142",
|
||||
"patent_number": "ZDFZ-PAT-2024-0142",
|
||||
"filing_date": (now - Duration::days(210)).to_rfc3339(),
|
||||
"grant_date": (now - Duration::days(120)).to_rfc3339(),
|
||||
"patent_type": "Utility",
|
||||
@@ -667,7 +667,7 @@ impl AssetController {
|
||||
"inventors": ["Dr. Amina Juma", "Eng. Ibrahim Hassan", "Dr. Sarah Mbeki"]
|
||||
}),
|
||||
image_url: Some("https://images.unsplash.com/photo-1708851148146-783a5b7da55d?q=80&w=3474&?auto=format&fit=crop&w=600&q=80".to_string()),
|
||||
external_url: Some("https://patents.zaz/ZAZ-PAT-2024-0142".to_string()),
|
||||
external_url: Some("https://patents.zdfz/ZDFZ-PAT-2024-0142".to_string()),
|
||||
};
|
||||
|
||||
tidal_energy_patent.add_blockchain_info(BlockchainInfo {
|
||||
@@ -680,9 +680,9 @@ impl AssetController {
|
||||
timestamp: Some(now - Duration::days(120)),
|
||||
});
|
||||
|
||||
tidal_energy_patent.add_valuation(80000.0, "USD", "ZAZ IP Registry", Some("Initial patent valuation upon filing".to_string()));
|
||||
tidal_energy_patent.add_valuation(100000.0, "USD", "ZAZ IP Registry", Some("Valuation after successful prototype testing".to_string()));
|
||||
tidal_energy_patent.add_valuation(120000.0, "USD", "ZAZ IP Registry", Some("Current valuation after pilot implementation".to_string()));
|
||||
tidal_energy_patent.add_valuation(80000.0, "USD", "ZDFZ IP Registry", Some("Initial patent valuation upon filing".to_string()));
|
||||
tidal_energy_patent.add_valuation(100000.0, "USD", "ZDFZ IP Registry", Some("Valuation after successful prototype testing".to_string()));
|
||||
tidal_energy_patent.add_valuation(120000.0, "USD", "ZDFZ IP Registry", Some("Current valuation after pilot implementation".to_string()));
|
||||
|
||||
tidal_energy_patent.add_transaction(
|
||||
"Registration",
|
||||
@@ -706,15 +706,15 @@ impl AssetController {
|
||||
|
||||
assets.push(tidal_energy_patent);
|
||||
|
||||
// Create Digital Art NFT
|
||||
// Create Digital Art Artwork
|
||||
let mut zanzibar_heritage_nft = Asset {
|
||||
id: "asset-heritage-nft".to_string(),
|
||||
id: "asset-heritage-Artwork".to_string(),
|
||||
name: "Zanzibar Heritage Collection #1".to_string(),
|
||||
description: "Limited edition digital art NFT showcasing Zanzibar's cultural heritage, created by renowned local artist Fatma Busaidy".to_string(),
|
||||
asset_type: AssetType::NFT,
|
||||
description: "Limited edition digital art Artwork showcasing Zanzibar's cultural heritage, created by renowned local artist Fatma Busaidy".to_string(),
|
||||
asset_type: AssetType::Artwork,
|
||||
status: AssetStatus::Active,
|
||||
owner_id: "entity-zaz-digital-arts".to_string(),
|
||||
owner_name: "ZAZ Digital Arts Collective".to_string(),
|
||||
owner_id: "entity-zdfz-digital-arts".to_string(),
|
||||
owner_name: "ZDFZ Digital Arts Collective".to_string(),
|
||||
created_at: now - Duration::days(90),
|
||||
updated_at: now - Duration::days(10),
|
||||
blockchain_info: None,
|
||||
@@ -729,10 +729,10 @@ impl AssetController {
|
||||
"medium": "Digital Mixed Media",
|
||||
"dimensions": "4000x3000 px",
|
||||
"creation_date": (now - Duration::days(95)).to_rfc3339(),
|
||||
"authenticity_certificate": "ZAZ-ART-CERT-2024-089"
|
||||
"authenticity_certificate": "ZDFZ-ART-CERT-2024-089"
|
||||
}),
|
||||
image_url: Some("https://images.unsplash.com/photo-1519125323398-675f0ddb6308?auto=format&fit=crop&w=600&q=80".to_string()),
|
||||
external_url: Some("https://digitalarts.zaz/collections/heritage/1".to_string()),
|
||||
external_url: Some("https://digitalarts.zdfz/collections/heritage/1".to_string()),
|
||||
};
|
||||
|
||||
zanzibar_heritage_nft.add_blockchain_info(BlockchainInfo {
|
||||
@@ -745,9 +745,9 @@ impl AssetController {
|
||||
timestamp: Some(now - Duration::days(90)),
|
||||
});
|
||||
|
||||
zanzibar_heritage_nft.add_valuation(5000.0, "USD", "ZAZ NFT Marketplace", Some("Initial offering price".to_string()));
|
||||
zanzibar_heritage_nft.add_valuation(5500.0, "USD", "ZAZ NFT Marketplace", Some("Valuation after artist exhibition".to_string()));
|
||||
zanzibar_heritage_nft.add_valuation(6000.0, "USD", "ZAZ NFT Marketplace", Some("Current market valuation".to_string()));
|
||||
zanzibar_heritage_nft.add_valuation(5000.0, "USD", "ZDFZ Artwork Marketplace", Some("Initial offering price".to_string()));
|
||||
zanzibar_heritage_nft.add_valuation(5500.0, "USD", "ZDFZ Artwork Marketplace", Some("Valuation after artist exhibition".to_string()));
|
||||
zanzibar_heritage_nft.add_valuation(6000.0, "USD", "ZDFZ Artwork Marketplace", Some("Current market valuation".to_string()));
|
||||
|
||||
zanzibar_heritage_nft.add_transaction(
|
||||
"Minting",
|
||||
@@ -756,7 +756,7 @@ impl AssetController {
|
||||
Some(0.0),
|
||||
Some("ETH".to_string()),
|
||||
Some("0x123456789abcdef123456789abcdef123456789abcdef123456789abcdef1234".to_string()),
|
||||
Some("Initial NFT minting by artist".to_string()),
|
||||
Some("Initial Artwork minting by artist".to_string()),
|
||||
);
|
||||
|
||||
zanzibar_heritage_nft.add_transaction(
|
||||
@@ -766,7 +766,7 @@ impl AssetController {
|
||||
Some(5000.0),
|
||||
Some("USD".to_string()),
|
||||
Some("0x234567890abcdef123456789abcdef123456789abcdef123456789abcdef1234".to_string()),
|
||||
Some("Primary sale to ZAZ Digital Arts Collective".to_string()),
|
||||
Some("Primary sale to ZDFZ Digital Arts Collective".to_string()),
|
||||
);
|
||||
|
||||
assets.push(zanzibar_heritage_nft);
|
||||
|
@@ -6,19 +6,19 @@ use serde::Deserialize;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::models::asset::{Asset, AssetType, AssetStatus};
|
||||
use crate::models::defi::{DefiPosition, DefiPositionType, DefiPositionStatus, LendingPosition, BorrowingPosition, DEFI_DB};
|
||||
use crate::models::defi::{DefiPosition, DefiPositionType, DefiPositionStatus, ProvidingPosition, ReceivingPosition, DEFI_DB};
|
||||
use crate::utils::render_template;
|
||||
|
||||
// Form structs for DeFi operations
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct LendingForm {
|
||||
pub struct ProvidingForm {
|
||||
pub asset_id: String,
|
||||
pub amount: f64,
|
||||
pub duration: i32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct BorrowingForm {
|
||||
pub struct ReceivingForm {
|
||||
pub collateral_asset_id: String,
|
||||
pub collateral_amount: f64,
|
||||
pub amount: f64,
|
||||
@@ -53,8 +53,8 @@ pub struct CollateralForm {
|
||||
pub asset_id: String,
|
||||
pub amount: f64,
|
||||
pub purpose: String,
|
||||
pub loan_amount: Option<f64>,
|
||||
pub loan_term: Option<i32>,
|
||||
pub funds_amount: Option<f64>,
|
||||
pub funds_term: Option<i32>,
|
||||
}
|
||||
|
||||
pub struct DefiController;
|
||||
@@ -86,22 +86,22 @@ impl DefiController {
|
||||
|
||||
context.insert("recent_assets", &recent_assets);
|
||||
|
||||
// Get user's lending positions
|
||||
// Get user's providing positions
|
||||
let db = DEFI_DB.lock().unwrap();
|
||||
let lending_positions = db.get_user_lending_positions("user123");
|
||||
let lending_positions_json: Vec<serde_json::Value> = lending_positions
|
||||
let providing_positions = db.get_user_providing_positions("user123");
|
||||
let providing_positions_json: Vec<serde_json::Value> = providing_positions
|
||||
.iter()
|
||||
.map(|p| serde_json::to_value(p).unwrap())
|
||||
.collect();
|
||||
context.insert("lending_positions", &lending_positions_json);
|
||||
context.insert("providing_positions", &providing_positions_json);
|
||||
|
||||
// Get user's borrowing positions
|
||||
let borrowing_positions = db.get_user_borrowing_positions("user123");
|
||||
let borrowing_positions_json: Vec<serde_json::Value> = borrowing_positions
|
||||
// Get user's receiving positions
|
||||
let receiving_positions = db.get_user_receiving_positions("user123");
|
||||
let receiving_positions_json: Vec<serde_json::Value> = receiving_positions
|
||||
.iter()
|
||||
.map(|p| serde_json::to_value(p).unwrap())
|
||||
.collect();
|
||||
context.insert("borrowing_positions", &borrowing_positions_json);
|
||||
context.insert("receiving_positions", &receiving_positions_json);
|
||||
|
||||
// Add success message if present in query params
|
||||
if let Some(success) = req.query_string().strip_prefix("success=") {
|
||||
@@ -115,17 +115,17 @@ impl DefiController {
|
||||
response
|
||||
}
|
||||
|
||||
// Process lending request
|
||||
pub async fn create_lending(_tmpl: web::Data<Tera>, form: web::Form<LendingForm>) -> Result<HttpResponse> {
|
||||
println!("DEBUG: Processing lending request: {:?}", form);
|
||||
// Process providing request
|
||||
pub async fn create_providing(_tmpl: web::Data<Tera>, form: web::Form<ProvidingForm>) -> Result<HttpResponse> {
|
||||
println!("DEBUG: Processing providing request: {:?}", form);
|
||||
|
||||
// Get the asset details (in a real app, this would come from a database)
|
||||
// Get the asset obligationails (in a real app, this would come from a database)
|
||||
let assets = Self::get_mock_assets();
|
||||
let asset = assets.iter().find(|a| a.id == form.asset_id);
|
||||
|
||||
if let Some(asset) = asset {
|
||||
// Calculate interest and return amount
|
||||
let apy = match form.duration {
|
||||
// Calculate profit share and return amount
|
||||
let profit_share = match form.duration {
|
||||
7 => 2.5,
|
||||
30 => 4.2,
|
||||
90 => 6.8,
|
||||
@@ -134,38 +134,37 @@ impl DefiController {
|
||||
_ => 4.2, // Default to 30 days rate
|
||||
};
|
||||
|
||||
let interest = form.amount * (apy / 100.0) * (form.duration as f64 / 365.0);
|
||||
let return_amount = form.amount + interest;
|
||||
let return_amount = form.amount + (form.amount * (profit_share / 100.0) * (form.duration as f64 / 365.0));
|
||||
|
||||
// Create a new lending position
|
||||
let lending_position = LendingPosition {
|
||||
// Create a new providing position
|
||||
let providing_position = ProvidingPosition {
|
||||
base: DefiPosition {
|
||||
id: Uuid::new_v4().to_string(),
|
||||
position_type: DefiPositionType::Lending,
|
||||
position_type: DefiPositionType::Providing,
|
||||
status: DefiPositionStatus::Active,
|
||||
asset_id: asset.id.clone(),
|
||||
asset_id: form.asset_id.clone(),
|
||||
asset_name: asset.name.clone(),
|
||||
asset_symbol: asset.asset_type.as_str().to_string(), // Using asset_type as symbol for now
|
||||
asset_symbol: asset.asset_type.as_str().to_string(),
|
||||
amount: form.amount,
|
||||
value_usd: form.amount * asset.latest_valuation().map_or(0.5, |v| v.value), // Assuming 0.5 USD per token if no valuation
|
||||
apy,
|
||||
value_usd: form.amount * asset.current_valuation.unwrap_or(0.0),
|
||||
expected_return: profit_share,
|
||||
created_at: Utc::now(),
|
||||
expires_at: Some(Utc::now() + Duration::days(form.duration as i64)),
|
||||
user_id: "user123".to_string(), // Hardcoded user ID for now
|
||||
},
|
||||
duration_days: form.duration,
|
||||
interest_earned: interest,
|
||||
profit_share_earned: profit_share,
|
||||
return_amount,
|
||||
};
|
||||
|
||||
// Add the position to the database
|
||||
{
|
||||
let mut db = DEFI_DB.lock().unwrap();
|
||||
db.add_lending_position(lending_position);
|
||||
db.add_providing_position(providing_position);
|
||||
}
|
||||
|
||||
// Redirect with success message
|
||||
let success_message = format!("Successfully lent {} {} at {}% APY", form.amount, asset.name, apy);
|
||||
let success_message = format!("Successfully provided {} {} for {} days", form.amount, asset.name, form.duration);
|
||||
Ok(HttpResponse::SeeOther()
|
||||
.append_header(("Location", format!("/defi?success={}", urlencoding::encode(&success_message))))
|
||||
.finish())
|
||||
@@ -177,17 +176,17 @@ impl DefiController {
|
||||
}
|
||||
}
|
||||
|
||||
// Process borrowing request
|
||||
pub async fn create_borrowing(_tmpl: web::Data<Tera>, form: web::Form<BorrowingForm>) -> Result<HttpResponse> {
|
||||
println!("DEBUG: Processing borrowing request: {:?}", form);
|
||||
// Process receiving request
|
||||
pub async fn create_receiving(_tmpl: web::Data<Tera>, form: web::Form<ReceivingForm>) -> Result<HttpResponse> {
|
||||
println!("DEBUG: Processing receiving request: {:?}", form);
|
||||
|
||||
// Get the asset details (in a real app, this would come from a database)
|
||||
// Get the asset obligationails (in a real app, this would come from a database)
|
||||
let assets = Self::get_mock_assets();
|
||||
let collateral_asset = assets.iter().find(|a| a.id == form.collateral_asset_id);
|
||||
|
||||
if let Some(collateral_asset) = collateral_asset {
|
||||
// Calculate interest rate based on duration
|
||||
let interest_rate = match form.duration {
|
||||
// Calculate profit share rate based on duration
|
||||
let profit_share_rate = match form.duration {
|
||||
7 => 3.5,
|
||||
30 => 5.0,
|
||||
90 => 6.5,
|
||||
@@ -196,26 +195,26 @@ impl DefiController {
|
||||
_ => 5.0, // Default to 30 days rate
|
||||
};
|
||||
|
||||
// Calculate interest and total to repay
|
||||
let interest = form.amount * (interest_rate / 100.0) * (form.duration as f64 / 365.0);
|
||||
let total_to_repay = form.amount + interest;
|
||||
// Calculate profit share and total to repay
|
||||
let profit_share = form.amount * (profit_share_rate / 100.0) * (form.duration as f64 / 365.0);
|
||||
let total_to_repay = form.amount + profit_share;
|
||||
|
||||
// Calculate collateral value and ratio
|
||||
let collateral_value = form.collateral_amount * collateral_asset.latest_valuation().map_or(0.5, |v| v.value);
|
||||
let collateral_ratio = (collateral_value / form.amount) * 100.0;
|
||||
|
||||
// Create a new borrowing position
|
||||
let borrowing_position = BorrowingPosition {
|
||||
// Create a new receiving position
|
||||
let receiving_position = ReceivingPosition {
|
||||
base: DefiPosition {
|
||||
id: Uuid::new_v4().to_string(),
|
||||
position_type: DefiPositionType::Borrowing,
|
||||
position_type: DefiPositionType::Receiving,
|
||||
status: DefiPositionStatus::Active,
|
||||
asset_id: "ZAZ".to_string(), // Hardcoded for now, in a real app this would be a parameter
|
||||
asset_id: "ZDFZ".to_string(), // Hardcoded for now, in a real app this would be a parameter
|
||||
asset_name: "Zanzibar Token".to_string(),
|
||||
asset_symbol: "ZAZ".to_string(),
|
||||
asset_symbol: "ZDFZ".to_string(),
|
||||
amount: form.amount,
|
||||
value_usd: form.amount * 0.5, // Assuming 0.5 USD per ZAZ
|
||||
apy: interest_rate,
|
||||
value_usd: form.amount * 0.5, // Assuming 0.5 USD per ZDFZ
|
||||
expected_return: profit_share_rate,
|
||||
created_at: Utc::now(),
|
||||
expires_at: Some(Utc::now() + Duration::days(form.duration as i64)),
|
||||
user_id: "user123".to_string(), // Hardcoded user ID for now
|
||||
@@ -226,8 +225,8 @@ impl DefiController {
|
||||
collateral_amount: form.collateral_amount,
|
||||
collateral_value_usd: collateral_value,
|
||||
duration_days: form.duration,
|
||||
interest_rate,
|
||||
interest_owed: interest,
|
||||
profit_share_rate,
|
||||
profit_share_owed: profit_share,
|
||||
total_to_repay,
|
||||
collateral_ratio,
|
||||
};
|
||||
@@ -235,11 +234,11 @@ impl DefiController {
|
||||
// Add the position to the database
|
||||
{
|
||||
let mut db = DEFI_DB.lock().unwrap();
|
||||
db.add_borrowing_position(borrowing_position);
|
||||
db.add_receiving_position(receiving_position);
|
||||
}
|
||||
|
||||
// Redirect with success message
|
||||
let success_message = format!("Successfully borrowed {} ZAZ using {} {} as collateral",
|
||||
let success_message = format!("Successfully borrowed {} ZDFZ using {} {} as collateral",
|
||||
form.amount, form.collateral_amount, collateral_asset.name);
|
||||
Ok(HttpResponse::SeeOther()
|
||||
.append_header(("Location", format!("/defi?success={}", urlencoding::encode(&success_message))))
|
||||
@@ -304,7 +303,7 @@ impl DefiController {
|
||||
// For now, we'll just redirect back to the DeFi dashboard with a success message
|
||||
|
||||
let purpose_str = match form.purpose.as_str() {
|
||||
"loan" => "secure a loan",
|
||||
"funds" => "secure a funds",
|
||||
"synthetic" => "generate synthetic assets",
|
||||
"leverage" => "leverage trading",
|
||||
_ => "collateralization",
|
||||
@@ -324,8 +323,8 @@ impl DefiController {
|
||||
|
||||
// Handle Option<Number> by unwrapping with expect
|
||||
stats.insert("total_value_locked".to_string(), serde_json::Value::Number(serde_json::Number::from_f64(1250000.0).expect("Valid float")));
|
||||
stats.insert("lending_volume".to_string(), serde_json::Value::Number(serde_json::Number::from_f64(450000.0).expect("Valid float")));
|
||||
stats.insert("borrowing_volume".to_string(), serde_json::Value::Number(serde_json::Number::from_f64(320000.0).expect("Valid float")));
|
||||
stats.insert("providing_volume".to_string(), serde_json::Value::Number(serde_json::Number::from_f64(450000.0).expect("Valid float")));
|
||||
stats.insert("receiving_volume".to_string(), serde_json::Value::Number(serde_json::Number::from_f64(320000.0).expect("Valid float")));
|
||||
stats.insert("liquidity_pools_count".to_string(), serde_json::Value::Number(serde_json::Number::from(12)));
|
||||
stats.insert("active_stakers".to_string(), serde_json::Value::Number(serde_json::Number::from(156)));
|
||||
stats.insert("total_swap_volume".to_string(), serde_json::Value::Number(serde_json::Number::from_f64(780000.0).expect("Valid float")));
|
||||
|
@@ -187,7 +187,7 @@ impl FlowController {
|
||||
// Create a few mock flows
|
||||
let mut flow1 = Flow {
|
||||
id: "flow-1".to_string(),
|
||||
name: "ZAZ Business Entity Registration".to_string(),
|
||||
name: "ZDFZ Business Entity Registration".to_string(),
|
||||
description: "Register a new business entity within the Zanzibar Digital Freezone legal framework".to_string(),
|
||||
flow_type: FlowType::CompanyRegistration,
|
||||
status: FlowStatus::InProgress,
|
||||
@@ -223,7 +223,7 @@ impl FlowController {
|
||||
FlowStep {
|
||||
id: "step-1-2".to_string(),
|
||||
name: "Regulatory Review".to_string(),
|
||||
description: "ZAZ Business Registry review of submitted documents and compliance with regulatory requirements".to_string(),
|
||||
description: "ZDFZ Business Registry review of submitted documents and compliance with regulatory requirements".to_string(),
|
||||
order: 2,
|
||||
status: StepStatus::InProgress,
|
||||
started_at: Some(Utc::now() - Duration::days(3)),
|
||||
@@ -231,7 +231,7 @@ impl FlowController {
|
||||
logs: vec![
|
||||
FlowLog {
|
||||
id: "log-1-2-1".to_string(),
|
||||
message: "Regulatory review initiated by ZAZ Business Registry".to_string(),
|
||||
message: "Regulatory review initiated by ZDFZ Business Registry".to_string(),
|
||||
timestamp: Utc::now() - Duration::days(3),
|
||||
},
|
||||
FlowLog {
|
||||
@@ -249,7 +249,7 @@ impl FlowController {
|
||||
FlowStep {
|
||||
id: "step-1-3".to_string(),
|
||||
name: "Digital Identity Creation".to_string(),
|
||||
description: "Creation of the entity's digital identity and blockchain credentials within the ZAZ ecosystem".to_string(),
|
||||
description: "Creation of the entity's digital identity and blockchain credentials within the ZDFZ ecosystem".to_string(),
|
||||
order: 3,
|
||||
status: StepStatus::Pending,
|
||||
started_at: None,
|
||||
@@ -280,7 +280,7 @@ impl FlowController {
|
||||
let mut flow2 = Flow {
|
||||
id: "flow-2".to_string(),
|
||||
name: "Digital Asset Tokenization Approval".to_string(),
|
||||
description: "Process for approving the tokenization of a real estate asset within the ZAZ regulatory framework".to_string(),
|
||||
description: "Process for approving the tokenization of a real estate asset within the ZDFZ regulatory framework".to_string(),
|
||||
flow_type: FlowType::AssetTokenization,
|
||||
status: FlowStatus::Completed,
|
||||
owner_id: "user-2".to_string(),
|
||||
@@ -302,7 +302,7 @@ impl FlowController {
|
||||
},
|
||||
FlowLog {
|
||||
id: "log-2-1-2".to_string(),
|
||||
message: "Independent valuation completed by ZAZ Property Registry".to_string(),
|
||||
message: "Independent valuation completed by ZDFZ Property Registry".to_string(),
|
||||
timestamp: Utc::now() - Duration::days(27),
|
||||
},
|
||||
FlowLog {
|
||||
@@ -315,7 +315,7 @@ impl FlowController {
|
||||
FlowStep {
|
||||
id: "step-2-2".to_string(),
|
||||
name: "Tokenization Structure Review".to_string(),
|
||||
description: "Review of the proposed token structure, distribution model, and compliance with ZAZ tokenization standards".to_string(),
|
||||
description: "Review of the proposed token structure, distribution model, and compliance with ZDFZ tokenization standards".to_string(),
|
||||
order: 2,
|
||||
status: StepStatus::Completed,
|
||||
started_at: Some(Utc::now() - Duration::days(24)),
|
||||
@@ -328,7 +328,7 @@ impl FlowController {
|
||||
},
|
||||
FlowLog {
|
||||
id: "log-2-2-2".to_string(),
|
||||
message: "Technical review completed by ZAZ Digital Assets Committee".to_string(),
|
||||
message: "Technical review completed by ZDFZ Digital Assets Committee".to_string(),
|
||||
timestamp: Utc::now() - Duration::days(22),
|
||||
},
|
||||
FlowLog {
|
||||
@@ -359,7 +359,7 @@ impl FlowController {
|
||||
},
|
||||
FlowLog {
|
||||
id: "log-2-3-3".to_string(),
|
||||
message: "Smart contracts deployed to ZAZ-approved blockchain".to_string(),
|
||||
message: "Smart contracts deployed to ZDFZ-approved blockchain".to_string(),
|
||||
timestamp: Utc::now() - Duration::days(15),
|
||||
},
|
||||
],
|
||||
@@ -367,7 +367,7 @@ impl FlowController {
|
||||
FlowStep {
|
||||
id: "step-2-4".to_string(),
|
||||
name: "Final Approval and Listing".to_string(),
|
||||
description: "Final regulatory approval and listing on the ZAZ Digital Asset Exchange".to_string(),
|
||||
description: "Final regulatory approval and listing on the ZDFZ Digital Asset Exchange".to_string(),
|
||||
order: 4,
|
||||
status: StepStatus::Completed,
|
||||
started_at: Some(Utc::now() - Duration::days(14)),
|
||||
@@ -380,12 +380,12 @@ impl FlowController {
|
||||
},
|
||||
FlowLog {
|
||||
id: "log-2-4-2".to_string(),
|
||||
message: "Regulatory approval granted by ZAZ Financial Authority".to_string(),
|
||||
message: "Regulatory approval granted by ZDFZ Financial Authority".to_string(),
|
||||
timestamp: Utc::now() - Duration::days(12),
|
||||
},
|
||||
FlowLog {
|
||||
id: "log-2-4-3".to_string(),
|
||||
message: "Asset tokens listed on ZAZ Digital Asset Exchange".to_string(),
|
||||
message: "Asset tokens listed on ZDFZ Digital Asset Exchange".to_string(),
|
||||
timestamp: Utc::now() - Duration::days(10),
|
||||
},
|
||||
],
|
||||
@@ -403,7 +403,7 @@ impl FlowController {
|
||||
let mut flow3 = Flow {
|
||||
id: "flow-3".to_string(),
|
||||
name: "Sustainable Tourism Certification".to_string(),
|
||||
description: "Application process for ZAZ Sustainable Tourism Certification for eco-tourism businesses".to_string(),
|
||||
description: "Application process for ZDFZ Sustainable Tourism Certification for eco-tourism businesses".to_string(),
|
||||
flow_type: FlowType::Certification,
|
||||
status: FlowStatus::Stuck,
|
||||
owner_id: "user-3".to_string(),
|
||||
@@ -474,7 +474,7 @@ impl FlowController {
|
||||
FlowStep {
|
||||
id: "step-3-4".to_string(),
|
||||
name: "Certification Issuance".to_string(),
|
||||
description: "Final review and issuance of ZAZ Sustainable Tourism Certification".to_string(),
|
||||
description: "Final review and issuance of ZDFZ Sustainable Tourism Certification".to_string(),
|
||||
order: 4,
|
||||
status: StepStatus::Pending,
|
||||
started_at: None,
|
||||
@@ -494,7 +494,7 @@ impl FlowController {
|
||||
let mut flow4 = Flow {
|
||||
id: "flow-4".to_string(),
|
||||
name: "Digital Payment Provider License".to_string(),
|
||||
description: "Application for a license to operate as a digital payment provider within the ZAZ financial system".to_string(),
|
||||
description: "Application for a license to operate as a digital payment provider within the ZDFZ financial system".to_string(),
|
||||
flow_type: FlowType::LicenseApplication,
|
||||
status: FlowStatus::InProgress,
|
||||
owner_id: "user-4".to_string(),
|
||||
@@ -529,7 +529,7 @@ impl FlowController {
|
||||
FlowStep {
|
||||
id: "step-4-2".to_string(),
|
||||
name: "Technical Infrastructure Review".to_string(),
|
||||
description: "Review of the technical infrastructure, security measures, and compliance with ZAZ financial standards".to_string(),
|
||||
description: "Review of the technical infrastructure, security measures, and compliance with ZDFZ financial standards".to_string(),
|
||||
order: 2,
|
||||
status: StepStatus::Completed,
|
||||
started_at: Some(Utc::now() - Duration::days(17)),
|
||||
@@ -542,7 +542,7 @@ impl FlowController {
|
||||
},
|
||||
FlowLog {
|
||||
id: "log-4-2-2".to_string(),
|
||||
message: "Security audit initiated by ZAZ Financial Technology Office".to_string(),
|
||||
message: "Security audit initiated by ZDFZ Financial Technology Office".to_string(),
|
||||
timestamp: Utc::now() - Duration::days(15),
|
||||
},
|
||||
FlowLog {
|
||||
|
@@ -241,7 +241,7 @@ impl GovernanceController {
|
||||
id: "prop-002".to_string(),
|
||||
creator_id: 2,
|
||||
creator_name: "Amina Salim".to_string(),
|
||||
title: "ZAZ Sustainable Tourism Framework".to_string(),
|
||||
title: "ZDFZ Sustainable Tourism Framework".to_string(),
|
||||
description: "A comprehensive framework for sustainable tourism development within the Zanzibar Digital Freezone. This proposal outlines environmental standards, community benefit-sharing mechanisms, and digital infrastructure for eco-tourism businesses. It includes tokenization standards for tourism assets and a certification system for sustainable operators.".to_string(),
|
||||
status: ProposalStatus::Approved,
|
||||
created_at: now - Duration::days(15),
|
||||
@@ -265,7 +265,7 @@ impl GovernanceController {
|
||||
id: "prop-004".to_string(),
|
||||
creator_id: 1,
|
||||
creator_name: "Ibrahim Faraji".to_string(),
|
||||
title: "ZAZ Regulatory Framework for Digital Financial Services".to_string(),
|
||||
title: "ZDFZ Regulatory Framework for Digital Financial Services".to_string(),
|
||||
description: "Establish a comprehensive regulatory framework for digital financial services within the Zanzibar Digital Freezone. This includes licensing requirements for crypto exchanges, digital payment providers, and tokenized asset platforms operating within the zone, while ensuring compliance with international AML/KYC standards.".to_string(),
|
||||
status: ProposalStatus::Rejected,
|
||||
created_at: now - Duration::days(20),
|
||||
@@ -277,8 +277,8 @@ impl GovernanceController {
|
||||
id: "prop-005".to_string(),
|
||||
creator_id: 4,
|
||||
creator_name: "Fatma Busaidy".to_string(),
|
||||
title: "Digital Arts Incubator and NFT Marketplace".to_string(),
|
||||
description: "Create a dedicated digital arts incubator and NFT marketplace to support Zanzibar's creative economy. The initiative will provide technical training, equipment, and a curated marketplace for local artists to create and sell digital art that celebrates Zanzibar's rich cultural heritage while accessing global markets.".to_string(),
|
||||
title: "Digital Arts Incubator and Artwork Marketplace".to_string(),
|
||||
description: "Create a dedicated digital arts incubator and Artwork marketplace to support Zanzibar's creative economy. The initiative will provide technical training, equipment, and a curated marketplace for local artists to create and sell digital art that celebrates Zanzibar's rich cultural heritage while accessing global markets.".to_string(),
|
||||
status: ProposalStatus::Active,
|
||||
created_at: now - Duration::days(7),
|
||||
updated_at: now - Duration::days(7),
|
||||
@@ -301,7 +301,7 @@ impl GovernanceController {
|
||||
id: "prop-007".to_string(),
|
||||
creator_id: 6,
|
||||
creator_name: "Saida Juma".to_string(),
|
||||
title: "ZAZ Educational Technology Initiative".to_string(),
|
||||
title: "ZDFZ Educational Technology Initiative".to_string(),
|
||||
description: "Establish a comprehensive educational technology program within the Zanzibar Digital Freezone to develop local tech talent. This initiative includes coding academies, blockchain development courses, and digital entrepreneurship training, with a focus on preparing Zanzibar's youth for careers in the zone's growing digital economy.".to_string(),
|
||||
status: ProposalStatus::Draft,
|
||||
created_at: now - Duration::days(3),
|
||||
|
@@ -100,7 +100,7 @@ impl MarketplaceController {
|
||||
]);
|
||||
context.insert("asset_types", &[
|
||||
AssetType::Token.as_str(),
|
||||
AssetType::NFT.as_str(),
|
||||
AssetType::Artwork.as_str(),
|
||||
AssetType::RealEstate.as_str(),
|
||||
AssetType::IntellectualProperty.as_str(),
|
||||
AssetType::Commodity.as_str(),
|
||||
@@ -168,7 +168,7 @@ impl MarketplaceController {
|
||||
|
||||
// Add current user info for bid/purchase forms
|
||||
let user_id = "user-123";
|
||||
let user_name = "John Doe";
|
||||
let user_name = "Alice Hostly";
|
||||
context.insert("user_id", &user_id);
|
||||
context.insert("user_name", &user_name);
|
||||
|
||||
@@ -237,7 +237,7 @@ impl MarketplaceController {
|
||||
|
||||
// Mock user data
|
||||
let user_id = "user-123";
|
||||
let user_name = "John Doe";
|
||||
let user_name = "Alice Hostly";
|
||||
|
||||
// Create the listing
|
||||
let _listing = Listing::new(
|
||||
@@ -347,7 +347,7 @@ impl MarketplaceController {
|
||||
|
||||
// Mock user data
|
||||
let user_ids = vec!["user-123", "user-456", "user-789"];
|
||||
let user_names = vec!["John Doe", "Jane Smith", "Bob Johnson"];
|
||||
let user_names = vec!["Alice Hostly", "Ethan Cloudman", "Priya Servera"];
|
||||
|
||||
// Create some fixed price listings
|
||||
for i in 0..6 {
|
||||
@@ -357,7 +357,7 @@ impl MarketplaceController {
|
||||
|
||||
let price = match asset.asset_type {
|
||||
AssetType::Token => 50.0 + (i as f64 * 10.0),
|
||||
AssetType::NFT => 500.0 + (i as f64 * 100.0),
|
||||
AssetType::Artwork => 500.0 + (i as f64 * 100.0),
|
||||
AssetType::RealEstate => 50000.0 + (i as f64 * 10000.0),
|
||||
AssetType::IntellectualProperty => 2000.0 + (i as f64 * 500.0),
|
||||
AssetType::Commodity => 1000.0 + (i as f64 * 200.0),
|
||||
@@ -398,7 +398,7 @@ impl MarketplaceController {
|
||||
|
||||
let starting_price = match asset.asset_type {
|
||||
AssetType::Token => 40.0 + (i as f64 * 5.0),
|
||||
AssetType::NFT => 400.0 + (i as f64 * 50.0),
|
||||
AssetType::Artwork => 400.0 + (i as f64 * 50.0),
|
||||
AssetType::RealEstate => 40000.0 + (i as f64 * 5000.0),
|
||||
AssetType::IntellectualProperty => 1500.0 + (i as f64 * 300.0),
|
||||
AssetType::Commodity => 800.0 + (i as f64 * 100.0),
|
||||
@@ -454,7 +454,7 @@ impl MarketplaceController {
|
||||
|
||||
let value = match asset.asset_type {
|
||||
AssetType::Token => 60.0 + (i as f64 * 15.0),
|
||||
AssetType::NFT => 600.0 + (i as f64 * 150.0),
|
||||
AssetType::Artwork => 600.0 + (i as f64 * 150.0),
|
||||
AssetType::RealEstate => 60000.0 + (i as f64 * 15000.0),
|
||||
AssetType::IntellectualProperty => 2500.0 + (i as f64 * 600.0),
|
||||
AssetType::Commodity => 1200.0 + (i as f64 * 300.0),
|
||||
@@ -491,7 +491,7 @@ impl MarketplaceController {
|
||||
|
||||
let price = match asset.asset_type {
|
||||
AssetType::Token => 55.0 + (i as f64 * 12.0),
|
||||
AssetType::NFT => 550.0 + (i as f64 * 120.0),
|
||||
AssetType::Artwork => 550.0 + (i as f64 * 120.0),
|
||||
AssetType::RealEstate => 55000.0 + (i as f64 * 12000.0),
|
||||
AssetType::IntellectualProperty => 2200.0 + (i as f64 * 550.0),
|
||||
AssetType::Commodity => 1100.0 + (i as f64 * 220.0),
|
||||
@@ -540,7 +540,7 @@ impl MarketplaceController {
|
||||
|
||||
let price = match asset.asset_type {
|
||||
AssetType::Token => 45.0 + (i as f64 * 8.0),
|
||||
AssetType::NFT => 450.0 + (i as f64 * 80.0),
|
||||
AssetType::Artwork => 450.0 + (i as f64 * 80.0),
|
||||
AssetType::RealEstate => 45000.0 + (i as f64 * 8000.0),
|
||||
AssetType::IntellectualProperty => 1800.0 + (i as f64 * 400.0),
|
||||
AssetType::Commodity => 900.0 + (i as f64 * 180.0),
|
||||
|
Reference in New Issue
Block a user