CosmosContracts / bounties

MIT License
25 stars 12 forks source link

solution for bounty 1,2,3 using a smart contract #17

Closed catShaark closed 1 year ago

catShaark commented 2 years ago

I make this smart contract which can be deployed on osmosis, this contract can effectively solve all the problems mentioned in bounty 1,2,3

catShaark commented 2 years ago

This contract doesn't use ica, it instead uses wasmd ibc with custom ibc packet. The logic of this contract is inspired by ica, with the contract account holding funds and can only be controlled by ibc packet sent from smart contracts on a remote chain. Upon receiving a valid ibc packet, the contract will MsgSwapExactAmountIn using the fund of its account and then MsgSend the out amount to the address specified in the ibc packet, just like what happens if using ica account controlled by remote contract. However, This proves to be better than using ica since wasmd can fetch random data from the chain, which can be used for the contract logic providing better functionality. For example, with using ica, their is no way of knowing out amount of osmo from swapping 5 token X, this value is needed for the MsgSend after MsgSwapExactAmountIn. Therefore, users must specify exactly how much osmo they get from swapping, and they will get exactly that specified amount of osmo (that specified amount must be smaller than or equal to the actual out amount from swapping). Using this contract in the other hand, it can query the actual out amount from swapping, thus user always get the exact amount of osmo they can get from swapping.

catShaark commented 2 years ago

So I've made 2 different contracts as solutions for bounty 1,2,3, each with slightly different logic. The first one is here and the second one is here. I prefer the second one as it is much better

JakeHartnell commented 2 years ago

Very cool! I think we may have multiple winners for this bounty, cool to see the different approaches everyone is taking.

Have you tried deploying it Osmosis testnet?

@dimiandre, have a look when you get a chance.

catShaark commented 2 years ago

I haven't deployed it on osmosis testnet

catShaark commented 2 years ago

This contract of mine needs fund to work so I come up with this idea. This might be useful in the future when the community wants to fund useful utility contract on foreign chain like osmosis

JakeHartnell commented 1 year ago

Closing for now, keep working on IBC contracts!