-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<!-- Before opening a pull request, please read the [contributing guidelines](https://github.com/pancakeswap/pancake-frontend/blob/develop/CONTRIBUTING.md) first --> <!-- start pr-codex --> --- ## PR-Codex overview This PR introduces functionality for an Initial DEX Offering (IDO) feature. It adds new hooks, constants, and contract interactions related to IDOs, allowing users to deposit, claim, and retrieve information about their participation in IDOs. ### Detailed summary - Added `getIDOAddress` function in `addressHelpers.ts`. - Introduced IDO-related constants in `contracts.ts`. - Created `useIDOContract` hook in `useContract.ts`. - Added hooks for user info, status, deposit, and claim related to IDOs. - Defined IDO ABI in `ido.ts`. - Implemented queries for IDO pool info and user details. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
- Loading branch information
Showing
13 changed files
with
674 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,260 @@ | ||
export const idoABI = [ | ||
{ inputs: [], stateMutability: 'nonpayable', type: 'constructor' }, | ||
{ inputs: [], name: 'AddressesLengthNotCorrect', type: 'error' }, | ||
{ inputs: [], name: 'AlreadyHarvested', type: 'error' }, | ||
{ inputs: [], name: 'AlreadyInitialized', type: 'error' }, | ||
{ inputs: [], name: 'AmountMustBeZero', type: 'error' }, | ||
{ inputs: [], name: 'AmountMustExceedZero', type: 'error' }, | ||
{ inputs: [], name: 'CanNotBeLPToken', type: 'error' }, | ||
{ inputs: [], name: 'CanNotBeOfferingToken', type: 'error' }, | ||
{ inputs: [], name: 'DidNotParticipate', type: 'error' }, | ||
{ inputs: [], name: 'EmptyUserAddress', type: 'error' }, | ||
{ inputs: [], name: 'EndTimeTooFar', type: 'error' }, | ||
{ inputs: [], name: 'FlatTaxRateMustBe0WhenHasTaxIsFalse', type: 'error' }, | ||
{ inputs: [], name: 'FlatTaxRateMustBeLessThan1e12', type: 'error' }, | ||
{ inputs: [], name: 'IDOHasEnded', type: 'error' }, | ||
{ inputs: [], name: 'IDOHasStarted', type: 'error' }, | ||
{ inputs: [], name: 'NewAmountAboveUserCap', type: 'error' }, | ||
{ inputs: [], name: 'NotEnoughLPTokens', type: 'error' }, | ||
{ inputs: [], name: 'NotEnoughOfferingTokens', type: 'error' }, | ||
{ inputs: [], name: 'NotFactory', type: 'error' }, | ||
{ inputs: [], name: 'NotMeetAnyoneOfRequiredConditions', type: 'error' }, | ||
{ inputs: [], name: 'PoolNotSet', type: 'error' }, | ||
{ inputs: [], name: 'StartAndEndTimestampsLengthNotCorrect', type: 'error' }, | ||
{ inputs: [], name: 'StartTimeMustGreaterThanCurrentBlockTime', type: 'error' }, | ||
{ inputs: [], name: 'StartTimeMustInferiorToEndTime', type: 'error' }, | ||
{ inputs: [], name: 'TokensNotDepositedProperly', type: 'error' }, | ||
{ inputs: [], name: 'TooEarly', type: 'error' }, | ||
{ inputs: [], name: 'TooLate', type: 'error' }, | ||
{ | ||
anonymous: false, | ||
inputs: [ | ||
{ indexed: false, internalType: 'address', name: 'tokenAddress', type: 'address' }, | ||
{ indexed: false, internalType: 'uint256', name: 'amountTokens', type: 'uint256' }, | ||
], | ||
name: 'AdminTokenRecovery', | ||
type: 'event', | ||
}, | ||
{ | ||
anonymous: false, | ||
inputs: [ | ||
{ indexed: false, internalType: 'uint256', name: 'amountLP', type: 'uint256' }, | ||
{ indexed: false, internalType: 'uint256', name: 'amountOfferingToken', type: 'uint256' }, | ||
], | ||
name: 'AdminWithdraw', | ||
type: 'event', | ||
}, | ||
{ | ||
anonymous: false, | ||
inputs: [ | ||
{ indexed: true, internalType: 'address', name: 'user', type: 'address' }, | ||
{ indexed: false, internalType: 'uint256', name: 'amount', type: 'uint256' }, | ||
], | ||
name: 'Deposit', | ||
type: 'event', | ||
}, | ||
{ | ||
anonymous: false, | ||
inputs: [ | ||
{ indexed: true, internalType: 'address', name: 'user', type: 'address' }, | ||
{ indexed: false, internalType: 'uint256', name: 'offeringAmount', type: 'uint256' }, | ||
{ indexed: false, internalType: 'uint256', name: 'excessAmount', type: 'uint256' }, | ||
], | ||
name: 'Harvest', | ||
type: 'event', | ||
}, | ||
{ | ||
anonymous: false, | ||
inputs: [ | ||
{ indexed: false, internalType: 'uint256', name: 'startTimestamp', type: 'uint256' }, | ||
{ indexed: false, internalType: 'uint256', name: 'endTimestamp', type: 'uint256' }, | ||
], | ||
name: 'NewStartAndEndTimestamps', | ||
type: 'event', | ||
}, | ||
{ | ||
anonymous: false, | ||
inputs: [ | ||
{ indexed: true, internalType: 'address', name: 'previousOwner', type: 'address' }, | ||
{ indexed: true, internalType: 'address', name: 'newOwner', type: 'address' }, | ||
], | ||
name: 'OwnershipTransferred', | ||
type: 'event', | ||
}, | ||
{ | ||
anonymous: false, | ||
inputs: [ | ||
{ indexed: false, internalType: 'uint256', name: 'offeringAmountPool', type: 'uint256' }, | ||
{ indexed: false, internalType: 'uint256', name: 'raisingAmountPool', type: 'uint256' }, | ||
], | ||
name: 'PoolParametersSet', | ||
type: 'event', | ||
}, | ||
{ | ||
inputs: [], | ||
name: 'MAX_BUFFER_SECONDS', | ||
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [], | ||
name: '_poolInformation', | ||
outputs: [ | ||
{ internalType: 'uint256', name: 'raisingAmountPool', type: 'uint256' }, | ||
{ internalType: 'uint256', name: 'offeringAmountPool', type: 'uint256' }, | ||
{ internalType: 'uint256', name: 'capPerUserInLP', type: 'uint256' }, | ||
{ internalType: 'bool', name: 'hasTax', type: 'bool' }, | ||
{ internalType: 'uint256', name: 'flatTaxRate', type: 'uint256' }, | ||
{ internalType: 'uint256', name: 'totalAmountPool', type: 'uint256' }, | ||
{ internalType: 'uint256', name: 'sumTaxesOverflow', type: 'uint256' }, | ||
], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], | ||
name: 'addresses', | ||
outputs: [{ internalType: 'address', name: '', type: 'address' }], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [{ internalType: 'uint256', name: '_amount', type: 'uint256' }], | ||
name: 'depositPool', | ||
outputs: [], | ||
stateMutability: 'payable', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [], | ||
name: 'endTimestamp', | ||
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [ | ||
{ internalType: 'uint256', name: '_lpAmount', type: 'uint256' }, | ||
{ internalType: 'uint256', name: '_offerAmount', type: 'uint256' }, | ||
], | ||
name: 'finalWithdraw', | ||
outputs: [], | ||
stateMutability: 'nonpayable', | ||
type: 'function', | ||
}, | ||
{ inputs: [], name: 'harvestPool', outputs: [], stateMutability: 'nonpayable', type: 'function' }, | ||
{ | ||
inputs: [ | ||
{ internalType: 'address[]', name: '_addresses', type: 'address[]' }, | ||
{ internalType: 'uint256[]', name: '_startAndEndTimestamps', type: 'uint256[]' }, | ||
{ internalType: 'uint256', name: '_maxBufferSeconds', type: 'uint256' }, | ||
], | ||
name: 'initialize', | ||
outputs: [], | ||
stateMutability: 'nonpayable', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [], | ||
name: 'owner', | ||
outputs: [{ internalType: 'address', name: '', type: 'address' }], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [ | ||
{ internalType: 'address', name: '_tokenAddress', type: 'address' }, | ||
{ internalType: 'uint256', name: '_tokenAmount', type: 'uint256' }, | ||
], | ||
name: 'recoverWrongTokens', | ||
outputs: [], | ||
stateMutability: 'nonpayable', | ||
type: 'function', | ||
}, | ||
{ inputs: [], name: 'renounceOwnership', outputs: [], stateMutability: 'nonpayable', type: 'function' }, | ||
{ | ||
inputs: [ | ||
{ internalType: 'uint256', name: '_offeringAmountPool', type: 'uint256' }, | ||
{ internalType: 'uint256', name: '_raisingAmountPool', type: 'uint256' }, | ||
{ internalType: 'uint256', name: '_limitPerUserInLP', type: 'uint256' }, | ||
{ internalType: 'bool', name: '_hasTax', type: 'bool' }, | ||
{ internalType: 'uint256', name: '_flatTaxRate', type: 'uint256' }, | ||
], | ||
name: 'setPool', | ||
outputs: [], | ||
stateMutability: 'nonpayable', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [], | ||
name: 'startTimestamp', | ||
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [{ internalType: 'address', name: 'newOwner', type: 'address' }], | ||
name: 'transferOwnership', | ||
outputs: [], | ||
stateMutability: 'nonpayable', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [{ internalType: 'uint256[]', name: '_startAndEndTimestamps', type: 'uint256[]' }], | ||
name: 'updateStartAndEndTimestamps', | ||
outputs: [], | ||
stateMutability: 'nonpayable', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [], | ||
name: 'viewPoolInformation', | ||
outputs: [ | ||
{ internalType: 'uint256', name: '', type: 'uint256' }, | ||
{ internalType: 'uint256', name: '', type: 'uint256' }, | ||
{ internalType: 'uint256', name: '', type: 'uint256' }, | ||
{ internalType: 'bool', name: '', type: 'bool' }, | ||
{ internalType: 'uint256', name: '', type: 'uint256' }, | ||
{ internalType: 'uint256', name: '', type: 'uint256' }, | ||
{ internalType: 'uint256', name: '', type: 'uint256' }, | ||
], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [], | ||
name: 'viewPoolTaxRateOverflow', | ||
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [{ internalType: 'address', name: '_user', type: 'address' }], | ||
name: 'viewUserAllocation', | ||
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [{ internalType: 'address', name: '_user', type: 'address' }], | ||
name: 'viewUserInfo', | ||
outputs: [ | ||
{ internalType: 'uint256', name: '', type: 'uint256' }, | ||
{ internalType: 'bool', name: '', type: 'bool' }, | ||
], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
{ | ||
inputs: [{ internalType: 'address', name: '_user', type: 'address' }], | ||
name: 'viewUserOfferingAndRefundingAmounts', | ||
outputs: [ | ||
{ internalType: 'uint256', name: '', type: 'uint256' }, | ||
{ internalType: 'uint256', name: '', type: 'uint256' }, | ||
{ internalType: 'uint256', name: '', type: 'uint256' }, | ||
], | ||
stateMutability: 'view', | ||
type: 'function', | ||
}, | ||
] as const |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { type Currency, CurrencyAmount, Percent } from '@pancakeswap/swap-sdk-core' | ||
import { useMemo } from 'react' | ||
import { useIDOCurrencies } from './useIDOCurrencies' | ||
import { useIDOPoolInfo } from './useIDOPoolInfo' | ||
|
||
export type IDOStatus = { | ||
progress: Percent | ||
currentStakedAmount: CurrencyAmount<Currency> | ||
} | ||
|
||
export const useIDOStatus = () => { | ||
const { stakeCurrency } = useIDOCurrencies() | ||
const { data: poolInfo } = useIDOPoolInfo() | ||
|
||
const progress = useMemo(() => { | ||
if (!poolInfo) return new Percent(0, 100) | ||
return new Percent(poolInfo.totalAmountPool, poolInfo.raisingAmountPool) | ||
}, [poolInfo]) | ||
|
||
const currentStakedAmount = useMemo(() => { | ||
if (!stakeCurrency || !poolInfo) return undefined | ||
return CurrencyAmount.fromRawAmount(stakeCurrency, poolInfo.totalAmountPool) | ||
}, [poolInfo, stakeCurrency]) | ||
|
||
return { | ||
progress, | ||
currentStakedAmount, | ||
} | ||
} |
Oops, something went wrong.