@ape.swap/bonds-sdk 1.0.352 → 1.0.354
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 +40 -66
- package/dist/components/YourBonds/fetchBillsUser.d.ts +3 -3
- package/dist/components/YourBonds/fetchBillsUser.js +4 -4
- package/dist/types/bonds.d.ts +0 -62
- package/dist/types/yourbonds.d.ts +0 -4
- package/package.json +1 -1
- package/dist/config/abi/erc20.json +0 -117
- package/dist/config/abi/price-getter-linea.json +0 -1448
- package/dist/config/abi/price-getter.json +0 -1309
- package/dist/hooks/PriceGetter/usePricesFromPriceGetter.d.ts +0 -17
- package/dist/hooks/PriceGetter/usePricesFromPriceGetter.js +0 -205
- 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
- package/dist/state/tokenPrices/fetchTokenPricesForMultipleChains.d.ts +0 -4
- package/dist/state/tokenPrices/fetchTokenPricesForMultipleChains.js +0 -68
- package/dist/state/tokenPrices/getAllTokenPrices.d.ts +0 -5
- package/dist/state/tokenPrices/getAllTokenPrices.js +0 -288
- package/dist/state/tokenPrices/useTokenPricesNew.d.ts +0 -11
- package/dist/state/tokenPrices/useTokenPricesNew.js +0 -72
- package/dist/types/dexFactories.d.ts +0 -11
- package/dist/types/dexFactories.js +0 -2
|
@@ -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(bondAddress, amount)];
|
|
224
224
|
case 2:
|
|
225
225
|
tx = _a.sent();
|
|
226
226
|
return [4 /*yield*/, tx.wait()];
|
|
@@ -69,7 +69,6 @@ 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';
|
|
73
72
|
var YourBonds = function (_a) {
|
|
74
73
|
var connectionString = _a.connectionString;
|
|
75
74
|
var _b = useWeb3React(), account = _b.account, isActive = _b.isActive;
|
|
@@ -161,16 +160,26 @@ var YourBonds = function (_a) {
|
|
|
161
160
|
setIsModalOpen(true);
|
|
162
161
|
navigate("/YourBonds/?bondAddress=".concat(bond.billAddress, "&bondChain=").concat(bond.chainId), { replace: true });
|
|
163
162
|
};
|
|
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
|
+
// }
|
|
164
173
|
var currentTime = useCurrentTime() / 1000;
|
|
165
174
|
var vestingTimeRemaining = function (userBill) {
|
|
166
175
|
return getTimePeriods(parseInt(userBill.lastBlockTimestamp) + parseInt(userBill.vesting) - currentTime, true);
|
|
167
176
|
};
|
|
168
177
|
var fetchUserOwnedBillsDataAsync = function (chainId, account) { return __awaiter(void 0, void 0, void 0, function () {
|
|
169
|
-
var bonds, userOwnedBills_1, mapUserOwnedBills_1, userOwnedBillsData_1,
|
|
178
|
+
var bonds, userOwnedBills_1, mapUserOwnedBills_1, userOwnedBillsData_1, error_2;
|
|
170
179
|
return __generator(this, function (_a) {
|
|
171
180
|
switch (_a.label) {
|
|
172
181
|
case 0:
|
|
173
|
-
_a.trys.push([0,
|
|
182
|
+
_a.trys.push([0, 2, , 3]);
|
|
174
183
|
bonds = bondData.filter(function (bond) {
|
|
175
184
|
return bond.billVersion !== BillVersion.FixedPrice &&
|
|
176
185
|
(bond === null || bond === void 0 ? void 0 : bond.chainId) === chainId &&
|
|
@@ -187,50 +196,41 @@ var YourBonds = function (_a) {
|
|
|
187
196
|
index: bill.index,
|
|
188
197
|
userOwnedBills: mapUserOwnedBills_1[i],
|
|
189
198
|
}); });
|
|
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
|
-
// const ownedBillsWithNftData = mapUserOwnedBills.map((bs: any, index: number) => {
|
|
197
|
-
// return {
|
|
198
|
-
// index: bonds[index].index,
|
|
199
|
-
// userOwnedBillsNfts: bs.map((b: any) => {
|
|
200
|
-
// const nftData = userBillNftData.find((nftB) => parseInt(nftB.id) === b.id);
|
|
201
|
-
// return {
|
|
202
|
-
// ...b,
|
|
203
|
-
// ...nftData
|
|
204
|
-
// } as UserBillNftData;
|
|
205
|
-
// }),
|
|
206
|
-
// };
|
|
207
|
-
// });
|
|
208
|
-
// Combine userBillNftData with userOwnedBillsData
|
|
209
|
-
];
|
|
210
|
-
case 2:
|
|
211
|
-
userBillNftData_1 = _a.sent();
|
|
212
|
-
combinedData = ownedBillsData.map(function (ownedBill) {
|
|
213
|
-
var nftData = userBillNftData_1.find(function (nft) { return nft.id === parseInt(ownedBill.id); });
|
|
214
|
-
return __assign(__assign({}, ownedBill), { image: nftData === null || nftData === void 0 ? void 0 : nftData.data.image, attributes: nftData === null || nftData === void 0 ? void 0 : nftData.data.attributes });
|
|
215
|
-
});
|
|
216
|
-
console.log("userBillNftData");
|
|
217
|
-
console.log(userBillNftData_1);
|
|
218
|
-
console.log("userBillNftData");
|
|
219
|
-
console.log("userOwnedBillsData");
|
|
220
|
-
console.log(userOwnedBillsData_1);
|
|
221
|
-
console.log("userOwnedBillsData");
|
|
222
|
-
console.log("combinedData");
|
|
223
|
-
console.log(combinedData);
|
|
224
|
-
console.log("combinedData");
|
|
225
199
|
return [2 /*return*/, Promise.resolve(userOwnedBillsData_1)];
|
|
226
|
-
case
|
|
200
|
+
case 2:
|
|
227
201
|
error_2 = _a.sent();
|
|
228
202
|
console.error('Error fetching user owned bills data:', error_2);
|
|
229
203
|
return [2 /*return*/, Promise.reject(error_2)];
|
|
230
|
-
case
|
|
204
|
+
case 3: return [2 /*return*/];
|
|
231
205
|
}
|
|
232
206
|
});
|
|
233
207
|
}); };
|
|
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
234
|
var fetchUserOwnedBills = function (chainId, account, bonds) { return __awaiter(void 0, void 0, void 0, function () {
|
|
235
235
|
var billIdCalls, billIds, billsPendingRewardCall, billDataCalls, billVersions, billData, pendingRewardsCall, result, i, billDataPos, data;
|
|
236
236
|
var _a, _b, _c, _d, _e;
|
|
@@ -307,32 +307,6 @@ var YourBonds = function (_a) {
|
|
|
307
307
|
}
|
|
308
308
|
});
|
|
309
309
|
}); };
|
|
310
|
-
var _g = useState([]), userOwnedBillsData = _g[0], setUserOwnedBillsData = _g[1];
|
|
311
|
-
useEffect(function () {
|
|
312
|
-
var fetchData = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
313
|
-
var results, error_3;
|
|
314
|
-
return __generator(this, function (_a) {
|
|
315
|
-
switch (_a.label) {
|
|
316
|
-
case 0:
|
|
317
|
-
if (!account) return [3 /*break*/, 4];
|
|
318
|
-
_a.label = 1;
|
|
319
|
-
case 1:
|
|
320
|
-
_a.trys.push([1, 3, , 4]);
|
|
321
|
-
return [4 /*yield*/, Promise.all(MAINNET_CHAINS.map(function (chain) { return fetchUserOwnedBillsDataAsync(chain, account); }))];
|
|
322
|
-
case 2:
|
|
323
|
-
results = _a.sent();
|
|
324
|
-
setUserOwnedBillsData(results);
|
|
325
|
-
return [3 /*break*/, 4];
|
|
326
|
-
case 3:
|
|
327
|
-
error_3 = _a.sent();
|
|
328
|
-
console.error('Error fetching user owned bills data:', error_3);
|
|
329
|
-
return [3 /*break*/, 4];
|
|
330
|
-
case 4: return [2 /*return*/];
|
|
331
|
-
}
|
|
332
|
-
});
|
|
333
|
-
}); };
|
|
334
|
-
fetchData();
|
|
335
|
-
}, [account]);
|
|
336
310
|
var chainId = useWeb3React().chainId;
|
|
337
311
|
var totalPending = function (userBill) {
|
|
338
312
|
var _a, _b, _c, _d;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ChainId } from '@ape.swap/apeswap-lists';
|
|
2
|
+
import { Bills, CleanedBondsState, UserBill } from '../../types/bonds';
|
|
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: (CleanedBondsState | Bills)[]) => 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';
|
|
40
41
|
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;
|
|
58
59
|
var id = _a.id, billNftAddress = _a.billNftAddress, contractAddress = _a.contractAddress;
|
|
59
|
-
var bill = bills
|
|
60
|
-
.find(function (b) { return b.
|
|
61
|
-
// ?.userOwnedBillsNftData?.find((u) => +u.tokenId === +id)
|
|
60
|
+
var bill = (_c = (_b = bills
|
|
61
|
+
.find(function (b) { return b.contractAddress[chainId] === contractAddress; })) === null || _b === void 0 ? void 0 : _b.userOwnedBillsNftData) === null || _c === void 0 ? void 0 : _c.find(function (u) { return +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 });
|
package/dist/types/bonds.d.ts
CHANGED
|
@@ -46,68 +46,6 @@ export interface UserBillNft {
|
|
|
46
46
|
value: string;
|
|
47
47
|
}[];
|
|
48
48
|
}
|
|
49
|
-
export interface UserBillNftData {
|
|
50
|
-
id: number;
|
|
51
|
-
data: {
|
|
52
|
-
name: string;
|
|
53
|
-
description: string;
|
|
54
|
-
tokenId: number;
|
|
55
|
-
image: string;
|
|
56
|
-
attributes: {
|
|
57
|
-
trait_type: string;
|
|
58
|
-
value: string;
|
|
59
|
-
}[];
|
|
60
|
-
data: {
|
|
61
|
-
billContract: string;
|
|
62
|
-
billNftAddress: string;
|
|
63
|
-
payout: number;
|
|
64
|
-
deposit: number;
|
|
65
|
-
createTransactionHash: string;
|
|
66
|
-
billNftId: number;
|
|
67
|
-
expires: number;
|
|
68
|
-
vestingPeriodSeconds: number;
|
|
69
|
-
payoutToken: string;
|
|
70
|
-
principalToken: string;
|
|
71
|
-
type: string;
|
|
72
|
-
pairName: string;
|
|
73
|
-
payoutTokenData: {
|
|
74
|
-
address: string;
|
|
75
|
-
name: string;
|
|
76
|
-
symbol: string;
|
|
77
|
-
decimals: {
|
|
78
|
-
[chainId: number]: number;
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
token0: {
|
|
82
|
-
address: string;
|
|
83
|
-
symbol: string;
|
|
84
|
-
name: string;
|
|
85
|
-
decimals: {
|
|
86
|
-
[chainId: number]: number;
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
token1: {
|
|
90
|
-
address: string;
|
|
91
|
-
symbol: string;
|
|
92
|
-
name: string;
|
|
93
|
-
decimals: {
|
|
94
|
-
[chainId: number]: number;
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
|
-
dollarValue: number;
|
|
98
|
-
chainId: ChainId;
|
|
99
|
-
blockNumber: number;
|
|
100
|
-
bondArtCollection: string;
|
|
101
|
-
bondPartner: string;
|
|
102
|
-
bondVersion: string;
|
|
103
|
-
createdAddressOwner: string;
|
|
104
|
-
createdAt: number;
|
|
105
|
-
payoutTokenPrice: string;
|
|
106
|
-
};
|
|
107
|
-
contractAddress: string;
|
|
108
|
-
chainId: ChainId;
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
49
|
export interface UserBill {
|
|
112
50
|
address: string;
|
|
113
51
|
id: string;
|
package/package.json
CHANGED
|
@@ -1,117 +0,0 @@
|
|
|
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
|
-
]
|