@ape.swap/bonds-sdk 4.4.0-test.4 → 4.4.0-test.6
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/config/constants/addresses.d.ts +0 -1
- package/dist/hooks/useSortedZapList.d.ts +4 -1
- package/dist/main.js +133 -121
- package/dist/state/bonds/utils.d.ts +1 -1
- package/dist/views/YourBonds/fetchBillsUser.d.ts +2 -2
- package/dist/views/YourBonds/fetchBillsUserSolana.d.ts +1 -1
- package/package.json +1 -1
|
@@ -2,7 +2,6 @@ import { ChainId } from '@ape.swap/apeswap-lists';
|
|
|
2
2
|
type AddressMap = {
|
|
3
3
|
[chainId: number]: string;
|
|
4
4
|
};
|
|
5
|
-
export declare const PRICE_GETTER_ADDRESSES: AddressMap;
|
|
6
5
|
export declare const MULTICALL_V2: AddressMap;
|
|
7
6
|
export declare const SoulZapTokenManager: Partial<Record<ChainId, string>>;
|
|
8
7
|
export declare const ACF_TO_ABOND: string;
|
|
@@ -5,5 +5,8 @@ export interface SortedZapList {
|
|
|
5
5
|
balance?: string;
|
|
6
6
|
usdValue: number;
|
|
7
7
|
}
|
|
8
|
-
declare const useSortedZapList: (chainId?: ChainId, principalToken?: Token) =>
|
|
8
|
+
declare const useSortedZapList: (chainId?: ChainId, principalToken?: Token) => {
|
|
9
|
+
sortedZapList: SortedZapList[];
|
|
10
|
+
isFetched: boolean;
|
|
11
|
+
};
|
|
9
12
|
export default useSortedZapList;
|
package/dist/main.js
CHANGED
|
@@ -21862,24 +21862,6 @@ var lensContractABI = [
|
|
|
21862
21862
|
}
|
|
21863
21863
|
];
|
|
21864
21864
|
|
|
21865
|
-
({
|
|
21866
|
-
[main.ChainId.BSC]: '0x424356909715afcE9D0263dda0B27f0BC6cc638d', // Price getter V3
|
|
21867
|
-
[main.ChainId.MATIC]: '0xc5331AF02Cb72e5Df07c47f85C89ef9227418f01', // Price getter V3
|
|
21868
|
-
[main.ChainId.MAINNET]: '0xf63e25B5492A856189420724fe6f3573620966f3', // Price getter V3
|
|
21869
|
-
[main.ChainId.ARBITRUM]: '0xf1e931A569d8B3Ff5cCd11d2F42422FCABA6DBa4', // Price getter V3
|
|
21870
|
-
[main.ChainId.LINEA]: '0x4E4746b8Cfc7E57d824Dd91A80146F9C23C36d52', // Price getter V3
|
|
21871
|
-
[main.ChainId.LIGHTLINK]: '0xb4aD8df313109caaF8Fdcde9094e9d1DE41252bc', // Price getter V3
|
|
21872
|
-
[main.ChainId.IOTA]: '0x7D8f0e5964a1D05974EfD9aaff8A4154618B49f3', // Price getter V3
|
|
21873
|
-
[main.ChainId.BASE]: '0xE29C74B4DD05A268B5FFaadeF4fdbAa1de6FDe84', // Price getter V3
|
|
21874
|
-
[main.ChainId.BLAST]: '0x218EB9ACDC721E235969A30f5DA46FB1224Fa7A7', // Price getter V3
|
|
21875
|
-
[main.ChainId.AVAX]: '0x01dadaa586D30d93Ac92C79A5Cb02a8F276a8B4F', // Price getter V3
|
|
21876
|
-
[main.ChainId.CROSSFI]: '0xC22Db8dDe3A3591fFB02be868Ce2901d30671FE4', // Price getter V3
|
|
21877
|
-
[main.ChainId.SONIC]: '0xC22Db8dDe3A3591fFB02be868Ce2901d30671FE4', // Price getter V3
|
|
21878
|
-
[main.ChainId.MONAD_TESTNET]: '0x0187D959A28B0D3B490c2D898fA1CcD054cCC3cd', // Price getter V3
|
|
21879
|
-
[main.ChainId.BERACHAIN]: '0x70005Da62E17041977f7F99f91098b125CcDE1a7',
|
|
21880
|
-
[main.ChainId.UNICHAIN]: '0xE2EaDC50c2F3044065E2484B0287F1CA82fD92E1',
|
|
21881
|
-
[main.ChainId.KATANA]: '0x5fbFd1955EeA2F62F1AfD6d6E92223Ae859F7887',
|
|
21882
|
-
});
|
|
21883
21865
|
const MULTICALL_V2 = {
|
|
21884
21866
|
[main.ChainId.BSC]: '0x38ce767d81de3940CFa5020B55af1A400ED4F657',
|
|
21885
21867
|
[main.ChainId.BSC_TESTNET]: '0x67ADCB4dF3931b0C5Da724058ADC2174a9844412',
|
|
@@ -63162,14 +63144,14 @@ const defaultUrls = {
|
|
|
63162
63144
|
apiV2: 'https://api.ape.bond',
|
|
63163
63145
|
realTimeApi: 'https://realtime-api.ape.bond',
|
|
63164
63146
|
mainUrl: 'https://ape.bond',
|
|
63165
|
-
priceApi: 'https://price-api.ape.bond
|
|
63147
|
+
priceApi: 'https://price-api.ape.bond',
|
|
63166
63148
|
};
|
|
63167
63149
|
// Staging URLS.
|
|
63168
63150
|
const stagingUrls = {
|
|
63169
63151
|
apiV2: 'https://staging-api.ape.bond',
|
|
63170
63152
|
realTimeApi: 'https://realtime-api-staging.ape.bond',
|
|
63171
63153
|
mainUrl: 'https://staging.ape.bond',
|
|
63172
|
-
priceApi: 'https://price-api.ape.bond
|
|
63154
|
+
priceApi: 'https://price-api.ape.bond',
|
|
63173
63155
|
};
|
|
63174
63156
|
const useSDKConfig = (config) => {
|
|
63175
63157
|
const urls = process.env.NODE_ENV === 'production' ? defaultUrls : stagingUrls;
|
|
@@ -64754,15 +64736,14 @@ var BOND_ABI = [
|
|
|
64754
64736
|
}
|
|
64755
64737
|
];
|
|
64756
64738
|
|
|
64757
|
-
|
|
64758
|
-
const fetchUserOwnedBillsDataAsync = (chainId, account, bondData, tokenPrices) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
64739
|
+
const fetchUserOwnedBillsDataAsync = (chainId, account, bondData, tokenPrices, priceApiUrl) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
64759
64740
|
try {
|
|
64760
64741
|
if (!account) {
|
|
64761
64742
|
return [];
|
|
64762
64743
|
}
|
|
64763
64744
|
const bonds = bondData;
|
|
64764
64745
|
// Fetch and set user owned bill data without NFT Data
|
|
64765
|
-
const userOwnedBills = yield fetchUserOwnedBills(chainId, account, bonds, tokenPrices);
|
|
64746
|
+
const userOwnedBills = yield fetchUserOwnedBills(chainId, account, bonds, tokenPrices, priceApiUrl);
|
|
64766
64747
|
const mapUserOwnedBills = bonds.map((bill) => userOwnedBills.filter((b) => { var _a; return b.address.toLowerCase() === ((_a = bill.contractAddress[bill.chainId]) === null || _a === void 0 ? void 0 : _a.toLowerCase()); }));
|
|
64767
64748
|
const userOwnedBillsData = bonds.map((bill, i) => ({
|
|
64768
64749
|
index: bill.index,
|
|
@@ -64781,9 +64762,8 @@ const fetchUserOwnedBillsDataAsync = (chainId, account, bondData, tokenPrices) =
|
|
|
64781
64762
|
return Promise.reject(error);
|
|
64782
64763
|
}
|
|
64783
64764
|
});
|
|
64784
|
-
|
|
64785
|
-
|
|
64786
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
64765
|
+
const fetchUserOwnedBills = (chainId, account, bonds, tokenPrices, priceApiUrl) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
64766
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
64787
64767
|
// Maps all the bills in the list repo to make a call to each of them to get Bills Id, meaning purchased bill ids
|
|
64788
64768
|
const billIdCalls = bonds.map((b) => {
|
|
64789
64769
|
var _a;
|
|
@@ -64815,31 +64795,51 @@ const fetchUserOwnedBills = (chainId, account, bonds, tokenPrices) => __awaiter$
|
|
|
64815
64795
|
for (let i = 0; i < billVersions.length; i++) {
|
|
64816
64796
|
const billPos = i === 0 ? 0 : i * 2;
|
|
64817
64797
|
let bond = billDataCalls[billPos].bond;
|
|
64818
|
-
|
|
64819
|
-
|
|
64798
|
+
let principalTokenPrice = (_b = (_a = tokenPrices === null || tokenPrices === void 0 ? void 0 : tokenPrices[bond.chainId]) === null || _a === void 0 ? void 0 : _a.find((tokenPrice) => { var _a, _b, _c, _d; return ((_a = tokenPrice.tokenAddress) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === ((_d = (_c = (_b = bond === null || bond === void 0 ? void 0 : bond.lpToken) === null || _b === void 0 ? void 0 : _b.address) === null || _c === void 0 ? void 0 : _c[bond.chainId]) === null || _d === void 0 ? void 0 : _d.toLowerCase()); })) === null || _b === void 0 ? void 0 : _b.price;
|
|
64799
|
+
let payoutTokenPrice = (_d = (_c = tokenPrices === null || tokenPrices === void 0 ? void 0 : tokenPrices[bond.chainId]) === null || _c === void 0 ? void 0 : _c.find((tokenPrice) => { var _a, _b, _c, _d; return ((_a = tokenPrice === null || tokenPrice === void 0 ? void 0 : tokenPrice.tokenAddress) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === ((_d = (_c = (_b = bond === null || bond === void 0 ? void 0 : bond.earnToken) === null || _b === void 0 ? void 0 : _b.address) === null || _c === void 0 ? void 0 : _c[bond.chainId]) === null || _d === void 0 ? void 0 : _d.toLowerCase()); })) === null || _d === void 0 ? void 0 : _d.price;
|
|
64800
|
+
if (principalTokenPrice === undefined) {
|
|
64801
|
+
try {
|
|
64802
|
+
const res = yield axios.get(`${priceApiUrl}/price?token=${(_f = (_e = bond === null || bond === void 0 ? void 0 : bond.lpToken) === null || _e === void 0 ? void 0 : _e.address) === null || _f === void 0 ? void 0 : _f[bond === null || bond === void 0 ? void 0 : bond.chainId]}&chain=${bond === null || bond === void 0 ? void 0 : bond.chainId}`);
|
|
64803
|
+
console.log('Individual call for: ', bond.lpToken.symbol, '. Price: ', res.data.price);
|
|
64804
|
+
principalTokenPrice = parseFloat((_g = res.data.price) !== null && _g !== void 0 ? _g : '0');
|
|
64805
|
+
}
|
|
64806
|
+
catch (_y) {
|
|
64807
|
+
principalTokenPrice = 0;
|
|
64808
|
+
}
|
|
64809
|
+
}
|
|
64810
|
+
if (payoutTokenPrice === undefined) {
|
|
64811
|
+
try {
|
|
64812
|
+
const res = yield axios.get(`${priceApiUrl}/price?token=${(_j = (_h = bond === null || bond === void 0 ? void 0 : bond.earnToken) === null || _h === void 0 ? void 0 : _h.address) === null || _j === void 0 ? void 0 : _j[bond === null || bond === void 0 ? void 0 : bond.chainId]}&chain=${bond === null || bond === void 0 ? void 0 : bond.chainId}`);
|
|
64813
|
+
console.log('Individual call for: ', bond.earnToken.symbol, '. Price: ', res.data.price);
|
|
64814
|
+
payoutTokenPrice = parseFloat((_k = res.data.price) !== null && _k !== void 0 ? _k : '0');
|
|
64815
|
+
}
|
|
64816
|
+
catch (_z) {
|
|
64817
|
+
payoutTokenPrice = 0;
|
|
64818
|
+
}
|
|
64819
|
+
}
|
|
64820
64820
|
bond = Object.assign(Object.assign({}, bond), { payoutTokenPrice: payoutTokenPrice === null || payoutTokenPrice === void 0 ? void 0 : payoutTokenPrice.toString(), principalTokenPrice: principalTokenPrice === null || principalTokenPrice === void 0 ? void 0 : principalTokenPrice.toString() });
|
|
64821
64821
|
const data = billVersions[i] !== main.BillVersion.V1
|
|
64822
64822
|
? {
|
|
64823
64823
|
address: billDataCalls[billPos].address,
|
|
64824
64824
|
id: billDataCalls[billPos].params[0].toString(),
|
|
64825
|
-
payout: new BigNumber$1((
|
|
64826
|
-
.minus((
|
|
64825
|
+
payout: new BigNumber$1((_l = billData[billPos][0]) === null || _l === void 0 ? void 0 : _l.payout.toString())
|
|
64826
|
+
.minus((_m = billData[billPos][0]) === null || _m === void 0 ? void 0 : _m.payoutClaimed.toString())
|
|
64827
64827
|
.toString(),
|
|
64828
|
-
totalPayout: (
|
|
64829
|
-
payoutClaimed: (
|
|
64830
|
-
billNftAddress: (
|
|
64831
|
-
vesting: (
|
|
64832
|
-
lastBlockTimestamp: (
|
|
64833
|
-
truePricePaid: (
|
|
64828
|
+
totalPayout: (_o = billData[billPos][0]) === null || _o === void 0 ? void 0 : _o.payout.toString(),
|
|
64829
|
+
payoutClaimed: (_p = billData[billPos][0]) === null || _p === void 0 ? void 0 : _p.payoutClaimed.toString(),
|
|
64830
|
+
billNftAddress: (_q = bond.billNnftAddress[bond.chainId]) !== null && _q !== void 0 ? _q : '',
|
|
64831
|
+
vesting: (_r = billData[billPos][0]) === null || _r === void 0 ? void 0 : _r.vesting.toString(),
|
|
64832
|
+
lastBlockTimestamp: (_s = billData[billPos][0]) === null || _s === void 0 ? void 0 : _s.lastClaimTimestamp.toString(),
|
|
64833
|
+
truePricePaid: (_t = billData[billPos][0]) === null || _t === void 0 ? void 0 : _t.truePricePaid.toString(),
|
|
64834
64834
|
pendingRewards: billData[billPos + 1][0].toString(),
|
|
64835
64835
|
bond,
|
|
64836
64836
|
}
|
|
64837
64837
|
: {
|
|
64838
64838
|
address: billDataCalls[billPos].address,
|
|
64839
64839
|
id: billDataCalls[billPos].params[0].toString(),
|
|
64840
|
-
payoutClaimed: (
|
|
64840
|
+
payoutClaimed: (_w = (_v = (_u = billData === null || billData === void 0 ? void 0 : billData[billPos]) === null || _u === void 0 ? void 0 : _u[0]) === null || _v === void 0 ? void 0 : _v.payoutClaimed) === null || _w === void 0 ? void 0 : _w.toString(),
|
|
64841
64841
|
payout: billData[billPos][0].toString(),
|
|
64842
|
-
billNftAddress: (
|
|
64842
|
+
billNftAddress: (_x = bond.billNnftAddress[bond.chainId]) !== null && _x !== void 0 ? _x : '',
|
|
64843
64843
|
vesting: billData[billPos][1].toString(),
|
|
64844
64844
|
lastBlockTimestamp: billData[billPos][2].toString(),
|
|
64845
64845
|
truePricePaid: billData[billPos][3].toString(),
|
|
@@ -64866,7 +64866,7 @@ function useTokenPrices() {
|
|
|
64866
64866
|
}
|
|
64867
64867
|
const getTokenPrices = (priceApi, apiv2) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
64868
64868
|
try {
|
|
64869
|
-
const response = yield axios.get(`${priceApi}`);
|
|
64869
|
+
const response = yield axios.get(`${priceApi}/realtime/prices`);
|
|
64870
64870
|
return response.data;
|
|
64871
64871
|
}
|
|
64872
64872
|
catch (error) {
|
|
@@ -65116,9 +65116,9 @@ function getBondPricingAccountSolana(accountAddresses) {
|
|
|
65116
65116
|
});
|
|
65117
65117
|
}
|
|
65118
65118
|
|
|
65119
|
-
function fetchUserOwnedSolanaBonds(user, bondData, tokenPrices) {
|
|
65119
|
+
function fetchUserOwnedSolanaBonds(user, bondData, tokenPrices, priceApiUrl) {
|
|
65120
65120
|
return __awaiter$9(this, void 0, void 0, function* () {
|
|
65121
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
65121
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
65122
65122
|
if (!user)
|
|
65123
65123
|
return [];
|
|
65124
65124
|
try {
|
|
@@ -65149,8 +65149,18 @@ function fetchUserOwnedSolanaBonds(user, bondData, tokenPrices) {
|
|
|
65149
65149
|
const bondIssuancePda = new PublicKey(bond.contractAddress[main.ChainId.SOL]);
|
|
65150
65150
|
const userBills = [];
|
|
65151
65151
|
const collection = bond.billNnftAddress[main.ChainId.SOL];
|
|
65152
|
-
|
|
65153
|
-
|
|
65152
|
+
let principalTokenPrice = (_c = (_b = (_a = tokenPrices === null || tokenPrices === void 0 ? void 0 : tokenPrices[main.ChainId.SOL]) === null || _a === void 0 ? void 0 : _a.find) === null || _b === void 0 ? void 0 : _b.call(_a, (t) => { var _a, _b, _c, _d; return ((_a = t === null || t === void 0 ? void 0 : t.tokenAddress) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === ((_d = (_c = (_b = bond === null || bond === void 0 ? void 0 : bond.lpToken) === null || _b === void 0 ? void 0 : _b.address) === null || _c === void 0 ? void 0 : _c[main.ChainId.SOL]) === null || _d === void 0 ? void 0 : _d.toLowerCase()); })) === null || _c === void 0 ? void 0 : _c.price;
|
|
65153
|
+
let payoutTokenPrice = (_f = (_e = (_d = tokenPrices === null || tokenPrices === void 0 ? void 0 : tokenPrices[main.ChainId.SOL]) === null || _d === void 0 ? void 0 : _d.find) === null || _e === void 0 ? void 0 : _e.call(_d, (t) => { var _a, _b, _c, _d; return ((_a = t === null || t === void 0 ? void 0 : t.tokenAddress) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === ((_d = (_c = (_b = bond === null || bond === void 0 ? void 0 : bond.earnToken) === null || _b === void 0 ? void 0 : _b.address) === null || _c === void 0 ? void 0 : _c[main.ChainId.SOL]) === null || _d === void 0 ? void 0 : _d.toLowerCase()); })) === null || _f === void 0 ? void 0 : _f.price;
|
|
65154
|
+
if (principalTokenPrice === undefined) {
|
|
65155
|
+
const res = yield axios.get(`${priceApiUrl}/price?token=${(_h = (_g = bond === null || bond === void 0 ? void 0 : bond.lpToken) === null || _g === void 0 ? void 0 : _g.address) === null || _h === void 0 ? void 0 : _h[bond === null || bond === void 0 ? void 0 : bond.chainId]}&chain=${bond === null || bond === void 0 ? void 0 : bond.chainId}`);
|
|
65156
|
+
console.log('Individual call for: ', bond.lpToken.symbol, '. Price: ', res.data.price);
|
|
65157
|
+
principalTokenPrice = parseFloat((_j = res.data.price) !== null && _j !== void 0 ? _j : '0');
|
|
65158
|
+
}
|
|
65159
|
+
if (payoutTokenPrice === undefined) {
|
|
65160
|
+
const res = yield axios.get(`${priceApiUrl}/price?token=${(_l = (_k = bond === null || bond === void 0 ? void 0 : bond.earnToken) === null || _k === void 0 ? void 0 : _k.address) === null || _l === void 0 ? void 0 : _l[bond === null || bond === void 0 ? void 0 : bond.chainId]}&chain=${bond === null || bond === void 0 ? void 0 : bond.chainId}`);
|
|
65161
|
+
console.log('Individual call for: ', bond.earnToken.symbol, '. Price: ', res.data.price);
|
|
65162
|
+
payoutTokenPrice = parseFloat((_m = res.data.price) !== null && _m !== void 0 ? _m : '0');
|
|
65163
|
+
}
|
|
65154
65164
|
const userAssets = allUserAssets.filter((asset) => {
|
|
65155
65165
|
var _a;
|
|
65156
65166
|
return asset.authorities[0].address.toLowerCase() === ((_a = bond.contractAddress[main.ChainId.SOL]) === null || _a === void 0 ? void 0 : _a.toLowerCase());
|
|
@@ -65174,7 +65184,7 @@ function fetchUserOwnedSolanaBonds(user, bondData, tokenPrices) {
|
|
|
65174
65184
|
}
|
|
65175
65185
|
const bondAccount = bondAccounts[0];
|
|
65176
65186
|
const id = asset.content.metadata.name;
|
|
65177
|
-
const idTrimmed = (
|
|
65187
|
+
const idTrimmed = (_o = id.split('-')[1]) === null || _o === void 0 ? void 0 : _o.trim();
|
|
65178
65188
|
userBills.push({
|
|
65179
65189
|
address: bondPda.toBase58(),
|
|
65180
65190
|
id: idTrimmed,
|
|
@@ -65296,6 +65306,7 @@ function useUserBonds() {
|
|
|
65296
65306
|
const getUserBonds = (account, solanaAccount, bondList, queryClient) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
65297
65307
|
const { chains, urls } = queryClient === null || queryClient === void 0 ? void 0 : queryClient.getQueryData([QUERY_KEYS.SDK_CONFIG]);
|
|
65298
65308
|
const apiUrl = urls['apiV2'];
|
|
65309
|
+
const priceApiUrl = urls['priceApi'];
|
|
65299
65310
|
const tokenPrices = queryClient === null || queryClient === void 0 ? void 0 : queryClient.getQueryData([QUERY_KEYS.TOKEN_PRICES]);
|
|
65300
65311
|
try {
|
|
65301
65312
|
console.time('getUserBonds');
|
|
@@ -65322,10 +65333,10 @@ const getUserBonds = (account, solanaAccount, bondList, queryClient) => __awaite
|
|
|
65322
65333
|
.filter((chain) => bondsByChain[chain])
|
|
65323
65334
|
.map((chain) => {
|
|
65324
65335
|
if (chain === main.ChainId.SOL) {
|
|
65325
|
-
return fetchUserOwnedSolanaBonds(solanaAccount, bondsByChain[chain], tokenPrices);
|
|
65336
|
+
return fetchUserOwnedSolanaBonds(solanaAccount, bondsByChain[chain], tokenPrices, priceApiUrl);
|
|
65326
65337
|
}
|
|
65327
65338
|
else
|
|
65328
|
-
return fetchUserOwnedBillsDataAsync(chain, account, bondsByChain[chain], tokenPrices);
|
|
65339
|
+
return fetchUserOwnedBillsDataAsync(chain, account, bondsByChain[chain], tokenPrices, priceApiUrl);
|
|
65329
65340
|
}));
|
|
65330
65341
|
// Filter out only fulfilled promises
|
|
65331
65342
|
const fulfilledResults = results
|
|
@@ -75336,7 +75347,7 @@ const fetchBondsDataPreTGE = (chain, tokenPrices, preTGEBonds, apiUrl) => __awai
|
|
|
75336
75347
|
return [];
|
|
75337
75348
|
}
|
|
75338
75349
|
});
|
|
75339
|
-
const fetchBondsData = (chainId, bills, apiUrl, tokenPrices) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
75350
|
+
const fetchBondsData = (chainId, bills, apiUrl, tokenPrices, priceApiUrl) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
75340
75351
|
var _a, _b;
|
|
75341
75352
|
if (!tokenPrices)
|
|
75342
75353
|
return [];
|
|
@@ -75378,7 +75389,7 @@ const fetchBondsData = (chainId, bills, apiUrl, tokenPrices) => __awaiter$9(void
|
|
|
75378
75389
|
allBillsIds.push(...solanaBillIds);
|
|
75379
75390
|
allBillsData.push(...solanaBills);
|
|
75380
75391
|
}
|
|
75381
|
-
return yield cleanBillsData(allBillsIds, allBillsData, chainId, bills, tokenPrices);
|
|
75392
|
+
return yield cleanBillsData(allBillsIds, allBillsData, chainId, bills, tokenPrices, priceApiUrl);
|
|
75382
75393
|
}
|
|
75383
75394
|
else {
|
|
75384
75395
|
const billIds = [];
|
|
@@ -75441,7 +75452,7 @@ const fetchBondsData = (chainId, bills, apiUrl, tokenPrices) => __awaiter$9(void
|
|
|
75441
75452
|
//
|
|
75442
75453
|
const chunkSize = (updatedVals === null || updatedVals === void 0 ? void 0 : updatedVals.length) / (bills === null || bills === void 0 ? void 0 : bills.length);
|
|
75443
75454
|
const chunkedBills = lodashExports.chunk(updatedVals, chunkSize);
|
|
75444
|
-
return yield cleanBillsData(billIds, chunkedBills, chainId, bills, tokenPrices);
|
|
75455
|
+
return yield cleanBillsData(billIds, chunkedBills, chainId, bills, tokenPrices, priceApiUrl);
|
|
75445
75456
|
}
|
|
75446
75457
|
}
|
|
75447
75458
|
catch (e) {
|
|
@@ -75454,29 +75465,51 @@ const fetchBondsData = (chainId, bills, apiUrl, tokenPrices) => __awaiter$9(void
|
|
|
75454
75465
|
return [];
|
|
75455
75466
|
}
|
|
75456
75467
|
});
|
|
75457
|
-
const cleanBillsData = (billIds, chunkedBills, chainId, bills, tokenPrices) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
75468
|
+
const cleanBillsData = (billIds, chunkedBills, chainId, bills, tokenPrices, priceApiUrl) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
75458
75469
|
const data = yield Promise.all(chunkedBills === null || chunkedBills === void 0 ? void 0 : chunkedBills.map((chunk, index) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
75459
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
75470
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
75460
75471
|
const bill = bills === null || bills === void 0 ? void 0 : bills.find((bill) => (bill === null || bill === void 0 ? void 0 : bill.index) === billIds[index]);
|
|
75461
|
-
|
|
75472
|
+
let lpPrice = (_a = tokenPrices === null || tokenPrices === void 0 ? void 0 : tokenPrices.find((tokenPrice) => {
|
|
75462
75473
|
var _a, _b, _c, _d;
|
|
75463
75474
|
return ((_a = tokenPrice === null || tokenPrice === void 0 ? void 0 : tokenPrice.tokenAddress) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === ((_d = (_c = (_b = bill === null || bill === void 0 ? void 0 : bill.lpToken) === null || _b === void 0 ? void 0 : _b.address) === null || _c === void 0 ? void 0 : _c[bill === null || bill === void 0 ? void 0 : bill.chainId]) === null || _d === void 0 ? void 0 : _d.toLowerCase()) &&
|
|
75464
75475
|
(tokenPrice === null || tokenPrice === void 0 ? void 0 : tokenPrice.chainId) === chainId;
|
|
75465
|
-
})) === null || _a === void 0 ? void 0 : _a.price
|
|
75466
|
-
|
|
75476
|
+
})) === null || _a === void 0 ? void 0 : _a.price;
|
|
75477
|
+
if (lpPrice === undefined) {
|
|
75478
|
+
try {
|
|
75479
|
+
// Missing token price, therefor make a single call to api to fetch it
|
|
75480
|
+
const res = yield axios.get(`${priceApiUrl}/price?token=${(_c = (_b = bill === null || bill === void 0 ? void 0 : bill.lpToken) === null || _b === void 0 ? void 0 : _b.address) === null || _c === void 0 ? void 0 : _c[bill === null || bill === void 0 ? void 0 : bill.chainId]}&chain=${bill === null || bill === void 0 ? void 0 : bill.chainId}`);
|
|
75481
|
+
console.log('Individual call for: ', bill.lpToken.symbol, '. Price: ', res.data.price);
|
|
75482
|
+
lpPrice = parseFloat((_d = res.data.price) !== null && _d !== void 0 ? _d : '0');
|
|
75483
|
+
}
|
|
75484
|
+
catch (_r) {
|
|
75485
|
+
lpPrice = 0;
|
|
75486
|
+
}
|
|
75487
|
+
}
|
|
75488
|
+
let earnTokenPrice = (_e = tokenPrices === null || tokenPrices === void 0 ? void 0 : tokenPrices.find((tokenPrice) => {
|
|
75467
75489
|
var _a, _b, _c, _d;
|
|
75468
75490
|
return ((_a = tokenPrice === null || tokenPrice === void 0 ? void 0 : tokenPrice.tokenAddress) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === ((_d = (_c = (_b = bill === null || bill === void 0 ? void 0 : bill.earnToken) === null || _b === void 0 ? void 0 : _b.address) === null || _c === void 0 ? void 0 : _c[bill === null || bill === void 0 ? void 0 : bill.chainId]) === null || _d === void 0 ? void 0 : _d.toLowerCase()) &&
|
|
75469
75491
|
(tokenPrice === null || tokenPrice === void 0 ? void 0 : tokenPrice.chainId) === chainId;
|
|
75470
|
-
})) === null ||
|
|
75492
|
+
})) === null || _e === void 0 ? void 0 : _e.price;
|
|
75493
|
+
if (earnTokenPrice === undefined) {
|
|
75494
|
+
try {
|
|
75495
|
+
// Missing token price, therefor make a single call to api to fetch it
|
|
75496
|
+
const res = yield axios.get(`${priceApiUrl}/price?token=${(_g = (_f = bill === null || bill === void 0 ? void 0 : bill.earnToken) === null || _f === void 0 ? void 0 : _f.address) === null || _g === void 0 ? void 0 : _g[bill === null || bill === void 0 ? void 0 : bill.chainId]}&chain=${bill === null || bill === void 0 ? void 0 : bill.chainId}`);
|
|
75497
|
+
console.log('Individual call for: ', bill.earnToken.symbol, '. Price: ', res.data.price);
|
|
75498
|
+
earnTokenPrice = parseFloat((_h = res.data.price) !== null && _h !== void 0 ? _h : '0');
|
|
75499
|
+
}
|
|
75500
|
+
catch (_s) {
|
|
75501
|
+
earnTokenPrice = 0;
|
|
75502
|
+
}
|
|
75503
|
+
}
|
|
75471
75504
|
const [trueBillPriceFromChunk, totalPayoutGiven, terms, maxTotalPayout, fee, feeInPrincipal, customTreasuryBalance, bondPricing, bondTerms,] = chunk;
|
|
75472
75505
|
let trueBillPrice = trueBillPriceFromChunk;
|
|
75473
75506
|
const feeInPayout = Number(fee / 10000);
|
|
75474
75507
|
const [, vestingTerm, , maxPayout] = terms;
|
|
75475
75508
|
const tokensRemaining = new BigNumber$1(maxTotalPayout !== null && maxTotalPayout !== void 0 ? maxTotalPayout : '0')
|
|
75476
75509
|
.minus(new BigNumber$1(totalPayoutGiven))
|
|
75477
|
-
.div(new BigNumber$1(10).pow((
|
|
75510
|
+
.div(new BigNumber$1(10).pow((_j = bill === null || bill === void 0 ? void 0 : bill.earnToken.decimals[bill === null || bill === void 0 ? void 0 : bill.chainId]) !== null && _j !== void 0 ? _j : 18))
|
|
75478
75511
|
.toNumber();
|
|
75479
|
-
const treasuryBalance = getBalanceNumber(customTreasuryBalance, (
|
|
75512
|
+
const treasuryBalance = getBalanceNumber(customTreasuryBalance, (_m = (_l = (_k = bill === null || bill === void 0 ? void 0 : bill.earnToken) === null || _k === void 0 ? void 0 : _k.decimals) === null || _l === void 0 ? void 0 : _l[bill === null || bill === void 0 ? void 0 : bill.chainId]) !== null && _m !== void 0 ? _m : 18);
|
|
75480
75513
|
if (chainId === main.ChainId.SOL) {
|
|
75481
75514
|
const principalDecimals = bill === null || bill === void 0 ? void 0 : bill.lpToken.decimals[main.ChainId.SOL];
|
|
75482
75515
|
const payoutDecimals = bill === null || bill === void 0 ? void 0 : bill.earnToken.decimals[main.ChainId.SOL];
|
|
@@ -75507,7 +75540,7 @@ const cleanBillsData = (billIds, chunkedBills, chainId, bills, tokenPrices) => _
|
|
|
75507
75540
|
];
|
|
75508
75541
|
}
|
|
75509
75542
|
const cleanedData = Object.assign(Object.assign({}, bill), { feeInPayout,
|
|
75510
|
-
feeInPrincipal, showcaseTokenName: (
|
|
75543
|
+
feeInPrincipal, showcaseTokenName: (_q = (_p = (_o = bill === null || bill === void 0 ? void 0 : bill.showcaseToken) === null || _o === void 0 ? void 0 : _o.symbol) !== null && _p !== void 0 ? _p : bill === null || bill === void 0 ? void 0 : bill.earnToken.symbol) !== null && _q !== void 0 ? _q : '', trueBondPrices, principalTokenPrice: lpPrice === null || lpPrice === void 0 ? void 0 : lpPrice.toString(), payoutTokenPrice: earnTokenPrice === null || earnTokenPrice === void 0 ? void 0 : earnTokenPrice.toString(), tokensRemaining: treasuryBalance
|
|
75511
75544
|
? Math.min(treasuryBalance, tokensRemaining).toString()
|
|
75512
75545
|
: tokensRemaining.toString(), maxTotalPayout: maxTotalPayout === null || maxTotalPayout === void 0 ? void 0 : maxTotalPayout.toString(), maxPayout: maxPayout === null || maxPayout === void 0 ? void 0 : maxPayout.toString(), totalPayoutGiven: totalPayoutGiven === null || totalPayoutGiven === void 0 ? void 0 : totalPayoutGiven.toString(), vestingTerm: typeof vestingTerm === 'number' ? vestingTerm : vestingTerm.toNumber() });
|
|
75513
75546
|
return cleanedData;
|
|
@@ -75547,8 +75580,9 @@ function useBondsData() {
|
|
|
75547
75580
|
const calculateBondsData = (queryClient) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
75548
75581
|
// Fetch state from queryClient
|
|
75549
75582
|
const { chains, urls } = queryClient === null || queryClient === void 0 ? void 0 : queryClient.getQueryData([QUERY_KEYS.SDK_CONFIG]);
|
|
75550
|
-
const
|
|
75583
|
+
const realTimeApiUrl = urls['realTimeApi'];
|
|
75551
75584
|
const apiUrl = urls['apiV2'];
|
|
75585
|
+
const priceApiUrl = urls['priceApi'];
|
|
75552
75586
|
const bondList = queryClient === null || queryClient === void 0 ? void 0 : queryClient.getQueryData([QUERY_KEYS.BONDS_LIST]);
|
|
75553
75587
|
const preTGEList = queryClient === null || queryClient === void 0 ? void 0 : queryClient.getQueryData([QUERY_KEYS.BONDS_LIST_PRE_TGE]);
|
|
75554
75588
|
const tokenPrices = queryClient === null || queryClient === void 0 ? void 0 : queryClient.getQueryData([
|
|
@@ -75570,8 +75604,8 @@ const calculateBondsData = (queryClient) => __awaiter$9(void 0, void 0, void 0,
|
|
|
75570
75604
|
try {
|
|
75571
75605
|
// First, we try to fetch from realtime API
|
|
75572
75606
|
const [solBonds, evmResponse] = yield Promise.all([
|
|
75573
|
-
yield fetchBondsData(main.ChainId.SOL, reducedBonds[main.ChainId.SOL], apiUrl, tokenPrices === null || tokenPrices === void 0 ? void 0 : tokenPrices[main.ChainId.SOL]),
|
|
75574
|
-
yield axios.get(`${
|
|
75607
|
+
yield fetchBondsData(main.ChainId.SOL, reducedBonds[main.ChainId.SOL], apiUrl, tokenPrices === null || tokenPrices === void 0 ? void 0 : tokenPrices[main.ChainId.SOL], priceApiUrl),
|
|
75608
|
+
yield axios.get(`${realTimeApiUrl}/bonds`),
|
|
75575
75609
|
]);
|
|
75576
75610
|
return [...solBonds, ...evmResponse.data.bonds].filter((bond) => chains.includes(bond.chainId));
|
|
75577
75611
|
}
|
|
@@ -75584,7 +75618,7 @@ const calculateBondsData = (queryClient) => __awaiter$9(void 0, void 0, void 0,
|
|
|
75584
75618
|
var _a;
|
|
75585
75619
|
if (!reducedBonds[chainId])
|
|
75586
75620
|
return [];
|
|
75587
|
-
return (_a = (yield fetchBondsData(chainId, reducedBonds[chainId], apiUrl, tokenPrices === null || tokenPrices === void 0 ? void 0 : tokenPrices[chainId]))) !== null && _a !== void 0 ? _a : [];
|
|
75621
|
+
return ((_a = (yield fetchBondsData(chainId, reducedBonds[chainId], apiUrl, tokenPrices === null || tokenPrices === void 0 ? void 0 : tokenPrices[chainId], priceApiUrl))) !== null && _a !== void 0 ? _a : []);
|
|
75588
75622
|
})),
|
|
75589
75623
|
...chains.map((chainId) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
75590
75624
|
var _a;
|
|
@@ -76845,15 +76879,6 @@ const TokenRow = ({ token, chainId, handleTokenSelect, tokenBalance, }) => {
|
|
|
76845
76879
|
return (jsxs(Flex, { sx: { p: '8px', justifyContent: 'space-between', cursor: 'pointer', '&:hover': { background: 'white4' } }, onClick: () => handleTokenSelect(tokenAddress !== null && tokenAddress !== void 0 ? tokenAddress : ''), children: [jsxs(Flex, { children: [lodashExports.isArray(splited) ? (jsx$2(TokenImage, { symbol: splited[0], symbol2: splited[1], size: 28, chain: chainId })) : (jsx$2(TokenImage, { symbol: getSymbol(token, chainId), size: 28, chain: chainId })), jsx$2(Flex, { sx: { mx: '8px', lineHeight: '28px', fontSize: '14px' }, children: symbol })] }), accountToUse && (jsx$2(Flex, { sx: { fontSize: '14px' }, children: tokenBalance === '0' ? ('0') : !tokenBalance ? (jsx$2(Spinner, { size: 15 })) : (jsx$2(Fragment$1, { children: (_b = new BigNumber$1(tokenBalance !== null && tokenBalance !== void 0 ? tokenBalance : '0')) === null || _b === void 0 ? void 0 : _b.toPrecision(5) })) }))] }));
|
|
76846
76880
|
};
|
|
76847
76881
|
|
|
76848
|
-
function useCurrencyBalanceSolana(currency, account) {
|
|
76849
|
-
return useQuery({
|
|
76850
|
-
queryKey: [QUERY_KEYS.CURRENCY_BALANCE, account !== null && account !== void 0 ? account : '', currency === 'NATIVE' ? currency : currency === null || currency === void 0 ? void 0 : currency.symbol],
|
|
76851
|
-
queryFn: () => getTokenBalanceSolana(currency, account),
|
|
76852
|
-
refetchInterval: 10000,
|
|
76853
|
-
refetchOnWindowFocus: false,
|
|
76854
|
-
retry: 1,
|
|
76855
|
-
});
|
|
76856
|
-
}
|
|
76857
76882
|
// Use devnet or your custom cluster URL
|
|
76858
76883
|
const SOLANA_RPC_URL = getRPC(main.ChainId.SOL);
|
|
76859
76884
|
const connection = new Connection(SOLANA_RPC_URL, 'confirmed');
|
|
@@ -76974,10 +76999,10 @@ const useSortedZapList = (chainId, principalToken) => {
|
|
|
76974
76999
|
const zapList = [...((_a = main.zapInputTokens[chainId]) !== null && _a !== void 0 ? _a : []), principalToken];
|
|
76975
77000
|
//@ts-ignore
|
|
76976
77001
|
const uniqueTokensList = getUniqueTokensList(zapList, chainId, principalToken);
|
|
76977
|
-
const { data: tokenPrices } = useTokenPrices();
|
|
76978
|
-
const { data: balances } = useUserTokensBalance(uniqueTokensList, chainId);
|
|
77002
|
+
const { data: tokenPrices, isFetched: tokensFetched } = useTokenPrices();
|
|
77003
|
+
const { data: balances, isFetched: balancesFetched } = useUserTokensBalance(uniqueTokensList, chainId);
|
|
76979
77004
|
//@ts-ignore
|
|
76980
|
-
|
|
77005
|
+
const sortedZapList = uniqueTokensList
|
|
76981
77006
|
.map((list) => {
|
|
76982
77007
|
var _a, _b;
|
|
76983
77008
|
const token = list === 'NATIVE' && chainId ? main.WNATIVE[chainId] : list;
|
|
@@ -77003,6 +77028,7 @@ const useSortedZapList = (chainId, principalToken) => {
|
|
|
77003
77028
|
.sort((a, b) => {
|
|
77004
77029
|
return b.usdValue - a.usdValue;
|
|
77005
77030
|
});
|
|
77031
|
+
return { sortedZapList, isFetched: tokensFetched && balancesFetched };
|
|
77006
77032
|
};
|
|
77007
77033
|
const getUniqueTokensList = (zapList, chainId, principalToken) => {
|
|
77008
77034
|
var _a;
|
|
@@ -77019,7 +77045,7 @@ const getUniqueTokensList = (zapList, chainId, principalToken) => {
|
|
|
77019
77045
|
const TokenSelectorModal = ({ bondPrincipalToken, handleCurrencySelect, chainId, onDismiss, }) => {
|
|
77020
77046
|
var _a;
|
|
77021
77047
|
const [searchQuery, setSearchQuery] = useState('');
|
|
77022
|
-
const sortedZapList = useSortedZapList(chainId, bondPrincipalToken);
|
|
77048
|
+
const { sortedZapList } = useSortedZapList(chainId, bondPrincipalToken);
|
|
77023
77049
|
const parsedList = (_a = sortedZapList === null || sortedZapList === void 0 ? void 0 : sortedZapList.filter((token) => {
|
|
77024
77050
|
var _a;
|
|
77025
77051
|
// Search filter
|
|
@@ -79371,7 +79397,7 @@ const BuyComponent = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond,
|
|
|
79371
79397
|
const inputToken = useTokenFromZapList(inputTokenString, bondData === null || bondData === void 0 ? void 0 : bondData.chainId, bondData === null || bondData === void 0 ? void 0 : bondData.lpToken);
|
|
79372
79398
|
const isZap = (inputTokenString === null || inputTokenString === void 0 ? void 0 : inputTokenString.toLowerCase()) !== ((_e = (_d = (_c = bondData === null || bondData === void 0 ? void 0 : bondData.lpToken) === null || _c === void 0 ? void 0 : _c.address) === null || _d === void 0 ? void 0 : _d[bondData === null || bondData === void 0 ? void 0 : bondData.chainId]) === null || _e === void 0 ? void 0 : _e.toLowerCase());
|
|
79373
79399
|
const [fetchingZapQuote, zapData, zapDepositAmount, zapError, zapTrueBondPrice] = useSoulZapBondQuote(inputValue, inputToken, bondData, account, tierProofSig !== null && tierProofSig !== void 0 ? tierProofSig : undefined);
|
|
79374
|
-
const sortedZapList = useSortedZapList(bondChain, bondData === null || bondData === void 0 ? void 0 : bondData.lpToken);
|
|
79400
|
+
const { sortedZapList, isFetched: zapListFetched } = useSortedZapList(bondChain, bondData === null || bondData === void 0 ? void 0 : bondData.lpToken);
|
|
79375
79401
|
const enrichedTokenData = sortedZapList.find((item) => {
|
|
79376
79402
|
var _a, _b, _c, _d, _e;
|
|
79377
79403
|
return item.token === 'NATIVE' || inputToken === 'NATIVE'
|
|
@@ -79584,18 +79610,14 @@ const BuyComponent = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond,
|
|
|
79584
79610
|
// Effects
|
|
79585
79611
|
const [hasChecked, setHasChecked] = useState(false);
|
|
79586
79612
|
useEffect(() => {
|
|
79587
|
-
if (
|
|
79588
|
-
inputCurrencyBalance
|
|
79589
|
-
|
|
79590
|
-
|
|
79591
|
-
zapEnabled &&
|
|
79592
|
-
(sortedZapList === null || sortedZapList === void 0 ? void 0 : sortedZapList.length) > 0 &&
|
|
79593
|
-
sortedZapList[0].usdValue !== 0) {
|
|
79613
|
+
if (zapListFetched && !hasChecked) {
|
|
79614
|
+
if (parseFloat(inputCurrencyBalance !== null && inputCurrencyBalance !== void 0 ? inputCurrencyBalance : '0') < 0.0001) {
|
|
79615
|
+
setInputTokenString(sortedZapList[0].token === 'NATIVE' ? 'NATIVE' : sortedZapList[0].token.address[bondChain]);
|
|
79616
|
+
}
|
|
79594
79617
|
setHasChecked(true);
|
|
79595
|
-
setInputTokenString(sortedZapList[0].token === 'NATIVE' ? 'NATIVE' : sortedZapList[0].token.address[bondChain]);
|
|
79596
79618
|
}
|
|
79597
79619
|
/* eslint-disable react-hooks/exhaustive-deps */
|
|
79598
|
-
}, [inputCurrencyBalance,
|
|
79620
|
+
}, [inputCurrencyBalance, zapListFetched]);
|
|
79599
79621
|
// If rateChanged meaning the zap quote has a >1% difference from the true bond price, we let the user know and we update state
|
|
79600
79622
|
useEffect(() => {
|
|
79601
79623
|
if (rateChanged) {
|
|
@@ -80569,7 +80591,7 @@ const ConnectSolanaWallet = ({ navBarFlag }) => {
|
|
|
80569
80591
|
};
|
|
80570
80592
|
|
|
80571
80593
|
const BuyComponentSolana = ({ onDismiss, bondAddress, bondChain, isProjectView, setBillId, }) => {
|
|
80572
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
80594
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
80573
80595
|
const SDKConfig = useSDKConfig();
|
|
80574
80596
|
// Hooks
|
|
80575
80597
|
const { publicKey: accountSolana, signTransaction } = useSOLAccount();
|
|
@@ -80584,11 +80606,9 @@ const BuyComponentSolana = ({ onDismiss, bondAddress, bondChain, isProjectView,
|
|
|
80584
80606
|
const [inputTokenString, setInputTokenString] = useState((_b = (_a = bondData === null || bondData === void 0 ? void 0 : bondData.lpToken) === null || _a === void 0 ? void 0 : _a.address) === null || _b === void 0 ? void 0 : _b[bondData.chainId]);
|
|
80585
80607
|
// On-chain Data
|
|
80586
80608
|
const inputToken = useTokenFromZapList(inputTokenString, bondData === null || bondData === void 0 ? void 0 : bondData.chainId, bondData === null || bondData === void 0 ? void 0 : bondData.lpToken);
|
|
80587
|
-
const
|
|
80588
|
-
const { data: inputCurrencyBalance } = useCurrencyBalanceSolana(inputToken !== null && inputToken !== void 0 ? inputToken : null, (_c = accountSolana === null || accountSolana === void 0 ? void 0 : accountSolana.toBase58()) !== null && _c !== void 0 ? _c : null);
|
|
80589
|
-
const isZap = (inputTokenString === null || inputTokenString === void 0 ? void 0 : inputTokenString.toLowerCase()) !== ((_f = (_e = (_d = bondData === null || bondData === void 0 ? void 0 : bondData.lpToken) === null || _d === void 0 ? void 0 : _d.address) === null || _e === void 0 ? void 0 : _e[bondData === null || bondData === void 0 ? void 0 : bondData.chainId]) === null || _f === void 0 ? void 0 : _f.toLowerCase());
|
|
80609
|
+
const isZap = (inputTokenString === null || inputTokenString === void 0 ? void 0 : inputTokenString.toLowerCase()) !== ((_e = (_d = (_c = bondData === null || bondData === void 0 ? void 0 : bondData.lpToken) === null || _c === void 0 ? void 0 : _c.address) === null || _d === void 0 ? void 0 : _d[bondData === null || bondData === void 0 ? void 0 : bondData.chainId]) === null || _e === void 0 ? void 0 : _e.toLowerCase());
|
|
80590
80610
|
const [fetchingZapQuote, jupiterQuote, zapDepositAmount, zapError, isDirectRoute, minimumDepositAmount, wrapAndUnwrapSol,] = useJupiterSolanaQuote(inputValue, inputToken, bondData, accountSolana === null || accountSolana === void 0 ? void 0 : accountSolana.toBase58(), true, slippage);
|
|
80591
|
-
const sortedZapList = useSortedZapList(bondChain, bondData === null || bondData === void 0 ? void 0 : bondData.lpToken);
|
|
80611
|
+
const { sortedZapList, isFetched: zapListFetched } = useSortedZapList(bondChain, bondData === null || bondData === void 0 ? void 0 : bondData.lpToken);
|
|
80592
80612
|
const enrichedTokenData = sortedZapList.find((item) => {
|
|
80593
80613
|
var _a, _b, _c, _d, _e;
|
|
80594
80614
|
return item.token === 'NATIVE' || inputToken === 'NATIVE'
|
|
@@ -80596,18 +80616,14 @@ const BuyComponentSolana = ({ onDismiss, bondAddress, bondChain, isProjectView,
|
|
|
80596
80616
|
: ((_c = (_b = (_a = item === null || item === void 0 ? void 0 : item.token) === null || _a === void 0 ? void 0 : _a.address) === null || _b === void 0 ? void 0 : _b[bondChain]) === null || _c === void 0 ? void 0 : _c.toLowerCase()) ===
|
|
80597
80617
|
((_e = (_d = inputToken === null || inputToken === void 0 ? void 0 : inputToken.address) === null || _d === void 0 ? void 0 : _d[bondChain]) === null || _e === void 0 ? void 0 : _e.toLowerCase());
|
|
80598
80618
|
});
|
|
80599
|
-
const
|
|
80600
|
-
const
|
|
80601
|
-
// Use the sorted list balance/price if available, otherwise fall back to existing
|
|
80602
|
-
const finalInputCurrencyBalance = inputCurrencyBalanceFromList !== null && inputCurrencyBalanceFromList !== void 0 ? inputCurrencyBalanceFromList : inputCurrencyBalance;
|
|
80603
|
-
const finalInputTokenPrice = inputTokenPriceFromList !== null && inputTokenPriceFromList !== void 0 ? inputTokenPriceFromList : inputTokenPrice === null || inputTokenPrice === void 0 ? void 0 : inputTokenPrice.price;
|
|
80619
|
+
const inputCurrencyBalance = enrichedTokenData === null || enrichedTokenData === void 0 ? void 0 : enrichedTokenData.balance;
|
|
80620
|
+
const inputTokenPrice = enrichedTokenData === null || enrichedTokenData === void 0 ? void 0 : enrichedTokenData.price;
|
|
80604
80621
|
// Estimations - use zapDepositAmount if swapping
|
|
80605
80622
|
const depositAmount = isZap ? zapDepositAmount : inputValue;
|
|
80606
80623
|
const youSpendString = `${formatNumber$1(inputValue)} ${getSymbol(inputToken, bondData === null || bondData === void 0 ? void 0 : bondData.chainId)} =
|
|
80607
|
-
$${formatUSDNumber((parseFloat(inputValue) * (
|
|
80608
|
-
// Validations - update to use finalInputCurrencyBalance
|
|
80624
|
+
$${formatUSDNumber((parseFloat(inputValue) * (inputTokenPrice !== null && inputTokenPrice !== void 0 ? inputTokenPrice : 0)).toString())}`;
|
|
80609
80625
|
const exceedsMaxBuy = maxBuy(bondData).lt(getPayoutAmount(bondData, depositAmount, '0'));
|
|
80610
|
-
const exceedsBalance = new BigNumber$1(
|
|
80626
|
+
const exceedsBalance = new BigNumber$1(inputCurrencyBalance !== null && inputCurrencyBalance !== void 0 ? inputCurrencyBalance : '0').lt(inputValue);
|
|
80611
80627
|
// Loading State - include zap loading
|
|
80612
80628
|
const [loadingTx, setLoadingTx] = useState(false);
|
|
80613
80629
|
const load = loadingTx || (fetchingZapQuote && !!inputValue);
|
|
@@ -80617,7 +80633,7 @@ const BuyComponentSolana = ({ onDismiss, bondAddress, bondChain, isProjectView,
|
|
|
80617
80633
|
setInputTokenString(newInputToken);
|
|
80618
80634
|
}, []);
|
|
80619
80635
|
const handleBuyCallback = () => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
80620
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
80636
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
80621
80637
|
if (!accountSolana || !bondData || !inputValue || !inputToken || !bondData)
|
|
80622
80638
|
return;
|
|
80623
80639
|
track({
|
|
@@ -80626,7 +80642,7 @@ const BuyComponentSolana = ({ onDismiss, bondAddress, bondChain, isProjectView,
|
|
|
80626
80642
|
data: {
|
|
80627
80643
|
cat: bondData === null || bondData === void 0 ? void 0 : bondData.billType,
|
|
80628
80644
|
bond: bondData === null || bondData === void 0 ? void 0 : bondData.earnToken.symbol,
|
|
80629
|
-
value: parseFloat(inputValue) * (
|
|
80645
|
+
value: parseFloat(inputValue) * (inputTokenPrice !== null && inputTokenPrice !== void 0 ? inputTokenPrice : 0),
|
|
80630
80646
|
},
|
|
80631
80647
|
});
|
|
80632
80648
|
try {
|
|
@@ -80636,7 +80652,7 @@ const BuyComponentSolana = ({ onDismiss, bondAddress, bondChain, isProjectView,
|
|
|
80636
80652
|
const depositAmount = new BigNumber$1(new BigNumber$1(inputValue).times(new BigNumber$1(10).pow(bondData.lpToken.decimals[main.ChainId.SOL])));
|
|
80637
80653
|
const amountBigInt = BigInt(depositAmount.toFixed(0));
|
|
80638
80654
|
const user = accountSolana;
|
|
80639
|
-
const trueBondPriceWithoutFee = (
|
|
80655
|
+
const trueBondPriceWithoutFee = (_b = (_a = bondData === null || bondData === void 0 ? void 0 : bondData.trueBondPrices) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.trueBondPrice;
|
|
80640
80656
|
const maxPrice = new BigNumber$1(trueBondPriceWithoutFee !== null && trueBondPriceWithoutFee !== void 0 ? trueBondPriceWithoutFee : '0')
|
|
80641
80657
|
.times((100 + slippage) / 100)
|
|
80642
80658
|
.dividedBy(new BigNumber$1(1e6))
|
|
@@ -80722,12 +80738,12 @@ const BuyComponentSolana = ({ onDismiss, bondAddress, bondChain, isProjectView,
|
|
|
80722
80738
|
chain: bondChain,
|
|
80723
80739
|
data: {
|
|
80724
80740
|
cat: 'lp-buy',
|
|
80725
|
-
type: (
|
|
80741
|
+
type: (_c = bondData === null || bondData === void 0 ? void 0 : bondData.billType) !== null && _c !== void 0 ? _c : '',
|
|
80726
80742
|
typedValue: inputValue,
|
|
80727
|
-
principalToken: (
|
|
80728
|
-
earnToken: (
|
|
80729
|
-
address: remove0xPrefix((
|
|
80730
|
-
usdAmount: parseFloat(inputValue) * (
|
|
80743
|
+
principalToken: (_d = bondData === null || bondData === void 0 ? void 0 : bondData.lpToken.symbol) !== null && _d !== void 0 ? _d : '',
|
|
80744
|
+
earnToken: (_e = bondData === null || bondData === void 0 ? void 0 : bondData.earnToken.symbol) !== null && _e !== void 0 ? _e : '',
|
|
80745
|
+
address: remove0xPrefix((_f = bondData === null || bondData === void 0 ? void 0 : bondData.contractAddress) === null || _f === void 0 ? void 0 : _f[bondData.chainId]),
|
|
80746
|
+
usdAmount: parseFloat(inputValue) * (inputTokenPrice !== null && inputTokenPrice !== void 0 ? inputTokenPrice : 0),
|
|
80731
80747
|
},
|
|
80732
80748
|
});
|
|
80733
80749
|
// waits 3 seconds before triggering after-purchase flow
|
|
@@ -80739,7 +80755,7 @@ const BuyComponentSolana = ({ onDismiss, bondAddress, bondChain, isProjectView,
|
|
|
80739
80755
|
console.error('Error during bond purchase:', error);
|
|
80740
80756
|
addToastError((error === null || error === void 0 ? void 0 : error.message) || 'Unknown error');
|
|
80741
80757
|
reportError({
|
|
80742
|
-
apiUrl: (
|
|
80758
|
+
apiUrl: (_g = SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.urls) === null || _g === void 0 ? void 0 : _g.apiV2,
|
|
80743
80759
|
error: error.message,
|
|
80744
80760
|
extraInfo: { type: 'solanaBuyBond', error: error.message },
|
|
80745
80761
|
chainId: bondChain,
|
|
@@ -80810,7 +80826,7 @@ const BuyComponentSolana = ({ onDismiss, bondAddress, bondChain, isProjectView,
|
|
|
80810
80826
|
cat: 'bond',
|
|
80811
80827
|
token1: getSymbol(inputToken),
|
|
80812
80828
|
token2: (_a = bondData === null || bondData === void 0 ? void 0 : bondData.lpToken.symbol) !== null && _a !== void 0 ? _a : '',
|
|
80813
|
-
amount: parseFloat(inputValue) * (
|
|
80829
|
+
amount: parseFloat(inputValue) * (inputTokenPrice !== null && inputTokenPrice !== void 0 ? inputTokenPrice : 0),
|
|
80814
80830
|
},
|
|
80815
80831
|
});
|
|
80816
80832
|
track({
|
|
@@ -80823,7 +80839,7 @@ const BuyComponentSolana = ({ onDismiss, bondAddress, bondChain, isProjectView,
|
|
|
80823
80839
|
principalToken: (_c = bondData === null || bondData === void 0 ? void 0 : bondData.lpToken.symbol) !== null && _c !== void 0 ? _c : '',
|
|
80824
80840
|
earnToken: (_d = bondData === null || bondData === void 0 ? void 0 : bondData.earnToken.symbol) !== null && _d !== void 0 ? _d : '',
|
|
80825
80841
|
address: remove0xPrefix((_e = bondData === null || bondData === void 0 ? void 0 : bondData.contractAddress) === null || _e === void 0 ? void 0 : _e[bondData.chainId]),
|
|
80826
|
-
usdAmount: parseFloat(inputValue) * (
|
|
80842
|
+
usdAmount: parseFloat(inputValue) * (inputTokenPrice !== null && inputTokenPrice !== void 0 ? inputTokenPrice : 0),
|
|
80827
80843
|
},
|
|
80828
80844
|
});
|
|
80829
80845
|
};
|
|
@@ -80837,7 +80853,7 @@ const BuyComponentSolana = ({ onDismiss, bondAddress, bondChain, isProjectView,
|
|
|
80837
80853
|
data: {
|
|
80838
80854
|
cat: bondData === null || bondData === void 0 ? void 0 : bondData.billType,
|
|
80839
80855
|
bond: bondData === null || bondData === void 0 ? void 0 : bondData.earnToken.symbol,
|
|
80840
|
-
value: parseFloat(inputValue) * (
|
|
80856
|
+
value: parseFloat(inputValue) * (inputTokenPrice !== null && inputTokenPrice !== void 0 ? inputTokenPrice : 0),
|
|
80841
80857
|
},
|
|
80842
80858
|
});
|
|
80843
80859
|
try {
|
|
@@ -81061,19 +81077,15 @@ const BuyComponentSolana = ({ onDismiss, bondAddress, bondChain, isProjectView,
|
|
|
81061
81077
|
// Effects
|
|
81062
81078
|
const [hasChecked, setHasChecked] = useState(false);
|
|
81063
81079
|
useEffect(() => {
|
|
81064
|
-
if (
|
|
81065
|
-
parseFloat(inputCurrencyBalance !== null && inputCurrencyBalance !== void 0 ? inputCurrencyBalance : '0') < 0.0001
|
|
81066
|
-
|
|
81067
|
-
|
|
81068
|
-
supportedByLIFI.includes(bondChain) &&
|
|
81069
|
-
(sortedZapList === null || sortedZapList === void 0 ? void 0 : sortedZapList.length) > 0 &&
|
|
81070
|
-
sortedZapList[0].usdValue !== 0) {
|
|
81080
|
+
if (zapListFetched && !hasChecked) {
|
|
81081
|
+
if (parseFloat(inputCurrencyBalance !== null && inputCurrencyBalance !== void 0 ? inputCurrencyBalance : '0') < 0.0001) {
|
|
81082
|
+
setInputTokenString(sortedZapList[0].token === 'NATIVE' ? 'NATIVE' : sortedZapList[0].token.address[bondChain]);
|
|
81083
|
+
}
|
|
81071
81084
|
setHasChecked(true);
|
|
81072
|
-
setInputTokenString(sortedZapList[0].token === 'NATIVE' ? 'NATIVE' : sortedZapList[0].token.address[bondChain]);
|
|
81073
81085
|
}
|
|
81074
81086
|
/* eslint-disable react-hooks/exhaustive-deps */
|
|
81075
|
-
}, [inputCurrencyBalance,
|
|
81076
|
-
return bondData ? (jsx$2(Flex, { className: "modal-content", sx: Object.assign({}, buyComponentStyles[(
|
|
81087
|
+
}, [inputCurrencyBalance, zapListFetched]);
|
|
81088
|
+
return bondData ? (jsx$2(Flex, { className: "modal-content", sx: Object.assign({}, buyComponentStyles[(_f = bondData === null || bondData === void 0 ? void 0 : bondData.billArt) === null || _f === void 0 ? void 0 : _f.collection]), children: jsxs(Flex, { className: "modaltable-container", children: [jsx$2(BondModalHeader, { bondData: bondData, onDismiss: onDismiss }), jsx$2(ProjectDescription, { description: bondData.shortDescription, isProjectView: true }), jsx$2(Flex, { sx: { width: '100%', display: isProjectView ? ['flex', 'flex', 'flex', 'none'] : 'flex' }, children: jsx$2(BondCards, { bondData: bondData }) }), jsx$2(Estimations, { depositAmount: depositAmount, bondData: bondData, youSpendString: youSpendString, isZap: isZap, fetchingZapQuote: fetchingZapQuote, zapError: zapError }), jsx$2(TokenSelectorPanel, { typedValue: inputValue, setTypedValue: setInputValue, selectedToken: inputToken, handleValueBtn: () => { var _a; return setInputValue((_a = new BigNumber$1(inputCurrencyBalance !== null && inputCurrencyBalance !== void 0 ? inputCurrencyBalance : '0')) === null || _a === void 0 ? void 0 : _a.toString()); }, handleCurrencySelect: handleCurrencySelect, bondChainId: bondData === null || bondData === void 0 ? void 0 : bondData.chainId, enableZap: true, bondPrincipalToken: bondData === null || bondData === void 0 ? void 0 : bondData.lpToken, tokenBalance: inputCurrencyBalance !== null && inputCurrencyBalance !== void 0 ? inputCurrencyBalance : undefined, selectedTokenPrice: inputTokenPrice }), (bondData === null || bondData === void 0 ? void 0 : bondData.warningCard) && (jsx$2(Flex, { sx: {
|
|
81077
81089
|
width: '100%',
|
|
81078
81090
|
background: '#DE62F366',
|
|
81079
81091
|
justifyContent: 'center',
|
|
@@ -81083,7 +81095,7 @@ const BuyComponentSolana = ({ onDismiss, bondAddress, bondChain, isProjectView,
|
|
|
81083
81095
|
}, children: jsxs(Text, { sx: { fontSize: '12px', fontWeight: 400, display: 'flex', alignItems: 'center', gap: '10px' }, children: [jsx$2(SafeHTMLComponent, { html: bondData === null || bondData === void 0 ? void 0 : bondData.warningCard }), (bondData === null || bondData === void 0 ? void 0 : bondData.chainId) === main.ChainId.SONIC && (bondData === null || bondData === void 0 ? void 0 : bondData.earnToken.symbol.toLowerCase()) === 'moon' && (jsx$2(TooltipBubble, { className: "tooltip-bubble", body: jsx$2(Text, { sx: { textTransform: 'none' }, children: "Open the 'cog' icon menu in the top right and set the Slippage Tolerance to 5% or more." }), width: "315px", placement: "topRight", transformTip: "translate(9%, -10%)", children: jsx$2(Svg, { icon: "questionCircle", width: 14, color: "textDisabledButton" }) }))] }) })), jsx$2(Flex, { className: "modaltable-container button-container", children: jsx$2(Flex, { className: "button-container buy", children: !accountSolana ? (jsx$2(ConnectSolanaWallet, {})) : (jsxs(Flex, { sx: { width: '100%', gap: '10px', flexDirection: ['column', 'column', 'column', 'row'] }, children: [jsxs(Button, { variant: "secondary", onClick: () => {
|
|
81084
81096
|
var _a, _b;
|
|
81085
81097
|
return window.open(`https://jumper.exchange/?fromChain=1151111081099710&fromToken=11111111111111111111111111111111&toChain=1151111081099710&toToken=${(_b = (_a = bondData === null || bondData === void 0 ? void 0 : bondData.lpToken) === null || _a === void 0 ? void 0 : _a.address) === null || _b === void 0 ? void 0 : _b[bondData === null || bondData === void 0 ? void 0 : bondData.chainId]}`, '_blank', 'noopener noreferrer');
|
|
81086
|
-
}, sx: { width: ['100%', '100%', '100%', '35%'] }, children: ["get ", (
|
|
81098
|
+
}, sx: { width: ['100%', '100%', '100%', '35%'] }, children: ["get ", (_g = bondData === null || bondData === void 0 ? void 0 : bondData.lpToken) === null || _g === void 0 ? void 0 : _g.symbol] }), jsx$2(Button, { className: "action-button", load: load, disabled: load ||
|
|
81087
81099
|
(bondData === null || bondData === void 0 ? void 0 : bondData.soldOut) ||
|
|
81088
81100
|
!accountSolana ||
|
|
81089
81101
|
!inputValue ||
|
|
@@ -2,5 +2,5 @@ import { BondsData } from '../../types/bonds';
|
|
|
2
2
|
import { BillsConfig, ChainId, PreTGEConfig } from '@ape.swap/apeswap-lists';
|
|
3
3
|
import { TokenPrices } from '../tokenPrices/useTokenPrices';
|
|
4
4
|
export declare const fetchBondsDataPreTGE: (chain: number, tokenPrices: Partial<Record<ChainId, TokenPrices[]>>, preTGEBonds: PreTGEConfig[], apiUrl?: string) => Promise<BondsData[]>;
|
|
5
|
-
export declare const fetchBondsData: (chainId: number, bills: BillsConfig[], apiUrl: string, tokenPrices?: TokenPrices[]) => Promise<BondsData[]>;
|
|
5
|
+
export declare const fetchBondsData: (chainId: number, bills: BillsConfig[], apiUrl: string, tokenPrices?: TokenPrices[], priceApiUrl?: string) => Promise<BondsData[]>;
|
|
6
6
|
export declare const getBonusWithFee: (feeInPayout: number, trueBillPrice: string, lpPrice: number, earnTokenPrice: number) => number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UserBill, UserOwnedBillsData } from '../../types/yourbonds';
|
|
2
2
|
import { BillsConfig, ChainId } from '@ape.swap/apeswap-lists';
|
|
3
3
|
import { TokenPrices } from '../../state/tokenPrices/useTokenPrices';
|
|
4
|
-
export declare const fetchUserOwnedBillsDataAsync: (chainId: ChainId, account: string, bondData: BillsConfig[], tokenPrices: Partial<Record<ChainId, TokenPrices[]
|
|
5
|
-
export declare const fetchUserOwnedBills: (chainId: ChainId, account: string, bonds: BillsConfig[], tokenPrices: Partial<Record<ChainId, TokenPrices[]
|
|
4
|
+
export declare const fetchUserOwnedBillsDataAsync: (chainId: ChainId, account: string, bondData: BillsConfig[], tokenPrices: Partial<Record<ChainId, TokenPrices[]>>, priceApiUrl?: string) => Promise<UserOwnedBillsData[]>;
|
|
5
|
+
export declare const fetchUserOwnedBills: (chainId: ChainId, account: string, bonds: BillsConfig[], tokenPrices: Partial<Record<ChainId, TokenPrices[]>>, priceApiUrl?: string) => Promise<UserBill[]>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { BillsConfig, ChainId } from '@ape.swap/apeswap-lists';
|
|
2
2
|
import { UserOwnedBillsData } from '../../types/yourbonds';
|
|
3
3
|
import { TokenPrices } from '../../state/tokenPrices/useTokenPrices';
|
|
4
|
-
export declare function fetchUserOwnedSolanaBonds(user: string, bondData: BillsConfig[], tokenPrices: Partial<Record<ChainId, TokenPrices[]
|
|
4
|
+
export declare function fetchUserOwnedSolanaBonds(user: string, bondData: BillsConfig[], tokenPrices: Partial<Record<ChainId, TokenPrices[]>>, priceApiUrl?: string): Promise<UserOwnedBillsData[]>;
|