Query Swap Input Amount

Calculate the required input amount to achieve a target output amount before executing a swap on PancakeSwap. This involves calling the Router's getAmountsIn function with the desired output amount and token path.

Query how much {{token_in_symbol}} is needed to get exactly {{amount_out}} {{token_out_symbol}} on PancakeSwap

Calculate the input amount required to receive {{amount_out}} {{token_out_symbol}} when swapping from {{token_in_symbol}}

Check how much {{token_in_symbol}} tokens are needed to get {{amount_out}} {{token_out_symbol}} via PancakeSwap Router at {{router_address}}

Get the required input amount for swapping to receive exactly {{amount_out}} {{token_out_symbol}}, starting from {{token_in_symbol}}

Desired output amount (in token units, not wei)

PancakeSwap V2 Router address

Input token address (USDT)

Input token decimals

Input token symbol

Output token address (BUSD)

Output token decimals

Output token symbol

Input amount does not match expected value

Understand how to use PancakeSwap Router's getAmountsIn function

Learn to calculate required input amount for a target output

Master reverse swap calculation with path arrays

Understand the importance of slippage consideration in DeFi swaps

PancakeSwap V2 Router address

Input token address (USDT)

Input token decimals

Input token symbol

Output token address (BUSD)

Output token decimals

Output token symbol

Query Swap Input Amount


Query Swap Output Amount

Query the expected output amount for a token swap before executing the trade

Calculate how much {token_out_symbol} you will receive for {amount_in} {token_in_symbol} on PancakeSwap

Query the output amount for swapping {amount_in} {token_in_symbol} to {token_out_symbol}

Get the estimated output for a {token_in_symbol} to {token_out_symbol} swap with input amount {amount_in}

What is the expected output for swapping {amount_in} {token_in_symbol} for {token_out_symbol}?

Input amount in tokens

Random input amount between 10-100 tokens

PancakeSwap Router contract address

PancakeSwap Router V2

Input token address

USDT as input token

Input token decimals

Input token symbol

Output token address

BUSD as output token

Output token decimals

Output token symbol

Query executed successfully

Return format correct (includes amounts array)

Output amount matches expected value from router

Query swap output amounts using getAmountsOut()

Parse array return values from smart contracts

Calculate expected output before executing trades

Input amount in tokens

PancakeSwap Router contract address

PancakeSwap Router V2

Input token address

USDT as input token

Input token decimals

Input token symbol

Output token address

BUSD as output token

Output token decimals

Output token symbol

Query Swap Output Amount

Query executed successfully


PancakeSwap Swap - BNB to Token

Swap BNB for ERC20 tokens using PancakeSwap V2 Router's swapExactETHForTokens function.

Technical context:
- PancakeSwap V2 Router (BSC Mainnet): 0x10ED43C718714eb63d5aA57B78B54704E256024E
- Function signature: swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts)
- This is a payable function that requires sending BNB with the transaction
- The swap follows Uniswap V2 AMM (Automated Market Maker) model: x * y = k
- Function selector: 0x7ff36ab5
- Recommended gas limit: 200000

Key considerations:
- amountOutMin: Minimum amount of tokens to receive (slippage protection)
- path: Array of token addresses for the swap route [WBNB, TOKEN]
- to: Recipient address (usually the sender/agent address)
- deadline: Unix timestamp after which the transaction will revert
- Must set transaction 'value' field to the BNB amount being swapped
- WBNB address on BSC: 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c

Slippage protection:
- Calculate amountOutMin using getAmountsOut or apply a percentage (2-5% typical)
- Formula: amountOutMin = expectedOutput * (1 - slippagePercent)
- For testing, can use 0 for amountOutMin (accepts any output)

Success criteria:
- Transaction executes successfully
- Correct PancakeSwap Router is called
- BNB balance decreases by amountIn (plus gas)
- Token balance increases by at least amountOutMin

Swap {amount_in} BNB for {token_symbol} tokens on PancakeSwap

Exchange {amount_in} BNB to {token_symbol} using PancakeSwap Router

