-
Notifications
You must be signed in to change notification settings - Fork 608
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
feat/spike: CosmWasm Pool Type and Module #4675
Conversation
registry.RegisterInterface( | ||
"osmosis.poolmanager.v1beta1.PoolI", | ||
(*poolmanagertypes.PoolI)(nil), | ||
&CosmWasmPool{}, | ||
) | ||
registry.RegisterInterface( | ||
"osmosis.cosmwasmpool.v1beta1.CosmWasmExtension", | ||
(*types.CosmWasmExtension)(nil), | ||
&CosmWasmPool{}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code block is the reason why fdc16a4 is needed.
I'm open to suggestions on how to reduce the need for the boilerplate in fdc16a4
The way this works is that there is a proto-generated CosmWasmPool
model that is written to state. It only implements PoolI
and CosmWasmExtensions
for registering interfaces.
There is also a Go struct wrapper Pool
. It is not proto-generated because it must contain WasmKeeper
for interacting with the contract. As a result, I'm unable to RegisterInterface
s for Pool
and have to rely on the verbose hack in fdc16a4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What to do with the creatorAddress in InitializePool?
creatorAddress
should essentially be the same as contract initiator I suppose? Unless I'm missing anything.
referring to question asked in Slack:
Use Go mocks for the wasmKeeper and contractKeeper to mock out the responses of instantiate msg, query msg and sudo msg in tests
- I think this makes a lot of sense for as unit tests
What is the ETA on the contract that I can use for testing this?
- I will make transmuter conform pool interface within this week. Will quickly release and document new beaker features and back to this task :)
please also refer to:
#4389 (comment)
fdc16a4
to
8804f74
Compare
x/cosmwasmpool/pool_module_test.go
Outdated
// Assert that pool and swapper balances are changes | ||
// TODO / Question for Boss: this check is failint because the originalPoolBalance is empty. | ||
// I would expect it to equal to coins that were added to the pool in the beginning of the test | ||
// via the join pool message (tc.initialCoins). | ||
expectedPoolBalances := originalPoolBalances.Add(tc.tokenIn).Sub(sdk.NewCoins(tc.expectedTokenOut)) | ||
afterSwapPoolBalances := s.App.BankKeeper.GetAllBalances(s.Ctx, sdk.AccAddress(pool.GetContractAddress())) | ||
|
||
s.Require().Equal(expectedPoolBalances.String(), afterSwapPoolBalances.String()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iboss-ptk it seems to me that pool's balances are not updated upon joining the pool. Should this be handles inside a contract? That is when a user executes join message via contract, the pool's balance is updated with the joined tokens?
69e638c
to
7e5c034
Compare
d229d1c
to
2594331
Compare
This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. Thank you! |
… into roman/cosmwasm-pool
Closing in favor of: #5327 |
Closes: #4389
What is the purpose of the change
The CosmWasm Pool Module is an extension for the Osmosis pools, aiming to create a custom module that allows users to create and manage liquidity pools backed by CosmWasm smart contracts. The feature enables developers to build and deploy custom smart contracts that can be integrated with the rest of the pool types on the Osmosis chain.
The module is built on top of the CosmWasm smart contracting platform, which provides a secure and efficient way to develop and execute WebAssembly (Wasm) smart contracts on the Cosmos SDK.
Having pools in CosmWasm provides several benefits, one of which is avoiding the need for chain upgrades when introducing new functionalities or modifying existing ones related to liquidity pools. This advantage is particularly important in the context of speed of development and iteration.
An example of a CosmWasm pool type: https://github.com/osmosis-labs/transmuter
Brief Changelog
cosmwasmpool
cosmwasmpool
implementpoolmanagertypes.PoolModule
x/cosmwasm/model.Pool
of typepoolmanagertypes.CosmWasm
poolmanagertypes.PoolI
MsgCreateCosmWasmPool
cosmwasmpool.Keeper.InitializePool
CosmWasmExtension
PoolI
andCosmWasm
extension methodspoolmanagertypes.PoolModule
transmuter
poolTesting and Verifying
TBD after getting concept-ACK from @iboss-ptk
Open Quesitons
What to do with the
creatorAddress
inInitializePool
?How to resolve codec issues around
PoolI
Currently, getting the following:
The reason is because the struct implementing
PoolI
is a Go Struct. This is done so thatPool
struct can have a field forWasmKeeper
. Otherwise, the pool struct is unable to interact with the contract for querying spot price and other pool operations.UPDATE: #4675 (comment)
Documentation and Release Note
Unreleased
section inCHANGELOG.md
? TBD