Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement credit deal auto-repayment feature #2735

Merged
merged 29 commits into from
Apr 19, 2023

Conversation

abitmore
Copy link
Member

@abitmore abitmore commented Mar 22, 2023

PR for #2595.

Changes:

  • Add enum class credit_deal_auto_repayment_type

     /// Defines automatic repayment types
     enum class credit_deal_auto_repayment_type
     {  
        /// Do not repay automatically
        no_auto_repayment = 0,
        /// Automatically repay fully when and only when the account balance is sufficient
        only_full_repayment = 1,
        /// Automatically repay as much as possible using available account balance
        allow_partial_repayment = 2,
        /// Total number of available automatic repayment types
        CDAR_TYPE_COUNT = 3
     };
    
  • Update type of extensions field of credit_offer_accept_operation struct, add an auto_repay field inside, so that accounts can decide whether and how to automatically repay when accepting a credit offer

     struct credit_offer_accept_operation : public base_operation
     {  
        struct ext
        {  
           /// After the core-2595 hard fork, the account can specify whether and how to automatically repay
           fc::optional<uint8_t> auto_repay;
        };
        asset                    fee;                ///< Operation fee
        account_id_type          borrower;           ///< The account who accepts the offer
        credit_offer_id_type     offer_id;           ///< ID of the credit offer
        asset                    borrow_amount;      ///< The amount to borrow
        asset                    collateral;         ///< The collateral
        uint32_t                 max_fee_rate = 0;   ///< The maximum acceptable fee rate
        uint32_t                 min_duration_seconds = 0; ///< The minimum acceptable duration
        extension<ext> extensions; ///< Extensions
     };
    
  • New operation: credit_deal_update_operation, so that credit deal owners can change whether or how to automatically repay

    • operation_type = 76
    • default fee 1 BTS
     struct credit_deal_update_operation : public base_operation
     {
        struct fee_params_t { uint64_t fee = 1 * GRAPHENE_BLOCKCHAIN_PRECISION; };
    
        asset                    fee;                ///< Operation fee
        account_id_type          account;            ///< The account who owns the credit deal
        credit_deal_id_type      deal_id;            ///< ID of the credit deal
        uint8_t                  auto_repay;         ///< The specified automatic repayment type
        extensions_type extensions;  ///< Unused. Reserved for future use.
     };
    
  • Rename all fee_parameters_type in the codebase to fee_params_t to get around the "string table overflow" issue in MinGW build

abitmore and others added 17 commits March 23, 2023 22:36
Remove SonarCloud cache and threads configuration as it is now by default
Remove SonarCloud cache and threads configuration as it is now by default
for better coverage reporting, including branch coverage
Type "long" is not reflected in macOS, so avoid using it implicitly in tests
Use gcovr to process code coverage data
…6-2-x

Update sonar.projectVersion to 6.2.x
For branch coverage, exclude branches that the compiler generates for
exception handling, to generate more "sensible" coverage reports.
Update code coverage report settings in sonar-scan overflow
Resolved conflicts:
- sonar-project.properties
@sonarcloud
Copy link

sonarcloud bot commented Apr 19, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

82.6% 82.6% Coverage
0.0% 0.0% Duplication

@abitmore abitmore merged commit d441b3e into hardfork Apr 19, 2023
@abitmore abitmore deleted the pr-2595-credit-auto-repay branch April 19, 2023 19:43
This was referenced Jun 24, 2023
@abitmore abitmore mentioned this pull request Jul 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants