Skip to content
Merged
Show file tree
Hide file tree
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
15 changes: 13 additions & 2 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ jobs:
# Smart Contracts (Rust / Soroban)
# ─────────────────────────────────────────────
contracts:
# TODO: Contracts have pre-existing compilation errors (170 on main).
# This job is set to continue-on-error until the smart contracts are fixed.
name: Contracts — Lint, Build, Test
runs-on: ubuntu-latest
env:
Expand Down Expand Up @@ -62,6 +60,19 @@ jobs:
cd stellar-lend
cargo test --verbose

- name: Run cross-contract tests
run: |
cd stellar-lend
cargo test --package hello-world --lib cross_contract_test 2>&1 | tee cross-contract-test-report.txt
grep "test result:" cross-contract-test-report.txt

- name: Upload cross-contract test report
if: always()
uses: actions/upload-artifact@v4
with:
name: cross-contract-test-report
path: stellar-lend/cross-contract-test-report.txt

- name: Run security audit
run: |
cd stellar-lend
Expand Down
15 changes: 15 additions & 0 deletions stellar-lend/contracts/hello-world/src/deposit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ pub enum DepositError {
Overflow = 6,
/// Reentrancy detected
Reentrancy = 7,
/// Caller is not authorized
Unauthorized = 8,
}

/// Storage keys for deposit-related data
Expand Down Expand Up @@ -178,6 +180,19 @@ pub struct ProtocolAnalytics {
pub total_value_locked: i128,
}

/// Set per-asset deposit parameters (admin-only). Caller must already be verified.
pub fn set_asset_params(
env: &Env,
_caller: Address,
asset: Address,
params: AssetParams,
) -> Result<(), DepositError> {
env.storage()
.persistent()
.set(&DepositDataKey::AssetParams(asset), &params);
Ok(())
}

/// Deposit collateral function
///
/// Allows users to deposit assets as collateral in the protocol.
Expand Down
31 changes: 31 additions & 0 deletions stellar-lend/contracts/hello-world/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,39 @@ impl HelloContract {
pub fn get_user_position(env: Env, user: Address) -> Result<Position, AnalyticsError> {
analytics::get_user_position_summary(&env, &user)
}

// -------------------------------------------------------------------------
// Asset Configuration
// -------------------------------------------------------------------------

/// Set per-asset deposit/collateral parameters (admin-only).
pub fn update_asset_config(
env: Env,
asset: Address,
params: deposit::AssetParams,
) -> Result<(), deposit::DepositError> {
let admin = crate::admin::get_admin(&env).ok_or(deposit::DepositError::Unauthorized)?;
admin.require_auth();
deposit::set_asset_params(&env, admin, asset, params)
}

// -------------------------------------------------------------------------
// Flash Loan Configuration
// -------------------------------------------------------------------------

/// Configure flash loan parameters (admin-only).
pub fn configure_flash_loan(
env: Env,
caller: Address,
config: flash_loan::FlashLoanConfig,
) -> Result<(), flash_loan::FlashLoanError> {
flash_loan::set_flash_loan_config(&env, caller, config)
}
}

#[cfg(test)]
#[path = "tests/cross_contract_test.rs"]
mod cross_contract_test;
#[cfg(test)]
mod flash_loan_test;
#[cfg(test)]
Expand Down
Loading
Loading