@ape.swap/bonds-sdk 1.0.105 → 1.0.107
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/components/BondModal/BondModal.js +15 -3
- package/dist/components/BondSingle/BondSingle.js +5 -3
- package/dist/components/Bonds/Bonds.js +2 -3
- package/dist/scss/bondmodal.scss +8 -0
- package/dist/scss/bonds.scss +11 -8
- package/dist/scss/bondsingle.scss +8 -0
- package/package.json +1 -1
- package/dist/components/Bonds/styles.d.ts +0 -4
- package/dist/components/Bonds/styles.js +0 -75
|
@@ -14,13 +14,13 @@ import { jsxs as _jsxs, jsx as _jsx } from "theme-ui/jsx-runtime";
|
|
|
14
14
|
import React, { useEffect, useState } from 'react';
|
|
15
15
|
import { Flex, ThemeUIProvider, Input } from 'theme-ui';
|
|
16
16
|
import { useWeb3React } from '@web3-react/core';
|
|
17
|
-
import { getColumnDiscountStyle } from '../Bonds/styles';
|
|
18
17
|
import { defaultTheme } from '../../theme';
|
|
19
18
|
import '../../scss/bondmodal.scss';
|
|
20
19
|
import getTimePeriods from '../../utils/getTimePeriods';
|
|
21
20
|
import { Button } from '../uikit/Button';
|
|
22
21
|
import Svg from '../uikit/Svg';
|
|
23
22
|
import axios from 'axios';
|
|
23
|
+
import { BigNumber } from 'bignumber.js';
|
|
24
24
|
var BondModal = function (_a) {
|
|
25
25
|
var isOpen = _a.isOpen, onClose = _a.onClose, bondAddress = _a.bondAddress;
|
|
26
26
|
if (!isOpen)
|
|
@@ -36,9 +36,21 @@ var BondModal = function (_a) {
|
|
|
36
36
|
setBondData(bond);
|
|
37
37
|
});
|
|
38
38
|
}, [bondAddress]);
|
|
39
|
+
var getDiscountColor = function (discount) {
|
|
40
|
+
return discount < 0 ? 'discount-negative' : 'discount-positive';
|
|
41
|
+
};
|
|
42
|
+
var calcMaxBuy = function (bond) {
|
|
43
|
+
var _a, _b, _c, _d;
|
|
44
|
+
var available = new BigNumber((_a = bond === null || bond === void 0 ? void 0 : bond.tokensRemaining) !== null && _a !== void 0 ? _a : '0');
|
|
45
|
+
var threshold = 5;
|
|
46
|
+
var thresholdToShow = new BigNumber(threshold).div((_b = bond === null || bond === void 0 ? void 0 : bond.payoutTokenPrice) !== null && _b !== void 0 ? _b : 0);
|
|
47
|
+
var safeAvailable = available.minus(thresholdToShow);
|
|
48
|
+
var singlePurchaseLimit = new BigNumber((_c = bond === null || bond === void 0 ? void 0 : bond.maxPayout) !== null && _c !== void 0 ? _c : 0).div(new BigNumber(10).pow((_d = bond === null || bond === void 0 ? void 0 : bond.payoutTokenDecimals) !== null && _d !== void 0 ? _d : 18));
|
|
49
|
+
return !available ? 0 : (singlePurchaseLimit.lt(safeAvailable) ? singlePurchaseLimit : safeAvailable);
|
|
50
|
+
};
|
|
39
51
|
return (_jsx(ThemeUIProvider, __assign({ theme: defaultTheme }, { children: bondData.map(function (bond) {
|
|
40
|
-
var _a, _b, _c, _d, _e
|
|
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"
|
|
52
|
+
var _a, _b, _c, _d, _e;
|
|
53
|
+
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 ".concat(getDiscountColor(bond === null || bond === void 0 ? void 0 : bond.discount)) }, { 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((_a = bond === null || bond === void 0 ? void 0 : bond.discount) === null || _a === void 0 ? void 0 : _a.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(((((_b = bond === null || bond === void 0 ? void 0 : bond.discount) !== null && _b !== void 0 ? _b : 0) * 365) / vestingTime((_c = bond === null || bond === void 0 ? void 0 : bond.vestingTerm) !== null && _c !== void 0 ? _c : 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((_d = bond === null || bond === void 0 ? void 0 : bond.vestingTerm) !== null && _d !== void 0 ? _d : 0).days ? "".concat(vestingTime((_e = bond === null || bond === void 0 ? void 0 : bond.vestingTerm) !== null && _e !== void 0 ? _e : 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" }) }))] })), calcMaxBuy(bond).toFixed(2)] }))] })), _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
54
|
}) })));
|
|
43
55
|
};
|
|
44
56
|
export default BondModal;
|
|
@@ -15,7 +15,6 @@ import { useEffect, useState } from 'react';
|
|
|
15
15
|
import { Flex, ThemeUIProvider } from "theme-ui";
|
|
16
16
|
import axios from "axios";
|
|
17
17
|
import { useWeb3React } from "@web3-react/core";
|
|
18
|
-
import { getColumnDiscountStyle } from '../Bonds/styles';
|
|
19
18
|
import { defaultTheme } from '../../theme';
|
|
20
19
|
import '../../scss/bondsingle.scss';
|
|
21
20
|
import { useParams } from 'react-router-dom';
|
|
@@ -38,9 +37,12 @@ var BondSingle = function (_a) {
|
|
|
38
37
|
setBondData(bond);
|
|
39
38
|
});
|
|
40
39
|
}, []);
|
|
40
|
+
var getDiscountColor = function (discount) {
|
|
41
|
+
return discount < 0 ? 'discount-negative' : 'discount-positive';
|
|
42
|
+
};
|
|
41
43
|
return (_jsxs(ThemeUIProvider, __assign({ theme: defaultTheme }, { children: [_jsxs("div", { children: ["Bond Single Page", _jsx("p", { children: billAddress })] }), isActive && account && (_jsx("p", { children: account })), _jsxs(Flex, __assign({ className: "container table-container" }, { children: [_jsxs(Flex, __assign({ className: "container header-container" }, { children: [_jsx(Flex, __assign({ className: "column column-header" }, { children: "Token" })), _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" }))] })), bondData.map(function (bond) {
|
|
42
|
-
var _a, _b
|
|
43
|
-
return (_jsxs(Flex, __assign({ className: "container bondrow-container" }, { children: [_jsx(Flex, __assign({ className: "column column-token" }, { children: _jsxs(Button, { children: ["Buy ", bond.showcaseTokenName] }) })), _jsx(Flex, __assign({ className: "column column-discount"
|
|
44
|
+
var _a, _b;
|
|
45
|
+
return (_jsxs(Flex, __assign({ className: "container bondrow-container" }, { children: [_jsx(Flex, __assign({ className: "column column-token" }, { children: _jsxs(Button, { children: ["Buy ", bond.showcaseTokenName] }) })), _jsx(Flex, __assign({ className: "column column-discount ".concat(getDiscountColor(bond === null || bond === void 0 ? void 0 : bond.discount)) }, { children: "".concat((_a = bond === null || bond === void 0 ? void 0 : bond.discount) === null || _a === void 0 ? void 0 : _a.toFixed(2), "%") })), _jsx(Flex, __assign({ className: "column column-arr" }, { children: "".concat("".concat(((((_b = bond === null || bond === void 0 ? void 0 : bond.discount) !== null && _b !== void 0 ? _b : 0) * 365) / vestingTime(bond.vestingTerm).days).toFixed(2), "%")) })), _jsx(Flex, __assign({ className: "column column-term" }, { children: vestingTime(bond.vestingTerm).days ? "".concat(vestingTime(bond.vestingTerm).days, " D") : '-' })), _jsx(Flex, __assign({ className: "column column-tokensremaining" }, { children: bond.tokensRemaining.split('.')[0] }))] })));
|
|
44
46
|
})] }))] })));
|
|
45
47
|
};
|
|
46
48
|
export default BondSingle;
|
|
@@ -53,7 +53,6 @@ import axios from 'axios';
|
|
|
53
53
|
import { ethers } from 'ethers';
|
|
54
54
|
import { useWeb3React } from '@web3-react/core';
|
|
55
55
|
import { useSearchParams, useNavigate } from 'react-router-dom';
|
|
56
|
-
import styles from './styles';
|
|
57
56
|
import getTimePeriods from '../../utils/getTimePeriods';
|
|
58
57
|
import { defaultTheme } from '../../theme';
|
|
59
58
|
import Svg from '../uikit/Svg';
|
|
@@ -142,12 +141,12 @@ var Bonds = function (_a) {
|
|
|
142
141
|
setIsModalOpen(true);
|
|
143
142
|
navigate("/?bondAddress=".concat(bond.billAddress, "&bondChain=").concat(bond.chainId), { replace: true });
|
|
144
143
|
};
|
|
145
|
-
var
|
|
144
|
+
var getDiscountColor = function (discount) {
|
|
146
145
|
return discount < 0 ? 'discount-negative' : 'discount-positive';
|
|
147
146
|
};
|
|
148
147
|
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) {
|
|
149
148
|
var _a, _b, _c;
|
|
150
|
-
return (_jsxs(Flex, __assign({ className: "container bondrow-container", onClick: function () { return rowClick(bond); } }, { children: [_jsx(Flex, __assign({ className: "column column-token"
|
|
149
|
+
return (_jsxs(Flex, __assign({ className: "container bondrow-container", onClick: function () { return rowClick(bond); } }, { children: [_jsx(Flex, __assign({ className: "column column-token" }, { children: bond.showcaseTokenName })), _jsx(Flex, __assign({ className: "column column-discount ".concat(getDiscountColor(bond === null || bond === void 0 ? void 0 : bond.discount)) }, { children: "".concat((_a = bond === null || bond === void 0 ? void 0 : bond.discount) === null || _a === void 0 ? void 0 : _a.toFixed(2), "%") })), _jsx(Flex, __assign({ className: "column column-arr" }, { children: "".concat(((((_b = bond === null || bond === void 0 ? void 0 : bond.discount) !== null && _b !== void 0 ? _b : 0) * 365) / vestingTime(bond.vestingTerm).days).toFixed(2), "%") })), _jsx(Flex, __assign({ className: "column column-term" }, { children: vestingTime(bond.vestingTerm).days ? "".concat(vestingTime(bond.vestingTerm).days, " D") : '-' })), _jsx(Flex, __assign({ className: "column column-tokensremaining" }, { 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()) && ((_c = bond.discount) !== null && _c !== void 0 ? _c : 0) > 0 && (_jsx(Svg, { icon: "fire", width: "20px" })) })) }))] }), bond.billAddress));
|
|
151
150
|
})] }))] })));
|
|
152
151
|
};
|
|
153
152
|
export default Bonds;
|
package/dist/scss/bondmodal.scss
CHANGED
package/dist/scss/bonds.scss
CHANGED
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
width: 100%;
|
|
4
4
|
display: flex;
|
|
5
5
|
flex-direction: column;
|
|
6
|
-
padding: 50px;
|
|
6
|
+
padding-top: 50px;
|
|
7
|
+
padding-left: 100px;
|
|
8
|
+
padding-right: 100px;
|
|
9
|
+
padding-bottom: 50px;
|
|
7
10
|
}
|
|
8
11
|
|
|
9
12
|
.container.header-container {
|
|
@@ -45,13 +48,6 @@
|
|
|
45
48
|
align-items: center;
|
|
46
49
|
}
|
|
47
50
|
|
|
48
|
-
.column.column-arr {
|
|
49
|
-
width: 50px;
|
|
50
|
-
flex-direction: column;
|
|
51
|
-
justify-content: center;
|
|
52
|
-
align-items: center;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
51
|
.discount-positive {
|
|
56
52
|
color: #38A611;
|
|
57
53
|
}
|
|
@@ -60,6 +56,13 @@
|
|
|
60
56
|
color: #DF4141;
|
|
61
57
|
}
|
|
62
58
|
|
|
59
|
+
.column.column-arr {
|
|
60
|
+
width: 50px;
|
|
61
|
+
flex-direction: column;
|
|
62
|
+
justify-content: center;
|
|
63
|
+
align-items: center;
|
|
64
|
+
}
|
|
65
|
+
|
|
63
66
|
.column.column-term {
|
|
64
67
|
width: 50px;
|
|
65
68
|
flex-direction: column;
|
package/package.json
CHANGED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { ThemeUIStyleObject } from 'theme-ui';
|
|
2
|
-
export declare function getColumnDiscountStyle(discount: number): ThemeUIStyleObject;
|
|
3
|
-
export declare const styles: Record<'tableContainer' | 'headerContainer' | 'bondrowContainer' | 'columnToken' | 'columnDiscount' | 'columnArr' | 'columnTerm' | 'columnTokensRemaining' | 'hotBond', ThemeUIStyleObject>;
|
|
4
|
-
export default styles;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
var getDiscountColorStyle = function (discount) {
|
|
2
|
-
return discount < 0 ? '#DF4141' : '#38A611';
|
|
3
|
-
};
|
|
4
|
-
export function getColumnDiscountStyle(discount) {
|
|
5
|
-
return {
|
|
6
|
-
width: '50px',
|
|
7
|
-
flexDirection: 'column',
|
|
8
|
-
justifyContent: 'center',
|
|
9
|
-
alignItems: 'center',
|
|
10
|
-
color: getDiscountColorStyle(discount)
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
export var styles = {
|
|
14
|
-
tableContainer: {
|
|
15
|
-
width: '80vw',
|
|
16
|
-
flexDirection: 'column',
|
|
17
|
-
p: '20px',
|
|
18
|
-
marginLeft: 'auto',
|
|
19
|
-
marginRight: 'auto'
|
|
20
|
-
},
|
|
21
|
-
headerContainer: {
|
|
22
|
-
display: 'flex',
|
|
23
|
-
justifyContent: ['flex-end', 'flex-end', 'flex-end', 'space-around'],
|
|
24
|
-
padding: '5px',
|
|
25
|
-
fontWeight: 'bold'
|
|
26
|
-
},
|
|
27
|
-
bondrowContainer: {
|
|
28
|
-
display: 'flex',
|
|
29
|
-
flexDirection: 'row',
|
|
30
|
-
width: '100%',
|
|
31
|
-
justifyContent: ['flex-end', 'flex-end', 'flex-end', 'space-around'],
|
|
32
|
-
backgroundColor: '#151320',
|
|
33
|
-
marginBottom: '10px',
|
|
34
|
-
padding: '20px',
|
|
35
|
-
borderRadius: '10px',
|
|
36
|
-
border: '1px solid #4B4B53',
|
|
37
|
-
},
|
|
38
|
-
columnToken: {
|
|
39
|
-
width: '100px',
|
|
40
|
-
flexDirection: 'column',
|
|
41
|
-
justifyContent: 'center',
|
|
42
|
-
alignItems: 'center',
|
|
43
|
-
},
|
|
44
|
-
columnDiscount: {
|
|
45
|
-
width: '50px',
|
|
46
|
-
flexDirection: 'column',
|
|
47
|
-
justifyContent: 'center',
|
|
48
|
-
alignItems: 'center',
|
|
49
|
-
},
|
|
50
|
-
columnArr: {
|
|
51
|
-
width: '50px',
|
|
52
|
-
flexDirection: 'column',
|
|
53
|
-
justifyContent: 'center',
|
|
54
|
-
alignItems: 'center',
|
|
55
|
-
},
|
|
56
|
-
columnTerm: {
|
|
57
|
-
width: '50px',
|
|
58
|
-
flexDirection: 'column',
|
|
59
|
-
justifyContent: 'center',
|
|
60
|
-
alignItems: 'center',
|
|
61
|
-
},
|
|
62
|
-
columnTokensRemaining: {
|
|
63
|
-
width: '50px',
|
|
64
|
-
flexDirection: 'column',
|
|
65
|
-
justifyContent: 'center',
|
|
66
|
-
alignItems: 'center',
|
|
67
|
-
},
|
|
68
|
-
hotBond: {
|
|
69
|
-
width: '50px',
|
|
70
|
-
flexDirection: 'column',
|
|
71
|
-
justifyContent: 'center',
|
|
72
|
-
alignItems: 'center',
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
export default styles;
|