Skip to content
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

v2 #11

Merged
merged 116 commits into from
Sep 7, 2023
Merged

v2 #11

merged 116 commits into from
Sep 7, 2023

Conversation

iboss-ptk
Copy link
Collaborator

@iboss-ptk iboss-ptk commented Jun 20, 2023

@iboss-ptk iboss-ptk added the v2 label Jun 20, 2023
@iboss-ptk iboss-ptk marked this pull request as ready for review September 4, 2023 09:06

/// get the alloyed denom
pub fn get_alloyed_denom(&self, store: &dyn Storage) -> StdResult<String> {
self.alloyed_denom.load(store)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I generally like this pattern, but I'm thinking that it may lead to loads happening multiple times if the caller uses several get methods.

Not release-blocker, but we can consider caching these (if the data is there return it, otherwise fetch)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea! on it

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(just remember to reset the cache on sets! :p )

@@ -128,13 +346,44 @@ impl Transmuter<'_> {
&self,
ctx: (DepsMut, Env, MessageInfo),
tokens_out: Vec<Coin>,
) -> Result<Response, ContractError> {
self.swap_alloyed_asset_for_tokens("exit_pool", ctx, tokens_out)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These being join/exit pool confused me at first, but I get it now

let alloyed_denom = self.alloyed_asset.get_alloyed_denom(deps.storage)?;

// if funds contains one coin and is alloyed asset, use that as sender's share
let (sender_shares, burn_from_address) = if info.funds.is_empty() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain these two blocks of code?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohh, this is what makes it work as both exit_pool and swap. Maybe just add some comments for each block

// --- admin ---

#[msg(exec)]
pub fn transfer_admin(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not transmuter specific, but there are a few patterns that we keep using. It would be good to make sylvia interfaces that we can reuse on all osmosis contracts

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, I think this is simlilar to openzeppelin Ownable, we might wanna have our own collection.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

100%! we could even add some osmosis-specific stuff behind compilation flags (so they're only included when needed)

@iboss-ptk iboss-ptk merged commit 6bce8f8 into main Sep 7, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants