@b3dotfun/sdk 0.0.51 → 0.0.52-alpha.0
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/abis/upsideStaking.d.ts +2058 -0
- package/dist/cjs/anyspend/abis/upsideStaking.js +1139 -0
- package/dist/cjs/anyspend/react/components/AnySpendStakeUpside.d.ts +11 -0
- package/dist/cjs/anyspend/react/components/AnySpendStakeUpside.js +44 -0
- package/dist/cjs/anyspend/types/chain.d.ts +1 -0
- package/dist/cjs/anyspend/utils/chain.js +56 -47
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +5 -0
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +21 -1
- package/dist/cjs/shared/utils/simplehash.d.ts +1 -1
- package/dist/esm/anyspend/abis/upsideStaking.d.ts +2058 -0
- package/dist/esm/anyspend/abis/upsideStaking.js +1136 -0
- package/dist/esm/anyspend/react/components/AnySpendStakeUpside.d.ts +11 -0
- package/dist/esm/anyspend/react/components/AnySpendStakeUpside.js +38 -0
- package/dist/esm/anyspend/types/chain.d.ts +1 -0
- package/dist/esm/anyspend/utils/chain.js +57 -48
- package/dist/esm/global-account/react/components/B3DynamicModal.js +5 -0
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +21 -1
- package/dist/esm/shared/utils/simplehash.d.ts +1 -1
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/abis/upsideStaking.d.ts +2058 -0
- package/dist/types/anyspend/react/components/AnySpendStakeUpside.d.ts +11 -0
- package/dist/types/anyspend/types/chain.d.ts +1 -0
- package/dist/types/global-account/react/stores/useModalStore.d.ts +21 -1
- package/dist/types/shared/utils/simplehash.d.ts +1 -1
- package/package.json +1 -1
- package/src/anyspend/abis/upsideStaking.ts +1137 -0
- package/src/anyspend/react/components/AnySpendStakeUpside.tsx +96 -0
- package/src/anyspend/types/chain.ts +1 -0
- package/src/anyspend/utils/chain.ts +49 -53
- package/src/global-account/react/components/B3DynamicModal.tsx +5 -0
- package/src/global-account/react/stores/useModalStore.ts +22 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
2
|
+
import { StyleRoot } from "@b3dotfun/sdk/global-account/react";
|
|
3
|
+
import { formatTokenAmount } from "@b3dotfun/sdk/shared/utils/number";
|
|
4
|
+
import invariant from "invariant";
|
|
5
|
+
import { encodeFunctionData } from "viem";
|
|
6
|
+
import { base } from "viem/chains";
|
|
7
|
+
import { B3_STAKING_CONTRACT, WETH_STAKING_CONTRACT } from "../../abis/upsideStaking";
|
|
8
|
+
import { AnySpendCustom } from "./AnySpendCustom";
|
|
9
|
+
|
|
10
|
+
function generateEncodedDataForStaking(amount: string, beneficiary: string, poolType: "b3" | "weth"): string {
|
|
11
|
+
invariant(BigInt(amount) > 0, "Amount must be greater than zero");
|
|
12
|
+
if (poolType === "weth") {
|
|
13
|
+
return encodeFunctionData({
|
|
14
|
+
abi: WETH_STAKING_CONTRACT,
|
|
15
|
+
functionName: "stakeFor",
|
|
16
|
+
args: [beneficiary as `0x${string}`, BigInt(amount)],
|
|
17
|
+
});
|
|
18
|
+
} else if (poolType === "b3") {
|
|
19
|
+
return encodeFunctionData({
|
|
20
|
+
abi: B3_STAKING_CONTRACT,
|
|
21
|
+
functionName: "stakeFor",
|
|
22
|
+
args: [beneficiary as `0x${string}`, BigInt(amount)],
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
throw new Error("Unsupported pool type");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function AnySpendStakeUpside({
|
|
29
|
+
loadOrder,
|
|
30
|
+
mode = "modal",
|
|
31
|
+
beneficiaryAddress,
|
|
32
|
+
stakeAmount,
|
|
33
|
+
stakingContractAddress,
|
|
34
|
+
token,
|
|
35
|
+
poolType,
|
|
36
|
+
onSuccess,
|
|
37
|
+
}: {
|
|
38
|
+
loadOrder?: string;
|
|
39
|
+
mode?: "modal" | "page";
|
|
40
|
+
beneficiaryAddress: string;
|
|
41
|
+
stakeAmount: string;
|
|
42
|
+
stakingContractAddress: string;
|
|
43
|
+
token: components["schemas"]["Token"];
|
|
44
|
+
poolType: "b3" | "weth";
|
|
45
|
+
onSuccess?: () => void;
|
|
46
|
+
}) {
|
|
47
|
+
const header = () => (
|
|
48
|
+
<>
|
|
49
|
+
<div className="relative mx-auto size-32">
|
|
50
|
+
<img alt="token" className="size-full" src={token.metadata.logoURI || "https://cdn.b3.fun/b3-coin-3d.png"} />
|
|
51
|
+
</div>
|
|
52
|
+
<div className="from-b3-react-background to-as-on-surface-1 mt-[-60px] w-full rounded-t-lg bg-gradient-to-t">
|
|
53
|
+
<div className="h-[60px] w-full" />
|
|
54
|
+
<div className="mb-1 flex w-full flex-col items-center gap-2 p-5">
|
|
55
|
+
<span className="font-sf-rounded text-2xl font-semibold">
|
|
56
|
+
Swap & Stake {stakeAmount ? formatTokenAmount(BigInt(stakeAmount), token.decimals) : ""} {token.symbol}
|
|
57
|
+
</span>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
</>
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
// Only generate encoded data if we have a valid beneficiary address
|
|
64
|
+
// This is used for the AnySpendCustom swap & stake flow
|
|
65
|
+
if (!beneficiaryAddress || beneficiaryAddress === "") {
|
|
66
|
+
return (
|
|
67
|
+
<StyleRoot>
|
|
68
|
+
<div className="bg-b3-react-background flex w-full flex-col items-center justify-center p-8">
|
|
69
|
+
<p className="font-medium text-yellow-600 dark:text-yellow-400">⚠️ Please connect your wallet to continue.</p>
|
|
70
|
+
</div>
|
|
71
|
+
</StyleRoot>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const encodedData = generateEncodedDataForStaking(stakeAmount, beneficiaryAddress, poolType);
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<AnySpendCustom
|
|
79
|
+
loadOrder={loadOrder}
|
|
80
|
+
mode={mode}
|
|
81
|
+
recipientAddress={beneficiaryAddress}
|
|
82
|
+
orderType={"custom"}
|
|
83
|
+
dstChainId={base.id}
|
|
84
|
+
dstToken={token}
|
|
85
|
+
dstAmount={stakeAmount}
|
|
86
|
+
contractAddress={stakingContractAddress}
|
|
87
|
+
encodedData={encodedData}
|
|
88
|
+
metadata={{
|
|
89
|
+
action: `stake ${token.symbol}`,
|
|
90
|
+
}}
|
|
91
|
+
header={header}
|
|
92
|
+
onSuccess={onSuccess}
|
|
93
|
+
showRecipient={true}
|
|
94
|
+
/>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
@@ -13,20 +13,7 @@ import {
|
|
|
13
13
|
Transport,
|
|
14
14
|
WalletClient,
|
|
15
15
|
} from "viem";
|
|
16
|
-
import {
|
|
17
|
-
abstract,
|
|
18
|
-
arbitrum,
|
|
19
|
-
avalanche,
|
|
20
|
-
b3,
|
|
21
|
-
b3Sepolia,
|
|
22
|
-
base,
|
|
23
|
-
baseSepolia,
|
|
24
|
-
bsc,
|
|
25
|
-
mainnet,
|
|
26
|
-
optimism,
|
|
27
|
-
polygon,
|
|
28
|
-
sepolia,
|
|
29
|
-
} from "viem/chains";
|
|
16
|
+
import { abstract, arbitrum, avalanche, b3, base, bsc, mainnet, optimism, polygon } from "viem/chains";
|
|
30
17
|
import { ChainType, IBaseChain, IEVMChain, ISolanaChain } from "../types/chain";
|
|
31
18
|
import { getAvaxToken, getBnbToken, getEthToken, getPolToken, getSolanaToken } from "./token";
|
|
32
19
|
|
|
@@ -59,6 +46,7 @@ export const EVM_MAINNET: Record<number, IEVMChain> = {
|
|
|
59
46
|
pollingInterval: 4000, // 4 seconds for Ethereum mainnet
|
|
60
47
|
zapperEnum: "ETHEREUM_MAINNET",
|
|
61
48
|
coingeckoName: "eth",
|
|
49
|
+
wethAddress: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
|
|
62
50
|
},
|
|
63
51
|
[arbitrum.id]: {
|
|
64
52
|
id: arbitrum.id,
|
|
@@ -76,6 +64,7 @@ export const EVM_MAINNET: Record<number, IEVMChain> = {
|
|
|
76
64
|
pollingInterval: 500, // 500ms for Arbitrum's fast blocks
|
|
77
65
|
zapperEnum: "ARBITRUM_MAINNET",
|
|
78
66
|
coingeckoName: "arbitrum",
|
|
67
|
+
wethAddress: "0x82af49447d8a07e3bd95bd0d56f35241523fbab1",
|
|
79
68
|
},
|
|
80
69
|
[base.id]: {
|
|
81
70
|
id: base.id,
|
|
@@ -93,6 +82,7 @@ export const EVM_MAINNET: Record<number, IEVMChain> = {
|
|
|
93
82
|
pollingInterval: 1000, // 1 second for Base
|
|
94
83
|
zapperEnum: "BASE_MAINNET",
|
|
95
84
|
coingeckoName: "base",
|
|
85
|
+
wethAddress: "0x4200000000000000000000000000000000000006",
|
|
96
86
|
},
|
|
97
87
|
[optimism.id]: {
|
|
98
88
|
id: optimism.id,
|
|
@@ -110,6 +100,7 @@ export const EVM_MAINNET: Record<number, IEVMChain> = {
|
|
|
110
100
|
pollingInterval: 1000, // 1 second for Optimism
|
|
111
101
|
zapperEnum: "OPTIMISM_MAINNET",
|
|
112
102
|
coingeckoName: "optimism",
|
|
103
|
+
wethAddress: "0x4200000000000000000000000000000000000006",
|
|
113
104
|
},
|
|
114
105
|
[polygon.id]: {
|
|
115
106
|
id: polygon.id,
|
|
@@ -127,6 +118,7 @@ export const EVM_MAINNET: Record<number, IEVMChain> = {
|
|
|
127
118
|
pollingInterval: 1000, // 1 second for Polygon
|
|
128
119
|
zapperEnum: "POLYGON_MAINNET",
|
|
129
120
|
coingeckoName: "polygon_pos",
|
|
121
|
+
wethAddress: "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
|
|
130
122
|
},
|
|
131
123
|
[avalanche.id]: {
|
|
132
124
|
id: avalanche.id,
|
|
@@ -141,6 +133,7 @@ export const EVM_MAINNET: Record<number, IEVMChain> = {
|
|
|
141
133
|
pollingInterval: 1000, // 1 second for Avalanche
|
|
142
134
|
zapperEnum: "AVALANCHE_MAINNET",
|
|
143
135
|
coingeckoName: "avax",
|
|
136
|
+
wethAddress: "0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7",
|
|
144
137
|
},
|
|
145
138
|
[bsc.id]: {
|
|
146
139
|
id: bsc.id,
|
|
@@ -155,6 +148,7 @@ export const EVM_MAINNET: Record<number, IEVMChain> = {
|
|
|
155
148
|
pollingInterval: 1000, // 1 second for BSC
|
|
156
149
|
zapperEnum: "BSC_MAINNET",
|
|
157
150
|
coingeckoName: "bsc",
|
|
151
|
+
wethAddress: "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c",
|
|
158
152
|
},
|
|
159
153
|
[b3.id]: {
|
|
160
154
|
id: b3.id,
|
|
@@ -172,6 +166,7 @@ export const EVM_MAINNET: Record<number, IEVMChain> = {
|
|
|
172
166
|
pollingInterval: 1000, // 1 second for B3
|
|
173
167
|
zapperEnum: "B3_MAINNET",
|
|
174
168
|
coingeckoName: "b3",
|
|
169
|
+
wethAddress: "0x4200000000000000000000000000000000000006",
|
|
175
170
|
},
|
|
176
171
|
[abstract.id]: {
|
|
177
172
|
id: abstract.id,
|
|
@@ -189,49 +184,50 @@ export const EVM_MAINNET: Record<number, IEVMChain> = {
|
|
|
189
184
|
pollingInterval: 3000, // 3 seconds for Abstract
|
|
190
185
|
zapperEnum: "ABSTRACT_MAINNET",
|
|
191
186
|
coingeckoName: "abstract",
|
|
187
|
+
wethAddress: "0x3439153eb7af838ad19d56e1571fbd09333c2809",
|
|
192
188
|
},
|
|
193
189
|
};
|
|
194
190
|
|
|
195
191
|
export const EVM_TESTNET: Record<number, IEVMChain> = {
|
|
196
|
-
[sepolia.id]: {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
},
|
|
209
|
-
[baseSepolia.id]: {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
},
|
|
222
|
-
[b3Sepolia.id]: {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
},
|
|
192
|
+
// [sepolia.id]: {
|
|
193
|
+
// id: sepolia.id,
|
|
194
|
+
// name: sepolia.name,
|
|
195
|
+
// logoUrl: "https://assets.relay.link/icons/square/1/light.png",
|
|
196
|
+
// type: ChainType.EVM,
|
|
197
|
+
// nativeRequired: parseEther("0.00001"),
|
|
198
|
+
// canDepositNative: true,
|
|
199
|
+
// defaultToken: getEthToken(sepolia.id),
|
|
200
|
+
// nativeToken: getEthToken(sepolia.id),
|
|
201
|
+
// viem: sepolia,
|
|
202
|
+
// pollingInterval: 1000, // 1 second for Sepolia
|
|
203
|
+
// coingeckoName: "sepolia-testnet",
|
|
204
|
+
// },
|
|
205
|
+
// [baseSepolia.id]: {
|
|
206
|
+
// id: baseSepolia.id,
|
|
207
|
+
// name: baseSepolia.name,
|
|
208
|
+
// logoUrl: "https://assets.relay.link/icons/square/8453/light.png",
|
|
209
|
+
// type: ChainType.EVM,
|
|
210
|
+
// nativeRequired: parseEther("0.00001"),
|
|
211
|
+
// canDepositNative: true,
|
|
212
|
+
// defaultToken: getEthToken(baseSepolia.id),
|
|
213
|
+
// nativeToken: getEthToken(baseSepolia.id),
|
|
214
|
+
// viem: baseSepolia,
|
|
215
|
+
// pollingInterval: 1000, // 1 second for Base Sepolia
|
|
216
|
+
// coingeckoName: null,
|
|
217
|
+
// },
|
|
218
|
+
// [b3Sepolia.id]: {
|
|
219
|
+
// id: b3Sepolia.id,
|
|
220
|
+
// name: b3Sepolia.name,
|
|
221
|
+
// logoUrl: "https://assets.relay.link/icons/square/8333/light.png",
|
|
222
|
+
// type: ChainType.EVM,
|
|
223
|
+
// nativeRequired: parseEther("0.00001"),
|
|
224
|
+
// canDepositNative: true,
|
|
225
|
+
// defaultToken: getEthToken(b3Sepolia.id),
|
|
226
|
+
// nativeToken: getEthToken(b3Sepolia.id),
|
|
227
|
+
// viem: b3Sepolia,
|
|
228
|
+
// pollingInterval: 1000, // 1 second for B3 Sepolia
|
|
229
|
+
// coingeckoName: null,
|
|
230
|
+
// },
|
|
235
231
|
// [b4testnet.id]: {
|
|
236
232
|
// id: b4testnet.id,
|
|
237
233
|
// logoUrl: "https://cdn.b3.fun/b4-logo.png",
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
OrderHistory,
|
|
10
10
|
} from "@b3dotfun/sdk/anyspend/react";
|
|
11
11
|
import { AnySpendDepositHype } from "@b3dotfun/sdk/anyspend/react/components/AnyspendDepositHype";
|
|
12
|
+
import { AnySpendStakeUpside } from "@b3dotfun/sdk/anyspend/react/components/AnySpendStakeUpside";
|
|
12
13
|
import { useIsMobile, useModalStore } from "@b3dotfun/sdk/global-account/react";
|
|
13
14
|
import { cn } from "@b3dotfun/sdk/shared/utils/cn";
|
|
14
15
|
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
@@ -35,6 +36,7 @@ export function B3DynamicModal() {
|
|
|
35
36
|
"anySpendJoinTournament",
|
|
36
37
|
"anySpendFundTournament",
|
|
37
38
|
"anySpendStakeB3",
|
|
39
|
+
"anySpendStakeUpside",
|
|
38
40
|
"anySpendBuySpin",
|
|
39
41
|
"anySpendOrderHistory",
|
|
40
42
|
"signInWithB3",
|
|
@@ -49,6 +51,7 @@ export function B3DynamicModal() {
|
|
|
49
51
|
"anySpendJoinTournament",
|
|
50
52
|
"anySpendFundTournament",
|
|
51
53
|
"anySpendStakeB3",
|
|
54
|
+
"anySpendStakeUpside",
|
|
52
55
|
"anySpendBuySpin",
|
|
53
56
|
"anySpendSignatureMint",
|
|
54
57
|
"anySpendBondKit",
|
|
@@ -97,6 +100,8 @@ export function B3DynamicModal() {
|
|
|
97
100
|
return <OrderHistory onBack={() => {}} mode="modal" />;
|
|
98
101
|
case "anySpendStakeB3":
|
|
99
102
|
return <AnySpendStakeB3 {...contentType} mode="modal" />;
|
|
103
|
+
case "anySpendStakeUpside":
|
|
104
|
+
return <AnySpendStakeUpside {...contentType} mode="modal" />;
|
|
100
105
|
case "anySpendBuySpin":
|
|
101
106
|
return <AnySpendBuySpin {...contentType} mode="modal" />;
|
|
102
107
|
case "anySpendSignatureMint":
|
|
@@ -223,6 +223,27 @@ export interface AnySpendStakeB3Props extends BaseModalProps {
|
|
|
223
223
|
onSuccess?: () => void;
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
+
/**
|
|
227
|
+
* Props for the AnySpend Stake Contract modal
|
|
228
|
+
* Handles token staking operations to a given contract
|
|
229
|
+
*/
|
|
230
|
+
export interface AnySpendStakeUpsideProps extends BaseModalProps {
|
|
231
|
+
/** Modal type identifier */
|
|
232
|
+
type: "anySpendStakeUpside";
|
|
233
|
+
/** Recipient address to stake B3 for */
|
|
234
|
+
beneficiaryAddress: string;
|
|
235
|
+
/** Stake amount */
|
|
236
|
+
stakeAmount: string;
|
|
237
|
+
/** Staking contract address */
|
|
238
|
+
stakingContractAddress: string;
|
|
239
|
+
/** Pool type for staking */
|
|
240
|
+
poolType: "b3" | "weth";
|
|
241
|
+
/** Token address to stake */
|
|
242
|
+
token: components["schemas"]["Token"];
|
|
243
|
+
/** Callback function called when the stake is successful */
|
|
244
|
+
onSuccess?: () => void;
|
|
245
|
+
}
|
|
246
|
+
|
|
226
247
|
/**
|
|
227
248
|
* Props for the AnySpend Buy Spin modal
|
|
228
249
|
* Handles spin wheel entry purchases
|
|
@@ -332,6 +353,7 @@ export type ModalContentType =
|
|
|
332
353
|
| AnySpendFundTournamentProps
|
|
333
354
|
| AnySpendOrderHistoryProps
|
|
334
355
|
| AnySpendStakeB3Props
|
|
356
|
+
| AnySpendStakeUpsideProps
|
|
335
357
|
| AnySpendBuySpinProps
|
|
336
358
|
| AnySpendSignatureMintProps
|
|
337
359
|
| AnySpendBondKitProps
|