Guys can someone suggest formula to calculate user shares from total amount of tokens in pool that many users put tokens in? The following works fine if there is only 1 user invested in the said pool but when users increase it always return 0, any ideas whats wrong?
uint256 userPoolSharePercent = (userBetAmount / pooledForThisOutcome) * 100;
calculateUserPoolWeight = (totalPooledAmountForThisMatch * userPoolSharePercent) / 100;
Mar 26, 2023, 7:44 PM
Have you looked at this maybe it can help
https://solidity-by-example.org/defi/staking-rewards/
https://solidity-by-example.org/defi/staking-rewards/
Mar 26, 2023, 7:49 PM
ty, will check it now i hope it help
Mar 26, 2023, 7:50 PM
https://t.me/ethers_officer/286
Mar 26, 2023, 8:37 PM
mappings
or arrays whatever you use, but in Solidity it's a norm tu use mappings due to evm being a turing complete machine
mapping (address => uint ) balances
fn example()...
{
calculate the amount %
balances[user] - now change accordingly
}
fn example()...
{
calculate the amount %
balances[user] - now change accordingly
}
this takes a mapping of type uint for each address
and thus allowing the contract to store/know the balance of an address
why use priv key to see balanceπ
can anyone explain how hybrid stablecoins function in a nutshell?
How do they algorithmically decide the burn-mint when it's also backed by fiat
what if fiat falls?
Mar 27, 2023, 3:07 AM
everything fall apart
and a new era will begin
Mar 27, 2023, 3:32 AM
π€ I suppose, but people say frax aint like luna coz it's hybrid
How does it manage the depeg risk
In ICO contracts what's the best way to bootstrap liquidity from the ICO to dex?
Mar 27, 2023, 4:59 AM
It's a new feature we're planning to integrate...
Is it possible tho?
Is it possible tho?
Also, can I convert an already existing wallet into a Multi-Sig wallet?
Any help with this please?
Mar 28, 2023, 10:37 AM
No, if it's an eoa it can't become a sc keeping the same address
Mar 28, 2023, 11:09 AM
You can't. Multi sig is essentially a contract with multiple owners. Its not possible to convert an existing eoa wallet to such smart contract
Mar 28, 2023, 11:11 AM
It is possible to convert an existing wallet into a multi-sig wallet, but it depends on the type of wallet you have and whether it supports multi-sig functionality.
Mar 28, 2023, 1:03 PM
EVM doesn't support it
Mar 28, 2023, 1:10 PM
function Participate() public {
UserInfo storage userInfo = LottoUserInfo[msg.sender];
uint256 balance = GetTokenBal(msg.sender);
require(started,"lotto not started");
require(!hasParticipated[msg.sender], "User has already participated");
require(balance >0 , "Not Enough Balance of Tokens to buy TICKET" );
require(participantList.length < MaxParticipantCap, "Max participants reached");
require(userInfo.ClaimedLastParticipation,"Claim Your Last Participation Rewards Before Participating");
IERC20(LottoToken).transferFrom(msg.sender, address(this), CurrentTicketPrice);
uint256 f = CurrentTicketPrice.mul(feeAmount).div(10000);
uint256 amtAfterFee = CurrentTicketPrice.sub(f);
uint256 toLockAndPool = amtAfterFee.div(2);
ISwapRouter.ExactInputParams memory params =
ISwapRouter.ExactInputParams({
path: abi.encodePacked(Stable1, poolFee, Stable2, poolFee, WETH),
recipient: msg.sender,
deadline: block.timestamp,
amountIn: f,
amountOutMinimum: 0
});
uint256 amountOut = swapRouter.exactInput(params);
Treasury.add(amountOut);
Lock(msg.sender, toLockAndPool);
RewardPool = RewardPool.add(toLockAndPool);
participantList.push(msg.sender);
hasParticipated[msg.sender] = true;
userInfo.LottosParticipated = userInfo.LottosParticipated.add(1);
emit ParticipantRegistered(msg.sender, CurrentTicketPrice);
}
will doing this call a swap?
https://github.com/BOBseal/SolidityExamples/blob/master/Locks%20and%20Lotteries/lottery_Alpha-Incomplete.sol
UserInfo storage userInfo = LottoUserInfo[msg.sender];
uint256 balance = GetTokenBal(msg.sender);
require(started,"lotto not started");
require(!hasParticipated[msg.sender], "User has already participated");
require(balance >0 , "Not Enough Balance of Tokens to buy TICKET" );
require(participantList.length < MaxParticipantCap, "Max participants reached");
require(userInfo.ClaimedLastParticipation,"Claim Your Last Participation Rewards Before Participating");
IERC20(LottoToken).transferFrom(msg.sender, address(this), CurrentTicketPrice);
uint256 f = CurrentTicketPrice.mul(feeAmount).div(10000);
uint256 amtAfterFee = CurrentTicketPrice.sub(f);
uint256 toLockAndPool = amtAfterFee.div(2);
ISwapRouter.ExactInputParams memory params =
ISwapRouter.ExactInputParams({
path: abi.encodePacked(Stable1, poolFee, Stable2, poolFee, WETH),
recipient: msg.sender,
deadline: block.timestamp,
amountIn: f,
amountOutMinimum: 0
});
uint256 amountOut = swapRouter.exactInput(params);
Treasury.add(amountOut);
Lock(msg.sender, toLockAndPool);
RewardPool = RewardPool.add(toLockAndPool);
participantList.push(msg.sender);
hasParticipated[msg.sender] = true;
userInfo.LottosParticipated = userInfo.LottosParticipated.add(1);
emit ParticipantRegistered(msg.sender, CurrentTicketPrice);
}
will doing this call a swap?
https://github.com/BOBseal/SolidityExamples/blob/master/Locks%20and%20Lotteries/lottery_Alpha-Incomplete.sol
nvm i made a typo
but still can anyone help me what i am doing wrong, i know something is not right but i can't seem to identify where
in the contract
Mar 28, 2023, 3:24 PM
bro how can we receive BNB or any other NATIVE token into our contract ??
can we use msg.value like receiving ETH ?
Mar 28, 2023, 3:55 PM
yes
for evm
Mar 28, 2023, 3:56 PM
my idea was when user buy the token, they have to pay with BNB or USDT
is it possible using msg.value ?
Mar 28, 2023, 3:57 PM
yes
for others it's transfer, transferFrom
Mar 28, 2023, 3:57 PM
okay bro, thanks
Mar 28, 2023, 3:58 PM
https://docs.soliditylang.org/en/v0.8.19/contracts.html#receive-ether-function
or
https://docs.soliditylang.org/en/v0.8.19/contracts.html#fallback-function
or
payable
https://docs.soliditylang.org/en/v0.8.19/grammar.html#a4.SolidityParser.stateMutability
or
https://docs.soliditylang.org/en/v0.8.19/contracts.html#fallback-function
or
payable
https://docs.soliditylang.org/en/v0.8.19/grammar.html#a4.SolidityParser.stateMutability
those for native crypto (ETH is not a token is a crypto)
for tokens (erc20), you can implement the IERC20 interface
for tokens (erc20), you can implement the IERC20 interface
The secret sauce is under balanceOf()
Mar 28, 2023, 6:27 PM
π€
Mar 28, 2023, 6:30 PM
where lot of us started
https://github.com/safemoonprotocol/Safemoon.sol/blob/main/Safemoon.sol
https://github.com/safemoonprotocol/Safemoon.sol/blob/main/Safemoon.sol
Mar 28, 2023, 6:33 PM
Yes, msg.value can be used to receive Ether (ETH) in a Solidity contract. When a user sends ETH to a contract, it can be accessed in the contract using the msg.value keyword, which represents the amount of Ether sent in the transaction.
Mar 28, 2023, 9:54 PM
guys any idea how to deploy to BSC ? cause binance are banned in my country
it can't fetch the chain ID, i use VPN but still can't
this is testnet RPC url: https://data-seed-prebsc-2-s1.binance.org:8545
failed to get chainId, falling back on net_version...
i got this errors
i got this errors
Mar 28, 2023, 10:04 PM
Whats with the chatGPT answers
Mar 28, 2023, 10:27 PM
bruh
https://bscscan.com/tx/0x48e52a12cb297354a2a1c54cbc897cf3772328e7e71f51c9889bb8c5e533a934
Mar 28, 2023, 10:38 PM
Rug
Mar 28, 2023, 10:40 PM
looks like exploiter
Mar 28, 2023, 10:55 PM
Yeah Iβm sure thatβs what coroney or whatever the dudes name is will throw it on lol.
Mar 28, 2023, 10:56 PM
Mar 28, 2023, 10:57 PM
ππ
Mar 28, 2023, 10:57 PM
too bad on DeFi you never know :\
Mar 28, 2023, 10:57 PM
please enable sticker and GIF
Mar 28, 2023, 10:57 PM
that's up to the group owner
Mar 28, 2023, 10:58 PM
Oh no we got exploited!
*wipes tears with bnb*
-coroney, probably.
*wipes tears with bnb*
-coroney, probably.
Mar 28, 2023, 10:58 PM
top meme of the yearπ
Mar 28, 2023, 11:00 PM
The attacker took advantage of the public burn() function, this function let any user burn tokens from ANY other address (code attached).
The attacker used this function to remove SFM tokens from the Safemoon-WBNB Liquidity Pool, artificially raising the price of SFM.
The attacker was then able to sell SFM into this LP at a grossly overpriced rate within the same transaction, wiping out the remaining WBNB in the liquidity pool.
The attacker used this function to remove SFM tokens from the Safemoon-WBNB Liquidity Pool, artificially raising the price of SFM.
The attacker was then able to sell SFM into this LP at a grossly overpriced rate within the same transaction, wiping out the remaining WBNB in the liquidity pool.
Apparently thatβs what happend to safemoon.
Mar 28, 2023, 11:05 PM
when is that happen ??
that is alot of BNB bro π
Mar 28, 2023, 11:42 PM
https://bscscan.com/tx/0xf98a8b7e3ffee676f06f0c037141483ec2c9cf8753a57fbcdbd718590e4d77ff "hey relax" lol
Mar 29, 2023, 1:12 AM
It's on ARB blockchain...
Does that count? or change anything?
Does that count? or change anything?
Mar 31, 2023, 9:00 AM
can anyone send me some goerli, just enough for 3-4 tx
Mar 31, 2023, 9:03 AM
I dont have much but send your address
Mar 31, 2023, 9:10 AM
0x76A6fEE997075AB315Ae97b5C54bc0A6c33b4D0f
Mar 31, 2023, 9:10 AM
Okay coming
Mar 31, 2023, 9:11 AM
thanks π
Mar 31, 2023, 9:11 AM
Sent 0.14
Lending Protocols in DeFi - Explained with Emojis π€π°π
π€ Oleanji(π§±,π) | oleanji.lens
https://twitter.com/Oleanji_sol/status/1640366815158099969?t=l5-RXG09ahqP-aRgFknFCA&s=19
π€ Oleanji(π§±,π) | oleanji.lens
https://twitter.com/Oleanji_sol/status/1640366815158099969?t=l5-RXG09ahqP-aRgFknFCA&s=19
who has tested out the zkEVM (polygon)
https://chn.lk/3YLC84r
Mar 31, 2023, 10:45 AM
anyone heard about brics currency? will it be like a stable backed by gold or something else? cbdc?
does anyone have any info
Mar 31, 2023, 10:53 AM
Yes, the BRICS countries (Brazil, Russia, India, China, and South Africa) have been exploring the possibility of creating a common cryptocurrency, sometimes referred to as the BRICS currency or BRICScoin. While there have been some discussions about this idea, there is no official plan or timeline for the creation of such a currency at this time.
It is not clear what form a potential BRICS currency would take, as there are many different approaches to designing a cryptocurrency. Some proponents of a BRICS currency have suggested that it could be backed by gold or other assets, similar to a stablecoin, in order to provide stability and avoid the volatility of other cryptocurrencies. Others have suggested that a BRICScoin could take the form of a central bank digital currency (CBDC), which would be issued and backed by the central banks of the BRICS countries.
At this point, it is difficult to say what the future holds for a potential BRICS currency. While there has been some interest and discussion around the idea, it remains to be seen whether or not such a currency will be created, and what form it would take if it is.
It is not clear what form a potential BRICS currency would take, as there are many different approaches to designing a cryptocurrency. Some proponents of a BRICS currency have suggested that it could be backed by gold or other assets, similar to a stablecoin, in order to provide stability and avoid the volatility of other cryptocurrencies. Others have suggested that a BRICScoin could take the form of a central bank digital currency (CBDC), which would be issued and backed by the central banks of the BRICS countries.
At this point, it is difficult to say what the future holds for a potential BRICS currency. While there has been some interest and discussion around the idea, it remains to be seen whether or not such a currency will be created, and what form it would take if it is.
Mar 31, 2023, 11:50 AM
ChatGPT strikes again.
Mar 31, 2023, 11:50 AM
ππ
Mar 31, 2023, 11:55 AM
ππ
Mar 31, 2023, 11:57 AM
there are "devs" doing interview with those
seems the "tx.origin" question always breaks their soul
seems the "tx.origin" question always breaks their soul
Mar 31, 2023, 12:51 PM
yoyo
Mar 31, 2023, 2:41 PM
Howβs you doing Karola?
Mar 31, 2023, 2:41 PM
π₯Ά
but that's not how it's calculated ig
on btc in bnb chain you mean, it'll be in btc price
is it same
Mar 31, 2023, 2:54 PM
/ban @m1token
Mar 31, 2023, 3:11 PM
Another one bites the dust...!
Banned M1.
Banned M1.
Mar 31, 2023, 3:11 PM