Skip to content

Commit

Permalink
Properly place liquidity mining functions in cpk service (#2234)
Browse files Browse the repository at this point in the history
* fix: place liquidity mining cpk functions in proper location

* style: make function type headers more obvious
  • Loading branch information
kadenzipfel authored Aug 31, 2021
1 parent 763d9c9 commit b0b9a3e
Showing 1 changed file with 75 additions and 71 deletions.
146 changes: 75 additions & 71 deletions app/src/services/cpk/cpk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -551,7 +622,9 @@ class CPKService {
}

/**
* Getters
* =======
* GETTERS
* =======
*/

fetchLatestUnclaimedTransactions = async () => {
Expand Down Expand Up @@ -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 }

0 comments on commit b0b9a3e

Please sign in to comment.