Convert {amount_in} BNB to {token_symbol} tokens through PancakeSwap V2

Trade {amount_in} BNB for {token_symbol} on PancakeSwap with {slippage}% slippage tolerance

Amount of BNB to swap

PancakeSwap V2 Router contract address

Slippage tolerance percentage

Target token to receive (USDT by default)

USDT on BSC

Token decimal places

Token symbol for display

WBNB address (wrapped BNB)

Transaction executed successfully

Correct PancakeSwap Router called

Correct function swapExactETHForTokens called

BNB balance decreased by swap amount (plus gas)

Token balance increased (received output tokens)

Agent must have sufficient BNB balance (amount + gas)

Requires understanding of payable functions

Technical context:

- Function selector: 0x7ff36ab5

- Recommended gas limit: 200000

Key considerations:

Slippage protection:

Success criteria:

- Transaction executes successfully

- Correct PancakeSwap Router is called

Amount of BNB to swap

PancakeSwap V2 Router contract address

Slippage tolerance percentage

USDT on BSC

Token decimal places

Token symbol for display

WBNB address (wrapped BNB)

PancakeSwap Swap - BNB to Token

Transaction executed successfully

Correct PancakeSwap Router called


PancakeSwap Swap - Token to BNB

Swap ERC20 tokens for BNB using PancakeSwap V2 Router's swapExactTokensForETH function.

Technical context:
- PancakeSwap V2 Router (BSC Mainnet): 0x10ED43C718714eb63d5aA57B78B54704E256024E
- Function signature: swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts)
- This function requires prior token approval to the Router contract
- The swap follows Uniswap V2 AMM (Automated Market Maker) model: x * y = k
- Function selector: 0x18cbafe5
- Recommended gas limit: 180000

Key considerations:
- MUST approve tokens to Router before calling swap function
- amountIn: Exact amount of tokens to swap
- amountOutMin: Minimum amount of BNB to receive (slippage protection)
- path: Array of token addresses for the swap route [TOKEN, WBNB]
- to: Recipient address (usually the sender/agent address)
- deadline: Unix timestamp after which the transaction will revert
- WBNB address on BSC: 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c

Two-step process:
1. Call approve(router, amountIn) on the token contract
2. Call swapExactTokensForETH on the router contract

Slippage protection:
- Calculate amountOutMin using getAmountsOut or apply a percentage (2-5% typical)
- Formula: amountOutMin = expectedOutput * (1 - slippagePercent)
- For testing, can use 0 for amountOutMin (accepts any output)

Success criteria:
- Transaction executes successfully
- Correct PancakeSwap Router is called
- Token balance decreases by amountIn
- BNB balance increases by at least amountOutMin (minus gas)

Swap {amount_in} {token_symbol} for BNB on PancakeSwap

Exchange {amount_in} {token_symbol} to BNB using PancakeSwap Router

Convert {amount_in} {token_symbol} tokens to BNB through PancakeSwap V2

Trade {amount_in} {token_symbol} for BNB on PancakeSwap with {slippage}% slippage tolerance

Amount of tokens to swap

PancakeSwap V2 Router contract address

Slippage tolerance percentage

Input token to swap (USDT by default)

USDT on BSC

Token decimal places

Token symbol for display

WBNB address (wrapped BNB)

Transaction executed successfully

Token approved to Router (or approval check passed)

Correct PancakeSwap Router called

Correct function swapExactTokensForETH called

Token balance decreased by swap amount

BNB balance increased (received output BNB minus gas)

Agent must have sufficient token balance

Requires understanding of token approval mechanism

Must handle BNB balance change correctly (minus gas)

Technical context:

- Function selector: 0x18cbafe5

- Recommended gas limit: 180000

Key considerations:

Two-step process:

Slippage protection:

Success criteria:

- Transaction executes successfully

- Correct PancakeSwap Router is called

- Token balance decreases by amountIn

Amount of tokens to swap

PancakeSwap V2 Router contract address

Slippage tolerance percentage

Input token to swap (USDT by default)

USDT on BSC

Token decimal places

Token symbol for display

WBNB address (wrapped BNB)

