@funkit/fun-relay 2.1.15 → 2.1.16-next.1

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/index.mjs CHANGED
@@ -39,7 +39,14 @@ var RELAY_NATIVE_TOKEN = "0x0000000000000000000000000000000000000000";
39
39
  var RELAY_NATIVE_TOKEN_HYPERCORE = "0x00000000000000000000000000000000";
40
40
  var RELAY_NATIVE_TOKEN_SOLANA = "11111111111111111111111111111111";
41
41
  var RELAY_NATIVE_TOKEN_BITCOIN = "bc1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqmql8k8";
42
- var RELAY_NATIVE_TOKEN_LIGHTER = "0";
42
+ var RELAY_LIGHTER_USDC_PERPS = "0";
43
+ var RELAY_LIGHTER_USDC_SPOT = "3";
44
+ var RELAY_LIGHTER_ETH_SPOT = "1";
45
+ var RELAY_LIGHTER_FUN_ADDRESS_MAP = {
46
+ "0x0000000000000000000000000000000000000000": RELAY_LIGHTER_USDC_PERPS,
47
+ "0x0000000000000000000000000000000000000001": RELAY_LIGHTER_ETH_SPOT,
48
+ "0x0000000000000000000000000000000000000003": RELAY_LIGHTER_USDC_SPOT
49
+ };
43
50
  var FUN_RELAY_REVENUE_WALLET = "0xdfd877679e95c1276c85801805b2c2ab8f4f4cf6";
44
51
  var FUN_RELAY_REFERRER = "funxyz";
45
52
  var RELAY_QUOTE_CHECKOUT_TIME_BUFFER_MS = 25e3;
@@ -101,11 +108,17 @@ function convertFunToRelayTokenAddress(address, chainId) {
101
108
  case FUN_SOLANA_CHAIN_ID_NUMBER:
102
109
  return RELAY_NATIVE_TOKEN_SOLANA;
103
110
  case RELAY_LIGHTER_CHAIN_ID_NUMBER:
104
- return RELAY_NATIVE_TOKEN_LIGHTER;
111
+ return RELAY_LIGHTER_USDC_PERPS;
105
112
  default:
106
113
  return RELAY_NATIVE_TOKEN;
107
114
  }
108
115
  }
116
+ if (RELAY_LIGHTER_CHAIN_ID_NUMBER === chainId) {
117
+ const relayAddress = RELAY_LIGHTER_FUN_ADDRESS_MAP[address.toLowerCase()];
118
+ if (relayAddress) {
119
+ return relayAddress;
120
+ }
121
+ }
109
122
  return address;
110
123
  }
111
124
  function convertFunToRelayChainId(chainId) {
@@ -143,6 +156,17 @@ function jsonStringifyWithBigIntSanitization(serializable) {
143
156
  // return everything else unchanged
144
157
  );
145
158
  }
159
+ function indexBy(items, getKey) {
160
+ const indexedItems = {};
161
+ for (const item of items) {
162
+ const key = getKey(item);
163
+ if (!key) {
164
+ continue;
165
+ }
166
+ indexedItems[key] = item;
167
+ }
168
+ return indexedItems;
169
+ }
146
170
 
147
171
  // src/execution.ts
