@ape.swap/bonds-sdk 1.0.358 → 1.0.360
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 +20 -11
- package/dist/components/YourBonds/YourBonds.js +6 -45
- package/dist/components/YourBondsModal/YourBondsModal.js +56 -44
- package/package.json +1 -1
- package/dist/enum/abis.d.ts +0 -80
- package/dist/enum/abis.js +0 -1
- package/dist/state/bills/cleanBillsData.d.ts +0 -5
- package/dist/state/bills/cleanBillsData.js +0 -41
- package/dist/state/bills/fetchBills.d.ts +0 -4
- package/dist/state/bills/fetchBills.js +0 -61
- package/dist/state/bills/fetchBillsCalls.d.ts +0 -4
- package/dist/state/bills/fetchBillsCalls.js +0 -27
- package/dist/state/bills/fetchBillsUser.d.ts +0 -15
- package/dist/state/bills/fetchBillsUser.js +0 -171
- package/dist/state/bills/getBillNftData.d.ts +0 -9
- package/dist/state/bills/getBillNftData.js +0 -109
- package/dist/state/bills/hooks.d.ts +0 -4
- package/dist/state/bills/hooks.js +0 -142
- package/dist/state/bills/index.d.ts +0 -48
- package/dist/state/bills/index.js +0 -293
- package/dist/state/bills/types.d.ts +0 -168
- package/dist/state/bills/types.js +0 -1
|
@@ -62,9 +62,10 @@ import { TooltipText } from '../../enum/tooltips';
|
|
|
62
62
|
import { formatNumberSI } from '../../utils/formatNumber';
|
|
63
63
|
import { ethers } from 'ethers';
|
|
64
64
|
import { adjustDecimals } from "../../utils/convertToTokenValue";
|
|
65
|
-
import { BondAbi } from '../../enum/abis';
|
|
66
65
|
import TokenImage from '../uikit-sdk/TokenImage';
|
|
67
66
|
import '../../scss/BondModal.scss';
|
|
67
|
+
import BOND_ABI from '../../config/abi/bond.json';
|
|
68
|
+
import ERC_20_ABI from '../../config/abi/bond.json';
|
|
68
69
|
var BondModal = function (_a) {
|
|
69
70
|
var isOpen = _a.isOpen, onClose = _a.onClose, bondAddress = _a.bondAddress;
|
|
70
71
|
if (!isOpen)
|
|
@@ -115,6 +116,8 @@ var BondModal = function (_a) {
|
|
|
115
116
|
setSelectedBond(bond);
|
|
116
117
|
navigate("/bondsingle/".concat(bond.billAddress));
|
|
117
118
|
};
|
|
119
|
+
//Note to Gordon: Can we put all this in a helper file or something so the code in here is less?
|
|
120
|
+
/////////////////////
|
|
118
121
|
function formatNumber(input) {
|
|
119
122
|
var number = new BigNumber(input);
|
|
120
123
|
if (number.isNaN())
|
|
@@ -166,6 +169,9 @@ var BondModal = function (_a) {
|
|
|
166
169
|
var getPremium = premium(bond);
|
|
167
170
|
return parseFloat(getPremium) < 0 ? 'premium-negative' : 'premium-positive';
|
|
168
171
|
};
|
|
172
|
+
////////////////////////////////////////////////////////////////////////////////////
|
|
173
|
+
////////////////////////////////////////////////////////////////////////////////////
|
|
174
|
+
////////////////////////////////////////////////////////////////////////////////////
|
|
169
175
|
var handleBuy = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
170
176
|
var provider, signer, bondContract, maxPrice, amount, tx, error_1;
|
|
171
177
|
return __generator(this, function (_a) {
|
|
@@ -179,7 +185,7 @@ var BondModal = function (_a) {
|
|
|
179
185
|
}
|
|
180
186
|
provider = new ethers.providers.Web3Provider(window.ethereum);
|
|
181
187
|
signer = provider.getSigner();
|
|
182
|
-
bondContract = new ethers.Contract(bondAddress !== null && bondAddress !== void 0 ? bondAddress : "",
|
|
188
|
+
bondContract = new ethers.Contract(bondAddress !== null && bondAddress !== void 0 ? bondAddress : "", BOND_ABI, signer);
|
|
183
189
|
_a.label = 1;
|
|
184
190
|
case 1:
|
|
185
191
|
_a.trys.push([1, 4, , 5]);
|
|
@@ -202,10 +208,12 @@ var BondModal = function (_a) {
|
|
|
202
208
|
}
|
|
203
209
|
});
|
|
204
210
|
}); };
|
|
211
|
+
//You approve the token, not the contract (this code will have to be updated for zap)
|
|
205
212
|
var handleApprove = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
206
213
|
var provider, signer, bondContract, amount, tx, error_2;
|
|
207
|
-
|
|
208
|
-
|
|
214
|
+
var _a;
|
|
215
|
+
return __generator(this, function (_b) {
|
|
216
|
+
switch (_b.label) {
|
|
209
217
|
case 0:
|
|
210
218
|
console.log('handle approve clicked');
|
|
211
219
|
if (!window.ethereum) {
|
|
@@ -213,24 +221,25 @@ var BondModal = function (_a) {
|
|
|
213
221
|
alert('No Ethereum provider found');
|
|
214
222
|
return [2 /*return*/];
|
|
215
223
|
}
|
|
224
|
+
console.log(selectedBond === null || selectedBond === void 0 ? void 0 : selectedBond.principalToken);
|
|
216
225
|
provider = new ethers.providers.Web3Provider(window.ethereum);
|
|
217
226
|
signer = provider.getSigner();
|
|
218
|
-
bondContract = new ethers.Contract(
|
|
219
|
-
|
|
227
|
+
bondContract = new ethers.Contract((_a = selectedBond === null || selectedBond === void 0 ? void 0 : selectedBond.principalToken) !== null && _a !== void 0 ? _a : "", ERC_20_ABI, signer);
|
|
228
|
+
_b.label = 1;
|
|
220
229
|
case 1:
|
|
221
|
-
|
|
230
|
+
_b.trys.push([1, 4, , 5]);
|
|
222
231
|
amount = adjustDecimals(inputValue);
|
|
223
|
-
return [4 /*yield*/, bondContract.approve(
|
|
232
|
+
return [4 /*yield*/, bondContract.approve(bondAddress, amount)];
|
|
224
233
|
case 2:
|
|
225
|
-
tx =
|
|
234
|
+
tx = _b.sent();
|
|
226
235
|
return [4 /*yield*/, tx.wait()];
|
|
227
236
|
case 3:
|
|
228
|
-
|
|
237
|
+
_b.sent();
|
|
229
238
|
setApprovalStatus(true);
|
|
230
239
|
alert('Approve Successful');
|
|
231
240
|
return [3 /*break*/, 5];
|
|
232
241
|
case 4:
|
|
233
|
-
error_2 =
|
|
242
|
+
error_2 = _b.sent();
|
|
234
243
|
console.error('Approval error', error_2);
|
|
235
244
|
alert('Approval Failed');
|
|
236
245
|
return [3 /*break*/, 5];
|
|
@@ -114,45 +114,12 @@ var YourBonds = function (_a) {
|
|
|
114
114
|
}
|
|
115
115
|
});
|
|
116
116
|
}); };
|
|
117
|
-
// const [hotBonds, setHotBonds] = useState<string[]>([]);
|
|
118
|
-
// const vestingTime = (vestingTerm: number) => {
|
|
119
|
-
// return getTimePeriods(vestingTerm ?? 0, true);
|
|
120
|
-
// }
|
|
121
117
|
useEffect(function () {
|
|
122
118
|
axios.get('https://realtime-api.ape.bond/bonds').then(function (response) {
|
|
123
119
|
var bonds = response.data.bonds;
|
|
124
120
|
setBondData(bonds);
|
|
125
121
|
});
|
|
126
122
|
}, []);
|
|
127
|
-
// useEffect(() => {
|
|
128
|
-
// axios.get('https://apeswap-strapi.herokuapp.com/hot-bonds').then((response) => {
|
|
129
|
-
// const hotBondAddresses = response.data.map((bond: { BondAddress: string }) =>
|
|
130
|
-
// bond.BondAddress.toLowerCase(),
|
|
131
|
-
// );
|
|
132
|
-
// setHotBonds(hotBondAddresses);
|
|
133
|
-
// })
|
|
134
|
-
// }, []);
|
|
135
|
-
// const isSoldOut = useCallback((bond: BondsDataResponse) => {
|
|
136
|
-
// const thresholdToHide = new BigNumber(100).div(bond.payoutTokenPrice ?? 0);
|
|
137
|
-
// if (bond.soldOut) return true;
|
|
138
|
-
// if (bond.discount == null) return true;
|
|
139
|
-
// if (!bond.tokensRemaining) return false;
|
|
140
|
-
// if (bond.discount && bond.discount > 25 && bond.chainId === ChainId.BASE /*BASE*/) return true;
|
|
141
|
-
// return new BigNumber(bond.tokensRemaining)?.lte(thresholdToHide) || bond.discount === 100;
|
|
142
|
-
// }, []);
|
|
143
|
-
// const sortedBonds = bondData.sort((a, b) => {
|
|
144
|
-
// const aIsHot = hotBonds.includes(a.billAddress.toLowerCase()) && (a.discount ?? 0) > 0;
|
|
145
|
-
// const bIsHot = hotBonds.includes(b.billAddress.toLowerCase()) && (b.discount ?? 0) > 0;
|
|
146
|
-
// if (aIsHot && !bIsHot) {
|
|
147
|
-
// return -1;
|
|
148
|
-
// }
|
|
149
|
-
// else if (!aIsHot && bIsHot) {
|
|
150
|
-
// return 1;
|
|
151
|
-
// }
|
|
152
|
-
// else {
|
|
153
|
-
// return b.discount - a.discount;
|
|
154
|
-
// }
|
|
155
|
-
// });
|
|
156
123
|
var _d = useState(false), isModalOpen = _d[0], setIsModalOpen = _d[1];
|
|
157
124
|
var _e = useState(null), selectedBond = _e[0], setSelectedBond = _e[1];
|
|
158
125
|
var _f = useState([]), bondData = _f[0], setBondData = _f[1];
|
|
@@ -161,10 +128,6 @@ var YourBonds = function (_a) {
|
|
|
161
128
|
setIsModalOpen(true);
|
|
162
129
|
navigate("/YourBonds/?bondAddress=".concat(bond.billAddress, "&bondChain=").concat(bond.chainId), { replace: true });
|
|
163
130
|
};
|
|
164
|
-
var currentTime = useCurrentTime() / 1000;
|
|
165
|
-
var vestingTimeRemaining = function (userBill) {
|
|
166
|
-
return getTimePeriods(parseInt(userBill.lastBlockTimestamp) + parseInt(userBill.vesting) - currentTime, true);
|
|
167
|
-
};
|
|
168
131
|
var fetchUserOwnedBillsDataAsync = function (chainId, account) { return __awaiter(void 0, void 0, void 0, function () {
|
|
169
132
|
var bonds, userOwnedBills_1, mapUserOwnedBills_1, userOwnedBillsData_1, ownedBillsData, userBillNftData_1, combinedData, error_2;
|
|
170
133
|
return __generator(this, function (_a) {
|
|
@@ -204,12 +167,6 @@ var YourBonds = function (_a) {
|
|
|
204
167
|
});
|
|
205
168
|
return __assign(__assign({}, data), { userOwnedBills: enrichedUserBills });
|
|
206
169
|
});
|
|
207
|
-
// console.log("userBillNftData");
|
|
208
|
-
// console.log(userBillNftData);
|
|
209
|
-
// console.log("userBillNftData");
|
|
210
|
-
// console.log("userOwnedBillsData");
|
|
211
|
-
// console.log(userOwnedBillsData);
|
|
212
|
-
// console.log("userOwnedBillsData");
|
|
213
170
|
console.log("combinedData");
|
|
214
171
|
console.log(combinedData);
|
|
215
172
|
console.log("combinedData");
|
|
@@ -325,6 +282,10 @@ var YourBonds = function (_a) {
|
|
|
325
282
|
fetchData();
|
|
326
283
|
}, [account]);
|
|
327
284
|
var chainId = useWeb3React().chainId;
|
|
285
|
+
var currentTime = useCurrentTime() / 1000;
|
|
286
|
+
var vestingTimeRemaining = function (userBill) {
|
|
287
|
+
return getTimePeriods(parseInt(userBill.lastBlockTimestamp) + parseInt(userBill.vesting) - currentTime, true);
|
|
288
|
+
};
|
|
328
289
|
var totalPending = function (userBill) {
|
|
329
290
|
var _a, _b, _c, _d;
|
|
330
291
|
return getBalanceNumber(new BigNumber((_a = userBill === null || userBill === void 0 ? void 0 : userBill.payout) !== null && _a !== void 0 ? _a : 0), (_d = (_c = (_b = userBill.bond.earnToken) === null || _b === void 0 ? void 0 : _b.decimals) === null || _c === void 0 ? void 0 : _c[chainId]) !== null && _d !== void 0 ? _d : 18);
|
|
@@ -352,8 +313,8 @@ var YourBonds = function (_a) {
|
|
|
352
313
|
return totalPending(b) - totalPending(a);
|
|
353
314
|
});
|
|
354
315
|
return sortedBills.map(function (bill) {
|
|
355
|
-
var _a, _b
|
|
356
|
-
return (_jsxs(Flex, __assign({ className: "container bondrow-container", onClick: function () { return rowClick(bill.bond); } }, { children: [_jsx(Flex, __assign({ className: "column column-tokens" }, { children:
|
|
316
|
+
var _a, _b;
|
|
317
|
+
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: {
|
|
357
318
|
height: ['36px', '36px', '36px', '26px'],
|
|
358
319
|
lineHeight: '12px',
|
|
359
320
|
fontSize: '14px',
|
|
@@ -52,7 +52,6 @@ import { Flex, ThemeUIProvider } from 'theme-ui';
|
|
|
52
52
|
import { useWeb3React } from '@web3-react/core';
|
|
53
53
|
import { defaultTheme } from '../../theme';
|
|
54
54
|
import '../../scss/YourBondsModal.scss';
|
|
55
|
-
import getTimePeriods from '../../utils/getTimePeriods';
|
|
56
55
|
import axios from 'axios';
|
|
57
56
|
import { BigNumber } from 'bignumber.js';
|
|
58
57
|
import { getFirstNonZeroDigits } from '../../utils/roundNumber';
|
|
@@ -67,12 +66,12 @@ import { ACF_TO_ABOND } from '../../config/constants/addresses';
|
|
|
67
66
|
import { MAINNET_CHAINS } from '../../config/constants/chains';
|
|
68
67
|
import { getPendingVesting } from '../../hooks/usePendingVesting';
|
|
69
68
|
import { formatNumberSI } from '../../utils/formatNumber';
|
|
69
|
+
import { fetchUserOwnedBillNftData } from '../YourBonds/fetchBillsUser';
|
|
70
70
|
var YourBondsModal = function (_a) {
|
|
71
71
|
var isOpen = _a.isOpen, onClose = _a.onClose, bondAddress = _a.bondAddress;
|
|
72
72
|
if (!isOpen)
|
|
73
73
|
return null;
|
|
74
|
-
var _b = useWeb3React(), account = _b.account, isActive = _b.isActive;
|
|
75
|
-
var vestingTime = function (vestingTerm) { return getTimePeriods(vestingTerm !== null && vestingTerm !== void 0 ? vestingTerm : 0, true); };
|
|
74
|
+
var _b = useWeb3React(), account = _b.account, chainId = _b.chainId, isActive = _b.isActive;
|
|
76
75
|
var _c = useState([]), bondData = _c[0], setBondData = _c[1];
|
|
77
76
|
useEffect(function () {
|
|
78
77
|
axios.get('https://realtime-api.ape.bond/bonds').then(function (response) {
|
|
@@ -82,44 +81,13 @@ var YourBondsModal = function (_a) {
|
|
|
82
81
|
setBondData(bond);
|
|
83
82
|
});
|
|
84
83
|
}, [bondAddress]);
|
|
85
|
-
// const [selectedBond, setSelectedBond] = useState<BondsDataResponse | null>(null);
|
|
86
|
-
// const navigate = useNavigate();
|
|
87
|
-
// const projectInfo = (bond: BondsDataResponse) => {
|
|
88
|
-
// setSelectedBond(bond);
|
|
89
|
-
// navigate(`/bondsingle/${bond.billAddress}`);
|
|
90
|
-
// };
|
|
91
84
|
var _d = useState([]), userOwnedBillsData = _d[0], setUserOwnedBillsData = _d[1];
|
|
92
|
-
useEffect(function () {
|
|
93
|
-
var fetchData = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
94
|
-
var results, error_1;
|
|
95
|
-
return __generator(this, function (_a) {
|
|
96
|
-
switch (_a.label) {
|
|
97
|
-
case 0:
|
|
98
|
-
if (!account) return [3 /*break*/, 4];
|
|
99
|
-
_a.label = 1;
|
|
100
|
-
case 1:
|
|
101
|
-
_a.trys.push([1, 3, , 4]);
|
|
102
|
-
return [4 /*yield*/, Promise.all(MAINNET_CHAINS.map(function (chain) { return fetchUserOwnedBillsDataAsync(chain, account); }))];
|
|
103
|
-
case 2:
|
|
104
|
-
results = _a.sent();
|
|
105
|
-
setUserOwnedBillsData(results);
|
|
106
|
-
return [3 /*break*/, 4];
|
|
107
|
-
case 3:
|
|
108
|
-
error_1 = _a.sent();
|
|
109
|
-
console.error('Error fetching user owned bills data:', error_1);
|
|
110
|
-
return [3 /*break*/, 4];
|
|
111
|
-
case 4: return [2 /*return*/];
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
}); };
|
|
115
|
-
fetchData();
|
|
116
|
-
}, [account]);
|
|
117
85
|
var fetchUserOwnedBillsDataAsync = function (chainId, account) { return __awaiter(void 0, void 0, void 0, function () {
|
|
118
|
-
var bonds, userOwnedBills_1, mapUserOwnedBills_1, userOwnedBillsData_1,
|
|
86
|
+
var bonds, userOwnedBills_1, mapUserOwnedBills_1, userOwnedBillsData_1, ownedBillsData, userBillNftData_1, combinedData, error_1;
|
|
119
87
|
return __generator(this, function (_a) {
|
|
120
88
|
switch (_a.label) {
|
|
121
89
|
case 0:
|
|
122
|
-
_a.trys.push([0,
|
|
90
|
+
_a.trys.push([0, 3, , 4]);
|
|
123
91
|
bonds = bondData.filter(function (bond) {
|
|
124
92
|
return bond.billVersion !== BillVersion.FixedPrice &&
|
|
125
93
|
(bond === null || bond === void 0 ? void 0 : bond.chainId) === chainId &&
|
|
@@ -136,12 +104,32 @@ var YourBondsModal = function (_a) {
|
|
|
136
104
|
index: bill.index,
|
|
137
105
|
userOwnedBills: mapUserOwnedBills_1[i],
|
|
138
106
|
}); });
|
|
139
|
-
|
|
107
|
+
ownedBillsData = mapUserOwnedBills_1.flatMap(function (bs) {
|
|
108
|
+
return bs.map(function (b) {
|
|
109
|
+
return { id: b.id, billNftAddress: b.billNftAddress, contractAddress: b.address };
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
return [4 /*yield*/, fetchUserOwnedBillNftData(ownedBillsData, chainId, bonds)
|
|
113
|
+
// Merge userBillNftData into userOwnedBillsData
|
|
114
|
+
];
|
|
140
115
|
case 2:
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
116
|
+
userBillNftData_1 = _a.sent();
|
|
117
|
+
combinedData = userOwnedBillsData_1.map(function (data) {
|
|
118
|
+
var enrichedUserBills = data.userOwnedBills.map(function (bill) {
|
|
119
|
+
var nftData = userBillNftData_1.find(function (nft) { return nft.id === parseInt(bill.id); });
|
|
120
|
+
return __assign(__assign({}, bill), { nftData: nftData ? nftData : undefined });
|
|
121
|
+
});
|
|
122
|
+
return __assign(__assign({}, data), { userOwnedBills: enrichedUserBills });
|
|
123
|
+
});
|
|
124
|
+
console.log("combinedData");
|
|
125
|
+
console.log(combinedData);
|
|
126
|
+
console.log("combinedData");
|
|
127
|
+
return [2 /*return*/, Promise.resolve(combinedData)];
|
|
128
|
+
case 3:
|
|
129
|
+
error_1 = _a.sent();
|
|
130
|
+
console.error('Error fetching user owned bills data:', error_1);
|
|
131
|
+
return [2 /*return*/, Promise.reject(error_1)];
|
|
132
|
+
case 4: return [2 /*return*/];
|
|
145
133
|
}
|
|
146
134
|
});
|
|
147
135
|
}); };
|
|
@@ -221,7 +209,31 @@ var YourBondsModal = function (_a) {
|
|
|
221
209
|
}
|
|
222
210
|
});
|
|
223
211
|
}); };
|
|
224
|
-
|
|
212
|
+
useEffect(function () {
|
|
213
|
+
var fetchData = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
214
|
+
var results, error_2;
|
|
215
|
+
return __generator(this, function (_a) {
|
|
216
|
+
switch (_a.label) {
|
|
217
|
+
case 0:
|
|
218
|
+
if (!account) return [3 /*break*/, 4];
|
|
219
|
+
_a.label = 1;
|
|
220
|
+
case 1:
|
|
221
|
+
_a.trys.push([1, 3, , 4]);
|
|
222
|
+
return [4 /*yield*/, Promise.all(MAINNET_CHAINS.map(function (chain) { return fetchUserOwnedBillsDataAsync(chain, account); }))];
|
|
223
|
+
case 2:
|
|
224
|
+
results = _a.sent();
|
|
225
|
+
setUserOwnedBillsData(results);
|
|
226
|
+
return [3 /*break*/, 4];
|
|
227
|
+
case 3:
|
|
228
|
+
error_2 = _a.sent();
|
|
229
|
+
console.error('Error fetching user owned bills data:', error_2);
|
|
230
|
+
return [3 /*break*/, 4];
|
|
231
|
+
case 4: return [2 /*return*/];
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}); };
|
|
235
|
+
fetchData();
|
|
236
|
+
}, [account]);
|
|
225
237
|
var totalPending = function (userBill) {
|
|
226
238
|
var _a, _b, _c, _d;
|
|
227
239
|
return getBalanceNumber(new BigNumber((_a = userBill === null || userBill === void 0 ? void 0 : userBill.payout) !== null && _a !== void 0 ? _a : 0), (_d = (_c = (_b = userBill.bond.earnToken) === null || _b === void 0 ? void 0 : _b.decimals) === null || _c === void 0 ? void 0 : _c[chainId]) !== null && _d !== void 0 ? _d : 18);
|
|
@@ -235,11 +247,11 @@ var YourBondsModal = function (_a) {
|
|
|
235
247
|
return getFirstNonZeroDigits(parseFloat((_a = bond === null || bond === void 0 ? void 0 : bond.payoutTokenPrice) !== null && _a !== void 0 ? _a : '0'));
|
|
236
248
|
};
|
|
237
249
|
return (_jsx(ThemeUIProvider, __assign({ theme: defaultTheme }, { children: userOwnedBillsData.flat().map(function (data) {
|
|
238
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
250
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
239
251
|
var userBill = data.userOwnedBills.find(function (bill) { return bill.bond.billAddress.toLowerCase() === (bondAddress === null || bondAddress === void 0 ? void 0 : bondAddress.toLowerCase()); });
|
|
240
252
|
console.log("USER BILL LOG");
|
|
241
253
|
console.log(userBill);
|
|
242
|
-
return userBill ? (_jsx(React.Fragment, { children: _jsx(Flex, __assign({ className: "yourbondsmodal backdrop" }, { children: _jsxs(Flex, __assign({ className: "yourbondsmodal content" }, { children: [_jsx(Flex, __assign({ className: "yourbondsmodal header" }, { children: _jsx(Flex, __assign({ className: "svg-close", onClick: onClose }, { children: _jsx(Svg, { icon: "close" }) })) })), _jsxs(Flex, __assign({ className: "yourbondsmodal table-container" }, { children: [_jsx(Flex, __assign({ className: "yourbondsmodal bondimage" }, { children: "
|
|
254
|
+
return userBill ? (_jsx(React.Fragment, { children: _jsx(Flex, __assign({ className: "yourbondsmodal backdrop" }, { children: _jsxs(Flex, __assign({ className: "yourbondsmodal content" }, { children: [_jsx(Flex, __assign({ className: "yourbondsmodal header" }, { children: _jsx(Flex, __assign({ className: "svg-close", onClick: onClose }, { children: _jsx(Svg, { icon: "close" }) })) })), _jsxs(Flex, __assign({ className: "yourbondsmodal table-container" }, { children: [_jsx(Flex, __assign({ className: "yourbondsmodal bondimage" }, { children: _jsx("img", { src: (_a = userBill.nftData) === null || _a === void 0 ? void 0 : _a.data.image }) })), _jsxs(Flex, __assign({ className: "yourbondsmodal yourbondinfo" }, { children: [_jsxs(Flex, __assign({ className: "yourbondinfo title-container" }, { children: [_jsx(Flex, __assign({ className: "title-container bondicon" }, { children: _jsx(TokenImage, { symbol: (_b = userBill.bond.showcaseTokenName) !== null && _b !== void 0 ? _b : userBill.bond.payoutTokenName, size: 40 }) })), _jsx(Flex, __assign({ className: "title-container bondname" }, { children: (_c = userBill.bond) === null || _c === void 0 ? void 0 : _c.showcaseTokenName })), _jsx(Flex, __assign({ className: "title-container tokentags" }, { children: _jsx(ListTag, { text: (_e = (_d = userBill.bond) === null || _d === void 0 ? void 0 : _d.tags) === null || _e === void 0 ? void 0 : _e[0], variant: ((_g = (_f = userBill.bond) === null || _f === void 0 ? void 0 : _f.tags) === null || _g === void 0 ? void 0 : _g[0]) === 'Cex Fund' ? 'cex_fund' : 'liquidity' }) }))] })), _jsxs(Flex, __assign({ className: "yourbondinfo blocks-container" }, { children: [_jsx(Flex, __assign({ className: "yourbondinfo-block row-traits" }, { children: _jsx(Flex, __assign({ className: "yourbondinfo-block header" }, { children: "Traits" })) })), _jsxs(Flex, __assign({ className: "yourbondinfo-block row-vested" }, { children: [_jsxs(Flex, __assign({ className: "yourbondinfo-block header" }, { children: ["Fully Vested", _jsx(TooltipBubble, __assign({ body: _jsx(Flex, { children: UserBillTooltipText.FullyVested }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)" }, { children: _jsx(Flex, __assign({ className: "block-header icon" }, { children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) })) }))] })), _jsxs(Flex, __assign({ className: "yourbondinfo-block info" }, { children: [_jsx(Flex, { className: "block-info icon" }), _jsx(Flex, __assign({ className: "block-info text" }, { children: getPendingVesting(userBill.lastBlockTimestamp, userBill.vesting) }))] }))] })), _jsxs(Flex, __assign({ className: "yourbondinfo-block row-pending" }, { children: [_jsxs(Flex, __assign({ className: "yourbondinfo-block header" }, { children: ["Pending", _jsx(TooltipBubble, __assign({ body: _jsx(Flex, { children: UserBillTooltipText.Pending }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)" }, { children: _jsx(Flex, __assign({ className: "block-header icon" }, { children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) })) }))] })), _jsxs(Flex, __assign({ className: "yourbondinfo-block info" }, { children: [_jsx(Flex, __assign({ className: "block-info icon" }, { children: _jsx(TokenImage, { symbol: (_h = userBill.bond.showcaseTokenName) !== null && _h !== void 0 ? _h : userBill.bond.payoutTokenName, size: 25 }) })), _jsxs(Flex, __assign({ className: "block-info text" }, { children: [formatNumberSI(parseFloat(totalPending(userBill).toFixed(4)), 4), "($".concat((totalPending(userBill) * ((_j = parseFloat(earnTokenPrice(userBill.bond))) !== null && _j !== void 0 ? _j : 0)).toFixed(2), ")")] }))] }))] })), _jsxs(Flex, __assign({ className: "yourbondinfo-block row-claimable" }, { children: [_jsxs(Flex, __assign({ className: "yourbondinfo-block header" }, { children: ["Claimable", _jsx(TooltipBubble, __assign({ body: _jsx(Flex, { children: UserBillTooltipText.Claimable }), width: "230px", placement: "bottomLeft", transformTip: "translate(-5%, -5%)" }, { children: _jsx(Flex, __assign({ className: "block-header icon" }, { children: _jsx(Svg, { icon: "questionCircle", width: "12px" }) })) }))] })), _jsxs(Flex, __assign({ className: "yourbondinfo-block info" }, { children: [_jsx(Flex, __assign({ className: "block-info icon" }, { children: _jsx(TokenImage, { symbol: (_k = userBill.bond.showcaseTokenName) !== null && _k !== void 0 ? _k : userBill.bond.payoutTokenName, size: 25 }) })), _jsxs(Flex, __assign({ className: "block-info text" }, { children: [formatNumberSI(parseFloat(claimable(userBill).toFixed(4)), 4), "($".concat((claimable(userBill) * ((_l = parseFloat(earnTokenPrice(userBill.bond))) !== null && _l !== void 0 ? _l : 0)).toFixed(2), ")")] }))] }))] }))] })), _jsxs(Flex, __assign({ className: "yourbondinfo button-container" }, { children: [_jsx(Flex, __assign({ className: "button-container claim" }, { children: _jsx(Button, { children: "CLAIM" }) })), _jsx(Flex, __assign({ className: "button-container transfer" }, { children: _jsx(Button, { children: "TRANSFER" }) }))] }))] }))] }))] })) })) }, userBill.bond.billAddress)) : null;
|
|
243
255
|
}) })));
|
|
244
256
|
};
|
|
245
257
|
export default YourBondsModal;
|
package/package.json
CHANGED
package/dist/enum/abis.d.ts
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
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
|
-
})[];
|
package/dist/enum/abis.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
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" }];
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { ChainId } from '../../enum/apeswaplists';
|
|
2
|
-
import { CleanedBondsState } from '../../types/bonds';
|
|
3
|
-
import { TokenPrices } from '../tokenPrices/useTokenPricesNew';
|
|
4
|
-
declare const cleanBillsData: (billIds: number[], chunkedBills: any[], tokenPrices: TokenPrices[], chainId: ChainId, bills: CleanedBondsState[]) => CleanedBondsState[];
|
|
5
|
-
export default cleanBillsData;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
import { getBalanceNumber } from '../../utils/getBalanceNumber';
|
|
13
|
-
import BigNumber from 'bignumber.js';
|
|
14
|
-
var cleanBillsData = function (billIds, chunkedBills, tokenPrices, chainId, bills) {
|
|
15
|
-
var data = chunkedBills === null || chunkedBills === void 0 ? void 0 : chunkedBills.map(function (chunk, index) {
|
|
16
|
-
var _a, _b, _c;
|
|
17
|
-
var billFromState = bills === null || bills === void 0 ? void 0 : bills.find(function (bill) { return (bill === null || bill === void 0 ? void 0 : bill.index) === billIds[index]; });
|
|
18
|
-
var lpPrice = (_a = tokenPrices === null || tokenPrices === void 0 ? void 0 : tokenPrices.find(function (tokenPrice) {
|
|
19
|
-
var _a;
|
|
20
|
-
return ((_a = tokenPrice.address) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === (billFromState === null || billFromState === void 0 ? void 0 : billFromState.principalToken.toLowerCase()) &&
|
|
21
|
-
tokenPrice.chainId === chainId;
|
|
22
|
-
})) === null || _a === void 0 ? void 0 : _a.price;
|
|
23
|
-
var earnTokenPrice = (_b = tokenPrices === null || tokenPrices === void 0 ? void 0 : tokenPrices.find(function (tokenPrice) {
|
|
24
|
-
var _a;
|
|
25
|
-
return ((_a = tokenPrice.address) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === (billFromState === null || billFromState === void 0 ? void 0 : billFromState.payoutToken.toLowerCase()) &&
|
|
26
|
-
tokenPrice.chainId === chainId;
|
|
27
|
-
})) === null || _b === void 0 ? void 0 : _b.price;
|
|
28
|
-
var trueBillPrice = chunk[0], totalPayoutGiven = chunk[1], terms = chunk[2], maxTotalPayout = chunk[3];
|
|
29
|
-
var vestingTerm = terms[1], maxPayout = terms[3];
|
|
30
|
-
var priceUsd = lpPrice && trueBillPrice && getBalanceNumber(trueBillPrice === null || trueBillPrice === void 0 ? void 0 : trueBillPrice.toString()) * lpPrice;
|
|
31
|
-
var discount = earnTokenPrice && priceUsd && ((earnTokenPrice - priceUsd) / earnTokenPrice) * 100;
|
|
32
|
-
var tokensRemaining = new BigNumber(maxTotalPayout !== null && maxTotalPayout !== void 0 ? maxTotalPayout : '0')
|
|
33
|
-
.minus(new BigNumber(totalPayoutGiven))
|
|
34
|
-
.div(new BigNumber(10).pow((_c = billFromState === null || billFromState === void 0 ? void 0 : billFromState.payoutTokenDecimals) !== null && _c !== void 0 ? _c : 18))
|
|
35
|
-
.toString();
|
|
36
|
-
var cleanedData = __assign(__assign({}, billFromState), { discount: discount, principalTokenPrice: lpPrice === null || lpPrice === void 0 ? void 0 : lpPrice.toString(), payoutTokenPrice: earnTokenPrice === null || earnTokenPrice === void 0 ? void 0 : earnTokenPrice.toString(), tokensRemaining: tokensRemaining, maxTotalPayout: maxTotalPayout === null || maxTotalPayout === void 0 ? void 0 : maxTotalPayout.toString(), trueBillPrice: trueBillPrice === null || trueBillPrice === void 0 ? void 0 : trueBillPrice.toString(), maxPayout: maxPayout === null || maxPayout === void 0 ? void 0 : maxPayout.toString(), totalPayoutGiven: totalPayoutGiven === null || totalPayoutGiven === void 0 ? void 0 : totalPayoutGiven.toString(), vestingTerm: vestingTerm.toNumber() });
|
|
37
|
-
return cleanedData;
|
|
38
|
-
});
|
|
39
|
-
return data;
|
|
40
|
-
};
|
|
41
|
-
export default cleanBillsData;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { TokenPrices } from '../tokenPrices/useTokenPricesNew';
|
|
2
|
-
import { CleanedBondsState } from '../../types/bonds';
|
|
3
|
-
declare const fetchBills: (chainId: number, tokenPrices: TokenPrices[], bills: CleanedBondsState[]) => Promise<CleanedBondsState[]>;
|
|
4
|
-
export default fetchBills;
|