use of wannabit.io.cosmostaion.model.type.Coin in project cosmostation-android by cosmostation.
the class SifDexWithdrawStep0Fragment method isValidateAmount.
private boolean isValidateAmount() {
try {
BigDecimal amountTemp = new BigDecimal(mLpCoinInput.getText().toString().trim());
if (amountTemp.compareTo(BigDecimal.ZERO) <= 0)
return false;
if (amountTemp.compareTo(mAvailableMaxAmount.movePointLeft(mCoinDecimal).setScale(mCoinDecimal, RoundingMode.CEILING)) > 0)
return false;
getSActivity().mSifWithdrawCoin = new Coin(getSActivity().mMyProvider.getLiquidityProvider().getAsset().getSymbol(), amountTemp.movePointRight(mCoinDecimal).toPlainString());
return true;
} catch (Exception e) {
return false;
}
}
use of wannabit.io.cosmostaion.model.type.Coin in project cosmostation-android by cosmostation.
the class JoinPoolStep0Fragment method isValidateJoinPool.
private boolean isValidateJoinPool() {
try {
BigDecimal InputAmountTemp = new BigDecimal(mJoinPoolInput0.getText().toString().trim());
if (InputAmountTemp.compareTo(BigDecimal.ZERO) <= 0)
return false;
if (InputAmountTemp.compareTo(mAvailable0MaxAmount.movePointLeft(mCoin0Decimal).setScale(mCoin0Decimal, RoundingMode.CEILING)) > 0)
return false;
BigDecimal OutputAmountTemp = new BigDecimal(mJoinPoolInput1.getText().toString().trim());
if (OutputAmountTemp.compareTo(BigDecimal.ZERO) <= 0)
return false;
if (OutputAmountTemp.compareTo(mAvailable1MaxAmount.movePointLeft(mCoin1Decimal).setScale(mCoin1Decimal, RoundingMode.CEILING)) > 0)
return false;
getSActivity().mPoolCoin0 = new Coin(getSActivity().mOsmosisPool.getPoolAssets(0).getToken().getDenom(), InputAmountTemp.movePointRight(mCoin0Decimal).toPlainString());
getSActivity().mPoolCoin1 = new Coin(getSActivity().mOsmosisPool.getPoolAssets(1).getToken().getDenom(), OutputAmountTemp.movePointRight(mCoin1Decimal).toPlainString());
// Expected receiveing lp Token
BigDecimal originAmount = new BigDecimal(getSActivity().mOsmosisPool.getPoolAssets(0).getToken().getAmount());
BigDecimal addedAmount = originAmount.add(InputAmountTemp.movePointRight(mCoin0Decimal));
BigDecimal poolTotalShare = new BigDecimal(getSActivity().mOsmosisPool.getTotalShares().getAmount());
BigDecimal expectedLpTokenAmount = addedAmount.multiply(poolTotalShare).divide(originAmount, 0, RoundingMode.DOWN);
BigDecimal willReceieveLpTokenAmount = (expectedLpTokenAmount.subtract(poolTotalShare)).multiply(new BigDecimal("0.975")).setScale(0, RoundingMode.DOWN);
getSActivity().mLpToken = new Coin(getSActivity().mOsmosisPool.getTotalShares().getDenom(), willReceieveLpTokenAmount.toPlainString());
return true;
} catch (Exception e) {
return false;
}
}
use of wannabit.io.cosmostaion.model.type.Coin in project cosmostation-android by cosmostation.
the class StartLockStep0Fragment method isValidateAmount.
private boolean isValidateAmount() {
try {
BigDecimal amountTemp = new BigDecimal(mLpCoinInput.getText().toString().trim());
if (amountTemp.compareTo(BigDecimal.ZERO) <= 0)
return false;
if (amountTemp.compareTo(mAvailableMaxAmount.movePointLeft(mCoinDecimal).setScale(mCoinDecimal, RoundingMode.CEILING)) > 0)
return false;
getSActivity().mLpToken = new Coin(mLpDenom, amountTemp.movePointRight(mCoinDecimal).toPlainString());
return true;
} catch (Exception e) {
return false;
}
}
use of wannabit.io.cosmostaion.model.type.Coin in project cosmostation-android by cosmostation.
the class StartLockStep3Fragment method onRefreshTab.
@Override
public void onRefreshTab() {
mDpDecimal = WDp.mainDivideDecimal(getSActivity().mBaseChain);
BigDecimal feeAmount = new BigDecimal(getSActivity().mTxFee.amount.get(0).amount);
final Coin LpCoin = new Coin(getSActivity().mLpToken.denom, getSActivity().mLpToken.amount);
long UnbondingDuraion = getSActivity().mOsmosisLockupDuration;
mFeeAmount.setText(WDp.getDpAmount2(getContext(), feeAmount, mDpDecimal, mDpDecimal));
WDp.showCoinDp(getSActivity(), getBaseDao(), LpCoin, mLockCoinSymbol, mLockCoinAmount, BaseChain.OSMOSIS_MAIN);
if (UnbondingDuraion == 86400) {
mLockUnbondingDuraion.setText("1 Day");
} else if (UnbondingDuraion == 604800) {
mLockUnbondingDuraion.setText("7 Days");
} else if (UnbondingDuraion == 1209600) {
mLockUnbondingDuraion.setText("14 Days");
}
mMemo.setText(getSActivity().mTxMemo);
}
use of wannabit.io.cosmostaion.model.type.Coin in project cosmostation-android by cosmostation.
the class ResTxInfo method simpleIncentives.
public ArrayList<Coin> simpleIncentives(int position) {
ArrayList<Coin> coins = new ArrayList<>();
if (logs != null && logs.get(position) != null) {
for (Event event : logs.get(position).events) {
if (event.type.equals("claim_reward")) {
for (EventAttribute attr : event.attributes) {
if (attr.key.equals("claim_amount")) {
String value = attr.value;
String[] splits = value.split(",");
for (String split : splits) {
Coin incenCoin = new Coin(split.replaceAll("[0-9]", ""), split.replaceAll("[^0-9]", ""));
coins.add(incenCoin);
}
}
}
}
}
}
return coins;
}
Aggregations