osmosis-labs / osmosis-rust

Rust libraries for osmosis
Apache License 2.0
59 stars 52 forks source link

CreateDenom Fee #47

Closed triccs closed 1 year ago

triccs commented 1 year ago

How is the fee accounted for when creating a CosmosMsg from MsgCreateDenom? For example, if I call a function to create a denom and send the fee alongside it, where is the fee handled? If it isn't then the creation would error right?

iboss-ptk commented 1 year ago

Are you talking about tokenfactory, if it is then the fee will be deducted from funds sending from msg sender.

triccs commented 1 year ago

Thanks for responding @iboss-ptk . Yes I am but for example: If I'm sending funds to a a contract that uses tokenfactory, then that contract would need to also send those funds when calling CreateDenom. I don't see where that happens or where that could be added, unless the .into() adds the funds automatically?

iboss-ptk commented 1 year ago

TLDR; you don't need to do anything from contract side, only that msg sender needs to send enough funds for denom creation fee.


When you attach funds to cosmwasm execute msg, it invokes bank Send, from msg sender to contract. After that, in the same tx, with funds owned by contract, the it invokes CreateDenom with contract as creator. Then tokenfactory keeper will ask the creator (which is the contract) to fund community pool with amount = denom creation fee.

If the contract has enough funds, it should just consume those funds.

https://github.com/osmosis-labs/osmosis/blob/c960e4a6d443d8d0a434179312e86c99600faae9/x/tokenfactory/keeper/createdenom.go#L73-L86

triccs commented 1 year ago

Okay thank you! Seems like a chain interaction I’m not used to, makes sense though that the funds don’t need to be sent.