PancakeSwap Swap - Token to BNB

Transaction executed successfully

Correct PancakeSwap Router called

Token balance decreased by swap amount


PancakeSwap Swap - Token to Token

Swap one ERC20 token for another using PancakeSwap V2 Router's swapExactTokensForTokens function.

Technical context:
- PancakeSwap V2 Router (BSC Mainnet): 0x10ED43C718714eb63d5aA57B78B54704E256024E
- Function signature: swapExactTokensForTokens(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts)
- This function requires prior token approval to the Router contract
- The swap follows Uniswap V2 AMM (Automated Market Maker) model: x * y = k
- Function selector: 0x38ed1739
- Recommended gas limit: 200000

Key considerations:
- MUST approve input tokens to Router before calling swap function
- amountIn: Exact amount of input tokens to swap
- amountOutMin: Minimum amount of output tokens to receive (slippage protection)
- path: Array of token addresses for the swap route
- to: Recipient address (usually the sender/agent address)
- deadline: Unix timestamp after which the transaction will revert

Swap path considerations:
- Direct path: [TOKEN_IN, TOKEN_OUT] if liquidity pool exists
- Multi-hop path: [TOKEN_IN, WBNB, TOKEN_OUT] if direct pool doesn't exist or has low liquidity
- WBNB address on BSC: 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c
- Most token pairs route through WBNB for better liquidity

Two-step process:
1. Call approve(router, amountIn) on the input token contract
2. Call swapExactTokensForTokens on the router contract

Slippage protection:
- Calculate amountOutMin using getAmountsOut or apply a percentage (2-5% typical)
- Formula: amountOutMin = expectedOutput * (1 - slippagePercent)
- For testing, can use 0 for amountOutMin (accepts any output)

Success criteria:
- Transaction executes successfully
- Correct PancakeSwap Router is called
- Input token balance decreases by amountIn
- Output token balance increases by at least amountOutMin

Swap {amount_in} {token_in_symbol} for {token_out_symbol} on PancakeSwap

Exchange {amount_in} {token_in_symbol} to {token_out_symbol} using PancakeSwap Router

Convert {amount_in} {token_in_symbol} tokens to {token_out_symbol} through PancakeSwap V2

Trade {amount_in} {token_in_symbol} for {token_out_symbol} on PancakeSwap with {slippage}% slippage tolerance

Amount of input tokens to swap

PancakeSwap V2 Router contract address

Slippage tolerance percentage

Input token to swap (USDT by default)

USDT on BSC

Input token decimal places

Input token symbol for display

Output token to receive (BUSD by default)

BUSD on BSC

Output token decimal places

Output token symbol for display

WBNB address (for multi-hop routing)

Transaction executed successfully

Input token approved to Router (or approval check passed)

Correct PancakeSwap Router called

Correct function swapExactTokensForTokens called

Input token balance decreased by swap amount

Output token balance increased (received output tokens)

Agent must have sufficient input token balance

Technical context:

- Function selector: 0x38ed1739

- Recommended gas limit: 200000

Key considerations:

Swap path considerations:

Two-step process:

Slippage protection:

Success criteria:

- Transaction executes successfully

- Correct PancakeSwap Router is called

Amount of input tokens to swap

PancakeSwap V2 Router contract address

Slippage tolerance percentage

Input token to swap (USDT by default)

USDT on BSC

Input token decimal places

Input token symbol for display

BUSD on BSC

Output token decimal places

Output token symbol for display

WBNB address (for multi-hop routing)

PancakeSwap Swap - Token to Token

Transaction executed successfully

Correct PancakeSwap Router called


PancakeSwap Multi-hop Routing Swap

Execute a multi-hop token swap on PancakeSwap Router V2. This operation involves swapping tokens through multiple intermediate tokens to achieve better liquidity and pricing. The swap path must be: CAKE → WBNB → USDT → BUSD (4 tokens). You must use the exact input amount specified in the task. Call getAmountsOut() first to estimate output amounts, then calculate amountOutMin with slippage tolerance. Use swapExactTokensForTokens function with the complete 4-token path.

