diff --git a/app/src/services/cpk/cpk.ts b/app/src/services/cpk/cpk.ts index 96e8c6c89..3aef7a1d0 100644 --- a/app/src/services/cpk/cpk.ts +++ b/app/src/services/cpk/cpk.ts @@ -475,8 +475,79 @@ class CPKService { } } + depositAndStake = async (params: CPKDepositAndStakeParams) => { + try { + const { transaction } = await this.pipe(fee, wrap, approve, deposit, addFunds, approveCampaign, stake)(params) + return transaction + } catch (err) { + logger.error(`There was an error depositing and staking liquidity`, err.message) + throw err + } + } + + stakePoolTokens = async (params: CPKStakePoolTokensParams) => { + try { + const { transaction } = await this.pipe(fee, approveCampaign, stake)(params) + return transaction + } catch (err) { + logger.error('Failed to stake pool tokens', err.message) + throw err + } + } + + unstakePoolTokens = async (params: CPKUnstakePoolTokensParams) => { + try { + const { transaction } = await this.pipe(fee, unstake)(params) + return transaction + } catch (err) { + logger.error('Failed to withdraw staked pool tokens', err.message) + throw err + } + } + + claimRewardTokens = async (campaignAddress: string) => { + try { + const { transaction } = await this.pipe(fee, claim, withdrawRewards)({ campaignAddress }) + return transaction + } catch (err) { + logger.error('Failed to claim reward tokens', err.message) + throw err + } + } + + unstakeClaimAndWithdraw = async (params: CPKUnstakeClaimAndWithdrawParams) => { + try { + const { transaction } = await this.pipe( + fee, + claim, + unstake, + wrangleRemoveFundsParams, + removeFunds, + unwrap, + withdraw, + withdrawRewards, + )(params) + return transaction + } catch (err) { + logger.error('There was an error unstaking, claiming and withdrawing funding', err.message) + throw err + } + } + + unstakeAndClaim = async (campaignAddress: string) => { + try { + const { transaction } = await this.pipe(fee, exitStaking, withdrawRewards)({ campaignAddress }) + return transaction + } catch (err) { + logger.error('There was an error unstaking, claiming and withdrawing funding', err.message) + throw err + } + } + /** - * Direct transactions + * =================== + * DIRECT TRANSACTIONS + * =================== */ sendMainnetTokenToBridge = async (amount: BigNumber, address: string, symbol?: string) => { @@ -551,7 +622,9 @@ class CPKService { } /** - * Getters + * ======= + * GETTERS + * ======= */ fetchLatestUnclaimedTransactions = async () => { @@ -594,75 +667,6 @@ class CPKService { } return true } - - depositAndStake = async (params: CPKDepositAndStakeParams) => { - try { - const { transaction } = await this.pipe(fee, wrap, approve, deposit, addFunds, approveCampaign, stake)(params) - return transaction - } catch (err) { - logger.error(`There was an error depositing and staking liquidity`, err.message) - throw err - } - } - - stakePoolTokens = async (params: CPKStakePoolTokensParams) => { - try { - const { transaction } = await this.pipe(fee, approveCampaign, stake)(params) - return transaction - } catch (err) { - logger.error('Failed to stake pool tokens', err.message) - throw err - } - } - - unstakePoolTokens = async (params: CPKUnstakePoolTokensParams) => { - try { - const { transaction } = await this.pipe(fee, unstake)(params) - return transaction - } catch (err) { - logger.error('Failed to withdraw staked pool tokens', err.message) - throw err - } - } - - claimRewardTokens = async (campaignAddress: string) => { - try { - const { transaction } = await this.pipe(fee, claim, withdrawRewards)({ campaignAddress }) - return transaction - } catch (err) { - logger.error('Failed to claim reward tokens', err.message) - throw err - } - } - - unstakeClaimAndWithdraw = async (params: CPKUnstakeClaimAndWithdrawParams) => { - try { - const { transaction } = await this.pipe( - fee, - claim, - unstake, - wrangleRemoveFundsParams, - removeFunds, - unwrap, - withdraw, - withdrawRewards, - )(params) - return transaction - } catch (err) { - logger.error('There was an error unstaking, claiming and withdrawing funding', err.message) - throw err - } - } - - unstakeAndClaim = async (campaignAddress: string) => { - try { - const { transaction } = await this.pipe(fee, exitStaking, withdrawRewards)({ campaignAddress }) - return transaction - } catch (err) { - logger.error('There was an error unstaking, claiming and withdrawing funding', err.message) - throw err - } - } } export { CPKService }