Skip to content

Commit 2aeb353

Browse files
committed
first draft/test/release on bitriel-farm v0.1.0
1 parent 4fc7a04 commit 2aeb353

16 files changed

Lines changed: 1746 additions & 309 deletions

contracts/BitrielFarmer.sol

Lines changed: 102 additions & 106 deletions
Large diffs are not rendered by default.

contracts/interfaces/IBitrielFarmer.sol

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ interface IBitrielFarmer is IERC721Receiver, IMulticall {
4545
/// @return totalYieldUnclaimed The amount of yield (reward token) not yet claimed by users
4646
/// @return totalSecondsClaimedX128 Total liquidity-seconds claimed, represented as a UQ32.128
4747
/// @return numberOfStakes The count of deposits that are currently staked for the yield farming incentive
48-
/// @return lastYieldBlock Last block number that BTRs distribution occurs
48+
// /// @return lastYieldBlock Last block number that BTRs distribution occurs
4949
// /// @return accBTRPerShare Accumulated BTRs per share, times 1e12
5050
function farms(bytes32 farmId) external view
5151
returns (
5252
uint256 totalYieldUnclaimed,
5353
uint160 totalSecondsClaimedX128,
54-
uint96 numberOfStakes,
55-
uint256 lastYieldBlock
54+
uint96 numberOfStakes
55+
// uint256 lastYieldBlock
5656
// uint256 accBTRPerShare
5757
);
5858

@@ -74,7 +74,7 @@ interface IBitrielFarmer is IERC721Receiver, IMulticall {
7474
/// @param farmId The ID of the yield farming incentive for which the token is staked
7575
/// @return secondsPerLiquidityInsideInitialX128 secondsPerLiquidity represented as a UQ32.128
7676
/// @return liquidity The amount of liquidity in the NFT as of the last time the rewards were computed
77-
function stakes(bytes32 farmId, uint256 tokenId) external view
77+
function stakes(uint256 tokenId, bytes32 farmId) external view
7878
returns (
7979
uint160 secondsPerLiquidityInsideInitialX128,
8080
uint128 liquidity
@@ -130,19 +130,6 @@ interface IBitrielFarmer is IERC721Receiver, IMulticall {
130130
/// @return yieldHarvested The amount of yield harvested
131131
function harvest(address to, uint256 yieldRequested) external returns (uint256 yieldHarvested);
132132

133-
/// @notice Withdraw a BitrielSwap LP token `tokenId` and Transfers `amountRequested` of accrued BTRs yield (reward tokens) from the contract to the recipient `to`
134-
/// @param to The address where harvest yield will be sent to
135-
/// @param tokenId The unique identifier of an BitrielSwap liquidity NFT token
136-
/// @param amountRequested The amount of yield to harvest. Claims entire yield amount if set to 0.
137-
/// @param data An optional data array that will be passed along to the `to` address via the NFT safeTransferFrom
138-
/// @return yieldHarvested The amount of yield harvested
139-
function withdrawAndHarvest(
140-
address to,
141-
uint256 tokenId,
142-
uint256 amountRequested,
143-
bytes calldata data
144-
) external returns (uint256 yieldHarvested);
145-
146133
/// @notice Calculates the yield (reward) amount that will be received for the given stake
147134
/// @param key The key of the yield farming incentive
148135
/// @param tokenId The ID of the token
@@ -158,7 +145,8 @@ interface IBitrielFarmer is IERC721Receiver, IMulticall {
158145

159146
/// @notice Migrate lp token to another lp contract. Can be called by anyone. We trust that migrator contract is good.
160147
/// @param params The params necessary to migrate v2 liquidity, encoded as `MigrateParams` in calldata
161-
function migrate(IMigrator.MigrateParams calldata params) external;
148+
/// @param data An optional data array that will be passed along to the `to` address via the NFT safeTransferFrom
149+
function migrate(IMigrator.MigrateParams calldata params, bytes calldata data) external;
162150

163151
/// @notice Event emitted when a yield farming incentive has been created
164152
/// @param pool The BitrielSwap pool

deploy/BitrielFarmer.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FACTORY_ADDRESS, NONFUNGIBLE_POSITION_MANAGER_ADDRESSES } from "@bitriel/bitrielswap-sdk"
1+
import { FACTORY_ADDRESS, NONFUNGIBLE_POSITION_MANAGER_ADDRESSES, MIGRATOR_ADDRESS } from "@bitriel/bitrielswap-sdk"
22
import { HardhatRuntimeEnvironment } from 'hardhat/types'
33
import { DeployFunction } from 'hardhat-deploy/types'
44

@@ -7,6 +7,7 @@ const deploy: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
77
const { deploy } = deployments
88
const { deployer, dev } = await getNamedAccounts()
99
const chainId = ethers.BigNumber.from(await getChainId()).toNumber()
10+
1011
if(chainId in FACTORY_ADDRESS && chainId in NONFUNGIBLE_POSITION_MANAGER_ADDRESSES) {
1112
const bitriel = await ethers.getContract("BitrielToken")
1213
const dayInSeconds = 60 * 60 * 24 // 86400
@@ -28,11 +29,9 @@ const deploy: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
2829
})
2930

3031
const bitrielFarmer = await ethers.getContract("BitrielFarmer")
31-
const migrator = await deployments.get("Migrator")
32-
33-
if(migrator.address != "0") {
32+
if(chainId in MIGRATOR_ADDRESS) {
3433
console.log("Set migrator address on BitrielFarmer contract")
35-
await (await bitrielFarmer.setMigrator(migrator.address)).wait()
34+
await (await bitrielFarmer.setMigrator(MIGRATOR_ADDRESS[chainId])).wait()
3635
}
3736

3837
if (await bitriel.owner() !== bitrielFarmer.address) {
@@ -48,5 +47,5 @@ const deploy: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
4847
}
4948

5049
deploy.tags = ['BitrielFarmer']
51-
deploy.dependencies = ['BitrielToken', 'Migrator']
50+
deploy.dependencies = ['BitrielToken']
5251
export default deploy

0 commit comments

Comments
 (0)