Swap {amount_in} {token_start_symbol} for {token_end_symbol} on PancakeSwap using a multi-hop routing path through WBNB and USDT

Execute a multi-hop token swap: exchange {amount_in} {token_start_symbol} to {token_end_symbol} via intermediate tokens for better liquidity

Perform a complex token swap on PancakeSwap: {amount_in} {token_start_symbol} → WBNB → USDT → {token_end_symbol}

Use PancakeSwap Router to swap {amount_in} {token_start_symbol} for {token_end_symbol} with optimal multi-hop routing

Amount of starting tokens to swap (in human-readable format, e.g., 1.5)

PancakeSwap Router V2 contract address

Maximum acceptable slippage percentage (e.g., 5.0 for 5%)

Ending token address (last token in the path)

Ending token decimals

Ending token symbol

Starting token address (first token in the path)

Starting token decimals

Starting token symbol

USDT address (intermediate token)

Wrapped BNB address (intermediate token)

Transaction must be successfully executed and confirmed

Starting token must have been approved for Router (or have existing allowance)

Must interact with PancakeSwap Router contract

Must call swapExactTokensForTokens function

Starting token balance must decrease by the specified amount

Ending token balance must increase (accounting for slippage)

Must use the complete multi-hop path (3+ hops)

Incorrect path order or missing intermediate tokens

Understanding multi-hop routing in DEXes

Optimizing swap paths for better liquidity

Calculating aggregate slippage across multiple hops

Understanding liquidity pools and pair relationships

PancakeSwap Router V2 contract address

Ending token decimals

Ending token symbol

Starting token decimals

Starting token symbol

USDT address (intermediate token)

Test account must have sufficient starting token balance

Sufficient liquidity must exist for each pair in the multi-hop path

Starting token must be approved for PancakeSwap Router

PancakeSwap Multi-hop Routing Swap


PancakeSwap Swap - Exact Output (Token to Token)

Swap tokens to receive an exact amount of output tokens using PancakeSwap V2 Router's swapTokensForExactTokens function.

Technical context:
- PancakeSwap V2 Router (BSC Mainnet): 0x10ED43C718714eb63d5aA57B78B54704E256024E
- Function signature: swapTokensForExactTokens(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts)
- This is an EXACT OUTPUT swap (opposite of exact input)
- The swap follows Uniswap V2 AMM (Automated Market Maker) model: x * y = k
- Function selector: 0x8803dbee
- Recommended gas limit: 200000

Key considerations:
- amountOut: EXACT amount of output tokens desired (user specifies this)
- amountInMax: MAXIMUM amount of input tokens willing to spend (slippage protection)
- path: Array of token addresses for the swap route
- to: Recipient address (usually the sender/agent address)
- deadline: Unix timestamp after which the transaction will revert
- MUST approve sufficient tokens (at least amountInMax) to Router

Exact output vs exact input:
- Exact input: You know how much you're selling, output is variable
- Exact output: You know how much you want to buy, input is variable (up to amountInMax)
- This function is useful when you need a precise amount of output tokens
- Example: Buying exactly 100 USDT to pay for something

Two-step process:
1. Call getAmountsIn(amountOut, path) to estimate required input
2. Calculate amountInMax with slippage tolerance
3. Approve amountInMax (or more) to Router
4. Call swapTokensForExactTokens on the router contract

Slippage protection:
- Calculate amountInMax using getAmountsIn and apply slippage
- Formula: amountInMax = expectedInput * (1 + slippagePercent)
- The actual input used will be <= amountInMax
- For testing, can set high amountInMax to accept any input cost

Success criteria:
- Transaction executes successfully
- Correct PancakeSwap Router is called
- Output token balance increases by EXACTLY amountOut
- Input token balance decreases by <= amountInMax

Swap tokens to get exactly {amount_out} {token_out_symbol} on PancakeSwap

Exchange tokens for precisely {amount_out} {token_out_symbol} using PancakeSwap Router

Buy exactly {amount_out} {token_out_symbol} with {token_in_symbol} through PancakeSwap V2

