Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libs/evm-protocols/src/common-protocol/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ import {
arbitrum,
base,
baseSepolia,
soneium,
blast,
bsc,
linea,
mainnet,
optimism,
skaleCalypsoTestnet,
soneium,
} from 'viem/chains';
import Web3, { AbiInput, TransactionReceipt, Web3 as Web3Type } from 'web3';
import * as AbiCoder from 'web3-eth-abi';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,28 +123,21 @@ import { launchAndBuyThreadTokenUtility } from './useLaunchAndBuyThreadToken';

const MIN_ETH_FOR_CONTEST_THREAD = 0.0005;

// using sigmoid function
function calculateConnectorWeightFromUsdPrice(usdPrice: number): number {
if (usdPrice === 0) {
return 830000;
return 500000;
}
const initialBalance = BigInt(Math.floor((100 / usdPrice) * 1e18));
const graduationBalance = BigInt(Math.floor((1000 / usdPrice) * 1e18));
const launchpadLiquidity = BigInt(200_000_000) * BigInt(1e18);
const initialSupply = BigInt(1_000_000_000) * BigInt(1e18);
const MIN = 50000;
const MAX = 100000;

const supplyNum = Number(initialSupply) / 1e18;
const liquidityNum = Number(launchpadLiquidity) / 1e18;
const depositNum = Number(graduationBalance - initialBalance) / 1e18;
const balanceNum = Number(initialBalance) / 1e18;
const steepness = 2.5;
const log10Midpoint = 1.5; // log10 midpoint (~$32)

const connectorRatio = 1 + depositNum / balanceNum;
const tokenRatio = liquidityNum / supplyNum + 1;
const x = Math.log10(Math.max(usdPrice, 1));
const sigma = 1 / (1 + Math.exp(-steepness * (x - log10Midpoint)));

const w = Math.floor(
(1_000_000 * Math.log(tokenRatio)) / Math.log(connectorRatio),
);

return Math.max(10000, Math.min(1000000, w));
return Math.round(MIN - (MAX - MIN) * sigma);
}

interface NewThreadFormProps {
Expand Down Expand Up @@ -401,7 +394,7 @@ export const NewThreadForm = forwardRef<
const { data: launchpadPriceEth } = useGetLaunchpadPriceQuery(
chainRpc,
ethChainId,
communityToken?.token_address || '',
communityToken!.token_address || '',
!!externalUsdPrice && !isLoadingETHToCurrencyRate,
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ const ThreadTokenWidget = ({

try {
const amountInWei = parseFloat(safeCurrentAmount) * 1e18;
const minAmountOut = safeCurrentTokenGainAmount * 0.95 * 1e18;
const minAmountOut = Math.round(safeCurrentTokenGainAmount * 0.95 * 1e18);

const payload = {
chainRpc,
Expand Down
Loading