Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: switch FOXy from web3 to ethers and JsonRpcBatchProvider #3508

Merged
merged 29 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f1ce27f
feat: manually reapply lib/1032
gomesalexandre Apr 23, 2023
5712539
feat: reapply web/3508
gomesalexandre Apr 23, 2023
65496c7
fix: types
gomesalexandre Apr 23, 2023
838f7ec
feat: use consistent ethers version across packages
gomesalexandre Apr 23, 2023
b8b3d38
fix: getFoxyOpportunityByStakingAddress should use foxy staking contract
gomesalexandre Apr 23, 2023
645d5f1
feat(investor-foxy): estimate fees from node
gomesalexandre Apr 23, 2023
27e3021
wip: consume feeDataEstimate in FOxy view-layer instead of dumb previ…
gomesalexandre Apr 23, 2023
76033d3
fix: stake(uint256) arity
gomesalexandre Apr 23, 2023
cc56ac4
feat: safeGasLimit 5% buffer
gomesalexandre Apr 23, 2023
d18ca4f
feat: fully plumb through web
gomesalexandre Apr 24, 2023
7fbc499
feat: bye bye investor-foxy getGasPrice(), you will not be missed
gomesalexandre Apr 24, 2023
76e80af
feat: gas -> fees vernacular
gomesalexandre Apr 24, 2023
1d43399
chore: cleanup getNonce
gomesalexandre Apr 24, 2023
a891d2c
feat: remove investor-foxy's buildTxToSign and use buildCustomTx
gomesalexandre Apr 24, 2023
a8cbcfb
feat: more cleanup, remove getNonce, why tf did we need this
gomesalexandre Apr 24, 2023
0806b0d
feat: consistently use JsonRpcBatchProvider
gomesalexandre Apr 24, 2023
73d5295
feat: actually remove web3 deps from investor-foxy
gomesalexandre Apr 24, 2023
615d8dd
fix: big derp
gomesalexandre Apr 24, 2023
2a3ef74
feat: regenerate yarn.lock
gomesalexandre Apr 24, 2023
5903028
feat: excuse my LSP
gomesalexandre Apr 24, 2023
0b8f077
feat: one ethers to rule them all
gomesalexandre Apr 24, 2023
7a1ca4a
feat: import from ethers vs ethers/lib
gomesalexandre Apr 24, 2023
e62a24d
feat: that damn LSP
gomesalexandre Apr 24, 2023
41f4280
feat: rm @ethersproject/providers dep
gomesalexandre Apr 24, 2023
246b77a
fix: derp
gomesalexandre Apr 24, 2023
c883f3a
feat: use gasUsed from ethers' TransactionReceipt
gomesalexandre Apr 25, 2023
21b198f
fix: use ethers effectiveGasPrice
gomesalexandre Apr 25, 2023
bfe6727
feat: consistent naming
gomesalexandre Apr 25, 2023
61a91a6
feat: disgusting code, get out
gomesalexandre Apr 25, 2023
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
1 change: 1 addition & 0 deletions __mocks__/ethers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const ethers = {
...jest.requireActual('ethers').ethers,
providers: {
JsonRpcProvider: jest.fn(),
JsonRpcBatchProvider: jest.fn(),
},
Contract: jest.fn().mockImplementation(address => ({
decimals: () => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
"embla-carousel-react": "^7.0.5",
"envalid": "^7.3.1",
"eth-url-parser": "^1.0.4",
"ethers": "^5.5.3",
"ethers": "^5.7.2",
"framer-motion": "^6.3.11",
"friendly-challenge": "0.9.2",
"grapheme-splitter": "^1.0.4",
Expand Down
1 change: 0 additions & 1 deletion packages/asset-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"js-pixel-fonts": "^1.5.0"
},
"devDependencies": {
"@ethersproject/providers": "^5.5.3",
"@yfi/sdk": "^1.2.0",
"colorthief": "^2.3.2"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { JsonRpcProvider } from '@ethersproject/providers'
import { ethChainId as chainId, toAssetId } from '@shapeshiftoss/caip'
import type { Token, Vault } from '@yfi/sdk'
import { Yearn } from '@yfi/sdk'
import { ethers } from 'ethers'
import toLower from 'lodash/toLower'

import type { Asset } from '../../service/AssetService'
import { ethereum } from '../baseAssets'
import { colorMap } from '../colorMap'

const network = 1 // 1 for mainnet
const provider = new JsonRpcProvider(process.env.ETHEREUM_NODE_URL)
const provider = new ethers.providers.JsonRpcBatchProvider(process.env.ETHEREUM_NODE_URL)
export const yearnSdk = new Yearn(network, { provider })

const explorerData = {
Expand Down
4 changes: 2 additions & 2 deletions packages/caip/src/adapters/yearn/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @shapeshiftoss/logger/no-native-console */
import { JsonRpcProvider } from '@ethersproject/providers'
import type { Token, Vault } from '@yfi/sdk'
import { Yearn } from '@yfi/sdk'
import { ethers } from 'ethers'
import fs from 'fs'
import toLower from 'lodash/toLower'
import uniqBy from 'lodash/uniqBy'
Expand All @@ -11,7 +11,7 @@ import { toChainId } from '../../chainId/chainId'
import { CHAIN_NAMESPACE, CHAIN_REFERENCE } from '../../constants'

const network = 1 // 1 for mainnet
const provider = new JsonRpcProvider(process.env.REACT_APP_ETHEREUM_NODE_URL)
const provider = new ethers.providers.JsonRpcBatchProvider(process.env.REACT_APP_ETHEREUM_NODE_URL)
const yearnSdk = new Yearn(network, { provider })

export const writeFiles = async (data: Record<string, Record<string, string>>) => {
Expand Down
5 changes: 1 addition & 4 deletions packages/investor-foxy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,11 @@
"cli": "yarn build && yarn node dist/foxycli.js"
},
"dependencies": {
"@ethersproject/providers": "^5.5.3",
"@shapeshiftoss/caip": "workspace:^",
"@shapeshiftoss/chain-adapters": "workspace:^",
"@shapeshiftoss/logger": "workspace:^",
"@shapeshiftoss/types": "workspace:^",
"readline-sync": "^1.4.10",
"web3-core": "1.7.4",
"web3-utils": "1.7.4"
"readline-sync": "^1.4.10"
},
"devDependencies": {
"@types/readline-sync": "^1.4.4"
Expand Down
4 changes: 2 additions & 2 deletions packages/investor-foxy/src/abi/erc20-abi.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AbiItem } from 'web3-utils'
import type { ContractInterface } from 'ethers'

export const erc20Abi: AbiItem[] = [
export const erc20Abi: ContractInterface = [
{
constant: true,
inputs: [],
Expand Down
4 changes: 2 additions & 2 deletions packages/investor-foxy/src/abi/foxy-abi.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AbiItem } from 'web3-utils'
import type { ContractInterface } from 'ethers'

export const foxyAbi: AbiItem[] = [
export const foxyAbi: ContractInterface = [
{
inputs: [],
stateMutability: 'nonpayable',
Expand Down
4 changes: 2 additions & 2 deletions packages/investor-foxy/src/abi/foxy-staking-abi.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AbiItem } from 'web3-utils'
import type { ContractInterface } from 'ethers'

export const foxyStakingAbi: AbiItem[] = [
export const foxyStakingAbi: ContractInterface = [
{
inputs: [
{
Expand Down
4 changes: 2 additions & 2 deletions packages/investor-foxy/src/abi/liquidity-reserve-abi.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AbiItem } from 'web3-utils'
import type { ContractInterface } from 'ethers'

export const liquidityReserveAbi: AbiItem[] = [
export const liquidityReserveAbi: ContractInterface = [
{
inputs: [
{
Expand Down
4 changes: 2 additions & 2 deletions packages/investor-foxy/src/abi/toke-manager-abi.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AbiItem } from 'web3-utils'
import type { ContractInterface } from 'ethers'

export const tokeManagerAbi: AbiItem[] = [
export const tokeManagerAbi: ContractInterface = [
{ inputs: [], stateMutability: 'nonpayable', type: 'constructor' },
{
anonymous: false,
Expand Down
4 changes: 2 additions & 2 deletions packages/investor-foxy/src/abi/toke-pool-abi.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AbiItem } from 'web3-utils'
import type { ContractInterface } from 'ethers'

export const tokePoolAbi: AbiItem[] = [
export const tokePoolAbi: ContractInterface = [
{
anonymous: false,
inputs: [
Expand Down
4 changes: 2 additions & 2 deletions packages/investor-foxy/src/abi/toke-reward-hash-abi.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AbiItem } from 'web3-utils'
import type { ContractInterface } from 'ethers'

export const tokeRewardHashAbi: AbiItem[] = [
export const tokeRewardHashAbi: ContractInterface = [
{ inputs: [], stateMutability: 'nonpayable', type: 'constructor' },
{
anonymous: false,
Expand Down
Loading