@ape.swap/bonds-sdk 1.0.354 → 1.0.355
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 +1 -1
- package/dist/components/YourBonds/YourBonds.js +62 -43
- package/dist/components/YourBonds/fetchBillsUser.d.ts +3 -3
- package/dist/components/YourBonds/fetchBillsUser.js +4 -4
- package/dist/config/abi/erc20.json +117 -0
- package/dist/config/abi/price-getter-linea.json +1448 -0
- package/dist/config/abi/price-getter.json +1309 -0
- package/dist/hooks/PriceGetter/usePricesFromPriceGetter.d.ts +17 -0
- package/dist/hooks/PriceGetter/usePricesFromPriceGetter.js +205 -0
- package/dist/state/bills/cleanBillsData.d.ts +5 -0
- package/dist/state/bills/cleanBillsData.js +41 -0
- package/dist/state/bills/fetchBills.d.ts +4 -0
- package/dist/state/bills/fetchBills.js +61 -0
- package/dist/state/bills/fetchBillsCalls.d.ts +4 -0
- package/dist/state/bills/fetchBillsCalls.js +27 -0
- package/dist/state/bills/fetchBillsUser.d.ts +15 -0
- package/dist/state/bills/fetchBillsUser.js +171 -0
- package/dist/state/bills/getBillNftData.d.ts +9 -0
- package/dist/state/bills/getBillNftData.js +109 -0
- package/dist/state/bills/hooks.d.ts +4 -0
- package/dist/state/bills/hooks.js +142 -0
- package/dist/state/bills/index.d.ts +48 -0
- package/dist/state/bills/index.js +293 -0
- package/dist/state/bills/types.d.ts +168 -0
- package/dist/state/bills/types.js +1 -0
- package/dist/state/tokenPrices/fetchTokenPricesForMultipleChains.d.ts +4 -0
- package/dist/state/tokenPrices/fetchTokenPricesForMultipleChains.js +68 -0
- package/dist/state/tokenPrices/getAllTokenPrices.d.ts +5 -0
- package/dist/state/tokenPrices/getAllTokenPrices.js +288 -0
- package/dist/state/tokenPrices/useTokenPricesNew.d.ts +11 -0
- package/dist/state/tokenPrices/useTokenPricesNew.js +72 -0
- package/dist/types/bonds.d.ts +62 -0
- package/dist/types/dexFactories.d.ts +11 -0
- package/dist/types/dexFactories.js +2 -0
- package/dist/types/yourbonds.d.ts +4 -0
- package/package.json +1 -1
|
@@ -220,7 +220,7 @@ var BondModal = function (_a) {
|
|
|
220
220
|
case 1:
|
|
221
221
|
_a.trys.push([1, 4, , 5]);
|
|
222
222
|
amount = adjustDecimals(inputValue);
|
|
223
|
-
return [4 /*yield*/, bondContract.approve(
|
|
223
|
+
return [4 /*yield*/, bondContract.approve(amount, account)];
|
|
224
224
|
case 2:
|
|
225
225
|
tx = _a.sent();
|
|
226
226
|
return [4 /*yield*/, tx.wait()];
|
|
@@ -69,6 +69,7 @@ import { formatNumberSI } from '../../utils/formatNumber';
|
|
|
69
69
|
import useCurrentTime from '../../hooks/useTimer';
|
|
70
70
|
import { getPendingVesting } from '../../hooks/usePendingVesting';
|
|
71
71
|
import axios from 'axios';
|
|
72
|
+
import { fetchUserOwnedBillNftData } from './fetchBillsUser';
|
|
72
73
|
var YourBonds = function (_a) {
|
|
73
74
|
var connectionString = _a.connectionString;
|
|
74
75
|
var _b = useWeb3React(), account = _b.account, isActive = _b.isActive;
|
|
@@ -160,26 +161,16 @@ var YourBonds = function (_a) {
|
|
|
160
161
|
setIsModalOpen(true);
|
|
161
162
|
navigate("/YourBonds/?bondAddress=".concat(bond.billAddress, "&bondChain=").concat(bond.chainId), { replace: true });
|
|
162
163
|
};
|
|
163
|
-
// const usePollUserBills = () => {
|
|
164
|
-
// const { slowRefresh } = useRefresh()
|
|
165
|
-
// // const dispatch = useAppDispatch()
|
|
166
|
-
// const { account, isActive } = useWeb3React();
|
|
167
|
-
// useEffect(() => {
|
|
168
|
-
// if (account) {
|
|
169
|
-
// MAINNET_CHAINS.map((chain) => fetchUserOwnedBillsDataAsync(chain as number, account))
|
|
170
|
-
// }
|
|
171
|
-
// }, [account, slowRefresh])
|
|
172
|
-
// }
|
|
173
164
|
var currentTime = useCurrentTime() / 1000;
|
|
174
165
|
var vestingTimeRemaining = function (userBill) {
|
|
175
166
|
return getTimePeriods(parseInt(userBill.lastBlockTimestamp) + parseInt(userBill.vesting) - currentTime, true);
|
|
176
167
|
};
|
|
177
168
|
var fetchUserOwnedBillsDataAsync = function (chainId, account) { return __awaiter(void 0, void 0, void 0, function () {
|
|
178
|
-
var bonds, userOwnedBills_1, mapUserOwnedBills_1, userOwnedBillsData_1, error_2;
|
|
169
|
+
var bonds, userOwnedBills_1, mapUserOwnedBills_1, userOwnedBillsData_1, ownedBillsData, userBillNftData_1, combinedData, error_2;
|
|
179
170
|
return __generator(this, function (_a) {
|
|
180
171
|
switch (_a.label) {
|
|
181
172
|
case 0:
|
|
182
|
-
_a.trys.push([0,
|
|
173
|
+
_a.trys.push([0, 3, , 4]);
|
|
183
174
|
bonds = bondData.filter(function (bond) {
|
|
184
175
|
return bond.billVersion !== BillVersion.FixedPrice &&
|
|
185
176
|
(bond === null || bond === void 0 ? void 0 : bond.chainId) === chainId &&
|
|
@@ -196,41 +187,41 @@ var YourBonds = function (_a) {
|
|
|
196
187
|
index: bill.index,
|
|
197
188
|
userOwnedBills: mapUserOwnedBills_1[i],
|
|
198
189
|
}); });
|
|
199
|
-
|
|
190
|
+
ownedBillsData = mapUserOwnedBills_1.flatMap(function (bs) {
|
|
191
|
+
return bs.map(function (b) {
|
|
192
|
+
return { id: b.id, billNftAddress: b.billNftAddress, contractAddress: b.address };
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
return [4 /*yield*/, fetchUserOwnedBillNftData(ownedBillsData, chainId, bonds)
|
|
196
|
+
// Merge userBillNftData into userOwnedBillsData
|
|
197
|
+
];
|
|
200
198
|
case 2:
|
|
199
|
+
userBillNftData_1 = _a.sent();
|
|
200
|
+
combinedData = userOwnedBillsData_1.map(function (data) {
|
|
201
|
+
var enrichedUserBills = data.userOwnedBills.map(function (bill) {
|
|
202
|
+
var nftData = userBillNftData_1.find(function (nft) { return nft.id === parseInt(bill.id); });
|
|
203
|
+
return __assign(__assign({}, bill), (nftData ? { image: nftData.data.image, attributes: nftData.data.attributes } : {}));
|
|
204
|
+
});
|
|
205
|
+
return __assign(__assign({}, data), { userOwnedBills: enrichedUserBills });
|
|
206
|
+
});
|
|
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
|
+
console.log("combinedData");
|
|
214
|
+
console.log(combinedData);
|
|
215
|
+
console.log("combinedData");
|
|
216
|
+
return [2 /*return*/, Promise.resolve(combinedData)];
|
|
217
|
+
case 3:
|
|
201
218
|
error_2 = _a.sent();
|
|
202
219
|
console.error('Error fetching user owned bills data:', error_2);
|
|
203
220
|
return [2 /*return*/, Promise.reject(error_2)];
|
|
204
|
-
case
|
|
221
|
+
case 4: return [2 /*return*/];
|
|
205
222
|
}
|
|
206
223
|
});
|
|
207
224
|
}); };
|
|
208
|
-
var _g = useState([]), userOwnedBillsData = _g[0], setUserOwnedBillsData = _g[1];
|
|
209
|
-
useEffect(function () {
|
|
210
|
-
var fetchData = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
211
|
-
var results, error_3;
|
|
212
|
-
return __generator(this, function (_a) {
|
|
213
|
-
switch (_a.label) {
|
|
214
|
-
case 0:
|
|
215
|
-
if (!account) return [3 /*break*/, 4];
|
|
216
|
-
_a.label = 1;
|
|
217
|
-
case 1:
|
|
218
|
-
_a.trys.push([1, 3, , 4]);
|
|
219
|
-
return [4 /*yield*/, Promise.all(MAINNET_CHAINS.map(function (chain) { return fetchUserOwnedBillsDataAsync(chain, account); }))];
|
|
220
|
-
case 2:
|
|
221
|
-
results = _a.sent();
|
|
222
|
-
setUserOwnedBillsData(results);
|
|
223
|
-
return [3 /*break*/, 4];
|
|
224
|
-
case 3:
|
|
225
|
-
error_3 = _a.sent();
|
|
226
|
-
console.error('Error fetching user owned bills data:', error_3);
|
|
227
|
-
return [3 /*break*/, 4];
|
|
228
|
-
case 4: return [2 /*return*/];
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
}); };
|
|
232
|
-
fetchData();
|
|
233
|
-
}, [account]);
|
|
234
225
|
var fetchUserOwnedBills = function (chainId, account, bonds) { return __awaiter(void 0, void 0, void 0, function () {
|
|
235
226
|
var billIdCalls, billIds, billsPendingRewardCall, billDataCalls, billVersions, billData, pendingRewardsCall, result, i, billDataPos, data;
|
|
236
227
|
var _a, _b, _c, _d, _e;
|
|
@@ -307,6 +298,32 @@ var YourBonds = function (_a) {
|
|
|
307
298
|
}
|
|
308
299
|
});
|
|
309
300
|
}); };
|
|
301
|
+
var _g = useState([]), userOwnedBillsData = _g[0], setUserOwnedBillsData = _g[1];
|
|
302
|
+
useEffect(function () {
|
|
303
|
+
var fetchData = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
304
|
+
var results, error_3;
|
|
305
|
+
return __generator(this, function (_a) {
|
|
306
|
+
switch (_a.label) {
|
|
307
|
+
case 0:
|
|
308
|
+
if (!account) return [3 /*break*/, 4];
|
|
309
|
+
_a.label = 1;
|
|
310
|
+
case 1:
|
|
311
|
+
_a.trys.push([1, 3, , 4]);
|
|
312
|
+
return [4 /*yield*/, Promise.all(MAINNET_CHAINS.map(function (chain) { return fetchUserOwnedBillsDataAsync(chain, account); }))];
|
|
313
|
+
case 2:
|
|
314
|
+
results = _a.sent();
|
|
315
|
+
setUserOwnedBillsData(results);
|
|
316
|
+
return [3 /*break*/, 4];
|
|
317
|
+
case 3:
|
|
318
|
+
error_3 = _a.sent();
|
|
319
|
+
console.error('Error fetching user owned bills data:', error_3);
|
|
320
|
+
return [3 /*break*/, 4];
|
|
321
|
+
case 4: return [2 /*return*/];
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
}); };
|
|
325
|
+
fetchData();
|
|
326
|
+
}, [account]);
|
|
310
327
|
var chainId = useWeb3React().chainId;
|
|
311
328
|
var totalPending = function (userBill) {
|
|
312
329
|
var _a, _b, _c, _d;
|
|
@@ -327,6 +344,9 @@ var YourBonds = function (_a) {
|
|
|
327
344
|
fontWeight: 600,
|
|
328
345
|
width: '100%',
|
|
329
346
|
} }, { children: "Claim All" })) }))] }))] })), userOwnedBillsData.flat().map(function (data) {
|
|
347
|
+
console.log("ROWDATA");
|
|
348
|
+
console.log(data);
|
|
349
|
+
console.log("ROWDATA");
|
|
330
350
|
var sortedBills = data.userOwnedBills.sort(function (a, b) {
|
|
331
351
|
var claimableDifference = claimable(b) - claimable(a);
|
|
332
352
|
if (claimableDifference !== 0) {
|
|
@@ -334,10 +354,9 @@ var YourBonds = function (_a) {
|
|
|
334
354
|
}
|
|
335
355
|
return totalPending(b) - totalPending(a);
|
|
336
356
|
});
|
|
337
|
-
console.log(sortedBills);
|
|
338
357
|
return sortedBills.map(function (bill) {
|
|
339
|
-
var _a, _b;
|
|
340
|
-
return (_jsxs(Flex, __assign({ className: "container bondrow-container", onClick: function () { return rowClick(bill.bond); } }, { children: [_jsx(Flex, __assign({ className: "column column-tokens" }, { children:
|
|
358
|
+
var _a, _b, _c;
|
|
359
|
+
return (_jsxs(Flex, __assign({ className: "container bondrow-container", onClick: function () { return rowClick(bill.bond); } }, { children: [_jsx(Flex, __assign({ className: "column column-tokens" }, { children: _jsxs(Flex, __assign({ className: "column column-tokeninfoname" }, { children: [_jsx(TokenInfoAndName, { bill: bill.bond, vestEnds: "Ends in ".concat(getPendingVesting(bill.lastBlockTimestamp, bill.vesting)) }), (_a = bill.nftData) === null || _a === void 0 ? void 0 : _a.image] })) })), _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) * ((_b = parseFloat(earnTokenPrice(bill.bond))) !== null && _b !== void 0 ? _b : 0)).toFixed(2), ")")] })), _jsxs(Flex, __assign({ className: "column column-pending" }, { children: [formatNumberSI(parseFloat(totalPending(bill).toFixed(0)), 0), "($".concat((totalPending(bill) * ((_c = parseFloat(earnTokenPrice(bill.bond))) !== null && _c !== void 0 ? _c : 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: {
|
|
341
360
|
height: ['36px', '36px', '36px', '26px'],
|
|
342
361
|
lineHeight: '12px',
|
|
343
362
|
fontSize: '14px',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { BondsDataResponse, CleanedBondsState, UserBill } from '../../types/bonds';
|
|
2
|
+
import { ChainId } from '../../enum/apeswaplists';
|
|
3
3
|
/**
|
|
4
4
|
* Fetches user-owned bill NFT data for a given set of owned bills data, chain ID, and bills.
|
|
5
5
|
* @param ownedBillsData An array of objects containing the ID, bill NFT address, and contract address of the owned bills.
|
|
@@ -11,5 +11,5 @@ export declare const fetchUserOwnedBillNftData: (ownedBillsData: {
|
|
|
11
11
|
id: string;
|
|
12
12
|
billNftAddress: string;
|
|
13
13
|
contractAddress: string;
|
|
14
|
-
}[], chainId: ChainId, bills:
|
|
14
|
+
}[], chainId: ChainId, bills: BondsDataResponse[]) => Promise<any[]>;
|
|
15
15
|
export declare const fetchUserOwnedBills: (chainId: ChainId, account: string, bills: CleanedBondsState[]) => Promise<UserBill[]>;
|
|
@@ -37,8 +37,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
import billAbi from '../../config/abi/bond.json';
|
|
38
38
|
import BigNumber from 'bignumber.js';
|
|
39
39
|
import { getBillNftBatchData } from './getBillNftData';
|
|
40
|
-
import { BillVersion } from '@ape.swap/apeswap-lists';
|
|
41
40
|
import multicall from '../../utils/multicall';
|
|
41
|
+
import { BillVersion } from '../../enum/apeswaplists';
|
|
42
42
|
/**
|
|
43
43
|
* Fetches user-owned bill NFT data for a given set of owned bills data, chain ID, and bills.
|
|
44
44
|
* @param ownedBillsData An array of objects containing the ID, bill NFT address, and contract address of the owned bills.
|
|
@@ -55,10 +55,10 @@ export var fetchUserOwnedBillNftData = function (ownedBillsData, chainId, bills)
|
|
|
55
55
|
billsFetched = [];
|
|
56
56
|
// Loop through each owned bill and check if it exists in the bills array
|
|
57
57
|
ownedBillsData === null || ownedBillsData === void 0 ? void 0 : ownedBillsData.forEach(function (_a) {
|
|
58
|
-
var _b, _c;
|
|
59
58
|
var id = _a.id, billNftAddress = _a.billNftAddress, contractAddress = _a.contractAddress;
|
|
60
|
-
var bill =
|
|
61
|
-
.find(function (b) { return b.
|
|
59
|
+
var bill = bills
|
|
60
|
+
.find(function (b) { return b.billAddress[chainId] === contractAddress; });
|
|
61
|
+
// ?.userOwnedBillsNftData?.find((u) => +u.tokenId === +id)
|
|
62
62
|
// If the bill exists in the bills array, add it to the billsFetched array
|
|
63
63
|
if (bill) {
|
|
64
64
|
billsFetched.push({ id: id, data: bill });
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"constant": true,
|
|
4
|
+
"inputs": [],
|
|
5
|
+
"name": "name",
|
|
6
|
+
"outputs": [{ "name": "", "type": "string" }],
|
|
7
|
+
"payable": false,
|
|
8
|
+
"stateMutability": "view",
|
|
9
|
+
"type": "function"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"constant": false,
|
|
13
|
+
"inputs": [
|
|
14
|
+
{ "name": "_spender", "type": "address" },
|
|
15
|
+
{ "name": "_value", "type": "uint256" }
|
|
16
|
+
],
|
|
17
|
+
"name": "approve",
|
|
18
|
+
"outputs": [{ "name": "", "type": "bool" }],
|
|
19
|
+
"payable": false,
|
|
20
|
+
"stateMutability": "nonpayable",
|
|
21
|
+
"type": "function"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"constant": true,
|
|
25
|
+
"inputs": [],
|
|
26
|
+
"name": "totalSupply",
|
|
27
|
+
"outputs": [{ "name": "", "type": "uint256" }],
|
|
28
|
+
"payable": false,
|
|
29
|
+
"stateMutability": "view",
|
|
30
|
+
"type": "function"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"constant": false,
|
|
34
|
+
"inputs": [
|
|
35
|
+
{ "name": "_from", "type": "address" },
|
|
36
|
+
{ "name": "_to", "type": "address" },
|
|
37
|
+
{ "name": "_value", "type": "uint256" }
|
|
38
|
+
],
|
|
39
|
+
"name": "transferFrom",
|
|
40
|
+
"outputs": [{ "name": "", "type": "bool" }],
|
|
41
|
+
"payable": false,
|
|
42
|
+
"stateMutability": "nonpayable",
|
|
43
|
+
"type": "function"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"constant": true,
|
|
47
|
+
"inputs": [],
|
|
48
|
+
"name": "decimals",
|
|
49
|
+
"outputs": [{ "name": "", "type": "uint8" }],
|
|
50
|
+
"payable": false,
|
|
51
|
+
"stateMutability": "view",
|
|
52
|
+
"type": "function"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"constant": true,
|
|
56
|
+
"inputs": [{ "name": "_owner", "type": "address" }],
|
|
57
|
+
"name": "balanceOf",
|
|
58
|
+
"outputs": [{ "name": "balance", "type": "uint256" }],
|
|
59
|
+
"payable": false,
|
|
60
|
+
"stateMutability": "view",
|
|
61
|
+
"type": "function"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"constant": true,
|
|
65
|
+
"inputs": [],
|
|
66
|
+
"name": "symbol",
|
|
67
|
+
"outputs": [{ "name": "", "type": "string" }],
|
|
68
|
+
"payable": false,
|
|
69
|
+
"stateMutability": "view",
|
|
70
|
+
"type": "function"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"constant": false,
|
|
74
|
+
"inputs": [
|
|
75
|
+
{ "name": "_to", "type": "address" },
|
|
76
|
+
{ "name": "_value", "type": "uint256" }
|
|
77
|
+
],
|
|
78
|
+
"name": "transfer",
|
|
79
|
+
"outputs": [{ "name": "", "type": "bool" }],
|
|
80
|
+
"payable": false,
|
|
81
|
+
"stateMutability": "nonpayable",
|
|
82
|
+
"type": "function"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"constant": true,
|
|
86
|
+
"inputs": [
|
|
87
|
+
{ "name": "_owner", "type": "address" },
|
|
88
|
+
{ "name": "_spender", "type": "address" }
|
|
89
|
+
],
|
|
90
|
+
"name": "allowance",
|
|
91
|
+
"outputs": [{ "name": "", "type": "uint256" }],
|
|
92
|
+
"payable": false,
|
|
93
|
+
"stateMutability": "view",
|
|
94
|
+
"type": "function"
|
|
95
|
+
},
|
|
96
|
+
{ "payable": true, "stateMutability": "payable", "type": "fallback" },
|
|
97
|
+
{
|
|
98
|
+
"anonymous": false,
|
|
99
|
+
"inputs": [
|
|
100
|
+
{ "indexed": true, "name": "owner", "type": "address" },
|
|
101
|
+
{ "indexed": true, "name": "spender", "type": "address" },
|
|
102
|
+
{ "indexed": false, "name": "value", "type": "uint256" }
|
|
103
|
+
],
|
|
104
|
+
"name": "Approval",
|
|
105
|
+
"type": "event"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"anonymous": false,
|
|
109
|
+
"inputs": [
|
|
110
|
+
{ "indexed": true, "name": "from", "type": "address" },
|
|
111
|
+
{ "indexed": true, "name": "to", "type": "address" },
|
|
112
|
+
{ "indexed": false, "name": "value", "type": "uint256" }
|
|
113
|
+
],
|
|
114
|
+
"name": "Transfer",
|
|
115
|
+
"type": "event"
|
|
116
|
+
}
|
|
117
|
+
]
|