Skip to content
This repository was archived by the owner on Apr 11, 2023. It is now read-only.
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 0 additions & 50 deletions packages/investor-foxy/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import {
TokeClaimIpfs,
TokenAddressInput,
TxInput,
TxInputWithoutAmount,
TxInputWithoutAmountAndWallet,
TxReceipt,
WithdrawEstimateGasInput,
Expand Down Expand Up @@ -264,22 +263,6 @@ export class FoxyApi {
}
}

async estimateSendWithdrawalRequestsGas(input: TxInputWithoutAmountAndWallet): Promise<string> {
const { userAddress, contractAddress } = input
this.verifyAddresses([userAddress, contractAddress])

const stakingContract = this.getStakingContract(contractAddress)

try {
const estimatedGas = await stakingContract.estimateGas.sendWithdrawalRequests([], {
from: userAddress,
})
return estimatedGas.toString()
} catch (e) {
throw new Error(`Failed to get gas ${e}`)
}
}

async estimateAddLiquidityGas(input: EstimateGasTxInput): Promise<string> {
const { amountDesiredCryptoBaseUnit, userAddress, contractAddress } = input
this.verifyAddresses([userAddress, contractAddress])
Expand Down Expand Up @@ -717,39 +700,6 @@ export class FoxyApi {
return isTimeToRequest && isCorrectIndex && hasAmount
}

async sendWithdrawalRequests(input: TxInputWithoutAmount): Promise<string> {
const { bip44Params, dryRun = false, contractAddress, userAddress, wallet } = input
this.verifyAddresses([userAddress, contractAddress])
if (!wallet || !contractAddress) throw new Error('Missing inputs')

let estimatedGas: string
try {
estimatedGas = await this.estimateSendWithdrawalRequestsGas(input)
} catch (e) {
throw new Error(`Estimate Gas Error: ${e}`)
}

const stakingContract = this.getStakingContract(contractAddress)

const canSendRequest = await this.canSendWithdrawalRequest({ stakingContract })
if (!canSendRequest) throw new Error('Not ready to send request')

const data: string = stakingContract.interface.encodeFunctionData('sendWithdrawalRequests')
const { nonce, gasPrice } = await this.getGasPriceAndNonce(userAddress)
const chainReferenceAsNumber = Number(this.ethereumChainReference)
const payload = {
bip44Params,
chainId: chainReferenceAsNumber,
data,
estimatedGas,
gasPrice,
nonce,
to: contractAddress,
value: '0',
}
return this.signAndBroadcastTx({ payload, wallet, dryRun })
}

// not a user facing function
// utility function for the dao to add liquidity to the lrContract for instantUnstaking
async addLiquidity(input: TxInput): Promise<string> {
Expand Down