use of wannabit.io.cosmostaion.utils.OsmosisGaugeWrapper in project cosmostation-android by cosmostation.
the class EarningOtherHolder method onBindView.
public void onBindView(Context c, BaseActivity activity, BaseData baseData, BalancerPoolOuterClass.BalancerPool pool, ArrayList<Lock.PeriodLock> lockups, ArrayList<GaugeOuterClass.Gauge> gauges) {
Coin coin0 = new Coin(pool.getPoolAssets(0).getToken().getDenom(), pool.getPoolAssets(0).getToken().getAmount());
Coin coin1 = new Coin(pool.getPoolAssets(1).getToken().getDenom(), pool.getPoolAssets(1).getToken().getAmount());
BigDecimal lpCoinPrice = WUtil.getOsmoLpTokenPerUsdPrice(baseData, pool);
BigDecimal apr = WUtil.getPoolArp(baseData, pool, gauges, 2);
itemPoolId.setText("#" + pool.getId() + " EARNING");
itemPoolCoinPair.setText(WUtil.dpOsmosisTokenName(baseData, coin0.denom) + " / " + WUtil.dpOsmosisTokenName(baseData, coin1.denom));
itemPoolApr.setText(WDp.getPercentDp(apr));
// display available
BigDecimal availableAmount = baseData.getAvailable("gamm/pool/" + pool.getId());
BigDecimal availableValue = availableAmount.multiply(lpCoinPrice).movePointLeft(18).setScale(2, RoundingMode.DOWN);
itemAvailableAmount.setText(WDp.getDpAmount2(c, availableAmount, 18, 6));
itemAvailableDenom.setText("GAMM-" + pool.getId());
itemAvailableValue.setText(WDp.getDpRawDollor(c, availableValue, 2));
itemRoot.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(activity, EarningDetailActivity.class);
intent.putExtra("osmosisPool", pool.toByteArray());
OsmosisGaugeWrapper gaugesWrapper = new OsmosisGaugeWrapper(gauges);
intent.putExtra("osmosisGauges", gaugesWrapper);
OsmosisPeriodLockWrapper lockupsWrapper = new OsmosisPeriodLockWrapper(lockups);
intent.putExtra("osmosislockups", lockupsWrapper);
activity.startActivity(intent);
}
});
}
use of wannabit.io.cosmostaion.utils.OsmosisGaugeWrapper in project cosmostation-android by cosmostation.
the class EarningDetailActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_earning_detail);
mToolbar = findViewById(R.id.tool_bar);
mRecyclerView = findViewById(R.id.recycler);
mBtnNewEarning = findViewById(R.id.btn_start_earning);
mPoolIdTv = findViewById(R.id.pool_id);
mPoolCoinPairTv = findViewById(R.id.coin_pair);
mPoolAprsTv1 = findViewById(R.id.aprs1);
mPoolAprsTv7 = findViewById(R.id.aprs7);
mPoolAprsTv14 = findViewById(R.id.aprs14);
mAvailableAmountTv = findViewById(R.id.available_amount);
mAvailableDenomTv = findViewById(R.id.available_denom);
mAvailableValueTv = findViewById(R.id.available_value);
setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mAccount = getBaseDao().onSelectAccount(getBaseDao().getLastUser());
mBaseChain = BaseChain.getChain(mAccount.baseChain);
try {
mPool = BalancerPool.Pool.parseFrom(getIntent().getByteArrayExtra("osmosisPool"));
OsmosisGaugeWrapper gaugeWrapper = (OsmosisGaugeWrapper) getIntent().getSerializableExtra("osmosisGauges");
if (gaugeWrapper != null) {
mGauges = gaugeWrapper.array;
}
OsmosisPeriodLockWrapper lockupWrapper = (OsmosisPeriodLockWrapper) getIntent().getSerializableExtra("osmosislockups");
if (lockupWrapper != null) {
mLockUps = lockupWrapper.array;
}
} catch (Exception e) {
WLog.w("Passing bundle Error");
}
// display top card data
Coin coin0 = new Coin(mPool.getPoolAssets(0).getToken().getDenom(), mPool.getPoolAssets(0).getToken().getAmount());
Coin coin1 = new Coin(mPool.getPoolAssets(1).getToken().getDenom(), mPool.getPoolAssets(1).getToken().getAmount());
BigDecimal lpCoinPrice = WUtil.getOsmoLpTokenPerUsdPrice(getBaseDao(), mPool);
BigDecimal apr1 = WUtil.getPoolArp(getBaseDao(), mPool, mGauges, 0);
BigDecimal apr7 = WUtil.getPoolArp(getBaseDao(), mPool, mGauges, 1);
BigDecimal apr14 = WUtil.getPoolArp(getBaseDao(), mPool, mGauges, 2);
if (mLockUps.size() > 0) {
mPoolIdTv.setText("#" + mPool.getId() + " MY EARNING");
mPoolIdTv.setTextColor(getResources().getColor(R.color.colorOsmosis));
} else {
mPoolIdTv.setText("#" + mPool.getId() + " EARNING");
}
mPoolCoinPairTv.setText(WUtil.dpOsmosisTokenName(getBaseDao(), coin0.denom) + " / " + WUtil.dpOsmosisTokenName(getBaseDao(), coin1.denom));
mPoolAprsTv1.setText(WDp.getPercentDp(apr1));
mPoolAprsTv7.setText(WDp.getPercentDp(apr7));
mPoolAprsTv14.setText(WDp.getPercentDp(apr14));
BigDecimal availableAmount = getBaseDao().getAvailable("gamm/pool/" + mPool.getId());
BigDecimal availableValue = availableAmount.multiply(lpCoinPrice).movePointLeft(18).setScale(2, RoundingMode.DOWN);
mAvailableAmountTv.setText(WDp.getDpAmount2(getBaseContext(), availableAmount, 18, 18));
mAvailableDenomTv.setText("GAMM-" + mPool.getId());
mAvailableValueTv.setText(WDp.getDpRawDollor(getBaseContext(), availableValue, 2));
// display recycler
for (Lock.PeriodLock lockup : mLockUps) {
long now = new Date().getTime();
long endTime = lockup.getEndTime().getSeconds() * 1000;
if (endTime == -62135596800000l) {
mBondedList.add(lockup);
} else if (endTime > now) {
mUnbondingList.add(lockup);
} else {
mUnbondedList.add(lockup);
}
}
mRecyclerView.setLayoutManager(new LinearLayoutManager(getBaseContext(), LinearLayoutManager.VERTICAL, false));
mRecyclerView.setHasFixedSize(true);
mAdapter = new EarningDetailsAdapter();
mRecyclerView.setAdapter(mAdapter);
mRecyclerViewHeader = new RecyclerViewHeader(EarningDetailActivity.this, true, getSectionCall());
mRecyclerView.addItemDecoration(mRecyclerViewHeader);
mBtnNewEarning.setOnClickListener(this);
}
use of wannabit.io.cosmostaion.utils.OsmosisGaugeWrapper in project cosmostation-android by cosmostation.
the class EarningMyHolder method onBindView.
public void onBindView(Context c, BaseActivity activity, BaseData baseData, BalancerPool.Pool pool, ArrayList<Lock.PeriodLock> lockups, ArrayList<GaugeOuterClass.Gauge> gauges) {
Coin coin0 = new Coin(pool.getPoolAssets(0).getToken().getDenom(), pool.getPoolAssets(0).getToken().getAmount());
Coin coin1 = new Coin(pool.getPoolAssets(1).getToken().getDenom(), pool.getPoolAssets(1).getToken().getAmount());
BigDecimal lpCoinPrice = WUtil.getOsmoLpTokenPerUsdPrice(baseData, pool);
BigDecimal apr = WUtil.getPoolArp(baseData, pool, gauges, 2);
BigDecimal totalShare = new BigDecimal(pool.getTotalShares().getAmount());
itemPoolId.setText("#" + pool.getId() + " MY EARNING");
itemPoolCoinPair.setText(WUtil.dpOsmosisTokenName(baseData, coin0.denom) + " / " + WUtil.dpOsmosisTokenName(baseData, coin1.denom));
itemPoolApr.setText(WDp.getPercentDp(apr));
// pool incentives
BigDecimal incentive1Day = WUtil.getNextIncentiveAmount(gauges, 0);
BigDecimal incentive7Day = WUtil.getNextIncentiveAmount(gauges, 1);
BigDecimal incentive14Day = WUtil.getNextIncentiveAmount(gauges, 2);
// display lock
BigDecimal bondedAmount = BigDecimal.ZERO;
BigDecimal unbondingAmount = BigDecimal.ZERO;
BigDecimal unbondedAmount = BigDecimal.ZERO;
BigDecimal myRewards = BigDecimal.ZERO;
for (Lock.PeriodLock lockup : lockups) {
Coin lpCoin = new Coin(lockup.getCoins(0).getDenom(), lockup.getCoins(0).getAmount());
BigDecimal myShare = new BigDecimal(lpCoin.amount);
BigDecimal myShareRate = myShare.divide(totalShare, 24, RoundingMode.DOWN);
long now = new Date().getTime();
long day7 = now + 604800000;
long endTime = lockup.getEndTime().getSeconds() * 1000;
if (endTime == -62135596800000l) {
bondedAmount = bondedAmount.add(new BigDecimal(lpCoin.amount));
if (lockup.getDuration().getSeconds() == 86400) {
myRewards = myRewards.add(myShareRate.multiply(incentive1Day));
} else if (lockup.getDuration().getSeconds() == 604800) {
myRewards = myRewards.add(myShareRate.multiply(incentive7Day));
} else if (lockup.getDuration().getSeconds() == 1209600) {
myRewards = myRewards.add(myShareRate.multiply(incentive14Day));
}
} else if (endTime > now) {
unbondingAmount = unbondingAmount.add(new BigDecimal(lpCoin.amount));
if (lockup.getEndTime().getSeconds() > day7) {
myRewards = myRewards.add(myShareRate.multiply(incentive7Day));
} else {
myRewards = myRewards.add(myShareRate.multiply(incentive1Day));
}
} else {
unbondedAmount = unbondedAmount.add(new BigDecimal(lpCoin.amount));
myRewards = myRewards.add(myShareRate.multiply(incentive1Day));
}
}
itemBondedAmount.setText(WDp.getDpAmount2(c, bondedAmount, 18, 6));
itemBondedDenom.setText("GAMM-" + pool.getId());
itemUnBondingAmount.setText(WDp.getDpAmount2(c, unbondingAmount, 18, 6));
itemUnBondingDenom.setText("GAMM-" + pool.getId());
itemUnBondedAmount.setText(WDp.getDpAmount2(c, unbondedAmount, 18, 6));
itemUnBondedDenom.setText("GAMM-" + pool.getId());
BigDecimal bonedCoinValue = bondedAmount.multiply(lpCoinPrice).movePointLeft(18).setScale(2, RoundingMode.DOWN);
itemBondedValue.setText(WDp.getDpRawDollor(c, bonedCoinValue, 2));
BigDecimal unbondingCoinValue = unbondingAmount.multiply(lpCoinPrice).movePointLeft(18).setScale(2, RoundingMode.DOWN);
itemUnBondingValue.setText(WDp.getDpRawDollor(c, unbondingCoinValue, 2));
BigDecimal unbondedCoinValue = unbondedAmount.multiply(lpCoinPrice).movePointLeft(18).setScale(2, RoundingMode.DOWN);
itemUnBondedValue.setText(WDp.getDpRawDollor(c, unbondedCoinValue, 2));
// display available
BigDecimal availableAmount = baseData.getAvailable("gamm/pool/" + pool.getId());
BigDecimal availableValue = availableAmount.multiply(lpCoinPrice).movePointLeft(18).setScale(2, RoundingMode.DOWN);
itemAvailableAmount.setText(WDp.getDpAmount2(c, availableAmount, 18, 6));
itemAvailableDenom.setText("GAMM-" + pool.getId());
itemAvailableValue.setText(WDp.getDpRawDollor(c, availableValue, 2));
// display reward
itemRewardAmount.setText(WDp.getDpAmount2(c, myRewards, 6, 6));
itemRoot.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(activity, EarningDetailActivity.class);
intent.putExtra("osmosisPool", pool.toByteArray());
OsmosisGaugeWrapper gaugesWrapper = new OsmosisGaugeWrapper(gauges);
intent.putExtra("osmosisGauges", gaugesWrapper);
OsmosisPeriodLockWrapper lockupsWrapper = new OsmosisPeriodLockWrapper(lockups);
intent.putExtra("osmosislockups", lockupsWrapper);
activity.startActivity(intent);
}
});
}
use of wannabit.io.cosmostaion.utils.OsmosisGaugeWrapper in project cosmostation-android by cosmostation.
the class EarningOtherHolder method onBindView.
public void onBindView(Context c, BaseActivity activity, BaseData baseData, BalancerPool.Pool pool, ArrayList<Lock.PeriodLock> lockups, ArrayList<GaugeOuterClass.Gauge> gauges) {
Coin coin0 = new Coin(pool.getPoolAssets(0).getToken().getDenom(), pool.getPoolAssets(0).getToken().getAmount());
Coin coin1 = new Coin(pool.getPoolAssets(1).getToken().getDenom(), pool.getPoolAssets(1).getToken().getAmount());
BigDecimal lpCoinPrice = WUtil.getOsmoLpTokenPerUsdPrice(baseData, pool);
BigDecimal apr = WUtil.getPoolArp(baseData, pool, gauges, 2);
itemPoolId.setText("#" + pool.getId() + " EARNING");
itemPoolCoinPair.setText(WUtil.dpOsmosisTokenName(baseData, coin0.denom) + " / " + WUtil.dpOsmosisTokenName(baseData, coin1.denom));
itemPoolApr.setText(WDp.getPercentDp(apr));
// display available
BigDecimal availableAmount = baseData.getAvailable("gamm/pool/" + pool.getId());
BigDecimal availableValue = availableAmount.multiply(lpCoinPrice).movePointLeft(18).setScale(2, RoundingMode.DOWN);
itemAvailableAmount.setText(WDp.getDpAmount2(c, availableAmount, 18, 6));
itemAvailableDenom.setText("GAMM-" + pool.getId());
itemAvailableValue.setText(WDp.getDpRawDollor(c, availableValue, 2));
itemRoot.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(activity, EarningDetailActivity.class);
intent.putExtra("osmosisPool", pool.toByteArray());
OsmosisGaugeWrapper gaugesWrapper = new OsmosisGaugeWrapper(gauges);
intent.putExtra("osmosisGauges", gaugesWrapper);
OsmosisPeriodLockWrapper lockupsWrapper = new OsmosisPeriodLockWrapper(lockups);
intent.putExtra("osmosislockups", lockupsWrapper);
activity.startActivity(intent);
}
});
}
use of wannabit.io.cosmostaion.utils.OsmosisGaugeWrapper in project cosmostation-android by cosmostation.
the class EarningMyHolder method onBindView.
public void onBindView(Context c, BaseActivity activity, BaseData baseData, BalancerPoolOuterClass.BalancerPool pool, ArrayList<Lock.PeriodLock> lockups, ArrayList<GaugeOuterClass.Gauge> gauges) {
Coin coin0 = new Coin(pool.getPoolAssets(0).getToken().getDenom(), pool.getPoolAssets(0).getToken().getAmount());
Coin coin1 = new Coin(pool.getPoolAssets(1).getToken().getDenom(), pool.getPoolAssets(1).getToken().getAmount());
BigDecimal lpCoinPrice = WUtil.getOsmoLpTokenPerUsdPrice(baseData, pool);
BigDecimal apr = WUtil.getPoolArp(baseData, pool, gauges, 2);
BigDecimal totalShare = new BigDecimal(pool.getTotalShares().getAmount());
itemPoolId.setText("#" + pool.getId() + " MY EARNING");
itemPoolCoinPair.setText(WUtil.dpOsmosisTokenName(baseData, coin0.denom) + " / " + WUtil.dpOsmosisTokenName(baseData, coin1.denom));
itemPoolApr.setText(WDp.getPercentDp(apr));
// pool incentives
BigDecimal incentive1Day = WUtil.getNextIncentiveAmount(gauges, 0);
BigDecimal incentive7Day = WUtil.getNextIncentiveAmount(gauges, 1);
BigDecimal incentive14Day = WUtil.getNextIncentiveAmount(gauges, 2);
// display lock
BigDecimal bondedAmount = BigDecimal.ZERO;
BigDecimal unbondingAmount = BigDecimal.ZERO;
BigDecimal unbondedAmount = BigDecimal.ZERO;
BigDecimal myRewards = BigDecimal.ZERO;
for (Lock.PeriodLock lockup : lockups) {
Coin lpCoin = new Coin(lockup.getCoins(0).getDenom(), lockup.getCoins(0).getAmount());
BigDecimal myShare = new BigDecimal(lpCoin.amount);
BigDecimal myShareRate = myShare.divide(totalShare, 24, RoundingMode.DOWN);
long now = new Date().getTime();
long day7 = now + 604800000;
long endTime = lockup.getEndTime().getSeconds() * 1000;
if (endTime == -62135596800000l) {
bondedAmount = bondedAmount.add(new BigDecimal(lpCoin.amount));
if (lockup.getDuration().getSeconds() == 86400) {
myRewards = myRewards.add(myShareRate.multiply(incentive1Day));
} else if (lockup.getDuration().getSeconds() == 604800) {
myRewards = myRewards.add(myShareRate.multiply(incentive7Day));
} else if (lockup.getDuration().getSeconds() == 1209600) {
myRewards = myRewards.add(myShareRate.multiply(incentive14Day));
}
} else if (endTime > now) {
unbondingAmount = unbondingAmount.add(new BigDecimal(lpCoin.amount));
if (lockup.getEndTime().getSeconds() > day7) {
myRewards = myRewards.add(myShareRate.multiply(incentive7Day));
} else {
myRewards = myRewards.add(myShareRate.multiply(incentive1Day));
}
} else {
unbondedAmount = unbondedAmount.add(new BigDecimal(lpCoin.amount));
myRewards = myRewards.add(myShareRate.multiply(incentive1Day));
}
}
itemBondedAmount.setText(WDp.getDpAmount2(c, bondedAmount, 18, 6));
itemBondedDenom.setText("GAMM-" + pool.getId());
itemUnBondingAmount.setText(WDp.getDpAmount2(c, unbondingAmount, 18, 6));
itemUnBondingDenom.setText("GAMM-" + pool.getId());
itemUnBondedAmount.setText(WDp.getDpAmount2(c, unbondedAmount, 18, 6));
itemUnBondedDenom.setText("GAMM-" + pool.getId());
BigDecimal bonedCoinValue = bondedAmount.multiply(lpCoinPrice).movePointLeft(18).setScale(2, RoundingMode.DOWN);
itemBondedValue.setText(WDp.getDpRawDollor(c, bonedCoinValue, 2));
BigDecimal unbondingCoinValue = unbondingAmount.multiply(lpCoinPrice).movePointLeft(18).setScale(2, RoundingMode.DOWN);
itemUnBondingValue.setText(WDp.getDpRawDollor(c, unbondingCoinValue, 2));
BigDecimal unbondedCoinValue = unbondedAmount.multiply(lpCoinPrice).movePointLeft(18).setScale(2, RoundingMode.DOWN);
itemUnBondedValue.setText(WDp.getDpRawDollor(c, unbondedCoinValue, 2));
// display available
BigDecimal availableAmount = baseData.getAvailable("gamm/pool/" + pool.getId());
BigDecimal availableValue = availableAmount.multiply(lpCoinPrice).movePointLeft(18).setScale(2, RoundingMode.DOWN);
itemAvailableAmount.setText(WDp.getDpAmount2(c, availableAmount, 18, 6));
itemAvailableDenom.setText("GAMM-" + pool.getId());
itemAvailableValue.setText(WDp.getDpRawDollor(c, availableValue, 2));
// display reward
itemRewardAmount.setText(WDp.getDpAmount2(c, myRewards, 6, 6));
itemRoot.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(activity, EarningDetailActivity.class);
intent.putExtra("osmosisPool", pool.toByteArray());
OsmosisGaugeWrapper gaugesWrapper = new OsmosisGaugeWrapper(gauges);
intent.putExtra("osmosisGauges", gaugesWrapper);
OsmosisPeriodLockWrapper lockupsWrapper = new OsmosisPeriodLockWrapper(lockups);
intent.putExtra("osmosislockups", lockupsWrapper);
activity.startActivity(intent);
}
});
}
Aggregations