@layerswap/widget 0.1.4 → 0.1.14
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/README.md +78 -3
- package/dist/Models/Theme.d.ts +7 -6
- package/dist/Models/Theme.js +7 -7
- package/dist/Models/WalletProvider.d.ts +0 -4
- package/dist/Models/WalletProvider.js +2 -0
- package/dist/components/Buttons/copyButton.js +4 -3
- package/dist/components/ColorSchema.js +79 -45
- package/dist/components/Common/AddressIcon.js +1 -0
- package/dist/components/Common/AverageCompletionTime.js +1 -1
- package/dist/components/Common/CountDownTimer.js +2 -2
- package/dist/components/Common/FormattedAverageCompletionTime.js +1 -1
- package/dist/components/HeaderWithMenu/index.js +1 -8
- package/dist/components/Input/Address/AddressNote.js +3 -2
- package/dist/components/Input/Address/AddressPicker/AddressWithIcon.js +2 -2
- package/dist/components/Input/Address/AddressPicker/ConnectedWallets/ConnectWalletButton.js +12 -5
- package/dist/components/Input/Address/AddressPicker/ExchangeNote.d.ts +1 -1
- package/dist/components/Input/Address/AddressPicker/ExchangeNote.js +1 -1
- package/dist/components/Input/RouteIcon.js +1 -1
- package/dist/components/LayerswapMenu/MenuList.js +2 -56
- package/dist/components/Pages/404/index.js +1 -0
- package/dist/components/Pages/Auth/Steps/CodeStep/VerifyEmailCode.js +1 -0
- package/dist/components/Pages/Auth/index.d.ts +1 -1
- package/dist/components/Pages/Auth/index.js +3 -2
- package/dist/components/Pages/Campaigns/Details/Leaderboard.js +1 -0
- package/dist/components/Pages/Campaigns/Details/index.d.ts +1 -1
- package/dist/components/Pages/Campaigns/Details/index.js +3 -2
- package/dist/components/Pages/Campaigns/index.d.ts +1 -1
- package/dist/components/Pages/Campaigns/index.js +3 -2
- package/dist/components/Pages/Maintanance/index.js +1 -0
- package/dist/components/Pages/NoCookies/index.js +1 -0
- package/dist/components/Pages/SwapHistory/History.js +1 -2
- package/dist/components/Pages/SwapHistory/index.d.ts +1 -1
- package/dist/components/Pages/SwapHistory/index.js +4 -3
- package/dist/components/Pages/SwapPages/Form/FeeDetails/Campaign.js +1 -0
- package/dist/components/Pages/SwapPages/Form/Form.js +1 -4
- package/dist/components/Pages/SwapPages/Form/SecondaryComponents/ValidationError.js +1 -1
- package/dist/components/Pages/SwapPages/Form/Select/Popover/PopoverSelect.js +1 -1
- package/dist/components/Pages/SwapPages/Form/index.js +1 -0
- package/dist/components/Pages/SwapPages/Withdraw/Coinbase/Carousel.js +8 -6
- package/dist/components/Pages/SwapPages/Withdraw/Processing/Processing.js +2 -2
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/FuelWalletWithdrawal.d.ts +0 -4
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/FuelWalletWithdrawal.js +159 -125
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/ImtblxWalletWithdrawStep.d.ts +0 -4
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/ImtblxWalletWithdrawStep.js +69 -51
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/Loopring/ActivationTokentPicker.d.ts +0 -8
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/Loopring/ActivationTokentPicker.js +87 -45
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/Loopring/hooks.d.ts +0 -40
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/Loopring/hooks.js +73 -46
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/Loopring/index.d.ts +0 -4
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/Loopring/index.js +175 -128
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/SVMWalletWithdraw/index.d.ts +0 -7
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/SVMWalletWithdraw/index.js +138 -116
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/SVMWalletWithdraw/transactionSender.d.ts +0 -8
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/SVMWalletWithdraw/transactionSender.js +96 -75
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/SophonWalletWithdraw.js +2 -2
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/StarknetWalletWithdraw.d.ts +0 -4
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/StarknetWalletWithdraw.js +88 -71
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/TonWalletWithdraw.d.ts +0 -4
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/TonWalletWithdraw.js +146 -136
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/TronWalletWithdraw.d.ts +0 -4
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/TronWalletWithdraw.js +120 -99
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/WalletTransfer/TransferToken.js +3 -3
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/WalletTransfer/buttons.js +1 -0
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/WalletTransfer/index.js +1 -1
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/WalletTransfer/transactionMessage.js +2 -2
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/WalletTransferContent.js +101 -33
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/paradex/Evm.d.ts +0 -4
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/paradex/Evm.js +60 -55
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/paradex/Starknet.d.ts +0 -4
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/paradex/Starknet.js +71 -55
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/paradex/buttons.js +1 -0
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/paradex/index.d.ts +0 -4
- package/dist/components/Pages/SwapPages/Withdraw/Wallet/paradex/index.js +56 -52
- package/dist/components/Pages/SwapPages/Withdraw/index.d.ts +1 -1
- package/dist/components/Pages/SwapPages/Withdraw/index.js +3 -2
- package/dist/components/Wallet/WalletModal/Connector.js +1 -1
- package/dist/components/Wallet/WalletProviders/FuelProvider.d.ts +0 -5
- package/dist/components/Wallet/WalletProviders/FuelProvider.js +25 -20
- package/dist/components/Wallet/WalletProviders/ImtblPassportProvider.d.ts +0 -5
- package/dist/components/Wallet/WalletProviders/ImtblPassportProvider.js +39 -36
- package/dist/components/Wallet/WalletProviders/SolanaProvider.d.ts +0 -5
- package/dist/components/Wallet/WalletProviders/SolanaProvider.js +49 -38
- package/dist/components/Wallet/WalletProviders/StarknetProvider.d.ts +0 -5
- package/dist/components/Wallet/WalletProviders/StarknetProvider.js +112 -117
- package/dist/components/Wallet/WalletProviders/TonConnectProvider.d.ts +0 -6
- package/dist/components/Wallet/WalletProviders/TonConnectProvider.js +58 -50
- package/dist/components/Wallet/WalletProviders/TronProvider.d.ts +0 -3
- package/dist/components/Wallet/WalletProviders/TronProvider.js +23 -15
- package/dist/components/Wallet/WalletProviders/Wagmi.d.ts +1 -1
- package/dist/components/Wallet/WalletProviders/Wagmi.js +20 -10
- package/dist/components/Wallet/WalletProviders/index.js +13 -6
- package/dist/components/Widget/Footer.d.ts +2 -1
- package/dist/components/Widget/Footer.js +13 -4
- package/dist/components/Widget/Index.d.ts +1 -1
- package/dist/components/Widget/Index.js +1 -1
- package/dist/components/WidgetLoading.d.ts +1 -0
- package/dist/components/WidgetLoading.js +5 -0
- package/dist/components/Wizard/Wizard.js +1 -1
- package/dist/components/shadcn/command.js +1 -1
- package/dist/components/themeWrapper.js +3 -2
- package/dist/context/{LayerswapContext.d.ts → LayerswapProvider.d.ts} +3 -8
- package/dist/context/{LayerswapContext.js → LayerswapProvider.js} +8 -9
- package/dist/context/authContext.js +1 -0
- package/dist/context/walletHooksProvider.js +1 -0
- package/dist/hooks/useWallet.js +10 -14
- package/dist/index.css +1 -1
- package/dist/index.d.ts +3 -5
- package/dist/index.js +2 -4
- package/dist/index.mjs +19 -0
- package/dist/lib/AppSettings.d.ts +7 -3
- package/dist/lib/AppSettings.js +8 -7
- package/dist/lib/address/formatter/index.js +8 -9
- package/dist/lib/address/validator/index.js +18 -20
- package/dist/lib/axiosInterceptor.js +1 -2
- package/dist/lib/balances/balanceResolver.js +16 -16
- package/dist/lib/balances/providers/evmBalanceProvider.js +3 -3
- package/dist/lib/balances/providers/loopringBalanceProvider.d.ts +0 -6
- package/dist/lib/balances/providers/loopringBalanceProvider.js +56 -43
- package/dist/lib/balances/providers/paradexBalanceProvider.d.ts +0 -6
- package/dist/lib/balances/providers/paradexBalanceProvider.js +42 -42
- package/dist/lib/balances/providers/solanaBalanceProvider.d.ts +0 -6
- package/dist/lib/balances/providers/solanaBalanceProvider.js +70 -71
- package/dist/lib/balances/providers/starknetBalanceProvider.d.ts +0 -6
- package/dist/lib/balances/providers/starknetBalanceProvider.js +48 -45
- package/dist/lib/balances/providers/tonBalanceProvider.d.ts +0 -18
- package/dist/lib/balances/providers/tonBalanceProvider.js +104 -100
- package/dist/lib/balances/providers/tronBalanceResolver.js +2 -3
- package/dist/lib/fuels/common/FakeAccount.d.ts +0 -24
- package/dist/lib/fuels/common/FakeAccount.js +58 -36
- package/dist/lib/fuels/common/PredicateConnector.d.ts +0 -54
- package/dist/lib/fuels/common/PredicateConnector.js +292 -205
- package/dist/lib/fuels/common/PredicateFactory.d.ts +0 -29
- package/dist/lib/fuels/common/PredicateFactory.js +123 -76
- package/dist/lib/fuels/common/PredicateWalletAdapter.d.ts +0 -17
- package/dist/lib/fuels/common/PredicateWalletAdapter.js +44 -29
- package/dist/lib/fuels/common/index.d.ts +0 -4
- package/dist/lib/fuels/common/index.js +4 -4
- package/dist/lib/fuels/connectors/fuel-wallet/FuelWalletConnector.d.ts +0 -51
- package/dist/lib/fuels/connectors/fuel-wallet/FuelWalletConnector.js +268 -234
- package/dist/lib/fuels/connectors/fuel-wallet/index.d.ts +0 -2
- package/dist/lib/fuels/connectors/fuel-wallet/index.js +2 -2
- package/dist/lib/fuels/connectors/fuel-wallet/types.d.ts +0 -50
- package/dist/lib/fuels/connectors/fuel-wallet/types.js +53 -9
- package/dist/lib/fuels/connectors/fuelet-wallet/FueletWalletConnector.d.ts +0 -7
- package/dist/lib/fuels/connectors/fuelet-wallet/FueletWalletConnector.js +20 -19
- package/dist/lib/fuels/connectors/fuelet-wallet/index.d.ts +0 -1
- package/dist/lib/fuels/connectors/fuelet-wallet/index.js +1 -1
- package/dist/lib/gases/gasResolver.d.ts +1 -1
- package/dist/lib/gases/gasResolver.js +10 -10
- package/dist/lib/gases/providers/evmGasProvider.js +5 -4
- package/dist/lib/gases/providers/loopringGasProvider.d.ts +0 -6
- package/dist/lib/gases/providers/loopringGasProvider.js +27 -24
- package/dist/lib/gases/providers/solanaGasProvider.d.ts +0 -7
- package/dist/lib/gases/providers/solanaGasProvider.js +32 -31
- package/dist/lib/gases/providers/starknetGasProvider.d.ts +0 -7
- package/dist/lib/gases/providers/starknetGasProvider.js +34 -33
- package/dist/lib/imtbl.d.ts +0 -69
- package/dist/lib/imtbl.js +63 -60
- package/dist/lib/internalApiClient.d.ts +0 -2
- package/dist/lib/internalApiClient.js +1 -4
- package/dist/lib/layerSwapApiClient.js +3 -3
- package/dist/lib/logError.js +2 -2
- package/dist/lib/nft/nftBalanceResolver.js +1 -2
- package/dist/lib/nft/providers/starknetNftProvider.d.ts +0 -6
- package/dist/lib/nft/providers/starknetNftProvider.js +49 -50
- package/dist/lib/wallets/connectors/EthereumProvider.d.ts +2 -2
- package/dist/lib/wallets/connectors/useSyncProviders/store.d.ts +1 -4
- package/dist/lib/wallets/fuel/Bako.d.ts +0 -15
- package/dist/lib/wallets/fuel/Bako.js +34 -29
- package/dist/lib/wallets/fuel/Basko.d.ts +0 -15
- package/dist/lib/wallets/fuel/Basko.js +34 -29
- package/dist/lib/wallets/fuel/useFuel.d.ts +0 -2
- package/dist/lib/wallets/fuel/useFuel.js +211 -192
- package/dist/lib/wallets/imtblX/useImtblX.d.ts +0 -2
- package/dist/lib/wallets/imtblX/useImtblX.js +87 -87
- package/dist/lib/wallets/paradex/Authorize/Ethereum.d.ts +0 -2
- package/dist/lib/wallets/paradex/Authorize/Ethereum.js +24 -23
- package/dist/lib/wallets/paradex/Authorize/Starknet.d.ts +0 -2
- package/dist/lib/wallets/paradex/Authorize/Starknet.js +14 -13
- package/dist/lib/wallets/paradex/lib/account.d.ts +0 -28
- package/dist/lib/wallets/paradex/lib/account.js +102 -53
- package/dist/lib/wallets/paradex/lib/index.d.ts +0 -24
- package/dist/lib/wallets/paradex/lib/index.js +20 -20
- package/dist/lib/wallets/paradex/lib/paraclear-provider.d.ts +0 -6
- package/dist/lib/wallets/paradex/lib/paraclear-provider.js +13 -9
- package/dist/lib/wallets/paradex/lib/paraclear.d.ts +0 -137
- package/dist/lib/wallets/paradex/lib/paraclear.js +258 -131
- package/dist/lib/wallets/paradex/lib/starknet-account-support.d.ts +0 -22
- package/dist/lib/wallets/paradex/lib/starknet-account-support.js +296 -220
- package/dist/lib/wallets/paradex/lib/starknet-signer.d.ts +0 -15
- package/dist/lib/wallets/paradex/lib/starknet-signer.js +120 -94
- package/dist/lib/wallets/paradex/useParadex.d.ts +0 -7
- package/dist/lib/wallets/paradex/useParadex.js +197 -194
- package/dist/lib/wallets/solana/transactionBuilder.d.ts +0 -4
- package/dist/lib/wallets/solana/transactionBuilder.js +63 -39
- package/dist/lib/wallets/solana/useSVM.d.ts +0 -5
- package/dist/lib/wallets/solana/useSVM.js +139 -142
- package/dist/lib/wallets/starknet/useStarknet.d.ts +0 -2
- package/dist/lib/wallets/starknet/useStarknet.js +139 -139
- package/dist/lib/wallets/ton/client.d.ts +0 -3
- package/dist/lib/wallets/ton/client.js +7 -7
- package/dist/lib/wallets/ton/useTON.d.ts +0 -2
- package/dist/lib/wallets/ton/useTON.js +121 -122
- package/dist/lib/wallets/tron/connectors/bitkeep.d.ts +0 -61
- package/dist/lib/wallets/tron/connectors/bitkeep.js +326 -303
- package/dist/lib/wallets/tron/connectors/index.d.ts +0 -4
- package/dist/lib/wallets/tron/connectors/index.js +4 -4
- package/dist/lib/wallets/tron/connectors/okxWallet.d.ts +0 -66
- package/dist/lib/wallets/tron/connectors/okxWallet.js +364 -336
- package/dist/lib/wallets/tron/connectors/tokenPocket.d.ts +0 -72
- package/dist/lib/wallets/tron/connectors/tokenPocket.js +337 -308
- package/dist/lib/wallets/tron/connectors/tronLink/index.d.ts +0 -102
- package/dist/lib/wallets/tron/connectors/tronLink/index.js +560 -520
- package/dist/lib/wallets/tron/connectors/tronLink/types.d.ts +0 -56
- package/dist/lib/wallets/tron/connectors/tronLink/types.js +53 -1
- package/dist/lib/wallets/tron/connectors/tronLink/utils.d.ts +0 -14
- package/dist/lib/wallets/tron/connectors/tronLink/utils.js +64 -61
- package/dist/lib/wallets/tron/useTron.d.ts +0 -2
- package/dist/lib/wallets/tron/useTron.js +111 -111
- package/dist/lib/wallets/utils/resolveWalletIcon.js +1 -0
- package/package.json +26 -77
- package/dist/hooks/useCopyClipboard.d.ts +0 -1
- package/dist/hooks/useCopyClipboard.js +0 -21
- package/dist/index.cjs +0 -125
- package/dist/lib/abis/ERC20.json +0 -258
- package/dist/lib/fuels/connectors/walletConnect/WalletConnectConnector.d.ts +0 -42
- package/dist/lib/fuels/connectors/walletConnect/WalletConnectConnector.js +0 -357
- package/dist/lib/fuels/connectors/walletConnect/constants.d.ts +0 -6
- package/dist/lib/fuels/connectors/walletConnect/constants.js +0 -7
- package/dist/lib/fuels/connectors/walletConnect/index.d.ts +0 -3
- package/dist/lib/fuels/connectors/walletConnect/index.js +0 -3
- package/dist/lib/fuels/connectors/walletConnect/types.d.ts +0 -12
- package/dist/lib/fuels/connectors/walletConnect/types.js +0 -1
- package/dist/lib/fuels/connectors/walletConnect/utils/index.d.ts +0 -1
- package/dist/lib/fuels/connectors/walletConnect/utils/index.js +0 -1
- package/dist/lib/fuels/connectors/walletConnect/utils/subscribeAndEnforceChain.d.ts +0 -2
- package/dist/lib/fuels/connectors/walletConnect/utils/subscribeAndEnforceChain.js +0 -39
- package/dist/lib/fuels/connectors/walletConnect/web3Modal.d.ts +0 -10
- package/dist/lib/fuels/connectors/walletConnect/web3Modal.js +0 -38
- package/dist/lib/loopring/LoopringAPI.d.ts +0 -12
- package/dist/lib/loopring/LoopringAPI.js +0 -13
- package/dist/lib/loopring/defs.d.ts +0 -425
- package/dist/lib/loopring/defs.js +0 -217
- package/dist/lib/loopring/eddsa.d.ts +0 -29
- package/dist/lib/loopring/eddsa.js +0 -208
- package/dist/lib/loopring/field.d.ts +0 -17
- package/dist/lib/loopring/field.js +0 -61
- package/dist/lib/loopring/formatter.d.ts +0 -137
- package/dist/lib/loopring/formatter.js +0 -516
- package/dist/lib/loopring/helpers.d.ts +0 -36
- package/dist/lib/loopring/helpers.js +0 -140
- package/dist/lib/loopring/jubjub.d.ts +0 -19
- package/dist/lib/loopring/jubjub.js +0 -79
- package/dist/lib/loopring/permutation.d.ts +0 -22
- package/dist/lib/loopring/permutation.js +0 -198
- package/dist/lib/loopring/poseidon/EDDSAUtil.d.ts +0 -14
- package/dist/lib/loopring/poseidon/EDDSAUtil.js +0 -61
- package/dist/lib/loopring/poseidon/babyJub.d.ts +0 -6
- package/dist/lib/loopring/poseidon/babyJub.js +0 -51
- package/dist/lib/loopring/poseidon/eddsa.d.ts +0 -29
- package/dist/lib/loopring/poseidon/eddsa.js +0 -210
- package/dist/lib/loopring/utils.d.ts +0 -76
- package/dist/lib/loopring/utils.js +0 -230
- package/dist/styles/dialog-transition.css +0 -28
- package/dist/styles/globals.css +0 -372
- package/dist/styles/manual-trasnfer-svg.css +0 -299
- package/dist/styles/vaul.css +0 -256
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
// import { providers } from 'ethers'
|
|
2
|
+
// import * as Paradex from "../lib";
|
|
3
|
+
// import { TypedData } from '../lib/types';
|
|
4
|
+
// import AppSettings from '../../../AppSettings';
|
|
5
|
+
// export default async function AuhorizeEthereum(ethersSigner: providers.JsonRpcSigner) {
|
|
6
|
+
// const environment = AppSettings.ApiVersion === 'sandbox' ? 'testnet' : 'prod'
|
|
7
|
+
// const config = await Paradex.Config.fetchConfig(environment);
|
|
8
|
+
// const paraclearProvider = new Paradex.ParaclearProvider.DefaultProvider(config);
|
|
9
|
+
// function ethersSignerAdapter(signer: typeof ethersSigner) {
|
|
10
|
+
// return {
|
|
11
|
+
// async signTypedData(typedData: TypedData) {
|
|
12
|
+
// return await signer!._signTypedData(typedData.domain, typedData.types, typedData.message);
|
|
13
|
+
// },
|
|
14
|
+
// };
|
|
15
|
+
// }
|
|
16
|
+
// const signer = ethersSignerAdapter(ethersSigner);
|
|
17
|
+
// if (!signer) throw new Error('Signer not found');
|
|
18
|
+
// const paradexAccount = await Paradex.Account.fromEthSigner({
|
|
19
|
+
// provider: paraclearProvider,
|
|
20
|
+
// config,
|
|
21
|
+
// signer: signer,
|
|
22
|
+
// });
|
|
23
|
+
// return paradexAccount
|
|
24
|
+
// }
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
// import { AccountInterface } from 'starknet';
|
|
2
|
+
// import * as Paradex from "../lib";
|
|
3
|
+
// import AppSettings from '../../../AppSettings';
|
|
4
|
+
// export async function AuthorizeStarknet(starknetAccount: AccountInterface) {
|
|
5
|
+
// const config = await Paradex.Config.fetchConfig(AppSettings.ApiVersion === "sandbox" ? 'testnet' : 'prod'); ///TODO: check environemnt may be mainnet
|
|
6
|
+
// const paraclearProvider = new Paradex.ParaclearProvider.DefaultProvider(config);
|
|
7
|
+
// const snAccount = starknetAccount
|
|
8
|
+
// const paradexAccount = await Paradex.Account.fromStarknetAccount({
|
|
9
|
+
// provider: paraclearProvider,
|
|
10
|
+
// config,
|
|
11
|
+
// account: snAccount,
|
|
12
|
+
// });
|
|
13
|
+
// return paradexAccount
|
|
14
|
+
// }
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import * as Starknet from 'starknet';
|
|
2
|
-
import type { ParadexConfig } from './config';
|
|
3
|
-
import * as ethereumSigner from './ethereum-signer';
|
|
4
|
-
export interface Account extends Starknet.Account {
|
|
5
|
-
}
|
|
6
|
-
interface FromEthSignerParams {
|
|
7
|
-
readonly provider: Starknet.ProviderOptions | Starknet.ProviderInterface;
|
|
8
|
-
readonly config: ParadexConfig;
|
|
9
|
-
readonly signer: ethereumSigner.EthereumSigner;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Generates a Paradex account from an Ethereum wallet.
|
|
13
|
-
* @returns The generated Paradex account.
|
|
14
|
-
*/
|
|
15
|
-
export declare function fromEthSigner({ provider, config, signer, }: FromEthSignerParams): Promise<Account>;
|
|
16
|
-
interface FromStarknetAccountParams {
|
|
17
|
-
/** Paradex chain provider */
|
|
18
|
-
readonly provider: Starknet.ProviderOptions | Starknet.ProviderInterface;
|
|
19
|
-
readonly config: ParadexConfig;
|
|
20
|
-
readonly account: Starknet.AccountInterface;
|
|
21
|
-
readonly starknetProvider?: Starknet.ProviderInterface;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Generates a Paradex account from a Starknet signer.
|
|
25
|
-
* @returns The generated Paradex account.
|
|
26
|
-
*/
|
|
27
|
-
export declare function fromStarknetAccount({ provider, config, account, starknetProvider, }: FromStarknetAccountParams): Promise<Account>;
|
|
28
|
-
export {};
|
|
@@ -1,53 +1,102 @@
|
|
|
1
|
-
import { keyDerivation } from '@starkware-industries/starkware-crypto-utils';
|
|
2
|
-
import * as Starknet from 'starknet';
|
|
3
|
-
import
|
|
4
|
-
import * as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
1
|
+
// import { keyDerivation } from '@starkware-industries/starkware-crypto-utils';
|
|
2
|
+
// import * as Starknet from 'starknet';
|
|
3
|
+
// import type { ParadexConfig } from './config';
|
|
4
|
+
// import * as ethereumSigner from './ethereum-signer';
|
|
5
|
+
// import * as starknetSigner from './starknet-signer';
|
|
6
|
+
// import type { Hex } from './types';
|
|
7
|
+
// export interface Account extends Starknet.Account {}
|
|
8
|
+
// interface FromEthSignerParams {
|
|
9
|
+
// readonly provider: Starknet.ProviderOptions | Starknet.ProviderInterface;
|
|
10
|
+
// readonly config: ParadexConfig;
|
|
11
|
+
// readonly signer: ethereumSigner.EthereumSigner;
|
|
12
|
+
// }
|
|
13
|
+
// /**
|
|
14
|
+
// * Generates a Paradex account from an Ethereum wallet.
|
|
15
|
+
// * @returns The generated Paradex account.
|
|
16
|
+
// */
|
|
17
|
+
// export async function fromEthSigner({
|
|
18
|
+
// provider,
|
|
19
|
+
// config,
|
|
20
|
+
// signer,
|
|
21
|
+
// }: FromEthSignerParams): Promise<Account> {
|
|
22
|
+
// const starkKeyTypedData = ethereumSigner.buildEthereumStarkKeyTypedData(
|
|
23
|
+
// config.ethereumChainId,
|
|
24
|
+
// );
|
|
25
|
+
// const seed = await signer.signTypedData(starkKeyTypedData);
|
|
26
|
+
// const privateKey = keyDerivation.getPrivateKeyFromEthSignature(seed);
|
|
27
|
+
// const publicKey = keyDerivation.privateToStarkKey(privateKey);
|
|
28
|
+
// const address = generateAccountAddress({
|
|
29
|
+
// publicKey: `0x${publicKey}`,
|
|
30
|
+
// accountClassHash: config.paraclearAccountHash,
|
|
31
|
+
// accountProxyClassHash: config.paraclearAccountProxyHash,
|
|
32
|
+
// });
|
|
33
|
+
// return new Starknet.Account(provider, address, `0x${privateKey}`);
|
|
34
|
+
// }
|
|
35
|
+
// interface FromStarknetAccountParams {
|
|
36
|
+
// /** Paradex chain provider */
|
|
37
|
+
// readonly provider: Starknet.ProviderOptions | Starknet.ProviderInterface;
|
|
38
|
+
// readonly config: ParadexConfig;
|
|
39
|
+
// readonly account: Starknet.AccountInterface;
|
|
40
|
+
// readonly starknetProvider?: Starknet.ProviderInterface;
|
|
41
|
+
// }
|
|
42
|
+
// /**
|
|
43
|
+
// * Generates a Paradex account from a Starknet signer.
|
|
44
|
+
// * @returns The generated Paradex account.
|
|
45
|
+
// */
|
|
46
|
+
// export async function fromStarknetAccount({
|
|
47
|
+
// provider,
|
|
48
|
+
// config,
|
|
49
|
+
// account,
|
|
50
|
+
// starknetProvider,
|
|
51
|
+
// }: FromStarknetAccountParams): Promise<Account> {
|
|
52
|
+
// const starkKeyTypedData = starknetSigner.buildStarknetStarkKeyTypedData(
|
|
53
|
+
// config.starknetChainId,
|
|
54
|
+
// );
|
|
55
|
+
// const accountSupport = await starknetSigner.getAccountSupport(
|
|
56
|
+
// account,
|
|
57
|
+
// starknetProvider ??
|
|
58
|
+
// starknetSigner.getPublicProvider(config.starknetChainId),
|
|
59
|
+
// );
|
|
60
|
+
// const signature = await account.signMessage(starkKeyTypedData);
|
|
61
|
+
// const seed = accountSupport.getSeedFromSignature(signature);
|
|
62
|
+
// const [privateKey, publicKey] =
|
|
63
|
+
// await starknetSigner.getStarkKeypairFromStarknetSignature(seed);
|
|
64
|
+
// const address = generateAccountAddress({
|
|
65
|
+
// publicKey: `0x${publicKey}`,
|
|
66
|
+
// accountClassHash: config.paraclearAccountHash,
|
|
67
|
+
// accountProxyClassHash: config.paraclearAccountProxyHash,
|
|
68
|
+
// });
|
|
69
|
+
// return new Starknet.Account(provider, address, `0x${privateKey}`);
|
|
70
|
+
// }
|
|
71
|
+
// interface GenerateAccountAddressParams {
|
|
72
|
+
// /** The hash of the account contract in hex format */
|
|
73
|
+
// readonly accountClassHash: Hex;
|
|
74
|
+
// /** The hash of the account proxy contract in hex format */
|
|
75
|
+
// readonly accountProxyClassHash: Hex;
|
|
76
|
+
// /** The public key of the account in hex format */
|
|
77
|
+
// readonly publicKey: Hex;
|
|
78
|
+
// }
|
|
79
|
+
// /**
|
|
80
|
+
// * Generates an account address based on the account contract and public key.
|
|
81
|
+
// */
|
|
82
|
+
// function generateAccountAddress({
|
|
83
|
+
// accountClassHash,
|
|
84
|
+
// accountProxyClassHash,
|
|
85
|
+
// publicKey,
|
|
86
|
+
// }: GenerateAccountAddressParams): Hex {
|
|
87
|
+
// const callData = Starknet.CallData.compile({
|
|
88
|
+
// implementation: accountClassHash,
|
|
89
|
+
// selector: Starknet.hash.getSelectorFromName('initialize'),
|
|
90
|
+
// calldata: Starknet.CallData.compile({
|
|
91
|
+
// signer: publicKey,
|
|
92
|
+
// guardian: '0',
|
|
93
|
+
// }),
|
|
94
|
+
// });
|
|
95
|
+
// const address = Starknet.hash.calculateContractAddressFromHash(
|
|
96
|
+
// publicKey,
|
|
97
|
+
// accountProxyClassHash,
|
|
98
|
+
// callData,
|
|
99
|
+
// 0,
|
|
100
|
+
// );
|
|
101
|
+
// return address as Hex;
|
|
102
|
+
// }
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import * as _Account from './account';
|
|
2
|
-
import * as _Config from './config';
|
|
3
|
-
import * as _Signer from './ethereum-signer';
|
|
4
|
-
import * as _ParaclearProvider from './paraclear-provider';
|
|
5
|
-
import * as _Paraclear from './paraclear';
|
|
6
|
-
export declare const Config: {
|
|
7
|
-
fetchConfig: typeof _Config.fetchConfig;
|
|
8
|
-
};
|
|
9
|
-
export declare const Account: {
|
|
10
|
-
fromEthSigner: typeof _Account.fromEthSigner;
|
|
11
|
-
fromStarknetAccount: typeof _Account.fromStarknetAccount;
|
|
12
|
-
};
|
|
13
|
-
export declare const Signer: {
|
|
14
|
-
ethersSignerAdapter: typeof _Signer.ethersSignerAdapter;
|
|
15
|
-
};
|
|
16
|
-
export declare const ParaclearProvider: {
|
|
17
|
-
DefaultProvider: typeof _ParaclearProvider.DefaultProvider;
|
|
18
|
-
};
|
|
19
|
-
export declare const Paraclear: {
|
|
20
|
-
getTokenBalance: typeof _Paraclear.getTokenBalance;
|
|
21
|
-
getSocializedLossFactor: typeof _Paraclear.getSocializedLossFactor;
|
|
22
|
-
getReceivableAmount: typeof _Paraclear.getReceivableAmount;
|
|
23
|
-
withdraw: typeof _Paraclear.withdraw;
|
|
24
|
-
};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import * as _Account from './account';
|
|
2
|
-
import * as _Config from './config';
|
|
3
|
-
import * as _Signer from './ethereum-signer';
|
|
4
|
-
import * as _ParaclearProvider from './paraclear-provider';
|
|
5
|
-
import * as _Paraclear from './paraclear';
|
|
6
|
-
export const Config = { fetchConfig: _Config.fetchConfig };
|
|
7
|
-
export const Account = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
export const Signer = { ethersSignerAdapter: _Signer.ethersSignerAdapter };
|
|
12
|
-
export const ParaclearProvider = {
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
export const Paraclear = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
1
|
+
// import * as _Account from './account';
|
|
2
|
+
// import * as _Config from './config';
|
|
3
|
+
// import * as _Signer from './ethereum-signer';
|
|
4
|
+
// import * as _ParaclearProvider from './paraclear-provider';
|
|
5
|
+
// import * as _Paraclear from './paraclear';
|
|
6
|
+
// export const Config = { fetchConfig: _Config.fetchConfig };
|
|
7
|
+
// export const Account = {
|
|
8
|
+
// fromEthSigner: _Account.fromEthSigner,
|
|
9
|
+
// fromStarknetAccount: _Account.fromStarknetAccount,
|
|
10
|
+
// };
|
|
11
|
+
// export const Signer = { ethersSignerAdapter: _Signer.ethersSignerAdapter };
|
|
12
|
+
// export const ParaclearProvider = {
|
|
13
|
+
// DefaultProvider: _ParaclearProvider.DefaultProvider,
|
|
14
|
+
// };
|
|
15
|
+
// export const Paraclear = {
|
|
16
|
+
// getTokenBalance: _Paraclear.getTokenBalance,
|
|
17
|
+
// getSocializedLossFactor: _Paraclear.getSocializedLossFactor,
|
|
18
|
+
// getReceivableAmount: _Paraclear.getReceivableAmount,
|
|
19
|
+
// withdraw: _Paraclear.withdraw,
|
|
20
|
+
// };
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import * as Starknet from 'starknet';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
// import * as Starknet from 'starknet';
|
|
2
|
+
// import type { ParadexConfig } from './config';
|
|
3
|
+
// export class DefaultProvider extends Starknet.RpcProvider {
|
|
4
|
+
// constructor(config: ParadexConfig) {
|
|
5
|
+
// super({
|
|
6
|
+
// nodeUrl: config.paradexFullNodeRpcUrl,
|
|
7
|
+
// chainId: Starknet.shortString.encodeShortString(
|
|
8
|
+
// config.paradexChainId,
|
|
9
|
+
// ) as Starknet.RpcProviderOptions['chainId'],
|
|
10
|
+
// });
|
|
11
|
+
// }
|
|
12
|
+
// }
|
|
13
|
+
// export type ParaclearProvider = DefaultProvider;
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import * as Starknet from 'starknet';
|
|
2
|
-
import type { Account } from './account';
|
|
3
|
-
import type { ParadexConfig } from './config';
|
|
4
|
-
import type { ParaclearProvider } from './paraclear-provider';
|
|
5
|
-
import type { Hex } from './types';
|
|
6
|
-
interface GetBalanceParams {
|
|
7
|
-
readonly config: ParadexConfig;
|
|
8
|
-
readonly provider: Pick<ParaclearProvider, 'callContract'>;
|
|
9
|
-
/**
|
|
10
|
-
* Account to get the balance for.
|
|
11
|
-
*/
|
|
12
|
-
readonly account: Pick<Account, 'address'>;
|
|
13
|
-
/**
|
|
14
|
-
* Token symbol.
|
|
15
|
-
* @example 'USDC'
|
|
16
|
-
*/
|
|
17
|
-
readonly token: string;
|
|
18
|
-
}
|
|
19
|
-
interface GetBalanceResult {
|
|
20
|
-
/**
|
|
21
|
-
* Token balance as a decimal string.
|
|
22
|
-
* @example '100.45'
|
|
23
|
-
* @example '45.2'
|
|
24
|
-
*/
|
|
25
|
-
readonly size: string;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Get the Paraclear balance of the given token for the given account.
|
|
29
|
-
*/
|
|
30
|
-
export declare function getTokenBalance(params: GetBalanceParams): Promise<GetBalanceResult>;
|
|
31
|
-
interface GetSocializedLossFactorParams {
|
|
32
|
-
readonly config: ParadexConfig;
|
|
33
|
-
readonly provider: Pick<ParaclearProvider, 'callContract'>;
|
|
34
|
-
}
|
|
35
|
-
interface GetSocializedLossFactorResult {
|
|
36
|
-
readonly socializedLossFactor: string;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Socialized losses happen when Paradex Insurance Fund is bankrupt
|
|
40
|
-
* due to large amounts of unprofitable liquidations. When socialized
|
|
41
|
-
* losses are active, (socialized loss factor > 0), the amount that
|
|
42
|
-
* the user will receive when withdrawing will be smaller than the
|
|
43
|
-
* requested amount.
|
|
44
|
-
*/
|
|
45
|
-
export declare function getSocializedLossFactor(params: GetSocializedLossFactorParams): Promise<GetSocializedLossFactorResult>;
|
|
46
|
-
interface GetReceivableAmountParams {
|
|
47
|
-
readonly config: ParadexConfig;
|
|
48
|
-
readonly provider: Pick<ParaclearProvider, 'callContract'>;
|
|
49
|
-
/**
|
|
50
|
-
* Token symbol.
|
|
51
|
-
* @example 'USDC'
|
|
52
|
-
*/
|
|
53
|
-
readonly token: string;
|
|
54
|
-
/**
|
|
55
|
-
* Amount of to withdraw from Paradex, as a decimal string.
|
|
56
|
-
* The receivable amount will be calculated based on this amount and
|
|
57
|
-
* can be less than the requested amount if socialized loss is active.
|
|
58
|
-
*/
|
|
59
|
-
readonly amount: string;
|
|
60
|
-
}
|
|
61
|
-
interface GetReceivableAmountResult {
|
|
62
|
-
/**
|
|
63
|
-
* Amount that will be received from Paradex, after socialized loss,
|
|
64
|
-
* if applicable, after a withdrawal of the given amount parameter.
|
|
65
|
-
* Decimal string.
|
|
66
|
-
* @example '99.45'
|
|
67
|
-
*/
|
|
68
|
-
readonly receivableAmount: string;
|
|
69
|
-
/**
|
|
70
|
-
* The receivable amount, converted to be used in chain calls,
|
|
71
|
-
* using the Paraclear decimals.
|
|
72
|
-
* @example '9945000000'
|
|
73
|
-
*/
|
|
74
|
-
readonly receivableAmountChain: string;
|
|
75
|
-
/**
|
|
76
|
-
* Socialized loss factor used to calculate the receivable amount.
|
|
77
|
-
* Decimal string.
|
|
78
|
-
* @example '0.05'
|
|
79
|
-
*/
|
|
80
|
-
readonly socializedLossFactor: string;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* The receivable amount is calculated based on the current
|
|
84
|
-
* socialized loss factor: amount * (1 - socializedLossFactor)
|
|
85
|
-
*
|
|
86
|
-
* If the socialized loss factor is 0, the receivable amount
|
|
87
|
-
* will be equal to the requested amount.
|
|
88
|
-
*/
|
|
89
|
-
export declare function getReceivableAmount(params: GetReceivableAmountParams): Promise<GetReceivableAmountResult>;
|
|
90
|
-
interface WithdrawParams {
|
|
91
|
-
readonly config: ParadexConfig;
|
|
92
|
-
/**
|
|
93
|
-
* Account to withdraw from.
|
|
94
|
-
*/
|
|
95
|
-
readonly account: Account;
|
|
96
|
-
/**
|
|
97
|
-
* Token symbol.
|
|
98
|
-
* @example 'USDC'
|
|
99
|
-
*/
|
|
100
|
-
readonly token: string;
|
|
101
|
-
/**
|
|
102
|
-
* Amount to withdraw from Paradex.
|
|
103
|
-
* Note that this amount can be less than the amount that will be
|
|
104
|
-
* received if socialized loss is active. Use {@link getReceivableAmount}
|
|
105
|
-
* to calculate the amount that will be received.
|
|
106
|
-
* Decimal string.
|
|
107
|
-
* @example '100.45'
|
|
108
|
-
* @example '45.2'
|
|
109
|
-
*/
|
|
110
|
-
readonly amount: string;
|
|
111
|
-
/**
|
|
112
|
-
* Call to transfer funds to the bridge. This transaction will be called
|
|
113
|
-
* as the second transaction of the withdrawal transactions batch.
|
|
114
|
-
*
|
|
115
|
-
* The bridge call must be made with the receivable amount calculated
|
|
116
|
-
* using {@link getReceivableAmount}.
|
|
117
|
-
*/
|
|
118
|
-
readonly bridgeCall: Starknet.Call | readonly Starknet.Call[];
|
|
119
|
-
}
|
|
120
|
-
interface TransactionResult {
|
|
121
|
-
readonly hash: Hex;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Withdraw funds from Paraclear for the given account.
|
|
125
|
-
*
|
|
126
|
-
* Automatically make a batch transaction with `initiate_withdrawal`
|
|
127
|
-
* call to the Paraclear contract along with the transaction passed
|
|
128
|
-
* as `params.bridgeCall` The batch call is atomic. If either of
|
|
129
|
-
* the transactions fail, the entire batch gets reverted.
|
|
130
|
-
*
|
|
131
|
-
* If socialized loss is active, the bridge call must be constructed
|
|
132
|
-
* with an amount that accounts for the loss. To calculate that amount,
|
|
133
|
-
* use {@link getReceivableAmount}. Failing to do so can result in a
|
|
134
|
-
* failed withdrawal.
|
|
135
|
-
*/
|
|
136
|
-
export declare function withdraw(params: WithdrawParams): Promise<TransactionResult>;
|
|
137
|
-
export {};
|