148
172
  function getTxHash({
@@ -770,7 +794,830 @@ function getSolanaWallet(walletAddress, connection, signTransaction, payerKey) {
770
794
  payerKey
771
795
  );
772
796
  }
797
+
798
+ // src/dynamicRoutes/lighter.ts
799
+ import {
800
+ concat,
801
+ encodeAbiParameters,
802
+ encodeFunctionData as encodeFunctionData2,
803
+ toFunctionSelector
804
+ } from "viem";
805
+ import { mainnet as mainnet2 } from "viem/chains";
806
+
807
+ // src/dynamicRoutes/abi.ts
808
+ var UNWRAP_AND_CALL_ABI = [
809
+ {
810
+ name: "unwrapAndCall",
811
+ type: "function",
812
+ stateMutability: "nonpayable",
813
+ inputs: [
814
+ { name: "target", type: "address" },
815
+ { name: "callData", type: "bytes" }
816
+ ],
817
+ outputs: [{ name: "returnData", type: "bytes" }]
818
+ }
819
+ ];
820
+ var VAULT_DEPOSITOR_ABI = [
821
+ {
822
+ inputs: [
823
+ { internalType: "address", name: "initialOwner", type: "address" }
824
+ ],
825
+ stateMutability: "nonpayable",
826
+ type: "constructor"
827
+ },
828
+ {
829
+ inputs: [
830
+ { internalType: "uint256", name: "amount", type: "uint256" },
831
+ { internalType: "uint256", name: "tickSize", type: "uint256" }
832
+ ],
833
+ name: "AmountBelowMinimumTick",
834
+ type: "error"
835
+ },
836
+ {
837
+ inputs: [{ internalType: "bytes", name: "returnData", type: "bytes" }],
838
+ name: "DepositFailed",
839
+ type: "error"
840
+ },
841
+ { inputs: [], name: "DustRefundFailed", type: "error" },
842
+ { inputs: [], name: "EmptyMethodSignature", type: "error" },
843
+ { inputs: [], name: "InsufficientETHAmount", type: "error" },
844
+ { inputs: [], name: "InsufficientTokenAmount", type: "error" },
845
+ {
846
+ inputs: [{ internalType: "string", name: "reason", type: "string" }],
847
+ name: "InvalidCalldata",
848
+ type: "error"
849
+ },
850
+ { inputs: [], name: "InvalidDustRecipient", type: "error" },
851
+ { inputs: [], name: "InvalidFunctionSelector", type: "error" },
852
+ { inputs: [], name: "InvalidTickSize", type: "error" },
853
+ { inputs: [], name: "InvalidVault", type: "error" },
854
+ { inputs: [], name: "NoETHInContract", type: "error" },
855
+ {
856
+ inputs: [{ internalType: "address", name: "owner", type: "address" }],
857
+ name: "OwnableInvalidOwner",
858
+ type: "error"
859
+ },
860
+ {
861
+ inputs: [{ internalType: "address", name: "account", type: "address" }],
862
+ name: "OwnableUnauthorizedAccount",
863
+ type: "error"
864
+ },
865
+ { inputs: [], name: "ReentrancyGuardReentrantCall", type: "error" },
866
+ {
867
+ inputs: [{ internalType: "address", name: "token", type: "address" }],
868
+ name: "SafeERC20FailedOperation",
869
+ type: "error"
870
+ },
871
+ {
872
+ inputs: [
873
+ { internalType: "address", name: "vault", type: "address" },
874
+ { internalType: "bytes4", name: "selector", type: "bytes4" }
875
+ ],
876
+ name: "SelectorNotAllowed",
877
+ type: "error"
878
+ },
879
+ { inputs: [], name: "VaultAlreadyRegistered", type: "error" },
880
+ { inputs: [], name: "VaultDoesNotSupportNative", type: "error" },
881
+ { inputs: [], name: "VaultNotRegistered", type: "error" },
882
+ { inputs: [], name: "VaultNotRegisteredForDeposit", type: "error" },
883
+ {
884
+ anonymous: false,
885
+ inputs: [
886
+ {
887
+ indexed: true,
888
+ internalType: "address",
889
+ name: "recipient",
890
+ type: "address"
891
+ },
892
+ {
893
+ indexed: true,
894
+ internalType: "address",
895
+ name: "token",
896
+ type: "address"
897
+ },
898
+ {
899
+ indexed: false,
900
+ internalType: "uint256",
901
+ name: "dust",
902
+ type: "uint256"
903
+ },
904
+ {
905
+ indexed: false,
906
+ internalType: "uint256",
907
+ name: "originalAmount",
908
+ type: "uint256"
909
+ },
910
+ {
911
+ indexed: false,
912
+ internalType: "uint256",
913
+ name: "depositedAmount",
914
+ type: "uint256"
915
+ }
916
+ ],
917
+ name: "DustRefunded",
918
+ type: "event"
919
+ },
920
+ {
921
+ anonymous: false,
922
+ inputs: [
923
+ {
924
+ indexed: true,
925
+ internalType: "address",
926
+ name: "vault",
927
+ type: "address"
928
+ },
929
+ {
930
+ indexed: true,
931
+ internalType: "address",
932
+ name: "token",
933
+ type: "address"
934
+ },
935
+ {
936
+ indexed: false,
937
+ internalType: "uint256",
938
+ name: "amount",
939
+ type: "uint256"
940
+ },
941
+ {
942
+ indexed: false,
943
+ internalType: "bytes",
944
+ name: "returnData",
945
+ type: "bytes"
946
+ }
947
+ ],
948
+ name: "FunMediatedDeposit",
949
+ type: "event"
950
+ },
951
+ {
952
+ anonymous: false,
953
+ inputs: [
954
+ {
955
+ indexed: true,
956
+ internalType: "address",
957
+ name: "previousOwner",
958
+ type: "address"
959
+ },
960
+ {
961
+ indexed: true,
962
+ internalType: "address",
963
+ name: "newOwner",
964
+ type: "address"
965
+ }
966
+ ],
967
+ name: "OwnershipTransferred",
968
+ type: "event"
969
+ },
970
+ {
971
+ anonymous: false,
972
+ inputs: [
973
+ {
974
+ indexed: true,
975
+ internalType: "address",
976
+ name: "vault",
977
+ type: "address"
978
+ },
979
+ {
980
+ indexed: true,
981
+ internalType: "bytes4",
982
+ name: "newSelector",
983
+ type: "bytes4"
984
+ }
985
+ ],
986
+ name: "SelectorUpdated",
987
+ type: "event"
988
+ },
989
+ {
990
+ anonymous: false,
991
+ inputs: [
992
+ {
993
+ indexed: true,
994
+ internalType: "address",
995
+ name: "vault",
996
+ type: "address"
997
+ },
998
+ {
999
+ indexed: false,
1000
+ internalType: "string",
1001
+ name: "methodSignature",
1002
+ type: "string"
1003
+ },
1004
+ {
1005
+ indexed: false,
1006
+ internalType: "bool",
1007
+ name: "convertTo18Decimals",
1008
+ type: "bool"
1009
+ }
1010
+ ],
1011
+ name: "VaultRegistered",
1012
+ type: "event"
1013
+ },
1014
+ {
1015
+ anonymous: false,
1016
+ inputs: [
1017
+ {
1018
+ indexed: true,
1019
+ internalType: "address",
1020
+ name: "vault",
1021
+ type: "address"
1022
+ }
1023
+ ],
1024
+ name: "VaultRemoved",
1025
+ type: "event"
1026
+ },
1027
+ {
1028
+ inputs: [],
1029
+ name: "AMOUNT_PLACEHOLDER",
1030
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
1031
+ stateMutability: "view",
1032
+ type: "function"
1033
+ },
1034
+ {
1035
+ inputs: [],
1036
+ name: "AMOUNT_PLACEHOLDER_BYTES32",
1037
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
1038
+ stateMutability: "view",
1039
+ type: "function"
1040
+ },
1041
+ {
1042
+ inputs: [],
1043
+ name: "NATIVE_TOKEN",
1044
+ outputs: [{ internalType: "address", name: "", type: "address" }],
1045
+ stateMutability: "view",
1046
+ type: "function"
1047
+ },
1048
+ {
1049
+ inputs: [
1050
+ { internalType: "uint256", name: "amount", type: "uint256" },
1051
+ { internalType: "uint256", name: "tickSize", type: "uint256" }
1052
+ ],
1053
+ name: "calculateTickRounding",
1054
+ outputs: [
1055
+ { internalType: "uint256", name: "roundedAmount", type: "uint256" },
1056
+ { internalType: "uint256", name: "dust", type: "uint256" }
1057
+ ],
1058
+ stateMutability: "pure",
1059
+ type: "function"
1060
+ },
1061
+ {
1062
+ inputs: [
1063
+ { internalType: "address", name: "token", type: "address" },
1064
+ { internalType: "address", name: "vault", type: "address" },
1065
+ { internalType: "bytes", name: "callData", type: "bytes" },
1066
+ { internalType: "uint256", name: "minAmountOut", type: "uint256" }
1067
+ ],
1068
+ name: "deposit",
1069
+ outputs: [{ internalType: "bytes", name: "returnData", type: "bytes" }],
1070
+ stateMutability: "nonpayable",
1071
+ type: "function"
1072
+ },
1073
+ {
1074
+ inputs: [
1075
+ { internalType: "address", name: "token", type: "address" },
1076
+ { internalType: "address", name: "vault", type: "address" },
1077
+ { internalType: "bytes", name: "callData", type: "bytes" },
1078
+ { internalType: "uint256", name: "minAmountOut", type: "uint256" },
1079
+ { internalType: "uint256", name: "tickSize", type: "uint256" },
1080
+ { internalType: "address", name: "dustRecipient", type: "address" }
1081
+ ],
1082
+ name: "depositWithTick",
1083
+ outputs: [{ internalType: "bytes", name: "returnData", type: "bytes" }],
1084
+ stateMutability: "nonpayable",
1085
+ type: "function"
1086
+ },
1087
+ {
1088
+ inputs: [{ internalType: "address", name: "vault", type: "address" }],
1089
+ name: "getAllowedSelector",
1090
+ outputs: [{ internalType: "bytes4", name: "", type: "bytes4" }],
1091
+ stateMutability: "view",
1092
+ type: "function"
1093
+ },
1094
+ {
1095
+ inputs: [{ internalType: "uint256", name: "tickSize", type: "uint256" }],
1096
+ name: "getMinimumDepositForTick",
1097
+ outputs: [{ internalType: "uint256", name: "minAmount", type: "uint256" }],
1098
+ stateMutability: "pure",
1099
+ type: "function"
1100
+ },
1101
+ {
1102
+ inputs: [{ internalType: "address", name: "vault", type: "address" }],
1103
+ name: "getVaultConfig",
1104
+ outputs: [
1105
+ {
1106
+ components: [
1107
+ { internalType: "bool", name: "isRegistered", type: "bool" },
1108
+ { internalType: "bool", name: "convertTo18Decimals", type: "bool" },
1109
+ { internalType: "bool", name: "allowsNative", type: "bool" },
1110
+ { internalType: "bytes4", name: "allowedSelector", type: "bytes4" }
1111
+ ],
1112
+ internalType: "struct VaultConfigLib.VaultConfig",
1113
+ name: "config",
1114
+ type: "tuple"
1115
+ }
1116
+ ],
1117
+ stateMutability: "view",
1118
+ type: "function"
1119
+ },
1120
+ {
1121
+ inputs: [{ internalType: "address", name: "vault", type: "address" }],
1122
+ name: "isVaultRegistered",
1123
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
1124
+ stateMutability: "view",
1125
+ type: "function"
1126
+ },
1127
+ {
1128
+ inputs: [],
1129
+ name: "owner",
1130
+ outputs: [{ internalType: "address", name: "", type: "address" }],
1131
+ stateMutability: "view",
1132
+ type: "function"
1133
+ },
1134
+ {
1135
+ inputs: [
1136
+ { internalType: "address", name: "vault", type: "address" },
1137
+ { internalType: "string", name: "vaultABI", type: "string" },
1138
+ {
1139
+ internalType: "bytes4",
1140
+ name: "allowedFunctionSelector",
1141
+ type: "bytes4"
1142
+ },
1143
+ { internalType: "bool", name: "convertTo18Decimals", type: "bool" },
1144
+ { internalType: "bool", name: "allowsNative", type: "bool" }
1145
+ ],
1146
+ name: "registerVault",
1147
+ outputs: [],
1148
+ stateMutability: "nonpayable",
1149
+ type: "function"
1150
+ },
1151
+ {
1152
+ inputs: [{ internalType: "address", name: "vault", type: "address" }],
1153
+ name: "removeVault",
1154
+ outputs: [],
1155
+ stateMutability: "nonpayable",
1156
+ type: "function"
1157
+ },
1158
+ {
1159
+ inputs: [],
1160
+ name: "renounceOwnership",
1161
+ outputs: [],
1162
+ stateMutability: "nonpayable",
1163
+ type: "function"
1164
+ },
1165
+ {
1166
+ inputs: [{ internalType: "address", name: "newOwner", type: "address" }],
1167
+ name: "transferOwnership",
1168
+ outputs: [],
1169
+ stateMutability: "nonpayable",
1170
+ type: "function"
1171
+ },
1172
+ {
1173
+ inputs: [
1174
+ { internalType: "address", name: "vault", type: "address" },
1175
+ { internalType: "bytes4", name: "newSelector", type: "bytes4" }
1176
+ ],
1177
+ name: "updateAllowedSelector",
1178
+ outputs: [],
1179
+ stateMutability: "nonpayable",
1180
+ type: "function"
1181
+ },
1182
+ {
1183
+ inputs: [
1184
+ { internalType: "uint256", name: "amount", type: "uint256" },
1185
+ { internalType: "uint256", name: "tickSize", type: "uint256" }
1186
+ ],
1187
+ name: "validateAmountForTick",
1188
+ outputs: [
1189
+ { internalType: "bool", name: "isValid", type: "bool" },
1190
+ { internalType: "uint256", name: "roundedAmount", type: "uint256" },
1191
+ { internalType: "uint256", name: "dust", type: "uint256" }
1192
+ ],
1193
+ stateMutability: "pure",
1194
+ type: "function"
1195
+ },
1196
+ {
1197
+ inputs: [{ internalType: "address", name: "vault", type: "address" }],
1198
+ name: "vaultAllowsNative",
1199
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
1200
+ stateMutability: "view",
1201
+ type: "function"
1202
+ },
1203
+ {
1204
+ inputs: [{ internalType: "address", name: "", type: "address" }],
1205
+ name: "vaultConfigs",
1206
+ outputs: [{ internalType: "uint40", name: "", type: "uint40" }],
1207
+ stateMutability: "view",
1208
+ type: "function"
1209
+ },
1210
+ {
1211
+ inputs: [{ internalType: "address", name: "vault", type: "address" }],
1212
+ name: "vaultRequires18Decimals",
1213
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
1214
+ stateMutability: "view",
1215
+ type: "function"
1216
+ },
1217
+ { stateMutability: "payable", type: "receive" }
1218
+ ];
1219
+
1220
+ // src/dynamicRoutes/assets.ts
1221
+ var ASSET_LOGO_SRCS = {
1222
+ $MFER: "https://sdk-cdn.fun.xyz/images/mfer.png",
1223
+ AARBUSDCN: "https://sdk-cdn.fun.xyz/images/aarbusdcn.png",
1224
+ AAVE: "https://sdk-cdn.fun.xyz/images/aave.svg",
1225
+ AERO: "https://sdk-cdn.fun.xyz/images/aero.svg",
1226
+ APE: "https://sdk-cdn.fun.xyz/images/ape.svg",
1227
+ APOLWMATIC: "https://sdk-cdn.fun.xyz/images/apolwmatic.png",
1228
+ ARB: "https://sdk-cdn.fun.xyz/images/arb.svg",
1229
+ BEHYPE: "https://sdk-cdn.fun.xyz/images/behype.svg",
1230
+ BENTO: "https://sdk-cdn.fun.xyz/images/bento.png",
1231
+ BLERF: "https://sdk-cdn.fun.xyz/images/blerf.png",
1232
+ BRETT: "https://sdk-cdn.fun.xyz/images/brett.svg",
1233
+ BSHIB: "https://sdk-cdn.fun.xyz/images/bshib.png",
1234
+ BTC: "https://sdk-cdn.fun.xyz/images/btc.svg",
1235
+ CBBTC: "https://sdk-cdn.fun.xyz/images/cbbtc.svg",
1236
+ CBETH: "https://sdk-cdn.fun.xyz/images/cbeth.png",
1237
+ CRO: "https://sdk-cdn.fun.xyz/images/cro.svg",
1238
+ CRV: "https://sdk-cdn.fun.xyz/images/crv.svg",
1239
+ DAI: "https://sdk-cdn.fun.xyz/images/dai.svg",
1240
+ DEGEN: "https://sdk-cdn.fun.xyz/images/degen.svg",
1241
+ ETH: "https://sdk-cdn.fun.xyz/images/eth.svg",
1242
+ GMX: "https://sdk-cdn.fun.xyz/images/gmx.svg",
1243
+ GRT: "https://sdk-cdn.fun.xyz/images/grt.svg",
1244
+ HYPE: "https://sdk-cdn.fun.xyz/images/hype.svg",
1245
+ IMX: "https://sdk-cdn.fun.xyz/images/imx.svg",
1246
+ INJ: "https://sdk-cdn.fun.xyz/images/inj.svg",
1247
+ LDO: "https://sdk-cdn.fun.xyz/images/ldo.svg",
1248
+ LINK: "https://sdk-cdn.fun.xyz/images/link.svg",
1249
+ LUCK: "https://sdk-cdn.fun.xyz/images/luck.png",
1250
+ MATIC: "https://sdk-cdn.fun.xyz/images/matic.svg",
1251
+ MFER: "https://sdk-cdn.fun.xyz/images/mfer.png",
1252
+ MKR: "https://sdk-cdn.fun.xyz/images/mkr.svg",
1253
+ MNT: "https://sdk-cdn.fun.xyz/images/mnt.svg",
1254
+ PENDLE: "https://sdk-cdn.fun.xyz/images/pendle.svg",
1255
+ POL: "https://sdk-cdn.fun.xyz/images/matic.svg",
1256
+ PYUSD: "https://sdk-cdn.fun.xyz/images/pyusd.svg",
1257
+ QNT: "https://sdk-cdn.fun.xyz/images/qnt.svg",
1258
+ RNDR: "https://sdk-cdn.fun.xyz/images/rndr.svg",
1259
+ ROOST: "https://sdk-cdn.fun.xyz/images/roost.png",
1260
+ SAND: "https://sdk-cdn.fun.xyz/images/sand.svg",
1261
+ SHIB: "https://sdk-cdn.fun.xyz/images/shib.svg",
1262
+ SNX: "https://sdk-cdn.fun.xyz/images/snx.svg",
1263
+ SOL: "https://sdk-cdn.fun.xyz/images/sol.svg",
1264
+ SUSDS: "https://sdk-cdn.fun.xyz/images/susds.svg",
1265
+ TYBG: "https://sdk-cdn.fun.xyz/images/tybg.png",
1266
+ UNI: "https://sdk-cdn.fun.xyz/images/uni.svg",
1267
+ USDC: "https://sdk-cdn.fun.xyz/images/usdc.svg",
1268
+ "USDC.E": "https://sdk-cdn.fun.xyz/images/usdc.svg",
1269
+ USDE: "https://sdk-cdn.fun.xyz/images/usde.svg",
1270
+ WUSDE: "https://sdk-cdn.fun.xyz/images/usde.svg",
1271
+ EUSDE: "https://sdk-cdn.fun.xyz/images/eusde.svg",
1272
+ USDT: "https://sdk-cdn.fun.xyz/images/usdt.svg",
1273
+ "USD\u20AE0": "https://sdk-cdn.fun.xyz/images/usdt0.svg",
1274
+ USDT0: "https://sdk-cdn.fun.xyz/images/usdt0.svg",
1275
+ USDS: "https://sdk-cdn.fun.xyz/images/usds.svg",
1276
+ USDH: "https://sdk-cdn.fun.xyz/images/usdh.svg",
1277
+ VRTX: "https://sdk-cdn.fun.xyz/images/vrtx.svg",
1278
+ WBTC: "https://sdk-cdn.fun.xyz/images/wbtc.svg",
1279
+ WEETH: "https://sdk-cdn.fun.xyz/images/weeth.png",
1280
+ WETH: "https://sdk-cdn.fun.xyz/images/weth.svg",
1281
+ WHYPE: "https://sdk-cdn.fun.xyz/images/whype.png",
1282
+ WSTETH: "https://sdk-cdn.fun.xyz/images/wsteth.png",
1283
+ TRUMP: "https://sdk-cdn.fun.xyz/images/trump.png",
1284
+ BNB: "https://sdk-cdn.fun.xyz/images/bsc.svg",
1285
+ WBNB: "https://sdk-cdn.fun.xyz/images/bsc.svg",
1286
+ BTCB: "https://sdk-cdn.fun.xyz/images/btc.svg",
1287
+ UBTC: "https://sdk-cdn.fun.xyz/images/btc.svg",
1288
+ BUSD: "https://sdk-cdn.fun.xyz/images/busd.svg",
1289
+ XAUT: "https://sdk-cdn.fun.xyz/images/xaut.png",
1290
+ ADA: "https://sdk-cdn.fun.xyz/images/ada.svg",
1291
+ XRP: "https://sdk-cdn.fun.xyz/images/xrp.svg",
1292
+ UDOGE: "https://sdk-cdn.fun.xyz/images/doge.svg",
1293
+ DOGE: "https://sdk-cdn.fun.xyz/images/doge.svg",
1294
+ LTC: "https://sdk-cdn.fun.xyz/images/ltc.svg",
1295
+ HNT: "https://sdk-cdn.fun.xyz/images/hnt.svg",
1296
+ COMP: "https://sdk-cdn.fun.xyz/images/comp.svg",
1297
+ PEPE: "https://sdk-cdn.fun.xyz/images/pepe.svg",
1298
+ LSTHYPE: "https://sdk-cdn.fun.xyz/images/lsthype.svg",
1299
+ HBUSDT: "https://sdk-cdn.fun.xyz/images/hbusdt.svg",
1300
+ WVLP: "https://sdk-cdn.fun.xyz/images/wvlp.svg",
1301
+ LIQUIDHYPE: "https://sdk-cdn.fun.xyz/images/liquidhype.svg",
1302
+ VHYPE: "https://sdk-cdn.fun.xyz/images/vhype.png",
1303
+ HBHYPE: "https://sdk-cdn.fun.xyz/images/hbhype.svg",
1304
+ MON: "https://sdk-cdn.fun.xyz/images/monad.svg",
1305
+ WMON: "https://sdk-cdn.fun.xyz/images/wmon.svg",
1306
+ AUSD: "https://sdk-cdn.fun.xyz/images/ausd.svg",
1307
+ SUSHI: "https://sdk-cdn.fun.xyz/images/sushi.svg"
1308
+ };
1309
+
1310
+ // src/dynamicRoutes/consts.ts
1311
+ import { getAddress } from "viem";
1312
+ import { mainnet } from "viem/chains";
1313
+ import { erc20Abi } from "viem";
1314
+ var AMOUNT_PLACEHOLDER = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffdeadbeefn;
1315
+ var tokenAddresses = {
1316
+ WETH: {
1317
+ [mainnet.id]: getAddress("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2")
1318
+ },
1319
+ USDC: {
1320
+ [mainnet.id]: getAddress("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48")
1321
+ }
1322
+ };
1323
+ var UNWRAP_AND_CALL_ADDRESS = {
1324
+ [mainnet.id]: getAddress("0x177591f2F4DcC3a47F768f6533eC6Edf564d6927")
1325
+ };
1326
+ var VAULT_DEPOSITOR_ADDRESS = {
1327
+ [mainnet.id]: getAddress("0x40b72bB73B1E9380629B205e7880Fa409ae7fcc9")
1328
+ };
1329
+ var LIGHTER_DEPOSIT_ADDRESS = getAddress(
1330
+ "0x3b4d794a66304f130a4db8f2551b0070dfcf5ca7"
1331
+ );
1332
+ var MATCH_ALL_CONDITION = "*";
1333
+
1334
+ // src/dynamicRoutes/utils.ts
1335
+ var createPath = (config) => {
1336
+ return config;
1337
+ };
1338
+ var createRoute = (config) => {
1339
+ const getPathById = (pathId) => {
1340
+ const path = config.paths[pathId];
1341
+ if (!path) {
1342
+ return null;
1343
+ }
1344
+ return path;
1345
+ };
1346
+ return {
1347
+ id: config.id,
1348
+ config,
1349
+ getPathById
1350
+ };
1351
+ };
1352
+ var resolveBadge = (rule) => {
1353
+ if ("badge" in rule.use) {
1354
+ return rule.use.badge;
1355
+ }
1356
+ return void 0;
1357
+ };
1358
+ var initDynamicRouting = (dynamicRoutes, dynamicRoutingConfig) => {
1359
+ const indexedRoutes = indexBy(dynamicRoutes, (route) => route.id);
1360
+ const indexedDynamicRoutingConfig = dynamicRoutingConfig.reduce(
1361
+ (acc, routeConfig) => {
1362
+ const route = indexedRoutes[routeConfig.routeId];
1363
+ if (!route) {
1364
+ return acc;
1365
+ }
1366
+ const { rules } = routeConfig;
1367
+ const indexedRules = indexBy([...rules], (rule) => {
1368
+ if (rule.when === MATCH_ALL_CONDITION) {
1369
+ return MATCH_ALL_CONDITION;
1370
+ }
1371
+ return `${rule.when.chainId}-${rule.when.tokenAddress}`.toLowerCase();
1372
+ });
1373
+ const resolveRule = (rule) => {
1374
+ const path = route.getPathById(rule.use.path);
1375
+ if (!path) {
1376
+ return null;
1377
+ }
1378
+ const badge = resolveBadge(rule);
1379
+ return {
1380
+ path,
1381
+ badge
1382
+ };
1383
+ };
1384
+ const findPath = ({
1385
+ chainId,
1386
+ tokenAddress
1387
+ }) => {
1388
+ const specificRule = indexedRules[`${chainId}-${tokenAddress}`.toLowerCase()];
1389
+ if (specificRule) {
1390
+ return resolveRule(specificRule);
1391
+ }
1392
+ const anyChainSpecificTokenAddress = indexedRules[`${MATCH_ALL_CONDITION}-${tokenAddress}`.toLowerCase()];
1393
+ if (anyChainSpecificTokenAddress) {
1394
+ return resolveRule(anyChainSpecificTokenAddress);
1395
+ }
1396
+ const anyTokenAddressSpecificChain = indexedRules[`${chainId}-${MATCH_ALL_CONDITION}`.toLowerCase()];
1397
+ if (anyTokenAddressSpecificChain) {
1398
+ return resolveRule(anyTokenAddressSpecificChain);
1399
+ }
1400
+ const wildcardRule = indexedRules[MATCH_ALL_CONDITION];
1401
+ if (wildcardRule) {
1402
+ return resolveRule(wildcardRule);
1403
+ }
1404
+ return null;
1405
+ };
1406
+ acc[routeConfig.routeId] = {
1407
+ route,
1408
+ rules,
1409
+ findPath
1410
+ };
1411
+ return acc;
1412
+ },
1413
+ {}
1414
+ );
1415
+ return indexedDynamicRoutingConfig;
1416
+ };
1417
+
1418
+ // src/dynamicRoutes/lighter.ts
1419
+ var NATIVE_TOKEN = FUNKIT_NATIVE_TOKEN;
1420
+ var RELAY_LIGHTER_CHAIN_ID2 = 3586256;
1421
+ var RELAY_LIGHTER_ETH_SPOT_ADDRESS = "0x0000000000000000000000000000000000000001";
1422
+ var RELAY_LIGHTER_USDC_PERPS_ADDRESS = "0x0000000000000000000000000000000000000000";
1423
+ var TICK_SIZE_FOR_ASSET_INDEX = {
1424
+ [3 /* USDC */]: BigInt(1),
1425
+ [1 /* ETH */]: BigInt(10 ** 10)
1426
+ };
1427
+ var DEPOSIT_TOKEN_FOR_ASSET_INDEX = {
1428
+ [3 /* USDC */]: tokenAddresses.USDC[mainnet2.id],
1429
+ [1 /* ETH */]: NATIVE_TOKEN
1430
+ };
1431
+ var USDC_PERPS_SYMBOL = "USDC (Perps)";
1432
+ var ETH_SPOT_SYMBOL = "ETH (Spot)";
1433
+ var generateLighterMainnetDepositActions = ({
1434
+ address,
1435
+ assetIndex,
1436
+ routeType
1437
+ }) => {
1438
+ const depositSelector = toFunctionSelector(
1439
+ "deposit(address,uint16,uint8,uint256)"
1440
+ );
1441
+ const encodedLighterParams = encodeAbiParameters(
1442
+ [
1443
+ { type: "address" },
1444
+ { type: "uint16" },
1445
+ { type: "uint8" },
1446
+ { type: "uint256" }
1447
+ ],
1448
+ [address, assetIndex, routeType, AMOUNT_PLACEHOLDER]
1449
+ );
1450
+ const lighterDepositCalldata = concat([depositSelector, encodedLighterParams]);
1451
+ const depositToken = DEPOSIT_TOKEN_FOR_ASSET_INDEX[assetIndex];
1452
+ const tickSize = TICK_SIZE_FOR_ASSET_INDEX[assetIndex];
1453
+ const dustRecipient = address;
1454
+ if (depositToken === NATIVE_TOKEN) {
1455
+ const vaultWrapperCalldata = encodeFunctionData2({
1456
+ abi: VAULT_DEPOSITOR_ABI,
1457
+ functionName: "depositWithTick",
1458
+ args: [
1459
+ depositToken,
1460
+ // token (native ETH)
1461
+ LIGHTER_DEPOSIT_ADDRESS,
1462
+ // vault (Lighter deposit contract)
1463
+ lighterDepositCalldata,
1464
+ // callData
1465
+ 0n,
1466
+ // minAmountOut
1467
+ tickSize,
1468
+ // tickSize
1469
+ dustRecipient
1470
+ // dustRecipient
1471
+ ]
1472
+ });
1473
+ return [
1474
+ // Step 1: Approve WETH to UnwrapWETHAndCall
1475
+ {
1476
+ contractAbi: erc20Abi,
1477
+ contractAddress: tokenAddresses.WETH[mainnet2.id],
1478
+ functionName: "approve",
1479
+ functionArgs: [
1480
+ UNWRAP_AND_CALL_ADDRESS[mainnet2.id],
1481
+ "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
1482
+ ]
1483
+ },
1484
+ // Step 2: UnwrapWETHAndCall pulls WETH, unwraps to ETH, sends to VaultWrapper, calls deposit
1485
+ {
1486
+ contractAbi: UNWRAP_AND_CALL_ABI,
1487
+ contractAddress: UNWRAP_AND_CALL_ADDRESS[mainnet2.id],
1488
+ functionName: "unwrapAndCall",
1489
+ functionArgs: [
1490
+ VAULT_DEPOSITOR_ADDRESS[mainnet2.id],
1491
+ // target (VaultWrapper)
1492
+ vaultWrapperCalldata
1493
+ // VaultWrapper.deposit() calldata
1494
+ ]
1495
+ }
1496
+ ];
1497
+ }
1498
+ if (depositToken === tokenAddresses.USDC[mainnet2.id]) {
1499
+ return [
1500
+ // Step 1: Approve USDC to VaultDepositor
1501
+ {
1502
+ contractAbi: erc20Abi,
1503
+ contractAddress: tokenAddresses.USDC[mainnet2.id],
1504
+ functionName: "approve",
1505
+ functionArgs: [
1506
+ VAULT_DEPOSITOR_ADDRESS[mainnet2.id],
1507
+ "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
1508
+ // Max approval
1509
+ ]
1510
+ },
1511
+ // Step 2: VaultDepositor pulls USDC and calls Lighter deposit
1512
+ {
1513
+ contractAbi: VAULT_DEPOSITOR_ABI,
1514
+ contractAddress: VAULT_DEPOSITOR_ADDRESS[mainnet2.id],
1515
+ functionName: "depositWithTick",
1516
+ functionArgs: [
1517
+ tokenAddresses.USDC[mainnet2.id],
1518
+ // token (USDC)
1519
+ LIGHTER_DEPOSIT_ADDRESS,
1520
+ // vault (Lighter deposit contract)
1521
+ lighterDepositCalldata,
1522
+ // callData
1523
+ 0n,
1524
+ // minAmountOut
1525
+ tickSize,
1526
+ // tickSize
1527
+ dustRecipient
1528
+ // dustRecipient
1529
+ ]
1530
+ }
1531
+ ];
1532
+ }
1533
+ };
1534
+ var LIGHTER_USDC_PERPS_FUN_MAINNET_DEPOSIT = createPath({
1535
+ targetChain: mainnet2.id.toString(),
1536
+ targetAsset: tokenAddresses.USDC[mainnet2.id],
1537
+ targetAssetTicker: USDC_PERPS_SYMBOL,
1538
+ iconSrc: ASSET_LOGO_SRCS.USDC,
1539
+ generateActionsParams: (address) => async (_finalTargetAssetAmount, outputConfig) => {
1540
+ if (!outputConfig) {
1541
+ return [];
1542
+ }
1543
+ if (outputConfig.targetChain !== mainnet2.id.toString()) {
1544
+ return [];
1545
+ }
1546
+ return generateLighterMainnetDepositActions({
1547
+ address,
1548
+ assetIndex: 3 /* USDC */,
1549
+ routeType: 0 /* Perps */
1550
+ });
1551
+ }
1552
+ });
1553
+ var LIGHTER_ETH_SPOT_FUN_MAINNET_DEPOSIT = createPath({
1554
+ targetChain: mainnet2.id.toString(),
1555
+ targetAsset: tokenAddresses.WETH[mainnet2.id],
1556
+ targetAssetTicker: ETH_SPOT_SYMBOL,
1557
+ iconSrc: ASSET_LOGO_SRCS.ETH,
1558
+ generateActionsParams: (address) => async (_finalTargetAssetAmount, outputConfig) => {
1559
+ if (!outputConfig) {
1560
+ return [];
1561
+ }
1562
+ if (outputConfig.targetChain !== mainnet2.id.toString()) {
1563
+ return [];
1564
+ }
1565
+ return generateLighterMainnetDepositActions({
1566
+ address,
1567
+ assetIndex: 1 /* ETH */,
1568
+ routeType: 1 /* Spot */
1569
+ });
1570
+ }
1571
+ });
1572
+ var LIGHTER_DYNAMIC_ROUTES = [
1573
+ createRoute({
1574
+ id: "LIGHTER_ETH_SPOT",
1575
+ paths: {
1576
+ FUN_MAINNET_DEPOSIT: LIGHTER_ETH_SPOT_FUN_MAINNET_DEPOSIT,
1577
+ RL_TRANSFER: createPath({
1578
+ targetChain: RELAY_LIGHTER_CHAIN_ID2.toString(),
1579
+ targetAsset: RELAY_LIGHTER_ETH_SPOT_ADDRESS,
1580
+ targetAssetTicker: ETH_SPOT_SYMBOL,
1581
+ iconSrc: ASSET_LOGO_SRCS.ETH,
1582
+ getCustomRecipient: ({ l2Address }) => {
1583
+ return l2Address;
1584
+ }
1585
+ })
1586
+ }
1587
+ }),
1588
+ createRoute({
1589
+ id: "LIGHTER_USDC_PERPS",
1590
+ paths: {
1591
+ FUN_MAINNET_DEPOSIT: LIGHTER_USDC_PERPS_FUN_MAINNET_DEPOSIT,
1592
+ RL_TRANSFER: createPath({
1593
+ targetChain: RELAY_LIGHTER_CHAIN_ID2.toString(),
1594
+ targetAsset: RELAY_LIGHTER_USDC_PERPS_ADDRESS,
1595
+ targetAssetTicker: USDC_PERPS_SYMBOL,
1596
+ iconSrc: ASSET_LOGO_SRCS.ETH,
1597
+ getCustomRecipient: ({ l2Address }) => {
1598
+ return l2Address;
1599
+ }
1600
+ })
1601
+ }
1602
+ }),
1603
+ createRoute({
1604
+ id: "LIGHTER_USDC_PERPS_NEW_USER",
1605
+ paths: {
1606
+ FUN_MAINNET_DEPOSIT: LIGHTER_USDC_PERPS_FUN_MAINNET_DEPOSIT
1607
+ }
1608
+ }),
1609
+ createRoute({
1610
+ id: "LIGHTER_ETH_SPOT_NEW_USER",
1611
+ paths: {
1612
+ FUN_MAINNET_DEPOSIT: LIGHTER_ETH_SPOT_FUN_MAINNET_DEPOSIT
1613
+ }
1614
+ })
1615
+ ];
1616
+
1617
+ // src/dynamicRoutes/index.ts
1618
+ var DYNAMIC_ROUTES = [...LIGHTER_DYNAMIC_ROUTES];
773
1619
  export {
1620
+ DYNAMIC_ROUTES,
774
1621
  FUN_RELAY_REFERRER,
775
1622
  FUN_RELAY_REVENUE_WALLET,
776
1623
  LogLevel,
@@ -797,6 +1644,7 @@ export {
797
1644
  getRelayExecutionState,
798
1645
  getRelayQuote,
799
1646
  getSolanaWallet,
1647
+ initDynamicRouting,
800
1648
  initializeRelayClient,
801
1649
  isRelayExecutionTerminalStatus,
802
1650
  parseRelayFees