@b3dotfun/sdk 0.0.49-alpha.1 → 0.0.49-alpha.10
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/cjs/anyspend/constants/index.d.ts +1 -0
- package/dist/cjs/anyspend/constants/index.js +12 -2
- package/dist/cjs/anyspend/react/components/AnySpend.js +10 -1
- package/dist/cjs/anyspend/react/components/AnyspendDepositHype.js +1 -1
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.js +15 -9
- package/dist/cjs/anyspend/react/components/common/FeeDetailPanel.js +2 -2
- package/dist/cjs/anyspend/react/components/common/OrderDetails.d.ts +1 -0
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +6 -6
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.d.ts +1 -0
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.js +3 -2
- package/dist/cjs/anyspend/react/contexts/FeatureFlagsContext.js +1 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +24 -12
- package/dist/cjs/anyspend/types/api.d.ts +14 -2
- package/dist/cjs/anyspend/utils/chain.js +4 -4
- package/dist/cjs/bondkit/bondkitToken.d.ts +3 -1
- package/dist/cjs/bondkit/bondkitToken.js +19 -0
- package/dist/cjs/bondkit/components/TradingView.d.ts +1 -1
- package/dist/cjs/bondkit/components/TradingView.js +14 -3
- package/dist/cjs/bondkit/components/index.d.ts +1 -1
- package/dist/cjs/bondkit/components/index.js +1 -1
- package/dist/cjs/bondkit/components/types.d.ts +1 -0
- package/dist/cjs/bondkit/config.d.ts +1 -0
- package/dist/cjs/bondkit/config.js +1 -0
- package/dist/cjs/bondkit/index.d.ts +1 -1
- package/dist/cjs/bondkit/index.js +2 -6
- package/dist/cjs/bondkit/types.d.ts +15 -0
- package/dist/cjs/shared/generated/chain-networks.json +40 -7
- package/dist/esm/anyspend/constants/index.d.ts +1 -0
- package/dist/esm/anyspend/constants/index.js +11 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +10 -1
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +1 -1
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.js +15 -9
- package/dist/esm/anyspend/react/components/common/FeeDetailPanel.js +2 -2
- package/dist/esm/anyspend/react/components/common/OrderDetails.d.ts +1 -0
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +6 -6
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.d.ts +1 -0
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.js +4 -3
- package/dist/esm/anyspend/react/contexts/FeatureFlagsContext.js +1 -1
- package/dist/esm/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +24 -12
- package/dist/esm/anyspend/types/api.d.ts +14 -2
- package/dist/esm/anyspend/utils/chain.js +4 -4
- package/dist/esm/bondkit/bondkitToken.d.ts +3 -1
- package/dist/esm/bondkit/bondkitToken.js +19 -0
- package/dist/esm/bondkit/components/TradingView.d.ts +1 -1
- package/dist/esm/bondkit/components/TradingView.js +14 -3
- package/dist/esm/bondkit/components/index.d.ts +1 -1
- package/dist/esm/bondkit/components/index.js +1 -1
- package/dist/esm/bondkit/components/types.d.ts +1 -0
- package/dist/esm/bondkit/config.d.ts +1 -0
- package/dist/esm/bondkit/config.js +1 -0
- package/dist/esm/bondkit/index.d.ts +1 -1
- package/dist/esm/bondkit/index.js +1 -1
- package/dist/esm/bondkit/types.d.ts +15 -0
- package/dist/esm/shared/generated/chain-networks.json +40 -7
- package/dist/types/anyspend/constants/index.d.ts +1 -0
- package/dist/types/anyspend/react/components/common/OrderDetails.d.ts +1 -0
- package/dist/types/anyspend/react/components/common/OrderDetailsCollapsible.d.ts +1 -0
- package/dist/types/anyspend/react/hooks/useAnyspendOrderHistory.d.ts +24 -12
- package/dist/types/anyspend/types/api.d.ts +14 -2
- package/dist/types/bondkit/bondkitToken.d.ts +3 -1
- package/dist/types/bondkit/components/TradingView.d.ts +1 -1
- package/dist/types/bondkit/components/index.d.ts +1 -1
- package/dist/types/bondkit/components/types.d.ts +1 -0
- package/dist/types/bondkit/config.d.ts +1 -0
- package/dist/types/bondkit/index.d.ts +1 -1
- package/dist/types/bondkit/types.d.ts +15 -0
- package/package.json +1 -1
- package/src/anyspend/constants/index.ts +12 -1
- package/src/anyspend/react/components/AnySpend.tsx +13 -0
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +1 -0
- package/src/anyspend/react/components/common/CryptoReceiveSection.tsx +17 -9
- package/src/anyspend/react/components/common/FeeDetailPanel.tsx +33 -6
- package/src/anyspend/react/components/common/OrderDetails.tsx +7 -0
- package/src/anyspend/react/components/common/OrderDetailsCollapsible.tsx +16 -0
- package/src/anyspend/react/contexts/FeatureFlagsContext.tsx +2 -2
- package/src/anyspend/types/api.ts +14 -2
- package/src/anyspend/utils/chain.ts +4 -4
- package/src/bondkit/bondkitToken.ts +24 -0
- package/src/bondkit/components/TradingView.tsx +15 -3
- package/src/bondkit/components/index.ts +1 -1
- package/src/bondkit/components/types.ts +1 -0
- package/src/bondkit/config.ts +2 -0
- package/src/bondkit/index.ts +1 -1
- package/src/bondkit/types.ts +19 -0
- package/src/shared/generated/chain-networks.json +40 -7
|
@@ -86,3 +86,18 @@ export interface SwapQuote {
|
|
|
86
86
|
executionPrice: string;
|
|
87
87
|
fee: string;
|
|
88
88
|
}
|
|
89
|
+
export interface MarketCapDataPoint {
|
|
90
|
+
time: string;
|
|
91
|
+
value: string;
|
|
92
|
+
}
|
|
93
|
+
export interface TokenInfo {
|
|
94
|
+
contractAddress: string;
|
|
95
|
+
chainId: number;
|
|
96
|
+
name: string;
|
|
97
|
+
symbol: string;
|
|
98
|
+
found: boolean;
|
|
99
|
+
}
|
|
100
|
+
export interface MarketCapChartResponse {
|
|
101
|
+
tokenInfo: TokenInfo;
|
|
102
|
+
data: MarketCapDataPoint[];
|
|
103
|
+
}
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@ export const SOLANA_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID = "ATokenGPvbdGVxr1b2hvZ
|
|
|
12
12
|
export const SOLANA_TOKEN_2022_PROGRAM_ID = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
|
|
13
13
|
|
|
14
14
|
export const B3_TOKEN: components["schemas"]["Token"] = {
|
|
15
|
-
chainId:
|
|
15
|
+
chainId: base.id,
|
|
16
16
|
address: "0xb3b32f9f8827d4634fe7d973fa1034ec9fddb3b3",
|
|
17
17
|
decimals: 18,
|
|
18
18
|
name: "B3",
|
|
@@ -22,6 +22,17 @@ export const B3_TOKEN: components["schemas"]["Token"] = {
|
|
|
22
22
|
},
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
+
export const ANYSPEND_TOKEN: components["schemas"]["Token"] = {
|
|
26
|
+
chainId: base.id,
|
|
27
|
+
address: "0xc17dda248e2d50fc006d8febb5a406dd31972712",
|
|
28
|
+
decimals: 18,
|
|
29
|
+
name: "Anyspend",
|
|
30
|
+
symbol: "ANY",
|
|
31
|
+
metadata: {
|
|
32
|
+
logoURI: "https://cdn.b3.fun/anyspend_64x64.png",
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
25
36
|
export const USDC_BASE: components["schemas"]["Token"] = {
|
|
26
37
|
symbol: "USDC",
|
|
27
38
|
chainId: base.id,
|
|
@@ -609,9 +609,20 @@ function AnySpendInner({
|
|
|
609
609
|
},
|
|
610
610
|
});
|
|
611
611
|
|
|
612
|
+
// Check if it's a same-chain same-token swap
|
|
613
|
+
const isSameChainSameToken = useMemo(() => {
|
|
614
|
+
return (
|
|
615
|
+
activeTab === "crypto" &&
|
|
616
|
+
selectedSrcChainId === selectedDstChainId &&
|
|
617
|
+
selectedSrcToken.address.toLowerCase() === selectedDstToken.address.toLowerCase()
|
|
618
|
+
);
|
|
619
|
+
}, [activeTab, selectedSrcChainId, selectedDstChainId, selectedSrcToken.address, selectedDstToken.address]);
|
|
620
|
+
|
|
612
621
|
// Determine button state and text
|
|
613
622
|
const btnInfo: { text: string; disable: boolean; error: boolean; loading: boolean } = useMemo(() => {
|
|
614
623
|
if (activeInputAmountInWei === "0") return { text: "Enter an amount", disable: true, error: false, loading: false };
|
|
624
|
+
if (isSameChainSameToken)
|
|
625
|
+
return { text: "Select a different token or chain", disable: true, error: false, loading: false };
|
|
615
626
|
if (isLoadingAnyspendQuote) return { text: "Loading quote...", disable: true, error: false, loading: true };
|
|
616
627
|
if (!recipientAddress) return { text: "Select recipient", disable: false, error: false, loading: false };
|
|
617
628
|
if (isCreatingOrder || isCreatingOnrampOrder)
|
|
@@ -648,6 +659,7 @@ function AnySpendInner({
|
|
|
648
659
|
return { text: "Buy", disable: false, error: false, loading: false };
|
|
649
660
|
}, [
|
|
650
661
|
activeInputAmountInWei,
|
|
662
|
+
isSameChainSameToken,
|
|
651
663
|
isLoadingAnyspendQuote,
|
|
652
664
|
recipientAddress,
|
|
653
665
|
isCreatingOrder,
|
|
@@ -905,6 +917,7 @@ function AnySpendInner({
|
|
|
905
917
|
refundTxs={oat.data.refundTxs}
|
|
906
918
|
selectedCryptoPaymentMethod={selectedCryptoPaymentMethod}
|
|
907
919
|
onPaymentMethodChange={setSelectedCryptoPaymentMethod}
|
|
920
|
+
points={oat.data.points || undefined}
|
|
908
921
|
onBack={() => {
|
|
909
922
|
setOrderId(undefined);
|
|
910
923
|
navigateBack();
|
|
@@ -130,7 +130,7 @@ export function CryptoReceiveSection({
|
|
|
130
130
|
(() => {
|
|
131
131
|
const calculatePriceImpact = (inputUsd?: string | number, outputUsd?: string | number) => {
|
|
132
132
|
if (!inputUsd || !outputUsd) {
|
|
133
|
-
return { percentage: "0.00", isNegative: false };
|
|
133
|
+
return { percentage: "0.00", percentageNum: 0, isNegative: false };
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
const input = Number(inputUsd);
|
|
@@ -138,38 +138,46 @@ export function CryptoReceiveSection({
|
|
|
138
138
|
|
|
139
139
|
// Handle edge cases
|
|
140
140
|
if (input === 0 || isNaN(input) || isNaN(output) || input <= output) {
|
|
141
|
-
return { percentage: "0.00", isNegative: false };
|
|
141
|
+
return { percentage: "0.00", percentageNum: 0, isNegative: false };
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
const percentageValue = ((output - input) / input) * 100;
|
|
145
145
|
|
|
146
146
|
// Handle the -0.00% case
|
|
147
147
|
if (percentageValue > -0.005 && percentageValue < 0) {
|
|
148
|
-
return { percentage: "0.00", isNegative: false };
|
|
148
|
+
return { percentage: "0.00", percentageNum: 0, isNegative: false };
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
return {
|
|
152
152
|
percentage: Math.abs(percentageValue).toFixed(2),
|
|
153
|
+
percentageNum: Math.abs(percentageValue),
|
|
153
154
|
isNegative: percentageValue < 0,
|
|
154
155
|
};
|
|
155
156
|
};
|
|
156
157
|
|
|
157
|
-
const { percentage, isNegative } = calculatePriceImpact(
|
|
158
|
+
const { percentage, percentageNum, isNegative } = calculatePriceImpact(
|
|
158
159
|
anyspendQuote.data.currencyIn.amountUsd,
|
|
159
160
|
anyspendQuote.data.currencyOut.amountUsd,
|
|
160
161
|
);
|
|
161
162
|
|
|
162
|
-
//
|
|
163
|
-
const
|
|
163
|
+
// Get the fee percentage if available
|
|
164
|
+
const feePercent = anyspendQuote.data.fee?.finalFeeBps ? anyspendQuote.data.fee.finalFeeBps / 100 : 0;
|
|
164
165
|
|
|
165
|
-
//
|
|
166
|
-
|
|
166
|
+
// Calculate actual slippage (price impact minus fee)
|
|
167
|
+
const actualSlippage = percentageNum - feePercent;
|
|
168
|
+
|
|
169
|
+
// Show warning based on actual slippage, not total impact
|
|
170
|
+
const yellowThreshold = 1; // 1% actual slippage
|
|
171
|
+
const redThreshold = 2; // 2% actual slippage
|
|
172
|
+
|
|
173
|
+
// Don't show if actual slippage is less than yellow threshold
|
|
174
|
+
if (actualSlippage < yellowThreshold) {
|
|
167
175
|
return null;
|
|
168
176
|
}
|
|
169
177
|
|
|
170
178
|
// Using inline style to ensure color displays
|
|
171
179
|
return (
|
|
172
|
-
<span className="ml-2" style={{ color:
|
|
180
|
+
<span className="ml-2" style={{ color: actualSlippage >= redThreshold ? "red" : "#FFD700" }}>
|
|
173
181
|
({isNegative ? "-" : ""}
|
|
174
182
|
{percentage}%)
|
|
175
183
|
</span>
|
|
@@ -114,7 +114,7 @@ export function FeeDetailPanel({ fee, transactionAmountUsd, onBack }: FeeDetailP
|
|
|
114
114
|
)}
|
|
115
115
|
>
|
|
116
116
|
<span>{tier.label}</span>
|
|
117
|
-
<span>
|
|
117
|
+
<span>Credit Card Fee + {tier.fee}</span>
|
|
118
118
|
</div>
|
|
119
119
|
);
|
|
120
120
|
})
|
|
@@ -244,11 +244,38 @@ export function FeeDetailPanel({ fee, transactionAmountUsd, onBack }: FeeDetailP
|
|
|
244
244
|
<span className="text-as-primary font-semibold">${transactionAmountUsd.toFixed(2)}</span>
|
|
245
245
|
</div>
|
|
246
246
|
|
|
247
|
-
{isStripeFee &&
|
|
248
|
-
|
|
249
|
-
<
|
|
250
|
-
|
|
251
|
-
|
|
247
|
+
{isStripeFee && (
|
|
248
|
+
<>
|
|
249
|
+
<div className="flex items-center justify-between">
|
|
250
|
+
<span className="text-as-secondary">
|
|
251
|
+
Credit Card Fee ({fee.stripeFeeBps ? `${bpsToPercent(fee.stripeFeeBps)}%` : "0%"} + $
|
|
252
|
+
{fee.stripeFeeUsd?.toFixed(2) || "0.00"})
|
|
253
|
+
</span>
|
|
254
|
+
<span className="text-as-primary font-medium">
|
|
255
|
+
${((transactionAmountUsd * (fee.stripeFeeBps || 0)) / 10000 + (fee.stripeFeeUsd || 0)).toFixed(2)}
|
|
256
|
+
</span>
|
|
257
|
+
</div>
|
|
258
|
+
<div className="flex items-center justify-between">
|
|
259
|
+
<span className="text-as-secondary">
|
|
260
|
+
AnySpend Fee ({fee.anyspendFeeBps ? `${bpsToPercent(fee.anyspendFeeBps)}%` : "0%"}
|
|
261
|
+
{fee.anyspendFeeUsd && fee.anyspendFeeUsd > 0 ? ` + $${fee.anyspendFeeUsd.toFixed(2)}` : ""})
|
|
262
|
+
</span>
|
|
263
|
+
<span className="text-as-primary font-medium">
|
|
264
|
+
$
|
|
265
|
+
{((transactionAmountUsd * (fee.anyspendFeeBps || 0)) / 10000 + (fee.anyspendFeeUsd || 0)).toFixed(
|
|
266
|
+
2,
|
|
267
|
+
)}
|
|
268
|
+
</span>
|
|
269
|
+
</div>
|
|
270
|
+
<div className="border-as-border-secondary border-t pt-2">
|
|
271
|
+
<div className="flex items-center justify-between">
|
|
272
|
+
<span className="text-as-primary font-semibold">Total Fee</span>
|
|
273
|
+
<span className="text-as-brand font-semibold">
|
|
274
|
+
${((transactionAmountUsd * (fee.finalFeeBps || 0)) / 10000 + (fee.finalFeeUsd || 0)).toFixed(2)}
|
|
275
|
+
</span>
|
|
276
|
+
</div>
|
|
277
|
+
</div>
|
|
278
|
+
</>
|
|
252
279
|
)}
|
|
253
280
|
|
|
254
281
|
{!isStripeFee && currentCryptoTier && (
|
|
@@ -68,6 +68,7 @@ interface OrderDetailsProps {
|
|
|
68
68
|
onPaymentMethodChange?: (method: CryptoPaymentMethodType) => void; // Callback for payment method switching
|
|
69
69
|
onBack?: () => void;
|
|
70
70
|
disableUrlParamManagement?: boolean; // When true, will not modify URL parameters
|
|
71
|
+
points?: number | undefined; // Points earned from the transaction
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
// Add this helper function near the top or just above the component
|
|
@@ -212,6 +213,7 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
212
213
|
onPaymentMethodChange,
|
|
213
214
|
onBack,
|
|
214
215
|
disableUrlParamManagement = false,
|
|
216
|
+
points,
|
|
215
217
|
}: OrderDetailsProps) {
|
|
216
218
|
const router = useRouter();
|
|
217
219
|
const searchParams = useSearchParams();
|
|
@@ -576,6 +578,7 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
576
578
|
nft={nft}
|
|
577
579
|
recipientName={recipientName}
|
|
578
580
|
formattedExpectedDstAmount={formattedExpectedDstAmount}
|
|
581
|
+
points={points}
|
|
579
582
|
/>
|
|
580
583
|
<Accordion type="single" collapsible className="order-details-accordion w-full">
|
|
581
584
|
<AccordionItem value="refund-details" className="order-details-refund-item">
|
|
@@ -654,6 +657,7 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
654
657
|
nft={nft}
|
|
655
658
|
recipientName={recipientName}
|
|
656
659
|
formattedExpectedDstAmount={formattedExpectedDstAmount}
|
|
660
|
+
points={points}
|
|
657
661
|
/>
|
|
658
662
|
<Accordion type="single" collapsible className="order-details-accordion w-full">
|
|
659
663
|
<AccordionItem value="execute-details" className="order-details-execute-item">
|
|
@@ -781,6 +785,7 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
781
785
|
nft={nft}
|
|
782
786
|
recipientName={recipientName}
|
|
783
787
|
formattedExpectedDstAmount={formattedExpectedDstAmount}
|
|
788
|
+
points={points}
|
|
784
789
|
/>
|
|
785
790
|
<Accordion type="single" collapsible className="order-details-accordion w-full">
|
|
786
791
|
<AccordionItem value="more-details" className="order-details-more-item">
|
|
@@ -910,6 +915,7 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
910
915
|
nft={nft}
|
|
911
916
|
recipientName={recipientName}
|
|
912
917
|
formattedExpectedDstAmount={formattedExpectedDstAmount}
|
|
918
|
+
points={points}
|
|
913
919
|
/>
|
|
914
920
|
<Accordion type="single" collapsible className="order-details-accordion w-full">
|
|
915
921
|
<AccordionItem value="deposit-details" className="order-details-deposit-item">
|
|
@@ -1190,6 +1196,7 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
1190
1196
|
nft={nft}
|
|
1191
1197
|
recipientName={recipientName}
|
|
1192
1198
|
formattedExpectedDstAmount={formattedExpectedDstAmount}
|
|
1199
|
+
points={points}
|
|
1193
1200
|
/>
|
|
1194
1201
|
)}
|
|
1195
1202
|
|
|
@@ -5,6 +5,7 @@ import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
|
5
5
|
import { CopyToClipboard } from "@b3dotfun/sdk/global-account/react";
|
|
6
6
|
import { cn } from "@b3dotfun/sdk/shared/utils";
|
|
7
7
|
import centerTruncate from "@b3dotfun/sdk/shared/utils/centerTruncate";
|
|
8
|
+
import { formatNumber } from "@b3dotfun/sdk/shared/utils/formatNumber";
|
|
8
9
|
import { formatTokenAmount } from "@b3dotfun/sdk/shared/utils/number";
|
|
9
10
|
import { ChevronDown, Copy } from "lucide-react";
|
|
10
11
|
import { motion } from "motion/react";
|
|
@@ -27,6 +28,7 @@ interface OrderDetailsCollapsibleProps {
|
|
|
27
28
|
className?: string;
|
|
28
29
|
showTotal?: boolean;
|
|
29
30
|
totalAmount?: string;
|
|
31
|
+
points?: number;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
export const OrderDetailsCollapsible = memo(function OrderDetailsCollapsible({
|
|
@@ -39,6 +41,7 @@ export const OrderDetailsCollapsible = memo(function OrderDetailsCollapsible({
|
|
|
39
41
|
className,
|
|
40
42
|
showTotal = false,
|
|
41
43
|
totalAmount,
|
|
44
|
+
points,
|
|
42
45
|
}: OrderDetailsCollapsibleProps) {
|
|
43
46
|
const [showOrderDetails, setShowOrderDetails] = useState(true);
|
|
44
47
|
|
|
@@ -150,6 +153,19 @@ export const OrderDetailsCollapsible = memo(function OrderDetailsCollapsible({
|
|
|
150
153
|
</div>
|
|
151
154
|
</div>
|
|
152
155
|
|
|
156
|
+
{points !== undefined && points !== null && (
|
|
157
|
+
<>
|
|
158
|
+
<div className="order-details-divider divider w-full" />
|
|
159
|
+
{/* Points Section */}
|
|
160
|
+
<div className="order-details-points-section flex w-full justify-between gap-4">
|
|
161
|
+
<div className="order-details-points-label text-as-tertiarry">Points</div>
|
|
162
|
+
<div className="order-details-points-value text-as-brand font-semibold">
|
|
163
|
+
+{formatNumber(points)} pts
|
|
164
|
+
</div>
|
|
165
|
+
</div>
|
|
166
|
+
</>
|
|
167
|
+
)}
|
|
168
|
+
|
|
153
169
|
<div className="order-details-divider divider w-full" />
|
|
154
170
|
|
|
155
171
|
{/* Order ID / Total Section */}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { createContext, useContext
|
|
3
|
+
import { ReactNode, createContext, useContext } from "react";
|
|
4
4
|
|
|
5
5
|
export interface FeatureFlags {
|
|
6
6
|
showPoints?: boolean;
|
|
@@ -18,7 +18,7 @@ interface FeatureFlagsProviderProps {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
const defaultFeatureFlags: FeatureFlags = {
|
|
21
|
-
showPoints:
|
|
21
|
+
showPoints: true,
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
export function FeatureFlagsProvider({ children, featureFlags = defaultFeatureFlags }: FeatureFlagsProviderProps) {
|
|
@@ -1334,10 +1334,22 @@ export interface components {
|
|
|
1334
1334
|
/** @description Settlement information for executed orders */
|
|
1335
1335
|
settlement: {
|
|
1336
1336
|
/**
|
|
1337
|
-
* @description Actual received amount after execution
|
|
1337
|
+
* @description Actual received amount after execution (only for swap/hypeduel orders). Optional - only present for swap/hypeduel orders.
|
|
1338
1338
|
* @example 990000
|
|
1339
1339
|
*/
|
|
1340
|
-
actualDstAmount
|
|
1340
|
+
actualDstAmount?: string;
|
|
1341
|
+
/**
|
|
1342
|
+
* @description Complete relay API response data. Contains transaction details, state changes, fees, and execution status. Optional - can be backfilled by querying Relay API /requests/v2 endpoint.
|
|
1343
|
+
* @example {
|
|
1344
|
+
* "status": "success",
|
|
1345
|
+
* "metadata": {
|
|
1346
|
+
* "currencyOut": {
|
|
1347
|
+
* "amount": "990000"
|
|
1348
|
+
* }
|
|
1349
|
+
* }
|
|
1350
|
+
* }
|
|
1351
|
+
*/
|
|
1352
|
+
relay?: Record<string, never>;
|
|
1341
1353
|
} | null;
|
|
1342
1354
|
/** @description Fee structure for the order including Stripe and AnySpend fees */
|
|
1343
1355
|
fee?: Omit<components["schemas"]["Fee"], "type"> | null;
|
|
@@ -126,7 +126,7 @@ export const EVM_MAINNET: Record<number, IEVMChain> = {
|
|
|
126
126
|
),
|
|
127
127
|
pollingInterval: 1000, // 1 second for Polygon
|
|
128
128
|
zapperEnum: "POLYGON_MAINNET",
|
|
129
|
-
coingeckoName: "
|
|
129
|
+
coingeckoName: "polygon_pos",
|
|
130
130
|
},
|
|
131
131
|
[avalanche.id]: {
|
|
132
132
|
id: avalanche.id,
|
|
@@ -140,7 +140,7 @@ export const EVM_MAINNET: Record<number, IEVMChain> = {
|
|
|
140
140
|
viem: getCustomEvmChain(avalanche, "https://avalanche-c-chain-rpc.publicnode.com"),
|
|
141
141
|
pollingInterval: 1000, // 1 second for Avalanche
|
|
142
142
|
zapperEnum: "AVALANCHE_MAINNET",
|
|
143
|
-
coingeckoName: "
|
|
143
|
+
coingeckoName: "avax",
|
|
144
144
|
},
|
|
145
145
|
[bsc.id]: {
|
|
146
146
|
id: bsc.id,
|
|
@@ -187,8 +187,8 @@ export const EVM_MAINNET: Record<number, IEVMChain> = {
|
|
|
187
187
|
"https://cosmopolitan-nameless-mountain.abstract-mainnet.quiknode.pro/863853304b986b582bdacf625ce3350397c560f8/",
|
|
188
188
|
),
|
|
189
189
|
pollingInterval: 3000, // 3 seconds for Abstract
|
|
190
|
-
zapperEnum: "
|
|
191
|
-
coingeckoName: "
|
|
190
|
+
zapperEnum: "ABSTRACT_MAINNET",
|
|
191
|
+
coingeckoName: "abstract",
|
|
192
192
|
},
|
|
193
193
|
};
|
|
194
194
|
|
|
@@ -17,6 +17,7 @@ import { BondkitSwapService } from "./swapService";
|
|
|
17
17
|
import type {
|
|
18
18
|
BondkitTokenInitializationConfig,
|
|
19
19
|
GetTransactionHistoryOptions,
|
|
20
|
+
MarketCapChartResponse,
|
|
20
21
|
SwapQuote,
|
|
21
22
|
TokenDetails,
|
|
22
23
|
TransactionResponse,
|
|
@@ -52,6 +53,7 @@ export class BondkitToken {
|
|
|
52
53
|
private walletKey?: Hex;
|
|
53
54
|
private rpcUrl: string;
|
|
54
55
|
private apiEndpoint: string;
|
|
56
|
+
private chartApiEndpoint: string;
|
|
55
57
|
private walletClientInstance: WalletClient;
|
|
56
58
|
private connectedProvider?: EIP1193Provider;
|
|
57
59
|
private tradingToken?: Address;
|
|
@@ -62,6 +64,7 @@ export class BondkitToken {
|
|
|
62
64
|
this.chain = sdkConfig.chain;
|
|
63
65
|
this.rpcUrl = sdkConfig.rpcUrl;
|
|
64
66
|
this.apiEndpoint = sdkConfig.apiEndpoint;
|
|
67
|
+
this.chartApiEndpoint = sdkConfig.chartApiEndpoint;
|
|
65
68
|
|
|
66
69
|
if (walletKey && !walletKey.startsWith("0x")) {
|
|
67
70
|
this.walletKey = `0x${walletKey}` as Hex;
|
|
@@ -459,6 +462,27 @@ export class BondkitToken {
|
|
|
459
462
|
}
|
|
460
463
|
}
|
|
461
464
|
|
|
465
|
+
// --- Market Cap Chart Data --- //
|
|
466
|
+
public async getMarketCapChartData(): Promise<MarketCapChartResponse | undefined> {
|
|
467
|
+
try {
|
|
468
|
+
const url = new URL("/recent_marketcap", this.chartApiEndpoint);
|
|
469
|
+
url.searchParams.set("contractAddress", this.contractAddress);
|
|
470
|
+
url.searchParams.set("chainId", this.chain.id.toString());
|
|
471
|
+
|
|
472
|
+
const response = await fetch(url.toString());
|
|
473
|
+
|
|
474
|
+
if (!response.ok) {
|
|
475
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
const result: MarketCapChartResponse = await response.json();
|
|
479
|
+
return result;
|
|
480
|
+
} catch (e) {
|
|
481
|
+
console.warn("Error fetching market cap chart data:", e);
|
|
482
|
+
return undefined;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
462
486
|
// --- Write Methods --- //
|
|
463
487
|
private async executeWrite(
|
|
464
488
|
functionName: string,
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { Loader2 } from "lucide-react";
|
|
4
4
|
import { useEffect, useRef, useState } from "react";
|
|
5
|
+
import { getConfig } from "../config";
|
|
5
6
|
import { TradingViewProps } from "./types";
|
|
6
7
|
import { loadScriptFromCDN } from "./utils/cdn-loader";
|
|
7
8
|
import { formatNumberSmall } from "./utils/format";
|
|
@@ -23,12 +24,16 @@ const GifLoadingOverlay = ({ className }: { className?: string }) => (
|
|
|
23
24
|
</div>
|
|
24
25
|
);
|
|
25
26
|
|
|
26
|
-
const TradingView = ({ className, tokenAddress, tokenSymbol }: TradingViewProps) => {
|
|
27
|
+
const TradingView = ({ className, tokenAddress, tokenSymbol, chainId = 8453 }: TradingViewProps) => {
|
|
27
28
|
// Use token info for the current trade
|
|
28
29
|
const currentTrade = {
|
|
29
30
|
product_id: tokenAddress && tokenSymbol ? `${tokenSymbol}-${tokenAddress}` : "BONDKIT",
|
|
30
31
|
};
|
|
31
32
|
|
|
33
|
+
// Get chart API endpoint from config
|
|
34
|
+
const config = getConfig(chainId);
|
|
35
|
+
const chartApiUrl = `${config.chartApiEndpoint}/udf`;
|
|
36
|
+
|
|
32
37
|
const [tradingViewDefaultInterval, setTradingViewDefaultInterval] = useState<ResolutionString>("60");
|
|
33
38
|
const [tradingViewTimezone, setTradingViewTimezone] = useState<string>("");
|
|
34
39
|
|
|
@@ -153,7 +158,7 @@ const TradingView = ({ className, tokenAddress, tokenSymbol }: TradingViewProps)
|
|
|
153
158
|
};
|
|
154
159
|
};
|
|
155
160
|
|
|
156
|
-
const datafeed = createUDFDatafeed(
|
|
161
|
+
const datafeed = createUDFDatafeed(chartApiUrl);
|
|
157
162
|
// Calculate timeframe for last 2 days
|
|
158
163
|
const currentTime = Math.floor(Date.now() / 1000);
|
|
159
164
|
const twoDaysAgo = currentTime - 2 * 24 * 60 * 60; // 2 days in seconds
|
|
@@ -280,7 +285,14 @@ const TradingView = ({ className, tokenAddress, tokenSymbol }: TradingViewProps)
|
|
|
280
285
|
tvWidgetRef.current = null;
|
|
281
286
|
}
|
|
282
287
|
};
|
|
283
|
-
}, [
|
|
288
|
+
}, [
|
|
289
|
+
librariesLoaded,
|
|
290
|
+
currentTrade?.product_id,
|
|
291
|
+
tradingViewDefaultInterval,
|
|
292
|
+
tradingViewTimezone,
|
|
293
|
+
chartApiUrl,
|
|
294
|
+
chainId,
|
|
295
|
+
]);
|
|
284
296
|
|
|
285
297
|
useEffect(() => {
|
|
286
298
|
if (
|
package/src/bondkit/config.ts
CHANGED
|
@@ -7,6 +7,7 @@ export interface Config {
|
|
|
7
7
|
rpcUrl: string;
|
|
8
8
|
factoryAddress: Address;
|
|
9
9
|
apiEndpoint: string;
|
|
10
|
+
chartApiEndpoint: string;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
export type SupportedChainId = typeof base.id;
|
|
@@ -16,6 +17,7 @@ const baseMainnetConfig: Config = {
|
|
|
16
17
|
rpcUrl: BaseMainnetRpcUrl,
|
|
17
18
|
factoryAddress: BaseBondkitTokenFactoryContractAddress,
|
|
18
19
|
apiEndpoint: "https://api.b3.fun/bondkit-tokens",
|
|
20
|
+
chartApiEndpoint: "https://bondkit-chart-api.b3.fun",
|
|
19
21
|
};
|
|
20
22
|
|
|
21
23
|
export const getConfig = (chainId: number, rpcUrl?: string): Config => {
|
package/src/bondkit/index.ts
CHANGED
package/src/bondkit/types.ts
CHANGED
|
@@ -108,3 +108,22 @@ export interface SwapQuote {
|
|
|
108
108
|
executionPrice: string;
|
|
109
109
|
fee: string;
|
|
110
110
|
}
|
|
111
|
+
|
|
112
|
+
// Market cap chart data types
|
|
113
|
+
export interface MarketCapDataPoint {
|
|
114
|
+
time: string; // ISO 8601 timestamp
|
|
115
|
+
value: string; // Market cap value as string (to handle large numbers)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface TokenInfo {
|
|
119
|
+
contractAddress: string;
|
|
120
|
+
chainId: number;
|
|
121
|
+
name: string;
|
|
122
|
+
symbol: string;
|
|
123
|
+
found: boolean;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface MarketCapChartResponse {
|
|
127
|
+
tokenInfo: TokenInfo;
|
|
128
|
+
data: MarketCapDataPoint[];
|
|
129
|
+
}
|