Search in sources :

Example 6 with Coin

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;
    }
}
Also used : Coin(wannabit.io.cosmostaion.model.type.Coin) BigDecimal(java.math.BigDecimal)

Example 7 with Coin

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;
    }
}
Also used : Coin(wannabit.io.cosmostaion.model.type.Coin) BigDecimal(java.math.BigDecimal)

Example 8 with Coin

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;
    }
}
Also used : Coin(wannabit.io.cosmostaion.model.type.Coin) BigDecimal(java.math.BigDecimal)

Example 9 with Coin

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);
}
Also used : Coin(wannabit.io.cosmostaion.model.type.Coin) BigDecimal(java.math.BigDecimal)

Example 10 with Coin

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;
}
Also used : Coin(wannabit.io.cosmostaion.model.type.Coin) ArrayList(java.util.ArrayList)

Aggregations

Coin (wannabit.io.cosmostaion.model.type.Coin)126 BigDecimal (java.math.BigDecimal)85 ArrayList (java.util.ArrayList)28 TextView (android.widget.TextView)27 CardView (androidx.cardview.widget.CardView)27 View (android.view.View)25 RecyclerView (androidx.recyclerview.widget.RecyclerView)17 Intent (android.content.Intent)15 Abci (cosmos.base.abci.v1beta1.Abci)13 ImageView (android.widget.ImageView)12 Matcher (java.util.regex.Matcher)12 Pattern (java.util.regex.Pattern)12 CoinOuterClass (cosmos.base.v1beta1.CoinOuterClass)9 SpannableString (android.text.SpannableString)6 Balance (wannabit.io.cosmostaion.dao.Balance)6 Date (java.util.Date)5 IbcToken (wannabit.io.cosmostaion.dao.IbcToken)5 Fee (wannabit.io.cosmostaion.model.type.Fee)5 Bundle (android.os.Bundle)4 Lock (osmosis.lockup.Lock)4