@ape.swap/bonds-sdk 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +26 -7
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -90297,7 +90297,7 @@ const PriceChart = ({ selectedBond, historicalPrices, }) => {
|
|
|
90297
90297
|
};
|
|
90298
90298
|
|
|
90299
90299
|
const ProjectView = ({ bondAddress, bondChain, historicalPrices }) => {
|
|
90300
|
-
var _a, _b, _c, _d, _e, _f
|
|
90300
|
+
var _a, _b, _c, _d, _e, _f;
|
|
90301
90301
|
const { data: bonds } = useBondsData();
|
|
90302
90302
|
const bondData = bonds === null || bonds === void 0 ? void 0 : bonds.find((bond) => {
|
|
90303
90303
|
var _a;
|
|
@@ -90313,13 +90313,20 @@ const ProjectView = ({ bondAddress, bondChain, historicalPrices }) => {
|
|
|
90313
90313
|
const sendReferenceId = useSendReferenceId();
|
|
90314
90314
|
const [buyTxHash, setBuyTxHash] = useState();
|
|
90315
90315
|
const [inputValue, setInputValue] = useState('');
|
|
90316
|
-
const [inputTokenString, setInputTokenString] = useState(
|
|
90316
|
+
const [inputTokenString, setInputTokenString] = useState('');
|
|
90317
|
+
useEffect(() => {
|
|
90318
|
+
var _a, _b;
|
|
90319
|
+
const inputTokenStr = (_b = (_a = bondData === null || bondData === void 0 ? void 0 : bondData.lpToken) === null || _a === void 0 ? void 0 : _a.address) === null || _b === void 0 ? void 0 : _b[bondData.chainId];
|
|
90320
|
+
if (!inputTokenString && bondData && inputTokenStr) {
|
|
90321
|
+
setInputTokenString(inputTokenStr);
|
|
90322
|
+
}
|
|
90323
|
+
}, [bondData]);
|
|
90317
90324
|
// Data
|
|
90318
90325
|
const inputToken = useTokenFromZapList(inputTokenString, bondData === null || bondData === void 0 ? void 0 : bondData.chainId, bondData === null || bondData === void 0 ? void 0 : bondData.lpToken);
|
|
90319
|
-
const isZap = (inputTokenString === null || inputTokenString === void 0 ? void 0 : inputTokenString.toLowerCase()) !== ((
|
|
90326
|
+
const isZap = (inputTokenString === null || inputTokenString === void 0 ? void 0 : inputTokenString.toLowerCase()) !== ((_c = (_b = (_a = bondData === null || bondData === void 0 ? void 0 : bondData.lpToken) === null || _a === void 0 ? void 0 : _a.address) === null || _b === void 0 ? void 0 : _b[bondData === null || bondData === void 0 ? void 0 : bondData.chainId]) === null || _c === void 0 ? void 0 : _c.toLowerCase());
|
|
90320
90327
|
const [fetchingZapQuote, zapData, zapEstimatedOutput, zapError] = useSoulZapBondQuote(inputValue, inputToken, bondData, account);
|
|
90321
90328
|
const inputTokenPrice = useCurrencyPrice(inputToken !== null && inputToken !== void 0 ? inputToken : null, parseInt(bondChain));
|
|
90322
|
-
const { data: inputCurrencyBalance } = useCurrencyBalance(inputToken !== null && inputToken !== void 0 ? inputToken : null, account !== null && account !== void 0 ? account : null, (
|
|
90329
|
+
const { data: inputCurrencyBalance } = useCurrencyBalance(inputToken !== null && inputToken !== void 0 ? inputToken : null, account !== null && account !== void 0 ? account : null, (_d = bondData === null || bondData === void 0 ? void 0 : bondData.chainId) !== null && _d !== void 0 ? _d : null);
|
|
90323
90330
|
// Estimations
|
|
90324
90331
|
const normalEstimatedOutput = youGet(bondData, inputValue);
|
|
90325
90332
|
const estimatedOutput = isZap ? zapEstimatedOutput : normalEstimatedOutput;
|
|
@@ -90336,7 +90343,7 @@ const ProjectView = ({ bondAddress, bondChain, historicalPrices }) => {
|
|
|
90336
90343
|
// Modals
|
|
90337
90344
|
const [onOpenZapModal] = useModal(jsx$2(ZapModal, { outputToken: bondData === null || bondData === void 0 ? void 0 : bondData.lpToken, account: account, chainId: bondData === null || bondData === void 0 ? void 0 : bondData.chainId }), true, true, 'zapModal');
|
|
90338
90345
|
// Approve & Purchase Functions
|
|
90339
|
-
const [approvalState, approveCallback] = useApproval(inputValue, inputToken !== null && inputToken !== void 0 ? inputToken : null, (
|
|
90346
|
+
const [approvalState, approveCallback] = useApproval(inputValue, inputToken !== null && inputToken !== void 0 ? inputToken : null, (_e = (isZap ? SoulZapTokenManager === null || SoulZapTokenManager === void 0 ? void 0 : SoulZapTokenManager[bondData === null || bondData === void 0 ? void 0 : bondData.chainId] : bondData === null || bondData === void 0 ? void 0 : bondData.billAddress)) !== null && _e !== void 0 ? _e : null, account !== null && account !== void 0 ? account : null, (_f = bondData === null || bondData === void 0 ? void 0 : bondData.chainId) !== null && _f !== void 0 ? _f : null);
|
|
90340
90347
|
const handleApprove = () => {
|
|
90341
90348
|
approveCallback().then(() => {
|
|
90342
90349
|
track({
|
|
@@ -90419,6 +90426,18 @@ const ProjectView = ({ bondAddress, bondChain, historicalPrices }) => {
|
|
|
90419
90426
|
window.open(`https://ape.bond/swap?outputcurrency=${bondData === null || bondData === void 0 ? void 0 : bondData.lpToken.address[bondData === null || bondData === void 0 ? void 0 : bondData.chainId]}&outputChain=${bondData === null || bondData === void 0 ? void 0 : bondData.chainId}`, '_blank');
|
|
90420
90427
|
}
|
|
90421
90428
|
};
|
|
90429
|
+
const handleOpenZapModal = () => {
|
|
90430
|
+
var _a;
|
|
90431
|
+
onOpenZapModal();
|
|
90432
|
+
track({
|
|
90433
|
+
event: 'getTokenClick',
|
|
90434
|
+
chain: bondData === null || bondData === void 0 ? void 0 : bondData.chainId,
|
|
90435
|
+
data: {
|
|
90436
|
+
bond: bondData === null || bondData === void 0 ? void 0 : bondData.earnToken.symbol,
|
|
90437
|
+
token: (_a = bondData === null || bondData === void 0 ? void 0 : bondData.lpToken) === null || _a === void 0 ? void 0 : _a.symbol,
|
|
90438
|
+
},
|
|
90439
|
+
});
|
|
90440
|
+
};
|
|
90422
90441
|
return (jsxs(Flex, { sx: styles$4.mainViewContainer, children: [jsx$2(RecommendationCards, {}), jsx$2(NavPanel, { contractAddress: bondData === null || bondData === void 0 ? void 0 : bondData.billAddress }), bondData ? (jsx$2(Fragment$1, { children: jsxs(Flex, { sx: { width: '100%', flexDirection: 'column', mt: '10px' }, children: [jsx$2(Flex, { sx: {
|
|
90423
90442
|
width: '100%',
|
|
90424
90443
|
display: ['none', 'none', 'none', 'block'],
|
|
@@ -90432,7 +90451,7 @@ const ProjectView = ({ bondAddress, bondChain, historicalPrices }) => {
|
|
|
90432
90451
|
p: '20px',
|
|
90433
90452
|
borderRadius: '10px',
|
|
90434
90453
|
mt: '5px',
|
|
90435
|
-
}, children: [jsx$2(BondModalHeader, { bondData: bondData }), jsx$2(ProjectDescription, { description: bondData.shortDescription }), jsx$2(Estimations, { bondData: bondData, inputValue: inputValue, inputToken: inputToken, estimatedOutput: estimatedOutput, inputTokenPrice: inputTokenPrice === null || inputTokenPrice === void 0 ? void 0 : inputTokenPrice.price, isZap: isZap, fetchingZapQuote: fetchingZapQuote, zapError: zapError }), jsx$2(TokenSelectorPanel, { typedValue: inputValue, setTypedValue: setInputValue, selectedToken: inputToken, handleMaxBtn: () => { var _a; return setInputValue((_a = new BigNumber$1(inputCurrencyBalance !== null && inputCurrencyBalance !== void 0 ? inputCurrencyBalance : '0')) === null || _a === void 0 ? void 0 : _a.toString()); }, handleCurrencySelect: handleCurrencySelect, chainId: bondData === null || bondData === void 0 ? void 0 : bondData.chainId, enableZap: supportedByLIFI.includes(bondData === null || bondData === void 0 ? void 0 : bondData.chainId), bondPrincipalToken: bondData === null || bondData === void 0 ? void 0 : bondData.lpToken, tokenBalance: inputCurrencyBalance, selectedTokenPrice: inputTokenPrice === null || inputTokenPrice === void 0 ? void 0 : inputTokenPrice.price }), jsxs(Flex, { className: "modaltable-container button-container", children: [jsx$2(Flex, { className: "button-container get", children: jsxs(Button, { className: "action-button", onClick: () =>
|
|
90454
|
+
}, children: [jsx$2(BondModalHeader, { bondData: bondData }), jsx$2(ProjectDescription, { description: bondData.shortDescription }), jsx$2(Estimations, { bondData: bondData, inputValue: inputValue, inputToken: inputToken, estimatedOutput: estimatedOutput, inputTokenPrice: inputTokenPrice === null || inputTokenPrice === void 0 ? void 0 : inputTokenPrice.price, isZap: isZap, fetchingZapQuote: fetchingZapQuote, zapError: zapError }), jsx$2(TokenSelectorPanel, { typedValue: inputValue, setTypedValue: setInputValue, selectedToken: inputToken, handleMaxBtn: () => { var _a; return setInputValue((_a = new BigNumber$1(inputCurrencyBalance !== null && inputCurrencyBalance !== void 0 ? inputCurrencyBalance : '0')) === null || _a === void 0 ? void 0 : _a.toString()); }, handleCurrencySelect: handleCurrencySelect, chainId: bondData === null || bondData === void 0 ? void 0 : bondData.chainId, enableZap: supportedByLIFI.includes(bondData === null || bondData === void 0 ? void 0 : bondData.chainId), bondPrincipalToken: bondData === null || bondData === void 0 ? void 0 : bondData.lpToken, tokenBalance: inputCurrencyBalance, selectedTokenPrice: inputTokenPrice === null || inputTokenPrice === void 0 ? void 0 : inputTokenPrice.price }), jsxs(Flex, { className: "modaltable-container button-container", children: [jsx$2(Flex, { className: "button-container get", children: jsxs(Button, { className: "action-button", onClick: () => supportedByLIFI.includes(bondData === null || bondData === void 0 ? void 0 : bondData.chainId) ? handleOpenZapModal() : openExternal(), variant: "secondary", children: ["Get ", getSymbol(bondData === null || bondData === void 0 ? void 0 : bondData.lpToken)] }) }), jsx$2(Flex, { className: "button-container buy", children: !account ? (jsx$2(ConnectButton, {})) : userChainId !== bondData.chainId ? (jsx$2(Button, { className: "switch-button", disabled: loadingTx || isConfirming || (bondData === null || bondData === void 0 ? void 0 : bondData.soldOut), onClick: (event) => {
|
|
90436
90455
|
event.stopPropagation();
|
|
90437
90456
|
switchChain({ chainId: bondData.chainId });
|
|
90438
90457
|
}, style: { fontSize: '14px', padding: '6px', marginLeft: '0px' }, children: `Switch to ${NETWORK_LABEL[bondData.chainId]}` })) : approvalState === ApprovalState.APPROVED ? (jsx$2(Button, { className: "action-button", load: load || fetchingZapQuote, disabled: load ||
|
|
@@ -90441,7 +90460,7 @@ const ProjectView = ({ bondAddress, bondChain, historicalPrices }) => {
|
|
|
90441
90460
|
!inputValue ||
|
|
90442
90461
|
parseFloat(inputValue) === 0 ||
|
|
90443
90462
|
fetchingZapQuote ||
|
|
90444
|
-
zapError, onClick: handleBothPurchases, children: zapError ? 'something went wrong' : `buy
|
|
90463
|
+
zapError, onClick: handleBothPurchases, children: zapError ? 'something went wrong' : `buy` })) : (jsx$2(Button, { className: "action-button", load: approvalState === ApprovalState.PENDING, disabled: approvalState === ApprovalState.PENDING ||
|
|
90445
90464
|
(bondData === null || bondData === void 0 ? void 0 : bondData.soldOut) ||
|
|
90446
90465
|
!account ||
|
|
90447
90466
|
!inputValue ||
|