Skip to main content

Refunds

Refunds are only allowed during the fundraising period, and only if the company decides to cancel the project's fundraising. This can happen, for example, when the company determines that the capital raised is far from the target and unlikely to be reached within the remaining funding time.

The refund_investor function

The admin can refund a position through:

  • refund_investor(token_id)
stellar contract invoke \
--id <YOUR_CONTRACT_ID> \
-s operator \
--network testnet \
-- \
refund_investor \
--token_id 1234

Refunds are only valid if:

  • the position exists
  • the position is not completed
  • the refund amount is non-zero
  • current time is still before ts_fundraising_ends

Worked example

The refund amount is:

deposited + commission

For the worked example of the previous section:

497.72 + 2.27 = 499.99 -> 500

The position is then marked as completed and aggregate accounting is adjusted.

If you call the "refund_investor" function and observe the result, you can check that the user is refunded exactly with the amount sent, that is, 500_0000000.

Events and balance after a refund

When an investor is refunded because the project's fundraising is cancelled, the contract updates the balance through recalculate_from_refunded_to_investor:

  • project is reduced by the position's deposited amount
  • comission is reduced by the position's commission amount
  • refunded_to_investor is increased by the sum of deposited and commission
  • payment_obligations is reduced by the position's outstanding amount (total - paid)

This update is published through the standard ContractBalanceUpdated event (see Fundraising and positions section above), reflecting the new balance snapshot after the refund.

In addition to the balance update, the contract emits a dedicated event with the refund details:

InvestmentDepositRefunded:

InvestmentDepositRefunded {
addr, // the address of the contract
to, // the operator address the deposit is refunded to
amount, // the total amount refunded
}

Reading this event with stellar-cli

stellar events \
--id <YOUR_CONTRACT_ID> \
--network testnet \
--start-ledger <LEDGER_NUMBER> \
--type contract \
--topic "InvestmentDepositRefunded,*"