Skip to content

Commit

Permalink
refactor(finance): remove a redundant function at CoinDTO
Browse files Browse the repository at this point in the history
  • Loading branch information
Gancho Manev committed Sep 20, 2024
1 parent cd3666b commit a549f60
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 16 deletions.
9 changes: 0 additions & 9 deletions platform/packages/finance/src/coin/dto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,6 @@ where
}

pub fn with_coin<V>(&self, cmd: V) -> StdResult<V::Output, V::Error>
where
V: WithCoin<G>,
G: Group<TopG = G>,
{
self.currency
.into_currency_type(CoinTransformerAny::new(self, cmd))
}

pub fn with_super_coin<V>(&self, cmd: V) -> StdResult<V::Output, V::Error>
where
V: WithCoin<G>,
G: MemberOf<G>,
Expand Down
4 changes: 2 additions & 2 deletions platform/packages/finance/src/price/base/with_price.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ where
Cmd: WithPrice<QuoteC, PriceG = BaseG>,
Cmd::Error: From<Error>,
{
price.amount.with_super_coin(CoinResolve {
price.amount.with_coin(CoinResolve {
price: UncheckedConversion::<BaseG, QuoteC>(PhantomData, price.amount_quote),
cmd,
})
Expand All @@ -56,7 +56,7 @@ where
Cmd: WithPrice<QuoteC, PriceG = BaseG>,
Cmd::Error: From<Error>,
{
amount.with_super_coin(CoinResolve {
amount.with_coin(CoinResolve {
price: CheckedConversion::<BaseG, QuoteC>(PhantomData, amount_quote),
cmd,
})
Expand Down
2 changes: 1 addition & 1 deletion platform/packages/platform/src/coin_legacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ where
Ok(to_cosmwasm_on_network_impl::<C, S>(coin))
}
}
coin_dto.with_super_coin(CoinTransformer(PhantomData::<S>))
coin_dto.with_coin(CoinTransformer(PhantomData::<S>))
}

fn to_cosmwasm_on_network_impl<C, S>(coin: Coin<C>) -> CosmWasmCoin
Expand Down
2 changes: 1 addition & 1 deletion protocol/contracts/lease/src/position/dto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl PositionDTO {
.and_then(|position| self.cmd.on(position))
}
}
self.amount.with_super_coin(WithAmount {
self.amount.with_coin(WithAmount {
cmd,
spec: self.spec,
})
Expand Down
7 changes: 5 additions & 2 deletions protocol/contracts/oracle/src/contract/oracle/feed/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@ where
from,
to: SwapTarget { target: to, .. },
}| {
// TODO price.base().of_currency_dto(from) && ...
price.base().currency() == from && price.quote().currency() == to
price
.base()
.of_currency_dto(&from)
.and_then(|()| price.quote().of_currency_dto(&to))
.is_ok()
},
)
}) {
Expand Down
2 changes: 1 addition & 1 deletion protocol/packages/dex/src/impl_/transfer_in.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ where
}
}

payment.with_super_coin(CheckBalance::<G> {
payment.with_coin(CheckBalance::<G> {
account,
querier,
currency_g: PhantomData,
Expand Down

0 comments on commit a549f60

Please sign in to comment.