implement loan default detection background job#92
Open
khaylebfortune wants to merge 1 commit into
Open
Conversation
- Add DefaultDetectionProcessor (@Cron '0 * * * *') that queries active loans past grace period, builds mark_defaulted XDR, signs with admin keypair, submits via transactions service, updates DB status, and clears reputation cache - Add buildMarkDefaultedTx to CreditLineContractClient - Add LOAN_DEFAULT to TransactionType enum - Register JobsModule in app.module.ts with required dependencies Closes StepFi-app#71
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the missing default detection background job that automatically detects loans past their grace period and marks them as defaulted.
Changes
New Files
src/jobs/default-detection.processor.ts— Cron job (@Cron('0 * * * *'), every hour) that:next_payment_due + 7 days < now()mark_defaulted(loan_id)XDR viaCreditLineContractClient.buildMarkDefaultedTx()STELLAR_ADMIN_SECRET(server-side keypair)TransactionsService.submitTransaction()defaultedwithdefaulted_attimestampreputation_cacheso next read picks up on-chain scoresrc/jobs/jobs.module.ts— Module registering the processor with itsStellarModuleandTransactionsModuledependenciesModified Files
src/stellar/contracts/clients/creditline.client.ts— AddedbuildMarkDefaultedTx(loanId)that builds an unsigned Soroban XDR callingmark_defaultedon the creditline contract (followsbuildRepayLoanTxpattern)src/stellar/contracts/interfaces/creditline.interface.ts— AddedbuildMarkDefaultedTxtoICreditLineClientinterfacesrc/modules/transactions/dto/submit-transaction-request.dto.ts— AddedLOAN_DEFAULT = 'loan_default'toTransactionTypeenumsrc/app.module.ts— ImportedJobsModule.env.example— AddedSTELLAR_ADMIN_SECRETenv var documentationAcceptance Criteria
@Cron('0 * * * *'))next_payment_due)mark_defaultedon-chain via prepared XDRdefaultedVerification
npm run build— passesnpm run test— 24 suites, 288 tests, all passingCloses #71