├── .github
├── ISSUE_TEMPLATE
│ ├── bug_report.yml
│ └── feature_request.yml
└── PULL_REQUEST_TEMPLATE.md
├── .gitignore
├── README.md
├── crowdin.yml
├── package.json
├── public
├── 451.html
├── _redirects
├── favicon.ico
├── hero.png
├── index.html
├── logo192.png
├── logo512.png
├── manifest.json
└── robots.txt
├── src
├── App.tsx
├── assets
│ ├── copy.svg
│ ├── copy_confirm.svg
│ ├── documents
│ │ ├── Umbrella_Protocol_Lite_Paper.pdf
│ │ └── Umbrella_Protocol_Lite_Paper_CN.pdf
│ ├── flags
│ │ ├── ch-flag.png
│ │ ├── de-flag.png
│ │ ├── en-flag.png
│ │ ├── es-flag.png
│ │ ├── fr-flag.png
│ │ ├── he-flag.png
│ │ ├── it-flag.png
│ │ ├── ja-flag.png
│ │ ├── ko-flag.png
│ │ ├── ro-flag.png
│ │ ├── ru-flag.png
│ │ └── vi-flag.png
│ ├── fortmatic.png
│ ├── locales
│ │ ├── en.json
│ │ └── zh.json
│ ├── metamask-fox.svg
│ ├── mofy.png
│ ├── portis.png
│ ├── wallet-connect.svg
│ ├── yamdaohouse.png
│ └── yampp.png
├── components
│ ├── AddressButton
│ │ ├── AddressButton.tsx
│ │ └── index.ts
│ ├── Bar
│ │ ├── Bar.tsx
│ │ └── index.ts
│ ├── BoxWithDisplay
│ │ ├── BoxWithDisplay.tsx
│ │ └── index.ts
│ ├── ClaimCard
│ │ ├── ClaimCard.tsx
│ │ └── index.ts
│ ├── ConfirmTransactionModal
│ │ ├── ConfirmTransactionModal.tsx
│ │ └── index.ts
│ ├── DarkModeSwitch
│ │ ├── DarkModeSwitch.tsx
│ │ └── index.ts
│ ├── DegenerativeCard
│ │ ├── DegenerativeCard.tsx
│ │ └── index.ts
│ ├── DelegateLP
│ │ ├── DelegateLP.tsx
│ │ └── index.ts
│ ├── DelegateToken
│ │ ├── DelegateToken.tsx
│ │ └── index.ts
│ ├── Dial
│ │ ├── Dial.tsx
│ │ └── index.ts
│ ├── ExternalLink
│ │ ├── ExternalLink.tsx
│ │ └── index.ts
│ ├── FancyValue
│ │ ├── FancyValue.tsx
│ │ └── index.ts
│ ├── Footer
│ │ ├── Footer.tsx
│ │ ├── components
│ │ │ └── Nav.tsx
│ │ └── index.ts
│ ├── Label
│ │ ├── Label.tsx
│ │ └── index.ts
│ ├── LangSwitcher
│ │ ├── LangSwitcher.tsx
│ │ ├── index.css
│ │ └── index.ts
│ ├── Logo
│ │ ├── Logo.tsx
│ │ └── index.ts
│ ├── MofyCard
│ │ ├── MofyCard.tsx
│ │ └── index.ts
│ ├── Page
│ │ ├── Page.tsx
│ │ └── index.ts
│ ├── PageHeader
│ │ ├── PageHeader.tsx
│ │ └── index.ts
│ ├── ProjectCard
│ │ ├── ProjectCard.tsx
│ │ └── index.ts
│ ├── RegistrationButton
│ │ ├── RegistrationButton.tsx
│ │ └── index.ts
│ ├── SeparatorWithCSS
│ │ ├── SeparatorWithCSS.tsx
│ │ └── index.ts
│ ├── Split
│ │ ├── Split.tsx
│ │ └── index.ts
│ ├── StartFooter
│ │ ├── StartFooter.tsx
│ │ └── index.ts
│ ├── StartPage
│ │ ├── StartPage.tsx
│ │ └── index.ts
│ ├── StartPageHeader
│ │ ├── StartPageHeader.tsx
│ │ └── index.ts
│ ├── StartSplit
│ │ ├── StartSplit.tsx
│ │ └── index.ts
│ ├── StyledMenu
│ │ └── index.tsx
│ ├── StyledNoticeIcon
│ │ ├── StyledNoticeIcon.tsx
│ │ └── index.ts
│ ├── TokenInput
│ │ ├── TokenInput.tsx
│ │ └── index.ts
│ ├── TopBar
│ │ ├── TopBar.tsx
│ │ ├── components
│ │ │ ├── Nav.tsx
│ │ │ ├── StyledLink.tsx
│ │ │ ├── StyledRouterLink.tsx
│ │ │ └── WalletButton.tsx
│ │ └── index.ts
│ ├── UmbrellaCard
│ │ ├── UmbrellaCard.tsx
│ │ └── index.ts
│ ├── UnlockWalletModal
│ │ ├── UnlockWalletModal.tsx
│ │ ├── components
│ │ │ └── WalletProviderCard.tsx
│ │ └── index.ts
│ ├── Value
│ │ ├── Value.tsx
│ │ └── index.ts
│ ├── ValueText
│ │ ├── ValueText.tsx
│ │ └── index.ts
│ ├── WalletModal
│ │ ├── WalletModal.tsx
│ │ └── index.ts
│ ├── YamLoader
│ │ ├── YamLoader.tsx
│ │ └── index.ts
│ ├── YamReOrgCard
│ │ ├── YamReOrgCard.tsx
│ │ └── index.ts
│ ├── YamTreasuriesCard
│ │ ├── YamTreasuriesCard.tsx
│ │ └── index.ts
│ └── icons
│ │ ├── CoinDeskIcon.tsx
│ │ ├── CoinTelegraphIcon.tsx
│ │ ├── ForbesIcon.tsx
│ │ ├── Gizmodo.tsx
│ │ ├── Menu.tsx
│ │ ├── TheDefiantIcon.tsx
│ │ └── TheRegisterIcon.tsx
├── constants
│ ├── Footers.json
│ ├── abi
│ │ └── ERC20.json
│ └── tokenAddresses.ts
├── contexts
│ ├── Balances
│ │ ├── Context.ts
│ │ ├── Provider.tsx
│ │ ├── index.ts
│ │ └── types.ts
│ ├── Farming
│ │ ├── Context.ts
│ │ ├── Provider.tsx
│ │ ├── index.ts
│ │ └── types.ts
│ ├── Governance
│ │ ├── Context.ts
│ │ ├── Provider.tsx
│ │ ├── index.ts
│ │ └── types.ts
│ ├── Migration
│ │ ├── Context.ts
│ │ ├── Provider.tsx
│ │ ├── index.ts
│ │ └── types.ts
│ ├── Prices
│ │ ├── PricesContext.ts
│ │ ├── PricesProvider.tsx
│ │ └── index.ts
│ ├── Tvl
│ │ ├── Context.ts
│ │ ├── Provider.tsx
│ │ ├── index.ts
│ │ └── types.ts
│ ├── Vesting
│ │ ├── Context.ts
│ │ ├── Provider.tsx
│ │ ├── index.ts
│ │ └── types.ts
│ └── YamProvider
│ │ ├── YamProvider.tsx
│ │ └── index.ts
├── hooks
│ ├── useAllowance.ts
│ ├── useApproval.ts
│ ├── useBalances.ts
│ ├── useDashboard.ts
│ ├── useENS.ts
│ ├── useFarming.ts
│ ├── useGovernance.ts
│ ├── useLocalStorage.ts
│ ├── useMigration.ts
│ ├── useOnClickOutside.tsx
│ ├── usePrices.ts
│ ├── useSDK.ts
│ ├── useTokenBalance.ts
│ ├── useTreasury.ts
│ ├── useTvl.ts
│ ├── useVesting.ts
│ └── useYam.ts
├── index.css
├── index.tsx
├── plugins
│ └── i18n.ts
├── react-app-env.d.ts
├── serviceWorker.js
├── setupTests.js
├── types
│ └── Charts.ts
├── utils
│ ├── index.ts
│ └── misc.ts
├── views
│ ├── Addresses
│ │ ├── Addresses.tsx
│ │ └── index.ts
│ ├── Claim
│ │ ├── Claim.tsx
│ │ └── index.ts
│ ├── Contributor
│ │ ├── Contributor.tsx
│ │ └── index.ts
│ ├── Dashboard
│ │ ├── Dashboard.tsx
│ │ ├── components
│ │ │ ├── Asset.tsx
│ │ │ ├── AssetsList.tsx
│ │ │ ├── Charts.tsx
│ │ │ └── TopCards.tsx
│ │ └── index.ts
│ ├── Delegate
│ │ ├── Delegate.tsx
│ │ └── index.ts
│ ├── FAQ
│ │ ├── FAQ.tsx
│ │ ├── components
│ │ │ └── Question.tsx
│ │ └── index.ts
│ ├── Farm
│ │ ├── Farm.tsx
│ │ ├── components
│ │ │ ├── Harvest
│ │ │ │ ├── Harvest.tsx
│ │ │ │ └── index.ts
│ │ │ ├── HarvestLPsNoticeYAMYUSD.tsx
│ │ │ ├── PausedLPsNotice.tsx
│ │ │ ├── ResumedLPsNotice.tsx
│ │ │ └── Stake
│ │ │ │ ├── Stake.tsx
│ │ │ │ ├── components
│ │ │ │ ├── StakeModal.tsx
│ │ │ │ └── UnstakeModal.tsx
│ │ │ │ └── index.ts
│ │ └── index.ts
│ ├── Governance
│ │ ├── Governance.tsx
│ │ ├── components
│ │ │ ├── Proposal.tsx
│ │ │ └── VoteModal.tsx
│ │ └── index.ts
│ ├── Home
│ │ ├── Home.tsx
│ │ ├── components
│ │ │ ├── MigrationNotice.tsx
│ │ │ ├── Rebase.tsx
│ │ │ ├── RegisterVoteNotice.tsx
│ │ │ ├── Stats.tsx
│ │ │ ├── Treasury.tsx
│ │ │ └── VestingNotice.tsx
│ │ └── index.ts
│ ├── Landings
│ │ ├── Daohouse.tsx
│ │ └── Umbrella.tsx
│ ├── Migrate
│ │ ├── Migrate.tsx
│ │ ├── components
│ │ │ ├── EndingMigrationNotice.tsx
│ │ │ ├── MigrateCard.tsx
│ │ │ └── VestingNotice.tsx
│ │ └── index.ts
│ ├── Projects
│ │ ├── Projects.tsx
│ │ └── index.ts
│ ├── Redemption
│ │ ├── Redemption.tsx
│ │ └── index.ts
│ ├── Registration
│ │ ├── Registration.tsx
│ │ ├── components
│ │ │ └── RegisterNotice.tsx
│ │ └── index.ts
│ ├── Start
│ │ ├── Start.tsx
│ │ └── index.ts
│ ├── TVL
│ │ ├── TVL.tsx
│ │ └── index.ts
│ ├── TokenValues
│ │ ├── TokenValues.tsx
│ │ └── index.ts
│ └── User
│ │ ├── User.tsx
│ │ └── index.ts
├── yam-sdk-files
│ ├── dist
│ │ ├── Yam.js
│ │ ├── index.js
│ │ ├── lib
│ │ │ ├── contracts
│ │ │ │ ├── Governor.js
│ │ │ │ ├── Redeemer.js
│ │ │ │ └── Token.js
│ │ │ └── types
│ │ │ │ └── yam.t.js
│ │ └── utils
│ │ │ ├── abis
│ │ │ ├── governor.json
│ │ │ ├── incentivizer.json
│ │ │ ├── migrator.json
│ │ │ ├── redeemer.json
│ │ │ ├── timelock.json
│ │ │ └── yam.json
│ │ │ ├── contracts.js
│ │ │ ├── tokens.js
│ │ │ └── utils.js
│ └── file.txt
└── yam-sdk
│ ├── lib
│ ├── Yam.js
│ ├── clean_build
│ │ └── contracts
│ │ │ ├── Address.json
│ │ │ ├── Babylonian.json
│ │ │ ├── Context.json
│ │ │ ├── DualGovernorAlpha.json
│ │ │ ├── FixedPoint.json
│ │ │ ├── GovernorAlpha.json
│ │ │ ├── IERC20.json
│ │ │ ├── IRewardDistributionRecipient.json
│ │ │ ├── IndexStakingRewards.json
│ │ │ ├── LPTokenWrapper.json
│ │ │ ├── MasterChef.json
│ │ │ ├── Math.json
│ │ │ ├── Migrations.json
│ │ │ ├── Migrator.json
│ │ │ ├── OTC.json
│ │ │ ├── Ownable.json
│ │ │ ├── Rebaser.json
│ │ │ ├── SafeERC20.json
│ │ │ ├── SafeMath.json
│ │ │ ├── SushiBarXSushi.json
│ │ │ ├── SushiToken.json
│ │ │ ├── SushiswapPool.json
│ │ │ ├── Timelock.json
│ │ │ ├── TimelockInterface.json
│ │ │ ├── UniswapPair.json
│ │ │ ├── UniswapV2OracleLibrary.json
│ │ │ ├── VestingPool.json
│ │ │ ├── YAM.json
│ │ │ ├── YAMAMPLPool.json
│ │ │ ├── YAMCOMPPool.json
│ │ │ ├── YAMDelegate.json
│ │ │ ├── YAMDelegate2.json
│ │ │ ├── YAMDelegateInterface.json
│ │ │ ├── YAMDelegationStorage.json
│ │ │ ├── YAMDelegator.json
│ │ │ ├── YAMDelegatorInterface.json
│ │ │ ├── YAMDelegatorV3.json
│ │ │ ├── YAMETHPool.json
│ │ │ ├── YAMGovernanceStorage.json
│ │ │ ├── YAMGovernanceToken.json
│ │ │ ├── YAMIncentives.json
│ │ │ ├── YAMIncentivizer.json
│ │ │ ├── YAMIncentivizerOld.json
│ │ │ ├── YAMIncentivizerWithVoting.json
│ │ │ ├── YAMInterface.json
│ │ │ ├── YAMLENDPool.json
│ │ │ ├── YAMLINKPool.json
│ │ │ ├── YAMMKRPool.json
│ │ │ ├── YAMRebaser.json
│ │ │ ├── YAMRebaser2.json
│ │ │ ├── YAMReserve.json
│ │ │ ├── YAMReserves.json
│ │ │ ├── YAMReserves2.json
│ │ │ ├── YAMSNXPool.json
│ │ │ ├── YAMToken.json
│ │ │ ├── YAMTokenInterface.json
│ │ │ ├── YAMTokenStorage.json
│ │ │ ├── YAMYFIPool.json
│ │ │ ├── YAMv2.json
│ │ │ └── YAMv2Migration.json
│ ├── index.js
│ ├── lib
│ │ ├── BytesHelper.js
│ │ ├── Expect.js
│ │ ├── Helpers.js
│ │ ├── accounts.js
│ │ ├── constants.js
│ │ ├── contracts.js
│ │ ├── evm.js
│ │ ├── snx.json
│ │ ├── types.js
│ │ ├── uni.json
│ │ ├── uni2.json
│ │ ├── uniR.json
│ │ ├── unifact2.json
│ │ ├── weth.json
│ │ └── ycrv.json
│ └── tests
│ │ ├── EIP712.js
│ │ ├── deployment.test.js
│ │ ├── distribution.test.js
│ │ ├── governance.test.js
│ │ ├── governorAlpha.test.js
│ │ ├── migrate.test.js
│ │ ├── rebase.test.js
│ │ ├── token.test.js
│ │ └── token2.test.js
│ └── utils
│ └── index.js
├── tsconfig.json
├── typings
└── index.d.ts
└── yarn.lock
/.github/ISSUE_TEMPLATE/bug_report.yml:
--------------------------------------------------------------------------------
1 | name: Bug Report
2 | description: Create a bug report to help us improve
3 | title: "Bug "
4 | labels: ["bug"]
5 | body:
6 | - type: textarea
7 | id: bug-info
8 | attributes:
9 | label: What is the bug?
10 | description: A clear and concise description of what the bug is.
11 | placeholder: Tell us what you saw!
12 | validations:
13 | required: true
14 | - type: textarea
15 | id: screenshots
16 | attributes:
17 | label: Screenshots
18 | description: If applicable, add screenshots to help explain your problem.
19 | - type: textarea
20 | id: logs-output
21 | attributes:
22 | label: Logs Output
23 | description: Please paste any relevant logs output.
24 | render: shell
25 | - type: dropdown
26 | id: desktop-mobile
27 | attributes:
28 | label: Are you on desktop or mobile?
29 | options:
30 | - Desktop
31 | - Mobile
32 | validations:
33 | required: true
34 | - type: dropdown
35 | id: browsers
36 | attributes:
37 | label: What browsers are you using?
38 | multiple: true
39 | options:
40 | - Firefox
41 | - Chrome
42 | - Safari
43 | - Microsoft Edge
44 | - Other
45 | validations:
46 | required: true
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.yml:
--------------------------------------------------------------------------------
1 | name: Feature Request
2 | description: Suggest an idea for this project
3 | title: "Request "
4 | labels: ["enhancement"]
5 | body:
6 | - type: textarea
7 | id: feature-info
8 | attributes:
9 | label: Describe your request
10 | description: A clear and concise description of what you like us to add.
11 | placeholder: Tell us about your idea!
12 | validations:
13 | required: true
14 | - type: textarea
15 | id: screenshots
16 | attributes:
17 | label: Screenshots
18 | validations:
19 | required: false
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | ### Description of changes proposed in this pull request:
2 | -
3 | -
4 |
5 | ### Checks:
6 | * [ ] Have you followed the guidelines in our Contributing document?
7 | * [ ] Have you checked to ensure there aren't other open [Pull Requests](../../pulls) for the same update/change?
8 |
9 |
10 |
11 | ### New Feature Submission:
12 | * [ ] Have you successfully ran tests with your changes locally?
13 | * [ ] Have you lint your code locally prior to submission?
14 |
15 | ### Changes to Existing Features:
16 | * [ ] Have you added an explanation of what your changes do and why you'd like us to include them?
17 | * [ ] Have you written new tests for your core changes, if applicable?
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 | /.pnp
6 | .pnp.js
7 | .vscode
8 | .idea
9 |
10 | # testing
11 | /coverage
12 |
13 | # production
14 | /build
15 |
16 | # misc
17 | .DS_Store
18 | .env.local
19 | .env.development.local
20 | .env.test.local
21 | .env.production.local
22 | .vscode
23 | .idea
24 |
25 | npm-debug.log*
26 | yarn-debug.log*
27 | yarn-error.log*
28 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Yam.finance 🍠
2 |
3 | > The Yam core website application.
4 |
5 | # What is YAM?
6 |
7 | YAM is the governance token for the YAM protocol. A decentralized cryptocurrency with treasury managed by the community. The community can then use those funds via YAM governance to build out the protocol.
8 |
9 | ## Available at
10 |
11 | https://yam.finance/ - Live website
12 | 
13 |
14 | https://develop.yam.finance/ - Devleopment builds
15 | 
16 |
17 | ## Developments
18 |
19 | **Install deps**
20 |
21 | ```sh
22 | yarn install
23 | ```
24 |
25 | **Start the project**
26 |
27 | ```sh
28 | yarn start
29 | ```
30 |
31 | ## Contributions
32 |
33 | If you are interested to contribute feel free to [open an issue](https://github.com/yam-finance/yam-www/issues) or [submit PR](https://github.com/yam-finance/yam-www/pulls) to the `develop` branch. If an issue has the tag `assigned` means it has already been assigned to someone.
34 |
35 | For any other questions or bugs that you like to submit please join [the chat](https://discord.gg/TgFpmDj) to speak about it.
36 |
37 | ## License
38 |
39 | [MIT](LICENSE)
40 |
--------------------------------------------------------------------------------
/crowdin.yml:
--------------------------------------------------------------------------------
1 | preserve_hierarchy: true
2 | files:
3 | - source: /src/assets/locales/en.json
4 | translation: /src/assets/locales/%two_letters_code%.json
5 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "yam-www",
3 | "version": "0.1.0",
4 | "homepage": "./",
5 | "private": true,
6 | "scripts": {
7 | "start": "react-scripts start",
8 | "build": "CI= GENERATE_SOURCEMAP=false react-scripts build",
9 | "lint": "prettier --write \"**/*.+(js|jsx|ts|tsx|json|css)\" --print-width 150",
10 | "eslint": "eslint . --fix",
11 | "test": "react-scripts test",
12 | "eject": "react-scripts eject"
13 | },
14 | "eslintConfig": {
15 | "extends": "react-app"
16 | },
17 | "browserslist": {
18 | "production": [
19 | ">0.2%",
20 | "not dead",
21 | "not op_mini all"
22 | ],
23 | "development": [
24 | "last 1 chrome version",
25 | "last 1 firefox version",
26 | "last 1 safari version"
27 | ]
28 | },
29 | "dependencies": {
30 | "@davatar/react": "^1.8.1",
31 | "@testing-library/jest-dom": "^4.2.4",
32 | "@testing-library/react": "^9.3.2",
33 | "@testing-library/user-event": "^7.1.2",
34 | "@types/numeral": "^0.0.28",
35 | "@types/react-countup": "^4.3.0",
36 | "@types/react-csv": "^1.1.1",
37 | "@types/request": "^2.48.5",
38 | "apexcharts": "^3.21.0",
39 | "bignumber.js": "^9.0.0",
40 | "ethers": "^5.5.2",
41 | "husky": "^4.3.0",
42 | "i18next": "^20.3.1",
43 | "i18next-browser-languagedetector": "^6.1.2",
44 | "lint-staged": "^10.5.0",
45 | "moment": "^2.29.1",
46 | "numeral": "^2.0.6",
47 | "prettier": "^2.1.2",
48 | "rc-progress": "^3.1.0",
49 | "react": "^16.13.1",
50 | "react-apexcharts": "^1.3.7",
51 | "react-countdown": "^2.2.1",
52 | "react-countup": "^4.3.3",
53 | "react-csv": "^2.0.3",
54 | "react-dom": "^16.13.1",
55 | "react-i18next": "^11.11.0",
56 | "react-neu": "^1.0.25",
57 | "react-router-dom": "^5.2.0",
58 | "react-scripts": "3.4.3",
59 | "react-tooltip": "^4.2.10",
60 | "request": "^2.88.2",
61 | "semantic-ui-css": "^2.4.1",
62 | "semantic-ui-react": "^2.0.1",
63 | "styled-components": "^5.2.0",
64 | "use-wallet": "^0.13.6",
65 | "web3": "1.2.11",
66 | "yam-sdk": "^0.0.16-alpha",
67 | "yam-sdk-dev": "^0.0.18-alpha"
68 | },
69 | "devDependencies": {
70 | "@types/react-router-dom": "^5.1.5",
71 | "@types/styled-components": "^5.1.3",
72 | "@types/web3": "^1.2.2",
73 | "react-circular-progressbar": "^2.0.3",
74 | "typescript": "^3.9.7"
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/public/_redirects:
--------------------------------------------------------------------------------
1 | /* /451.html 451! Country=by,cu,ir,iq,ci,lr,kp,sd,sy,zw
2 | /* /index.html 200
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yam-finance/yam-www/1bdaca12a7997013e084d625a6f982b1e3d431ca/public/favicon.ico
--------------------------------------------------------------------------------
/public/hero.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yam-finance/yam-www/1bdaca12a7997013e084d625a6f982b1e3d431ca/public/hero.png
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
32 | YAM Finance
33 |
34 |
35 |
36 |
37 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/public/logo192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yam-finance/yam-www/1bdaca12a7997013e084d625a6f982b1e3d431ca/public/logo192.png
--------------------------------------------------------------------------------
/public/logo512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yam-finance/yam-www/1bdaca12a7997013e084d625a6f982b1e3d431ca/public/logo512.png
--------------------------------------------------------------------------------
/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | },
10 | {
11 | "src": "logo192.png",
12 | "type": "image/png",
13 | "sizes": "192x192"
14 | },
15 | {
16 | "src": "logo512.png",
17 | "type": "image/png",
18 | "sizes": "512x512"
19 | }
20 | ],
21 | "start_url": ".",
22 | "display": "standalone",
23 | "theme_color": "#000000",
24 | "background_color": "#ffffff"
25 | }
26 |
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/src/assets/copy.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
45 |
--------------------------------------------------------------------------------
/src/assets/copy_confirm.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
39 |
--------------------------------------------------------------------------------
/src/assets/documents/Umbrella_Protocol_Lite_Paper.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yam-finance/yam-www/1bdaca12a7997013e084d625a6f982b1e3d431ca/src/assets/documents/Umbrella_Protocol_Lite_Paper.pdf
--------------------------------------------------------------------------------
/src/assets/documents/Umbrella_Protocol_Lite_Paper_CN.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yam-finance/yam-www/1bdaca12a7997013e084d625a6f982b1e3d431ca/src/assets/documents/Umbrella_Protocol_Lite_Paper_CN.pdf
--------------------------------------------------------------------------------
/src/assets/flags/ch-flag.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yam-finance/yam-www/1bdaca12a7997013e084d625a6f982b1e3d431ca/src/assets/flags/ch-flag.png
--------------------------------------------------------------------------------
/src/assets/flags/de-flag.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yam-finance/yam-www/1bdaca12a7997013e084d625a6f982b1e3d431ca/src/assets/flags/de-flag.png
--------------------------------------------------------------------------------
/src/assets/flags/en-flag.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yam-finance/yam-www/1bdaca12a7997013e084d625a6f982b1e3d431ca/src/assets/flags/en-flag.png
--------------------------------------------------------------------------------
/src/assets/flags/es-flag.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yam-finance/yam-www/1bdaca12a7997013e084d625a6f982b1e3d431ca/src/assets/flags/es-flag.png
--------------------------------------------------------------------------------
/src/assets/flags/fr-flag.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yam-finance/yam-www/1bdaca12a7997013e084d625a6f982b1e3d431ca/src/assets/flags/fr-flag.png
--------------------------------------------------------------------------------
/src/assets/flags/he-flag.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yam-finance/yam-www/1bdaca12a7997013e084d625a6f982b1e3d431ca/src/assets/flags/he-flag.png
--------------------------------------------------------------------------------
/src/assets/flags/it-flag.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yam-finance/yam-www/1bdaca12a7997013e084d625a6f982b1e3d431ca/src/assets/flags/it-flag.png
--------------------------------------------------------------------------------
/src/assets/flags/ja-flag.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yam-finance/yam-www/1bdaca12a7997013e084d625a6f982b1e3d431ca/src/assets/flags/ja-flag.png
--------------------------------------------------------------------------------
/src/assets/flags/ko-flag.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yam-finance/yam-www/1bdaca12a7997013e084d625a6f982b1e3d431ca/src/assets/flags/ko-flag.png
--------------------------------------------------------------------------------
/src/assets/flags/ro-flag.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yam-finance/yam-www/1bdaca12a7997013e084d625a6f982b1e3d431ca/src/assets/flags/ro-flag.png
--------------------------------------------------------------------------------
/src/assets/flags/ru-flag.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yam-finance/yam-www/1bdaca12a7997013e084d625a6f982b1e3d431ca/src/assets/flags/ru-flag.png
--------------------------------------------------------------------------------
/src/assets/flags/vi-flag.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yam-finance/yam-www/1bdaca12a7997013e084d625a6f982b1e3d431ca/src/assets/flags/vi-flag.png
--------------------------------------------------------------------------------
/src/assets/fortmatic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yam-finance/yam-www/1bdaca12a7997013e084d625a6f982b1e3d431ca/src/assets/fortmatic.png
--------------------------------------------------------------------------------
/src/assets/locales/en.json:
--------------------------------------------------------------------------------
1 | {
2 | "hello": "Hi",
3 | "bye": "Aurevoir",
4 | "asset-detail-expiry": "is a synthetic that will expire at",
5 | "testString": "This is a test string",
6 | "test": "Il s'agit d'une variable de test: {{testVariable}}"
7 | }
8 |
--------------------------------------------------------------------------------
/src/assets/locales/zh.json:
--------------------------------------------------------------------------------
1 | {
2 | "hello": "你好",
3 | "bye": "傲华",
4 | "asset-detail-expiry": "是一种合成物,将在",
5 | "testString": "This is a test string",
6 | "test": "这是一个测试变量: {{testVariable}}"
7 | }
8 |
--------------------------------------------------------------------------------
/src/assets/metamask-fox.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/assets/mofy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yam-finance/yam-www/1bdaca12a7997013e084d625a6f982b1e3d431ca/src/assets/mofy.png
--------------------------------------------------------------------------------
/src/assets/portis.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yam-finance/yam-www/1bdaca12a7997013e084d625a6f982b1e3d431ca/src/assets/portis.png
--------------------------------------------------------------------------------
/src/assets/wallet-connect.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/src/assets/yamdaohouse.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yam-finance/yam-www/1bdaca12a7997013e084d625a6f982b1e3d431ca/src/assets/yamdaohouse.png
--------------------------------------------------------------------------------
/src/assets/yampp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yam-finance/yam-www/1bdaca12a7997013e084d625a6f982b1e3d431ca/src/assets/yampp.png
--------------------------------------------------------------------------------
/src/components/AddressButton/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./AddressButton";
2 |
--------------------------------------------------------------------------------
/src/components/Bar/Bar.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import styled from "styled-components";
3 | import { useTheme } from "react-neu";
4 | import numeral from "numeral";
5 | import { useCountUp } from 'react-countup';
6 | import { useEffect, useState } from "react";
7 | interface BarProgressProps {
8 | value?: number;
9 | invert?: boolean;
10 | type?: "buffer" | "normal";
11 | }
12 |
13 | const Bar: React.FC = ({ value, invert, type }) => {
14 | if (invert) {
15 | value = 100 - (value || 0);
16 | }
17 | const { darkMode } = useTheme();
18 | const valueCountUp= useCountUp({
19 | start: 0,
20 | end: value ? value: 0,
21 | formattingFn: (val) => val ? ` ${numeral(val).format("0")}` : "Loading ...",
22 | decimals: 0,
23 | duration: 1.3
24 | });
25 | const [progressValue, setProgressValue] = useState(0);
26 | useEffect(() => {
27 | valueCountUp.update(value);
28 | setProgressValue(value? value: 0);
29 | },[value] );
30 |
31 | return (
32 | <>
33 |
34 |
35 | {valueCountUp.countUp}%
36 |
37 | >
38 | );
39 | };
40 |
41 | interface StyledBarProps {
42 | darkMode?: boolean;
43 | }
44 |
45 | interface StyledBarProgressTextProps {
46 | darkMode?: boolean;
47 | }
48 |
49 | const StyledBar = styled.div`
50 | background: ${(props) => (props.darkMode ? props.theme.colors.grey[900] : props.theme.colors.grey[400])};
51 | border-radius: 15px;
52 | position: relative;
53 | overflow: hidden;
54 | height: 2.8rem;
55 | width: 100%;
56 | `;
57 |
58 | const StyledBarInner = styled.div`
59 | background: ${(props) => props.theme.colors.primary.main};
60 | border-radius: 15px;
61 | height: 100%;
62 |
63 | transition: 1s ease;
64 | transition-delay: 0.3s;
65 | `;
66 |
67 | const StyledBarProgressText = styled.div`
68 | cursor: default;
69 | position: relative;
70 | top: 0px;
71 | font-size: 24px;
72 | font-weight: 700;
73 | text-align: center;
74 | line-height: 46px;
75 | color: white;
76 | z-index: 90;
77 | opacity: 0.95;
78 | `;
79 |
80 | export default Bar;
81 |
--------------------------------------------------------------------------------
/src/components/Bar/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./Bar";
2 |
--------------------------------------------------------------------------------
/src/components/BoxWithDisplay/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./BoxWithDisplay";
2 |
--------------------------------------------------------------------------------
/src/components/ClaimCard/ClaimCard.tsx:
--------------------------------------------------------------------------------
1 | import React, { useMemo } from "react";
2 |
3 | import numeral from "numeral";
4 | import { Box, Button, Card, CardActions, CardContent, CardIcon, Spacer } from "react-neu";
5 |
6 | import Label from "components/Label";
7 | import Value from "components/Value";
8 |
9 | import useVesting from "hooks/useVesting";
10 |
11 | const ClaimCard: React.FC = () => {
12 | const { isClaiming, onClaim, vestedBalance } = useVesting();
13 |
14 | const vestingBalanceDisplayValue = useMemo(() => {
15 | if (vestedBalance) {
16 | return numeral(vestedBalance).format("0.00a");
17 | }
18 | return "--";
19 | }, [vestedBalance]);
20 |
21 | const ClaimButton = useMemo(() => {
22 | const hasVestedYams = vestedBalance && vestedBalance.toNumber() > 0;
23 | if (isClaiming) {
24 | return ;
25 | }
26 | if (hasVestedYams) {
27 | return ;
28 | }
29 | return ;
30 | }, [isClaiming, onClaim, vestedBalance]);
31 |
32 | return (
33 |
34 |
35 | 🦋 + 🎁
36 |
37 |
38 |
39 |
40 |
41 |
42 | {ClaimButton}
43 |
44 | );
45 | };
46 |
47 | export default ClaimCard;
48 |
--------------------------------------------------------------------------------
/src/components/ClaimCard/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./ClaimCard";
--------------------------------------------------------------------------------
/src/components/ConfirmTransactionModal/ConfirmTransactionModal.tsx:
--------------------------------------------------------------------------------
1 | import React, { useMemo } from "react";
2 | import { Modal, ModalContent, ModalProps, Spacer } from "react-neu";
3 | import styled from "styled-components";
4 | import { useWallet } from "use-wallet";
5 |
6 | import metamaskLogo from "assets/metamask-fox.svg";
7 | import walletConnectLogo from "assets/wallet-connect.svg";
8 |
9 | const ConfirmTransactionModal: React.FC = ({ isOpen }) => {
10 | const { connector } = useWallet();
11 |
12 | const WalletLogo = useMemo(() => {
13 | if (connector === "injected") {
14 | return
;
15 | } else if (connector === "walletconnect") {
16 | return
;
17 | }
18 | }, [connector]);
19 |
20 | return (
21 |
22 |
23 | {WalletLogo}
24 |
25 | Confirm transaction in wallet.
26 |
27 |
28 | );
29 | };
30 |
31 | const StyledText = styled.div`
32 | font-size: 24px;
33 | text-align: center;
34 | `;
35 |
36 | export default ConfirmTransactionModal;
37 |
--------------------------------------------------------------------------------
/src/components/ConfirmTransactionModal/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./ConfirmTransactionModal";
2 |
--------------------------------------------------------------------------------
/src/components/DarkModeSwitch/DarkModeSwitch.tsx:
--------------------------------------------------------------------------------
1 | import React, { useEffect } from "react";
2 |
3 | import { Emoji, Switch, SwitchButton, useTheme } from "react-neu";
4 |
5 | import useLocalStorage from "hooks/useLocalStorage";
6 |
7 | const DarkModeSwitch: React.FC = () => {
8 | const { darkMode, onToggleDarkMode } = useTheme();
9 | const [_, setDarkModeSetting] = useLocalStorage("darkMode", darkMode);
10 |
11 | useEffect(() => {
12 | if (darkMode) {
13 | document.documentElement.style.setProperty("--gridline-drop-shadow", "drop-shadow( 0px 1px 0px rgba(240, 240, 240, 0.13))");
14 | document.documentElement.style.setProperty("--pagination-text-color", "white");
15 | document.documentElement.style.setProperty("--pagination-background-color", "rgba(45, 32, 36, 0.35)");
16 | } else {
17 | document.documentElement.style.setProperty("--gridline-drop-shadow", "drop-shadow(0 -1px 0px hsl(338deg 20% 90% / 100%))");
18 | document.documentElement.style.setProperty("--pagination-text-color", "black");
19 | document.documentElement.style.setProperty("--pagination-background-color", "rgba(0, 0, 0, 0.05)");
20 | }
21 | setDarkModeSetting(darkMode);
22 | }, [darkMode, setDarkModeSetting]);
23 |
24 | return (
25 |
26 |
27 |
28 |
29 |
30 | );
31 | };
32 |
33 | export default DarkModeSwitch;
34 |
--------------------------------------------------------------------------------
/src/components/DarkModeSwitch/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./DarkModeSwitch";
2 |
--------------------------------------------------------------------------------
/src/components/DegenerativeCard/DegenerativeCard.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 |
3 | import { Box, Button, Card, CardActions, CardContent, CardIcon, Spacer } from "react-neu";
4 |
5 | import Label from "components/Label";
6 | import ValueText from "components/ValueText";
7 | import styled from "styled-components";
8 | const DegenerativeCard: React.FC = () => {
9 |
10 | return (
11 |
12 |
13 |
14 | 🧟
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | );
27 | };
28 | const StyledCard = styled.div`
29 | height:320px;
30 | `;
31 | export default DegenerativeCard;
32 |
--------------------------------------------------------------------------------
/src/components/DegenerativeCard/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./DegenerativeCard";
--------------------------------------------------------------------------------
/src/components/DelegateLP/DelegateLP.tsx:
--------------------------------------------------------------------------------
1 | import React, { useState, useCallback } from 'react';
2 | import { Card, CardTitle, CardContent, Button, Input, Spacer } from "react-neu";
3 | import { validateAddress } from 'utils';
4 | import { useWallet } from 'use-wallet';
5 | import { shorten } from "utils";
6 | import Box from 'components/BoxWithDisplay';
7 | import Split from "components/Split";
8 | import Label from "components/Label";
9 | import useGovernance from "hooks/useGovernance";
10 | import useFarming from "hooks/useFarming";
11 |
12 | export const DelegateLP: React.FC = () => {
13 | const { account } = useWallet();
14 | const [delegatee, setDelegatee] = useState('');
15 |
16 | const {
17 | delegatedAddressLP,
18 | isDelegatedLP,
19 | onDelegateLP,
20 | onRemoveLPDelegation,
21 | } = useGovernance();
22 |
23 | const onChange = (e: any): void => setDelegatee(e.target.value);
24 | const handleTokenDelegation = useCallback(
25 | () => onDelegateLP(delegatee),
26 | [onDelegateLP, delegatee]
27 | );
28 |
29 | const { stakedBalanceYAMETH } = useFarming();
30 | const isStaked = !!stakedBalanceYAMETH && stakedBalanceYAMETH.toNumber() > 0;
31 |
32 | return (
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
49 |
55 |
56 |
57 |
58 |
59 | );
60 | }
61 |
62 | export default DelegateLP;
63 |
--------------------------------------------------------------------------------
/src/components/DelegateLP/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./DelegateLP";
2 |
--------------------------------------------------------------------------------
/src/components/DelegateToken/DelegateToken.tsx:
--------------------------------------------------------------------------------
1 | import React, { useState, useCallback } from 'react';
2 | import { Card, CardTitle, CardContent, Button, Input, Spacer } from "react-neu";
3 | import { validateAddress } from 'utils';
4 | import { useWallet } from 'use-wallet';
5 | import { shorten } from "utils";
6 | import Box from 'components/BoxWithDisplay';
7 | import Split from "components/Split";
8 | import Label from "components/Label";
9 | import useGovernance from "hooks/useGovernance";
10 |
11 | export const DelegateToken: React.FC = () => {
12 | const { account } = useWallet();
13 | const [delegatee, setDelegatee] = useState('');
14 |
15 | const {
16 | delegatedAddressToken,
17 | isDelegatedToken,
18 | onDelegateToken,
19 | onRemoveTokenDelegation,
20 | } = useGovernance();
21 |
22 | const onChange = (e: any): void => setDelegatee(e.target.value);
23 | const handleTokenDelegation = useCallback(
24 | () => onDelegateToken(delegatee),
25 | [onDelegateToken, delegatee]
26 | );
27 |
28 | return (
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
45 |
51 |
52 |
53 |
54 |
55 | );
56 | }
57 |
58 | export default DelegateToken;
59 |
--------------------------------------------------------------------------------
/src/components/DelegateToken/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./DelegateToken";
2 |
--------------------------------------------------------------------------------
/src/components/Dial/Dial.tsx:
--------------------------------------------------------------------------------
1 | import React, { useContext } from "react";
2 |
3 | import { CircularProgressbar, buildStyles } from "react-circular-progressbar";
4 | import { useTheme } from "react-neu";
5 | import styled from "styled-components";
6 |
7 | interface DialProps {
8 | children?: React.ReactNode;
9 | color?: "primary" | "secondary";
10 | disabled?: boolean;
11 | size?: number;
12 | value: number;
13 | }
14 |
15 | const Dial: React.FC = ({ children, color, disabled, size = 256, value }) => {
16 | const { colors } = useTheme();
17 | let pathColor = colors.primary.main;
18 | if (color === "primary") {
19 | pathColor = colors.primary.main;
20 | }
21 |
22 | return (
23 |
24 |
25 |
33 |
34 | {children}
35 |
36 | );
37 | };
38 |
39 | interface StyledInnerProps {
40 | size: number;
41 | }
42 |
43 | const StyledDial = styled.div`
44 | padding: calc(${(props) => props.size}px * 24 / 256);
45 | position: relative;
46 | height: ${(props) => props.size}px;
47 | width: ${(props) => props.size}px;
48 | `;
49 |
50 | const StyledInner = styled.div`
51 | align-items: center;
52 | background: ${(props) => props.theme.baseBg};
53 | border-radius: ${(props) => props.size}px;
54 | display: flex;
55 | justify-content: center;
56 | position: relative;
57 | height: ${(props) => props.size}px;
58 | width: ${(props) => props.size}px;
59 | `;
60 |
61 | const StyledOuter = styled.div`
62 | background-color: ${(props) => props.theme.shadowColor};
63 | border-radius: 10000px;
64 | position: absolute;
65 | top: 0;
66 | right: 0;
67 | bottom: 0;
68 | left: 0;
69 | `;
70 |
71 | export default Dial;
72 |
--------------------------------------------------------------------------------
/src/components/Dial/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./Dial";
2 |
--------------------------------------------------------------------------------
/src/components/ExternalLink/ExternalLink.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import styled from "styled-components";
3 |
4 | interface ExternalLinkProps {
5 | href?: string;
6 | }
7 |
8 | const ExternalLink: React.FC = ({ children, href }) => {children};
9 |
10 | const StyledLink = styled.a`
11 | color: ${(props) => props.theme.colors.primary.light};
12 | &:visited {
13 | color: ${(props) => props.theme.colors.primary.light};
14 | }
15 | `;
16 |
17 | export default ExternalLink;
18 |
--------------------------------------------------------------------------------
/src/components/ExternalLink/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./ExternalLink";
2 |
--------------------------------------------------------------------------------
/src/components/FancyValue/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./FancyValue";
2 |
--------------------------------------------------------------------------------
/src/components/Footer/Footer.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import styled from "styled-components";
3 | import Nav from "./components/Nav";
4 | import DarkModeSwitch from "../DarkModeSwitch";
5 |
6 | const Footer: React.FC = () => (
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | );
18 |
19 | const StyledFooter = styled.footer`
20 | align-items: center;
21 | display: flex;
22 | justify-content: center;
23 | flex-direction: column;
24 | `;
25 |
26 | const StyledFooterInner = styled.div`
27 | align-items: center;
28 | display: flex;
29 | justify-content: center;
30 | height: 72px;
31 | max-width: ${(props) => props.theme.siteWidth}px;
32 | width: 100%;
33 | @media (max-width: 980px) {
34 | display: -webkit-box;
35 | overflow-x: scroll;
36 | }
37 | `;
38 |
39 | const StyledFooterDarkModeSwitch = styled.div`
40 | display: none;
41 | @media (max-width: 1130px) {
42 | display: block;
43 | }
44 | `;
45 |
46 | export default Footer;
47 |
--------------------------------------------------------------------------------
/src/components/Footer/components/Nav.tsx:
--------------------------------------------------------------------------------
1 | import React, { useMemo } from "react";
2 | import { NavLink } from "react-router-dom";
3 | import styled from "styled-components";
4 | import { useWallet } from "use-wallet";
5 | import { contributors } from "utils/misc";
6 |
7 | import footers from 'constants/Footers.json';
8 |
9 | const Nav: React.FC = () => {
10 | const { account, status } = useWallet();
11 |
12 | const CheckContributor = useMemo(() => {
13 | if (status === "connected" && contributors.hasOwnProperty(account?.toLowerCase())) {
14 | return Contributor;
15 | }
16 | }, [status, account]);
17 |
18 | return (
19 |
20 | <>
21 | {footers.map((footer:any, index:any) => (
22 |
23 | {
24 | footer.router ? {footer.name}
25 | : {footer.name}
26 | }
27 |
28 | ))}
29 | >
30 |
31 | );
32 | };
33 |
34 | const StyledNav = styled.nav`
35 | align-items: center;
36 | display: flex;
37 | `;
38 |
39 | const StyledLink = styled.a`
40 | color: ${(props) => props.theme.colors.grey[500]};
41 | padding-left: ${(props) => props.theme.spacing[3]}px;
42 | padding-right: ${(props) => props.theme.spacing[3]}px;
43 | text-decoration: none;
44 | &:hover {
45 | color: ${(props) => props.theme.colors.grey[600]};
46 | }
47 | `;
48 |
49 | const StyledRouterLink = styled(NavLink)`
50 | color: ${(props) => props.theme.colors.grey[500]};
51 | padding-left: ${(props) => props.theme.spacing[3]}px;
52 | padding-right: ${(props) => props.theme.spacing[3]}px;
53 | text-decoration: none;
54 | &:hover {
55 | color: ${(props) => props.theme.colors.grey[600]};
56 | }
57 | `;
58 |
59 | const StyledRouterLinkColor = styled(StyledRouterLink)`
60 | color: ${(props) => props.theme.colors.primary.main};
61 | `;
62 |
63 | export default Nav;
64 |
--------------------------------------------------------------------------------
/src/components/Footer/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./Footer";
2 |
--------------------------------------------------------------------------------
/src/components/Label/Label.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import styled from "styled-components";
3 |
4 | interface LabelProps {
5 | text?: string;
6 | bold?: boolean;
7 | labelPosition?: string;
8 | }
9 |
10 | const Label: React.FC = ({ text, bold, labelPosition }) => {text};
11 |
12 | const StyledLabel = styled.div`
13 | color: ${(props) => props.theme.colors.grey[500]};
14 | font-weight: ${(props) => (props.bold ? "bold" : "normal")};
15 | text-align: ${(props) => (props.labelPosition ? props.labelPosition : "left")};
16 | `;
17 |
18 | export default Label;
19 |
--------------------------------------------------------------------------------
/src/components/Label/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./Label";
2 |
--------------------------------------------------------------------------------
/src/components/LangSwitcher/index.css:
--------------------------------------------------------------------------------
1 | .flag-panel {
2 |
3 |
4 |
5 | box-shadow: rgb(0 0 0 / 1%) 0px 0px 1px, rgb(0 0 0 / 4%) 0px 4px 8px, rgb(0 0 0 / 4%) 0px 16px 24px, rgb(0 0 0 / 1%) 0px 24px 32px;
6 | border-radius: 10px;
7 | padding: 0.5rem;
8 | display: flex;
9 | flex-direction: column;
10 | font-size: 1rem;
11 | position: absolute;
12 | top: 3rem;
13 | right: 0rem;
14 | z-index: 100;
15 | min-width: 10rem;
16 | }
17 | .flag-current {
18 | display: flex;
19 | -webkit-box-pack: center;
20 | justify-content: center;
21 | -webkit-box-align: center;
22 | align-items: center;
23 | position: relative;
24 | border: none;
25 | text-align: left;
26 | }
27 | .flag-current-button {
28 | position: relative;
29 | width: 100%;
30 |
31 | margin: 0px;
32 | padding: 0.15rem 0.5rem;
33 | border: none;
34 | border-radius: 22px;
35 | font-size: 1.25rem;
36 | height: 40px;
37 | cursor: pointer;
38 | }
39 | .flag-current-image {
40 | display: block;
41 | cursor: pointer;
42 | }
43 | .flag-list-image {
44 | display: inline;
45 | margin-right: 0.625rem;
46 | width: 20px;
47 | height: 20px;
48 | vertical-align: middle;
49 |
50 | }
51 | .flag-list-span {
52 | -webkit-box-align: center;
53 | align-items: center;
54 | flex: 1 1 0%;
55 | padding: 0.5rem;
56 | font-weight: 500;
57 | cursor: pointer;
58 |
59 | }
60 | .flag-list-span:hover {
61 | font-weight: bold;
62 | }
--------------------------------------------------------------------------------
/src/components/LangSwitcher/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./LangSwitcher";
2 |
--------------------------------------------------------------------------------
/src/components/Logo/Logo.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import styled from "styled-components";
3 | import { Link } from "react-router-dom";
4 |
5 | const Logo: React.FC = () => {
6 | return (
7 |
8 | 🍠
9 | YAM Finance
10 |
11 | );
12 | };
13 |
14 | const StyledLogo = styled(Link)`
15 | align-items: center;
16 | display: flex;
17 | justify-content: center;
18 | margin: 0;
19 | min-height: 44px;
20 | min-width: 44px;
21 | padding: 0;
22 | text-decoration: none;
23 | `;
24 |
25 | const StyledEmoji = styled.span.attrs({
26 | role: "img",
27 | })`
28 | font-size: 24px;
29 | `;
30 |
31 | const StyledText = styled.span`
32 | color: ${(props) => props.theme.textColor};
33 | font-size: 18px;
34 | font-weight: 700;
35 | margin-left: ${(props) => props.theme.spacing[2]}px;
36 | @media (max-width: 400px) {
37 | display: none;
38 | }
39 | `;
40 |
41 | export default Logo;
42 |
--------------------------------------------------------------------------------
/src/components/Logo/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./Logo";
2 |
--------------------------------------------------------------------------------
/src/components/MofyCard/MofyCard.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 |
3 | import { Box, Button, Card, CardActions, CardContent, CardIcon, Spacer } from "react-neu";
4 |
5 | import Label from "components/Label";
6 | import ValueText from "components/ValueText";
7 | import MofyIcon from "assets/mofy.png";
8 |
9 | import styled from "styled-components";
10 | const MofyCard: React.FC = () => {
11 |
12 | return (
13 |
14 |
15 |
16 | {/**/}
17 | 🖼
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 | );
30 | };
31 | const StyledDiv = styled.div`
32 | text-align:center;
33 | `;
34 | const StyledImg = styled.img`
35 | width:60px;
36 | `;
37 | const StyledCard = styled.div`
38 | height:320px;
39 | `;
40 | export default MofyCard;
41 |
--------------------------------------------------------------------------------
/src/components/MofyCard/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./MofyCard";
--------------------------------------------------------------------------------
/src/components/Page/Page.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import styled from "styled-components";
3 |
4 | import Footer from "../Footer";
5 |
6 | const Page: React.FC = ({ children }) => (
7 |
8 | {children}
9 |
10 |
11 | );
12 |
13 | const StyledPage = styled.div``;
14 |
15 | const StyledMain = styled.div`
16 | align-items: center;
17 | box-sizing: border-box;
18 | display: flex;
19 | flex-direction: column;
20 | min-height: calc(100vh - 160px);
21 | padding: ${(props) => props.theme.spacing[6]}px 0;
22 | `;
23 |
24 | export default Page;
25 |
--------------------------------------------------------------------------------
/src/components/Page/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./Page";
2 |
--------------------------------------------------------------------------------
/src/components/PageHeader/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./PageHeader";
2 |
--------------------------------------------------------------------------------
/src/components/ProjectCard/ProjectCard.tsx:
--------------------------------------------------------------------------------
1 | import { Box, Button, Card, CardActions, CardContent, CardIcon, Spacer } from "react-neu";
2 |
3 | import Label from "components/Label";
4 | import React from "react";
5 | import ValueText from "components/ValueText";
6 | import styled from "styled-components";
7 |
8 | const ProjectCard: React.FC = () => {
9 | return (
10 |
11 |
12 |
13 | 🌂
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | );
26 | };
27 | const StyledCard = styled.div`
28 | height:320px;
29 | `;
30 |
31 | export default ProjectCard;
32 |
--------------------------------------------------------------------------------
/src/components/ProjectCard/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./ProjectCard";
--------------------------------------------------------------------------------
/src/components/RegistrationButton/RegistrationButton.tsx:
--------------------------------------------------------------------------------
1 | import React, { useState } from 'react';
2 | import { Button } from 'react-neu';
3 | import useGovernance from "hooks/useGovernance";
4 | import { useWallet } from "use-wallet";
5 |
6 | interface RegistrationButtonProps {
7 | size?: 'sm' | 'md' | 'lg';
8 | }
9 |
10 | const RegistrationButton: React.FC = ({ size }) => {
11 | const { isRegistered, isRegistering, onRegister, onUnregister } = useGovernance();
12 | const { account } = useWallet();
13 |
14 | const [hover, setHover] = useState(false);
15 |
16 | return (
17 | setHover(true)}
19 | onMouseLeave={() => setHover(false)}
20 | style={{ minWidth: isRegistered ? '128px' : '' }}
21 | >
22 | {!isRegistered
23 | ?
24 | :
25 | }
26 |
27 | )
28 | }
29 |
30 | export default RegistrationButton;
31 |
--------------------------------------------------------------------------------
/src/components/RegistrationButton/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from './RegistrationButton';
--------------------------------------------------------------------------------
/src/components/SeparatorWithCSS/SeparatorWithCSS.tsx:
--------------------------------------------------------------------------------
1 | import React, { useContext, useMemo } from "react";
2 | import styled from "styled-components";
3 |
4 | import { ThemeContext } from "react-neu";
5 |
6 | type SeparatorOrientation = "horizontal" | "vertical";
7 |
8 | interface SeparatorProps {
9 | orientation?: SeparatorOrientation;
10 | stretch?: boolean;
11 | gridArea?: string;
12 | }
13 |
14 | const SeparatorGrid: React.FC = ({ orientation, stretch, gridArea }) => {
15 | const { highlightColor, shadowColor } = useContext(ThemeContext).theme;
16 |
17 | let boxShadow = `0 -1px 0px ${shadowColor}, 0 1px 0px ${highlightColor}`;
18 | if (orientation === "vertical") {
19 | boxShadow = `-1px 0px 0px ${shadowColor}, 1px 0px 0px ${highlightColor}`;
20 | }
21 |
22 | const Content = useMemo(() => {
23 | if (gridArea && !stretch) {
24 | return ;
25 | } else {
26 | return ;
27 | }
28 | }, [boxShadow, orientation]);
29 |
30 | if (stretch && gridArea) {
31 | return (
32 |
40 | {Content}
41 |
42 | );
43 | } else if (stretch) {
44 | return {Content}
;
45 | }
46 |
47 | return Content;
48 | };
49 |
50 | interface StyledSeparatorProps {
51 | boxShadow: string;
52 | orientation?: SeparatorOrientation;
53 | gridArea?: string;
54 | }
55 |
56 | const StyledSeparator = styled.div`
57 | box-shadow: ${(props) => props.boxShadow};
58 | height: ${(props) => (props.orientation === "vertical" ? "100%" : "1px")};
59 | width: ${(props) => (props.orientation === "vertical" ? "1px" : "100%")};
60 | `;
61 |
62 | const StyledSeparatorGrid = styled.div`
63 | box-shadow: ${(props) => props.boxShadow};
64 | height: ${(props) => (props.orientation === "vertical" ? "100%" : "1px")};
65 | width: ${(props) => (props.orientation === "vertical" ? "1px" : "100%")};
66 | display: grid;
67 | grid-area: ${(props) => props.gridArea};
68 | `;
69 |
70 | export default SeparatorGrid;
71 |
--------------------------------------------------------------------------------
/src/components/SeparatorWithCSS/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./SeparatorWithCSS";
2 |
--------------------------------------------------------------------------------
/src/components/Split/Split.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { Spacer } from "react-neu";
3 | import styled from "styled-components";
4 |
5 | const Split: React.FC = ({ children }) => {
6 | const l = React.Children.toArray(children).length;
7 | return (
8 |
9 | {React.Children.map(children, (child, i) => (
10 | <>
11 | {child}
12 | {i < l - 1 && }
13 | >
14 | ))}
15 |
16 | );
17 | };
18 |
19 | const StyledSplit = styled.div`
20 | display: flex;
21 | width: 100%;
22 | @media (max-width: 768px) {
23 | flex-flow: column nowrap;
24 | align-items: center;
25 | }
26 | `;
27 |
28 | const StyledSplitColumn = styled.div`
29 | flex: 1;
30 | @media (max-width: 768px) {
31 | flex: none;
32 | width: 100%;
33 | }
34 | `;
35 |
36 | export default Split;
37 |
--------------------------------------------------------------------------------
/src/components/Split/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./Split";
2 |
--------------------------------------------------------------------------------
/src/components/StartFooter/StartFooter.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import styled from 'styled-components'
3 | import {
4 | Container,
5 | Spacer,
6 | useTheme,
7 | } from 'react-neu'
8 | import { NavLink } from "react-router-dom";
9 |
10 | import Split from 'components/Split'
11 | import footers from 'constants/Footers.json';
12 | import DarkModeSwitch from "../DarkModeSwitch";
13 |
14 | const StartFooter: React.FC = () => {
15 |
16 | const footerItems = footers.filter((footer) => (footer.homeDisplay === true));
17 |
18 | const { darkMode } = useTheme()
19 | return (
20 |
21 |
22 |
23 |
24 | {footerItems.map((footer:any, index:any) => (
25 |
26 | {
27 | footer.router ? {footer.name}
28 | : {footer.name}
29 | }
30 |
31 | ))}
32 |
33 |
34 |
35 |
36 | Built with
37 | ❤️
38 | by the YAM community.
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | )
49 | }
50 |
51 | interface StyledFooterProps {
52 | darkMode?: boolean
53 | }
54 | const StyledFooter = styled.div`
55 | background-color: ${props => props.darkMode ? props.theme.colors.grey[800] : props.theme.colors.grey[300]};
56 | `
57 |
58 | const StyledFooterText = styled.div`
59 | text-align: center;
60 | `
61 |
62 | const StyledLink = styled.a`
63 | color: ${(props) => props.theme.colors.grey[500]};
64 | padding-left: ${(props) => props.theme.spacing[3]}px;
65 | padding-right: ${(props) => props.theme.spacing[3]}px;
66 | text-decoration: none;
67 | &:hover {
68 | color: ${(props) => props.theme.colors.grey[600]};
69 | }
70 | `;
71 |
72 | const StyledRouterLink = styled(NavLink)`
73 | color: ${(props) => props.theme.colors.grey[500]};
74 | padding-left: ${(props) => props.theme.spacing[3]}px;
75 | padding-right: ${(props) => props.theme.spacing[3]}px;
76 | text-decoration: none;
77 | &:hover {
78 | color: ${(props) => props.theme.colors.grey[600]};
79 | }
80 | `;
81 |
82 | const StyledFooterDarkModeSwitch = styled.div`
83 | display: none;
84 | @media (max-width: 1130px) {
85 | display: flex;
86 | justify-content: center;
87 | }
88 | `;
89 |
90 | export default StartFooter;
--------------------------------------------------------------------------------
/src/components/StartFooter/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from './StartFooter'
--------------------------------------------------------------------------------
/src/components/StartPage/StartPage.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import styled from "styled-components";
3 |
4 | import StartFooter from "../StartFooter";
5 |
6 | const StartPage: React.FC = ({ children }) => (
7 |
8 | {children}
9 |
10 |
11 | );
12 |
13 | const StyledPage = styled.div``;
14 |
15 | const StyledMain = styled.div`
16 | align-items: center;
17 | box-sizing: border-box;
18 | display: flex;
19 | flex-direction: column;
20 | min-height: calc(100vh - 215px);
21 | padding: ${(props) => props.theme.spacing[6]}px 0;
22 | `;
23 |
24 | export default StartPage;
25 |
--------------------------------------------------------------------------------
/src/components/StartPage/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./StartPage";
2 |
--------------------------------------------------------------------------------
/src/components/StartPageHeader/StartPageHeader.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 |
3 | import { Container, Spacer } from 'react-neu'
4 | import styled from 'styled-components'
5 |
6 | interface PageHeaderProps {
7 | icon: React.ReactNode,
8 | subtitle?: string,
9 | title?: string,
10 | }
11 |
12 | const PageHeader: React.FC = ({ icon, subtitle, title }) => {
13 | return (
14 |
15 |
16 | {icon}
17 |
18 | {title}
19 |
20 | {subtitle}
21 |
22 |
23 | )
24 | }
25 |
26 | const StyledPageHeader = styled.div`
27 | align-items: center;
28 | box-sizing: border-box;
29 | display: flex;
30 | flex-direction: column;
31 | padding-bottom: ${props => props.theme.spacing[6]}px;
32 | margin: 0 auto;
33 | `
34 |
35 | const StyledIcon = styled.span.attrs({
36 | role: 'img'
37 | })`
38 | font-size: 96px;
39 | min-height: 96px;
40 | line-height: 96px;
41 | text-align: center;
42 | min-width: 96px;
43 | @media (max-width: 768px) {
44 | font-size: 64px;
45 | text-align: left;
46 | }
47 | `
48 |
49 | const StyledTitle = styled.h1`
50 | color: ${props => props.theme.textColor};
51 | font-size: 36px;
52 | font-weight: 700;
53 | margin: 0;
54 | padding: 0;
55 | text-align: center;
56 | @media (max-width: 768px) {
57 | text-align: left;
58 | }
59 | `
60 |
61 | const StyledSubtitle = styled.h3`
62 | color: ${props => props.theme.textColor};
63 | font-size: 18px;
64 | font-weight: 400;
65 | margin: 0;
66 | opacity: 0.66;
67 | padding: 0;
68 | text-align: center;
69 | @media (max-width: 768px) {
70 | text-align: left;
71 | }
72 | `
73 |
74 | export default PageHeader
--------------------------------------------------------------------------------
/src/components/StartPageHeader/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from './StartPageHeader'
--------------------------------------------------------------------------------
/src/components/StartSplit/StartSplit.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import { Spacer } from 'react-neu'
3 | import styled from 'styled-components'
4 |
5 | interface SplitProps {
6 | gapSize?: 'sm' | 'md' | 'lg'
7 | }
8 |
9 | const StartSplit: React.FC = ({ children, gapSize = 'md' }) => {
10 | const l = React.Children.toArray(children).length
11 | return (
12 |
13 | {React.Children.map(children, (child, i) => (
14 | <>
15 |
16 | {child}
17 |
18 | {i < l - 1 && }
19 | >
20 | ))}
21 |
22 | )
23 | }
24 |
25 | const StyledSplit = styled.div`
26 | display: flex;
27 | width: 100%;
28 | @media (max-width: 768px) {
29 | flex-flow: column nowrap;
30 | align-items: center;
31 | }
32 | `
33 |
34 | const StyledSplitColumn = styled.div`
35 | flex: 1;
36 | @media (max-width: 768px) {
37 | flex: none;
38 | width: 100%;
39 | }
40 | `
41 |
42 | export default StartSplit
--------------------------------------------------------------------------------
/src/components/StartSplit/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from './StartSplit'
--------------------------------------------------------------------------------
/src/components/StyledMenu/index.tsx:
--------------------------------------------------------------------------------
1 | import styled from 'styled-components'
2 |
3 | export const StyledMenuButton = styled.button`
4 | position: relative;
5 | width: 100%;
6 | height: 100%;
7 | border: none;
8 | background-color: transparent;
9 | margin: 0;
10 | padding: 0;
11 | height: 35px;
12 | padding: 0.15rem 0.5rem;
13 | border-radius: 10px;
14 | :hover,
15 | :focus {
16 | cursor: pointer;
17 | outline: none;
18 | }
19 | > * {
20 | // stroke: ${({ theme }) => theme.text1};
21 | }
22 | `
23 |
24 | export const StyledMenu = styled.div`
25 | // margin-left: 0.5rem;
26 | display: flex;
27 | justify-content: center;
28 | align-items: center;
29 | position: relative;
30 | border: none;
31 | text-align: left;
32 | `
33 |
34 | export const MenuFlyout = styled.span`
35 | min-width: 8.125rem;
36 | background-color: #161522;
37 | border-radius: 10px;
38 | box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.01), 0px 4px 8px rgba(0, 0, 0, 0.04), 0px 16px 24px rgba(0, 0, 0, 0.04),
39 | 0px 24px 32px rgba(0, 0, 0, 0.01);
40 | padding: 0.5rem;
41 | display: flex;
42 | flex-direction: column;
43 | font-size: 1rem;
44 | position: absolute;
45 | top: 3rem;
46 | right: 0rem;
47 | z-index: 100;
48 | `
49 |
--------------------------------------------------------------------------------
/src/components/StyledNoticeIcon/StyledNoticeIcon.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import styled from "styled-components";
3 |
4 | const StyledNoticeIcon = styled.span`
5 | height: 46px;
6 | font-size: 32px;
7 | display: flex;
8 | align-items: center;
9 | `;
10 |
11 | export default StyledNoticeIcon
--------------------------------------------------------------------------------
/src/components/StyledNoticeIcon/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./StyledNoticeIcon";
2 |
--------------------------------------------------------------------------------
/src/components/TokenInput/TokenInput.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import styled from "styled-components";
3 |
4 | import { Button, Input, InputProps } from "react-neu";
5 |
6 | interface TokenInputProps extends InputProps {
7 | max: number | string;
8 | symbol: string;
9 | onSelectMax?: () => void;
10 | }
11 |
12 | const TokenInput: React.FC = ({ max, symbol, onChange, onSelectMax, value }) => {
13 | return (
14 |
15 |
16 | {max.toLocaleString()} {symbol} Available
17 |
18 |
21 | {symbol}
22 |
23 |
24 |
25 |
26 |
27 | }
28 | onChange={onChange}
29 | placeholder="0"
30 | value={value}
31 | />
32 |
33 | );
34 | };
35 |
36 | const StyledTokenInput = styled.div``;
37 |
38 | const StyledSpacer = styled.div`
39 | width: ${(props) => props.theme.spacing[3]}px;
40 | `;
41 |
42 | const StyledTokenAdornmentWrapper = styled.div`
43 | align-items: center;
44 | display: flex;
45 | `;
46 |
47 | const StyledMaxText = styled.div`
48 | align-items: center;
49 | color: ${(props) => props.theme.colors.grey[500]};
50 | display: flex;
51 | font-size: 14px;
52 | font-weight: 700;
53 | height: 44px;
54 | justify-content: flex-end;
55 | `;
56 |
57 | const StyledTokenSymbol = styled.span`
58 | color: ${(props) => props.theme.colors.grey[600]};
59 | font-weight: 700;
60 | `;
61 |
62 | export default TokenInput;
63 |
--------------------------------------------------------------------------------
/src/components/TokenInput/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./TokenInput";
2 |
--------------------------------------------------------------------------------
/src/components/TopBar/components/StyledLink.tsx:
--------------------------------------------------------------------------------
1 | import React, { useState } from "react";
2 | import styled from "styled-components";
3 |
4 | interface StyledLinkProps {
5 | href?: string;
6 | label?: string;
7 | style?: any;
8 | onDismiss?: () => void;
9 | children?: React.ReactNode;
10 | mobileMenu?: boolean;
11 | }
12 |
13 | const StyledLink: React.FC = ({href, label, style, onDismiss, children, mobileMenu}) => {
14 | const [isShow, setIsShow] = useState(false);
15 | if (children) {
16 | return (
17 | {
19 | if (!mobileMenu) {
20 | setIsShow(true)
21 | }
22 | }}
23 | onMouseLeave={() => {
24 | if (!mobileMenu) {
25 | setIsShow(false)
26 | }
27 | }}
28 | onClick={() => {
29 | if (mobileMenu) {
30 | setIsShow(!isShow)
31 | }
32 | }}
33 | style={mobileMenu ? {cursor: "pointer", width: "100%", textAlign: "left", display: "flex", flexDirection: "column"}
34 | : {cursor: "pointer", width: "100%", textAlign: "left"}}
35 | >
36 | {label}
37 | {
38 | isShow === true &&
39 | {children}
40 |
41 | }
42 |
43 | )
44 | } else {
45 | return (
46 | {label}
47 | )
48 | }
49 | }
50 |
51 | const StyledHyper = styled.a`
52 | color: ${(props) => props.theme.colors.grey[500]};
53 | padding-left: ${(props) => props.theme.spacing[3]}px;
54 | padding-right: ${(props) => props.theme.spacing[3]}px;
55 | text-decoration: none;
56 | font-weight: bold;
57 | &:hover {
58 | color: ${(props) => props.theme.colors.grey[600]};
59 | }
60 | @media (max-width: 770px) {
61 | box-sizing: border-box;
62 | color: ${(props) => props.theme.colors.grey[500]};
63 | font-size: 24px;
64 | font-weight: 700;
65 | padding: ${(props) => props.theme.spacing[3]}px ${(props) => props.theme.spacing[4]}px;
66 | text-align: left;
67 | text-decoration: none;
68 | width: 100%;
69 | &:hover {
70 | color: ${(props) => props.theme.colors.grey[600]};
71 | }
72 | &.active {
73 | color: ${(props) => props.theme.colors.primary.main};
74 | }
75 | }
76 | `;
77 |
78 | const StyledNestedMenu = styled.div`
79 | position: absolute;
80 | display: flex;
81 | flex-direction: column;
82 | @media (max-width: 770px) {
83 | position: relative;
84 | background-color: rgba(194 , 163, 174, 0.33);
85 | padding-left: 30px;
86 | }
87 | `;
88 |
89 | export default StyledLink;
--------------------------------------------------------------------------------
/src/components/TopBar/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./TopBar";
2 |
--------------------------------------------------------------------------------
/src/components/UmbrellaCard/UmbrellaCard.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 |
3 | import { Box, Button, Card, CardActions, CardContent, CardIcon, Spacer } from "react-neu";
4 |
5 | import Label from "components/Label";
6 | import ValueText from "components/ValueText";
7 | import styled from "styled-components";
8 | const UmbrellaCard: React.FC = () => {
9 |
10 | return (
11 |
12 |
13 |
14 | 🌂
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | );
27 | };
28 | const StyledCard = styled.div`
29 | height:320px;
30 | `;
31 |
32 | export default UmbrellaCard;
33 |
--------------------------------------------------------------------------------
/src/components/UmbrellaCard/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./UmbrellaCard";
--------------------------------------------------------------------------------
/src/components/UnlockWalletModal/components/WalletProviderCard.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { Button, Card, CardActions, CardContent, CardIcon, Spacer } from "react-neu";
3 | import styled from "styled-components";
4 |
5 | interface WalletProviderCardProps {
6 | icon: React.ReactNode;
7 | name: string;
8 | onSelect: () => void;
9 | }
10 | const WalletProviderCard: React.FC = ({ icon, name, onSelect }) => (
11 |
12 |
13 | {icon}
14 |
15 | {name}
16 |
17 |
18 |
19 |
20 |
21 | );
22 |
23 | const StyledName = styled.div`
24 | font-size: 18px;
25 | font-weight: 700;
26 | text-align: center;
27 | `;
28 |
29 | export default WalletProviderCard;
30 |
--------------------------------------------------------------------------------
/src/components/UnlockWalletModal/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./UnlockWalletModal";
2 |
--------------------------------------------------------------------------------
/src/components/Value/Value.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 |
3 | import styled from "styled-components";
4 | import { useCountUp } from 'react-countup';
5 | import numeral from "numeral";
6 | import { useEffect } from "react";
7 | interface ValueProps {
8 | value: string;
9 | valueSize?: string;
10 | valueColor?: string;
11 | valuePosition?: string;
12 | valueBold?: string;
13 | decimals?: number;
14 | prefix?: string;
15 | suffix?: string;
16 |
17 | }
18 |
19 | const getFormat = (decimals: number) => {
20 | switch (decimals) {
21 | case 2:
22 | return "0.00a";
23 | case 3:
24 | return "0.000a";
25 | case 4:
26 | return "0.0000a";
27 | case 5:
28 | return "0.00000a";
29 | case 6:
30 | return "0.000000a";
31 | case 7:
32 | return "0.0000000a";
33 | case 8:
34 | return "0.00000000a";
35 | default:
36 | return "0.00a";
37 | }
38 | }
39 |
40 | const Value: React.FC = ({ value, valueSize, valueColor, valuePosition, valueBold, decimals=2, prefix="", suffix="" }) => {
41 | const valueCountUp= useCountUp({
42 | start: 0,
43 | end: numeral(value).value() ? numeral(value).value(): 0,
44 | formattingFn: (val) => val ? `${suffix} ${numeral(val).format(getFormat(decimals))} ${prefix}` : "--",
45 | decimals: decimals,
46 | duration: 1.75
47 | });
48 | useEffect(() => {
49 | valueCountUp.update(numeral(value).value());
50 | },[value] );
51 | return (
52 |
53 | {valueCountUp.countUp}
54 |
55 | );
56 | };
57 |
58 | interface StyledValueProps {
59 | valueSize?: string;
60 | valueColor?: string;
61 | valuePosition?: string;
62 | valueBold?: string;
63 | }
64 |
65 | const StyledValue = styled.div`
66 | color: ${(props) => (props.valueColor ? props.valueColor : props.theme.textColor)};
67 | font-size: ${(props) => (props.valueSize ? props.valueSize : "24px")};
68 | font-weight: ${(props) => (props.valueBold ? props.valueBold : "700")};
69 | text-align: ${(props) => (props.valuePosition ? props.valuePosition : "left")};
70 | line-height: ${(props) => (props.valueSize ? props.valueSize : "normal")};
71 | `;
72 |
73 | export default Value;
74 |
--------------------------------------------------------------------------------
/src/components/Value/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./Value";
2 |
--------------------------------------------------------------------------------
/src/components/ValueText/ValueText.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 |
3 | import styled from 'styled-components'
4 |
5 | interface ValueProps {
6 | value: string,
7 | valueSize?: string,
8 | valueColor?: string,
9 | valuePosition?: string,
10 | valueBold?: string,
11 | }
12 |
13 | const ValueText: React.FC = ({ value, valueSize, valueColor, valuePosition, valueBold }) => {
14 | return (
15 | {value}
16 | )
17 | }
18 |
19 | interface StyledValueProps {
20 | valueSize?: string,
21 | valueColor?: string,
22 | valuePosition?: string;
23 | valueBold?: string;
24 | }
25 |
26 | const StyledValue = styled.div`
27 | color: ${props => (props.valueColor ? props.valueColor : props.theme.textColor)};
28 | font-size: ${props => (props.valueSize ? props.valueSize : "24px")};
29 | font-weight: ${props => (props.valueBold ? props.valueBold : "700")};
30 | text-align: ${props => (props.valuePosition ? props.valuePosition : "left")};
31 | line-height: ${props => (props.valueSize ? props.valueSize : "normal")};
32 | `
33 |
34 | export default ValueText
--------------------------------------------------------------------------------
/src/components/ValueText/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./ValueText";
2 |
--------------------------------------------------------------------------------
/src/components/WalletModal/WalletModal.tsx:
--------------------------------------------------------------------------------
1 | import React, { useCallback, useState, useEffect, useMemo } from "react";
2 | import BigNumber from "bignumber.js";
3 | import { useWallet } from "use-wallet";
4 | import numeral from "numeral";
5 | import { Box, Button, Modal, ModalContent, ModalProps, ModalTitle, Separator, Spacer } from "react-neu";
6 | import FancyValue from "components/FancyValue";
7 | import Split from "components/Split";
8 | import useBalances from "hooks/useBalances";
9 | import useVesting from "hooks/useVesting";
10 | import AddressButton from "components/AddressButton";
11 | import styled from "styled-components";
12 |
13 | const WalletModal: React.FC = ({ isOpen, onDismiss }) => {
14 | const [walletModalIsOpen, setWalletModalIsOpen] = useState(false);
15 | const { account, reset } = useWallet();
16 |
17 | const { isClaiming, onClaim, vestedDelegatorRewardBalance, vestedMigratedBalance, vestedBalance } = useVesting();
18 |
19 | const getDisplayBalance = useCallback((value?: any) => {
20 | if (value) {
21 | return numeral(value).format("0.00a");
22 | } else {
23 | return "--";
24 | }
25 | }, []);
26 |
27 | const handleSignOut = useCallback(() => {
28 | localStorage.removeItem("account");
29 | localStorage.removeItem("walletProvider");
30 | setWalletModalIsOpen(false);
31 | reset();
32 | if (onDismiss) {
33 | onDismiss();
34 | }
35 | }, [reset]);
36 |
37 | useEffect(() => {
38 | isOpen = !isOpen;
39 | }, [setWalletModalIsOpen]);
40 |
41 | return (
42 |
43 |
44 |
45 | {account}
46 | {/* */}
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 | );
64 | };
65 |
66 | const StyledText = styled.div`
67 | font-size: 18px;
68 | text-align: center;
69 | `;
70 |
71 | export default WalletModal;
72 |
--------------------------------------------------------------------------------
/src/components/WalletModal/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./WalletModal";
2 |
--------------------------------------------------------------------------------
/src/components/YamLoader/YamLoader.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import styled, { keyframes } from "styled-components";
3 | import { useTheme } from "react-neu";
4 |
5 | interface LoaderOptions {
6 | space?: number;
7 | }
8 |
9 | const YamLoader: React.FC = ({ space }) => {
10 | const { darkMode } = useTheme();
11 | return (
12 | <>
13 |
14 | >
15 | );
16 | };
17 |
18 | interface StyledBarProps {
19 | darkMode?: boolean;
20 | spaceMode?: number;
21 | }
22 |
23 | const StyledLoader = styled.div`
24 | width: 32px;
25 | height: 32px;
26 | clear: both;
27 | margin: ${(props) => (props.spaceMode ? props.spaceMode / 2 : 10)}px auto;
28 | border: 4px ${(props) => (props.darkMode ? props.theme.colors.grey[900] : props.theme.colors.grey[400])} solid;
29 | border-top: 4px ${(props) => props.theme.colors.primary.main} solid;
30 | border-radius: 50%;
31 | animation: ${() => Spin} 0.4s infinite linear;
32 | `;
33 |
34 | const Spin = keyframes`
35 | from { transform: rotate(0deg); }
36 | to { transform: rotate(359deg); }
37 | `;
38 |
39 | export default YamLoader;
40 |
--------------------------------------------------------------------------------
/src/components/YamLoader/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./YamLoader";
2 |
--------------------------------------------------------------------------------
/src/components/YamReOrgCard/YamReOrgCard.tsx:
--------------------------------------------------------------------------------
1 | import { Box, Button, Card, CardActions, CardContent, CardIcon, Spacer } from "react-neu";
2 |
3 | import Label from "components/Label";
4 | import React from "react";
5 | import ValueText from "components/ValueText";
6 | import styled from "styled-components";
7 |
8 | const YamReOrgCard: React.FC = () => {
9 | return (
10 |
11 |
12 |
13 | 🍠
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
27 |
28 |
29 |
30 | );
31 | };
32 | const StyledCard = styled.div`
33 | height:320px;
34 | `;
35 |
36 | export default YamReOrgCard;
37 |
--------------------------------------------------------------------------------
/src/components/YamReOrgCard/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./YamReOrgCard";
--------------------------------------------------------------------------------
/src/components/YamTreasuriesCard/YamTreasuriesCard.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 |
3 | import { Box, Button, Card, CardActions, CardContent, CardIcon, Container, Spacer } from "react-neu";
4 |
5 | import Label from "components/Label";
6 | import ValueText from "components/ValueText";
7 | import styled from "styled-components";
8 | const YamTreasuriesCard: React.FC = () => {
9 |
10 | return (
11 |
12 |
13 |
14 | 🏡
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | );
27 | };
28 | const StyledCard = styled.div`
29 | height:320px;
30 | `;
31 | export default YamTreasuriesCard;
32 |
--------------------------------------------------------------------------------
/src/components/YamTreasuriesCard/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./YamTreasuriesCard";
--------------------------------------------------------------------------------
/src/components/icons/ForbesIcon.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import { useTheme } from 'react-neu'
3 |
4 | const ForbesIcon: React.FC = () => {
5 | const { textColor } = useTheme()
6 | return (
7 |
14 | )
15 | }
16 |
17 | export default ForbesIcon
--------------------------------------------------------------------------------
/src/components/icons/Gizmodo.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import { useTheme } from 'react-neu'
3 |
4 | const GizmodoIcon: React.FC = () => {
5 | const { textColor } = useTheme()
6 | return (
7 |
13 | )
14 | }
15 |
16 | export default GizmodoIcon
--------------------------------------------------------------------------------
/src/components/icons/Menu.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import styled from "styled-components";
3 |
4 | import { useTheme } from "react-neu";
5 |
6 | interface CloseProps {
7 | color?: string;
8 | }
9 |
10 | const Menu: React.FC = ({ color }) => {
11 | const { textColor } = useTheme();
12 | return (
13 |
14 |
15 |
16 |
17 | );
18 | };
19 |
20 | interface StyledSVGProps {
21 | color: string;
22 | }
23 | const StyledSVG = styled.svg.attrs(() => ({
24 | height: "24",
25 | viewBox: "0 0 24 24",
26 | width: "24",
27 | }))`
28 | fill: ${(props) => props.color};
29 | `;
30 |
31 | export default Menu;
32 |
--------------------------------------------------------------------------------
/src/constants/Footers.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "GitHub",
4 | "url": "https://github.com/yam-finance/yam-www",
5 | "router": false,
6 | "homeDisplay": true
7 | },
8 | {
9 | "name": "Snapshot",
10 | "url": "https://snapshot.page/#/yam",
11 | "router": false,
12 | "homeDisplay": true
13 | },
14 | {
15 | "name": "Twitter",
16 | "url": "https://twitter.com/YamFinance",
17 | "router": false,
18 | "homeDisplay": true
19 | },
20 | {
21 | "name": "Discord",
22 | "url": "https://discord.gg/e75FaW8eW8",
23 | "router": false,
24 | "homeDisplay": true
25 | },
26 | {
27 | "name": "Medium",
28 | "url": "https://medium.com/yam-finance",
29 | "router": false,
30 | "homeDisplay": false
31 | },
32 | {
33 | "name": "Forum",
34 | "url": "https://forum.yam.finance",
35 | "router": false,
36 | "homeDisplay": true
37 | },
38 | {
39 | "name": "Docs",
40 | "url": "https://docs.yam.finance/",
41 | "router": false,
42 | "homeDisplay": false
43 | }
44 | ]
45 |
--------------------------------------------------------------------------------
/src/constants/tokenAddresses.ts:
--------------------------------------------------------------------------------
1 | // YAMDAO related Addresses
2 | // If there is another, easier to find file with this information in the YAM github, this should be mentioned here so it can be referenced and cross-checked when added to or changed.
3 |
4 | //YAM Token Addresses
5 |
6 | //Current
7 | export const yam = "0x0e2298e3b3390e3b945a5456fbf59ecc3f55da16";
8 | export const YAMETHSLPAddress = "0x0f82e57804d0b1f6fab2370a43dcfad3c7cb239c";
9 |
10 | //deprecated
11 | export const yamv2 = "0xaba8cac6866b83ae4eec97dd07ed254282f6ad8a";
12 | export const yamv3 = "0x0AaCfbeC6a24756c20D41914F2caba817C0d8521";
13 |
14 | //YAM Contract Addresses
15 |
16 | //Current
17 | export const ContractGovernor = "0x2da253835967d6e721c6c077157f9c9742934aea";
18 | export const ContractTimelock = "0x8b4f1616751117C38a0f84F9A146cca191ea3EC5";
19 | export const ContractIncentivizer = "0xD67c05523D8ec1c60760Fd017Ef006b9F6e496D0";
20 | export const ContractReserves = "0x97990b693835da58a281636296d2bf02787dea17";
21 | export const ContractMigrator = "0x72CFEd9293cbFB2bfC7515c413048c697C6c811C";
22 | export const ContractMonthlyAllowance = "0x03A882495Bc616D3a1508211312765904Fb062d1";
23 | export const ContractIndexStaking = "0x205Cc7463267861002b27021C7108Bc230603d0F";
24 | export const ContractRedeemer = "0x54D9Ec9E1246F56A1ccbDE0B6fFd76Eb129fFCAA";
25 |
26 | //Deprecated
27 | export const ContractRebaser = "0xd93f403b432d39aa0f736c2021be6051d85a1d55"; //turned off
28 | export const ContractContributorGovernor = "0xdcec4a3aa84f79249c1b5325a06c1560d202dd87"; //never used
29 | export const ContractContribtorTimelock = "0xd40a03e520d49339e91bc58c2c9b8966ee7f490f"; //never used
30 | export const ContractVestingPool = "0xDCf613db29E4d0B35e7e15e93BF6cc6315eB0b82"; //funds removed. YAM in this contract is considered lost
31 | export const reservesContractv2 = "0xCF27cA116dd5C7b4201c75B46489D1c075362087"; //old treasury contract
32 | export const OldContractIncentivizer = "0x5b0501F7041120d36Bc8c6DC3FAeA0b74b32a0Ed";
33 |
34 | //Other Token Addresses
35 |
36 | export const WETH = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2";
37 | export const yUsd = "0x5dbcf33d8c2e976c6b560249878e6f1491bca25c";
38 | export const DPI = "0x1494CA1F11D487c2bBe4543E90080AeBa4BA3C2b";
39 | export const INDEX = "0x0954906da0Bf32d5479e25f46056d22f08464cab";
40 | export const yycrvUniLp = "0xb93Cc05334093c6B3b8Bfd29933bb8d5C031caBC"; //old YAM-yUSD uniswap pool.
41 | export const UMA = "0x04Fa0d235C4abf4BcF4787aF4CF447DE572eF828";
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/src/contexts/Balances/Context.ts:
--------------------------------------------------------------------------------
1 | import { createContext } from "react";
2 |
3 | import { ContextValues } from "./types";
4 |
5 | const Context = createContext({});
6 |
7 | export default Context;
8 |
--------------------------------------------------------------------------------
/src/contexts/Balances/Provider.tsx:
--------------------------------------------------------------------------------
1 | import React, { useCallback, useEffect, useState } from "react";
2 | import BigNumber from "bignumber.js";
3 | import { useWallet } from "use-wallet";
4 | import { provider } from "web3-core";
5 |
6 | import { yamv2 as yamV2Address, yamv3 as yamV3Address, yycrvUniLp as yyrcvUniLpAddress, YAMETHSLPAddress } from "constants/tokenAddresses";
7 | import { getBalance } from "utils";
8 | import Context from "./Context";
9 |
10 | const Provider: React.FC = ({ children }) => {
11 | const [yamV2Balance, setYamV2Balance] = useState();
12 | const [yamV3Balance, setYamV3Balance] = useState();
13 | const [yycrvUniLpBalance, setYycrvUniLpBalance] = useState();
14 | const [YAMETHLPBalance, setYAMETHLPBalance] = useState();
15 |
16 | const { account, ethereum } = useWallet();
17 |
18 | const fetchBalances = useCallback(
19 | async (userAddress: string, provider: provider) => {
20 | const balances = await Promise.all([
21 | await getBalance(provider, yamV2Address, userAddress),
22 | await getBalance(provider, yamV3Address, userAddress),
23 | await getBalance(provider, yyrcvUniLpAddress, userAddress),
24 | await getBalance(provider, YAMETHSLPAddress, userAddress),
25 | ]);
26 | setYamV2Balance(new BigNumber(balances[0]).dividedBy(new BigNumber(10).pow(24)));
27 | setYamV3Balance(new BigNumber(balances[1]).dividedBy(new BigNumber(10).pow(18)));
28 | setYycrvUniLpBalance(new BigNumber(balances[2]).dividedBy(new BigNumber(10).pow(18)));
29 | setYAMETHLPBalance(new BigNumber(balances[3]).dividedBy(new BigNumber(10).pow(18)));
30 | },
31 | [setYamV2Balance, setYamV3Balance, setYycrvUniLpBalance, setYAMETHLPBalance]
32 | );
33 |
34 | useEffect(() => {
35 | if (account && ethereum) {
36 | fetchBalances(account, ethereum);
37 | }
38 | }, [account, ethereum, fetchBalances]);
39 |
40 | useEffect(() => {
41 | if (account && ethereum) {
42 | fetchBalances(account, ethereum);
43 | let refreshInterval = setInterval(() => fetchBalances(account, ethereum), 10000);
44 | return () => clearInterval(refreshInterval);
45 | }
46 | }, [account, ethereum, fetchBalances]);
47 |
48 | return (
49 |
57 | {children}
58 |
59 | );
60 | };
61 |
62 | export default Provider;
63 |
--------------------------------------------------------------------------------
/src/contexts/Balances/index.ts:
--------------------------------------------------------------------------------
1 | export { default as BalancesContext } from "./Context";
2 | export { default as BalancesProvider } from "./Provider";
3 |
4 | export type { ContextValues as BalancesContextValues } from "./types";
5 |
--------------------------------------------------------------------------------
/src/contexts/Balances/types.ts:
--------------------------------------------------------------------------------
1 | import BigNumber from "bignumber.js";
2 |
3 | export interface ContextValues {
4 | yamV2Balance?: BigNumber;
5 | yamV3Balance?: BigNumber;
6 | yycrvUniLpBalance?: BigNumber;
7 | YAMETHLPBalance?: BigNumber;
8 | }
9 |
--------------------------------------------------------------------------------
/src/contexts/Farming/Context.ts:
--------------------------------------------------------------------------------
1 | import { createContext } from "react";
2 |
3 | import { ContextValues } from "./types";
4 |
5 | const Context = createContext({
6 | farmingStartTime: 1600545500000,
7 | onApprove: () => {},
8 | onHarvestYAMYUSD: () => {},
9 | onRedeemYAMYUSD: () => {},
10 | onStakeYAMYUSD: () => {},
11 | onUnstakeYAMYUSD: () => {},
12 | onHarvestYAMETH: () => {},
13 | onRedeemYAMETH: () => {},
14 | onStakeYAMETH: () => {},
15 | onUnstakeYAMETH: () => {},
16 | });
17 |
18 | export default Context;
19 |
--------------------------------------------------------------------------------
/src/contexts/Farming/index.ts:
--------------------------------------------------------------------------------
1 | export { default as FarmingContext } from "./Context";
2 | export { default as FarmingProvider } from "./Provider";
3 |
4 | export type { ContextValues as FarmingContextValues } from "./types";
5 |
--------------------------------------------------------------------------------
/src/contexts/Farming/types.ts:
--------------------------------------------------------------------------------
1 | import BigNumber from "bignumber.js";
2 |
3 | export interface ContextValues {
4 | countdown?: number;
5 | earnedBalance?: BigNumber;
6 | tvl?: number;
7 | apr?: number;
8 | farmingStartTime: number;
9 | isApproved?: boolean;
10 | isApproving?: boolean;
11 | isHarvesting?: boolean;
12 | isRedeeming?: boolean;
13 | isStaking?: boolean;
14 | isUnstaking?: boolean;
15 | onApprove: () => void;
16 | onHarvestYAMYUSD: () => void;
17 | onRedeemYAMYUSD: () => void;
18 | onStakeYAMYUSD: (amount: string) => void;
19 | onUnstakeYAMYUSD: (amount: string) => void;
20 | onHarvestYAMETH: () => void;
21 | onRedeemYAMETH: () => void;
22 | onStakeYAMETH: (amount: string) => void;
23 | onUnstakeYAMETH: (amount: string) => void;
24 | earnedBalanceYAMYUSD?: BigNumber;
25 | stakedBalanceYAMYUSD?: BigNumber;
26 | earnedBalanceYAMETH?: BigNumber;
27 | stakedBalanceYAMETH?: BigNumber;
28 | }
29 |
--------------------------------------------------------------------------------
/src/contexts/Governance/Context.ts:
--------------------------------------------------------------------------------
1 | import { createContext } from "react";
2 | import { ContextValues } from "./types";
3 |
4 | const Context = createContext({
5 | isDelegatedToken: false,
6 | isDelegatedLP: false,
7 | onVote: () => {},
8 | onRegister: () => {},
9 | onUnregister: () => {},
10 | onDelegateToken: () => {},
11 | onDelegateLP: () => {},
12 | onRemoveTokenDelegation: () => {},
13 | onRemoveLPDelegation: () => {},
14 | });
15 |
16 | export default Context;
17 |
--------------------------------------------------------------------------------
/src/contexts/Governance/index.ts:
--------------------------------------------------------------------------------
1 | export { default as GovernanceContext } from "./Context";
2 | export { default as GovernanceProvider } from "./Provider";
3 |
4 | export type { ContextValues as GovernanceContextValues } from "./types";
5 |
--------------------------------------------------------------------------------
/src/contexts/Governance/types.ts:
--------------------------------------------------------------------------------
1 | export interface Proposal {
2 | gov?: string;
3 | description?: string;
4 | state?: string;
5 | id: number;
6 | targets: string[];
7 | signatures: string[];
8 | inputs: string[][];
9 | forVotes: number;
10 | againstVotes: number;
11 | start?: number;
12 | end?: number;
13 | hash: string;
14 | more?: string;
15 | }
16 |
17 | export interface ProposalVotingPower {
18 | hash: string;
19 | power: number;
20 | voted: boolean;
21 | side: boolean;
22 | }
23 |
24 | export interface ContextValues {
25 | proposals?: Proposal[];
26 | votingPowers?: ProposalVotingPower[];
27 | currentPower?: number;
28 | isRegistered?: boolean;
29 | isRegistering?: boolean;
30 | isVoting?: boolean;
31 | isDelegatedToken: boolean;
32 | isDelegatedLP: boolean;
33 | delegatedAddressToken?: string;
34 | delegatedAddressLP?: string;
35 | onVote: (proposal: number, side: boolean) => void;
36 | onRegister: () => void;
37 | onUnregister: () => void;
38 | onDelegateToken: (delegatee: string) => void;
39 | onDelegateLP: (delegatee: string) => void;
40 | onRemoveTokenDelegation: () => void;
41 | onRemoveLPDelegation: () => void;
42 | }
43 |
--------------------------------------------------------------------------------
/src/contexts/Migration/Context.ts:
--------------------------------------------------------------------------------
1 | import { createContext } from "react";
2 |
3 | import { ContextValues } from "./types";
4 |
5 | const Context = createContext({
6 | onApprove: () => {},
7 | onMigrate: () => {},
8 | });
9 |
10 | export default Context;
11 |
--------------------------------------------------------------------------------
/src/contexts/Migration/Provider.tsx:
--------------------------------------------------------------------------------
1 | import React, { useCallback, useState } from "react";
2 | import { useWallet } from "use-wallet";
3 |
4 | import { yamv2 as yamV2Address } from "constants/tokenAddresses";
5 | import useApproval from "hooks/useApproval";
6 | import useYam from "hooks/useYam";
7 | import { migrateV3 } from "yam-sdk/utils";
8 |
9 | import ConfirmTransactionModal from "components/ConfirmTransactionModal";
10 |
11 | import Context from "./Context";
12 |
13 | const Provider: React.FC = ({ children }) => {
14 | const { account } = useWallet();
15 | const yam = useYam();
16 | const [isMigrating, setIsMigrating] = useState(false);
17 | const [confirmTxModalIsOpen, setConfirmTxModalIsOpen] = useState(false);
18 |
19 | const { isApproved, isApproving, onApprove } = useApproval(yamV2Address, yam ? yam.contracts.migrator.options.address : undefined, () =>
20 | setConfirmTxModalIsOpen(false)
21 | );
22 |
23 | const handleApprove = useCallback(() => {
24 | setConfirmTxModalIsOpen(true);
25 | onApprove();
26 | }, [onApprove, setConfirmTxModalIsOpen]);
27 |
28 | const handleMigrationTxSent = useCallback(() => {
29 | setIsMigrating(true);
30 | setConfirmTxModalIsOpen(false);
31 | }, [setIsMigrating, setConfirmTxModalIsOpen]);
32 |
33 | const handleMigrate = useCallback(async () => {
34 | setConfirmTxModalIsOpen(true);
35 | await migrateV3(yam, account, handleMigrationTxSent);
36 | setIsMigrating(false);
37 | }, [account, handleMigrationTxSent, setConfirmTxModalIsOpen, setIsMigrating, yam]);
38 |
39 | return (
40 |
49 | {children}
50 |
51 |
52 | );
53 | };
54 |
55 | export default Provider;
56 |
--------------------------------------------------------------------------------
/src/contexts/Migration/index.ts:
--------------------------------------------------------------------------------
1 | export { default as MigrationContext } from "./Context";
2 | export { default as MigrationProvider } from "./Provider";
3 |
4 | export type { ContextValues as MigrationContextValues } from "./types";
5 |
--------------------------------------------------------------------------------
/src/contexts/Migration/types.ts:
--------------------------------------------------------------------------------
1 | export interface ContextValues {
2 | isApproved?: boolean;
3 | isApproving?: boolean;
4 | isMigrating?: boolean;
5 | onApprove: () => void;
6 | onMigrate: () => void;
7 | }
8 |
--------------------------------------------------------------------------------
/src/contexts/Prices/PricesContext.ts:
--------------------------------------------------------------------------------
1 | import { createContext } from "react";
2 |
3 | interface PricesContextValues {
4 | yamTwap?: number;
5 | }
6 |
7 | const PricesContext = createContext({});
8 |
9 | export default PricesContext;
10 |
--------------------------------------------------------------------------------
/src/contexts/Prices/PricesProvider.tsx:
--------------------------------------------------------------------------------
1 | import React, { useCallback, useEffect, useState } from "react";
2 |
3 | import useYam from "hooks/useYam";
4 | import { bnToDec } from "utils";
5 | import { getCurrentPrice } from "yam-sdk/utils";
6 |
7 | import PricesContext from "./PricesContext";
8 |
9 | const PricesProvider: React.FC = ({ children }) => {
10 | const [yamTwap, setYamTwap] = useState();
11 | const yam = useYam();
12 |
13 | const fetchCurrentPrice = useCallback(async () => {
14 | if (!yam) return;
15 | const price = await getCurrentPrice(yam);
16 | setYamTwap(price);
17 | }, [setYamTwap, yam]);
18 |
19 | useEffect(() => {
20 | fetchCurrentPrice();
21 | let refreshInterval = setInterval(fetchCurrentPrice, 10000);
22 | return () => clearInterval(refreshInterval);
23 | }, [fetchCurrentPrice]);
24 |
25 | return (
26 |
31 | {children}
32 |
33 | );
34 | };
35 |
36 | export default PricesProvider;
37 |
--------------------------------------------------------------------------------
/src/contexts/Prices/index.ts:
--------------------------------------------------------------------------------
1 | export { default as PricesContext } from "./PricesContext";
2 | export { default as PricesProvider } from "./PricesProvider";
3 |
--------------------------------------------------------------------------------
/src/contexts/Tvl/Context.ts:
--------------------------------------------------------------------------------
1 | import { createContext } from "react";
2 |
3 | import { ContextValues } from "./types";
4 |
5 | const Context = createContext({});
6 |
7 | export default Context;
8 |
--------------------------------------------------------------------------------
/src/contexts/Tvl/Provider.tsx:
--------------------------------------------------------------------------------
1 | import React, { useCallback, useEffect, useState } from "react";
2 |
3 | import { useWallet } from "use-wallet";
4 |
5 | import useYam from "hooks/useYam";
6 | import request from "request";
7 |
8 | import Context from "./Context";
9 | import { bnToDec } from "utils";
10 |
11 | const requestHttp = (url:string) => {
12 | return new Promise((resolve, reject) => {
13 | request({
14 | url: url,
15 | json: true,
16 | },
17 | (error, response, body) => {
18 | if (error) {
19 | reject(error);
20 | } else {
21 | resolve(body);
22 | }
23 | }
24 | );
25 | });
26 | };
27 |
28 | const Provider: React.FC = ({ children }) => {
29 | const [tvl, setTVL] = useState();
30 | const [apr, setAPR] = useState();
31 | const yam = useYam();
32 | const { account } = useWallet();
33 |
34 | const fetchTVL = useCallback(async () => {
35 | if (!yam) return;
36 | const data:any = await requestHttp("https://api.yam.finance/tvl");
37 | const tvl = data?.total;
38 | setTVL(tvl);
39 | }, [setTVL, yam]);
40 |
41 |
42 |
43 | useEffect(() => {
44 | fetchTVL();
45 | let refreshInterval = setInterval(fetchTVL, 5000);
46 | return () => clearInterval(refreshInterval);
47 | }, [fetchTVL]);
48 |
49 |
50 | return (
51 |
57 | {children}
58 |
59 | );
60 | };
61 |
62 | export default Provider;
63 |
--------------------------------------------------------------------------------
/src/contexts/Tvl/index.ts:
--------------------------------------------------------------------------------
1 | export { default as TvlContext } from "./Context";
2 | export { default as TvlProvider } from "./Provider";
3 |
4 | export type { ContextValues as TvlContextValues } from "./types";
5 |
--------------------------------------------------------------------------------
/src/contexts/Tvl/types.ts:
--------------------------------------------------------------------------------
1 | import BigNumber from "bignumber.js";
2 |
3 | export interface ContextValues {
4 | tvl?: number;
5 | apr?: number;
6 | }
7 |
--------------------------------------------------------------------------------
/src/contexts/Vesting/Context.ts:
--------------------------------------------------------------------------------
1 | import { createContext } from "react";
2 |
3 | import { ContextValues } from "./types";
4 |
5 | const Context = createContext({
6 | onClaim: () => {},
7 | });
8 |
9 | export default Context;
10 |
--------------------------------------------------------------------------------
/src/contexts/Vesting/Provider.tsx:
--------------------------------------------------------------------------------
1 | import React, { useCallback, useEffect, useState } from "react";
2 |
3 | import BigNumber from "bignumber.js";
4 | import { useWallet } from "use-wallet";
5 |
6 | import useYam from "hooks/useYam";
7 | import { claimVested, currUnclaimedMigratorVesting, currUnclaimedDelegatorRewards, currVested } from "yam-sdk/utils";
8 |
9 | import ConfirmTransactionModal from "components/ConfirmTransactionModal";
10 |
11 | import Context from "./Context";
12 |
13 | const Provider: React.FC = ({ children }) => {
14 | const { account } = useWallet();
15 | const yam = useYam();
16 |
17 | const [vestedBalance, setVestedBalance] = useState();
18 | const [vestedDelegatorRewardBalance, setVestedDelegatorRewardBalance] = useState();
19 | const [vestedMigratedBalance, setVestedMigratedBalance] = useState();
20 |
21 | const [isClaiming, setIsClaiming] = useState(false);
22 | const [confirmTxModalIsOpen, setConfirmtxModalIsOpen] = useState(false);
23 |
24 | const fetchVestedBalances = useCallback(async () => {
25 | const vBal = await currVested(yam, account);
26 | const dRVBal = await currUnclaimedDelegatorRewards(yam, account);
27 | const mVBal = await currUnclaimedMigratorVesting(yam, account);
28 | setVestedBalance(vBal);
29 | setVestedDelegatorRewardBalance(dRVBal);
30 | setVestedMigratedBalance(mVBal);
31 | }, [account, setVestedBalance, setVestedDelegatorRewardBalance, setVestedMigratedBalance, yam]);
32 |
33 | const handleClaimTxSent = useCallback(() => {
34 | setIsClaiming(true);
35 | setConfirmtxModalIsOpen(false);
36 | }, [setIsClaiming, setConfirmtxModalIsOpen]);
37 |
38 | const handleClaim = useCallback(async () => {
39 | setConfirmtxModalIsOpen(true);
40 | await claimVested(yam, account, handleClaimTxSent);
41 | setIsClaiming(false);
42 | }, [account, handleClaimTxSent, setConfirmtxModalIsOpen, setIsClaiming, yam]);
43 |
44 | useEffect(() => {
45 | if (account && yam) {
46 | fetchVestedBalances();
47 | }
48 | }, [account, fetchVestedBalances, yam]);
49 |
50 | useEffect(() => {
51 | if (account && yam) {
52 | fetchVestedBalances();
53 | let refreshInterval = setInterval(fetchVestedBalances, 10000);
54 | return () => clearInterval(refreshInterval);
55 | }
56 | }, [account, yam, fetchVestedBalances]);
57 |
58 | return (
59 |
68 | {children}
69 |
70 |
71 | );
72 | };
73 |
74 | export default Provider;
75 |
--------------------------------------------------------------------------------
/src/contexts/Vesting/index.ts:
--------------------------------------------------------------------------------
1 | export { default as VestingContext } from "./Context";
2 | export { default as VestingProvider } from "./Provider";
3 |
4 | export type { ContextValues as VestingContextValues } from "./types";
5 |
--------------------------------------------------------------------------------
/src/contexts/Vesting/types.ts:
--------------------------------------------------------------------------------
1 | import BigNumber from "bignumber.js";
2 |
3 | export interface ContextValues {
4 | isClaiming?: boolean;
5 | onClaim: () => void;
6 | vestedBalance?: BigNumber;
7 | vestedDelegatorRewardBalance?: BigNumber;
8 | vestedMigratedBalance?: BigNumber;
9 | }
10 |
--------------------------------------------------------------------------------
/src/contexts/YamProvider/YamProvider.tsx:
--------------------------------------------------------------------------------
1 | import React, { createContext, useEffect, useState } from "react";
2 |
3 | import { useWallet } from "use-wallet";
4 |
5 | import { Yam } from "yam-sdk/lib";
6 |
7 | export interface YamContext {
8 | yam?: any;
9 | }
10 |
11 | export const Context = createContext({
12 | yam: undefined,
13 | });
14 |
15 | declare global {
16 | interface Window {
17 | yamsauce: any;
18 | }
19 | }
20 |
21 | const YamProvider: React.FC = ({ children }) => {
22 | const { ethereum } = useWallet();
23 | const [yam, setYam] = useState();
24 |
25 | useEffect(() => {
26 | if (ethereum) {
27 | const yamLib = new Yam(ethereum, "1", false, {
28 | defaultAccount: "",
29 | defaultConfirmations: 1,
30 | autoGasMultiplier: 1.5,
31 | testing: false,
32 | defaultGas: "6000000",
33 | defaultGasPrice: "1000000000000",
34 | accounts: [],
35 | ethereumNodeTimeout: 10000,
36 | });
37 |
38 | setYam(yamLib);
39 | window.yamsauce = yamLib;
40 | }
41 | }, [ethereum]);
42 |
43 | return {children};
44 | };
45 |
46 | export default YamProvider;
47 |
--------------------------------------------------------------------------------
/src/contexts/YamProvider/index.ts:
--------------------------------------------------------------------------------
1 | export { default, Context } from "./YamProvider";
2 |
--------------------------------------------------------------------------------
/src/hooks/useAllowance.ts:
--------------------------------------------------------------------------------
1 | import { useCallback, useEffect, useState } from "react";
2 |
3 | import BigNumber from "bignumber.js";
4 | import { useWallet } from "use-wallet";
5 | import { provider } from "web3-core";
6 |
7 | import { getAllowance } from "utils";
8 |
9 | const useAllowance = (tokenAddress?: string, spenderAddress?: string) => {
10 | const [allowance, setAllowance] = useState();
11 | const { account, ethereum }: { account: string | null; ethereum?: provider } = useWallet();
12 |
13 | const fetchAllowance = useCallback(
14 | async (userAddress: string, provider: provider) => {
15 | if (!spenderAddress || !tokenAddress) {
16 | return;
17 | }
18 | const allowance = await getAllowance(userAddress, spenderAddress, tokenAddress, provider);
19 | setAllowance(new BigNumber(allowance));
20 | },
21 | [setAllowance, spenderAddress, tokenAddress]
22 | );
23 |
24 | useEffect(() => {
25 | if (account && ethereum && spenderAddress && tokenAddress) {
26 | fetchAllowance(account, ethereum);
27 | }
28 | let refreshInterval = setInterval(fetchAllowance, 10000);
29 | return () => clearInterval(refreshInterval);
30 | }, [account, ethereum, spenderAddress, tokenAddress]);
31 |
32 | return allowance;
33 | };
34 |
35 | export default useAllowance;
36 |
--------------------------------------------------------------------------------
/src/hooks/useApproval.ts:
--------------------------------------------------------------------------------
1 | import { useCallback, useState, useEffect } from "react";
2 |
3 | import { useWallet } from "use-wallet";
4 | import { provider } from "web3-core";
5 |
6 | import { approve } from "utils";
7 |
8 | import useAllowance from "./useAllowance";
9 |
10 | const useApproval = (tokenAddress?: string, spenderAddress?: string, onTxHash?: (txHash: string) => void) => {
11 | const allowance = useAllowance(tokenAddress, spenderAddress);
12 | const [isApproving, setIsApproving] = useState(false);
13 | const [isApproved, setIsApproved] = useState(false);
14 |
15 | const { account, ethereum }: { account: string | null; ethereum?: provider } = useWallet();
16 |
17 | const handleApprove = useCallback(async () => {
18 | if (!ethereum || !account || !spenderAddress || !tokenAddress) {
19 | console.log("here", ethereum, account, spenderAddress, tokenAddress)
20 | return;
21 | }
22 | try {
23 | setIsApproving(true);
24 | const result = await approve(account, spenderAddress, tokenAddress, ethereum, onTxHash);
25 | setIsApproved(result);
26 | setIsApproving(false);
27 | } catch (e) {
28 | console.log("error:", e)
29 | setIsApproving(false);
30 | return false;
31 | }
32 | }, [account, ethereum, onTxHash, setIsApproved, setIsApproving, spenderAddress, tokenAddress]);
33 |
34 | useEffect(() => {
35 | if (!!allowance?.toNumber()) {
36 | setIsApproved(true);
37 | }
38 | }, [allowance, setIsApproved]);
39 |
40 | return {
41 | isApproved,
42 | isApproving,
43 | onApprove: handleApprove,
44 | };
45 | };
46 |
47 | export default useApproval;
48 |
--------------------------------------------------------------------------------
/src/hooks/useBalances.ts:
--------------------------------------------------------------------------------
1 | import { useContext } from "react";
2 |
3 | import { BalancesContext } from "contexts/Balances";
4 |
5 | const useBalances = () => {
6 | return {
7 | ...useContext(BalancesContext),
8 | };
9 | };
10 |
11 | export default useBalances;
12 |
--------------------------------------------------------------------------------
/src/hooks/useENS.ts:
--------------------------------------------------------------------------------
1 | import { ethers } from "ethers";
2 | import { useEffect, useState } from "react";
3 |
4 | const useENS = (address: string | null | undefined) => {
5 | const [ensName, setENSName] = useState(null);
6 |
7 | useEffect(() => {
8 | const resolveENS = async () => {
9 | if (address && ethers.utils.isAddress(address)) {
10 | const provider = new ethers.providers.JsonRpcProvider(
11 | "https://cloudflare-eth.com"
12 | );
13 | const ensName = await provider.lookupAddress(address);
14 | setENSName(ensName);
15 | }
16 | };
17 | resolveENS();
18 | }, [address]);
19 |
20 | return { ensName };
21 | };
22 |
23 | export default useENS;
24 |
--------------------------------------------------------------------------------
/src/hooks/useFarming.ts:
--------------------------------------------------------------------------------
1 | import { useContext } from "react";
2 |
3 | import { FarmingContext } from "contexts/Farming";
4 |
5 | const useFarming = () => {
6 | return { ...useContext(FarmingContext) };
7 | };
8 |
9 | export default useFarming;
10 |
--------------------------------------------------------------------------------
/src/hooks/useGovernance.ts:
--------------------------------------------------------------------------------
1 | import { useContext } from "react";
2 |
3 | import { GovernanceContext } from "contexts/Governance";
4 |
5 | const useGovernance = () => {
6 | return { ...useContext(GovernanceContext) };
7 | };
8 |
9 | export default useGovernance;
10 |
--------------------------------------------------------------------------------
/src/hooks/useLocalStorage.ts:
--------------------------------------------------------------------------------
1 | import { useCallback, useState } from "react";
2 |
3 | export default function useLocalStorage(key: string, initialValue: T) {
4 | // State to store our value
5 | // Pass initial state function to useState so logic is only executed once
6 | const [storedValue, setStoredValue] = useState(() => {
7 | try {
8 | // Get from local storage by key
9 | const item = window.localStorage.getItem(key);
10 | // Parse stored json or if none return initialValue
11 | return item ? JSON.parse(item) : initialValue;
12 | } catch (error) {
13 | // If error also return initialValue
14 | console.log(error);
15 | return initialValue;
16 | }
17 | });
18 |
19 | // Return a wrapped version of useState's setter function that ...
20 | // ... persists the new value to localStorage.
21 | const setValue = useCallback((value: T | ((value: T) => T)) => {
22 | try {
23 | // Allow value to be a function so we have same API as useState
24 | const valueToStore = value instanceof Function ? value(storedValue) : value;
25 | // Save state
26 | setStoredValue(valueToStore);
27 | // Save to local storage
28 | window.localStorage.setItem(key, JSON.stringify(valueToStore));
29 | } catch (error) {
30 | // A more advanced implementation would handle the error case
31 | console.log(error);
32 | }
33 | }, []);
34 |
35 | return [storedValue, setValue] as [T, (value: T | ((value: T) => T)) => void];
36 | }
37 |
--------------------------------------------------------------------------------
/src/hooks/useMigration.ts:
--------------------------------------------------------------------------------
1 | import { useContext } from "react";
2 |
3 | import { MigrationContext } from "contexts/Migration";
4 |
5 | const useMigration = () => {
6 | return { ...useContext(MigrationContext) };
7 | };
8 |
9 | export default useMigration;
10 |
--------------------------------------------------------------------------------
/src/hooks/useOnClickOutside.tsx:
--------------------------------------------------------------------------------
1 | import { RefObject, useEffect, useRef } from 'react'
2 |
3 | export function useOnClickOutside(
4 | node: RefObject,
5 | handler: undefined | (() => void)
6 | ) {
7 | const handlerRef = useRef void)>(handler)
8 | useEffect(() => {
9 | handlerRef.current = handler
10 | }, [handler])
11 |
12 | useEffect(() => {
13 | const handleClickOutside = (e: MouseEvent) => {
14 | if (node.current?.contains(e.target as Node) ?? false) {
15 | return
16 | }
17 | if (handlerRef.current) handlerRef.current()
18 | }
19 |
20 | document.addEventListener('mousedown', handleClickOutside)
21 |
22 | return () => {
23 | document.removeEventListener('mousedown', handleClickOutside)
24 | }
25 | }, [node])
26 | }
27 |
--------------------------------------------------------------------------------
/src/hooks/usePrices.ts:
--------------------------------------------------------------------------------
1 | import { useContext } from "react";
2 |
3 | import { PricesContext } from "contexts/Prices";
4 |
5 | const usePrices = () => {
6 | return { ...useContext(PricesContext) };
7 | };
8 |
9 | export default usePrices;
10 |
--------------------------------------------------------------------------------
/src/hooks/useSDK.ts:
--------------------------------------------------------------------------------
1 | import { ProposalVotingPower } from "contexts/Governance/types";
2 | import { ethers } from "ethers";
3 | import { useCallback, useEffect, useState } from "react";
4 | import { useWallet } from "use-wallet";
5 | import Yam from "yam-sdk-dev";
6 |
7 | const useSDK = () => {
8 | const { ethereum } = useWallet();
9 | const [yamSDK, setYamSDK] = useState();
10 | // Contracts
11 | const [yamContract, setYamContract] = useState();
12 | const [govContract, setGovContract] = useState();
13 | const [redeemerContract, setRedeemerContract] = useState();
14 |
15 | // Functions
16 | const [yamBalance, setYamBalance] = useState();
17 | const [yamBalanceOf, setYamBalanceOf] = useState();
18 | const [govProposals, setGovProposals] = useState([]);
19 |
20 | const fetchSDK = useCallback(async () => {
21 | if (ethereum && Yam != undefined) {
22 | const provider = new ethers.providers.Web3Provider(ethereum);
23 | const yamSDK = await new Yam({
24 | provider: provider,
25 | });
26 | const yamContract = await yamSDK.contracts.token;
27 | const govContract = await yamSDK.contracts.governor;
28 | const redeemerContract = await yamSDK.contracts.redeemer;
29 | setYamSDK(yamSDK);
30 | setYamContract(yamContract);
31 | setGovContract(govContract);
32 | setRedeemerContract(redeemerContract);
33 | const userYamBalance = await yamContract.balance();
34 | const userBalanceOfYam = await yamContract.balanceOf(yamContract.signer.getAddress());
35 | console.log("userBalanceOfYam", userBalanceOfYam);
36 | const govProposals = await govContract.getRecentProposals();
37 | let govProposalsSorted = govProposals.sort((a: any, b: any) => {
38 | if (a && b && a.end && b.end) {
39 | if (a.end === b.end) {
40 | return 0;
41 | }
42 | if (a.end < b.end) {
43 | return 1;
44 | } else {
45 | return -1;
46 | }
47 | } else {
48 | return 0;
49 | }
50 | });
51 | setYamBalance(userYamBalance);
52 | setYamBalanceOf(userBalanceOfYam);
53 | setGovProposals(govProposalsSorted);
54 | }
55 | }, [ethereum]);
56 |
57 | useEffect(() => {
58 | fetchSDK();
59 | }, [ethereum]);
60 |
61 | return {
62 | yamSDK,
63 | yamContract,
64 | govContract,
65 | redeemerContract,
66 | yamBalance,
67 | yamBalanceOf,
68 | govProposals,
69 | };
70 | };
71 |
72 | export default useSDK;
73 |
--------------------------------------------------------------------------------
/src/hooks/useTokenBalance.ts:
--------------------------------------------------------------------------------
1 | import { useCallback, useEffect, useState } from "react";
2 |
3 | import BigNumber from "bignumber.js";
4 | import { useWallet } from "use-wallet";
5 | import { provider } from "web3-core";
6 |
7 | import { bnToDec, getBalance } from "utils";
8 |
9 | const useTokenBalance = (accountAddress?: string, tokenAddress?: string, decimals = 18) => {
10 | const [balance, setBalance] = useState();
11 | const { ethereum } = useWallet();
12 |
13 | const fetchBalance = useCallback(async () => {
14 | if (!accountAddress || !ethereum || !tokenAddress) {
15 | return;
16 | }
17 | const bal = await getBalance(ethereum, tokenAddress, accountAddress);
18 | setBalance(bnToDec(new BigNumber(bal), decimals));
19 | }, [accountAddress, decimals, ethereum, tokenAddress]);
20 |
21 | useEffect(() => {
22 | fetchBalance();
23 | }, [accountAddress, decimals, ethereum, tokenAddress]);
24 | return balance;
25 | };
26 |
27 | export default useTokenBalance;
28 |
--------------------------------------------------------------------------------
/src/hooks/useTvl.ts:
--------------------------------------------------------------------------------
1 | import { useContext } from "react";
2 |
3 | import { TvlContext } from "contexts/Tvl";
4 |
5 | const useTvl = () => {
6 | return { ...useContext(TvlContext) };
7 | };
8 |
9 | export default useTvl;
10 |
--------------------------------------------------------------------------------
/src/hooks/useVesting.ts:
--------------------------------------------------------------------------------
1 | import { useContext } from "react";
2 |
3 | import { VestingContext } from "contexts/Vesting";
4 |
5 | const useVesting = () => {
6 | return { ...useContext(VestingContext) };
7 | };
8 |
9 | export default useVesting;
10 |
--------------------------------------------------------------------------------
/src/hooks/useYam.ts:
--------------------------------------------------------------------------------
1 | import { useContext } from "react";
2 | import { Context } from "../contexts/YamProvider";
3 |
4 | const useYam = () => {
5 | const { yam } = useContext(Context);
6 | return yam;
7 | };
8 |
9 | export default useYam;
10 |
--------------------------------------------------------------------------------
/src/index.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import ReactDOM from "react-dom";
3 | import 'semantic-ui-css/semantic.min.css';
4 | import "./index.css";
5 | import './plugins/i18n';
6 | import App from "./App";
7 | import * as serviceWorker from "./serviceWorker";
8 |
9 | ReactDOM.render(
10 |
11 |
12 | ,
13 | document.getElementById("root")
14 | );
15 |
16 | // If you want your app to work offline and load faster, you can change
17 | // unregister() to register() below. Note this comes with some pitfalls.
18 | // Learn more about service workers: https://bit.ly/CRA-PWA
19 | serviceWorker.unregister();
20 |
--------------------------------------------------------------------------------
/src/plugins/i18n.ts:
--------------------------------------------------------------------------------
1 | import i18next from 'i18next';
2 | import { initReactI18next } from 'react-i18next';
3 | import LanguageDetector from 'i18next-browser-languagedetector';
4 | import zh from '../assets/locales/zh.json';
5 | import en from '../assets/locales/en.json';
6 |
7 | i18next
8 | .use(initReactI18next)
9 | .use(LanguageDetector)
10 | .init({
11 | resources: {
12 | zh: {
13 | translation: zh,
14 | },
15 | en: {
16 | translation: en,
17 | },
18 | },
19 | lng: 'en',
20 | fallbackLng: 'en',
21 | supportedLngs: ['zh', 'en'],
22 | nonExplicitSupportedLngs: true,
23 | interpolation: {
24 | escapeValue: false,
25 | },
26 | debug: process.env.NODE_ENV === 'development',
27 | });
28 |
29 | export default i18next;
30 |
--------------------------------------------------------------------------------
/src/react-app-env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
--------------------------------------------------------------------------------
/src/setupTests.js:
--------------------------------------------------------------------------------
1 | // jest-dom adds custom jest matchers for asserting on DOM nodes.
2 | // allows you to do things like:
3 | // expect(element).toHaveTextContent(/react/i)
4 | // learn more: https://github.com/testing-library/jest-dom
5 | import "@testing-library/jest-dom/extend-expect";
6 |
--------------------------------------------------------------------------------
/src/utils/misc.ts:
--------------------------------------------------------------------------------
1 |
2 | export const contributors: any = {
3 | "0x4a29e88cea7e1505db9b6491c749fb5d6d595265": { id: 12, amount: 30000 },
4 | "0x8a8acf1cecc4ed6fe9c408449164ce2034adc03f": { id: 100, amount: 4048 * 2 },
5 | "0xc3edcbe0f93a6258c3933e86ffaa3bcf12f8d695": { id: 15, amount: 30000 },
6 | "0xbdac5657edd13f47c3dd924eaa36cf1ec49672cc": { id: 16, amount: 30000 },
7 | "0x01e0c7b70e0e05a06c7cc8deeb97fa03d6a77c9c": { id: 85, amount: 3190 * 3 },
8 | "0xdadc6f71986643d9e9cb368f08eb6f1333f6d8f9": { id: 94, amount: 1587 * 3 },
9 | "0x3fdced6b5c1f176b543e5e0b841cb7224596c33c": { id: 87, amount: 3143 * 3 },
10 | "0x31920DF2b31B5f7ecf65BDb2c497DE31d299d472": { id: 73, amount: 2857 * 3 },
11 | "0xbe9Bb7a473DE5c043146B24AbfA72AB81aee67CD": { id: 89, amount: 9524 * 3 },
12 | "0x392027fDc620d397cA27F0c1C3dCB592F27A4dc3": { id: 90, amount: 2381 * 3 },
13 | "0x386568164bdC5B105a66D8Ae83785D4758939eE6": { id: 91, amount: 2857 * 3 },
14 | "0x88c868B1024ECAefDc648eb152e91C57DeA984d0": { id: 88, amount: 2381 * 3 },
15 | };
16 |
--------------------------------------------------------------------------------
/src/views/Addresses/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./Addresses";
2 |
--------------------------------------------------------------------------------
/src/views/Claim/Claim.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { Container, Spacer } from "react-neu";
3 |
4 | import Page from "components/Page";
5 | import PageHeader from "components/PageHeader";
6 | import Split from "components/Split";
7 | import ClaimCard from "components/ClaimCard";
8 |
9 | const Claim: React.FC = () => {
10 | return (
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | );
21 | };
22 |
23 | export default Claim;
24 |
--------------------------------------------------------------------------------
/src/views/Claim/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./Claim";
2 |
--------------------------------------------------------------------------------
/src/views/Contributor/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./Contributor";
2 |
--------------------------------------------------------------------------------
/src/views/Dashboard/Dashboard.tsx:
--------------------------------------------------------------------------------
1 | import useDashboard from "hooks/useDashboard";
2 |
3 | import React, { useCallback, useMemo, useState } from "react";
4 | import { Box, Button, Container } from "react-neu";
5 |
6 | import Page from "components/Page";
7 | import PageHeader from "components/PageHeader";
8 | import Charts from "./components/Charts";
9 | import TopCards from "./components/TopCards";
10 | import AssetsList from "./components/AssetsList";
11 | import { useWallet } from "use-wallet";
12 | import LanguageSwitcher from "../../components/LangSwitcher";
13 | import { useTranslation } from 'react-i18next';
14 | import UnlockWalletModal from "components/UnlockWalletModal";
15 |
16 | const Dashboard: React.FC = () => {
17 | const { account } = useWallet();
18 | const { assetsData, yamObject, assetsColors } = useDashboard();
19 | const [unlockModalIsOpen, setUnlockModalIsOpen] = useState(false);
20 | const { t } = useTranslation();
21 |
22 | const handleDismissUnlockModal = useCallback(() => {
23 | setUnlockModalIsOpen(false);
24 | }, [setUnlockModalIsOpen]);
25 |
26 | const handleUnlockWalletClick = useCallback(() => {
27 | setUnlockModalIsOpen(true);
28 | }, [setUnlockModalIsOpen]);
29 |
30 | return (
31 |
32 |
33 |
34 |
35 | {/* */}
36 | {account
37 | ?
38 | : (
39 | <>
40 |
41 |
42 |
43 |
44 | >
45 | )
46 | }
47 |
48 |
49 | );
50 | };
51 |
52 | export default Dashboard;
53 |
--------------------------------------------------------------------------------
/src/views/Dashboard/components/Asset.tsx:
--------------------------------------------------------------------------------
1 | import React, { Fragment } from "react";
2 |
3 | import SeparatorGrid from "components/SeparatorWithCSS";
4 | import Box from "components/BoxWithDisplay";
5 |
6 | import styled from "styled-components";
7 | import numeral from "numeral";
8 |
9 | interface ProposalProps {
10 | prop: any;
11 | }
12 |
13 | export const AssetEntry: React.FC = ({ prop }) => {
14 | return (
15 |
16 |
17 |
18 |
19 |
20 |
21 | {prop.name}
22 |
23 |
24 |
25 | {prop.symbol}
26 |
27 | {numeral(prop.quantity).format("0,0.00")}
28 |
29 | {"$" + numeral(prop.price).format("0,0.00")}
30 |
31 | {numeral(prop.change).format("0.00a") + "%"}
32 |
33 | {"$" + numeral(prop.value).format("0,0.00")}
34 |
35 |
36 |
37 | );
38 | };
39 |
40 | interface StyledFieldProps {
41 | gridArea?: string;
42 | }
43 |
44 | export const StyledTokenNameMain = styled.span`
45 | font-weight: 600;
46 | display: grid;
47 | grid-area: name;
48 | @media (max-width: 768px) {
49 | flex-flow: column nowrap;
50 | align-items: flex-start;
51 | }
52 | `;
53 |
54 | const StyledField = styled.span`
55 | font-weight: 600;
56 | margin-left: 5px;
57 | margin-right: 5px;
58 | display: grid;
59 | grid-area: ${(props) => props.gridArea};
60 | justify-content: center;
61 | min-width: 67px;
62 | @media (max-width: 768px) {
63 | flex-flow: column nowrap;
64 | align-items: flex-start;
65 | }
66 | `;
67 |
68 | export const StyledAssetContentInner = styled.div`
69 | align-items: center;
70 | display: grid;
71 | min-width: 768px;
72 | grid-template-columns: 20fr 5px 10fr 5px 20fr 5px 20fr 5px 12fr 5px 18fr;
73 | grid-template-areas: "name spacer1 symbol spacer2 quantity spacer3 price spacer4 change spacer5 value";
74 | grid-template-rows: 100fr;
75 | @media (max-width: 768px) {
76 | flex-flow: column nowrap;
77 | }
78 | `;
79 |
--------------------------------------------------------------------------------
/src/views/Dashboard/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./Dashboard";
2 |
--------------------------------------------------------------------------------
/src/views/Delegate/Delegate.tsx:
--------------------------------------------------------------------------------
1 | import React, { useState, useCallback } from 'react';
2 | import { Container, Spacer, Button } from "react-neu";
3 | import { useWallet } from "use-wallet";
4 | import Page from 'components/Page';
5 | import PageHeader from "components/PageHeader";
6 | import Box from 'components/BoxWithDisplay';
7 | import UnlockWalletModal from "components/UnlockWalletModal";
8 | import DelegateToken from 'components/DelegateToken';
9 | import DelegateLP from 'components/DelegateLP';
10 |
11 | const Delegate = () => {
12 | const { account } = useWallet();
13 | const [unlockModalIsOpen, setUnlockModalIsOpen] = useState(false);
14 |
15 | const handleDismissUnlockModal = useCallback(() => {
16 | setUnlockModalIsOpen(false);
17 | }, [setUnlockModalIsOpen]);
18 |
19 | const handleUnlockWalletClick = useCallback(() => {
20 | setUnlockModalIsOpen(true);
21 | }, [setUnlockModalIsOpen])
22 |
23 | return (
24 |
25 |
26 |
27 | {account
28 | ? (
29 | <>
30 |
31 |
32 |
33 | >
34 | )
35 | : (
36 | <>
37 |
38 |
39 |
40 |
41 | >
42 | )
43 | }
44 |
45 |
46 | );
47 | }
48 |
49 | export default Delegate;
50 |
--------------------------------------------------------------------------------
/src/views/Delegate/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./Delegate";
--------------------------------------------------------------------------------
/src/views/FAQ/components/Question.tsx:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useRef } from "react";
2 |
3 | import { Box, Emoji, Spacer, useTheme } from "react-neu";
4 | import styled from "styled-components";
5 |
6 | interface QuestionProps {
7 | active?: boolean;
8 | question: string;
9 | slug: string;
10 | }
11 |
12 | const Question: React.FC = ({ active, children, question, slug }) => {
13 | const ref = useRef(null);
14 | const l = React.Children.toArray(children).length;
15 |
16 | useEffect(() => {
17 | if (active) {
18 | if (ref.current !== null) {
19 | ref.current.scrollIntoView({ behavior: "smooth", block: "start" });
20 | }
21 | }
22 | }, [active]);
23 |
24 | return (
25 |
26 |
27 |
28 | {active && (
29 | <>
30 |
31 |
32 | >
33 | )}
34 | {question}
35 |
36 |
37 | {React.Children.map(children, (child, i) => (
38 | <>
39 | {child}
40 | {i < l - 1 && }
41 | >
42 | ))}
43 |
44 |
45 | );
46 | };
47 |
48 | interface StyledQuestionLinkProps {
49 | active?: boolean;
50 | }
51 | const StyledQuestionLink = styled.a`
52 | color: ${(props) => (props.active ? props.theme.colors.primary.main : props.theme.textColor)};
53 | display: block;
54 | font-size: 24px;
55 | font-weight: 700;
56 | `;
57 |
58 | export default Question;
59 |
--------------------------------------------------------------------------------
/src/views/FAQ/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./FAQ";
2 |
--------------------------------------------------------------------------------
/src/views/Farm/components/Harvest/Harvest.tsx:
--------------------------------------------------------------------------------
1 | import React, { useCallback, useEffect, useMemo, useState } from "react";
2 |
3 | import numeral from "numeral";
4 | import { Box, Button, Card, CardActions, CardContent, CardIcon, Spacer } from "react-neu";
5 | import { useWallet } from "use-wallet";
6 |
7 | import Label from "components/Label";
8 | import Value from "components/Value";
9 |
10 | import useFarming from "hooks/useFarming";
11 |
12 | import { bnToDec } from "utils";
13 |
14 | const Harvest: React.FC = () => {
15 | const [earnedBalance, setEarnedBalance] = useState(0);
16 | const { status } = useWallet();
17 | const { earnedBalanceYAMETH, isHarvesting, isRedeeming, onHarvestYAMETH } = useFarming();
18 |
19 | const formattedEarnedBalance = useCallback(async () => {
20 | if (earnedBalanceYAMETH && bnToDec(earnedBalanceYAMETH) > 0) {
21 | setEarnedBalance(bnToDec(earnedBalanceYAMETH));
22 | } else {
23 | setEarnedBalance(0);
24 | }
25 | }, [earnedBalanceYAMETH]);
26 |
27 | useEffect(() => {
28 | formattedEarnedBalance();
29 | let refreshInterval = setInterval(formattedEarnedBalance, 10000);
30 | return () => clearInterval(refreshInterval);
31 | }, [formattedEarnedBalance]);
32 |
33 | const HarvestAction = useMemo(() => {
34 | if (status !== "connected") {
35 | return ;
36 | }
37 | if (!isHarvesting) {
38 | return ;
39 | }
40 | if (isHarvesting) {
41 | return ;
42 | }
43 | }, [isHarvesting, isRedeeming, earnedBalance, onHarvestYAMETH]);
44 |
45 | return (
46 | <>
47 |
48 |
49 | 🍠
50 |
51 |
52 | 0 ? earnedBalance.toString() : "--"} />
53 |
54 |
55 |
56 | {HarvestAction}
57 |
58 | >
59 | );
60 | };
61 |
62 | export default Harvest;
63 |
--------------------------------------------------------------------------------
/src/views/Farm/components/Harvest/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./Harvest";
2 |
--------------------------------------------------------------------------------
/src/views/Farm/components/HarvestLPsNoticeYAMYUSD.tsx:
--------------------------------------------------------------------------------
1 | import BigNumber from "bignumber.js";
2 | import useFarming from "hooks/useFarming";
3 | import React, { useCallback, useEffect, useMemo, useState } from "react";
4 | import { Box, Button, Notice, NoticeContent, Spacer } from "react-neu";
5 | import styled from "styled-components";
6 | import { useWallet } from "use-wallet";
7 | import { bnToDec } from "utils";
8 | import StyledNoticeIcon from "components/StyledNoticeIcon";
9 |
10 | const HarvestLPsNoticeYAMYUSD: React.FC = () => {
11 | const [stakedBalanceYUSDLP, setStakedBalanceYUSDLP] = useState(0);
12 | const [earnedBalanceYUSDLP, setEarnedBalanceYUSDLP] = useState(0);
13 | const { stakedBalanceYAMYUSD, earnedBalanceYAMYUSD, onRedeemYAMYUSD, onHarvestYAMYUSD } = useFarming();
14 | const { status } = useWallet();
15 |
16 | const checkOldStakedEarned = useCallback(() => {
17 | if (status !== "connected") {
18 | return;
19 | }
20 |
21 | if (stakedBalanceYAMYUSD) {
22 | setStakedBalanceYUSDLP(bnToDec(stakedBalanceYAMYUSD));
23 | }
24 | if (earnedBalanceYAMYUSD) {
25 | setEarnedBalanceYUSDLP(bnToDec(earnedBalanceYAMYUSD));
26 | }
27 | }, [stakedBalanceYAMYUSD, earnedBalanceYAMYUSD, setStakedBalanceYUSDLP, setEarnedBalanceYUSDLP]);
28 |
29 | useEffect(() => {
30 | checkOldStakedEarned();
31 | let refreshInterval = setInterval(() => checkOldStakedEarned(), 100000);
32 | return () => clearInterval(refreshInterval);
33 | }, [checkOldStakedEarned]);
34 |
35 | const HarvestNotice = useMemo(() => {
36 | if (status === "connected" && (stakedBalanceYUSDLP > 0 || earnedBalanceYUSDLP > 0)) {
37 | return (
38 | <>
39 |
40 | ❗
41 |
42 |
43 |
44 | You was farming on the old pool with{" "}
45 | {(stakedBalanceYUSDLP ? stakedBalanceYUSDLP + " LP tokens" : "") +
46 | (stakedBalanceYUSDLP && earnedBalanceYUSDLP ? " and you have " : "") +
47 | (earnedBalanceYUSDLP ? earnedBalanceYUSDLP.toFixed(2) + " Yam!" : "")}{" "}
48 |
49 |
50 |
51 |
52 |
58 |
59 |
60 |
61 |
62 |
63 | >
64 | );
65 | }
66 | }, [status, stakedBalanceYAMYUSD, stakedBalanceYUSDLP]);
67 |
68 | return <>{HarvestNotice}>;
69 | };
70 |
71 | const StyledNoticeContentInner = styled.div`
72 | align-items: center;
73 | display: flex;
74 | @media (max-width: 768px) {
75 | flex-flow: column nowrap;
76 | align-items: flex-start;
77 | }
78 | `;
79 |
80 | export default HarvestLPsNoticeYAMYUSD;
81 |
--------------------------------------------------------------------------------
/src/views/Farm/components/PausedLPsNotice.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { Box, Button, Notice, NoticeContent, Spacer } from "react-neu";
3 | import styled from "styled-components";
4 | import StyledNoticeIcon from "components/StyledNoticeIcon";
5 |
6 | const PausedLPsNotice: React.FC = () => (
7 | <>
8 |
9 | 💧
10 |
11 |
12 | LP rewards are paused for now, remove your liquidity.
13 |
14 |
15 |
21 |
22 |
23 |
24 |
25 | >
26 | );
27 |
28 | const StyledNoticeContentInner = styled.div`
29 | align-items: center;
30 | display: flex;
31 | @media (max-width: 768px) {
32 | flex-flow: column nowrap;
33 | align-items: flex-start;
34 | }
35 | `;
36 |
37 | export default PausedLPsNotice;
38 |
--------------------------------------------------------------------------------
/src/views/Farm/components/ResumedLPsNotice.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { Box, Button, Notice, NoticeContent, Spacer } from "react-neu";
3 | import styled from "styled-components";
4 | import StyledNoticeIcon from "components/StyledNoticeIcon";
5 |
6 | const ResumedLPsNotice: React.FC = () => (
7 | <>
8 |
9 | 💧
10 |
11 |
12 | Deposit YAM-ETH in Sushiswap LP and come back here to stake!
13 |
14 |
15 |
21 |
22 |
23 |
24 |
25 | >
26 | );
27 |
28 | const StyledNoticeContentInner = styled.div`
29 | align-items: center;
30 | display: flex;
31 | @media (max-width: 768px) {
32 | flex-flow: column nowrap;
33 | align-items: flex-start;
34 | }
35 | `;
36 |
37 | export default ResumedLPsNotice;
38 |
--------------------------------------------------------------------------------
/src/views/Farm/components/Stake/components/StakeModal.tsx:
--------------------------------------------------------------------------------
1 | import React, { useCallback, useMemo, useState } from "react";
2 |
3 | import BigNumber from "bignumber.js";
4 | import { Button, Modal, ModalActions, ModalContent, ModalProps, ModalTitle } from "react-neu";
5 |
6 | import TokenInput from "components/TokenInput";
7 | import useBalances from "hooks/useBalances";
8 | import { getFullDisplayBalance } from "utils";
9 |
10 | interface StakeModalProps extends ModalProps {
11 | onStake: (amount: string) => void;
12 | }
13 |
14 | const StakeModal: React.FC = ({ isOpen, onDismiss, onStake }) => {
15 | const [val, setVal] = useState("");
16 | const { yycrvUniLpBalance, YAMETHLPBalance } = useBalances();
17 |
18 | const fullBalance = useMemo(() => {
19 | return getFullDisplayBalance(YAMETHLPBalance || new BigNumber(0), 0);
20 | }, [YAMETHLPBalance]);
21 |
22 | const handleChange = useCallback(
23 | (e: React.FormEvent) => {
24 | setVal(e.currentTarget.value);
25 | },
26 | [setVal]
27 | );
28 |
29 | const handleSelectMax = useCallback(() => {
30 | setVal(fullBalance);
31 | }, [fullBalance, setVal]);
32 |
33 | const handleStakeClick = useCallback(() => {
34 | onStake(val);
35 | }, [onStake, val]);
36 |
37 | return (
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | );
49 | };
50 |
51 | export default StakeModal;
52 |
--------------------------------------------------------------------------------
/src/views/Farm/components/Stake/components/UnstakeModal.tsx:
--------------------------------------------------------------------------------
1 | import React, { useCallback, useMemo, useState } from "react";
2 |
3 | import BigNumber from "bignumber.js";
4 | import { Button, Modal, ModalActions, ModalContent, ModalProps, ModalTitle } from "react-neu";
5 |
6 | import TokenInput from "components/TokenInput";
7 |
8 | import useFarming from "hooks/useFarming";
9 | import { getFullDisplayBalance } from "utils";
10 |
11 | interface UnstakeModalProps extends ModalProps {
12 | onUnstake: (amount: string) => void;
13 | }
14 |
15 | const UnstakeModal: React.FC = ({ isOpen, onDismiss, onUnstake }) => {
16 | const [val, setVal] = useState("");
17 | const { stakedBalanceYAMETH } = useFarming();
18 |
19 | const fullBalance = useMemo(() => {
20 | return getFullDisplayBalance(stakedBalanceYAMETH || new BigNumber(0));
21 | }, [stakedBalanceYAMETH]);
22 |
23 | const handleChange = useCallback(
24 | (e: React.FormEvent) => {
25 | setVal(e.currentTarget.value);
26 | },
27 | [setVal]
28 | );
29 |
30 | const handleSelectMax = useCallback(() => {
31 | setVal(fullBalance);
32 | }, [fullBalance, setVal]);
33 |
34 | const handleUnstakeClick = useCallback(() => {
35 | onUnstake(val);
36 | }, [onUnstake, val]);
37 |
38 | return (
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
52 |
53 |
54 | );
55 | };
56 |
57 | export default UnstakeModal;
58 |
--------------------------------------------------------------------------------
/src/views/Farm/components/Stake/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./Stake";
2 |
--------------------------------------------------------------------------------
/src/views/Farm/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./Farm";
2 |
--------------------------------------------------------------------------------
/src/views/Governance/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./Governance";
2 |
--------------------------------------------------------------------------------
/src/views/Home/Home.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { Container, Spacer, useTheme } from "react-neu";
3 |
4 | import Page from "components/Page";
5 | import PageHeader from "components/PageHeader";
6 |
7 | import useBalances from "hooks/useBalances";
8 | import useVesting from "hooks/useVesting";
9 |
10 | import MigrationNotice from "./components/MigrationNotice";
11 | import RegisterVoteNotice from "./components/RegisterVoteNotice";
12 | import Treasury from "./components/Treasury";
13 | import VestingNotice from "./components/VestingNotice";
14 |
15 | const Home: React.FC = () => {
16 | const { darkMode } = useTheme();
17 | const { yamV2Balance } = useBalances();
18 | const { vestedBalance } = useVesting();
19 | return (
20 |
21 |
26 |
27 |
28 |
29 | {yamV2Balance && yamV2Balance.toNumber() > 0 && (
30 | <>
31 |
32 |
33 | >
34 | )}
35 | {vestedBalance && vestedBalance.toNumber() > 0 && (
36 | <>
37 |
38 |
39 | >
40 | )}
41 |
42 |
43 |
44 | );
45 | };
46 |
47 | export default Home;
48 |
--------------------------------------------------------------------------------
/src/views/Home/components/MigrationNotice.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 |
3 | import { Box, Button, Notice, NoticeContent, Spacer } from "react-neu";
4 | import styled from "styled-components";
5 | import StyledNoticeIcon from "components/StyledNoticeIcon";
6 |
7 | const MigrationNotice: React.FC = () => {
8 | return (
9 |
10 | 🦋
11 |
12 |
13 | You have unmigrated YAMV2 tokens!
14 |
15 |
16 |
17 |
18 |
19 |
20 | );
21 | };
22 |
23 | const StyledNoticeContentInner = styled.div`
24 | align-items: center;
25 | display: flex;
26 | @media (max-width: 768px) {
27 | flex-flow: column nowrap;
28 | align-items: flex-start;
29 | }
30 | `;
31 |
32 | export default MigrationNotice;
33 |
--------------------------------------------------------------------------------
/src/views/Home/components/RegisterVoteNotice.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { Notice, NoticeContent, Box, Spacer, Button } from "react-neu";
3 | import RegistrationButton from 'components/RegistrationButton';
4 | import styled from "styled-components";
5 | import StyledNoticeIcon from "components/StyledNoticeIcon";
6 |
7 | import useGovernance from 'hooks/useGovernance';
8 |
9 | const RegisterVoteNotice: React.FC = () => {
10 | const { isRegistered } = useGovernance();
11 |
12 | return (
13 |
14 | {isRegistered ? "✔️" : "🗣️"}
15 |
16 |
17 | {isRegistered ? `You've successfuly registered to vote!` : `It's time to register to vote for onchain and Snapshot proposals.`}
18 |
19 |
20 | {!isRegistered && }
21 |
22 |
23 |
24 | );
25 | };
26 |
27 | const StyledNoticeContentInner = styled.div`
28 | align-items: center;
29 | display: flex;
30 | @media (max-width: 768px) {
31 | flex-flow: column nowrap;
32 | align-items: flex-start;
33 | }
34 | `;
35 |
36 | export default RegisterVoteNotice;
37 |
--------------------------------------------------------------------------------
/src/views/Home/components/Stats.tsx:
--------------------------------------------------------------------------------
1 | import React, { useCallback, useEffect, useState } from "react";
2 |
3 | import numeral from "numeral";
4 | import { Box, Card, CardContent, Spacer } from "react-neu";
5 |
6 | import FancyValue from "components/FancyValue";
7 | import useYam from "hooks/useYam";
8 | import { bnToDec } from "utils";
9 | import { getCurrentPrice, getScalingFactor } from "yam-sdk/utils";
10 |
11 | const Stats: React.FC = () => {
12 | const [currentPrice, setCurrentPrice] = useState();
13 | const [scalingFactor, setScalingFactor] = useState();
14 | const yam = useYam();
15 | const fetchStats = useCallback(async () => {
16 | if (!yam) return;
17 | const price = await getCurrentPrice(yam);
18 | const factor = await getScalingFactor(yam);
19 | setCurrentPrice(numeral(bnToDec(price)).format("0.00a"));
20 | setScalingFactor(numeral(bnToDec(factor)).format("0.00a"));
21 | }, [setCurrentPrice, setScalingFactor, yam]);
22 | useEffect(() => {
23 | fetchStats();
24 | let refreshInterval = setInterval(fetchStats, 10000);
25 | return () => clearInterval(refreshInterval);
26 | }, [fetchStats, yam]);
27 | return (
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | );
48 | };
49 |
50 | export default Stats;
51 |
--------------------------------------------------------------------------------
/src/views/Home/components/VestingNotice.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 |
3 | import { Box, Button, Notice, NoticeContent, Spacer } from "react-neu";
4 | import styled from "styled-components";
5 | import StyledNoticeIcon from "components/StyledNoticeIcon";
6 |
7 | const VestingNotice: React.FC = () => {
8 | return (
9 |
10 | 🎁
11 |
12 |
13 | You have unclaimed vested YAM tokens.
14 |
15 |
16 |
17 |
18 |
19 |
20 | );
21 | };
22 |
23 | const StyledNoticeContentInner = styled.div`
24 | align-items: center;
25 | display: flex;
26 | @media (max-width: 768px) {
27 | flex-flow: column nowrap;
28 | align-items: flex-start;
29 | }
30 | `;
31 |
32 | export default VestingNotice;
33 |
--------------------------------------------------------------------------------
/src/views/Home/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./Home";
2 |
--------------------------------------------------------------------------------
/src/views/Migrate/Migrate.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { Container, Spacer } from "react-neu";
3 |
4 | import Page from "components/Page";
5 | import PageHeader from "components/PageHeader";
6 | import Split from "components/Split";
7 | import ClaimCard from "components/ClaimCard";
8 |
9 | import MigrateCard from "./components/MigrateCard";
10 | import VestingNotice from "./components/VestingNotice";
11 | import EndingMigrationNotice from "./components/EndingMigrationNotice";
12 |
13 | const Migrate: React.FC = () => {
14 | return (
15 |
16 |
17 |
18 | {/**
19 | *
20 |
21 | */}
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 | );
31 | };
32 |
33 | export default Migrate;
34 |
--------------------------------------------------------------------------------
/src/views/Migrate/components/EndingMigrationNotice.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { Box, Button, Notice, NoticeContent, Spacer } from "react-neu";
3 | import styled from "styled-components";
4 | import StyledNoticeIcon from "components/StyledNoticeIcon";
5 |
6 | const EndingMigrationNotice: React.FC = () => (
7 |
8 | ❗
9 |
10 |
11 | For all Yam holders, Yam will be ending the migration on February 15th 2021 00:00 UTC. If you have any Yam v2, you can migrate it to v3 below.
12 |
13 |
14 |
15 | );
16 |
17 | const StyledNoticeContentInner = styled.div`
18 | align-items: center;
19 | display: flex;
20 | @media (max-width: 768px) {
21 | flex-flow: column nowrap;
22 | align-items: flex-start;
23 | }
24 | `;
25 |
26 | export default EndingMigrationNotice;
27 |
--------------------------------------------------------------------------------
/src/views/Migrate/components/MigrateCard.tsx:
--------------------------------------------------------------------------------
1 | import React, { useMemo } from "react";
2 |
3 | import numeral from "numeral";
4 | import { Box, Button, Card, CardActions, CardContent, CardIcon, Spacer } from "react-neu";
5 | import { useWallet } from "use-wallet";
6 |
7 | import Label from "components/Label";
8 | import Value from "components/Value";
9 |
10 | import useBalances from "hooks/useBalances";
11 | import useMigration from "hooks/useMigration";
12 |
13 | const MigrateCard: React.FC = () => {
14 | const { status } = useWallet();
15 | const { yamV2Balance } = useBalances();
16 | const { isApproved, isApproving, isMigrating, onApprove, onMigrate } = useMigration();
17 |
18 | const yamV2DisplayBalance = useMemo(() => {
19 | if (yamV2Balance) {
20 | return numeral(yamV2Balance).format("0.00a");
21 | } else {
22 | return "--";
23 | }
24 | }, [yamV2Balance]);
25 |
26 | const ActionButton = useMemo(() => {
27 | const hasYams = yamV2Balance && yamV2Balance.toNumber() > 0;
28 | if (isMigrating) {
29 | return ;
30 | }
31 | if (isApproved) {
32 | return ;
33 | }
34 | return (
35 |
42 | );
43 | }, [status, isApproved, isApproving, isMigrating, onApprove, onMigrate, yamV2Balance]);
44 |
45 | return (
46 |
47 |
48 |
49 | 🍠
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | {ActionButton}
58 |
59 | );
60 | };
61 |
62 | export default MigrateCard;
63 |
--------------------------------------------------------------------------------
/src/views/Migrate/components/VestingNotice.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { Box, Button, Notice, NoticeContent, Spacer } from "react-neu";
3 | import styled from "styled-components";
4 | import StyledNoticeIcon from "components/StyledNoticeIcon";
5 |
6 | const VestingNotice: React.FC = () => (
7 |
8 | ⚠️
9 |
10 |
11 | Migrated tokens are subject to a vesting schedule before they are claimable.
12 |
13 |
14 |
15 |
16 |
17 | );
18 |
19 | const StyledNoticeContentInner = styled.div`
20 | align-items: center;
21 | display: flex;
22 | @media (max-width: 768px) {
23 | flex-flow: column nowrap;
24 | align-items: flex-start;
25 | }
26 | `;
27 |
28 | export default VestingNotice;
29 |
--------------------------------------------------------------------------------
/src/views/Migrate/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./Migrate";
2 |
--------------------------------------------------------------------------------
/src/views/Projects/Projects.tsx:
--------------------------------------------------------------------------------
1 | import React, { useCallback, useState, useEffect } from "react";
2 | import { Container, Spacer } from "react-neu";
3 |
4 | import Page from "components/Page";
5 | import PageHeader from "components/PageHeader";
6 | import Split from "components/Split";
7 | import YamTreasuriesCard from "components/YamTreasuriesCard";
8 | import YamReOrgCard from "components/YamReOrgCard";
9 |
10 | const WORKERS = [
11 | '👷',
12 | '👷♂️',
13 | '👷🏽',
14 | '👷🏻',
15 | '👷🏾',
16 | '👷🏽♀️',
17 | '👷🏻♀️',
18 | '👷🏼♀️',
19 | '👷🏼♀️',
20 | '👷🏾♀️',
21 | '👷🏿♂️'
22 | ]
23 |
24 | const Projects: React.FC = () => {
25 |
26 | const [worker, setWorker] = useState('👷')
27 |
28 | const updateWorker = useCallback(() => {
29 | const newWorker = WORKERS[Math.floor(Math.random() * WORKERS.length)]
30 | setWorker(newWorker)
31 | }, [setWorker])
32 |
33 | useEffect(() => {
34 | const refresh = setInterval(updateWorker, 1000)
35 | return () => clearInterval(refresh)
36 | }, [updateWorker])
37 |
38 | return (
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 | {/* */}
47 | {/* */}
48 | {/* */}
49 |
50 |
51 |
52 | );
53 | };
54 |
55 |
56 | export default Projects;
57 |
--------------------------------------------------------------------------------
/src/views/Projects/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./Projects";
2 |
--------------------------------------------------------------------------------
/src/views/Redemption/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./Redemption";
2 |
--------------------------------------------------------------------------------
/src/views/Registration/Registration.tsx:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useCallback, useState } from "react";
2 | import { Container, Spacer, Button } from "react-neu";
3 |
4 | import Page from "components/Page";
5 | import PageHeader from "components/PageHeader";
6 | import Split from "components/Split";
7 |
8 | import RegisterNotice from "./components/RegisterNotice";
9 | import RegistrationButton from 'components/RegistrationButton';
10 | import styled from "styled-components";
11 | import { useWallet } from "use-wallet";
12 |
13 | const Registration: React.FC = () => {
14 | const { account } = useWallet();
15 |
16 | return (
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 | );
32 | };
33 |
34 | export const StyledButtonMain = styled.div`
35 | font-weight: 600;
36 | display: grid;
37 | grid-area: vote;
38 | margin-left: 10px;
39 | justify-content: center;
40 | @media (max-width: 768px) {
41 | flex-flow: column nowrap;
42 | align-items: flex-start;
43 | }
44 | `;
45 |
46 | export default Registration;
47 |
--------------------------------------------------------------------------------
/src/views/Registration/components/RegisterNotice.tsx:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { Notice, NoticeContent, Box, Spacer } from "react-neu";
3 | import styled from "styled-components";
4 | import StyledNoticeIcon from "components/StyledNoticeIcon";
5 |
6 | import useGovernance from 'hooks/useGovernance';
7 |
8 | const RegisterNotice: React.FC = () => {
9 | const { isRegistered } = useGovernance();
10 |
11 | return (
12 |
13 | {isRegistered ? "✔️" : "🗣️"}
14 |
15 |
16 | {isRegistered ? `You've successfuly registered!` : `To vote for on-chain and Snapshot proposals you must first register.`}
17 |
18 |
19 |
20 |
21 | );
22 | };
23 |
24 | const StyledNoticeContentInner = styled.div`
25 | align-items: center;
26 | display: flex;
27 | @media (max-width: 768px) {
28 | flex-flow: column nowrap;
29 | align-items: flex-start;
30 | }
31 | `;
32 |
33 | export default RegisterNotice;
34 |
--------------------------------------------------------------------------------
/src/views/Registration/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./Registration";
2 |
--------------------------------------------------------------------------------
/src/views/Start/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./Start";
2 |
--------------------------------------------------------------------------------
/src/views/TVL/TVL.tsx:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useCallback, useState } from "react";
2 | import { Container, Spacer, Card, CardContent, } from "react-neu";
3 |
4 | import { useCountUp } from 'react-countup';
5 |
6 | import numeral from "numeral";
7 | import Page from "components/Page";
8 | import PageHeader from "components/PageHeader";
9 |
10 | import styled from "styled-components";
11 | import { useWallet } from "use-wallet";
12 |
13 | import useTvl from "hooks/useTvl";
14 |
15 | const TVL: React.FC = () => {
16 | const { account } = useWallet();
17 | const {tvl} = useTvl();
18 |
19 | const { countUp , start, update } = useCountUp({
20 | start: 0,
21 | end: tvl ? tvl: 0,
22 | formattingFn: (val) => val ? `TVL $${numeral(val).format("000,000,000")}` : "Loading TVL...",
23 | decimals: 0,
24 | duration: 1.75
25 | });
26 | useEffect(() => {
27 | update(tvl);
28 | }, [tvl]);
29 |
30 |
31 |
32 |
33 | return (
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | {countUp}
42 |
43 |
44 |
45 |
46 |
47 | );
48 | };
49 |
50 | export const StyledButtonMain = styled.div`
51 | font-weight: 600;
52 | display: grid;
53 | grid-area: vote;
54 | margin-left: 10px;
55 | justify-content: center;
56 | @media (max-width: 768px) {
57 | flex-flow: column nowrap;
58 | align-items: flex-start;
59 | }
60 | `;
61 |
62 | export default TVL;
63 |
--------------------------------------------------------------------------------
/src/views/TVL/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./TVL";
2 |
--------------------------------------------------------------------------------
/src/views/TokenValues/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./TokenValues";
2 |
--------------------------------------------------------------------------------
/src/views/User/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from "./User";
2 |
--------------------------------------------------------------------------------
/src/yam-sdk-files/dist/Yam.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | var __importDefault = (this && this.__importDefault) || function (mod) {
3 | return (mod && mod.__esModule) ? mod : { "default": mod };
4 | };
5 | Object.defineProperty(exports, "__esModule", { value: true });
6 | exports.Yam = void 0;
7 | const Token_1 = require("./lib/contracts/Token");
8 | const Governor_1 = require("./lib/contracts/Governor");
9 | const Redeemer_1 = require("./lib/contracts/Redeemer");
10 | const yam_json_1 = __importDefault(require("./utils/abis/yam.json"));
11 | const governor_json_1 = __importDefault(require("./utils/abis/governor.json"));
12 | const timelock_json_1 = __importDefault(require("./utils/abis/timelock.json"));
13 | const incentivizer_json_1 = __importDefault(require("./utils/abis/incentivizer.json"));
14 | const migrator_json_1 = __importDefault(require("./utils/abis/migrator.json"));
15 | const redeemer_json_1 = __importDefault(require("./utils/abis/redeemer.json"));
16 | const tokens_1 = __importDefault(require("./utils/tokens"));
17 | class Yam {
18 | // config!: any;
19 | // read!: any;
20 | // write!: any;
21 | /**
22 | * Initialize the SDK instance.
23 | * @param params - Parameters the SDK takes on creation { provider, signer }
24 | */
25 | constructor(params) {
26 | this.signer = params.signer || params.provider.getSigner();
27 | this.provider = params.provider;
28 | this.chainId = this.getChainId();
29 | this.tokens = tokens_1.default;
30 | this.abis = {
31 | token: yam_json_1.default,
32 | governor: governor_json_1.default,
33 | timelock: timelock_json_1.default,
34 | incentivizer: incentivizer_json_1.default,
35 | migrator: migrator_json_1.default,
36 | redeemer: redeemer_json_1.default,
37 | };
38 | this.contracts = {
39 | token: new Token_1.YamToken(this.abis, this.signer),
40 | governor: new Governor_1.YamGovernor(this.abis, this.signer),
41 | redeemer: new Redeemer_1.YamRedeemer(this.abis, this.signer),
42 | };
43 | this.loaded = Promise.all([]);
44 | }
45 | async getChainId() {
46 | return await this.signer.getChainId();
47 | }
48 | async checkYam() {
49 | return 200 * 10 ** 24;
50 | }
51 | }
52 | exports.Yam = Yam;
53 |
--------------------------------------------------------------------------------
/src/yam-sdk-files/dist/index.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | Object.defineProperty(exports, "__esModule", { value: true });
3 | const Yam_1 = require("./Yam");
4 | exports.default = Yam_1.Yam;
5 |
--------------------------------------------------------------------------------
/src/yam-sdk-files/dist/lib/contracts/Redeemer.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | Object.defineProperty(exports, "__esModule", { value: true });
3 | exports.YamRedeemer = void 0;
4 | const ethers_1 = require("ethers");
5 | const Token_1 = require("./Token");
6 | const bn = ethers_1.ethers.BigNumber;
7 | const BASE24 = bn.from(10).pow(24);
8 | const BASE18 = bn.from(10).pow(18);
9 | const BASE6 = bn.from(10).pow(6);
10 | class YamRedeemer {
11 | constructor(abis, signer) {
12 | this.abis = abis;
13 | this.signer = signer;
14 | this.contract = new ethers_1.ethers.Contract(this.abis.redeemer.address, this.abis.redeemer.abi, this.signer);
15 | this.address = this.abis.redeemer.address;
16 | this.yamToken = new Token_1.YamToken(this.abis, this.signer);
17 | }
18 | // Read functions
19 | async checkAllowance(addressOwner) {
20 | const allowance = await this.yamToken.allowance(addressOwner, this.abis.redeemer.address);
21 | console.log("allowance", allowance);
22 | return bn.from(allowance);
23 | }
24 | async previewRedeem(yamBalance) {
25 | const previewBalances = await this.contract.previewRedeem(yamBalance);
26 | const balances = {
27 | weth: (Number(bn.from(previewBalances === null || previewBalances === void 0 ? void 0 : previewBalances.amountsOut[0]).toString()) / (10 ** 18)).toFixed(2),
28 | usdc: (Number(bn.from(previewBalances === null || previewBalances === void 0 ? void 0 : previewBalances.amountsOut[1]).toString()) / (10 ** 6)).toFixed(2),
29 | };
30 | return balances;
31 | }
32 | // Write functions
33 | async redeem(address, amount) {
34 | return await this.contract.redeem(address, amount);
35 | }
36 | }
37 | exports.YamRedeemer = YamRedeemer;
38 |
--------------------------------------------------------------------------------
/src/yam-sdk-files/dist/lib/types/yam.t.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | Object.defineProperty(exports, "__esModule", { value: true });
3 |
--------------------------------------------------------------------------------
/src/yam-sdk-files/dist/utils/contracts.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | Object.defineProperty(exports, "__esModule", { value: true });
3 | class Contracts {
4 | }
5 | Contracts.yam = "0x0aacfbec6a24756c20d41914f2caba817c0d8521";
6 | Contracts.reserves = "0x97990b693835da58a281636296d2bf02787dea17";
7 | Contracts.governor = "0x2da253835967d6e721c6c077157f9c9742934aea";
8 | Contracts.timelock = "0x8b4f1616751117c38a0f84f9a146cca191ea3ec5";
9 | Contracts.rebaser = "0xd93f403b432d39aa0f736c2021be6051d85a1d55";
10 | Contracts.incentivizer = "0xd67c05523d8ec1c60760fd017ef006b9f6e496d0";
11 | Contracts.migrator = "0x72cfed9293cbfb2bfc7515c413048c697c6c811c";
12 | // Other
13 | Contracts.susiswap = "0xd9e1ce17f2641f24ae83637ab66a2cca9c378b9f";
14 | exports.default = Contracts;
15 |
--------------------------------------------------------------------------------
/src/yam-sdk-files/dist/utils/tokens.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | Object.defineProperty(exports, "__esModule", { value: true });
3 | class Tokens {
4 | }
5 | Tokens.WETH = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";
6 | Tokens.WBTC = "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599";
7 | Tokens.YAM = "0x0AaCfbeC6a24756c20D41914F2caba817C0d8521";
8 | Tokens.USDC = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
9 | // Other
10 | Tokens.DPI = "0x1494CA1F11D487c2bBe4543E90080AeBa4BA3C2b";
11 | exports.default = Tokens;
12 |
--------------------------------------------------------------------------------
/src/yam-sdk-files/dist/utils/utils.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | Object.defineProperty(exports, "__esModule", { value: true });
3 | const ethers_1 = require("ethers");
4 | const bn = ethers_1.ethers.BigNumber;
5 | class Utils {
6 | static normalYam(amount) {
7 | return bn.from(amount).div(bn.from(10).pow(18)).toNumber();
8 | }
9 | static bouYam(amount) {
10 | return bn.from(amount).div(bn.from(10).pow(24)).toNumber();
11 | }
12 | static numberDecs(amount) {
13 | return Math.floor(Number(amount.toString()) / 10 ** 24);
14 | }
15 | }
16 | Utils.stateMap = {
17 | 0: "Pending",
18 | 1: "Active",
19 | 2: "Canceled",
20 | 3: "Defeated",
21 | 4: "Succeeded",
22 | 5: "Queued",
23 | 6: "Expired",
24 | 7: "Executed",
25 | };
26 | Utils.contractsNames = {
27 | "0x0e2298E3B3390e3b945a5456fBf59eCc3f55DA16": "yamv1",
28 | "0x1fB361f274f316d383B94D761832AB68099A7B00": "rebaser",
29 | "0xCF27cA116dd5C7b4201c75B46489D1c075362087": "reserves",
30 | "0x62702387C2a26C903985e9D078d18C45ACaE0908": "previous governor",
31 | "0x8b4f1616751117C38a0f84F9A146cca191ea3EC5": "timelock governance",
32 | "0xADDBCd6A68BFeb6E312e82B30cE1EB4a54497F4c": "ycrv pool",
33 | "0x5b0501F7041120d36Bc8c6DC3FAeA0b74b32a0Ed": "yusd farming",
34 | "0xAba8cAc6866B83Ae4eec97DD07ED254282f6aD8A": "yamv2",
35 | "0xf1d7c9E4c57a5C1902f4A4aE2630d2Da78Ffb1c1": "yamv1 yamv2 migrator",
36 | "0x0AaCfbeC6a24756c20D41914F2caba817C0d8521": "yamv3",
37 | "0x72CFEd9293cbFB2bfC7515c413048c697C6c811C": "migrator",
38 | "0x78BdD33e95ECbcAC16745FB28DB0FFb703344026": "second governor",
39 | "0x92ab5CCe7Af1605da2681458aE52a0BEc4eCB74C": "otc",
40 | "0x97990B693835da58A281636296D2Bf02787DEa17": "new reserves",
41 | "0xC32f9b0292965c5dd4A0Ea1abfcC1f5a36d66986": "dual governor old",
42 | "0x2DA253835967D6E721C6c077157F9c9742934aeA": "dual governor current",
43 | "0xD93f403b432d39aa0f736C2021bE6051d85a1D55": "eth rebaser",
44 | "0xD67c05523D8ec1c60760Fd017Ef006b9F6e496D0": "voting eth yam incentivizer",
45 | "0xc2EdaD668740f1aA35E4D8f227fB8E17dcA888Cd": "master chef",
46 | "0x0F82E57804D0B1F6FAb2370A43dcFAd3c7cB239c": "sushiswap lp",
47 | "0x8798249c2E607446EfB7Ad49eC89dD1865Ff4272": "sushi bar xsushi",
48 | "0x6B3595068778DD592e39A122f4f5a5cF09C90fE2": "sushi token",
49 | "0xB93b505Ed567982E2b6756177ddD23ab5745f309": "index coop staking rewards",
50 | "0xDCf613db29E4d0B35e7e15e93BF6cc6315eB0b82": "vesting pool",
51 | };
52 | exports.default = Utils;
53 |
--------------------------------------------------------------------------------
/src/yam-sdk-files/file.txt:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/src/yam-sdk/lib/Yam.js:
--------------------------------------------------------------------------------
1 | import Web3 from "web3";
2 | import BigNumber from "bignumber.js";
3 | import { Contracts } from "./lib/contracts.js";
4 | import { Account } from "./lib/accounts.js";
5 | import { EVM } from "./lib/evm.js";
6 |
7 | const oneEther = 1000000000000000000;
8 |
9 | export class Yam {
10 | constructor(provider, networkId, testing, options) {
11 | var realProvider;
12 |
13 | if (typeof provider === "string") {
14 | if (provider.includes("wss")) {
15 | realProvider = new Web3.providers.WebsocketProvider(provider, options.ethereumNodeTimeout || 10000);
16 | } else {
17 | realProvider = new Web3.providers.HttpProvider(provider, options.ethereumNodeTimeout || 10000);
18 | }
19 | } else {
20 | realProvider = provider;
21 | }
22 |
23 | this.web3 = new Web3(realProvider);
24 |
25 | if (testing) {
26 | this.testing = new EVM(realProvider);
27 | this.snapshot = this.testing.snapshot();
28 | }
29 |
30 | if (options.defaultAccount) {
31 | this.web3.eth.defaultAccount = options.defaultAccount;
32 | }
33 | this.contracts = new Contracts(realProvider, networkId, this.web3, options);
34 | this.accounts = [];
35 | this.markets = [];
36 | this.prices = {};
37 | this.allocations = {};
38 | this.rates = {};
39 | this.aprs = {};
40 | this.poolWeis = {};
41 | this.platformInfo = {};
42 | }
43 |
44 | async resetEVM() {
45 | this.testing.resetEVM(this.snapshot);
46 | }
47 |
48 | addAccount(address, number) {
49 | this.accounts.push(new Account(this.contracts, address, number));
50 | }
51 |
52 | setProvider(provider, networkId) {
53 | this.web3.setProvider(provider);
54 | this.contracts.setProvider(provider, networkId);
55 | this.operation.setNetworkId(networkId);
56 | }
57 |
58 | setDefaultAccount(account) {
59 | this.web3.eth.defaultAccount = account;
60 | this.contracts.setDefaultAccount(account);
61 | }
62 |
63 | getDefaultAccount() {
64 | return this.web3.eth.defaultAccount;
65 | }
66 |
67 | loadAccount(account) {
68 | const newAccount = this.web3.eth.accounts.wallet.add(account.privateKey);
69 |
70 | if (!newAccount || (account.address && account.address.toLowerCase() !== newAccount.address.toLowerCase())) {
71 | throw new Error(`Loaded account address mismatch.
72 | Expected ${account.address}, got ${newAccount ? newAccount.address : null}`);
73 | }
74 | }
75 |
76 | toBigN(a) {
77 | return BigNumber(a);
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/src/yam-sdk/lib/clean_build/contracts/Address.json:
--------------------------------------------------------------------------------
1 | { "abi": [], "networks": {} }
2 |
--------------------------------------------------------------------------------
/src/yam-sdk/lib/clean_build/contracts/Babylonian.json:
--------------------------------------------------------------------------------
1 | { "abi": [], "networks": {} }
2 |
--------------------------------------------------------------------------------
/src/yam-sdk/lib/clean_build/contracts/Context.json:
--------------------------------------------------------------------------------
1 | {
2 | "abi": [
3 | {
4 | "inputs": [],
5 | "payable": false,
6 | "stateMutability": "nonpayable",
7 | "type": "constructor"
8 | }
9 | ],
10 | "networks": {}
11 | }
12 |
--------------------------------------------------------------------------------
/src/yam-sdk/lib/clean_build/contracts/FixedPoint.json:
--------------------------------------------------------------------------------
1 | { "abi": [], "networks": {} }
2 |
--------------------------------------------------------------------------------
/src/yam-sdk/lib/clean_build/contracts/IRewardDistributionRecipient.json:
--------------------------------------------------------------------------------
1 | {
2 | "abi": [
3 | {
4 | "anonymous": false,
5 | "inputs": [
6 | {
7 | "indexed": true,
8 | "internalType": "address",
9 | "name": "previousOwner",
10 | "type": "address"
11 | },
12 | {
13 | "indexed": true,
14 | "internalType": "address",
15 | "name": "newOwner",
16 | "type": "address"
17 | }
18 | ],
19 | "name": "OwnershipTransferred",
20 | "type": "event"
21 | },
22 | {
23 | "constant": true,
24 | "inputs": [],
25 | "name": "isOwner",
26 | "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
27 | "payable": false,
28 | "stateMutability": "view",
29 | "type": "function"
30 | },
31 | {
32 | "constant": true,
33 | "inputs": [],
34 | "name": "owner",
35 | "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
36 | "payable": false,
37 | "stateMutability": "view",
38 | "type": "function"
39 | },
40 | {
41 | "constant": false,
42 | "inputs": [],
43 | "name": "renounceOwnership",
44 | "outputs": [],
45 | "payable": false,
46 | "stateMutability": "nonpayable",
47 | "type": "function"
48 | },
49 | {
50 | "constant": false,
51 | "inputs": [{ "internalType": "address", "name": "newOwner", "type": "address" }],
52 | "name": "transferOwnership",
53 | "outputs": [],
54 | "payable": false,
55 | "stateMutability": "nonpayable",
56 | "type": "function"
57 | },
58 | {
59 | "constant": false,
60 | "inputs": [{ "internalType": "uint256", "name": "reward", "type": "uint256" }],
61 | "name": "notifyRewardAmount",
62 | "outputs": [],
63 | "payable": false,
64 | "stateMutability": "nonpayable",
65 | "type": "function"
66 | },
67 | {
68 | "constant": false,
69 | "inputs": [
70 | {
71 | "internalType": "address",
72 | "name": "_rewardDistribution",
73 | "type": "address"
74 | }
75 | ],
76 | "name": "setRewardDistribution",
77 | "outputs": [],
78 | "payable": false,
79 | "stateMutability": "nonpayable",
80 | "type": "function"
81 | }
82 | ],
83 | "networks": {}
84 | }
85 |
--------------------------------------------------------------------------------
/src/yam-sdk/lib/clean_build/contracts/LPTokenWrapper.json:
--------------------------------------------------------------------------------
1 | {
2 | "abi": [
3 | {
4 | "constant": true,
5 | "inputs": [],
6 | "name": "uni_lp",
7 | "outputs": [{ "internalType": "contract IERC20", "name": "", "type": "address" }],
8 | "payable": false,
9 | "stateMutability": "view",
10 | "type": "function"
11 | },
12 | {
13 | "constant": true,
14 | "inputs": [],
15 | "name": "totalSupply",
16 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
17 | "payable": false,
18 | "stateMutability": "view",
19 | "type": "function"
20 | },
21 | {
22 | "constant": true,
23 | "inputs": [{ "internalType": "address", "name": "account", "type": "address" }],
24 | "name": "balanceOf",
25 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
26 | "payable": false,
27 | "stateMutability": "view",
28 | "type": "function"
29 | },
30 | {
31 | "constant": false,
32 | "inputs": [{ "internalType": "uint256", "name": "amount", "type": "uint256" }],
33 | "name": "stake",
34 | "outputs": [],
35 | "payable": false,
36 | "stateMutability": "nonpayable",
37 | "type": "function"
38 | },
39 | {
40 | "constant": false,
41 | "inputs": [{ "internalType": "uint256", "name": "amount", "type": "uint256" }],
42 | "name": "withdraw",
43 | "outputs": [],
44 | "payable": false,
45 | "stateMutability": "nonpayable",
46 | "type": "function"
47 | }
48 | ],
49 | "networks": {}
50 | }
51 |
--------------------------------------------------------------------------------
/src/yam-sdk/lib/clean_build/contracts/Math.json:
--------------------------------------------------------------------------------
1 | { "abi": [], "networks": {} }
2 |
--------------------------------------------------------------------------------
/src/yam-sdk/lib/clean_build/contracts/Migrations.json:
--------------------------------------------------------------------------------
1 | {
2 | "abi": [
3 | {
4 | "inputs": [],
5 | "payable": false,
6 | "stateMutability": "nonpayable",
7 | "type": "constructor"
8 | },
9 | {
10 | "constant": true,
11 | "inputs": [],
12 | "name": "last_completed_migration",
13 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
14 | "payable": false,
15 | "stateMutability": "view",
16 | "type": "function"
17 | },
18 | {
19 | "constant": true,
20 | "inputs": [],
21 | "name": "owner",
22 | "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
23 | "payable": false,
24 | "stateMutability": "view",
25 | "type": "function"
26 | },
27 | {
28 | "constant": false,
29 | "inputs": [{ "internalType": "uint256", "name": "completed", "type": "uint256" }],
30 | "name": "setCompleted",
31 | "outputs": [],
32 | "payable": false,
33 | "stateMutability": "nonpayable",
34 | "type": "function"
35 | }
36 | ],
37 | "networks": {
38 | "1": {
39 | "links": [{}],
40 | "address": "0x327ab530B53e78B55068609028c55Ab843FfdDc7",
41 | "transactionHash": "0x6f621f6d34b73165847cda0213f08349a89da2b55e81b028f6ed28e39e3927e8"
42 | },
43 | "1001": {
44 | "links": [{}],
45 | "address": "0x327ab530B53e78B55068609028c55Ab843FfdDc7",
46 | "transactionHash": "0x5abb855fc5bc355213ca245e6f9a201b0970f88389fdd063d623b75a90b4fb12"
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/yam-sdk/lib/clean_build/contracts/Ownable.json:
--------------------------------------------------------------------------------
1 | {
2 | "abi": [
3 | {
4 | "inputs": [],
5 | "payable": false,
6 | "stateMutability": "nonpayable",
7 | "type": "constructor"
8 | },
9 | {
10 | "anonymous": false,
11 | "inputs": [
12 | {
13 | "indexed": true,
14 | "internalType": "address",
15 | "name": "previousOwner",
16 | "type": "address"
17 | },
18 | {
19 | "indexed": true,
20 | "internalType": "address",
21 | "name": "newOwner",
22 | "type": "address"
23 | }
24 | ],
25 | "name": "OwnershipTransferred",
26 | "type": "event"
27 | },
28 | {
29 | "constant": true,
30 | "inputs": [],
31 | "name": "owner",
32 | "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
33 | "payable": false,
34 | "stateMutability": "view",
35 | "type": "function"
36 | },
37 | {
38 | "constant": true,
39 | "inputs": [],
40 | "name": "isOwner",
41 | "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
42 | "payable": false,
43 | "stateMutability": "view",
44 | "type": "function"
45 | },
46 | {
47 | "constant": false,
48 | "inputs": [],
49 | "name": "renounceOwnership",
50 | "outputs": [],
51 | "payable": false,
52 | "stateMutability": "nonpayable",
53 | "type": "function"
54 | },
55 | {
56 | "constant": false,
57 | "inputs": [{ "internalType": "address", "name": "newOwner", "type": "address" }],
58 | "name": "transferOwnership",
59 | "outputs": [],
60 | "payable": false,
61 | "stateMutability": "nonpayable",
62 | "type": "function"
63 | }
64 | ],
65 | "networks": {}
66 | }
67 |
--------------------------------------------------------------------------------
/src/yam-sdk/lib/clean_build/contracts/SafeERC20.json:
--------------------------------------------------------------------------------
1 | { "abi": [], "networks": {} }
2 |
--------------------------------------------------------------------------------
/src/yam-sdk/lib/clean_build/contracts/SafeMath.json:
--------------------------------------------------------------------------------
1 | { "abi": [], "networks": {} }
2 |
--------------------------------------------------------------------------------
/src/yam-sdk/lib/clean_build/contracts/TimelockInterface.json:
--------------------------------------------------------------------------------
1 | {
2 | "abi": [
3 | {
4 | "constant": true,
5 | "inputs": [],
6 | "name": "delay",
7 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
8 | "payable": false,
9 | "stateMutability": "view",
10 | "type": "function"
11 | },
12 | {
13 | "constant": true,
14 | "inputs": [],
15 | "name": "GRACE_PERIOD",
16 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
17 | "payable": false,
18 | "stateMutability": "view",
19 | "type": "function"
20 | },
21 | {
22 | "constant": false,
23 | "inputs": [],
24 | "name": "acceptAdmin",
25 | "outputs": [],
26 | "payable": false,
27 | "stateMutability": "nonpayable",
28 | "type": "function"
29 | },
30 | {
31 | "constant": true,
32 | "inputs": [{ "internalType": "bytes32", "name": "hash", "type": "bytes32" }],
33 | "name": "queuedTransactions",
34 | "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
35 | "payable": false,
36 | "stateMutability": "view",
37 | "type": "function"
38 | },
39 | {
40 | "constant": false,
41 | "inputs": [
42 | { "internalType": "address", "name": "target", "type": "address" },
43 | { "internalType": "uint256", "name": "value", "type": "uint256" },
44 | { "internalType": "string", "name": "signature", "type": "string" },
45 | { "internalType": "bytes", "name": "data", "type": "bytes" },
46 | { "internalType": "uint256", "name": "eta", "type": "uint256" }
47 | ],
48 | "name": "queueTransaction",
49 | "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }],
50 | "payable": false,
51 | "stateMutability": "nonpayable",
52 | "type": "function"
53 | },
54 | {
55 | "constant": false,
56 | "inputs": [
57 | { "internalType": "address", "name": "target", "type": "address" },
58 | { "internalType": "uint256", "name": "value", "type": "uint256" },
59 | { "internalType": "string", "name": "signature", "type": "string" },
60 | { "internalType": "bytes", "name": "data", "type": "bytes" },
61 | { "internalType": "uint256", "name": "eta", "type": "uint256" }
62 | ],
63 | "name": "cancelTransaction",
64 | "outputs": [],
65 | "payable": false,
66 | "stateMutability": "nonpayable",
67 | "type": "function"
68 | },
69 | {
70 | "constant": false,
71 | "inputs": [
72 | { "internalType": "address", "name": "target", "type": "address" },
73 | { "internalType": "uint256", "name": "value", "type": "uint256" },
74 | { "internalType": "string", "name": "signature", "type": "string" },
75 | { "internalType": "bytes", "name": "data", "type": "bytes" },
76 | { "internalType": "uint256", "name": "eta", "type": "uint256" }
77 | ],
78 | "name": "executeTransaction",
79 | "outputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }],
80 | "payable": true,
81 | "stateMutability": "payable",
82 | "type": "function"
83 | }
84 | ],
85 | "networks": {}
86 | }
87 |
--------------------------------------------------------------------------------
/src/yam-sdk/lib/clean_build/contracts/UniswapV2OracleLibrary.json:
--------------------------------------------------------------------------------
1 | { "abi": [], "networks": {} }
2 |
--------------------------------------------------------------------------------
/src/yam-sdk/lib/clean_build/contracts/YAMDelegateInterface.json:
--------------------------------------------------------------------------------
1 | {
2 | "abi": [
3 | {
4 | "constant": true,
5 | "inputs": [],
6 | "name": "implementation",
7 | "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
8 | "payable": false,
9 | "stateMutability": "view",
10 | "type": "function"
11 | },
12 | {
13 | "constant": false,
14 | "inputs": [{ "internalType": "bytes", "name": "data", "type": "bytes" }],
15 | "name": "_becomeImplementation",
16 | "outputs": [],
17 | "payable": false,
18 | "stateMutability": "nonpayable",
19 | "type": "function"
20 | },
21 | {
22 | "constant": false,
23 | "inputs": [],
24 | "name": "_resignImplementation",
25 | "outputs": [],
26 | "payable": false,
27 | "stateMutability": "nonpayable",
28 | "type": "function"
29 | }
30 | ],
31 | "networks": {}
32 | }
33 |
--------------------------------------------------------------------------------
/src/yam-sdk/lib/clean_build/contracts/YAMDelegationStorage.json:
--------------------------------------------------------------------------------
1 | {
2 | "abi": [
3 | {
4 | "constant": true,
5 | "inputs": [],
6 | "name": "implementation",
7 | "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
8 | "payable": false,
9 | "stateMutability": "view",
10 | "type": "function"
11 | }
12 | ],
13 | "networks": {}
14 | }
15 |
--------------------------------------------------------------------------------
/src/yam-sdk/lib/clean_build/contracts/YAMDelegatorInterface.json:
--------------------------------------------------------------------------------
1 | {
2 | "abi": [
3 | {
4 | "anonymous": false,
5 | "inputs": [
6 | {
7 | "indexed": false,
8 | "internalType": "address",
9 | "name": "oldImplementation",
10 | "type": "address"
11 | },
12 | {
13 | "indexed": false,
14 | "internalType": "address",
15 | "name": "newImplementation",
16 | "type": "address"
17 | }
18 | ],
19 | "name": "NewImplementation",
20 | "type": "event"
21 | },
22 | {
23 | "constant": true,
24 | "inputs": [],
25 | "name": "implementation",
26 | "outputs": [{ "internalType": "address", "name": "", "type": "address" }],
27 | "payable": false,
28 | "stateMutability": "view",
29 | "type": "function"
30 | },
31 | {
32 | "constant": false,
33 | "inputs": [
34 | {
35 | "internalType": "address",
36 | "name": "implementation_",
37 | "type": "address"
38 | },
39 | { "internalType": "bool", "name": "allowResign", "type": "bool" },
40 | {
41 | "internalType": "bytes",
42 | "name": "becomeImplementationData",
43 | "type": "bytes"
44 | }
45 | ],
46 | "name": "_setImplementation",
47 | "outputs": [],
48 | "payable": false,
49 | "stateMutability": "nonpayable",
50 | "type": "function"
51 | }
52 | ],
53 | "networks": {}
54 | }
55 |
--------------------------------------------------------------------------------
/src/yam-sdk/lib/clean_build/contracts/YAMGovernanceStorage.json:
--------------------------------------------------------------------------------
1 | {
2 | "abi": [
3 | {
4 | "constant": true,
5 | "inputs": [],
6 | "name": "DELEGATION_TYPEHASH",
7 | "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }],
8 | "payable": false,
9 | "stateMutability": "view",
10 | "type": "function"
11 | },
12 | {
13 | "constant": true,
14 | "inputs": [],
15 | "name": "DOMAIN_TYPEHASH",
16 | "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }],
17 | "payable": false,
18 | "stateMutability": "view",
19 | "type": "function"
20 | },
21 | {
22 | "constant": true,
23 | "inputs": [
24 | { "internalType": "address", "name": "", "type": "address" },
25 | { "internalType": "uint32", "name": "", "type": "uint32" }
26 | ],
27 | "name": "checkpoints",
28 | "outputs": [
29 | { "internalType": "uint32", "name": "fromBlock", "type": "uint32" },
30 | { "internalType": "uint256", "name": "votes", "type": "uint256" }
31 | ],
32 | "payable": false,
33 | "stateMutability": "view",
34 | "type": "function"
35 | },
36 | {
37 | "constant": true,
38 | "inputs": [{ "internalType": "address", "name": "", "type": "address" }],
39 | "name": "nonces",
40 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
41 | "payable": false,
42 | "stateMutability": "view",
43 | "type": "function"
44 | },
45 | {
46 | "constant": true,
47 | "inputs": [{ "internalType": "address", "name": "", "type": "address" }],
48 | "name": "numCheckpoints",
49 | "outputs": [{ "internalType": "uint32", "name": "", "type": "uint32" }],
50 | "payable": false,
51 | "stateMutability": "view",
52 | "type": "function"
53 | }
54 | ],
55 | "networks": {}
56 | }
57 |
--------------------------------------------------------------------------------
/src/yam-sdk/lib/clean_build/contracts/YAMInterface.json:
--------------------------------------------------------------------------------
1 | {
2 | "abi": [
3 | {
4 | "constant": true,
5 | "inputs": [
6 | { "internalType": "address", "name": "account", "type": "address" },
7 | { "internalType": "uint256", "name": "blockNumber", "type": "uint256" }
8 | ],
9 | "name": "getPriorVotes",
10 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
11 | "payable": false,
12 | "stateMutability": "view",
13 | "type": "function"
14 | },
15 | {
16 | "constant": true,
17 | "inputs": [],
18 | "name": "initSupply",
19 | "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],
20 | "payable": false,
21 | "stateMutability": "view",
22 | "type": "function"
23 | },
24 | {
25 | "constant": false,
26 | "inputs": [],
27 | "name": "_acceptGov",
28 | "outputs": [],
29 | "payable": false,
30 | "stateMutability": "nonpayable",
31 | "type": "function"
32 | }
33 | ],
34 | "networks": {}
35 | }
36 |
--------------------------------------------------------------------------------
/src/yam-sdk/lib/index.js:
--------------------------------------------------------------------------------
1 | import Web3 from "web3";
2 | import BigNumber from "bignumber.js/bignumber";
3 |
4 | BigNumber.config({
5 | EXPONENTIAL_AT: 1000,
6 | DECIMAL_PLACES: 80,
7 | });
8 |
9 | export { Yam } from "./Yam.js";
10 | export { Web3, BigNumber };
11 |
--------------------------------------------------------------------------------
/src/yam-sdk/lib/lib/BytesHelper.js:
--------------------------------------------------------------------------------
1 | import ethers from "ethers";
2 | import Web3 from "web3";
3 | import BigNumber from "bignumber.js/bignumber";
4 |
5 | export function hexStringToBytes(hex) {
6 | if (!hex || hex === "0x") {
7 | return [];
8 | }
9 | return Web3.utils.hexToBytes(hex).map((x) => [x]);
10 | }
11 |
12 | export function bytesToHexString(input) {
13 | return ethers.utils.hexlify(input.map((x) => new BigNumber(x[0]).toNumber()));
14 | }
15 |
16 | export function toBytes(...args) {
17 | const result = args.reduce((acc, val) => acc.concat(argToBytes(val)), []);
18 | return result.map((a) => [a]);
19 | }
20 |
21 | export function argToBytes(val) {
22 | let v = val;
23 | if (typeof val === "boolean") {
24 | v = val ? "1" : "0";
25 | }
26 | if (typeof val === "number") {
27 | v = val.toString();
28 | }
29 | if (val instanceof BigNumber) {
30 | v = val.toFixed(0);
31 | }
32 |
33 | return Web3.utils.hexToBytes(Web3.utils.padLeft(Web3.utils.toHex(v), 64, "0"));
34 | }
35 |
36 | export function addressToBytes32(input) {
37 | return `0x000000000000000000000000${stripHexPrefix(input)}`;
38 | }
39 |
40 | export function hashString(input) {
41 | return Web3.utils.soliditySha3({ t: "string", v: input });
42 | }
43 |
44 | export function hashBytes(input) {
45 | // javascript soliditySha3 has a problem with empty bytes arrays, so manually return the same
46 | // value that solidity does for keccak256 of an empty bytes array
47 | if (!stripHexPrefix(input)) {
48 | return "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470";
49 | }
50 | return Web3.utils.soliditySha3({
51 | t: "bytes",
52 | v: `0x${stripHexPrefix(input)}`,
53 | });
54 | }
55 |
56 | export function stripHexPrefix(input) {
57 | if (input.indexOf("0x") === 0) {
58 | return input.substr(2);
59 | }
60 | return input;
61 | }
62 |
63 | export function addressesAreEqual(addressOne, addressTwo) {
64 | return addressOne && addressTwo && stripHexPrefix(addressOne).toLowerCase() === stripHexPrefix(addressTwo).toLowerCase();
65 | }
66 |
--------------------------------------------------------------------------------
/src/yam-sdk/lib/lib/Expect.js:
--------------------------------------------------------------------------------
1 | const REQUIRE_MSG = "Returned error: VM Exception while processing transaction: revert";
2 | const ASSERT_MSG = "Returned error: VM Exception while processing transaction: invalid opcode";
3 |
4 | // For solidity function calls that violate require()
5 | export async function expectThrow(promise, reason) {
6 | try {
7 | await promise;
8 | throw new Error("Did not throw");
9 | } catch (e) {
10 | assertCertainError(e, REQUIRE_MSG);
11 | if (reason && process.env.COVERAGE !== "true") {
12 | assertCertainError(e, `${REQUIRE_MSG} ${reason}`);
13 | }
14 | }
15 | }
16 |
17 | // For solidity function calls that violate assert()
18 | export async function expectAssertFailure(promise) {
19 | try {
20 | await promise;
21 | throw new Error("Did not throw");
22 | } catch (e) {
23 | assertCertainError(e, ASSERT_MSG);
24 | }
25 | }
26 |
27 | // Helper function
28 | function assertCertainError(error, expected_error_msg) {
29 | // This complication is so that the actual error will appear in truffle test output
30 | const message = error.message;
31 | const matchedIndex = message.search(expected_error_msg);
32 | let matchedString = message;
33 | if (matchedIndex === 0) {
34 | matchedString = message.substring(matchedIndex, matchedIndex + expected_error_msg.length);
35 | }
36 | expect(matchedString).toEqual(expected_error_msg);
37 | }
38 |
--------------------------------------------------------------------------------
/src/yam-sdk/lib/lib/Helpers.js:
--------------------------------------------------------------------------------
1 | import BigNumber from "bignumber.js/bignumber";
2 | import { INTEGERS } from "./constants.js";
3 |
4 | export function stringToDecimal(s) {
5 | return new BigNumber(s).div(INTEGERS.INTEREST_RATE_BASE);
6 | }
7 |
8 | export function decimalToString(d) {
9 | return new BigNumber(d).times(INTEGERS.INTEREST_RATE_BASE).toFixed(0);
10 | }
11 |
12 | export function toString(input) {
13 | return new BigNumber(input).toFixed(0);
14 | }
15 |
16 | export function integerToValue(i) {
17 | return {
18 | sign: i.isGreaterThan(0),
19 | value: i.abs().toFixed(0),
20 | };
21 | }
22 |
23 | export function valueToInteger({ value, sign }) {
24 | let result = new BigNumber(value);
25 | if (!result.isZero() && !sign) {
26 | result = result.times(-1);
27 | }
28 | return result;
29 | }
30 |
31 | export function coefficientsToString(coefficients) {
32 | let m = new BigNumber(1);
33 | let result = new BigNumber(0);
34 | for (let i = 0; i < coefficients.length; i += 1) {
35 | result = result.plus(m.times(coefficients[i]));
36 | m = m.times(256);
37 | }
38 | return result.toFixed(0);
39 | }
40 |
41 | export function toNumber(input) {
42 | return new BigNumber(input).toNumber();
43 | }
44 |
45 | function partial(target, numerator, denominator) {
46 | return target.times(numerator).div(denominator).integerValue(BigNumber.ROUND_DOWN);
47 | }
48 |
--------------------------------------------------------------------------------
/src/yam-sdk/lib/lib/accounts.js:
--------------------------------------------------------------------------------
1 | import * as Types from "./types.js";
2 |
3 | export class Account {
4 | constructor(contracts, address) {
5 | this.contracts = contracts;
6 | this.accountInfo = address;
7 | this.type = "";
8 | this.allocation = [];
9 | this.balances = {};
10 | this.status = "";
11 | this.approvals = {};
12 | this.walletInfo = {};
13 | }
14 |
15 | async getYAMWalletBalance() {
16 | this.walletInfo["DAI"] = await this.contracts.yam.methods.balanceOf(this.accountInfo).call();
17 | return this.walletInfo["DAI"];
18 | }
19 |
20 | async getYCRVWalletBalance() {
21 | this.walletInfo["YCRV"] = await this.contracts.ycrv.methods.balanceOf(this.accountInfo).call();
22 | return this.walletInfo["YCRV"];
23 | }
24 |
25 | async getYFIWalletBalance() {
26 | this.walletInfo["YFI"] = await this.contracts.yfi.methods.balanceOf(this.accountInfo).call();
27 | return this.walletInfo["YFI"];
28 | }
29 |
30 | async getUNIAmplWalletBalance() {
31 | this.walletInfo["UNIAmpl"] = await this.contracts.UNIAmpl.methods.balanceOf(this.accountInfo).call();
32 | return this.walletInfo["UNIAmpl"];
33 | }
34 |
35 | async getWETHWalletBalance() {
36 | this.walletInfo["WETH"] = await this.contracts.weth.methods.balanceOf(this.accountInfo).call();
37 | return this.walletInfo["WETH"];
38 | }
39 |
40 | async getETHWalletBalance() {
41 | this.walletInfo["ETH"] = await this.contracts.web3.eth.getBalance(this.accountInfo);
42 | return this.walletInfo["ETH"];
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/yam-sdk/lib/lib/constants.js:
--------------------------------------------------------------------------------
1 | import BigNumber from "bignumber.js/bignumber";
2 |
3 | export const SUBTRACT_GAS_LIMIT = 100000;
4 |
5 | const ONE_MINUTE_IN_SECONDS = new BigNumber(60);
6 | const ONE_HOUR_IN_SECONDS = ONE_MINUTE_IN_SECONDS.times(60);
7 | const ONE_DAY_IN_SECONDS = ONE_HOUR_IN_SECONDS.times(24);
8 | const ONE_YEAR_IN_SECONDS = ONE_DAY_IN_SECONDS.times(365);
9 |
10 | export const INTEGERS = {
11 | ONE_MINUTE_IN_SECONDS,
12 | ONE_HOUR_IN_SECONDS,
13 | ONE_DAY_IN_SECONDS,
14 | ONE_YEAR_IN_SECONDS,
15 | ZERO: new BigNumber(0),
16 | ONE: new BigNumber(1),
17 | ONES_31: new BigNumber("4294967295"), // 2**32-1
18 | ONES_127: new BigNumber("340282366920938463463374607431768211455"), // 2**128-1
19 | ONES_255: new BigNumber("115792089237316195423570985008687907853269984665640564039457584007913129639935"), // 2**256-1
20 | INTEREST_RATE_BASE: new BigNumber("1e18"),
21 | };
22 |
23 | export const addressMap = {
24 | uniswapFactory: "0xc0a47dFe034B400B47bDaD5FecDa2621de6c4d95",
25 | uniswapFactoryV2: "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f",
26 | YFI: "0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e",
27 | YCRV: "0xdF5e0e81Dff6FAF3A7e52BA697820c5e32D806A8",
28 | YYCRV: "0x5dbcF33D8c2E976c6b560249878e6F1491Bca25c",
29 | UNIAmpl: "0xc5be99a02c6857f9eac67bbce58df5572498f40c",
30 | WETH: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
31 | UNIRouter: "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D",
32 | LINK: "0x514910771AF9Ca656af840dff83E8264EcF986CA",
33 | MKR: "0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2",
34 | SNX: "0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F",
35 | COMP: "0xc00e94Cb662C3520282E6f5717214004A7f26888",
36 | LEND: "0x80fB784B7eD66730e8b1DBd9820aFD29931aab03",
37 | YAMYCRV: "0x2C7a51A357d5739C5C74Bf3C96816849d2c9F726",
38 | YAMYYCRV: "0xb93Cc05334093c6B3b8Bfd29933bb8d5C031caBC",
39 | };
40 |
--------------------------------------------------------------------------------
/src/yam-sdk/lib/lib/types.js:
--------------------------------------------------------------------------------
1 | export const ConfirmationType = {
2 | Hash: 0,
3 | Confirmed: 1,
4 | Both: 2,
5 | Simulate: 3,
6 | };
7 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "lib": ["dom", "dom.iterable", "esnext"],
5 | "allowJs": true,
6 | "skipLibCheck": true,
7 | "esModuleInterop": true,
8 | "allowSyntheticDefaultImports": true,
9 | "strict": true,
10 | "forceConsistentCasingInFileNames": true,
11 | "module": "esnext",
12 | "moduleResolution": "node",
13 | "resolveJsonModule": true,
14 | "isolatedModules": true,
15 | "noEmit": true,
16 | "noImplicitAny": false,
17 | "jsx": "react",
18 | "baseUrl": "./src"
19 | },
20 | "include": ["src"]
21 | }
22 |
--------------------------------------------------------------------------------
/typings/index.d.ts:
--------------------------------------------------------------------------------
1 | declare module 'yam-sdk';
2 |
--------------------------------------------------------------------------------