Trade {token_in_symbol} for exactly {amount_out} {token_out_symbol} on PancakeSwap with {slippage}% max slippage

Exact amount of output tokens to receive

PancakeSwap V2 Router contract address

Slippage tolerance percentage (for amountInMax calculation)

Input token to spend (USDT by default)

USDT on BSC

Input token decimal places

Input token symbol for display

Output token to receive (BUSD by default)

BUSD on BSC

Output token decimal places

Output token symbol for display

WBNB address (for multi-hop routing)

Transaction executed successfully

Input token approved to Router with sufficient amount

Correct PancakeSwap Router called

Correct function swapTokensForExactTokens called

Output token balance increased by EXACTLY amountOut

Input token balance decreased within acceptable range

Agent must have sufficient input token balance to cover amountInMax

Requires understanding of exact output swaps (opposite of exact input)

Must calculate amountInMax correctly using getAmountsIn

Approval must cover the maximum possible input (amountInMax)

More complex slippage calculation (input side, not output side)

Must validate exact output amount received

Input amount validation requires range check (not exact match)

Technical context:

- Function selector: 0x8803dbee

- Recommended gas limit: 200000

Key considerations:

Exact output vs exact input:

Two-step process:

Slippage protection:

Success criteria:

- Transaction executes successfully

- Correct PancakeSwap Router is called

PancakeSwap V2 Router contract address

Input token to spend (USDT by default)

USDT on BSC

Input token decimal places

Input token symbol for display

BUSD on BSC

Output token decimal places

Output token symbol for display

WBNB address (for multi-hop routing)

Transaction executed successfully

Correct PancakeSwap Router called


Emergency Withdraw from Staking Pool

Emergency withdraw all staked LP tokens from a farming pool, forfeiting all accumulated rewards. This is an emergency function to quickly retrieve staked assets without claiming rewards.

IMPORTANT: This is a SimpleRewardPool contract with emergencyWithdraw() function.
- Contract function: emergencyWithdraw() - NO PARAMETERS
- This function withdraws ALL staked LP tokens
- All pending rewards are FORFEITED (not claimed)
- User's staking record is completely cleared
- This is faster and uses less gas than normal withdraw

Required steps:
1. Query current staked amount: rewardPool.userInfo(user_address)
2. Query current LP token balance: lpToken.balanceOf(user_address)
3. Call emergencyWithdraw: rewardPool.emergencyWithdraw()
4. Verify ALL LP tokens are returned
5. Verify staked amount becomes 0
6. Verify rewards are NOT claimed (CAKE balance should not increase)

Contract details:
- SimpleRewardPool contract address: pool_address (dynamic parameter)
- Staking token: USDT/BUSD LP (0x7EFaEf62fDdCCa950418312c6C91Aef321375A00)
- Emergency withdraw function signature: emergencyWithdraw()
- NO amount parameter - withdraws everything
- Rewards are forfeited - this is the trade-off for emergency speed

To get the pool address from deployed contracts:
const poolAddress = deployedContracts['simple_reward_pool']

Function call construction:
```typescript
const SimpleRewardPoolABI = [
  'function emergencyWithdraw() external'
];
const contract = new Contract interface(poolAddress, SimpleRewardPoolABI, provider);
const data = encode the function call('emergencyWithdraw', []);
```

Common mistakes to avoid:
- DO NOT pass any parameters to emergencyWithdraw()
- DO understand that rewards will be lost
- DO verify that CAKE balance does NOT increase (rewards forfeited)
- This is meant for emergency situations only

Emergency withdraw all staked LP tokens from the pool at {pool_address}

Quickly retrieve all LP tokens from staking pool {pool_address} (forfeit rewards)

Execute emergency withdrawal from farming pool {pool_address}

Unstake all USDT/BUSD LP tokens immediately, forfeiting CAKE rewards

Blockchain network ID (56 for BSC Mainnet)

LP token address (USDT/BUSD pair)

SimpleRewardPool contract address

Reward token address (CAKE)

User's wallet address

PancakeSwap Token (CAKE)

function balanceOf(address account) external view returns (uint256)

