Code Monkey home page Code Monkey logo

sdk-core's Introduction

@uniswap/sdk-core - Now at Uniswap/sdks

All versions after 4.2.0 of this SDK can be found in the SDK monorepo! Please file all future issues, PR’s, and discussions there.

Old Issues and PR’s

If you have an issue or open PR that is still active on this SDK in this repository, please recreate it in the new repository. Some existing issues and PR’s may be automatically migrated by the Uniswap Labs team.

sdk-core's People

Contributors

0xaliya avatar aadams avatar ahsan-javaiid avatar annieke avatar cbachmeier avatar dallinlarsen avatar dependabot[bot] avatar gzeoneth avatar hensha256 avatar ikedm avatar jackshort avatar jason-w123 avatar jfrankfurt avatar jsy1218 avatar just-toby avatar lint-action avatar marktoda avatar moodysalem avatar noahzinsmeister avatar rachel-eichenberger avatar sbvegan avatar tbtstl avatar tinaszheng avatar vm avatar willpote avatar zzmp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sdk-core's Issues

Can Fraction be moved to separate package?

I very like Fraction implementation and would like to use it in my project, but for now i have to install whole sdk-core which pulls ethersproject and other unrelated dependencies.

Can it be moved to a separate package?

Price Basic Math functions

The Price class inherits add(), subtract() and divide() from the Fraction class, as well as comparison functions (LT, GT,...).
All of these functions therefore take Fraction as the second argument.

Only the multiply function is overwritten and accepts Price<TQuote, TOtherQuote> as a second argument.

This is nearly the exact opposite behaviour of what I would intuitively expect. It makes sense to multiply or divide a Price with a Fraction, BigIntish or even Percent, but it makes no sense to add, divide or compare two totally different Price Objects and get a Fraction object in return.
What is the reason for this design decision?

Wrong TickLens address on Sepolia

Currently it's 0xd7f33bcdb21b359c8ee6f0251d30e94832baad07 which is the same as Multicall.

sdk-core/src/addresses.ts

Lines 157 to 161 in fdf6cf3

multicallAddress: '0xD7F33bCdb21b359c8ee6F0251d30E94832baAd07',
quoterAddress: '0xEd1f6473345F45b75F8179591dd5bA1888cf2FB3',
v3MigratorAddress: '0x729004182cF005CEC8Bd85df140094b6aCbe8b15',
nonfungiblePositionManagerAddress: '0x1238536071E1c677A632429e3655c799b22cDA52',
tickLensAddress: '0xd7f33bcdb21b359c8ee6f0251d30e94832baad07',

The actual deployed address is 0x0b343475d44EC2b4b8243EBF81dc888BF0A14b36.

Quoter vs QuoterV2 address

I noticed that the Addresses for the Quoter point to different contracts on different networks. This also happens in the Docs.

For Celo the address points to the QuoterV2 Contract.
For default chains e.g. Mainnet the address points to the Quoter Contract.

I would like to access the QuoterV2 Contract address from the v3-sdk.
I would suggest adding both addresses in the sdk-core ChainAddresses as optionals.

Add LUKSO chain ID support [42]

Hi,
As M8B dev house I have built several protocols already at LUKSO network, and I would love to use official UNISWAP interface on top of deployed contracts.
Since I saw you merged GNOSIS chain id I think it is very important to consider having UNISWAP as a brand in LUKSO ecosystem as well.

Parameters:

I have created basic deployment with the help of W3HC-uniswap-deploy-v3 tool on a token IERC20<->LSP7 compatible token instead of weth-9.
WLYX-IERC20

Deployed contracts list below:

