Comments (13)
I checked the source code and so that we have for sure to setting NativeNetwork, but what I not understand, we try to use the angular components which mainly we configure the supportedNetworkTokens.
How should I configure the tokens with our custom BSC router?
can you perhaps help?
@vm06007
@joshstevens19
from simple-uniswap-sdk.
@joshstevens19 @vm06007
So finally I understood when I would like to use your angular components I can configure the UniswapPairsettings
also in the UniswapDappSharedLogiContext
to configure. See below for configuration
But there are still two issues
- in this scenario EthersProvider always calls InfuraProvider which doesn't work for BSC, I can omit this if I costumize
uniswap-dapp-shared-logic to
if (this.supportedNetwork) {
this._tokensFactoryPublic = new TokensFactoryPublic({
chainId: this.chainId,
providerUrl: 'https://bsc-dataseed1.defibit.io'
});
}
- but at the end I'm running in the multi call into a ```
UniswapError: invalid from or to contract tokens
UniswapError: invalid from or to contract tokens
**BTW** I'm not sure what I have to configure tor `factoryAddress` and `pairAddress`
this.uniswapDappSharedLogicContext = {
supportedNetworkTokens: [
{
chainId: 56,
defaultInputToken: '0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c', // BNB
defaultOutputToken: '0x1fd13bB00d80986adc121d5bEF287Bf2ED5C31AF', // GRY
supportedTokens: [
{ contractAddress: '0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c' }, // BNB
{ contractAddress: '0x1fd13bB00d80986adc121d5bEF287Bf2ED5C31AF' }, // GRY
]
}
],
ethereumAddress: accounts[0],
ethereumProvider: this.web3Service.provider,
settings: {
slippage: 0.01 ,
deadlineMinutes: 20,
disableMultihops: false,
uniswapVersions: [UniswapVersion.v2],
cloneUniswapContractDetails: {
v2Override: {
routerAddress: "0x0317d3B54c4FF8050E30Fe0e56585d2179586580",
factoryAddress: "0xc35dadb65012ec5796536bd9864ed8773abc74c4",
pairAddress: "0xc35dadb65012ec5796536bd9864ed8773abc74c4"
}
},
customNetwork: {
nameNetwork: !testnet ? "bsc" : "bsctest",
multicallContractAddress: !testnet
? "0xfF6FD90A470Aaa0c1B8A54681746b07AcdFedc9B"
: "0x8F3273Fb89B075b1645095ABaC6ed17B2d4Bc576",
nativeCurrency: {
name: "BNB",
symbol: "BNB"
},
nativeWrappedTokenInfo: {
chainId: !testnet ? 56 : 97,
contractAddress: "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c",
decimals: 18,
symbol: "WBNB",
name: "Wrapped BNB"
}
}
},
theming: {
backgroundColor: 'red',
button: { textColor: 'white', backgroundColor: 'blue' },
panel: { textColor: 'black', backgroundColor: 'yellow' },
textColor: 'orange',
}
};
from simple-uniswap-sdk.
factoryAddress
and pairAddress
of PancakeSwap:
pairAddress: '0xca143ce32fe78f1f7019d7d551a6402fc5350c73',
factoryAddress: '0xca143ce32fe78f1f7019d7d551a6402fc5350c73'
try to use this multicall address: 0x41263cba59eb80dc200f3e2544eda4ed6a90e76c
from simple-uniswap-sdk.
@vm06007 thx you for your response
should be pairAddress
and factoryAddress
the same?
when I try this, I get two errors
1. MetaMask - RPC Error: Internal JSON-RPC error. {code: -32603, message: 'Internal JSON-RPC error.', data: {…}}
and as before
2. UniswapError: invalid from or to contract tokens
and I alsways have to set manually the provider url in the share lib
if (this.supportedNetwork) {
this._tokensFactoryPublic = new TokensFactoryPublic({
chainId: this.chainId,
providerUrl: 'https://bsc-dataseed1.defibit.io'
});
}
EDIT:
I could resolve error 1 and I figured out that I can debug better the second error
It's comming from
https://github.com/uniswap-integration/simple-uniswap-sdk/blob/1629b680e615ce9851a4f7e7a3ba0187beac8261/src/factories/token/token.factory.ts#L80
and the error is
call revert exception (method="tryBlockAndAggregate(bool,(address,bytes)[])", errorArgs=null, errorName=null, errorSignature=null, reason=null, code=CALL_EXCEPTION, version=abi/5.5.0)
from simple-uniswap-sdk.
@mburger81 Yes, factoryAddress usually includes pair code implementation, so they can stay the same, you might be missing the router address and you may need to specify the wethAddress of wrapped BNB token, here is my configuration for that:
pairAddress: '0xca143ce32fe78f1f7019d7d551a6402fc5350c73',
factoryAddress: '0xca143ce32fe78f1f7019d7d551a6402fc5350c73',
routerAddress: '0x10ED43C718714eb63d5aA57B78B54704E256024E',
daiAddress: '0x1AF3F329e8BE154074D8769D1FFa4eE058B1DBc3',
wethAddress: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c',
invalid from or to contract tokens
sounds like the token addresses you are trying to pass for the trade might not be actual contracts on BSC
from simple-uniswap-sdk.
@vm06007 I share with you all my configuration, I try to get work with PCK so once this is working I can try to get it work with our dex and our router
I really dont know what I'm missing
this.uniswapDappSharedLogicContext = {
supportedNetworkTokens: [
{
chainId: 56,
defaultInputToken: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c_ETH', // BNB
defaultOutputToken: '0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82', // CAKE
supportedTokens: [
{ contractAddress: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c_ETH' }, // BNB
{ contractAddress: '0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82' }, // CAKE
]
}
],
ethereumAddress: accounts[0],
ethereumProvider: this.web3Service.provider,
settings: {
slippage: 0.01 ,
deadlineMinutes: 20,
disableMultihops: false,
uniswapVersions: [ UniswapVersion.v2 ],
cloneUniswapContractDetails: {
v2Override: {
routerAddress: "0x10ED43C718714eb63d5aA57B78B54704E256024E",
factoryAddress: "0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73",
pairAddress: "0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73"
}
},
customNetwork: {
nameNetwork: !testnet ? "BSC Mainnet" : "BSC Testnet",
// https://github.com/makerdao/multicall
multicallContractAddress: !testnet
? "0x41263cba59eb80dc200f3e2544eda4ed6a90e76c"
: "0xae11C5B5f29A6a25e955F0CB8ddCc416f522AF5C",
nativeCurrency: {
name: "BNB",
symbol: "BNB"
},
nativeWrappedTokenInfo: {
chainId: !testnet ? 56 : 97,
contractAddress: "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c",
decimals: 18,
symbol: "WBNB",
name: "Wrapped BNB"
}
}
},
theming: {
backgroundColor: 'red',
button: { textColor: 'white', backgroundColor: 'blue' },
panel: { textColor: 'black', backgroundColor: 'yellow' },
textColor: 'orange',
}
};
from simple-uniswap-sdk.
here is my configuration dynamic setup
const details = chainDetails(
provider,
chainId
);
const WETH_ADDRESS = details.wethAddress;
const DAI_ADDRESS = details.daiAddress;
const fromToken = findTokenStrict(details.tokensIn, fromCurrency, WETH_ADDRESS);
const toToken = findTokenStrict(details.tokensOut, toCurrency, DAI_ADDRESS);
const targets = {
v2Override: {
routerAddress: details.routerAddress,
factoryAddress: details.factoryAddress,
pairAddress: details.pairAddress,
},
};
let customNetworkData;
let providerUrl;
if (chainId === 56) {
(providerUrl = 'https://bsc-dataseed1.ninicoin.io'),
(customNetworkData = {
nameNetwork: 'Binance',
multicallContractAddress: '0x65e9a150e06c84003d15ae6a060fc2b1b393342c',
nativeCurrency: {
name: 'BNB Token',
symbol: 'BNB',
},
nativeWrappedTokenInfo: {
chainId,
contractAddress: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c',
decimals: 18,
symbol: 'WBNB',
name: 'Wrapped BNB',
},
});
}
try {
const uniswapPair = new UniswapPair({
fromTokenContractAddress: fromToken,
toTokenContractAddress: toToken,
ethereumAddress: userAddress,
providerUrl,
chainId,
settings: new UniswapPairSettings({
slippage: 0.01,
deadlineMinutes: 15,
disableMultihops,
uniswapVersions: [UniswapVersion.v2],
cloneUniswapContractDetails: targets,
customNetwork: customNetworkData,
}),
});
const pair = await uniswapPair.createFactory();
return pair;
} catch (e) {
console.log(e);
}
perhaps I've given wrong multicallContractAddress
?? try 0x65e9a150e06c84003d15ae6a060fc2b1b393342c
from simple-uniswap-sdk.
Yeah the multicallContractAddress was the wrong address, strange I got the same as you send me before from this page
https://github.com/makerdao/multicall which seems the not right one.
I took a lot of time to give you a response because I would like to finish my implementation. I saw that the simple-uniswap-sdk works well with different chains, but the integration example doesnt work very well, so in the last days I took a couple of changes which I would like to push the next days
btw.
can you share with me also your configuration for the BSC TESTNET, still the same problem with unknown multicallAddress and whats about the router? is it the same as on BSC MAINNET?
thx @vm06007
from simple-uniswap-sdk.
I'm not dealing with BSC testnet
from simple-uniswap-sdk.
If your looking for pancake swap on BSC, I have the addresses here #34
from simple-uniswap-sdk.
Took a very long time, but I found the solution. You have to use this list of multicall contracts, else it will fail.
from simple-uniswap-sdk.
@vm06007 can you share the implementation of functions
- chainDetails
- findTokenStrict
from simple-uniswap-sdk.
those are simple array lookup functions with .find
const chainDetails = (provider, chainId = 1) => {
return (
provider.supportedChains.find((chain) => chain.chainId === chainId)
);
};
const findTokenStrict = (
array,
value,
defaultValue
) => {
const result = array.find((item) => item.value === value);
return result?.token || defaultValue;
};
from simple-uniswap-sdk.
Related Issues (20)
- Using this library to provide liquidity HOT 1
- Using this to swap erc-20 tokens, is there a need for providing approval before executing the swap? HOT 3
- How to use native currency on custom network HOT 4
- TokensFactoryPublic with customNetwork not working HOT 11
- How to compute Gas + Uniswap Fees needed for a trade? HOT 2
- Prices vary slightly
- Support for swapExactTokensForTokensSupportingFeeOnTransferTokens
- feat: AVALANCHE support HOT 13
- Invalid from or to address on custom chain? HOT 3
- findBestRoute method returns wrong value for expected amount HOT 6
- License clarification HOT 3
- bug(avalanche): native token _ETH is not valid HOT 4
- feat: support multiple exchanges and search for best route
- Hello, is there any way to get the best route, for several pairs (possibly hundreds) in a single request to the node (multicall)?
- Hello, is there a way to get the best price for several pairs (possibly hundreds) in a single request to the node (multicall)?
- Price impact
- Invalid from or to contract tokens
- Base Network support HOT 2
- How to use native currency on custom network (Arbitrum 42161, Sepolia 11155111, Arbitrum Sepolia 421614)
- base network
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simple-uniswap-sdk.