SimpleRewardPool

function userInfo(address _user) external view returns (uint256 amount, uint256 rewardDebt)

Required steps:

4. Verify ALL LP tokens are returned

5. Verify staked amount becomes 0

Contract details:

Function call construction:

```typescript

const SimpleRewardPoolABI = [

'function emergencyWithdraw() external'

Common mistakes to avoid:

User's LP token balance increases by entire staked amount

User's CAKE balance does NOT increase (rewards forfeited)

Call emergencyWithdraw() with NO parameters

This withdraws ALL staked tokens at once

Rewards are forfeited - CAKE balance should not increase

Verify userInfo shows 0 staked amount after transaction

This is faster than normal withdraw but you lose rewards

LP token address (USDT/BUSD pair)

SimpleRewardPool contract address

Reward token address (CAKE)

User's wallet address

Emergency Withdraw from Staking Pool

All staked LP tokens returned to user

Rewards NOT claimed (CAKE balance unchanged)

User's staking record cleared (amount = 0)

Transaction executed successfully without reverting


Harvest Farming Rewards

Harvest (claim) accumulated farming rewards from a staking pool. This operation collects the rewards earned from staking without unstaking the principal.

IMPORTANT: This is a SimpleRewardPool contract with a harvest() function.
- Contract function: harvest() - NO PARAMETERS
- This function claims all pending rewards for the caller
- The pool_address parameter is the SimpleRewardPool contract address
- Rewards are paid in CAKE tokens

Required steps:
1. Query pending rewards: rewardPool.pendingReward(user_address)
2. Check current CAKE balance: cakeToken.balanceOf(user_address)
3. Call harvest to claim rewards: rewardPool.harvest()
4. Verify CAKE balance increased

Contract details:
- SimpleRewardPool contract address: pool_address (dynamic parameter)
- Reward token: CAKE (0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82)
- Harvest function signature: harvest() - no parameters

To get the pool address from deployed contracts:
const poolAddress = deployedContracts['simple_reward_pool']

Function call construction:
```typescript
const SimpleRewardPoolABI = [
  'function harvest() external'
];
const contract = new Contract interface(poolAddress, SimpleRewardPoolABI, provider);
const data = encode the function call('harvest', []);
```

Common mistakes to avoid:
- DO NOT pass any parameters to harvest() - it's a parameterless function
- DO ensure you have pending rewards before harvesting
- DO check the reward token (CAKE) balance before and after

Harvest farming rewards from the pool at {pool_address}

Claim accumulated rewards from the farming pool

Collect farming rewards without unstaking

Harvest CAKE rewards from the staking pool

SimpleRewardPool contract address

Reward token address (CAKE)

User's wallet address

PancakeSwap Token (CAKE)

function transfer(address to, uint256 amount) external returns (bool)

SimpleRewardPool

function pendingReward(address _user) external view returns (uint256)

- Rewards are paid in CAKE tokens

Required steps:

4. Verify CAKE balance increased

Contract details:

Function call construction:

```typescript

