[MRC-64] Auto Repay Loan Functionality

Summary

The objective of this proposal is to do an upgrade of the credit manager contract which enables auto-repay of borrows after a swap action, within the same transaction.

Currently the repay function requires the user to pass in an exact amount to repay. However when swapping an asset, you cannot accurately calculate how much of the “swap to" asset you will receive once accounting for slippage etc.
This update allows a user to specify they would like to repay the available account balance amount of an asset instead of a specific amount.

Motivation

Currently Mars enables the user to open a leveraged long or short position in one transaction. However to “close” this same position takes multiple transactions involving swapping assets and repaying debt on assets.

With this new change, users of Mars protocol will be able to close a margined trade position in one transaction via swapping from the current asset to the debt asset and repaying the account balance of the debt asset from within one transaction.

A UI upgrade is planned to accompany this smart contract upgrade that introduces an auto-repay toggle to the trading screen. If the user is swapping into an asset they have a debt balance of, they now have the option to auto-repay this debt in the same transaction.

Risks

This change introduces smart contract code changes, the risk in making changes to the smart contracts are that while the code changes are minor, new bugs or unforeseen situations as a result of the changes can occur.

Implementation

This upgrade introduces a new functionality to the repay and repay_for_recipient functions that allow the amount of “account_balance” to be passed in the amount argument. Passing this value to the mentioned functions will repay the maximum amount possible based on the users account balance.

The changes can be viewed in Release v2.0.2 · mars-protocol/contracts · GitHub

This is a signaling proposal, not an executable proposal.

The Mars smart contracts on the Osmosis chain are currently controlled by the Builder Multisig address. If this proposal passes, the builders will utilize their multisig to make the necessary parameter changes.

Copyright

Copyright and related rights waived via CC0.

Disclaimers/Disclosures

This proposal is being made by Delphi Labs Ltd., a British Virgin Islands limited company. Delphi Labs engages in incubation, investment, research and development relevant to multiple ecosystems and protocols, including the Mars Protocol. Delphi Labs and certain of its service providers and equity holders own MARS tokens and have financial interests related to this proposal. Additionally, Delphi Labs is one of several entities associated with one another under the “Delphi Digital” brand. Delphi Digital’s associated entities and/or equityholders or service providers of such entities may hold MARS and may have financial interests related to this proposal. All such entities, service providers, equity holders and other related persons may also have financial interests in complementary or competing projects or ecosystems, entities or tokens, including Osmosis/OSMO and Celestia/TIA. Delphi Ventures, a related company, is an investor in rights to receive TIA. These statements are intended to disclose relevant facts and to help identify potential conflicts of interest, and should not be misconstrued as a complete description of all relevant interests or conflicts of interests; nor should they be construed as a recommendation to purchase or acquire any token or security.

This proposal is also subject to and qualified by the Mars Disclaimers/Disclosures. Delphi Labs may lack access to all relevant facts or may have failed to give appropriate weighting to available facts. Delphi Labs is not making any representation, warranty or guarantee regarding the accuracy or completeness of the statements herein, and Delphi Labs shall have no liability in the event of losses or damages ensuing from approval or rejection or other handling of the proposal. Each user and voter should undertake their own research and make their own independent interpretation and analysis of all relevant facts and issues to arrive at their own personal determinations of how to vote on the proposal.