@ape.swap/bonds-sdk 3.0.24 → 3.0.25
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/main.js +284 -368
- package/dist/types/bonds.d.ts +1 -0
- package/package.json +2 -2
package/dist/main.js
CHANGED
|
@@ -17904,8 +17904,10 @@ var types = {};
|
|
|
17904
17904
|
exports.defaultBillArtCollection =
|
|
17905
17905
|
exports.BillArtCollection =
|
|
17906
17906
|
exports.BillVersion =
|
|
17907
|
-
exports.Wrappers =
|
|
17908
17907
|
exports.Protocols =
|
|
17908
|
+
exports.ProtocolsWithWrapper =
|
|
17909
|
+
exports.Wrappers =
|
|
17910
|
+
exports.PriceApiProtocols =
|
|
17909
17911
|
exports.ZapVersion =
|
|
17910
17912
|
exports.IchiSupportedDex =
|
|
17911
17913
|
exports.LiquidityDex =
|
|
@@ -17988,6 +17990,8 @@ var types = {};
|
|
|
17988
17990
|
LiquidityDex['Synthswap'] = 'Synthswap';
|
|
17989
17991
|
LiquidityDex['Aerodrome'] = 'Aerodrome';
|
|
17990
17992
|
LiquidityDex['SmarDex'] = 'SmarDex';
|
|
17993
|
+
LiquidityDex['TrebleSwapV2'] = 'TrebleSwap V2';
|
|
17994
|
+
LiquidityDex['TrebleAlgebraIntegral'] = 'Treble Algebra Integral';
|
|
17991
17995
|
//IOTA
|
|
17992
17996
|
LiquidityDex['MagicSea'] = 'MagicSea';
|
|
17993
17997
|
//ARBITRUM
|
|
@@ -18043,6 +18047,29 @@ var types = {};
|
|
|
18043
18047
|
ZapVersion['SoulZap'] = 'SoulZap';
|
|
18044
18048
|
ZapVersion['SoulZapApi'] = 'SoulZapApi';
|
|
18045
18049
|
})((ZapVersion = exports.ZapVersion || (exports.ZapVersion = {})));
|
|
18050
|
+
//Price API Protocols
|
|
18051
|
+
var PriceApiProtocols
|
|
18052
|
+
;(function (PriceApiProtocols) {
|
|
18053
|
+
PriceApiProtocols[(PriceApiProtocols['UniV2'] = 0)] = 'UniV2';
|
|
18054
|
+
PriceApiProtocols[(PriceApiProtocols['UniV3'] = 1)] = 'UniV3';
|
|
18055
|
+
PriceApiProtocols[(PriceApiProtocols['UniV4'] = 2)] = 'UniV4';
|
|
18056
|
+
PriceApiProtocols[(PriceApiProtocols['Algebra'] = 3)] = 'Algebra';
|
|
18057
|
+
PriceApiProtocols[(PriceApiProtocols['AlgebraIntegral'] = 4)] = 'AlgebraIntegral';
|
|
18058
|
+
PriceApiProtocols[(PriceApiProtocols['Solidly'] = 5)] = 'Solidly';
|
|
18059
|
+
PriceApiProtocols[(PriceApiProtocols['Curve'] = 6)] = 'Curve';
|
|
18060
|
+
})((PriceApiProtocols = exports.PriceApiProtocols || (exports.PriceApiProtocols = {})));
|
|
18061
|
+
(function (Wrappers) {
|
|
18062
|
+
Wrappers[(Wrappers['Gamma'] = 0)] = 'Gamma';
|
|
18063
|
+
Wrappers[(Wrappers['Ichi'] = 1)] = 'Ichi';
|
|
18064
|
+
Wrappers[(Wrappers['Steer'] = 2)] = 'Steer';
|
|
18065
|
+
})((exports.Wrappers || (exports.Wrappers = {})));
|
|
18066
|
+
exports.ProtocolsWithWrapper = [
|
|
18067
|
+
PriceApiProtocols.UniV3,
|
|
18068
|
+
PriceApiProtocols.UniV4,
|
|
18069
|
+
PriceApiProtocols.Algebra,
|
|
18070
|
+
PriceApiProtocols.AlgebraIntegral,
|
|
18071
|
+
];
|
|
18072
|
+
//Protocols
|
|
18046
18073
|
var Protocols
|
|
18047
18074
|
;(function (Protocols) {
|
|
18048
18075
|
Protocols[(Protocols['Both'] = 1)] = 'Both';
|
|
@@ -18056,11 +18083,6 @@ var types = {};
|
|
|
18056
18083
|
Protocols[(Protocols['Curve'] = 9)] = 'Curve';
|
|
18057
18084
|
Protocols[(Protocols['AlgebraIntegral'] = 10)] = 'AlgebraIntegral';
|
|
18058
18085
|
})((Protocols = exports.Protocols || (exports.Protocols = {})));
|
|
18059
|
-
(function (Wrappers) {
|
|
18060
|
-
Wrappers[(Wrappers['Gamma'] = 0)] = 'Gamma';
|
|
18061
|
-
Wrappers[(Wrappers['Ichi'] = 1)] = 'Ichi';
|
|
18062
|
-
Wrappers[(Wrappers['Steer'] = 2)] = 'Steer';
|
|
18063
|
-
})((exports.Wrappers || (exports.Wrappers = {})));
|
|
18064
18086
|
(function (BillVersion) {
|
|
18065
18087
|
BillVersion['V1'] = 'V1';
|
|
18066
18088
|
BillVersion['V2'] = 'V2';
|
|
@@ -18640,6 +18662,8 @@ var types = {};
|
|
|
18640
18662
|
(_6[LiquidityDex.ShadowExchange] = {}),
|
|
18641
18663
|
(_6[LiquidityDex.SwapX] = {}),
|
|
18642
18664
|
(_6[LiquidityDex.SwapXAlgebraIntegral] = {}),
|
|
18665
|
+
(_6[LiquidityDex.TrebleSwapV2] = {}),
|
|
18666
|
+
(_6[LiquidityDex.TrebleAlgebraIntegral] = {}),
|
|
18643
18667
|
_6);
|
|
18644
18668
|
|
|
18645
18669
|
} (types));
|
|
@@ -68652,233 +68676,6 @@ const zapInputTokens = {
|
|
|
68652
68676
|
],
|
|
68653
68677
|
};
|
|
68654
68678
|
|
|
68655
|
-
var ERC_20_ABI = [
|
|
68656
|
-
{
|
|
68657
|
-
constant: true,
|
|
68658
|
-
inputs: [
|
|
68659
|
-
],
|
|
68660
|
-
name: "name",
|
|
68661
|
-
outputs: [
|
|
68662
|
-
{
|
|
68663
|
-
name: "",
|
|
68664
|
-
type: "string"
|
|
68665
|
-
}
|
|
68666
|
-
],
|
|
68667
|
-
payable: false,
|
|
68668
|
-
stateMutability: "view",
|
|
68669
|
-
type: "function"
|
|
68670
|
-
},
|
|
68671
|
-
{
|
|
68672
|
-
constant: false,
|
|
68673
|
-
inputs: [
|
|
68674
|
-
{
|
|
68675
|
-
name: "_spender",
|
|
68676
|
-
type: "address"
|
|
68677
|
-
},
|
|
68678
|
-
{
|
|
68679
|
-
name: "_value",
|
|
68680
|
-
type: "uint256"
|
|
68681
|
-
}
|
|
68682
|
-
],
|
|
68683
|
-
name: "approve",
|
|
68684
|
-
outputs: [
|
|
68685
|
-
{
|
|
68686
|
-
name: "",
|
|
68687
|
-
type: "bool"
|
|
68688
|
-
}
|
|
68689
|
-
],
|
|
68690
|
-
payable: false,
|
|
68691
|
-
stateMutability: "nonpayable",
|
|
68692
|
-
type: "function"
|
|
68693
|
-
},
|
|
68694
|
-
{
|
|
68695
|
-
constant: true,
|
|
68696
|
-
inputs: [
|
|
68697
|
-
],
|
|
68698
|
-
name: "totalSupply",
|
|
68699
|
-
outputs: [
|
|
68700
|
-
{
|
|
68701
|
-
name: "",
|
|
68702
|
-
type: "uint256"
|
|
68703
|
-
}
|
|
68704
|
-
],
|
|
68705
|
-
payable: false,
|
|
68706
|
-
stateMutability: "view",
|
|
68707
|
-
type: "function"
|
|
68708
|
-
},
|
|
68709
|
-
{
|
|
68710
|
-
constant: false,
|
|
68711
|
-
inputs: [
|
|
68712
|
-
{
|
|
68713
|
-
name: "_from",
|
|
68714
|
-
type: "address"
|
|
68715
|
-
},
|
|
68716
|
-
{
|
|
68717
|
-
name: "_to",
|
|
68718
|
-
type: "address"
|
|
68719
|
-
},
|
|
68720
|
-
{
|
|
68721
|
-
name: "_value",
|
|
68722
|
-
type: "uint256"
|
|
68723
|
-
}
|
|
68724
|
-
],
|
|
68725
|
-
name: "transferFrom",
|
|
68726
|
-
outputs: [
|
|
68727
|
-
{
|
|
68728
|
-
name: "",
|
|
68729
|
-
type: "bool"
|
|
68730
|
-
}
|
|
68731
|
-
],
|
|
68732
|
-
payable: false,
|
|
68733
|
-
stateMutability: "nonpayable",
|
|
68734
|
-
type: "function"
|
|
68735
|
-
},
|
|
68736
|
-
{
|
|
68737
|
-
constant: true,
|
|
68738
|
-
inputs: [
|
|
68739
|
-
],
|
|
68740
|
-
name: "decimals",
|
|
68741
|
-
outputs: [
|
|
68742
|
-
{
|
|
68743
|
-
name: "",
|
|
68744
|
-
type: "uint8"
|
|
68745
|
-
}
|
|
68746
|
-
],
|
|
68747
|
-
payable: false,
|
|
68748
|
-
stateMutability: "view",
|
|
68749
|
-
type: "function"
|
|
68750
|
-
},
|
|
68751
|
-
{
|
|
68752
|
-
constant: true,
|
|
68753
|
-
inputs: [
|
|
68754
|
-
{
|
|
68755
|
-
name: "_owner",
|
|
68756
|
-
type: "address"
|
|
68757
|
-
}
|
|
68758
|
-
],
|
|
68759
|
-
name: "balanceOf",
|
|
68760
|
-
outputs: [
|
|
68761
|
-
{
|
|
68762
|
-
name: "balance",
|
|
68763
|
-
type: "uint256"
|
|
68764
|
-
}
|
|
68765
|
-
],
|
|
68766
|
-
payable: false,
|
|
68767
|
-
stateMutability: "view",
|
|
68768
|
-
type: "function"
|
|
68769
|
-
},
|
|
68770
|
-
{
|
|
68771
|
-
constant: true,
|
|
68772
|
-
inputs: [
|
|
68773
|
-
],
|
|
68774
|
-
name: "symbol",
|
|
68775
|
-
outputs: [
|
|
68776
|
-
{
|
|
68777
|
-
name: "",
|
|
68778
|
-
type: "string"
|
|
68779
|
-
}
|
|
68780
|
-
],
|
|
68781
|
-
payable: false,
|
|
68782
|
-
stateMutability: "view",
|
|
68783
|
-
type: "function"
|
|
68784
|
-
},
|
|
68785
|
-
{
|
|
68786
|
-
constant: false,
|
|
68787
|
-
inputs: [
|
|
68788
|
-
{
|
|
68789
|
-
name: "_to",
|
|
68790
|
-
type: "address"
|
|
68791
|
-
},
|
|
68792
|
-
{
|
|
68793
|
-
name: "_value",
|
|
68794
|
-
type: "uint256"
|
|
68795
|
-
}
|
|
68796
|
-
],
|
|
68797
|
-
name: "transfer",
|
|
68798
|
-
outputs: [
|
|
68799
|
-
{
|
|
68800
|
-
name: "",
|
|
68801
|
-
type: "bool"
|
|
68802
|
-
}
|
|
68803
|
-
],
|
|
68804
|
-
payable: false,
|
|
68805
|
-
stateMutability: "nonpayable",
|
|
68806
|
-
type: "function"
|
|
68807
|
-
},
|
|
68808
|
-
{
|
|
68809
|
-
constant: true,
|
|
68810
|
-
inputs: [
|
|
68811
|
-
{
|
|
68812
|
-
name: "_owner",
|
|
68813
|
-
type: "address"
|
|
68814
|
-
},
|
|
68815
|
-
{
|
|
68816
|
-
name: "_spender",
|
|
68817
|
-
type: "address"
|
|
68818
|
-
}
|
|
68819
|
-
],
|
|
68820
|
-
name: "allowance",
|
|
68821
|
-
outputs: [
|
|
68822
|
-
{
|
|
68823
|
-
name: "",
|
|
68824
|
-
type: "uint256"
|
|
68825
|
-
}
|
|
68826
|
-
],
|
|
68827
|
-
payable: false,
|
|
68828
|
-
stateMutability: "view",
|
|
68829
|
-
type: "function"
|
|
68830
|
-
},
|
|
68831
|
-
{
|
|
68832
|
-
payable: true,
|
|
68833
|
-
stateMutability: "payable",
|
|
68834
|
-
type: "fallback"
|
|
68835
|
-
},
|
|
68836
|
-
{
|
|
68837
|
-
anonymous: false,
|
|
68838
|
-
inputs: [
|
|
68839
|
-
{
|
|
68840
|
-
indexed: true,
|
|
68841
|
-
name: "owner",
|
|
68842
|
-
type: "address"
|
|
68843
|
-
},
|
|
68844
|
-
{
|
|
68845
|
-
indexed: true,
|
|
68846
|
-
name: "spender",
|
|
68847
|
-
type: "address"
|
|
68848
|
-
},
|
|
68849
|
-
{
|
|
68850
|
-
indexed: false,
|
|
68851
|
-
name: "value",
|
|
68852
|
-
type: "uint256"
|
|
68853
|
-
}
|
|
68854
|
-
],
|
|
68855
|
-
name: "Approval",
|
|
68856
|
-
type: "event"
|
|
68857
|
-
},
|
|
68858
|
-
{
|
|
68859
|
-
anonymous: false,
|
|
68860
|
-
inputs: [
|
|
68861
|
-
{
|
|
68862
|
-
indexed: true,
|
|
68863
|
-
name: "from",
|
|
68864
|
-
type: "address"
|
|
68865
|
-
},
|
|
68866
|
-
{
|
|
68867
|
-
indexed: true,
|
|
68868
|
-
name: "to",
|
|
68869
|
-
type: "address"
|
|
68870
|
-
},
|
|
68871
|
-
{
|
|
68872
|
-
indexed: false,
|
|
68873
|
-
name: "value",
|
|
68874
|
-
type: "uint256"
|
|
68875
|
-
}
|
|
68876
|
-
],
|
|
68877
|
-
name: "Transfer",
|
|
68878
|
-
type: "event"
|
|
68879
|
-
}
|
|
68880
|
-
];
|
|
68881
|
-
|
|
68882
68679
|
var PRICE_GETTER_V3_ABI = [
|
|
68883
68680
|
{
|
|
68884
68681
|
anonymous: false,
|
|
@@ -69771,11 +69568,11 @@ const getTokenPrices = (apeswapListsURL, chains) => __awaiter$9(void 0, void 0,
|
|
|
69771
69568
|
}
|
|
69772
69569
|
});
|
|
69773
69570
|
const getAllTokenPrices = (chainId, tokens) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
69774
|
-
const {
|
|
69571
|
+
const { externalTokens, filterTokensToCall, arrayFilterTokens } = Object.keys(tokens).reduce((acc, key) => {
|
|
69775
69572
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
69776
69573
|
const token = tokens[key];
|
|
69777
69574
|
if (((_a = token === null || token === void 0 ? void 0 : token.liquidityDex) === null || _a === void 0 ? void 0 : _a[chainId]) === types.LiquidityDex.External) {
|
|
69778
|
-
acc.
|
|
69575
|
+
acc.externalTokens.push(Object.assign(Object.assign({}, token), { address: (_b = token.address[chainId]) !== null && _b !== void 0 ? _b : '', decimals: (_d = (_c = token === null || token === void 0 ? void 0 : token.decimals) === null || _c === void 0 ? void 0 : _c[chainId]) !== null && _d !== void 0 ? _d : 18, lpToken: (_e = token.lpToken) !== null && _e !== void 0 ? _e : false }));
|
|
69779
69576
|
}
|
|
69780
69577
|
else if ((token === null || token === void 0 ? void 0 : token.active) &&
|
|
69781
69578
|
token.address[chainId] &&
|
|
@@ -69789,7 +69586,7 @@ const getAllTokenPrices = (chainId, tokens) => __awaiter$9(void 0, void 0, void
|
|
|
69789
69586
|
},
|
|
69790
69587
|
// Accumulator
|
|
69791
69588
|
{
|
|
69792
|
-
|
|
69589
|
+
externalTokens: [],
|
|
69793
69590
|
filterTokensToCall: {},
|
|
69794
69591
|
arrayFilterTokens: [],
|
|
69795
69592
|
});
|
|
@@ -69805,7 +69602,7 @@ const getAllTokenPrices = (chainId, tokens) => __awaiter$9(void 0, void 0, void
|
|
|
69805
69602
|
};
|
|
69806
69603
|
});
|
|
69807
69604
|
}
|
|
69808
|
-
const
|
|
69605
|
+
const externalResults = yield getBatchTokensExternal({ chainId, tokens: externalTokens });
|
|
69809
69606
|
const tokenResults = yield getTokenPricesV3FromPriceGetter(filterTokensToCall, chainId);
|
|
69810
69607
|
const parsedTokenResults = arrayFilterTokens.map((token, i) => {
|
|
69811
69608
|
var _a, _b, _c;
|
|
@@ -69818,143 +69615,35 @@ const getAllTokenPrices = (chainId, tokens) => __awaiter$9(void 0, void 0, void
|
|
|
69818
69615
|
chainId,
|
|
69819
69616
|
};
|
|
69820
69617
|
});
|
|
69821
|
-
return [...parsedTokenResults, ...
|
|
69618
|
+
return [...parsedTokenResults, ...externalResults];
|
|
69822
69619
|
});
|
|
69823
|
-
const
|
|
69620
|
+
const getBatchTokensExternal = (params) => __awaiter$9(void 0, void 0, void 0, function* () {
|
|
69824
69621
|
const { chainId, tokens } = params;
|
|
69825
|
-
// as I'm reutilizing the same array, I need to clone it to avoid changing the original array
|
|
69826
|
-
const tokensCopy = lodashExports.cloneDeep(tokens);
|
|
69827
69622
|
try {
|
|
69828
|
-
const baseURL = 'https://api.
|
|
69829
|
-
const
|
|
69830
|
-
|
|
69831
|
-
|
|
69832
|
-
const
|
|
69833
|
-
|
|
69834
|
-
|
|
69835
|
-
|
|
69836
|
-
|
|
69837
|
-
|
|
69838
|
-
{
|
|
69839
|
-
chainId: chainName,
|
|
69840
|
-
baseToken: {
|
|
69841
|
-
address: token.address,
|
|
69842
|
-
},
|
|
69843
|
-
liquidity: {
|
|
69844
|
-
usd: 1,
|
|
69845
|
-
},
|
|
69846
|
-
priceUsd: 1,
|
|
69847
|
-
},
|
|
69848
|
-
],
|
|
69849
|
-
};
|
|
69850
|
-
}
|
|
69851
|
-
if (symbol.toLowerCase() === 'inj' || symbol.toLowerCase() === 'winj') {
|
|
69852
|
-
token.address = 'inj';
|
|
69853
|
-
}
|
|
69854
|
-
if (token.symbol.toUpperCase() === 'WGLQ') {
|
|
69855
|
-
token.address = '0x9f9c8ec3534c3ce16f928381372bfbfbfb9f4d24';
|
|
69856
|
-
chainName = 'ethereum';
|
|
69857
|
-
}
|
|
69858
|
-
if (token.symbol.toUpperCase() === 'ETH' && chainId === types.ChainId.GRAPHLINQ) {
|
|
69859
|
-
token.address = '0x2170Ed0880ac9A755fd29B2688956BD959F933F8';
|
|
69860
|
-
chainName = 'bsc';
|
|
69861
|
-
}
|
|
69862
|
-
if (!chainName) {
|
|
69863
|
-
console.log(`Chain ${chainId} is not supported by dexscreener.`);
|
|
69864
|
-
return null;
|
|
69865
|
-
}
|
|
69866
|
-
else {
|
|
69867
|
-
chains.push(chainName);
|
|
69868
|
-
}
|
|
69869
|
-
let endpoint;
|
|
69870
|
-
if (lpToken) {
|
|
69871
|
-
if (!totalSupply) {
|
|
69872
|
-
const calls = [
|
|
69873
|
-
{
|
|
69874
|
-
address: token.address,
|
|
69875
|
-
name: 'totalSupply',
|
|
69876
|
-
},
|
|
69877
|
-
];
|
|
69878
|
-
const supply = getBalanceNumber((yield multicall(chainId, ERC_20_ABI, calls))[0], decimals);
|
|
69879
|
-
totalSupplies.push(supply);
|
|
69880
|
-
}
|
|
69881
|
-
else {
|
|
69882
|
-
totalSupplies.push(totalSupply);
|
|
69883
|
-
}
|
|
69884
|
-
endpoint = `pairs/${chainName}`;
|
|
69885
|
-
}
|
|
69886
|
-
else {
|
|
69887
|
-
endpoint = `tokens`;
|
|
69888
|
-
}
|
|
69889
|
-
const url = `${baseURL}/${endpoint}/${token.address}`;
|
|
69890
|
-
try {
|
|
69891
|
-
const response = yield axios.get(url);
|
|
69892
|
-
return response.data;
|
|
69893
|
-
}
|
|
69894
|
-
catch (error) {
|
|
69895
|
-
console.log(`Failed to fetch data for token ${token.address}: ${error}`);
|
|
69896
|
-
return null;
|
|
69897
|
-
}
|
|
69898
|
-
}));
|
|
69899
|
-
const result = yield Promise.all(calls);
|
|
69900
|
-
return result.map((response, index) => {
|
|
69623
|
+
const baseURL = 'https://price-api.ape.bond/prices';
|
|
69624
|
+
const tokensToCall = tokens.map((token) => token.address);
|
|
69625
|
+
if (tokensToCall.length === 0)
|
|
69626
|
+
return [];
|
|
69627
|
+
const response = yield axios.post(`${baseURL}`, {
|
|
69628
|
+
rpcUrl: 'string',
|
|
69629
|
+
tokens: tokensToCall,
|
|
69630
|
+
chain: chainId,
|
|
69631
|
+
});
|
|
69632
|
+
return response.data.map((token) => {
|
|
69901
69633
|
var _a;
|
|
69902
|
-
|
|
69903
|
-
|
|
69904
|
-
|
|
69905
|
-
|
|
69906
|
-
|
|
69907
|
-
|
|
69908
|
-
|
|
69909
|
-
if (token.lpToken) {
|
|
69910
|
-
const liquidity = response.pair.liquidity.usd;
|
|
69911
|
-
price = liquidity / supply;
|
|
69912
|
-
}
|
|
69913
|
-
else {
|
|
69914
|
-
const pairs = response.pairs;
|
|
69915
|
-
price = (_a = pairs
|
|
69916
|
-
.filter((pair) => pair.chainId === chains[index] && pair.baseToken.address.toLowerCase() === token.address.toLowerCase())
|
|
69917
|
-
.sort((a, b) => { var _a, _b; return ((_a = b === null || b === void 0 ? void 0 : b.liquidity) === null || _a === void 0 ? void 0 : _a.usd) - ((_b = a === null || a === void 0 ? void 0 : a.liquidity) === null || _b === void 0 ? void 0 : _b.usd); })[0]) === null || _a === void 0 ? void 0 : _a.priceUsd;
|
|
69918
|
-
}
|
|
69919
|
-
}
|
|
69920
|
-
catch (_b) {
|
|
69921
|
-
price = undefined;
|
|
69922
|
-
}
|
|
69923
|
-
let originalAddress = token.address;
|
|
69924
|
-
if (token.address === 'inj') {
|
|
69925
|
-
originalAddress = '0x4569348D39cc38F4d6a1180573Df73B7b03251d9';
|
|
69926
|
-
}
|
|
69927
|
-
if (token.address === '0x2170Ed0880ac9A755fd29B2688956BD959F933F8' && chainId === types.ChainId.GRAPHLINQ) {
|
|
69928
|
-
originalAddress = '0xbeED106D0f2e6950BFa1Eec74E1253CA0a643442';
|
|
69929
|
-
chainName = 'ethereum';
|
|
69930
|
-
}
|
|
69931
|
-
if (token.address === '0x9f9c8ec3534c3ce16f928381372bfbfbfb9f4d24') {
|
|
69932
|
-
originalAddress = '0xEB567ec41738c2bAb2599A1070FC5B727721b3B6';
|
|
69933
|
-
}
|
|
69934
|
-
return Object.assign(Object.assign({}, tokensCopy === null || tokensCopy === void 0 ? void 0 : tokensCopy[index]), { address: originalAddress, chainId, price: parseFloat(price !== null && price !== void 0 ? price : '0') });
|
|
69634
|
+
return {
|
|
69635
|
+
symbol: token.symbol,
|
|
69636
|
+
address: token.tokenAddress,
|
|
69637
|
+
price: parseFloat(token.price),
|
|
69638
|
+
decimals: (_a = tokens.find((t) => t.address.toLowerCase() === token.tokenAddress.toLowerCase())) === null || _a === void 0 ? void 0 : _a.decimals,
|
|
69639
|
+
chainId,
|
|
69640
|
+
};
|
|
69935
69641
|
});
|
|
69936
69642
|
}
|
|
69937
69643
|
catch (_a) {
|
|
69938
|
-
console.log(`Failed to get price from
|
|
69939
|
-
return tokensCopy.map((token) => {
|
|
69940
|
-
return Object.assign(Object.assign({}, token), { chainId, price: undefined });
|
|
69941
|
-
});
|
|
69644
|
+
console.log(`Failed to get price from api for chain ${chainId}.`);
|
|
69942
69645
|
}
|
|
69943
69646
|
});
|
|
69944
|
-
const getDexScreenerChainName = (chainId) => {
|
|
69945
|
-
const chainsName = {
|
|
69946
|
-
[types.ChainId.MAINNET]: 'ethereum',
|
|
69947
|
-
[types.ChainId.TLOS]: 'telos',
|
|
69948
|
-
[types.ChainId.BSC]: 'bsc',
|
|
69949
|
-
[types.ChainId.MATIC]: 'polygon',
|
|
69950
|
-
[types.ChainId.ARBITRUM]: 'arbitrum',
|
|
69951
|
-
[types.ChainId.INEVM]: 'injective',
|
|
69952
|
-
[types.ChainId.LINEA]: 'linea',
|
|
69953
|
-
[types.ChainId.GRAPHLINQ]: 'ethereum',
|
|
69954
|
-
};
|
|
69955
|
-
//@ts-ignore
|
|
69956
|
-
return chainsName[chainId];
|
|
69957
|
-
};
|
|
69958
69647
|
function getTokenPricesV3FromPriceGetter(tokensToCall, chain) {
|
|
69959
69648
|
return __awaiter$9(this, void 0, void 0, function* () {
|
|
69960
69649
|
const calls = [];
|
|
@@ -74711,6 +74400,233 @@ function isAddress(value) {
|
|
|
74711
74400
|
}
|
|
74712
74401
|
}
|
|
74713
74402
|
|
|
74403
|
+
var ERC_20_ABI = [
|
|
74404
|
+
{
|
|
74405
|
+
constant: true,
|
|
74406
|
+
inputs: [
|
|
74407
|
+
],
|
|
74408
|
+
name: "name",
|
|
74409
|
+
outputs: [
|
|
74410
|
+
{
|
|
74411
|
+
name: "",
|
|
74412
|
+
type: "string"
|
|
74413
|
+
}
|
|
74414
|
+
],
|
|
74415
|
+
payable: false,
|
|
74416
|
+
stateMutability: "view",
|
|
74417
|
+
type: "function"
|
|
74418
|
+
},
|
|
74419
|
+
{
|
|
74420
|
+
constant: false,
|
|
74421
|
+
inputs: [
|
|
74422
|
+
{
|
|
74423
|
+
name: "_spender",
|
|
74424
|
+
type: "address"
|
|
74425
|
+
},
|
|
74426
|
+
{
|
|
74427
|
+
name: "_value",
|
|
74428
|
+
type: "uint256"
|
|
74429
|
+
}
|
|
74430
|
+
],
|
|
74431
|
+
name: "approve",
|
|
74432
|
+
outputs: [
|
|
74433
|
+
{
|
|
74434
|
+
name: "",
|
|
74435
|
+
type: "bool"
|
|
74436
|
+
}
|
|
74437
|
+
],
|
|
74438
|
+
payable: false,
|
|
74439
|
+
stateMutability: "nonpayable",
|
|
74440
|
+
type: "function"
|
|
74441
|
+
},
|
|
74442
|
+
{
|
|
74443
|
+
constant: true,
|
|
74444
|
+
inputs: [
|
|
74445
|
+
],
|
|
74446
|
+
name: "totalSupply",
|
|
74447
|
+
outputs: [
|
|
74448
|
+
{
|
|
74449
|
+
name: "",
|
|
74450
|
+
type: "uint256"
|
|
74451
|
+
}
|
|
74452
|
+
],
|
|
74453
|
+
payable: false,
|
|
74454
|
+
stateMutability: "view",
|
|
74455
|
+
type: "function"
|
|
74456
|
+
},
|
|
74457
|
+
{
|
|
74458
|
+
constant: false,
|
|
74459
|
+
inputs: [
|
|
74460
|
+
{
|
|
74461
|
+
name: "_from",
|
|
74462
|
+
type: "address"
|
|
74463
|
+
},
|
|
74464
|
+
{
|
|
74465
|
+
name: "_to",
|
|
74466
|
+
type: "address"
|
|
74467
|
+
},
|
|
74468
|
+
{
|
|
74469
|
+
name: "_value",
|
|
74470
|
+
type: "uint256"
|
|
74471
|
+
}
|
|
74472
|
+
],
|
|
74473
|
+
name: "transferFrom",
|
|
74474
|
+
outputs: [
|
|
74475
|
+
{
|
|
74476
|
+
name: "",
|
|
74477
|
+
type: "bool"
|
|
74478
|
+
}
|
|
74479
|
+
],
|
|
74480
|
+
payable: false,
|
|
74481
|
+
stateMutability: "nonpayable",
|
|
74482
|
+
type: "function"
|
|
74483
|
+
},
|
|
74484
|
+
{
|
|
74485
|
+
constant: true,
|
|
74486
|
+
inputs: [
|
|
74487
|
+
],
|
|
74488
|
+
name: "decimals",
|
|
74489
|
+
outputs: [
|
|
74490
|
+
{
|
|
74491
|
+
name: "",
|
|
74492
|
+
type: "uint8"
|
|
74493
|
+
}
|
|
74494
|
+
],
|
|
74495
|
+
payable: false,
|
|
74496
|
+
stateMutability: "view",
|
|
74497
|
+
type: "function"
|
|
74498
|
+
},
|
|
74499
|
+
{
|
|
74500
|
+
constant: true,
|
|
74501
|
+
inputs: [
|
|
74502
|
+
{
|
|
74503
|
+
name: "_owner",
|
|
74504
|
+
type: "address"
|
|
74505
|
+
}
|
|
74506
|
+
],
|
|
74507
|
+
name: "balanceOf",
|
|
74508
|
+
outputs: [
|
|
74509
|
+
{
|
|
74510
|
+
name: "balance",
|
|
74511
|
+
type: "uint256"
|
|
74512
|
+
}
|
|
74513
|
+
],
|
|
74514
|
+
payable: false,
|
|
74515
|
+
stateMutability: "view",
|
|
74516
|
+
type: "function"
|
|
74517
|
+
},
|
|
74518
|
+
{
|
|
74519
|
+
constant: true,
|
|
74520
|
+
inputs: [
|
|
74521
|
+
],
|
|
74522
|
+
name: "symbol",
|
|
74523
|
+
outputs: [
|
|
74524
|
+
{
|
|
74525
|
+
name: "",
|
|
74526
|
+
type: "string"
|
|
74527
|
+
}
|
|
74528
|
+
],
|
|
74529
|
+
payable: false,
|
|
74530
|
+
stateMutability: "view",
|
|
74531
|
+
type: "function"
|
|
74532
|
+
},
|
|
74533
|
+
{
|
|
74534
|
+
constant: false,
|
|
74535
|
+
inputs: [
|
|
74536
|
+
{
|
|
74537
|
+
name: "_to",
|
|
74538
|
+
type: "address"
|
|
74539
|
+
},
|
|
74540
|
+
{
|
|
74541
|
+
name: "_value",
|
|
74542
|
+
type: "uint256"
|
|
74543
|
+
}
|
|
74544
|
+
],
|
|
74545
|
+
name: "transfer",
|
|
74546
|
+
outputs: [
|
|
74547
|
+
{
|
|
74548
|
+
name: "",
|
|
74549
|
+
type: "bool"
|
|
74550
|
+
}
|
|
74551
|
+
],
|
|
74552
|
+
payable: false,
|
|
74553
|
+
stateMutability: "nonpayable",
|
|
74554
|
+
type: "function"
|
|
74555
|
+
},
|
|
74556
|
+
{
|
|
74557
|
+
constant: true,
|
|
74558
|
+
inputs: [
|
|
74559
|
+
{
|
|
74560
|
+
name: "_owner",
|
|
74561
|
+
type: "address"
|
|
74562
|
+
},
|
|
74563
|
+
{
|
|
74564
|
+
name: "_spender",
|
|
74565
|
+
type: "address"
|
|
74566
|
+
}
|
|
74567
|
+
],
|
|
74568
|
+
name: "allowance",
|
|
74569
|
+
outputs: [
|
|
74570
|
+
{
|
|
74571
|
+
name: "",
|
|
74572
|
+
type: "uint256"
|
|
74573
|
+
}
|
|
74574
|
+
],
|
|
74575
|
+
payable: false,
|
|
74576
|
+
stateMutability: "view",
|
|
74577
|
+
type: "function"
|
|
74578
|
+
},
|
|
74579
|
+
{
|
|
74580
|
+
payable: true,
|
|
74581
|
+
stateMutability: "payable",
|
|
74582
|
+
type: "fallback"
|
|
74583
|
+
},
|
|
74584
|
+
{
|
|
74585
|
+
anonymous: false,
|
|
74586
|
+
inputs: [
|
|
74587
|
+
{
|
|
74588
|
+
indexed: true,
|
|
74589
|
+
name: "owner",
|
|
74590
|
+
type: "address"
|
|
74591
|
+
},
|
|
74592
|
+
{
|
|
74593
|
+
indexed: true,
|
|
74594
|
+
name: "spender",
|
|
74595
|
+
type: "address"
|
|
74596
|
+
},
|
|
74597
|
+
{
|
|
74598
|
+
indexed: false,
|
|
74599
|
+
name: "value",
|
|
74600
|
+
type: "uint256"
|
|
74601
|
+
}
|
|
74602
|
+
],
|
|
74603
|
+
name: "Approval",
|
|
74604
|
+
type: "event"
|
|
74605
|
+
},
|
|
74606
|
+
{
|
|
74607
|
+
anonymous: false,
|
|
74608
|
+
inputs: [
|
|
74609
|
+
{
|
|
74610
|
+
indexed: true,
|
|
74611
|
+
name: "from",
|
|
74612
|
+
type: "address"
|
|
74613
|
+
},
|
|
74614
|
+
{
|
|
74615
|
+
indexed: true,
|
|
74616
|
+
name: "to",
|
|
74617
|
+
type: "address"
|
|
74618
|
+
},
|
|
74619
|
+
{
|
|
74620
|
+
indexed: false,
|
|
74621
|
+
name: "value",
|
|
74622
|
+
type: "uint256"
|
|
74623
|
+
}
|
|
74624
|
+
],
|
|
74625
|
+
name: "Transfer",
|
|
74626
|
+
type: "event"
|
|
74627
|
+
}
|
|
74628
|
+
];
|
|
74629
|
+
|
|
74714
74630
|
function useCurrencyBalance(currency, account, chainId) {
|
|
74715
74631
|
return useQuery({
|
|
74716
74632
|
queryKey: [
|
|
@@ -76754,7 +76670,7 @@ const GetUpToComponent = ({ bond, depositAmount }) => {
|
|
|
76754
76670
|
};
|
|
76755
76671
|
|
|
76756
76672
|
const BuyBond = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond, isProjectView }) => {
|
|
76757
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j
|
|
76673
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
76758
76674
|
const SDKConfig = useSDKConfig();
|
|
76759
76675
|
const { data: geoData } = useGeoFencing();
|
|
76760
76676
|
// Hooks
|
|
@@ -77004,13 +76920,13 @@ const BuyBond = ({ onDismiss, bondAddress, bondChain, handlePurchasedBond, isPro
|
|
|
77004
76920
|
console.log('change to native');
|
|
77005
76921
|
}
|
|
77006
76922
|
}, [inputCurrencyBalance]);
|
|
77007
|
-
return bondData ? (jsxs(Flex, { className: `modal-content ${isGoldRush ? 'gold-rush' : ''}`, children: [jsx$2("div", { className: "gold-ribbon" }), jsxs(Flex, { className: "modaltable-container", children: [jsx$2(BondModalHeader, { bondData: bondData, onDismiss: onDismiss, showProjectInfoButton: (SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.referenceId) === 'apebond' }), 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, chainId: bondData === null || bondData === void 0 ? void 0 : bondData.chainId, enableZap: supportedByLIFI.includes(bondData === null || bondData === void 0 ? void 0 : bondData.chainId), bondPrincipalToken: bondData === null || bondData === void 0 ? void 0 : bondData.lpToken, tokenBalance: inputCurrencyBalance, selectedTokenPrice: inputTokenPrice === null || inputTokenPrice === void 0 ? void 0 : inputTokenPrice.price, inputDisabled: isUserRestricted }), SDKConfig.useTiers && jsx$2(GetUpToComponent, { bond: bondData, depositAmount: depositAmount }), (
|
|
76923
|
+
return bondData ? (jsxs(Flex, { className: `modal-content ${isGoldRush ? 'gold-rush' : ''}`, children: [jsx$2("div", { className: "gold-ribbon" }), jsxs(Flex, { className: "modaltable-container", children: [jsx$2(BondModalHeader, { bondData: bondData, onDismiss: onDismiss, showProjectInfoButton: (SDKConfig === null || SDKConfig === void 0 ? void 0 : SDKConfig.referenceId) === 'apebond' }), 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, chainId: bondData === null || bondData === void 0 ? void 0 : bondData.chainId, enableZap: supportedByLIFI.includes(bondData === null || bondData === void 0 ? void 0 : bondData.chainId), bondPrincipalToken: bondData === null || bondData === void 0 ? void 0 : bondData.lpToken, tokenBalance: inputCurrencyBalance, selectedTokenPrice: inputTokenPrice === null || inputTokenPrice === void 0 ? void 0 : inputTokenPrice.price, inputDisabled: isUserRestricted }), SDKConfig.useTiers && jsx$2(GetUpToComponent, { bond: bondData, depositAmount: depositAmount }), (bondData === null || bondData === void 0 ? void 0 : bondData.warningCard) && (jsx$2(Flex, { sx: {
|
|
77008
76924
|
width: '100%',
|
|
77009
76925
|
background: '#DE62F366',
|
|
77010
76926
|
justifyContent: 'center',
|
|
77011
76927
|
mt: '15px',
|
|
77012
76928
|
borderRadius: 'normal',
|
|
77013
|
-
}, children: jsx$2(Text, { sx: { fontSize: '12px', fontWeight: 400, p: '2px 10px' }, children:
|
|
76929
|
+
}, children: jsx$2(Text, { sx: { fontSize: '12px', fontWeight: 400, p: '2px 10px' }, children: bondData === null || bondData === void 0 ? void 0 : bondData.warningCard }) })), jsxs(Flex, { className: "modaltable-container button-container", children: [account && (jsx$2(Flex, { className: "button-container get", children: jsx$2(Button, { className: "action-button", onClick: () => bondData.billVersion === types.BillVersion.V4 && SDKConfig.useTiers
|
|
77014
76930
|
? window.open('http://ape.bond/tier-staking', '_blank')
|
|
77015
76931
|
: supportedByLIFI.includes(bondData === null || bondData === void 0 ? void 0 : bondData.chainId)
|
|
77016
76932
|
? handleOpenZapModal()
|
package/dist/types/bonds.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Ape Bond SDK",
|
|
4
4
|
"author": "Ape Bond",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "3.0.
|
|
6
|
+
"version": "3.0.25",
|
|
7
7
|
"module": "dist/main.js",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"types": "dist/main.d.ts",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"yalc": "^1.0.0-pre.53"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@ape.swap/apeswap-lists": "4.2.
|
|
60
|
+
"@ape.swap/apeswap-lists": "4.2.5",
|
|
61
61
|
"@emotion/react": "11.11.4",
|
|
62
62
|
"bignumber.js": "^9.1.2",
|
|
63
63
|
"chart.js": "4.2.0",
|