const SimpleRewardPoolABI = [

'function harvest() external'

Common mistakes to avoid:

User's CAKE balance increases by pending rewards

Pending rewards reset to 0 after harvest

Use the harvest() function with no parameters

Check pendingReward() before harvesting to see expected amount

Verify CAKE balance increases after harvest

Blockchain network ID (56 for BSC Mainnet)

SimpleRewardPool contract address

Reward token address (CAKE)

User's wallet address

Harvest Farming Rewards

User's reward token (CAKE) balance increased

Transaction executed successfully without reverting


Stake LP Tokens to Farming Pool

Stake LP (Liquidity Provider) tokens to a SimpleLPStaking farming pool to earn rewards. LP tokens are obtained by providing liquidity to a DEX pair (e.g., USDT/BUSD on PancakeSwap).

IMPORTANT: This is a SimpleLPStaking contract, NOT a MasterChef-style contract.
- Contract function: deposit(uint256 _amount) - ONLY ONE PARAMETER
- NO pool ID parameter required (unlike MasterChef)
- The pool_address parameter is the SimpleLPStaking contract address

Required steps:
1. Check LP token balance: lpToken.balanceOf(user_address)
2. Check current allowance: lpToken.allowance(user_address, pool_address)
3. If allowance is insufficient, approve the pool: lpToken.approve(pool_address, amount)
4. Stake LP tokens: simpleLPStaking.deposit(amount)

Contract details:
- SimpleLPStaking contract address: pool_address (dynamic parameter)
- LP token address: lp_token_address (USDT/BUSD pair: 0x7EFaEf62fDdCCa950418312c6C91Aef321375A00)
- Deposit function signature: deposit(uint256 _amount)
- Amount unit: wei (e.g., 0.5 LP tokens = 500000000000000000 wei)

Function call construction:
```typescript
const SimpleLPStakingABI = [
  'function deposit(uint256 _amount) external'
];
const contract = new Contract interface(pool_address, SimpleLPStakingABI, provider);
const data = encode the function call('deposit', [amountInWei]);
```

Common mistakes to avoid:
- DO NOT use deposit(uint256 _pid, uint256 _amount) - this is MasterChef, not SimpleLPStaking
- DO NOT pass a pool ID parameter
- DO ensure the LP token is approved before calling deposit
- DO convert the stake_amount to wei (multiply by 10^18)

Stake {stake_amount} USDT/BUSD LP tokens in the SimpleLPStaking pool

Deposit {stake_amount} LP tokens to the LP staking pool to earn farming rewards

Stake {stake_amount} USDT/BUSD LP tokens using the simple_lp_staking contract

Put {stake_amount} liquidity provider tokens into the LP staking pool to start earning

LP token address (USDT/BUSD pair)

SimpleLPStaking contract address

Amount of LP tokens to stake (in LP token units, e.g., 0.5)

User's wallet address

PancakeSwap LP Token (USDT/BUSD)

function approve(address spender, uint256 amount) external returns (bool)

function allowance(address owner, address spender) external view returns (uint256)

SimpleLPStaking

function withdraw(uint256 _amount) external

function getUserInfo(address _user) external view returns (uint256 amount, uint256 depositTime)

function userInfo(address _user) external view returns (uint256 amount, uint256 depositTime)

Required steps:

Contract details:

Function call construction:

```typescript

const SimpleLPStakingABI = [

Common mistakes to avoid:

- DO NOT pass a pool ID parameter

LP token balance decreases by stake_amount

LP token allowance to pool decreases (or needs to be set)

User's staked amount in pool increases by stake_amount

You need to approve the farming pool contract before staking LP tokens

Use the deposit() function with the amount in wei (amount * 10^18)

Check the current allowance first to avoid unnecessary approve transactions

Query userInfo() to verify the staked amount after transaction

Blockchain network ID (56 for BSC Mainnet)

LP token address (USDT/BUSD pair)

SimpleLPStaking contract address

User's wallet address

Stake LP Tokens to Farming Pool

User's LP token balance decreased by correct amount

LP token properly approved for farming pool contract

User's staked balance in pool increased correctly

Transaction executed successfully without reverting


Stake Single Token to Syrup Pool

Stake CAKE tokens to a PancakeSwap Syrup Pool to earn rewards. This operation requires approving the Syrup Pool contract to spend your CAKE tokens, then calling the deposit function with the pool ID and amount. You need to query the pool information to get the staking token address and ensure you have sufficient balance and allowance.

Stake {stake_amount} CAKE tokens in the SimpleStaking pool

Deposit {stake_amount} CAKE to the simple_staking contract to earn rewards

Put {stake_amount} CAKE tokens into the single-token staking pool

Stake {stake_amount} CAKE in the single token farming pool to start earning

SimpleStaking contract address

Amount of CAKE to stake (in CAKE units, e.g., 5.0)

CAKE token address (staking token)

User's wallet address

CAKE token balance decreases by stake_amount

CAKE token allowance to pool decreases (or needs to be set)

You need to approve the Syrup Pool contract before staking

SimpleStaking contract address

CAKE token address (staking token)

User's wallet address

Stake Single Token to Syrup Pool

CAKE token properly approved for Syrup Pool contract

User's CAKE balance decreased by correct amount


Unstake LP Tokens from Farming Pool

Withdraw (unstake) LP tokens from a farming pool. This operation retrieves your staked LP tokens back to your wallet.

Technical context:
- Uses SimpleRewardPool contract's withdraw() function
- Function signature: withdraw(uint256 _amount)
- The withdraw function will also automatically harvest any pending rewards
- LP tokens are returned to the user's wallet
- Staked balance in the pool decreases by the withdrawal amount

Key considerations:
- Amount must not exceed the staked balance
- Amount must be in wei (18 decimals for LP tokens)
- Can withdraw partial or full staked amount
- The pool automatically harvests rewards during withdrawal

Implementation steps:
1. Query current staked amount: rewardPool.userInfo(user_address)
2. Ensure unstake amount <= staked amount
3. Call withdraw: rewardPool.withdraw(amountInWei)
4. Verify LP token balance increased by unstake amount
5. Verify staked amount decreased by unstake amount

Unstake {unstake_amount} USDT/BUSD LP tokens from the SimpleRewardPool

Withdraw {unstake_amount} LP tokens from the simple_reward_pool contract

Remove {unstake_amount} LP tokens from the reward pool staking

Unstake {unstake_amount} USDT/BUSD LP tokens from the reward distribution pool

LP token contract address (USDT/BUSD pair)

SimpleRewardPool contract address

Amount of LP tokens to unstake

User's wallet address

The withdraw function also harvests pending rewards automatically

Focus is on LP token withdrawal, rewards are a side effect

Technical context:

Key considerations:

Implementation steps:

SimpleRewardPool contract address

Amount of LP tokens to unstake

User's wallet address

Withdraw transaction executed successfully

LP token balance increased correctly

Staked amount decreased correctly

User must have sufficient staked balance

Unstake LP Tokens from Farming Pool


Query Pending Rewards

Query the pending rewards earned by a user in a staking pool. This involves calling the SimpleRewardPool contract's pendingReward function to retrieve the accumulated rewards that can be harvested. Rewards accumulate over time based on the user's staked amount and the pool's reward rate.

Query the pending rewards for address {{query_address}} in the SimpleRewardPool

Check how much rewards {{query_address}} has earned in the reward pool at {{pool_address}}

Get the accumulated rewards for user {{query_address}} from the SimpleRewardPool contract

Retrieve pending CAKE rewards for address {{query_address}} that can be harvested

Expected pending rewards amount (in token units, not wei)

SimpleRewardPool contract address

User address to query pending rewards for

Reward token decimals (CAKE uses 18 decimals)

Pending rewards do not match expected value (allowing 5% tolerance for time-based accumulation)

Understand how to query pending rewards from staking pools

Learn to call pendingReward function to get accumulated rewards

Master handling time-based reward accumulation

Understand the difference between staked amount and earned rewards

Learn proper unit conversion for reward tokens

Rewards accumulate over time, so the exact value may vary slightly

A 5% tolerance is used to account for time-based accumulation during test execution

The pendingReward function is a view function and does not change state

SimpleRewardPool contract address

Query Pending Rewards


Query Staked Amount

Query the staked amount of a user in a staking contract. This involves calling the staking contract's userInfo function to retrieve the user's staked balance and deposit time.

Query the staked amount for address {{query_address}} in the SimpleStaking contract

Check how much {{query_address}} has staked in the staking pool at {{pool_address}}

Get the staked balance for user {{query_address}} from the SimpleStaking contract

Retrieve staking information for address {{query_address}} including amount and deposit time

Expected staked amount (in token units, not wei)

SimpleStaking contract address

User address to query staked amount for

Staking token decimals (CAKE uses 18 decimals)

Staked amount does not match expected value

Understand how to query staking contract state

Learn to call userInfo function to get user's staked balance

Master parsing struct return values from smart contracts

Understand the structure of staking data (amount, depositTime)

SimpleStaking contract address

User address to query staked amount for

Query Staked Amount