6
votes
Accepted
What is DeFi decentralized finance?
Decentralized Finance (DeFi) is the movement that leverages decentralized networks to transform old financial products into trustless and transparent protocols that run without intermediaries.
Some ...
6
votes
Flash loan security considerations and attacks
As we work on flash loan attack debriefs, we can gather a lot of information about what could have been taken as preventative measures. It's important to understand how these flash loans work before ...
4
votes
Accepted
Calculate deposit amount when adding to a liquidity pool in Uniswap v3
To answer the question, first you need to calculate the liquidity Liquidity_x that is provided by the asset x given the current price and price range. From the whitepaper it can be derived that if ...
4
votes
Accepted
UniSwap V3 API : How to track **unclaimed fees** programmatically?
I solved this by going through powershell.
I query the infura account that the uniswap interface queries to.
Here is a powershell script for an DAI/USDC pool.
You have to change some things for this ...
4
votes
Call swapExactETHForTokens from contract and pay with contract balance
You should be able to achieve that if you send the ether along the function call. In solc v0.8 you achieve that using the function call options {value: amount}.
The resulting function should look like ...
3
votes
Flash loan security considerations and attacks
Flash loans violate two common intuitive assumptions.
1. "Nobody has that much ETH"
Problems can arise when for example:
Your contract uses a non-linear formula with an ETH amount as ...
3
votes
Flash loan security considerations and attacks
Generally speaking, if your system gives the users different terms under different scenarios, then you need to remember that a user can issue a flash-load attack on it.
For example, if your pool gives ...
3
votes
What are the risks of DeFi lending?
There is no answer for question "what are the risks of DeFi lending" because decentralised finance is an ecosystem and has various lending products. Each lending product has its own risk ...
3
votes
What is INIT_CODE_HASH and how is it calculated / used in DeFi smart contracts
https://www.codegrepper.com/code-examples/javascript/calculate+init+code+hash+nodejs
This shows how it's used with COMPUTED_INIT_CODE_HASH (https://www.codegrepper.com/code-examples/javascript/...
3
votes
What is INIT_CODE_HASH and how is it calculated / used in DeFi smart contracts
INIT_CODE_HASH is a hash of the initcode of a contract. The initcode is the code that creates the bytecode that is stored on-chain. You can read more about the types of bytecode here.
Most dapps, ...
3
votes
Accepted
How to create a Payable function that only accepts a customer token?
You don't use payable for non-protocol type of transfer. ERC20 isn't "protocol" because it is defined in a contract.
There is no way to detect ERC20 tokens that are blindly transferred to a ...
3
votes
Accepted
Retrieving Matic Reward Rates on AAVE with a Python script
So I solved the problem. There were two mistakes:
For the "REWARD_DECIMAL" and the "TOKEN_DECIMAL" I should use 10 to the power of the number, and not the numbers themselves.
...
3
votes
Why do we grant access to our funds instead of just sending them to the smart contract?
Generally, there are two ways to transfer (ERC20) tokens:
Direct transfer with transfer. You can call this function to transfer your tokens directly to another address.
Indirect transfer with ...
2
votes
What is the equivalent of ERC-20 tokens on the Cardano blockchain?
I think this question will be closed as off-topic as it's a question about Cardano. (Please ask on a Cardano forum.)
Just to clear one thing up:
Why doesn't Uniswap (a decentralized exchange) list ...
2
votes
What programming languages was Uniswap's open-source code written in?
Uniswap protocol is developed in Solidity, and you can find two main building blocks:
uniswap-v2-core: Core smart contracts, essentially with the Factory, Pair and ERC20, together with a number of ...
2
votes
Accepted
What are DeFi Smart Accounts?
"DeFi Smart Accounts" is not standard terminology and probably invented by a single person or a single marketing agency. It is impossible to tell and does not mean anything without context.
2
votes
What are the risks of DeFi lending?
Generally speaking, the main risk for DeFi platforms when your are a lender is in potential vulnerabilities within the smart contracts, rather than on parameters such as liquidation only affecting the ...
2
votes
Can I avoid impermanent loss if I only as a LP of BETH/ETH pair in binance?
Binance documentation describes the BETH/ETH pair.
In short, this pool is less exposed to impermanent loss because the
relative volatility between BETH and ETH is much lower than for
something like ...
eth♦
- 78.3k
2
votes
Calculate deposit amount when adding to a liquidity pool in Uniswap v3
The best place for the equations behind liquidity allocation is the V3 whitepaper
https://uniswap.org/whitepaper-v3.pdf
2
votes
UniSwap V3 API : How to track **unclaimed fees** programmatically?
By calling the "DeBank Open API".
Exmaple:
Random Wallet Address: 0x6741ad42f42564c3f21587d080880b2e79731eb1
Uniswap V3 Positions: DYDX + WETH
API call : https://openapi.debank.com/v1/user/...
2
votes
Accepted
bytes32 Error: incorrect data length - ethers.js
A bytes32 hex string should have 2+64=66 char length. It is possible that some tools can pad zero bytes around a value if it is smaller than the required length, for easy use.
// pads 00s from left ...
2
votes
Can anyone tell me the names of known uniswap v2 forks?
It is impossible to tell, because there is a new swap service almost every day.
You might want to limit your query with some criteria, like volume, etc. and then use services like DefiPulse to figure ...
2
votes
Accepted
Current ERC20 approval best practices?
IMO it is, as long as you trust the contract you approve to be good. limited allowances are definitely safer (in the case an exploit would be discovered somehow that would allow a malicious actor to ...
2
votes
Setting token price on a Dex
Prices are set by the market. The best practice is to set the price to its fair value on the market.
If there is no market yet, you have to evaluate it. This is basically what investment banks will do ...
2
votes
how to build Defi app from A to Z
I'm not sure that using just Java and Solidity will get you very far (at least as a beginner). Solidity "back end"/smart contracts and javascript front end using web3.js is the probably the ...
2
votes
What happens when disconnect my wallet from Pancakeswap
Just by connecting your wallet, most websites will just see your wallet address and require your permission before signing a transaction. Unless you connect to a shady site which asks for transaction ...
2
votes
Accepted
How accurate are 0x gas estimations?
Different tokens can cost different amounts when transferred, i.e during a swap. 0xAPI doesn't know the gas cost of every token in existence.
0xAPI will perform a more accurate gas estimate for you ...
2
votes
Accepted
Why do we grant access to our funds instead of just sending them to the smart contract?
There is no "advantage". The reason most DeFi apps ask users to "allow" the transfer of their funds is that those funds are represented as ERC-20 tokens. The Ethereum community is ...
2
votes
Accepted
ETH-Brownie How can I import from github when the version number includes letters and numbers?
You do exactly as you have here, you add the whole release string.
For example:
dependencies:
- OpenZeppelin/openzeppelin-contracts@3.2.1-solc-0.7
compiler:
solc:
remappings:
...
2
votes
Accepted
How to do call a smart contract at intervals on the matic network?
Chainlink Keepers is the perfect solution for your use case. They are a decentralized network of off-chain nodes that are incentivized to perform all registered jobs (upkeeps) off chain in a ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
defi × 163solidity × 55
uniswap × 37
erc-20 × 17
tokens × 15
contract-development × 14
pancakeswap × 14
decentralized-exchange × 12
liquidity-provider × 12
web3js × 10
blockchain × 10
dapps × 9
flash-loans × 9
aave × 8
security × 6
exchanges × 6
go-ethereum × 5
ether × 5
bsc × 5
polygon × 5
stablecoins × 5
compound-protocol × 5
remix × 4
etherscan × 4
swaps × 4