terra: fix tax calculation on withdraw_tokens
This commit is contained in:
parent
713b834f20
commit
98cb787512
|
@ -633,7 +633,7 @@ describe("Integration Tests", () => {
|
|||
{
|
||||
deposit_tokens: {},
|
||||
},
|
||||
{ ["uluna"]: "1" }
|
||||
{ uusd: "900000087654321" }
|
||||
);
|
||||
const feeEstimate = await lcd.tx.estimateFee(
|
||||
wallet.key.accAddress,
|
||||
|
@ -662,10 +662,10 @@ describe("Integration Tests", () => {
|
|||
{
|
||||
initiate_transfer: {
|
||||
asset: {
|
||||
amount: "10000",
|
||||
amount: "5900000087654321",
|
||||
info: {
|
||||
native_token: {
|
||||
denom: "uluna",
|
||||
denom: "uusd",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -696,7 +696,7 @@ describe("Integration Tests", () => {
|
|||
withdraw_tokens: {
|
||||
asset: {
|
||||
native_token: {
|
||||
denom: "uluna",
|
||||
denom: "uusd",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -295,19 +295,21 @@ fn withdraw_tokens(
|
|||
let mut messages: Vec<CosmosMsg> = vec![];
|
||||
if let AssetInfo::NativeToken { denom } = data {
|
||||
let deposit_key = format!("{}:{}", info.sender, denom);
|
||||
let mut deposited_amount: u128 = 0;
|
||||
bridge_deposit(deps.storage).update(
|
||||
deposit_key.as_bytes(),
|
||||
|current: Option<Uint128>| match current {
|
||||
Some(v) => {
|
||||
messages.push(CosmosMsg::Bank(BankMsg::Send {
|
||||
to_address: info.sender.to_string(),
|
||||
amount: vec![coin(v.u128(), &denom)],
|
||||
}));
|
||||
deposited_amount = v.u128();
|
||||
Ok(Uint128::new(0))
|
||||
}
|
||||
None => Err(StdError::generic_err("no deposit found to withdraw")),
|
||||
},
|
||||
)?;
|
||||
messages.push(CosmosMsg::Bank(BankMsg::Send {
|
||||
to_address: info.sender.to_string(),
|
||||
amount: coins_after_tax(deps, vec![coin(deposited_amount, &denom)])?,
|
||||
}));
|
||||
}
|
||||
|
||||
Ok(Response::new()
|
||||
|
|
Loading…
Reference in New Issue