@ape.swap/bonds-sdk 1.0.304 → 1.0.306

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.
@@ -9,6 +9,42 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
12
48
  import { jsxs as _jsxs, jsx as _jsx } from "theme-ui/jsx-runtime";
13
49
  /** @jsxImportSource theme-ui */
14
50
  import React, { useEffect, useState } from 'react';
@@ -25,6 +61,9 @@ import { isNumber } from '../../utils/numbers';
25
61
  import { TooltipBubble, Button, Svg, ListTag } from '../uikit-sdk';
26
62
  import { TooltipText } from '../../enum/tooltips';
27
63
  import { formatNumberSI } from '../../utils/formatNumber';
64
+ import { ethers } from 'ethers';
65
+ import { adjustDecimals } from "../../utils/convertToTokenValue";
66
+ import { BondAbi } from '../../enum/abis';
28
67
  import TokenImage from '../uikit-sdk/TokenImage';
29
68
  var BondModal = function (_a) {
30
69
  var isOpen = _a.isOpen, onClose = _a.onClose, bondAddress = _a.bondAddress;
@@ -123,6 +162,42 @@ var BondModal = function (_a) {
123
162
  var getPremium = premium(bond);
124
163
  return parseFloat(getPremium) < 0 ? 'premium-negative' : 'premium-positive';
125
164
  };
165
+ var handleBuy = function () { return __awaiter(void 0, void 0, void 0, function () {
166
+ var provider, signer, bondContract, maxPrice, amount, tx, error_1;
167
+ return __generator(this, function (_a) {
168
+ switch (_a.label) {
169
+ case 0:
170
+ console.log('handle buy clicked');
171
+ if (!window.ethereum) {
172
+ console.error('No Ethereum provider found');
173
+ alert('No Ethereum provider found');
174
+ return [2 /*return*/];
175
+ }
176
+ provider = new ethers.providers.Web3Provider(window.ethereum);
177
+ signer = provider.getSigner();
178
+ bondContract = new ethers.Contract(bondAddress !== null && bondAddress !== void 0 ? bondAddress : "", BondAbi, signer);
179
+ _a.label = 1;
180
+ case 1:
181
+ _a.trys.push([1, 4, , 5]);
182
+ maxPrice = new BigNumber(bondData[0].trueBillPrice).times(102).div(100);
183
+ amount = adjustDecimals(inputValue);
184
+ return [4 /*yield*/, bondContract.deposit(amount, maxPrice, account)];
185
+ case 2:
186
+ tx = _a.sent();
187
+ return [4 /*yield*/, tx.wait()];
188
+ case 3:
189
+ _a.sent();
190
+ alert('Buy Successful');
191
+ return [3 /*break*/, 5];
192
+ case 4:
193
+ error_1 = _a.sent();
194
+ console.error('Approval error', error_1);
195
+ alert('Approval Failed');
196
+ return [3 /*break*/, 5];
197
+ case 5: return [2 /*return*/];
198
+ }
199
+ });
200
+ }); };
126
201
  return (_jsx(ThemeUIProvider, __assign({ theme: defaultTheme }, { children: bondData.map(function (bond) {
127
202
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
128
203
  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] })), _jsx(Flex, __assign({ className: "modal modal-header" }, { children: _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 bondicon" }, { children: _jsx(TokenImage, { symbol: (_a = bond.showcaseTokenName) !== null && _a !== void 0 ? _a : bond.payoutTokenName, size: 50 }) })), _jsx(Flex, __assign({ className: "title-container bondname" }, { children: bond === null || bond === void 0 ? void 0 : bond.showcaseTokenName })), _jsxs(Flex, __assign({ className: "title-container price-container" }, { children: [_jsxs(Flex, __assign({ className: "price-container price" }, { children: ["$", earnTokenPrice(bond)] })), _jsxs(Flex, __assign({ className: "price-container discounted" }, { children: ["$", discountEarnTokenPrice(bond)] }))] })), _jsx(Flex, __assign({ className: "title-container tokentags" }, { children: _jsx(ListTag, { text: (_b = bond === null || bond === void 0 ? void 0 : bond.tags) === null || _b === void 0 ? void 0 : _b[0], variant: ((_c = bond === null || bond === void 0 ? void 0 : bond.tags) === null || _c === void 0 ? void 0 : _c[0]) === 'Cex Fund' ? 'cex_fund' : 'liquidity' }) }))] })), _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(TooltipBubble, __assign({ body: _jsx(Flex, { children: TooltipText.Discount }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)" }, { children: _jsx(Flex, __assign({ className: "block-header icon" }, { children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) })) }))] })), "".concat((_d = bond === null || bond === void 0 ? void 0 : bond.discount) === null || _d === void 0 ? void 0 : _d.toFixed(2), "%")] })), _jsxs(Flex, __assign({ className: "modal-block column-arr" }, { children: [_jsxs(Flex, __assign({ className: "block-header header" }, { children: ["ARR", _jsx(TooltipBubble, __assign({ body: _jsx(Flex, { children: TooltipText.ARR }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)" }, { children: _jsx(Flex, __assign({ className: "block-header icon" }, { children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) })) }))] })), "".concat(((((_e = bond === null || bond === void 0 ? void 0 : bond.discount) !== null && _e !== void 0 ? _e : 0) * 365) / vestingTime((_f = bond === null || bond === void 0 ? void 0 : bond.vestingTerm) !== null && _f !== void 0 ? _f : 0).days).toFixed(2), "%")] })), _jsxs(Flex, __assign({ className: "modal-block column-term" }, { children: [_jsxs(Flex, __assign({ className: "block-header header" }, { children: ["Terms", _jsx(TooltipBubble, __assign({ body: _jsx(Flex, { children: TooltipText.Terms }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)" }, { children: _jsx(Flex, __assign({ className: "block-header icon" }, { children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) })) }))] })), vestingTime((_g = bond === null || bond === void 0 ? void 0 : bond.vestingTerm) !== null && _g !== void 0 ? _g : 0).days ? "".concat(vestingTime((_h = bond === null || bond === void 0 ? void 0 : bond.vestingTerm) !== null && _h !== void 0 ? _h : 0).days, " D") : '-'] })), _jsxs(Flex, __assign({ className: "modal-block column-maxbuy" }, { children: [_jsxs(Flex, __assign({ className: "block-header header" }, { children: ["Max Buy", _jsx(TooltipBubble, __assign({ body: _jsx(Flex, { children: TooltipText.MaxBuy(bond.payoutTokenName) }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)" }, { children: _jsx(Flex, __assign({ className: "block-header icon" }, { children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) })) }))] })), (_j = parseFloat(maxBuy(bond).toFixed(0))) === null || _j === void 0 ? void 0 : _j.toLocaleString('en-US')] }))] })), _jsxs(Flex, __assign({ className: "modal-container text-container" }, { children: [_jsxs(Flex, __assign({ className: "text-container row" }, { children: [_jsx(Flex, __assign({ className: "row-container spend" }, { children: "You spend:" })), _jsxs(Flex, __assign({ className: "row-container spend-val" }, { children: [youSpend, " ", bond.principalTokenName, " = $ ", formatUSDNumber(youSpendUSD(bond))] }))] })), _jsxs(Flex, __assign({ className: "text-container row" }, { children: [_jsxs(Flex, __assign({ className: "row-container premium" }, { children: ["Premium:", _jsx(TooltipBubble, __assign({ body: _jsx(Flex, { children: TooltipText.Premium }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)" }, { children: _jsx(Flex, __assign({ className: "row-container premium-icon" }, { children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) })) }))] })), _jsxs(Flex, __assign({ className: "row-container premium-val ".concat(getPremiumColor(bond)) }, { children: ["$ ", premium(bond)] }))] })), _jsxs(Flex, __assign({ className: "text-container row" }, { children: [_jsxs(Flex, __assign({ className: "row-container get" }, { children: ["You get (over ", vestingTime((_k = bond === null || bond === void 0 ? void 0 : bond.vestingTerm) !== null && _k !== void 0 ? _k : 0).days, " days):"] })), _jsxs(Flex, __assign({ className: "row-container get-val" }, { children: [youGet(bond), " ", bond === null || bond === void 0 ? void 0 : bond.showcaseTokenName, " = $ ", formatUSDNumber(youGetUSD(bond))] }))] }))] })), _jsxs(Flex, __assign({ className: "modal-container input-container" }, { children: [_jsx(Flex, __assign({ className: "input-container input" }, { children: _jsx(Input, { placeholder: "0.0", value: inputValue, pattern: "^[0-9]*[.,]?[0-9]*$", onChange: handleInputChange, onInput: function (v) {
@@ -139,7 +214,7 @@ var BondModal = function (_a) {
139
214
  !!v.currentTarget.value && isNumber(v.currentTarget.value) && parseFloat(v.currentTarget.value) >= 0
140
215
  ? v.currentTarget.value
141
216
  : v.currentTarget.value.slice(0, v.currentTarget.value.length - 1);
142
- } }) })), _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));
217
+ } }) })), _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, __assign({ onClick: handleBuy }, { children: ["Buy ", bond === null || bond === void 0 ? void 0 : bond.showcaseTokenName] })) }))] }))] }))] })) })) }, bond.billAddress));
143
218
  }) })));
