osmosis-labs / isotonic

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

Define APIs to accept cw20 and native #69

Closed ethanfrey closed 2 years ago

ethanfrey commented 2 years ago

Right now we only work with native tokens.

In the future, we may want "super fluid" staking derivatives as collateral. These would most likely be cw20 tokens.

We could extend the API in such a way that this would not be breaking, but not adding this functionality yet. (For example rather than storing Coin in some API, we could return enum Balance{ Native(Coin), Token(Cw20Coin) } Or actually, only return enum Balance{ Native(Coin)} But with a shape that Balance::Token would not break the APIs (or maybe make final APIs and return error on Balance::Token?

uint commented 2 years ago

So basically think of an extendable abstraction layer for coins without actually implementing cw20 or anything yet, right? Makes sense.

We will need this for LP tokens I imagine.

ethanfrey commented 2 years ago

LP tokens are also native tokens. If we do some staking derivatives stuff, that would be cw20.

We have this abstraction in a number of places already. cw20-escrow is a good example. @maurolacy should be able to help with links to where this is used (and I think there is a generic Balance/Cw20Coin type in packages/cw20)