osmosis-labs / isotonic

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

Instantiate Market contract #16

Closed ueco-jb closed 2 years ago

ueco-jb commented 2 years ago

Second part of https://github.com/confio/lendex/issues/5 to avoid new contract's boilerplate.

closes #5

ethanfrey commented 2 years ago

Can you please rebase now that #18 is merged?

This also gives some multitest setup that may be useful to extend to test the market contract as controller.

ethanfrey commented 2 years ago

With the passing test, we are getting close.

One issue not mentioned here is the controller (market) needs to support a TransferableAmount Query:

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ControllerQuery {
    TransferableAmount {
        /// Lendex contract address that calls "CanTransfer"
        token: String,
        /// Address that wishes to transfer
        account: String,
    },
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct TransferableAmountResp {
    pub transferable: Uint128,
}

(from lendex-token/src/msg.rs)

ethanfrey commented 2 years ago

As a first draft, this implementation should:

(1) if token == btoken, return 0 (non-transferable) (2) if token == ltoken, return full balance of ltoken (query that contract for balance) (3) else, return error (unknown token or such)

But I guess you can't really test it until minting is implemented here https://github.com/confio/lendex/issues/6, but it would be good to have some code to handle this, even if unimplemented!() so we remember this needs to be done

ueco-jb commented 2 years ago

@ethanfrey I included query with full implementation.