Fix/align lend amount types#347
Open
thinktanktom wants to merge 3 commits into
Open
Conversation
Renames all references to "hosted" wallet provider to "embedded" throughout the SDK to better align with industry terminology used by providers like Privy, Dynamic, and Turnkey. Changes: - Rename wallet/*/providers/hosted/ → wallet/*/providers/embedded/ - Rename wallet/*/wallets/hosted/ → wallet/*/wallets/embedded/ - Rename HostedWalletProvider → EmbeddedWalletProvider - Rename HostedWalletConfig → EmbeddedWalletConfig - Rename EmbeddedProviderDeps, EmbeddedProviderFactory, etc. - Rename hostedWalletConfig → embeddedWalletConfig in WalletConfig - Rename hostedWalletProvider → embeddedWalletProvider in WalletNamespace - Rename all *HostedWalletProvider* files to *EmbeddedWalletProvider* - Add @deprecated aliases for HostedWalletConfig and hostedWalletConfig - Add @deprecated getter for hostedWalletProvider in WalletNamespace Closes ethereum-optimism#330
- LendTransaction: amount bigint → number + amountRaw bigint - LendMarketPosition: balance/shares bigint → number + *Raw bigint - Remove balanceFormatted/sharesFormatted (replaced by number fields) - LendClosePositionParams: amount → amountRaw for consistency - Update Morpho + Aave providers, mocks, and all consumers Closes ethereum-optimism#303
👷 Deploy request for actions-ui pending review.Visit the deploys page to approve it
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Aligns the
lendmodule's amount and position types with the pattern established by theswapmodule in #284. The core principle: developers pass human-readable numbers in, and receive human-readable numbers out with the same field names. Rawbigintvalues are always suffixed withRaw.Closes #303
Problem
The lend module had an inconsistent type pattern where the same field name changed type between input and output:
This was a footgun for developers consuming the SDK: passing
amount: 100in and receivingamount: 100000000nback from the same field.Changes
SDK types (
packages/sdk/src/types/lend/base.ts)LendTransactionamount: bigintamount: number+amountRaw: bigintLendMarketPositionbalance: bigintbalance: number+balanceRaw: bigintLendMarketPositionbalanceFormatted: stringbalance: number)LendMarketPositionshares: bigintshares: number+sharesRaw: bigintLendMarketPositionsharesFormatted: stringshares: number)LendClosePositionParamsamount: bigintamountRaw: bigint(consistency withLendOpenPositionInternalParams)SDK providers
LendProvider.ts:closePositionpassesamountRawto_closePositionMorphoLendProvider:_openPosition,_closePosition,_getPositionupdated to return new field shape usingformatAssetAmountAaveLendProvider:_openETHPosition,_openERC20Position,_closeETHPosition,_closeERC20Position,_getPositionupdatedMockLendProvider: All mock helpers updated to produce correctamount/amountRaw/balanceRaw/sharesRawfieldsDemo backend
packages/demo/backend/src/types/lend.ts— no change needed;serializeBigInthandles the new*Rawbigint fields automaticallyDemo frontend
packages/demo/frontend/src/types/api.ts—PositionResponseupdatedpackages/demo/frontend/src/api/actionsApi.ts—getPositiondeserializesbalanceRaw/sharesRawfrom string, passesbalance/sharesthrough as numberspackages/demo/frontend/src/hooks/useWalletBalance.ts—depositedAmountderived fromposition.balance(number) instead ofposition.balanceFormatted(string)packages/demo/frontend/src/hooks/useLendProvider.ts— position balance comparison updatedTests
LendProvider.test.ts,WalletLendNamespace.spec.ts,AaveLendProvider.test.ts,MorphoLendProvider.test.ts,useActivityLogging.spec.tsBefore / After
Notes
openPosition/closePositioncall signatures —amount: numberinput is unchangedformatAssetAmountfrompackages/sdk/src/utils/assets.tsis used for allbigint → numberconversions (already existed in the codebase)amount,balance,shares,balanceFormatted, orsharesFormattedoff lend types — a changeset should be added before merge