{"v3CoreFactoryAddress":"0xB0884fB5b6d79124F4E6BD6A34f476A44106bBA2","multicall2Address":"0x923601Dda4E62F01B0bE51F827Be85C37Dad9c86","proxyAdminAddress":"0x8FdaD422DB40747a05df58c7f3fa7d095c58e6C9","tickLensAddress":"0x24E5109575e70652E6b7B4F754bdc699afA2D420","nftDescriptorLibraryAddressV1_3_0":"0x7a09C8733C59019E2F16C97A87BfcDF15E4C368d","nonfungibleTokenPositionDescriptorAddressV1_3_0":"0x9a64F2f5824F3f681fD0F38095f429Edf14dE5b5","descriptorProxyAddress":"0xBbda2b6E0b704017A8C745a81aF029A98880C9DB","nonfungibleTokenPositionManagerAddress":"0xe1C3193221ABc205F26149b2aD86e7e692eB053e","v3MigratorAddress":"0x3673c1112b7BAc5703cCfF59dd93f4B359A93aE3","v3StakerAddress":"0x9b239337CBb6C94185F9Fba15D702A700b47Ed8b","quoterAddress":"0x6899a2682b7434f3e2424d637767834664aCBe83","quoterV2Address":"0x3b33431A399D2cb2fd8C395A220634ABd511c3A2","swapRouter02":"0x7b83F89a86C7bF2596C9d5AA77308c9F6F1B96Bb"}

p.s.
I am big fan of UNI, I cant wait for v4 to be up so we can remove WETH dependencies everywhere!

Could not parse fraction

when i copy the code
image
and throw a error such as
image

this is my params
i find source code params new Percent(50, 10_000),also throw the same error

Linting broken

Linting doesn't seem to work: #99

Might be because the PR is from a fork branch

new Token() constructor has an incorrect type for address

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @uniswap/[email protected] for the project I'm working on.

The documentation on the main site for Creating a Pool Instance shows creating a new Token() with an Address type, but the token.d.ts is forming the constructor with a string variable. This should be updated.

Here is the diff that solved my problem:

diff --git a/node_modules/@uniswap/sdk-core/dist/entities/token.d.ts b/node_modules/@uniswap/sdk-core/dist/entities/token.d.ts
index e76cd88..2a9b03b 100644
--- a/node_modules/@uniswap/sdk-core/dist/entities/token.d.ts
+++ b/node_modules/@uniswap/sdk-core/dist/entities/token.d.ts
@@ -1,3 +1,4 @@
+import { Address } from 'cluster';
 import { BaseCurrency } from './baseCurrency';
 import { Currency } from './currency';
 /**
@@ -10,7 +11,7 @@ export declare class Token extends BaseCurrency {
      * The contract address on the chain on which this token lives
      */
     readonly address: string;
-    constructor(chainId: number, address: string, decimals: number, symbol?: string, name?: string);
+    constructor(chainId: number, address: Address, decimals: number, symbol?: string, name?: string);
     /**
      * Returns true if the two tokens are equivalent, i.e. have the same chainId and address.
      * @param other other token to compare

This issue body was partially generated by patch-package.

add bsc chain BNB in ETHER

prev does not contian BNB on BSC chain,chainId is 56 .
var WETH9 = (_WETH = {}, _WETH[1] = /*#__PURE__*/new Token(1, '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', 18, 'WETH', 'Wrapped Ether'), _WETH[3] = /*#__PURE__*/new Token(3, '0xc778417E063141139Fce010982780140Aa0cD5Ab', 18, 'WETH', 'Wrapped Ether'), _WETH[4] = /*#__PURE__*/new Token(4, '0xc778417E063141139Fce010982780140Aa0cD5Ab', 18, 'WETH', 'Wrapped Ether'), _WETH[5] = /*#__PURE__*/new Token(5, '0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6', 18, 'WETH', 'Wrapped Ether'), _WETH[42] = /*#__PURE__*/new Token(42, '0xd0A1E359811322d97991E03f863a0C30C2cF029C', 18, 'WETH', 'Wrapped Ether'), _WETH[10] = /*#__PURE__*/new Token(10, '0x4200000000000000000000000000000000000006', 18, 'WETH', 'Wrapped Ether'), _WETH[69] = /*#__PURE__*/new Token(69, '0x4200000000000000000000000000000000000006', 18, 'WETH', 'Wrapped Ether'), _WETH[42161] = /*#__PURE__*/new Token(42161, '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1', 18, 'WETH', 'Wrapped Ether'), _WETH[421611] = /*#__PURE__*/new Token(421611, '0xB47e6A5f8b33b3F17603C83a0535A9dcD7E32681', 18, 'WETH', 'Wrapped Ether'), _WETH);
should add WETH on BSC chain . this is wbnb url : https://bscscan.com/address/0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c#readContract

3.2.4. ChainId Breaking Change

