@ape.swap/bonds-sdk 1.0.96 → 1.0.98
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.
|
@@ -11,9 +11,9 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsxs as _jsxs, jsx as _jsx } from "theme-ui/jsx-runtime";
|
|
13
13
|
/** @jsxImportSource theme-ui */
|
|
14
|
-
import { useEffect, useState } from 'react';
|
|
15
|
-
import { Flex, ThemeUIProvider, Input } from
|
|
16
|
-
import { useWeb3React } from
|
|
14
|
+
import React, { useEffect, useState } from 'react';
|
|
15
|
+
import { Flex, ThemeUIProvider, Input } from 'theme-ui';
|
|
16
|
+
import { useWeb3React } from '@web3-react/core';
|
|
17
17
|
import { getColumnDiscountStyle } from '../Bonds/styles';
|
|
18
18
|
import { defaultTheme } from '../../theme';
|
|
19
19
|
import '../../scss/bondmodal.scss';
|
|
@@ -26,9 +26,7 @@ var BondModal = function (_a) {
|
|
|
26
26
|
if (!isOpen)
|
|
27
27
|
return null;
|
|
28
28
|
var _b = useWeb3React(), account = _b.account, isActive = _b.isActive;
|
|
29
|
-
var vestingTime = function (vestingTerm) {
|
|
30
|
-
return getTimePeriods(vestingTerm !== null && vestingTerm !== void 0 ? vestingTerm : 0, true);
|
|
31
|
-
};
|
|
29
|
+
var vestingTime = function (vestingTerm) { return getTimePeriods(vestingTerm !== null && vestingTerm !== void 0 ? vestingTerm : 0, true); };
|
|
32
30
|
var _c = useState([]), bondData = _c[0], setBondData = _c[1];
|
|
33
31
|
useEffect(function () {
|
|
34
32
|
axios.get('https://realtime-api.ape.bond/bonds').then(function (response) {
|
|
@@ -37,10 +35,10 @@ var BondModal = function (_a) {
|
|
|
37
35
|
});
|
|
38
36
|
setBondData(bond);
|
|
39
37
|
});
|
|
40
|
-
}, []);
|
|
41
|
-
return (bondData.map(function (bond) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
}, [bondAddress]);
|
|
39
|
+
return (_jsx(ThemeUIProvider, __assign({ theme: defaultTheme }, { children: bondData.map(function (bond) {
|
|
40
|
+
var _a, _b, _c, _d, _e, _f;
|
|
41
|
+
return (_jsx(React.Fragment, { children: _jsx(Flex, __assign({ className: "modal modal-backdrop" }, { children: _jsxs(Flex, __assign({ className: "modal modal-content" }, { children: [isActive && account && (_jsxs("p", { children: ["Wallet Address: ", account] })), _jsxs(Flex, __assign({ className: "modal modal-header" }, { children: [_jsx(Flex, __assign({ className: "new" }, { children: "NEW" })), _jsxs(Flex, __assign({ className: "project-info" }, { children: ["Project Info", _jsx(Flex, __assign({ className: "project-info icon" }, { children: _jsx(Svg, { icon: "expand" }) }))] })), _jsx(Flex, __assign({ className: "svg-close", onClick: onClose }, { children: _jsx(Svg, { icon: "close" }) }))] })), _jsxs(Flex, __assign({ className: "modal-container table-container" }, { children: [_jsxs(Flex, __assign({ className: "modal-container title-container" }, { children: [_jsx(Flex, __assign({ className: "title-container bond" }, { children: bond === null || bond === void 0 ? void 0 : bond.showcaseTokenName })), _jsxs(Flex, __assign({ className: "title-container bond-price" }, { children: [_jsx(Flex, __assign({ className: "bond-price price" }, { children: "$0.0111" })), _jsx(Flex, __assign({ className: "bond-price discounted" }, { children: "$0.0101" }))] }))] })), _jsx(Flex, __assign({ className: "modal-container description-container" }, { children: bond === null || bond === void 0 ? void 0 : bond.shortDescription })), _jsxs(Flex, __assign({ className: "modal-container blocks-container" }, { children: [_jsxs(Flex, __assign({ className: "modal-block column-discount", sx: getColumnDiscountStyle((_a = bond === null || bond === void 0 ? void 0 : bond.discount) !== null && _a !== void 0 ? _a : 0) }, { children: [_jsxs(Flex, __assign({ className: "block-header header" }, { children: ["Discount", _jsx(Flex, __assign({ className: "block-header icon" }, { children: _jsx(Svg, { icon: "questionFill", width: "15px" }) }))] })), "".concat((_b = bond === null || bond === void 0 ? void 0 : bond.discount) === null || _b === void 0 ? void 0 : _b.toFixed(2), "%")] })), _jsxs(Flex, __assign({ className: "modal-block column-arr" }, { children: [_jsxs(Flex, __assign({ className: "block-header header" }, { children: ["ARR", _jsx(Flex, __assign({ className: "block-header icon" }, { children: _jsx(Svg, { icon: "questionFill", width: "15px" }) }))] })), "".concat(((((_c = bond === null || bond === void 0 ? void 0 : bond.discount) !== null && _c !== void 0 ? _c : 0) * 365) / vestingTime((_d = bond === null || bond === void 0 ? void 0 : bond.vestingTerm) !== null && _d !== void 0 ? _d : 0).days).toFixed(2), "%")] })), _jsxs(Flex, __assign({ className: "modal-block column-term" }, { children: [_jsxs(Flex, __assign({ className: "block-header header" }, { children: ["Terms", _jsx(Flex, __assign({ className: "block-header icon" }, { children: _jsx(Svg, { icon: "questionFill", width: "15px" }) }))] })), vestingTime((_e = bond === null || bond === void 0 ? void 0 : bond.vestingTerm) !== null && _e !== void 0 ? _e : 0).days ? "".concat(vestingTime((_f = bond === null || bond === void 0 ? void 0 : bond.vestingTerm) !== null && _f !== void 0 ? _f : 0).days, " D") : '-'] })), _jsxs(Flex, __assign({ className: "modal-block column-maxbuy" }, { children: [_jsxs(Flex, __assign({ className: "block-header header" }, { children: ["Max Buy", _jsx(Flex, __assign({ className: "block-header icon" }, { children: _jsx(Svg, { icon: "questionFill", width: "15px" }) }))] })), "1,000,000"] }))] })), _jsxs(Flex, __assign({ className: "modal-container text-container" }, { children: [_jsxs(Flex, __assign({ className: "text-container row" }, { children: [_jsx("div", { children: "You spend:" }), _jsxs("div", { children: ["0 ", bond === null || bond === void 0 ? void 0 : bond.principalTokenName, " = $ 0"] })] })), _jsxs(Flex, __assign({ className: "text-container row" }, { children: [_jsxs("div", { children: ["Premium: ", _jsx(Svg, { icon: "questionFill", width: "15px" })] }), _jsx("div", { children: "$ 0" })] })), _jsxs(Flex, __assign({ className: "text-container row" }, { children: [_jsx("div", { children: "You get (over 90 days):" }), _jsxs("div", { children: ["0 ", bond === null || bond === void 0 ? void 0 : bond.showcaseTokenName, " = $ 0"] })] }))] })), _jsxs(Flex, __assign({ className: "modal-container input-container" }, { children: [_jsx(Flex, __assign({ className: "input-container input" }, { children: _jsx(Input, { type: "number", className: "number-input", placeholder: "0.0" }) })), _jsx(Flex, __assign({ className: "input-container token" }, { children: bond === null || bond === void 0 ? void 0 : bond.principalTokenName }))] })), _jsxs(Flex, __assign({ className: "modal-container button-container" }, { children: [_jsx(Flex, __assign({ className: "button-container get" }, { children: _jsxs(Button, { children: ["Get ", bond === null || bond === void 0 ? void 0 : bond.principalTokenName] }) })), _jsx(Flex, __assign({ className: "button-container buy" }, { children: _jsxs(Button, { children: ["Buy ", bond === null || bond === void 0 ? void 0 : bond.showcaseTokenName] }) }))] }))] }))] })) })) }, bond.billAddress));
|
|
42
|
+
}) })));
|
|
45
43
|
};
|
|
46
44
|
export default BondModal;
|
|
@@ -48,30 +48,34 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
48
48
|
import { jsx as _jsx, jsxs as _jsxs } from "theme-ui/jsx-runtime";
|
|
49
49
|
/** @jsxImportSource theme-ui */
|
|
50
50
|
import { useEffect, useState } from 'react';
|
|
51
|
-
import { Flex, ThemeUIProvider } from
|
|
52
|
-
import axios from
|
|
51
|
+
import { Flex, ThemeUIProvider } from 'theme-ui';
|
|
52
|
+
import axios from 'axios';
|
|
53
53
|
import { ethers } from 'ethers';
|
|
54
|
-
import { useWeb3React } from
|
|
54
|
+
import { useWeb3React } from '@web3-react/core';
|
|
55
|
+
import { useSearchParams, useNavigate } from 'react-router-dom';
|
|
55
56
|
import styles, { getColumnDiscountStyle } from './styles';
|
|
56
57
|
import getTimePeriods from '../../utils/getTimePeriods';
|
|
57
58
|
import { defaultTheme } from '../../theme';
|
|
58
59
|
import Svg from '../uikit/Svg';
|
|
59
60
|
import '../../scss/bonds.scss';
|
|
61
|
+
import BondModal from '../BondModal/BondModal';
|
|
60
62
|
var Bonds = function (_a) {
|
|
61
63
|
var connectionString = _a.connectionString;
|
|
62
64
|
var _b = useWeb3React(), account = _b.account, isActive = _b.isActive;
|
|
65
|
+
var _c = useSearchParams(), searchParams = _c[0], setSearchParams = _c[1];
|
|
66
|
+
var navigate = useNavigate();
|
|
63
67
|
var USDT_ABI = [
|
|
64
68
|
// The ERC-20 approve function ABI
|
|
65
|
-
|
|
69
|
+
'function approve(address spender, uint256 amount) public returns (bool)',
|
|
66
70
|
];
|
|
67
|
-
var USDT_ADDRESS =
|
|
71
|
+
var USDT_ADDRESS = '0xdAC17F958D2ee523a2206206994597C13D831ec7'; // USDT contract address on Ethereum mainnet
|
|
68
72
|
var handleApprove = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
69
73
|
var provider, signer, usdtContract, tx, error_1;
|
|
70
74
|
return __generator(this, function (_a) {
|
|
71
75
|
switch (_a.label) {
|
|
72
76
|
case 0:
|
|
73
77
|
if (!window.ethereum) {
|
|
74
|
-
console.error(
|
|
78
|
+
console.error('No Ethereum provider found');
|
|
75
79
|
alert('No Ethereum provider found');
|
|
76
80
|
return [2 /*return*/];
|
|
77
81
|
}
|
|
@@ -82,8 +86,7 @@ var Bonds = function (_a) {
|
|
|
82
86
|
case 1:
|
|
83
87
|
_a.trys.push([1, 4, , 5]);
|
|
84
88
|
return [4 /*yield*/, usdtContract.approve(account, // Replace with the actual spender address
|
|
85
|
-
ethers.utils.parseUnits(
|
|
86
|
-
)];
|
|
89
|
+
ethers.utils.parseUnits('1000.0', 6))];
|
|
87
90
|
case 2:
|
|
88
91
|
tx = _a.sent();
|
|
89
92
|
return [4 /*yield*/, tx.wait()];
|
|
@@ -93,29 +96,29 @@ var Bonds = function (_a) {
|
|
|
93
96
|
return [3 /*break*/, 5];
|
|
94
97
|
case 4:
|
|
95
98
|
error_1 = _a.sent();
|
|
96
|
-
console.error(
|
|
99
|
+
console.error('Approval error', error_1);
|
|
97
100
|
alert('Approval Failed');
|
|
98
101
|
return [3 /*break*/, 5];
|
|
99
102
|
case 5: return [2 /*return*/];
|
|
100
103
|
}
|
|
101
104
|
});
|
|
102
105
|
}); };
|
|
103
|
-
var
|
|
104
|
-
var
|
|
106
|
+
var _d = useState([]), bondData = _d[0], setBondData = _d[1];
|
|
107
|
+
var _e = useState([]), hotBonds = _e[0], setHotBonds = _e[1];
|
|
105
108
|
var vestingTime = function (vestingTerm) {
|
|
106
109
|
return getTimePeriods(vestingTerm !== null && vestingTerm !== void 0 ? vestingTerm : 0, true);
|
|
107
110
|
};
|
|
108
111
|
useEffect(function () {
|
|
109
112
|
axios.get('https://realtime-api.ape.bond/bonds').then(function (response) {
|
|
110
|
-
var bonds = response.data.bonds.filter(function (x) {
|
|
111
|
-
return x.soldOut !== true && x.inactive !== true && x.discount < 25;
|
|
112
|
-
});
|
|
113
|
+
var bonds = response.data.bonds.filter(function (x) { return x.soldOut !== true && x.inactive !== true && x.discount < 25; });
|
|
113
114
|
setBondData(bonds);
|
|
114
115
|
});
|
|
115
116
|
}, []);
|
|
116
117
|
useEffect(function () {
|
|
117
118
|
axios.get('https://apeswap-strapi.herokuapp.com/hot-bonds').then(function (response) {
|
|
118
|
-
var hotBondAddresses = response.data.map(function (bond) {
|
|
119
|
+
var hotBondAddresses = response.data.map(function (bond) {
|
|
120
|
+
return bond.BondAddress.toLowerCase();
|
|
121
|
+
});
|
|
119
122
|
setHotBonds(hotBondAddresses);
|
|
120
123
|
});
|
|
121
124
|
}, []);
|
|
@@ -133,24 +136,21 @@ var Bonds = function (_a) {
|
|
|
133
136
|
return b.discount - a.discount;
|
|
134
137
|
}
|
|
135
138
|
});
|
|
136
|
-
var
|
|
137
|
-
|
|
138
|
-
window.location.href = url;
|
|
139
|
-
};
|
|
140
|
-
// Modal
|
|
141
|
-
var _e = useState(false), isModalOpen = _e[0], setIsModalOpen = _e[1];
|
|
142
|
-
var _f = useState(null), selectedBond = _f[0], setSelectedBond = _f[1];
|
|
139
|
+
var _f = useState(false), isModalOpen = _f[0], setIsModalOpen = _f[1];
|
|
140
|
+
var _g = useState(null), selectedBond = _g[0], setSelectedBond = _g[1];
|
|
143
141
|
var rowClick = function (bond) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
142
|
+
setSelectedBond(bond);
|
|
143
|
+
setIsModalOpen(true);
|
|
144
|
+
navigate("/?bondAddress=".concat(bond.billAddress, "&bondChain=").concat(bond.chainId), { replace: true });
|
|
145
|
+
};
|
|
146
|
+
var handleCloseModal = function () {
|
|
147
|
+
setIsModalOpen(false);
|
|
148
|
+
setSelectedBond(null);
|
|
149
|
+
navigate('/', { replace: true });
|
|
148
150
|
};
|
|
149
|
-
return (_jsxs(ThemeUIProvider, __assign({ theme: defaultTheme }, { children: [isActive && account &&
|
|
151
|
+
return (_jsxs(ThemeUIProvider, __assign({ theme: defaultTheme }, { children: [isActive && account && _jsx("p", { children: account }), isActive && account && _jsx("button", __assign({ onClick: handleApprove }, { children: "Approve USDT" })), _jsxs(Flex, __assign({ className: "container table-container" }, { children: [_jsxs(Flex, __assign({ className: "container header-container" }, { children: [_jsx(Flex, __assign({ className: "column column-header" }, { children: "Tokens" })), _jsx(Flex, __assign({ className: "column column-header" }, { children: "Discount" })), _jsx(Flex, __assign({ className: "column column-header" }, { children: "ARR" })), _jsx(Flex, __assign({ className: "column column-header" }, { children: "Terms" })), _jsx(Flex, __assign({ className: "column column-header" }, { children: "Tokens Remaining" })), _jsx(Flex, { className: "column column-header" })] })), sortedBonds.map(function (bond) {
|
|
150
152
|
var _a, _b, _c, _d;
|
|
151
|
-
return (
|
|
152
|
-
|
|
153
|
-
_jsxs(Flex, __assign({ className: "container bondrow-container", onClick: function () { return rowClick(bond); } }, { children: [_jsx(Flex, __assign({ className: "column column-token", sx: styles.columnToken }, { children: bond.showcaseTokenName })), _jsx(Flex, __assign({ className: "column column-discount", sx: getColumnDiscountStyle((_a = bond === null || bond === void 0 ? void 0 : bond.discount) !== null && _a !== void 0 ? _a : 0) }, { children: "".concat((_b = bond === null || bond === void 0 ? void 0 : bond.discount) === null || _b === void 0 ? void 0 : _b.toFixed(2), "%") })), _jsx(Flex, __assign({ className: "column column-arr", sx: styles.columnArr }, { children: "".concat("".concat(((((_c = bond === null || bond === void 0 ? void 0 : bond.discount) !== null && _c !== void 0 ? _c : 0) * 365) / vestingTime(bond.vestingTerm).days).toFixed(2), "%")) })), _jsx(Flex, __assign({ className: "column column-term", sx: styles.columnTerm }, { children: vestingTime(bond.vestingTerm).days ? "".concat(vestingTime(bond.vestingTerm).days, " D") : '-' })), _jsx(Flex, __assign({ className: "column column-tokensremaining", sx: styles.columnTokensRemaining }, { children: bond.tokensRemaining.split('.')[0] })), _jsx(Flex, __assign({ className: "column column-hotbond" }, { children: _jsx(Flex, __assign({ className: "column column-icon" }, { children: hotBonds.includes(bond.billAddress.toLowerCase()) && ((_d = bond.discount) !== null && _d !== void 0 ? _d : 0) > 0 && (_jsx(Svg, { icon: "fire", width: "20px" })) })) }))] })));
|
|
154
|
-
})] }))] })));
|
|
153
|
+
return (_jsxs(Flex, __assign({ className: "container bondrow-container", onClick: function () { return rowClick(bond); } }, { children: [_jsx(Flex, __assign({ className: "column column-token", sx: styles.columnToken }, { children: bond.showcaseTokenName })), _jsx(Flex, __assign({ className: "column column-discount", sx: getColumnDiscountStyle((_a = bond === null || bond === void 0 ? void 0 : bond.discount) !== null && _a !== void 0 ? _a : 0) }, { children: "".concat((_b = bond === null || bond === void 0 ? void 0 : bond.discount) === null || _b === void 0 ? void 0 : _b.toFixed(2), "%") })), _jsx(Flex, __assign({ className: "column column-arr", sx: styles.columnArr }, { children: "".concat(((((_c = bond === null || bond === void 0 ? void 0 : bond.discount) !== null && _c !== void 0 ? _c : 0) * 365) / vestingTime(bond.vestingTerm).days).toFixed(2), "%") })), _jsx(Flex, __assign({ className: "column column-term", sx: styles.columnTerm }, { children: vestingTime(bond.vestingTerm).days ? "".concat(vestingTime(bond.vestingTerm).days, " D") : '-' })), _jsx(Flex, __assign({ className: "column column-tokensremaining", sx: styles.columnTokensRemaining }, { children: bond.tokensRemaining.split('.')[0] })), _jsx(Flex, __assign({ className: "column column-hotbond" }, { children: _jsx(Flex, __assign({ className: "column column-icon" }, { children: hotBonds.includes(bond.billAddress.toLowerCase()) && ((_d = bond.discount) !== null && _d !== void 0 ? _d : 0) > 0 && (_jsx(Svg, { icon: "fire", width: "20px" })) })) }))] }), bond.billAddress));
|
|
154
|
+
})] })), selectedBond && (_jsx(BondModal, { isOpen: isModalOpen, onClose: handleCloseModal, bondAddress: selectedBond.billAddress }))] })));
|
|
155
155
|
};
|
|
156
156
|
export default Bonds;
|