144
219
  };
145
220
  export default BondModal;
@@ -67,7 +67,8 @@ import billAbi from '../../config/abi/bond.json';
67
67
  import { getBalanceNumber } from '../../utils/getBalanceNumber';
68
68
  import { getFirstNonZeroDigits } from '../../utils/roundNumber';
69
69
  import { formatNumberSI } from '../../utils/formatNumber';
70
- import useCurrentTime from '../../utils/useTimer';
70
+ import useCurrentTime from '../../hooks/useTimer';
71
+ import { getPendingVesting } from '../../hooks/usePendingVesting';
71
72
  var YourBonds = function (_a) {
72
73
  var connectionString = _a.connectionString;
73
74
  var _b = useWeb3React(), account = _b.account, isActive = _b.isActive;
@@ -339,7 +340,7 @@ var YourBonds = function (_a) {
339
340
  } }, { children: "Claim All" })) }))] }))] })), userOwnedBillsData.flat().map(function (data) {
340
341
  return data.userOwnedBills.map(function (bill) {
341
342
  var _a, _b;
342
- return (_jsxs(Flex, __assign({ className: "container bondrow-container", onClick: function () { return rowClick(bill.bond); } }, { children: [_jsx(Flex, __assign({ className: "column column-tokens" }, { children: _jsx(Flex, __assign({ className: "column column-tokeninfoname" }, { children: _jsx(TokenInfoAndName, { bill: bill.bond }) })) })), _jsxs(Flex, __assign({ className: "column column-bondinfo" }, { children: [_jsxs(Flex, __assign({ className: "column column-claimable" }, { children: [formatNumberSI(parseFloat(claimable(bill).toFixed(3)), 0), "($".concat((claimable(bill) * ((_a = parseFloat(earnTokenPrice(bill.bond))) !== null && _a !== void 0 ? _a : 0)).toFixed(2), ")")] })), _jsxs(Flex, __assign({ className: "column column-pending" }, { children: [formatNumberSI(parseFloat(totalPending(bill).toFixed(0)), 0), "($".concat((totalPending(bill) * ((_b = parseFloat(earnTokenPrice(bill.bond))) !== null && _b !== void 0 ? _b : 0)).toFixed(2), ")")] })), _jsx(Flex, __assign({ className: "column column-term" }, { children: "".concat(vestingTimeRemaining(bill).days, "d, ").concat(vestingTimeRemaining(bill).hours, "h, ").concat(vestingTimeRemaining(bill).minutes, "m") })), _jsx(Flex, __assign({ className: "column column-claimall" }, { children: _jsx(Flex, __assign({ className: "column-claimall button" }, { children: _jsx(Button, __assign({ disabled: !account, sx: {
343
+ return (_jsxs(Flex, __assign({ className: "container bondrow-container", onClick: function () { return rowClick(bill.bond); } }, { children: [_jsx(Flex, __assign({ className: "column column-tokens" }, { children: _jsx(Flex, __assign({ className: "column column-tokeninfoname" }, { children: _jsx(TokenInfoAndName, { bill: bill.bond, vestEnds: "Ends in ".concat(getPendingVesting(bill.lastBlockTimestamp, bill.vesting)) }) })) })), _jsxs(Flex, __assign({ className: "column column-bondinfo" }, { children: [_jsxs(Flex, __assign({ className: "column column-claimable" }, { children: [formatNumberSI(parseFloat(claimable(bill).toFixed(3)), 0), "($".concat((claimable(bill) * ((_a = parseFloat(earnTokenPrice(bill.bond))) !== null && _a !== void 0 ? _a : 0)).toFixed(2), ")")] })), _jsxs(Flex, __assign({ className: "column column-pending" }, { children: [formatNumberSI(parseFloat(totalPending(bill).toFixed(0)), 0), "($".concat((totalPending(bill) * ((_b = parseFloat(earnTokenPrice(bill.bond))) !== null && _b !== void 0 ? _b : 0)).toFixed(2), ")")] })), _jsx(Flex, __assign({ className: "column column-term" }, { children: "".concat(vestingTimeRemaining(bill).days, "d, ").concat(vestingTimeRemaining(bill).hours, "h, ").concat(vestingTimeRemaining(bill).minutes, "m") })), _jsx(Flex, __assign({ className: "column column-claimall" }, { children: _jsx(Flex, __assign({ className: "column-claimall button" }, { children: _jsx(Button, __assign({ disabled: !account, sx: {
343
344
  height: ['36px', '36px', '36px', '26px'],
344
345
  lineHeight: '12px',
345
346
  fontSize: '14px',
@@ -0,0 +1,80 @@
1
+ export declare const BondAbi: ({
2
+ anonymous: boolean;
3
+ inputs: ({
4
+ components: {
5
+ internalType: string;
6
+ name: string;
7
+ type: string;
8
+ }[];
9
+ indexed: boolean;
10
+ internalType: string;
11
+ name: string;
12
+ type: string;
13
+ } | {
14
+ indexed: boolean;
15
+ internalType: string;
16
+ name: string;
17
+ type: string;
18
+ components?: undefined;
19
+ })[];
20
+ name: string;
21
+ type: string;
22
+ outputs?: undefined;
23
+ stateMutability?: undefined;
24
+ } | {
25
+ inputs: {
26
+ internalType: string;
27
+ name: string;
28
+ type: string;
29
+ }[];
30
+ name: string;
31
+ outputs: {
32
+ internalType: string;
33
+ name: string;
34
+ type: string;
35
+ }[];
36
+ stateMutability: string;
37
+ type: string;
38
+ anonymous?: undefined;
39
+ } | {
40
+ inputs: {
41
+ internalType: string;
42
+ name: string;
43
+ type: string;
44
+ }[];
45
+ name: string;
46
+ outputs: {
47
+ components: {
48
+ internalType: string;
49
+ name: string;
50
+ type: string;
51
+ }[];
52
+ internalType: string;
53
+ name: string;
54
+ type: string;
55
+ }[];
56
+ stateMutability: string;
57
+ type: string;
58
+ anonymous?: undefined;
59
+ } | {
60
+ inputs: ({
61
+ internalType: string;
62
+ name: string;
63
+ type: string;
64
+ components?: undefined;
65
+ } | {
66
+ components: {
67
+ internalType: string;
68
+ name: string;
69
+ type: string;
70
+ }[];
71
+ internalType: string;
72
+ name: string;
73
+ type: string;
74
+ })[];
75
+ name: string;
76
+ outputs: never[];
77
+ stateMutability: string;
78
+ type: string;
79
+ anonymous?: undefined;
80
+ })[];
@@ -0,0 +1 @@
1
+ export var BondAbi = [{ "anonymous": false, "inputs": [{ "indexed": true, "internalType": "uint256", "name": "billId", "type": "uint256" }, { "indexed": true, "internalType": "address", "name": "recipient", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "payout", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "remaining", "type": "uint256" }], "name": "BillClaimed", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "uint256", "name": "deposit", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "payout", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "expires", "type": "uint256" }, { "indexed": true, "internalType": "uint256", "name": "billId", "type": "uint256" }], "name": "BillCreated", "type": "event" }, { "anonymous": false, "inputs": [{ "components": [{ "internalType": "uint256", "name": "controlVariable", "type": "uint256" }, { "internalType": "uint256", "name": "vestingTerm", "type": "uint256" }, { "internalType": "uint256", "name": "minimumPrice", "type": "uint256" }, { "internalType": "uint256", "name": "maxPayout", "type": "uint256" }, { "internalType": "uint256", "name": "maxDebt", "type": "uint256" }, { "internalType": "uint256", "name": "maxTotalPayout", "type": "uint256" }, { "internalType": "uint256", "name": "initialDebt", "type": "uint256" }], "indexed": false, "internalType": "struct ICustomBill.BillTerms", "name": "billTerms", "type": "tuple" }, { "indexed": false, "internalType": "uint256", "name": "lastDecay", "type": "uint256" }], "name": "BillInitialized", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "uint256", "name": "internalPrice", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "debtRatio", "type": "uint256" }], "name": "BillPriceChanged", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "address", "name": "payoutToken", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "amountAdded", "type": "uint256" }], "name": "BillRefilled", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "uint256", "name": "initialBCV", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "newBCV", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "adjustment", "type": "uint256" }], "name": "ControlVariableAdjustment", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "newFeeTo", "type": "address" }], "name": "FeeToChanged", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "uint8", "name": "version", "type": "uint8" }], "name": "Initialized", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "uint256", "name": "newMaxTotalPayout", "type": "uint256" }], "name": "MaxTotalPayoutChanged", "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": true, "internalType": "bytes32", "name": "role", "type": "bytes32" }, { "indexed": true, "internalType": "bytes32", "name": "previousAdminRole", "type": "bytes32" }, { "indexed": true, "internalType": "bytes32", "name": "newAdminRole", "type": "bytes32" }], "name": "RoleAdminChanged", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "bytes32", "name": "role", "type": "bytes32" }, { "indexed": true, "internalType": "address", "name": "account", "type": "address" }, { "indexed": true, "internalType": "address", "name": "sender", "type": "address" }], "name": "RoleGranted", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "bytes32", "name": "role", "type": "bytes32" }, { "indexed": true, "internalType": "address", "name": "account", "type": "address" }, { "indexed": true, "internalType": "address", "name": "sender", "type": "address" }], "name": "RoleRevoked", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "uint256", "name": "currentBCV", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "increment", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "targetBCV", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "buffer", "type": "uint256" }], "name": "SetAdjustment", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "uint256[]", "name": "fees", "type": "uint256[]" }, { "indexed": false, "internalType": "uint256[]", "name": "tierCeilings", "type": "uint256[]" }], "name": "SetFees", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "pendingOwner", "type": "address" }], "name": "SetPendingOwner", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "enum CustomBill.PARAMETER", "name": "parameter", "type": "uint8" }, { "indexed": false, "internalType": "uint256", "name": "input", "type": "uint256" }], "name": "TermsSet", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "owner", "type": "address" }, { "indexed": true, "internalType": "address", "name": "approvedAccount", "type": "address" }, { "indexed": false, "internalType": "bool", "name": "approved", "type": "bool" }], "name": "UpdateClaimApproval", "type": "event" }, { "inputs": [], "name": "DAO", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "DEFAULT_ADMIN_ROLE", "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "MAX_FEE", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "REFILL_ROLE", "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "acceptOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "adjustment", "outputs": [{ "internalType": "uint256", "name": "rate", "type": "uint256" }, { "internalType": "uint256", "name": "target", "type": "uint256" }, { "internalType": "uint256", "name": "buffer", "type": "uint256" }, { "internalType": "uint256", "name": "lastAdjustmentTimestamp", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "allIssuedBillIds", "outputs": [{ "internalType": "uint256[]", "name": "", "type": "uint256[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256[]", "name": "_billIds", "type": "uint256[]" }], "name": "batchClaim", "outputs": [{ "internalType": "uint256", "name": "payout", "type": "uint256" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "uint256[]", "name": "_billIds", "type": "uint256[]" }], "name": "batchRedeem", "outputs": [{ "internalType": "uint256", "name": "payout", "type": "uint256" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "name": "billInfo", "outputs": [{ "internalType": "uint256", "name": "payout", "type": "uint256" }, { "internalType": "uint256", "name": "payoutClaimed", "type": "uint256" }, { "internalType": "uint256", "name": "vesting", "type": "uint256" }, { "internalType": "uint256", "name": "vestingTerm", "type": "uint256" }, { "internalType": "uint256", "name": "vestingStartTimestamp", "type": "uint256" }, { "internalType": "uint256", "name": "lastClaimTimestamp", "type": "uint256" }, { "internalType": "uint256", "name": "truePricePaid", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "billNft", "outputs": [{ "internalType": "contract IBillNft", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "billPrice", "outputs": [{ "internalType": "uint256", "name": "price_", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_feeTo", "type": "address" }], "name": "changeFeeTo", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_billId", "type": "uint256" }], "name": "claim", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_billId", "type": "uint256" }], "name": "claimablePayout", "outputs": [{ "internalType": "uint256", "name": "claimablePayout_", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "currentDebt", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "currentFee", "outputs": [{ "internalType": "uint256", "name": "currentFee_", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "customTreasury", "outputs": [{ "internalType": "contract ICustomTreasury", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "debtDecay", "outputs": [{ "internalType": "uint256", "name": "decay_", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "debtRatio", "outputs": [{ "internalType": "uint256", "name": "debtRatio_", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_amount", "type": "uint256" }, { "internalType": "uint256", "name": "_maxPrice", "type": "uint256" }, { "internalType": "address", "name": "_depositor", "type": "address" }], "name": "deposit", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "feeInPayout", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "name": "feeTiers", "outputs": [{ "internalType": "uint256", "name": "tierCeilings", "type": "uint256" }, { "internalType": "uint256", "name": "fees", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "feeTo", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "user", "type": "address" }], "name": "getBillIds", "outputs": [{ "internalType": "uint256[]", "name": "", "type": "uint256[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "user", "type": "address" }, { "internalType": "uint256", "name": "start", "type": "uint256" }, { "internalType": "uint256", "name": "end", "type": "uint256" }], "name": "getBillIdsInRange", "outputs": [{ "internalType": "uint256[]", "name": "", "type": "uint256[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "billId", "type": "uint256" }], "name": "getBillInfo", "outputs": [{ "components": [{ "internalType": "uint256", "name": "payout", "type": "uint256" }, { "internalType": "uint256", "name": "payoutClaimed", "type": "uint256" }, { "internalType": "uint256", "name": "vesting", "type": "uint256" }, { "internalType": "uint256", "name": "vestingTerm", "type": "uint256" }, { "internalType": "uint256", "name": "vestingStartTimestamp", "type": "uint256" }, { "internalType": "uint256", "name": "lastClaimTimestamp", "type": "uint256" }, { "internalType": "uint256", "name": "truePricePaid", "type": "uint256" }], "internalType": "struct ICustomBill.Bill", "name": "", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "getFeeTierLength", "outputs": [{ "internalType": "uint256", "name": "tierLength_", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "getMaxTotalPayout", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "role", "type": "bytes32" }], "name": "getRoleAdmin", "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "role", "type": "bytes32" }, { "internalType": "uint256", "name": "index", "type": "uint256" }], "name": "getRoleMember", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "role", "type": "bytes32" }], "name": "getRoleMemberCount", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address[]", "name": "_billRefillers", "type": "address[]" }], "name": "grantRefillRole", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "role", "type": "bytes32" }, { "internalType": "address", "name": "account", "type": "address" }], "name": "grantRole", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "role", "type": "bytes32" }, { "internalType": "address", "name": "account", "type": "address" }], "name": "hasRole", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "contract ICustomTreasury", "name": "_customTreasury", "type": "address" }, { "components": [{ "internalType": "address", "name": "payoutToken", "type": "address" }, { "internalType": "address", "name": "principalToken", "type": "address" }, { "internalType": "address", "name": "initialOwner", "type": "address" }, { "internalType": "contract IVestingCurve", "name": "vestingCurve", "type": "address" }, { "internalType": "uint256[]", "name": "tierCeilings", "type": "uint256[]" }, { "internalType": "uint256[]", "name": "fees", "type": "uint256[]" }, { "internalType": "bool", "name": "feeInPayout", "type": "bool" }], "internalType": "struct ICustomBill.BillCreationDetails", "name": "_billCreationDetails", "type": "tuple" }, { "components": [{ "internalType": "uint256", "name": "controlVariable", "type": "uint256" }, { "internalType": "uint256", "name": "vestingTerm", "type": "uint256" }, { "internalType": "uint256", "name": "minimumPrice", "type": "uint256" }, { "internalType": "uint256", "name": "maxPayout", "type": "uint256" }, { "internalType": "uint256", "name": "maxDebt", "type": "uint256" }, { "internalType": "uint256", "name": "maxTotalPayout", "type": "uint256" }, { "internalType": "uint256", "name": "initialDebt", "type": "uint256" }], "internalType": "struct ICustomBill.BillTerms", "name": "_billTerms", "type": "tuple" }, { "components": [{ "internalType": "address", "name": "feeTo", "type": "address" }, { "internalType": "address", "name": "DAO", "type": "address" }, { "internalType": "address", "name": "billNft", "type": "address" }], "internalType": "struct ICustomBill.BillAccounts", "name": "_billAccounts", "type": "tuple" }, { "internalType": "address[]", "name": "_billRefillers", "type": "address[]" }], "name": "initialize", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "contract ICustomTreasury", "name": "_customTreasury", "type": "address" }, { "components": [{ "internalType": "address", "name": "payoutToken", "type": "address" }, { "internalType": "address", "name": "principalToken", "type": "address" }, { "internalType": "address", "name": "initialOwner", "type": "address" }, { "internalType": "contract IVestingCurve", "name": "vestingCurve", "type": "address" }, { "internalType": "uint256[]", "name": "tierCeilings", "type": "uint256[]" }, { "internalType": "uint256[]", "name": "fees", "type": "uint256[]" }, { "internalType": "bool", "name": "feeInPayout", "type": "bool" }], "internalType": "struct ICustomBill.BillCreationDetails", "name": "_billCreationDetails", "type": "tuple" }, { "components": [{ "internalType": "uint256", "name": "controlVariable", "type": "uint256" }, { "internalType": "uint256", "name": "vestingTerm", "type": "uint256" }, { "internalType": "uint256", "name": "minimumPrice", "type": "uint256" }, { "internalType": "uint256", "name": "maxPayout", "type": "uint256" }, { "internalType": "uint256", "name": "maxDebt", "type": "uint256" }, { "internalType": "uint256", "name": "maxTotalPayout", "type": "uint256" }, { "internalType": "uint256", "name": "initialDebt", "type": "uint256" }], "internalType": "struct ICustomBill.BillTerms", "name": "_billTerms", "type": "tuple" }, { "components": [{ "internalType": "address", "name": "feeTo", "type": "address" }, { "internalType": "address", "name": "DAO", "type": "address" }, { "internalType": "address", "name": "billNft", "type": "address" }], "internalType": "struct ICustomBill.BillAccounts", "name": "_billAccounts", "type": "tuple" }], "name": "initialize", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "lastDecay", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "maxPayout", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "owner", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_amount", "type": "uint256" }], "name": "payoutFor", "outputs": [{ "internalType": "uint256", "name": "_payout", "type": "uint256" }, { "internalType": "uint256", "name": "_fee", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "payoutToken", "outputs": [{ "internalType": "contract IERC20MetadataUpgradeable", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "pendingOwner", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_billId", "type": "uint256" }], "name": "pendingPayout", "outputs": [{ "internalType": "uint256", "name": "pendingPayout_", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_billId", "type": "uint256" }], "name": "pendingVesting", "outputs": [{ "internalType": "uint256", "name": "pendingVesting_", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "principalToken", "outputs": [{ "internalType": "contract IERC20MetadataUpgradeable", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_billId", "type": "uint256" }], "name": "redeem", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "", "type": "address" }, { "internalType": "address", "name": "", "type": "address" }], "name": "redeemerApproved", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_refillAmount", "type": "uint256" }], "name": "refillPayoutToken", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "renounceOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "role", "type": "bytes32" }, { "internalType": "address", "name": "account", "type": "address" }], "name": "renounceRole", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address[]", "name": "_billRefillers", "type": "address[]" }], "name": "revokeRefillRole", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "role", "type": "bytes32" }, { "internalType": "address", "name": "account", "type": "address" }], "name": "revokeRole", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_rate", "type": "uint256" }, { "internalType": "uint256", "name": "_target", "type": "uint256" }, { "internalType": "uint256", "name": "_buffer", "type": "uint256" }], "name": "setAdjustment", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "enum CustomBill.PARAMETER", "name": "_parameter", "type": "uint8" }, { "internalType": "uint256", "name": "_input", "type": "uint256" }], "name": "setBillTerms", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "approvedAccount", "type": "address" }, { "internalType": "bool", "name": "approved", "type": "bool" }], "name": "setClaimApproval", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "uint256[]", "name": "fees", "type": "uint256[]" }, { "internalType": "uint256[]", "name": "tierCeilings", "type": "uint256[]" }], "name": "setFeeTiers", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_maxTotalPayout", "type": "uint256" }], "name": "setMaxTotalPayout", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "newPendingOwner", "type": "address" }], "name": "setPendingOwner", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "bytes4", "name": "interfaceId", "type": "bytes4" }], "name": "supportsInterface", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "terms", "outputs": [{ "internalType": "uint256", "name": "controlVariable", "type": "uint256" }, { "internalType": "uint256", "name": "vestingTerm", "type": "uint256" }, { "internalType": "uint256", "name": "minimumPrice", "type": "uint256" }, { "internalType": "uint256", "name": "maxPayout", "type": "uint256" }, { "internalType": "uint256", "name": "maxDebt", "type": "uint256" }, { "internalType": "uint256", "name": "maxTotalPayout", "type": "uint256" }, { "internalType": "uint256", "name": "initialDebt", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "totalDebt", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "totalPayoutGiven", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "totalPrincipalBilled", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "", "type": "address" }], "name": "transferOwnership", "outputs": [], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "trueBillPrice", "outputs": [{ "internalType": "uint256", "name": "price_", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "userBillIds", "outputs": [{ "internalType": "uint256[]", "name": "", "type": "uint256[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_billId", "type": "uint256" }, { "internalType": "uint256", "name": "_timestamp", "type": "uint256" }], "name": "vestedPayoutAtTime", "outputs": [{ "internalType": "uint256", "name": "vestedPayout_", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "vestingCurve", "outputs": [{ "internalType": "contract IVestingCurve", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_billId", "type": "uint256" }], "name": "vestingPayout", "outputs": [{ "internalType": "uint256", "name": "vestingPayout_", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_billId", "type": "uint256" }], "name": "vestingPeriod", "outputs": [{ "internalType": "uint256", "name": "vestingStart_", "type": "uint256" }, { "internalType": "uint256", "name": "vestingEnd_", "type": "uint256" }], "stateMutability": "view", "type": "function" }];
@@ -0,0 +1,5 @@
1
+ export declare const usePendingVesting: ({ lastBlockTimestamp, vesting }: {
2
+ lastBlockTimestamp: string;
3
+ vesting: string;
4
+ }) => string;
5
+ export declare const getPendingVesting: (lastBlockTimestamp: string, vesting: string) => string;
@@ -0,0 +1,13 @@
1
+ import getTimePeriods from '../utils/getTimePeriods';
2
+ import useCurrentTime from './useTimer';
3
+ export var usePendingVesting = function (_a) {
4
+ var lastBlockTimestamp = _a.lastBlockTimestamp, vesting = _a.vesting;
5
+ var currentTime = useCurrentTime() / 1000;
6
+ var vestingTime = getTimePeriods(parseInt(lastBlockTimestamp) + parseInt(vesting) - currentTime, true);
7
+ return "".concat(vestingTime.days, "d, ").concat(vestingTime.hours, "h, ").concat(vestingTime.minutes, "m");
8
+ };
9
+ export var getPendingVesting = function (lastBlockTimestamp, vesting) {
10
+ var currentTime = new Date().getTime() / 1000;
11
+ var vestingTime = getTimePeriods(parseInt(lastBlockTimestamp) + parseInt(vesting) - currentTime, true);
12
+ return "".concat(vestingTime.days, "d, ").concat(vestingTime.hours, "h, ").concat(vestingTime.minutes, "m");
13
+ };
@@ -0,0 +1,4 @@
1
+ import { ethers } from 'ethers';
2
+ export declare function adjustDecimals(numStr: string): string;
3
+ declare const convertToTokenValue: (numberString: string, decimals: number) => ethers.BigNumber;
4
+ export default convertToTokenValue;
@@ -0,0 +1,24 @@
1
+ import { ethers } from 'ethers';
2
+ export function adjustDecimals(numStr) {
3
+ var parts = numStr.split('.');
4
+ if (parts.length < 2) {
5
+ // This means the number doesn't have any decimals
6
+ return numStr;
7
+ }
8
+ if (parts[1].length > 18) {
9
+ parts[1] = parts[1].slice(0, 18); // Take the first 18 decimals
10
+ return parts[0] + '.' + parts[1];
11
+ }
12
+ else {
13
+ return numStr;
14
+ }
15
+ }
16
+ var convertToTokenValue = function (numberString, decimals) {
17
+ if (isNaN(parseFloat(numberString))) {
18
+ console.error('Error: numberString to parse is not a number');
19
+ return ethers.utils.parseUnits('0', decimals);
20
+ }
21
+ var tokenValue = ethers.utils.parseUnits(adjustDecimals(numberString), decimals);
22
+ return tokenValue;
23
+ };
24
+ export default convertToTokenValue;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Ape Bond SDK",
4
4
  "author": "Ape Bond",
5
5
  "license": "MIT",
6
- "version": "1.0.304",
6
+ "version": "1.0.306",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.es.js",
9
9
  "types": "dist/index.d.ts",
File without changes
File without changes
File without changes