Version 3.2.4 renamed SupportedChainId to ChainId causing projects that import SupportedChainId to break.
I'd suggest adding SupportedChainId as a type alias.

SwapRouter02 addresses

The last three chains that were added to the addresses (Avalanche, Base, Base Goerli) have a different deployment address for the SwapRouter02 compared to the Default Chains.
The SWAP_ROUTER_02_ADDRESSES function returns a wrong address for these chains.

print 'Python 2'print('Python 3')app.enki.com/join/Dirtyyt66{

print 'Python 2'print('Python 3')app.enki.com/join/Dirtyyt66{
"ns": "yt",
"el": "detailpage",
"cpn": "7odY8DCx4Bt-J_26",
"ver": 2,
"cmt": "39.819",
"fmt": "243",
"fs": "0",
"rt": "91.368",
"euri": "",
"lact": 5,
"cl": "590345707",
"mos": 0,
"state": "8",
"volume": 100,
"cbrand": "generic",
"cbr": "Chrome Mobile",
"cbrver": "120.0.0.0",
"c": "MWEB",
"cver": "2.20231215.01.00",
"cplayer": "UNIPLAYER",
"cmodel": "android 10.0",
"cos": "Android",
"cosver": "10",
"cplatform": "MOBILE",
"hl": "en_US",
"cr": "US",
"len": "246.681",
"fexp": "v1,23983296,21348,2602,73492,54572,227323,23095,53633,69218,15519,469,19101,6118,4378,5164,1088,5877,394,26439494,4054,1930,5181,9369,1556,1141,5877,590,1661,859,408,686,9513,126,4557,1560,8394,236,1772,3220,1332,1994,892,1648,1252,1160,3033,3679,2995",
"afmt": "251",
"muted": "0",
"conn": "7",
"cc": ".en",
"docid": "Y8Tko2YC5hA",
"ei": "UMiBZdecIOqN2_gP8PWKgAI",
"plid": "AAYM35LQS0hN3XV6",
"of": "rUXqhMsdnPw6X7zswWpucw",
"vm": "CAEQARgEOjJBSHFpSlRMNXNyLTRPOGdjbEljMkV6M3JhbjhVRGFfZURxLWFwY3RFcXI0TEg1V1dqd2JuQVBta0tESi1LZHdua2ZQQzJYTG10UUJ4QlpFbGdGVC1YRHN5d2t0TjZiZ2s1aFBMaEVlTmMyaWQ4ZVBTRGp5S3BHNkhBUEdVSmRnaEFCX3EyTmRZaUdrWFV2NjFHcm5kUFpSTmpBbXozb0pEUGdoAg",
"vct": "39.819",
"vd": "246.681",
"vpl": "24.166-39.819",
"vbu": "21.355-100.001",
"vpa": "0",
"vsk": "0",
"ven": "0",
"vpr": "1",
"vrs": "4",
"vns": "2",
"vec": "null",
"vemsg": "",
"vvol": "1",
"vdom": "1",
"vsrc": "1",
"vw": "360",
"vh": "203",
"lct": "39.798",
"lsk": false,
"lmf": false,
"lbw": "1425345.689",
"lhd": "0.092",
"lst": "9.845",
"laa": "itag_251_type_3_src_reslicegetRequestInfoForRange_segsrc_reslicegetRequestInfoForRange_seg_9_range_1597215-1771580_time_90.0-100.0_off_0_len_174366_end_1",
"lva": "itag_243_type_3_src_reslicegetRequestInfoForRange_segsrc_reslicegetRequestInfoForRange_seg_27_range_1566088-1582760_time_143.1-148.4_off_0_len_16673_end_1",
"lar": "itag_251_type_3_src_getRequestInfoForRange_segsrc_getRequestInfoForRange_seg_9_range_1597215-1771580_time_90.0-100.0_off_0_len_174366_end_1",
"lvr": https://globalesg.xignite.com/xGlobalESG.json/ListCategories?https://logos.xignite.com/xLogos.csv/ListExchanges?https://github.com/Dirtyyt66/sdk-core/blob/main/package.jsondb8e2f03223ec47548fbeb1a12d55de724346ddf0dd908114c2e3588e9e86edfee281446c7ca84eapython/python-core/even-or-odd-exercisenumbers = [1, 2, 3, 4, 5]
average = sum(numbers) / len(numbers)
print(average)EOHJ K7JW DCSR JMNK OCK3 IJ57 Y42T E4KR

Originally posted by @Dirtyyt66 in Dirtyyt66#2 (comment)

Error in Uniswap/[email protected]: Uncaught TypeError when assigning to read-only property '10'

Description:
I encountered an error when upgrading from version 3.2.2 to version 3.2.4 of the Uniswap/sdk-core library. The error occurs while trying to assign a value to a read-only property '10' in the string '0x1F98431c8aD98523631AE4a59f267346ea31F984'. Upon investigating, it appears that the issue originates from the following line of code:

var V3_CORE_FACTORY_ADDRESSES = _extends({}, SUPPORTED_CHAINS.reduce(function(memo, chainId) { return memo[chainId] = CHAIN_TO_ADDRESSES_MAP[chainId].v3CoreFactoryAddress; }, {}));

Expected Behavior:
After upgrading to version 3.2.4, the code should execute without any errors, and the assignment to the read-only property should not occur.

Actual Behavior:
When executing the code with version 3.2.4, an Uncaught TypeError is thrown, indicating that it is not possible to assign a value to a read-only property '10' in the string '0x1F98431c8aD98523631AE4a59f267346ea31F984'.

Root Cause:
The error occurs in the reduce function during the second round, where the memo variable becomes a string. Attempting to define a property on a string is not allowed, causing the error.

Feature: Add an "amountFromReadable" method to BaseCurrency / CurrencyAmount

Unless I've missed it, but I have looked, there doesn't seem to be any built in method to convert a "display"/"readable" currency value to it's "atomic" amount. e.g 1.234ETH = 1234000000000000000

Is there any reason why not? Seems like a very common action to perform, as for the most part, user inputs are going to be in readable units, which need to be converted for use in contracts etc.

Strangely, in the "routing a trade" example (https://docs.uniswap.org/sdk/v3/guides/routing), it contains a function "fromReadableAmount":

https://github.com/Uniswap/examples/blob/0071bb5883fba6f4cc39a5f1644ac941e4f24822/v3-sdk/routing/src/libs/conversion.ts#L3

But this is in an example, and not part of the SDK. (also having amount: number is a bad idea imo but im nit-picking an example here...)

Just thought this makes sense. I don't think I'm missing it, as this is why I went to the example to see what was done in there.

Edit: Makes more sense for it to be in CurrencyAmount than BaseCurrency on second thought.

Why use uniswap sdk is so hard?

I'm struggling to understand why those of you who are evidently intelligent create something so complicated for users.

We simply want to employ code to swap pairs; it's perplexing that for a single straightforward use case, we're required to write an extensive amount of code. While I acknowledge the inherent complexity in Uniswap, it's puzzling why no one has yet devised a simpler method to navigate this platform, abstracting away the complicated elements.

For the majority of us, the desired use case is straightforward: we aim to exchange Token A for Token B in a specified quantity. However, achieving this necessitates several complex steps: creating a pool, establishing a route, generating a quote, executing a trade, and so on. Each step in this process is unnecessarily convoluted.

Why haven't you considered releasing an intuitive package that seamlessly handles all these steps, requiring only the token addresses and the transaction amount as input?

The prevailing complexity seems unwarranted, especially considering that 90% of use cases are simple.

Seemingly unecessary delay in Pool.getOutputAmount (also getInputAmount and swap)

Been testing Pool. Long story short, I discovered something odd when timing the performance of some functions.

I've made a gist for replication:

https://gist.github.com/NoUJoe/d57b3d478767dd409bab7e8f6aff44e0.js

The code sets up a pool, and then calls getOutputAmount 4 times, measuring the time from execution to the promise resolving. When all 4 have finished, it will then log the total time taken. Here's an example result:

o4 232
o2 297
o3 337
o1 347
Total time 348

o1 / o2 / o3 / o4 is each getOutputAmount call and Total time is... y'know, total time. All in MS

I know getOutputAmount is async for data retrieval reasons, like web calls etc. But all data used in my example is all local, no network requests or anything. So execution should be pretty synchronous.

But as we can see, total time is about the same time as the longest getOutputAmount call and not the sum of all calls, indicating there's some sort of delay happening somewhere.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.