osmosis-labs / isotonic

Smart Contracts for the Lendex Protocol
MIT License
1 stars 0 forks source link

Borrow and Repay B Tokens #7

Closed ethanfrey closed 2 years ago

ethanfrey commented 2 years ago

Requires https://github.com/confio/lendex/issues/6.

Add two more messages to the Market contract to "borrow" and "repay" B tokens.

#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
    /// X base_asset must be sent along with this message. If it matches, X b_token is burned from the sender address.
    /// If more was sent than needed to repay all debt, the excess is returned to the sender (this doesn't error)
    /// The underlying base_asset is stored in this Market contract
    Repay { },
    /// This requests to borrow amount base_asset in exchange for accepting amount B Tokens
    /// In the future we will do a check if this is allowed, for now, you can always allow.
    /// Dispatches two messages, one to mint amount B Token for this sender, and the other to send amount base asset to the sender.
    Borrow { amount: Uint128 },
}

There should be a placeholder function can_borrow(sender: &Addr, amount: Uint128) that always returns true now. This will later check if there is enough collateral to cover this debt.