forked from Zapper-fi/studio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tenderize): ✨ add farm support (Zapper-fi#2219)
* fix(tenderize): 🐛 fix swap tokens * feat(tenderize): ✨ add farm support * feat(tenderize): ✨ display farm reward rate
- Loading branch information
1 parent
e078ffc
commit e7f33ae
Showing
14 changed files
with
1,399 additions
and
9 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
src/apps/tenderize/arbitrum/tenderize.farm.contract-position-fetcher.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { PositionTemplate } from '~app-toolkit/decorators/position-template.decorator'; | ||
|
||
import { FarmContractPositionFetcher } from '../common/tenderize.farm.contract-position-fetcher'; | ||
|
||
@PositionTemplate() | ||
export class ArbitrumTenderizeFarmTokenFetcher extends FarmContractPositionFetcher { | ||
groupLabel = 'Farm'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/apps/tenderize/common/tenderize.farm.contract-position-fetcher.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { Inject } from '@nestjs/common'; | ||
|
||
import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface'; | ||
import { GetDataPropsParams, GetTokenBalancesParams } from '~position/template/contract-position.template.types'; | ||
import { | ||
SingleStakingFarmDataProps, | ||
SingleStakingFarmTemplateContractPositionFetcher, | ||
} from '~position/template/single-staking.template.contract-position-fetcher'; | ||
|
||
import { TenderizeContractFactory, TenderFarm } from '../contracts'; | ||
|
||
import { TenderizeTokenDefinitionsResolver } from './tenderize.token-definition-resolver'; | ||
|
||
export abstract class FarmContractPositionFetcher extends SingleStakingFarmTemplateContractPositionFetcher< | ||
TenderFarm, | ||
SingleStakingFarmDataProps | ||
> { | ||
constructor( | ||
@Inject(APP_TOOLKIT) protected readonly appToolkit: IAppToolkit, | ||
@Inject(TenderizeTokenDefinitionsResolver) | ||
private readonly tokenDefinitionsResolver: TenderizeTokenDefinitionsResolver, | ||
@Inject(TenderizeContractFactory) protected readonly contractFactory: TenderizeContractFactory, | ||
) { | ||
super(appToolkit); | ||
} | ||
|
||
getContract(address: string): TenderFarm { | ||
return this.contractFactory.tenderFarm({ network: this.network, address }); | ||
} | ||
|
||
async getFarmDefinitions() { | ||
const definitions = await this.tokenDefinitionsResolver.getTokenDefinitions(this.network); | ||
return definitions.map(v => ({ | ||
address: v.tenderFarm, | ||
stakedTokenAddress: v.lpToken, | ||
rewardTokenAddresses: [v.tenderToken], | ||
})); | ||
} | ||
|
||
async getStakedTokenBalance({ address, contract }: GetTokenBalancesParams<TenderFarm, SingleStakingFarmDataProps>) { | ||
return contract.stakeOf(address); | ||
} | ||
|
||
async getRewardTokenBalances({ address, contract }: GetTokenBalancesParams<TenderFarm, SingleStakingFarmDataProps>) { | ||
return contract.availableRewards(address); | ||
} | ||
|
||
async getRewardRates({ address }: GetDataPropsParams<TenderFarm, SingleStakingFarmDataProps>) { | ||
return [await this.tokenDefinitionsResolver.getRewardRate(this.network, address)]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
[ | ||
{ | ||
"anonymous": false, | ||
"inputs": [ | ||
{ "indexed": true, "internalType": "address", "name": "account", "type": "address" }, | ||
{ "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" } | ||
], | ||
"name": "Farm", | ||
"type": "event" | ||
}, | ||
{ | ||
"anonymous": false, | ||
"inputs": [ | ||
{ "indexed": true, "internalType": "address", "name": "account", "type": "address" }, | ||
{ "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" } | ||
], | ||
"name": "Harvest", | ||
"type": "event" | ||
}, | ||
{ | ||
"anonymous": false, | ||
"inputs": [{ "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" }], | ||
"name": "RewardsAdded", | ||
"type": "event" | ||
}, | ||
{ | ||
"anonymous": false, | ||
"inputs": [ | ||
{ "indexed": true, "internalType": "address", "name": "account", "type": "address" }, | ||
{ "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" } | ||
], | ||
"name": "Unfarm", | ||
"type": "event" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "CRF", | ||
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [{ "internalType": "uint256", "name": "_amount", "type": "uint256" }], | ||
"name": "addRewards", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [{ "internalType": "address", "name": "_for", "type": "address" }], | ||
"name": "availableRewards", | ||
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [{ "internalType": "uint256", "name": "_amount", "type": "uint256" }], | ||
"name": "farm", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ "internalType": "address", "name": "_for", "type": "address" }, | ||
{ "internalType": "uint256", "name": "_amount", "type": "uint256" } | ||
], | ||
"name": "farmFor", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ "internalType": "uint256", "name": "_amount", "type": "uint256" }, | ||
{ "internalType": "uint256", "name": "_deadline", "type": "uint256" }, | ||
{ "internalType": "uint8", "name": "_v", "type": "uint8" }, | ||
{ "internalType": "bytes32", "name": "_r", "type": "bytes32" }, | ||
{ "internalType": "bytes32", "name": "_s", "type": "bytes32" } | ||
], | ||
"name": "farmWithPermit", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ "inputs": [], "name": "harvest", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, | ||
{ | ||
"inputs": [ | ||
{ "internalType": "contract IERC20", "name": "_stakeToken", "type": "address" }, | ||
{ "internalType": "contract ITenderToken", "name": "_rewardToken", "type": "address" }, | ||
{ "internalType": "contract ITenderizer", "name": "_tenderizer", "type": "address" } | ||
], | ||
"name": "initialize", | ||
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "nextTotalStake", | ||
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "rewardToken", | ||
"outputs": [{ "internalType": "contract ITenderToken", "name": "", "type": "address" }], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ "internalType": "address", "name": "_token", "type": "address" }, | ||
{ "internalType": "uint256", "name": "_value", "type": "uint256" }, | ||
{ "internalType": "uint256", "name": "_deadline", "type": "uint256" }, | ||
{ "internalType": "uint8", "name": "_v", "type": "uint8" }, | ||
{ "internalType": "bytes32", "name": "_r", "type": "bytes32" }, | ||
{ "internalType": "bytes32", "name": "_s", "type": "bytes32" } | ||
], | ||
"name": "selfPermit", | ||
"outputs": [], | ||
"stateMutability": "payable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [ | ||
{ "internalType": "address", "name": "_token", "type": "address" }, | ||
{ "internalType": "uint256", "name": "_value", "type": "uint256" }, | ||
{ "internalType": "uint256", "name": "_deadline", "type": "uint256" }, | ||
{ "internalType": "uint8", "name": "_v", "type": "uint8" }, | ||
{ "internalType": "bytes32", "name": "_r", "type": "bytes32" }, | ||
{ "internalType": "bytes32", "name": "_s", "type": "bytes32" } | ||
], | ||
"name": "selfPermitIfNecessary", | ||
"outputs": [], | ||
"stateMutability": "payable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [{ "internalType": "contract ITenderizer", "name": "_tenderizer", "type": "address" }], | ||
"name": "setTenderizer", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [{ "internalType": "address", "name": "_of", "type": "address" }], | ||
"name": "stakeOf", | ||
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [{ "internalType": "address", "name": "", "type": "address" }], | ||
"name": "stakes", | ||
"outputs": [ | ||
{ "internalType": "uint256", "name": "stake", "type": "uint256" }, | ||
{ "internalType": "uint256", "name": "lastCRF", "type": "uint256" } | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "tenderizer", | ||
"outputs": [{ "internalType": "contract ITenderizer", "name": "", "type": "address" }], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "token", | ||
"outputs": [{ "internalType": "contract IERC20", "name": "", "type": "address" }], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [], | ||
"name": "totalStake", | ||
"outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], | ||
"stateMutability": "view", | ||
"type": "function" | ||
}, | ||
{ | ||
"inputs": [{ "internalType": "uint256", "name": "_amount", "type": "uint256" }], | ||
"name": "unfarm", | ||
"outputs": [], | ||
"stateMutability": "nonpayable", | ||
"type": "function" | ||
} | ||
] |
Oops, something went wrong.