-
Notifications
You must be signed in to change notification settings - Fork 2
feat: migrate to yield api balances #514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
petar-omni
wants to merge
8
commits into
main
Choose a base branch
from
feat/yield-balances-migration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
efeafe7
feat: migrate to yield api balances
petar-omni 4ae72e9
fix: tests
petar-omni a412e92
fix: position size
petar-omni 3be73d9
fix: misc
petar-omni f02120e
feat: migrate
petar-omni 93df083
feat: campaign
petar-omni 6b49e39
feat: useMaxAmount
petar-omni 3476aa6
fix: format
petar-omni File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@stakekit/widget": patch | ||
| --- | ||
|
|
||
| feat: migrate to yield api balances |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -266,4 +266,7 @@ next-env.d.ts | |
| *.p12 | ||
| *.pfx | ||
| *.crt | ||
| *.cer | ||
| *.cer | ||
|
|
||
| # opensrc - source code for packages | ||
| opensrc/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| # StakeKit Widget — Agent Guide | ||
|
|
||
| ## Project Overview | ||
| - Monorepo managed with `pnpm` workspaces + Turborepo. | ||
| - Main package is `@stakekit/widget` in `packages/widget` (React + TypeScript + Vite). | ||
| - Widget supports two entry modes: | ||
| - React component export (`src/index.package.ts`) | ||
| - Fully bundled renderer (`src/index.bundle.ts`) | ||
| - Runtime branches between classic widget and dashboard variant in `src/App.tsx`. | ||
|
|
||
| ## Repo Layout (important paths) | ||
| - `packages/widget/src/App.tsx` — root app, router setup, bundle renderer. | ||
| - `packages/widget/src/Widget.tsx` — non-dashboard route flow (earn/review/steps/details). | ||
| - `packages/widget/src/Dashboard.tsx` + `pages-dashboard/*` — dashboard variant UI. | ||
| - `packages/widget/src/providers/*` — global provider composition (API, query, wallet, tracking, theme, stores). | ||
| - `packages/widget/src/hooks/*` — feature and API hooks. | ||
| - `packages/widget/src/domain/*` — shared domain types/helpers. | ||
| - `packages/widget/src/translation/*` — i18n resources (`English`, `French`). | ||
| - `packages/widget/tests/*` — Vitest browser tests (MSW-backed). | ||
| - `packages/examples/*` — integration examples (`with-vite`, `with-vite-bundled`, `with-nextjs`, `with-cdn-script`). | ||
|
|
||
| ## Commands Agents Should Use | ||
|
|
||
| ### From repo root (all workspaces via Turbo) | ||
| - `pnpm build` — build all packages. | ||
| - `pnpm lint` — lint/type-check all packages. | ||
| - `pnpm test` — run all workspace tests. | ||
| - `pnpm format` — run formatting checks/tasks. | ||
|
|
||
| ### Focused widget commands (recommended for most tasks) | ||
| - `pnpm --filter @stakekit/widget {command}` | ||
|
|
||
| ## Agent Working Guidelines (short) | ||
| - Keep public API compatibility in `src/index.package.ts` and `src/index.bundle.ts`. | ||
| - When changing user-facing copy, update both: | ||
| - `packages/widget/src/translation/English/translations.json` | ||
| - `packages/widget/src/translation/French/translations.json` | ||
| - After changes, confirm nothing is broken with lint command which checks lint/type errors | ||
|
|
||
| ## Useful Context for Debugging | ||
| - API client is configured in `packages/widget/src/providers/api/api-client-provider.tsx`. | ||
| - React Query defaults are in `packages/widget/src/providers/query-client/index.tsx`. | ||
| - App-level config/env mapping is in `packages/widget/src/config/index.ts`. | ||
| - Test bootstrapping + MSW worker setup: | ||
| - `packages/widget/tests/utils/setup.ts` | ||
| - `packages/widget/tests/mocks/worker.ts` | ||
|
|
||
| <!-- opensrc:start --> | ||
|
|
||
| ## Source Code Reference | ||
|
|
||
| Source code for dependencies is available in `opensrc/` for deeper understanding of implementation details. | ||
|
|
||
| See `opensrc/sources.json` for the list of available packages and their versions. | ||
|
|
||
| Use this source code when you need to understand how a package works internally, not just its types/interface. | ||
|
|
||
| ### Fetching Additional Source Code | ||
|
|
||
| To fetch source code for a package or repository you need to understand, run: | ||
|
|
||
| ```bash | ||
| npx opensrc <package> # npm package (e.g., npx opensrc zod) | ||
| npx opensrc pypi:<package> # Python package (e.g., npx opensrc pypi:requests) | ||
| npx opensrc crates:<package> # Rust crate (e.g., npx opensrc crates:serde) | ||
| npx opensrc <owner>/<repo> # GitHub repo (e.g., npx opensrc vercel/ai) | ||
| ``` | ||
|
|
||
| <!-- opensrc:end --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| [tools] | ||
| node = "22" | ||
| pnpm = "10" | ||
| node = "24" | ||
| pnpm = "10" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
packages/widget/src/components/atoms/token-icon/token-icon-container/index.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
packages/widget/src/components/molecules/reward-rate-breakdown/index.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| import { useTranslation } from "react-i18next"; | ||
| import { | ||
| getRewardRateBreakdown, | ||
| type RewardRateBreakdownItem, | ||
| } from "../../../domain/types/reward-rate"; | ||
| import type { YieldRewardRateDto } from "../../../providers/yield-api-client-provider/types"; | ||
| import { getRewardRateFormatted } from "../../../utils/formatters"; | ||
| import { Box } from "../../atoms/box"; | ||
| import { Text } from "../../atoms/typography/text"; | ||
|
|
||
| const getLabelKey = (key: RewardRateBreakdownItem["key"]) => { | ||
| switch (key) { | ||
| case "native": | ||
| return "details.apy_composition.native"; | ||
| case "protocol_incentive": | ||
| return "details.apy_composition.protocol_incentive"; | ||
| case "campaign": | ||
| return "details.apy_composition.campaign"; | ||
| } | ||
| }; | ||
|
|
||
| export const RewardRateBreakdown = ({ | ||
| rewardRate, | ||
| showUpToCampaign = false, | ||
| title, | ||
| testId, | ||
| }: { | ||
| rewardRate: YieldRewardRateDto | null | undefined; | ||
| showUpToCampaign?: boolean; | ||
| title?: string; | ||
| testId?: string; | ||
| }) => { | ||
| const { t } = useTranslation(); | ||
|
|
||
| const items = getRewardRateBreakdown(rewardRate, { | ||
| showUpToCampaign, | ||
| }); | ||
|
|
||
| if (!items.length) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <Box | ||
| display="flex" | ||
| flexDirection="column" | ||
| gap="2" | ||
| marginTop="3" | ||
| data-testid={testId} | ||
| > | ||
| {title ? ( | ||
| <Text variant={{ type: "muted", weight: "normal" }}>{title}</Text> | ||
| ) : null} | ||
|
|
||
| {items.map((item) => { | ||
| const value = getRewardRateFormatted({ | ||
| rewardRate: item.rate, | ||
| rewardType: item.rewardType, | ||
| }); | ||
|
|
||
| return ( | ||
| <Box | ||
| key={item.key} | ||
| display="flex" | ||
| justifyContent="space-between" | ||
| alignItems="center" | ||
| gap="3" | ||
| data-testid={ | ||
| testId ? `${testId}__${item.key.replaceAll("_", "-")}` : undefined | ||
| } | ||
| > | ||
| <Text variant={{ type: "muted", weight: "normal" }}> | ||
| {t(getLabelKey(item.key))} | ||
| </Text> | ||
|
|
||
| <Text variant={{ type: "muted", weight: "normal" }}> | ||
| {item.isUpTo | ||
| ? t("details.apy_composition.up_to", { value }) | ||
| : value} | ||
| </Text> | ||
| </Box> | ||
| ); | ||
| })} | ||
| </Box> | ||
| ); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: stakekit/widget
Length of output: 2205
🏁 Script executed:
Repository: stakekit/widget
Length of output: 86
🏁 Script executed:
Repository: stakekit/widget
Length of output: 86
🏁 Script executed:
Repository: stakekit/widget
Length of output: 228
🏁 Script executed:
Repository: stakekit/widget
Length of output: 3888
🏁 Script executed:
Repository: stakekit/widget
Length of output: 319
🏁 Script executed:
Repository: stakekit/widget
Length of output: 189
🏁 Script executed:
Repository: stakekit/widget
Length of output: 98
🏁 Script executed:
Repository: stakekit/widget
Length of output: 466
🏁 Script executed:
Repository: stakekit/widget
Length of output: 1014
🏁 Script executed:
# Look at the complete settings types file to see the context cat -n packages/widget/src/providers/settings/types.tsRepository: stakekit/widget
Length of output: 3504
Update
tokenIconMappingcallback type to accept the union instead of casting.At Line 39, the cast suppresses type safety when the function parameter accepts
TokenDto | YieldTokenDto. SincetokenIconMappingis defined to only acceptTokenDto(inpackages/widget/src/providers/settings/types.ts:68), update its callback signature to((token: TokenDto | YieldTokenDto) => string)to properly reflect what the function can receive and eliminate the cast.🤖 Prompt for AI Agents