fn upgrade(env: soroban_sdk::Env, new_wasm_hash: soroban_sdk::BytesN<32>)
fn version(env: soroban_sdk::Env) -> u32
fn initialize(
env: soroban_sdk::Env,
multi_sig: Option,
usd_token: Option,
defa: Option,
invoices_ids: soroban_sdk::Vec,
borrower_addresses: soroban_sdk::Vec,
amounts: soroban_sdk::Vec,
min_amounts: soroban_sdk::Vec,
pool_values: soroban_sdk::Vec,
) -> (u128, u128)
- @notice Allows a borrower to repay their loan linked to a specific invoice.
fn repay_loan(env: soroban_sdk::Env, invoice_id: soroban_sdk::String, amount: u128)
- @notice Allows a lender to participate in the pool by contributing USD tokens.
- @dev
-
- Transfers USD tokens from the lender to the pool.
-
- Issues LP tokens to the lender proportional to their contribution.
-
- Updates pool state including total raised amount and lender details.
- @param lender The address of the lender providing funds.
- @param amount The amount of USD tokens the lender contributes.
fn participate(env: soroban_sdk::Env, lender: soroban_sdk::Address, amount: u128)
- @notice Accept the admin role.
- @dev Can only be called by the pending admin proposed earlier via
propose_new_admin().
-
Once accepted, the pending admin becomes the active admin,
-
and the pending slot is reset to zero.
fn accept_admin(env: soroban_sdk::Env)
- @notice Executes a pool by allocating funds to the specified invoices.
fn execute_pool(
env: soroban_sdk::Env,
invoicesids: soroban_sdk::Vec,
amounts: soroban_sdk::Vec,
)
fn __constructor(
env: soroban_sdk::Env,
admin: soroban_sdk::Address,
im_reciver: soroban_sdk::Address,
logger_contract: soroban_sdk::Address,
token_multiplier: u128,
)
- @notice Allows a lender to claim their LP tokens after repayment.
fn claim_lp_token(env: soroban_sdk::Env, lender_addr: soroban_sdk::Address)
- @notice Fills the insurance fund for specific invoices.
- @dev Only callable by the admin (secured with
onlyAdminSafe).
-
The insurance amount is funded from the admin/treasury wallet
-
and credited to the pool contract. These funds act as protection
-
for lenders in case of borrower default.
- @param invoices Array of invoice identifiers that will be insured.
- @param amounts Array of insurance amounts allocated to each corresponding invoice.
fn fill_insurance(
env: soroban_sdk::Env,
invoices: soroban_sdk::Vec,
amounts: soroban_sdk::Vec,
)
- @notice Returns the total claimable amount for a given lender.
- @param lender Address of the lender whose claimable amount is queried.
- @return u128 The total claimable amount for the lender.
fn get_claimables(env: soroban_sdk::Env, lender: soroban_sdk::Address) -> u128
fn pause_contract(env: soroban_sdk::Env)
- @notice Allows a lender to claim insurance compensation from the pool.
fn claim_insurance(env: soroban_sdk::Env, lender_addr: soroban_sdk::Address)
- @notice Allows a lender to claim their liquidity back from the pool.
- @dev Typically called after borrower repayments.
- @param lender_addr Address of the lender claiming their liquidity share.
fn claim_liquidity(env: soroban_sdk::Env, lender_addr: soroban_sdk::Address)
- @notice Sets the pool APY and (IM) APY.
fn set_percentages(env: soroban_sdk::Env, per1: u128, per2: u128)
fn get_pool_metrics(env: soroban_sdk::Env) -> PoolMetrics
- @notice Reconstructs an existing pool with updated parameters.
- @dev Used when borrowers fail to fully repay within the original terms,
-
or when the pool needs restructuring. Updates invoices with new APYs,
-
durations, user states, and IM APYs. New LP tokens or capital
-
adjustments may also be applied depending on the pool logic.
- @param invoice_ids Array of invoice identifiers to be restructured.
- @param new_apys Array of updated APYs (annual percentage yields)
-
applied to each corresponding invoice.
- @param new_durations Array of updated pool durations for each invoice.
- @param user_states Array of boolean flags indicating borrower states
-
(e.g., active, defaulted, or restructured).
- @param new_im_apys Array of updated IM APY values for each invoice.
fn reconstruct_pool(
env: soroban_sdk::Env,
invoice_ids: soroban_sdk::Vec,
new_apys: soroban_sdk::Vec,
new_durations: soroban_sdk::Vec,
user_states: soroban_sdk::Vec,
new_im_apys: soroban_sdk::Vec,
)
fn unpause_contract(env: soroban_sdk::Env)
- @notice Returns the total claimable DLPs amount for a given lender.
- @dev Reads the
claimAbleAmount stored in the lender’s details.
-
This represents the amount the lender is entitled to withdraw DLPs
-
(e.g., from repayments, yield, or insurance depending on logic).
- @param _lender Address of the lender whose claimable amount is queried.
- @return u128 The total claimable amount for the lender.
fn get_claimable_lps(env: soroban_sdk::Env, lender: soroban_sdk::Address) -> u128
- @notice Returns the shareholding percentage of a lender in the pool.
- @dev Calculates the lender’s share relative to the total amount raised.
-
Formula: (lender.poolShare * percentDivider) / amountRaised
-
where `percentDivider` is typically a constant 100* 1e10
-
for precision in percentage calculations.
- @param lender_addr Address of the lender whose shareholding is queried.
- @return shareHolding Lender’s shareholding expressed as a percentage
-
(scaled by `percentDivider`).
fn get_share_holding(env: soroban_sdk::Env, lender_addr: soroban_sdk::Address) -> u128
fn initiate_transfer(env: soroban_sdk::Env, to: soroban_sdk::Address, value: u128)
- @notice Propose a new admin for the contract.
fn propose_new_admin(env: soroban_sdk::Env, new_admin: soroban_sdk::Address)
fn emergency_withdraw(env: soroban_sdk::Env, token: soroban_sdk::Address, amount: u128)
fn get_lender_address(
env: soroban_sdk::Env,
start: u32,
end: u32,
) -> soroban_sdk::Vec
- @notice Returns details of a specific lender in the pool.
*
- @param lender Address of the lender.
- @return poolShare Lender’s share of the pool.
- @return claimedLpToken LP tokens already claimed.
- @return claimedInsurance Insurance already claimed.
- @return claimedAmount Stablecoin amount already claimed.
- @return isExists Whether lender record exists.
fn get_lender_details(
env: soroban_sdk::Env,
lender: soroban_sdk::Address,
) -> LenderDetails
fn update_im_receiver(
env: soroban_sdk::Env,
new_receiver: Option,
)
- @notice Returns borrower and funding details of a specific invoice.
*
- @param invoice_id Unique identifier of the invoice.
- @return borrower Borrower address linked to the invoice.
- @return principalAmount Total principal requested in the invoice.
- @return minAmount Minimum required funding amount.
- @return loanStartTime Timestamp when the loan started.
- @return isExists Whether the invoice record exists.
- @return amountAllocated Capital allocated from the pool to this invoice.
- @return repaidAmount Total amount repaid so far.
- @return fullyPaid Whether the invoice has been fully repaid.
- @return fundsReceived Whether borrower has received the funds.
fn get_invoice_details(
env: soroban_sdk::Env,
invoice_id: soroban_sdk::String,
) -> InvoiceDetails
- @notice Calculates the total repayment amount for a given invoice.
*
- @param invoice_id Unique identifier of the invoice.
- @return u128 The repayment amount.
fn get_total_repayment(env: soroban_sdk::Env, invoice_id: soroban_sdk::String) -> u128
fn emergency_close_pool(env: soroban_sdk::Env)
fn get_granted_invoices(env: soroban_sdk::Env) -> soroban_sdk::Vec
- @notice Updates the LP token contract address used in the pool.
- @dev Only callable by the treasury wallet. This function can be used in case
-
of contract upgrades, migrations, or if the LP token address needs to be changed.
-
Cannot be called after any funds have been raised (`AmountRaised > 0`).
- @param lp Address of the new LP token contract.
fn update_token_address(env: soroban_sdk::Env, lp: soroban_sdk::Address)
- @notice Returns the total claimable Insurance for a given lender.
- @param _lender Address of the lender whose claimable amount is queried.
- @return u128 The total claimable amount for the lender.
fn get_claimable_insurance(env: soroban_sdk::Env, lender: soroban_sdk::Address) -> u128
fn update_token_multiplier(env: soroban_sdk::Env, multiplier: u128)
- @notice Returns payment-related details of a specific invoice.
- @dev Excludes the nested
_invoiceRepaidAmount mapping.
- @param invoice_id Unique identifier of the invoice.
- @return _principalToRepay Principal amount that must be repaid.
- @return _apyToRepay Accrued APY to be repaid.
- @return _imApyToRepay Invoimate APY fee to be repaid.
- @return _isDefault Whether the invoice is marked as defaulted.
- @return _isInsured Whether the invoice is covered by insurance.
- @return _endTime End time (maturity) of the invoice.
- @return _amountInsured Amount covered under insurance for this invoice.
fn get_invocie_payment_details(
env: soroban_sdk::Env,
invoice_id: soroban_sdk::String,
) -> InvoicePaymentDetails