@rabby-wallet/rabby-swap 0.0.27 → 0.0.28-alpha.2
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/abi.d.ts +86 -0
- package/dist/abi.js +402 -0
- package/dist/consts.d.ts +2 -1
- package/dist/consts.js +1 -0
- package/dist/dexs/kyberswap.d.ts +5 -0
- package/dist/dexs/kyberswap.js +58 -0
- package/dist/dexs/wrapToken.js +5 -0
- package/dist/list.d.ts +34 -0
- package/dist/list.js +35 -0
- package/dist/quote.js +5 -0
- package/dist/utils.d.ts +1 -1
- package/package.json +3 -4
package/dist/abi.d.ts
CHANGED
|
@@ -176,3 +176,89 @@ export declare const UniswapABI: ({
|
|
|
176
176
|
stateMutability: string;
|
|
177
177
|
type: string;
|
|
178
178
|
})[];
|
|
179
|
+
export declare const KyberswapABI: ({
|
|
180
|
+
inputs: {
|
|
181
|
+
internalType: string;
|
|
182
|
+
name: string;
|
|
183
|
+
type: string;
|
|
184
|
+
}[];
|
|
185
|
+
stateMutability: string;
|
|
186
|
+
type: string;
|
|
187
|
+
anonymous?: undefined;
|
|
188
|
+
name?: undefined;
|
|
189
|
+
outputs?: undefined;
|
|
190
|
+
} | {
|
|
191
|
+
anonymous: boolean;
|
|
192
|
+
inputs: {
|
|
193
|
+
indexed: boolean;
|
|
194
|
+
internalType: string;
|
|
195
|
+
name: string;
|
|
196
|
+
type: string;
|
|
197
|
+
}[];
|
|
198
|
+
name: string;
|
|
199
|
+
type: string;
|
|
200
|
+
stateMutability?: undefined;
|
|
201
|
+
outputs?: undefined;
|
|
202
|
+
} | {
|
|
203
|
+
inputs: {
|
|
204
|
+
components: ({
|
|
205
|
+
internalType: string;
|
|
206
|
+
name: string;
|
|
207
|
+
type: string;
|
|
208
|
+
components?: undefined;
|
|
209
|
+
} | {
|
|
210
|
+
components: {
|
|
211
|
+
internalType: string;
|
|
212
|
+
name: string;
|
|
213
|
+
type: string;
|
|
214
|
+
}[];
|
|
215
|
+
internalType: string;
|
|
216
|
+
name: string;
|
|
217
|
+
type: string;
|
|
218
|
+
})[];
|
|
219
|
+
internalType: string;
|
|
220
|
+
name: string;
|
|
221
|
+
type: string;
|
|
222
|
+
}[];
|
|
223
|
+
name: string;
|
|
224
|
+
outputs: {
|
|
225
|
+
internalType: string;
|
|
226
|
+
name: string;
|
|
227
|
+
type: string;
|
|
228
|
+
}[];
|
|
229
|
+
stateMutability: string;
|
|
230
|
+
type: string;
|
|
231
|
+
anonymous?: undefined;
|
|
232
|
+
} | {
|
|
233
|
+
inputs: ({
|
|
234
|
+
internalType: string;
|
|
235
|
+
name: string;
|
|
236
|
+
type: string;
|
|
237
|
+
components?: undefined;
|
|
238
|
+
} | {
|
|
239
|
+
components: {
|
|
240
|
+
internalType: string;
|
|
241
|
+
name: string;
|
|
242
|
+
type: string;
|
|
243
|
+
}[];
|
|
244
|
+
internalType: string;
|
|
245
|
+
name: string;
|
|
246
|
+
type: string;
|
|
247
|
+
})[];
|
|
248
|
+
name: string;
|
|
249
|
+
outputs: {
|
|
250
|
+
internalType: string;
|
|
251
|
+
name: string;
|
|
252
|
+
type: string;
|
|
253
|
+
}[];
|
|
254
|
+
stateMutability: string;
|
|
255
|
+
type: string;
|
|
256
|
+
anonymous?: undefined;
|
|
257
|
+
} | {
|
|
258
|
+
stateMutability: string;
|
|
259
|
+
type: string;
|
|
260
|
+
inputs?: undefined;
|
|
261
|
+
anonymous?: undefined;
|
|
262
|
+
name?: undefined;
|
|
263
|
+
outputs?: undefined;
|
|
264
|
+
})[];
|
package/dist/abi.js
CHANGED
|
@@ -849,3 +849,405 @@ export const UniswapABI = [
|
|
|
849
849
|
type: "function",
|
|
850
850
|
},
|
|
851
851
|
];
|
|
852
|
+
export const KyberswapABI = [
|
|
853
|
+
{
|
|
854
|
+
inputs: [{ internalType: "address", name: "_WETH", type: "address" }],
|
|
855
|
+
stateMutability: "nonpayable",
|
|
856
|
+
type: "constructor",
|
|
857
|
+
},
|
|
858
|
+
{
|
|
859
|
+
anonymous: false,
|
|
860
|
+
inputs: [
|
|
861
|
+
{
|
|
862
|
+
indexed: false,
|
|
863
|
+
internalType: "bytes",
|
|
864
|
+
name: "clientData",
|
|
865
|
+
type: "bytes",
|
|
866
|
+
},
|
|
867
|
+
],
|
|
868
|
+
name: "ClientData",
|
|
869
|
+
type: "event",
|
|
870
|
+
},
|
|
871
|
+
{
|
|
872
|
+
anonymous: false,
|
|
873
|
+
inputs: [
|
|
874
|
+
{
|
|
875
|
+
indexed: false,
|
|
876
|
+
internalType: "string",
|
|
877
|
+
name: "reason",
|
|
878
|
+
type: "string",
|
|
879
|
+
},
|
|
880
|
+
],
|
|
881
|
+
name: "Error",
|
|
882
|
+
type: "event",
|
|
883
|
+
},
|
|
884
|
+
{
|
|
885
|
+
anonymous: false,
|
|
886
|
+
inputs: [
|
|
887
|
+
{
|
|
888
|
+
indexed: false,
|
|
889
|
+
internalType: "address",
|
|
890
|
+
name: "pair",
|
|
891
|
+
type: "address",
|
|
892
|
+
},
|
|
893
|
+
{
|
|
894
|
+
indexed: false,
|
|
895
|
+
internalType: "uint256",
|
|
896
|
+
name: "amountOut",
|
|
897
|
+
type: "uint256",
|
|
898
|
+
},
|
|
899
|
+
{
|
|
900
|
+
indexed: false,
|
|
901
|
+
internalType: "address",
|
|
902
|
+
name: "output",
|
|
903
|
+
type: "address",
|
|
904
|
+
},
|
|
905
|
+
],
|
|
906
|
+
name: "Exchange",
|
|
907
|
+
type: "event",
|
|
908
|
+
},
|
|
909
|
+
{
|
|
910
|
+
anonymous: false,
|
|
911
|
+
inputs: [
|
|
912
|
+
{
|
|
913
|
+
indexed: false,
|
|
914
|
+
internalType: "address",
|
|
915
|
+
name: "token",
|
|
916
|
+
type: "address",
|
|
917
|
+
},
|
|
918
|
+
{
|
|
919
|
+
indexed: false,
|
|
920
|
+
internalType: "uint256",
|
|
921
|
+
name: "totalAmount",
|
|
922
|
+
type: "uint256",
|
|
923
|
+
},
|
|
924
|
+
{
|
|
925
|
+
indexed: false,
|
|
926
|
+
internalType: "uint256",
|
|
927
|
+
name: "totalFee",
|
|
928
|
+
type: "uint256",
|
|
929
|
+
},
|
|
930
|
+
{
|
|
931
|
+
indexed: false,
|
|
932
|
+
internalType: "address[]",
|
|
933
|
+
name: "recipients",
|
|
934
|
+
type: "address[]",
|
|
935
|
+
},
|
|
936
|
+
{
|
|
937
|
+
indexed: false,
|
|
938
|
+
internalType: "uint256[]",
|
|
939
|
+
name: "amounts",
|
|
940
|
+
type: "uint256[]",
|
|
941
|
+
},
|
|
942
|
+
{ indexed: false, internalType: "bool", name: "isBps", type: "bool" },
|
|
943
|
+
],
|
|
944
|
+
name: "Fee",
|
|
945
|
+
type: "event",
|
|
946
|
+
},
|
|
947
|
+
{
|
|
948
|
+
anonymous: false,
|
|
949
|
+
inputs: [
|
|
950
|
+
{
|
|
951
|
+
indexed: true,
|
|
952
|
+
internalType: "address",
|
|
953
|
+
name: "previousOwner",
|
|
954
|
+
type: "address",
|
|
955
|
+
},
|
|
956
|
+
{
|
|
957
|
+
indexed: true,
|
|
958
|
+
internalType: "address",
|
|
959
|
+
name: "newOwner",
|
|
960
|
+
type: "address",
|
|
961
|
+
},
|
|
962
|
+
],
|
|
963
|
+
name: "OwnershipTransferred",
|
|
964
|
+
type: "event",
|
|
965
|
+
},
|
|
966
|
+
{
|
|
967
|
+
anonymous: false,
|
|
968
|
+
inputs: [
|
|
969
|
+
{
|
|
970
|
+
indexed: false,
|
|
971
|
+
internalType: "address",
|
|
972
|
+
name: "sender",
|
|
973
|
+
type: "address",
|
|
974
|
+
},
|
|
975
|
+
{
|
|
976
|
+
indexed: false,
|
|
977
|
+
internalType: "contract IERC20",
|
|
978
|
+
name: "srcToken",
|
|
979
|
+
type: "address",
|
|
980
|
+
},
|
|
981
|
+
{
|
|
982
|
+
indexed: false,
|
|
983
|
+
internalType: "contract IERC20",
|
|
984
|
+
name: "dstToken",
|
|
985
|
+
type: "address",
|
|
986
|
+
},
|
|
987
|
+
{
|
|
988
|
+
indexed: false,
|
|
989
|
+
internalType: "address",
|
|
990
|
+
name: "dstReceiver",
|
|
991
|
+
type: "address",
|
|
992
|
+
},
|
|
993
|
+
{
|
|
994
|
+
indexed: false,
|
|
995
|
+
internalType: "uint256",
|
|
996
|
+
name: "spentAmount",
|
|
997
|
+
type: "uint256",
|
|
998
|
+
},
|
|
999
|
+
{
|
|
1000
|
+
indexed: false,
|
|
1001
|
+
internalType: "uint256",
|
|
1002
|
+
name: "returnAmount",
|
|
1003
|
+
type: "uint256",
|
|
1004
|
+
},
|
|
1005
|
+
],
|
|
1006
|
+
name: "Swapped",
|
|
1007
|
+
type: "event",
|
|
1008
|
+
},
|
|
1009
|
+
{
|
|
1010
|
+
inputs: [],
|
|
1011
|
+
name: "WETH",
|
|
1012
|
+
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
1013
|
+
stateMutability: "view",
|
|
1014
|
+
type: "function",
|
|
1015
|
+
},
|
|
1016
|
+
{
|
|
1017
|
+
inputs: [{ internalType: "address", name: "", type: "address" }],
|
|
1018
|
+
name: "isWhitelist",
|
|
1019
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
1020
|
+
stateMutability: "view",
|
|
1021
|
+
type: "function",
|
|
1022
|
+
},
|
|
1023
|
+
{
|
|
1024
|
+
inputs: [],
|
|
1025
|
+
name: "owner",
|
|
1026
|
+
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
1027
|
+
stateMutability: "view",
|
|
1028
|
+
type: "function",
|
|
1029
|
+
},
|
|
1030
|
+
{
|
|
1031
|
+
inputs: [],
|
|
1032
|
+
name: "renounceOwnership",
|
|
1033
|
+
outputs: [],
|
|
1034
|
+
stateMutability: "nonpayable",
|
|
1035
|
+
type: "function",
|
|
1036
|
+
},
|
|
1037
|
+
{
|
|
1038
|
+
inputs: [
|
|
1039
|
+
{ internalType: "address", name: "token", type: "address" },
|
|
1040
|
+
{ internalType: "uint256", name: "amount", type: "uint256" },
|
|
1041
|
+
],
|
|
1042
|
+
name: "rescueFunds",
|
|
1043
|
+
outputs: [],
|
|
1044
|
+
stateMutability: "nonpayable",
|
|
1045
|
+
type: "function",
|
|
1046
|
+
},
|
|
1047
|
+
{
|
|
1048
|
+
inputs: [
|
|
1049
|
+
{
|
|
1050
|
+
components: [
|
|
1051
|
+
{ internalType: "address", name: "callTarget", type: "address" },
|
|
1052
|
+
{ internalType: "address", name: "approveTarget", type: "address" },
|
|
1053
|
+
{ internalType: "bytes", name: "targetData", type: "bytes" },
|
|
1054
|
+
{
|
|
1055
|
+
components: [
|
|
1056
|
+
{
|
|
1057
|
+
internalType: "contract IERC20",
|
|
1058
|
+
name: "srcToken",
|
|
1059
|
+
type: "address",
|
|
1060
|
+
},
|
|
1061
|
+
{
|
|
1062
|
+
internalType: "contract IERC20",
|
|
1063
|
+
name: "dstToken",
|
|
1064
|
+
type: "address",
|
|
1065
|
+
},
|
|
1066
|
+
{
|
|
1067
|
+
internalType: "address[]",
|
|
1068
|
+
name: "srcReceivers",
|
|
1069
|
+
type: "address[]",
|
|
1070
|
+
},
|
|
1071
|
+
{
|
|
1072
|
+
internalType: "uint256[]",
|
|
1073
|
+
name: "srcAmounts",
|
|
1074
|
+
type: "uint256[]",
|
|
1075
|
+
},
|
|
1076
|
+
{
|
|
1077
|
+
internalType: "address[]",
|
|
1078
|
+
name: "feeReceivers",
|
|
1079
|
+
type: "address[]",
|
|
1080
|
+
},
|
|
1081
|
+
{
|
|
1082
|
+
internalType: "uint256[]",
|
|
1083
|
+
name: "feeAmounts",
|
|
1084
|
+
type: "uint256[]",
|
|
1085
|
+
},
|
|
1086
|
+
{ internalType: "address", name: "dstReceiver", type: "address" },
|
|
1087
|
+
{ internalType: "uint256", name: "amount", type: "uint256" },
|
|
1088
|
+
{
|
|
1089
|
+
internalType: "uint256",
|
|
1090
|
+
name: "minReturnAmount",
|
|
1091
|
+
type: "uint256",
|
|
1092
|
+
},
|
|
1093
|
+
{ internalType: "uint256", name: "flags", type: "uint256" },
|
|
1094
|
+
{ internalType: "bytes", name: "permit", type: "bytes" },
|
|
1095
|
+
],
|
|
1096
|
+
internalType: "struct MetaAggregationRouterV2.SwapDescriptionV2",
|
|
1097
|
+
name: "desc",
|
|
1098
|
+
type: "tuple",
|
|
1099
|
+
},
|
|
1100
|
+
{ internalType: "bytes", name: "clientData", type: "bytes" },
|
|
1101
|
+
],
|
|
1102
|
+
internalType: "struct MetaAggregationRouterV2.SwapExecutionParams",
|
|
1103
|
+
name: "execution",
|
|
1104
|
+
type: "tuple",
|
|
1105
|
+
},
|
|
1106
|
+
],
|
|
1107
|
+
name: "swap",
|
|
1108
|
+
outputs: [
|
|
1109
|
+
{ internalType: "uint256", name: "returnAmount", type: "uint256" },
|
|
1110
|
+
{ internalType: "uint256", name: "gasUsed", type: "uint256" },
|
|
1111
|
+
],
|
|
1112
|
+
stateMutability: "payable",
|
|
1113
|
+
type: "function",
|
|
1114
|
+
},
|
|
1115
|
+
{
|
|
1116
|
+
inputs: [
|
|
1117
|
+
{
|
|
1118
|
+
components: [
|
|
1119
|
+
{ internalType: "address", name: "callTarget", type: "address" },
|
|
1120
|
+
{ internalType: "address", name: "approveTarget", type: "address" },
|
|
1121
|
+
{ internalType: "bytes", name: "targetData", type: "bytes" },
|
|
1122
|
+
{
|
|
1123
|
+
components: [
|
|
1124
|
+
{
|
|
1125
|
+
internalType: "contract IERC20",
|
|
1126
|
+
name: "srcToken",
|
|
1127
|
+
type: "address",
|
|
1128
|
+
},
|
|
1129
|
+
{
|
|
1130
|
+
internalType: "contract IERC20",
|
|
1131
|
+
name: "dstToken",
|
|
1132
|
+
type: "address",
|
|
1133
|
+
},
|
|
1134
|
+
{
|
|
1135
|
+
internalType: "address[]",
|
|
1136
|
+
name: "srcReceivers",
|
|
1137
|
+
type: "address[]",
|
|
1138
|
+
},
|
|
1139
|
+
{
|
|
1140
|
+
internalType: "uint256[]",
|
|
1141
|
+
name: "srcAmounts",
|
|
1142
|
+
type: "uint256[]",
|
|
1143
|
+
},
|
|
1144
|
+
{
|
|
1145
|
+
internalType: "address[]",
|
|
1146
|
+
name: "feeReceivers",
|
|
1147
|
+
type: "address[]",
|
|
1148
|
+
},
|
|
1149
|
+
{
|
|
1150
|
+
internalType: "uint256[]",
|
|
1151
|
+
name: "feeAmounts",
|
|
1152
|
+
type: "uint256[]",
|
|
1153
|
+
},
|
|
1154
|
+
{ internalType: "address", name: "dstReceiver", type: "address" },
|
|
1155
|
+
{ internalType: "uint256", name: "amount", type: "uint256" },
|
|
1156
|
+
{
|
|
1157
|
+
internalType: "uint256",
|
|
1158
|
+
name: "minReturnAmount",
|
|
1159
|
+
type: "uint256",
|
|
1160
|
+
},
|
|
1161
|
+
{ internalType: "uint256", name: "flags", type: "uint256" },
|
|
1162
|
+
{ internalType: "bytes", name: "permit", type: "bytes" },
|
|
1163
|
+
],
|
|
1164
|
+
internalType: "struct MetaAggregationRouterV2.SwapDescriptionV2",
|
|
1165
|
+
name: "desc",
|
|
1166
|
+
type: "tuple",
|
|
1167
|
+
},
|
|
1168
|
+
{ internalType: "bytes", name: "clientData", type: "bytes" },
|
|
1169
|
+
],
|
|
1170
|
+
internalType: "struct MetaAggregationRouterV2.SwapExecutionParams",
|
|
1171
|
+
name: "execution",
|
|
1172
|
+
type: "tuple",
|
|
1173
|
+
},
|
|
1174
|
+
],
|
|
1175
|
+
name: "swapGeneric",
|
|
1176
|
+
outputs: [
|
|
1177
|
+
{ internalType: "uint256", name: "returnAmount", type: "uint256" },
|
|
1178
|
+
{ internalType: "uint256", name: "gasUsed", type: "uint256" },
|
|
1179
|
+
],
|
|
1180
|
+
stateMutability: "payable",
|
|
1181
|
+
type: "function",
|
|
1182
|
+
},
|
|
1183
|
+
{
|
|
1184
|
+
inputs: [
|
|
1185
|
+
{
|
|
1186
|
+
internalType: "contract IAggregationExecutor",
|
|
1187
|
+
name: "caller",
|
|
1188
|
+
type: "address",
|
|
1189
|
+
},
|
|
1190
|
+
{
|
|
1191
|
+
components: [
|
|
1192
|
+
{
|
|
1193
|
+
internalType: "contract IERC20",
|
|
1194
|
+
name: "srcToken",
|
|
1195
|
+
type: "address",
|
|
1196
|
+
},
|
|
1197
|
+
{
|
|
1198
|
+
internalType: "contract IERC20",
|
|
1199
|
+
name: "dstToken",
|
|
1200
|
+
type: "address",
|
|
1201
|
+
},
|
|
1202
|
+
{
|
|
1203
|
+
internalType: "address[]",
|
|
1204
|
+
name: "srcReceivers",
|
|
1205
|
+
type: "address[]",
|
|
1206
|
+
},
|
|
1207
|
+
{ internalType: "uint256[]", name: "srcAmounts", type: "uint256[]" },
|
|
1208
|
+
{
|
|
1209
|
+
internalType: "address[]",
|
|
1210
|
+
name: "feeReceivers",
|
|
1211
|
+
type: "address[]",
|
|
1212
|
+
},
|
|
1213
|
+
{ internalType: "uint256[]", name: "feeAmounts", type: "uint256[]" },
|
|
1214
|
+
{ internalType: "address", name: "dstReceiver", type: "address" },
|
|
1215
|
+
{ internalType: "uint256", name: "amount", type: "uint256" },
|
|
1216
|
+
{ internalType: "uint256", name: "minReturnAmount", type: "uint256" },
|
|
1217
|
+
{ internalType: "uint256", name: "flags", type: "uint256" },
|
|
1218
|
+
{ internalType: "bytes", name: "permit", type: "bytes" },
|
|
1219
|
+
],
|
|
1220
|
+
internalType: "struct MetaAggregationRouterV2.SwapDescriptionV2",
|
|
1221
|
+
name: "desc",
|
|
1222
|
+
type: "tuple",
|
|
1223
|
+
},
|
|
1224
|
+
{ internalType: "bytes", name: "executorData", type: "bytes" },
|
|
1225
|
+
{ internalType: "bytes", name: "clientData", type: "bytes" },
|
|
1226
|
+
],
|
|
1227
|
+
name: "swapSimpleMode",
|
|
1228
|
+
outputs: [
|
|
1229
|
+
{ internalType: "uint256", name: "returnAmount", type: "uint256" },
|
|
1230
|
+
{ internalType: "uint256", name: "gasUsed", type: "uint256" },
|
|
1231
|
+
],
|
|
1232
|
+
stateMutability: "nonpayable",
|
|
1233
|
+
type: "function",
|
|
1234
|
+
},
|
|
1235
|
+
{
|
|
1236
|
+
inputs: [{ internalType: "address", name: "newOwner", type: "address" }],
|
|
1237
|
+
name: "transferOwnership",
|
|
1238
|
+
outputs: [],
|
|
1239
|
+
stateMutability: "nonpayable",
|
|
1240
|
+
type: "function",
|
|
1241
|
+
},
|
|
1242
|
+
{
|
|
1243
|
+
inputs: [
|
|
1244
|
+
{ internalType: "address[]", name: "addr", type: "address[]" },
|
|
1245
|
+
{ internalType: "bool[]", name: "value", type: "bool[]" },
|
|
1246
|
+
],
|
|
1247
|
+
name: "updateWhitelist",
|
|
1248
|
+
outputs: [],
|
|
1249
|
+
stateMutability: "nonpayable",
|
|
1250
|
+
type: "function",
|
|
1251
|
+
},
|
|
1252
|
+
{ stateMutability: "payable", type: "receive" },
|
|
1253
|
+
];
|
package/dist/consts.d.ts
CHANGED
package/dist/consts.js
CHANGED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { CHAINS_ENUM } from "@debank/common";
|
|
2
|
+
import { TxWithChainId, DecodeCalldataResult } from "../quote";
|
|
3
|
+
export declare const SUPPORT_CHAINS: CHAINS_ENUM[];
|
|
4
|
+
export declare const getQuote: (options: import("../quote").QuoteParams, api: import("@rabby-wallet/rabby-api").OpenApiService) => Promise<import("../quote").QuoteResult>;
|
|
5
|
+
export declare const decodeCalldata: (tx: TxWithChainId) => DecodeCalldataResult | null;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { CHAINS_ENUM, CHAINS } from "@debank/common";
|
|
2
|
+
import { Interface } from "@ethersproject/abi";
|
|
3
|
+
import { generateGetQuote, isSameAddress } from "../utils";
|
|
4
|
+
import { KyberswapABI } from "../abi";
|
|
5
|
+
import { DEX_ENUM } from "../consts";
|
|
6
|
+
const NATIVE_TOKEN = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
|
7
|
+
// eth op arb bsc avax ftm cro matic aurora linea btt oas
|
|
8
|
+
export const SUPPORT_CHAINS = [
|
|
9
|
+
CHAINS_ENUM.ETH,
|
|
10
|
+
CHAINS_ENUM.OP,
|
|
11
|
+
CHAINS_ENUM.ARBITRUM,
|
|
12
|
+
CHAINS_ENUM.BSC,
|
|
13
|
+
CHAINS_ENUM.AVAX,
|
|
14
|
+
CHAINS_ENUM.FTM,
|
|
15
|
+
CHAINS_ENUM.CRO,
|
|
16
|
+
CHAINS_ENUM.POLYGON,
|
|
17
|
+
CHAINS_ENUM.AURORA,
|
|
18
|
+
CHAINS_ENUM.LINEA,
|
|
19
|
+
CHAINS_ENUM.BTT,
|
|
20
|
+
// No prev2 support
|
|
21
|
+
// CHAINS_ENUM.ROSE,
|
|
22
|
+
];
|
|
23
|
+
export const getQuote = generateGetQuote({
|
|
24
|
+
SUPPORT_CHAINS,
|
|
25
|
+
id: "kyberswap",
|
|
26
|
+
dex: DEX_ENUM.KYBERSWAP,
|
|
27
|
+
});
|
|
28
|
+
export const decodeCalldata = (tx) => {
|
|
29
|
+
const chain = Object.values(CHAINS).find((item) => item.id === tx.chainId);
|
|
30
|
+
if (!chain)
|
|
31
|
+
return null;
|
|
32
|
+
const contractInterface = new Interface(KyberswapABI);
|
|
33
|
+
const result = contractInterface.parseTransaction({ data: tx.data });
|
|
34
|
+
let desc;
|
|
35
|
+
if (result.name === "swapSimpleMode") {
|
|
36
|
+
const [execution] = result.args;
|
|
37
|
+
desc = execution.desc;
|
|
38
|
+
}
|
|
39
|
+
if (result.name === "swap") {
|
|
40
|
+
const [execution] = result.args;
|
|
41
|
+
desc = execution.desc;
|
|
42
|
+
}
|
|
43
|
+
const { srcToken, amount, dstReceiver, dstToken, minReturnAmount } = desc;
|
|
44
|
+
if (!srcToken || !amount || !dstReceiver || !dstToken || !minReturnAmount) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
fromToken: isSameAddress(srcToken, NATIVE_TOKEN)
|
|
49
|
+
? chain.nativeTokenAddress
|
|
50
|
+
: srcToken,
|
|
51
|
+
fromTokenAmount: amount.toString(),
|
|
52
|
+
toToken: isSameAddress(dstToken, NATIVE_TOKEN)
|
|
53
|
+
? chain.nativeTokenAddress
|
|
54
|
+
: dstToken,
|
|
55
|
+
minReceiveToTokenAmount: minReturnAmount.toString(),
|
|
56
|
+
toTokenReceiver: tx.from,
|
|
57
|
+
};
|
|
58
|
+
};
|
package/dist/dexs/wrapToken.js
CHANGED
|
@@ -22,6 +22,11 @@ export const SUPPORT_CHAINS = [
|
|
|
22
22
|
CHAINS_ENUM.KLAY,
|
|
23
23
|
CHAINS_ENUM.GNOSIS,
|
|
24
24
|
CHAINS_ENUM.CELO,
|
|
25
|
+
CHAINS_ENUM.CRO,
|
|
26
|
+
CHAINS_ENUM.AURORA,
|
|
27
|
+
CHAINS_ENUM.LINEA,
|
|
28
|
+
CHAINS_ENUM.BTT,
|
|
29
|
+
CHAINS_ENUM.ROSE,
|
|
25
30
|
];
|
|
26
31
|
export const getQuote = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
32
|
const chain = CHAINS[options.chain];
|
package/dist/list.d.ts
CHANGED
|
@@ -9,6 +9,11 @@ export declare const WrapTokenAddressMap: {
|
|
|
9
9
|
ARBITRUM: string;
|
|
10
10
|
KLAY: string;
|
|
11
11
|
GNOSIS: string;
|
|
12
|
+
CRO: string;
|
|
13
|
+
LINEA: string;
|
|
14
|
+
AURORA: string;
|
|
15
|
+
BTT: string;
|
|
16
|
+
ROSE: string;
|
|
12
17
|
};
|
|
13
18
|
export declare const DEX_SUPPORT_CHAINS: {
|
|
14
19
|
WrapToken: CHAINS_ENUM[];
|
|
@@ -17,6 +22,7 @@ export declare const DEX_SUPPORT_CHAINS: {
|
|
|
17
22
|
"0xAPI": CHAINS_ENUM[];
|
|
18
23
|
OpenOcean: CHAINS_ENUM[];
|
|
19
24
|
Uniswap: CHAINS_ENUM[];
|
|
25
|
+
Kyberswap: CHAINS_ENUM[];
|
|
20
26
|
};
|
|
21
27
|
export declare const DEX_ROUTER_WHITELIST: {
|
|
22
28
|
"1inch": {
|
|
@@ -72,6 +78,20 @@ export declare const DEX_ROUTER_WHITELIST: {
|
|
|
72
78
|
OP: string;
|
|
73
79
|
ARBITRUM: string;
|
|
74
80
|
};
|
|
81
|
+
Kyberswap: {
|
|
82
|
+
ETH: string;
|
|
83
|
+
POLYGON: string;
|
|
84
|
+
OP: string;
|
|
85
|
+
ARBITRUM: string;
|
|
86
|
+
BSC: string;
|
|
87
|
+
AVAX: string;
|
|
88
|
+
FTM: string;
|
|
89
|
+
CRO: string;
|
|
90
|
+
AURORA: string;
|
|
91
|
+
BTT: string;
|
|
92
|
+
ROSE: string;
|
|
93
|
+
LINEA: string;
|
|
94
|
+
};
|
|
75
95
|
};
|
|
76
96
|
export declare const DEX_SPENDER_WHITELIST: {
|
|
77
97
|
"1inch": {
|
|
@@ -127,4 +147,18 @@ export declare const DEX_SPENDER_WHITELIST: {
|
|
|
127
147
|
OP: string;
|
|
128
148
|
ARBITRUM: string;
|
|
129
149
|
};
|
|
150
|
+
Kyberswap: {
|
|
151
|
+
ETH: string;
|
|
152
|
+
POLYGON: string;
|
|
153
|
+
OP: string;
|
|
154
|
+
ARBITRUM: string;
|
|
155
|
+
BSC: string;
|
|
156
|
+
AVAX: string;
|
|
157
|
+
FTM: string;
|
|
158
|
+
CRO: string;
|
|
159
|
+
AURORA: string;
|
|
160
|
+
BTT: string;
|
|
161
|
+
ROSE: string;
|
|
162
|
+
LINEA: string;
|
|
163
|
+
};
|
|
130
164
|
};
|
package/dist/list.js
CHANGED
|
@@ -5,6 +5,7 @@ import { SUPPORT_CHAINS as oneInchSupportChains } from "./dexs/1inch";
|
|
|
5
5
|
import { SUPPORT_CHAINS as paraswapSupportChains } from "./dexs/paraswap";
|
|
6
6
|
import { SUPPORT_CHAINS as openOceanSupportChains } from "./dexs/openocean";
|
|
7
7
|
import { SUPPORT_CHAINS as uniswapSupportChains } from "./dexs/uniswap";
|
|
8
|
+
import { SUPPORT_CHAINS as kyberswapSupportChains } from "./dexs/kyberswap";
|
|
8
9
|
import { DEX_ENUM } from "./consts";
|
|
9
10
|
export const WrapTokenAddressMap = {
|
|
10
11
|
[CHAINS_ENUM.ETH]: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
|
|
@@ -16,6 +17,11 @@ export const WrapTokenAddressMap = {
|
|
|
16
17
|
[CHAINS_ENUM.ARBITRUM]: "0x82af49447d8a07e3bd95bd0d56f35241523fbab1",
|
|
17
18
|
[CHAINS_ENUM.KLAY]: "0xe4f05a66ec68b54a58b17c22107b02e0232cc817",
|
|
18
19
|
[CHAINS_ENUM.GNOSIS]: "0xe91d153e0b41518a2ce8dd3d7944fa863463a97d",
|
|
20
|
+
[CHAINS_ENUM.CRO]: "0x5c7f8a570d578ed84e63fdfa7b1ee72deae1ae23",
|
|
21
|
+
[CHAINS_ENUM.LINEA]: "0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f",
|
|
22
|
+
[CHAINS_ENUM.AURORA]: "0xc9bdeed33cd01541e1eed10f90519d2c06fe3feb",
|
|
23
|
+
[CHAINS_ENUM.BTT]: "0x23181f21dea5936e24163ffaba4ea3b316b57f3c",
|
|
24
|
+
[CHAINS_ENUM.ROSE]: "0x21c718c22d52d0f3a789b752d4c2fd5908a8a733",
|
|
19
25
|
};
|
|
20
26
|
export const DEX_SUPPORT_CHAINS = {
|
|
21
27
|
[DEX_ENUM.WRAPTOKEN]: wrapTokenSupportChains,
|
|
@@ -24,6 +30,7 @@ export const DEX_SUPPORT_CHAINS = {
|
|
|
24
30
|
[DEX_ENUM.ZEROXAPI]: zeroXSupportChains,
|
|
25
31
|
[DEX_ENUM.OPENOCEAN]: openOceanSupportChains,
|
|
26
32
|
[DEX_ENUM.UNISWAP]: uniswapSupportChains,
|
|
33
|
+
[DEX_ENUM.KYBERSWAP]: kyberswapSupportChains,
|
|
27
34
|
};
|
|
28
35
|
export const DEX_ROUTER_WHITELIST = {
|
|
29
36
|
[DEX_ENUM.ONEINCH]: {
|
|
@@ -79,6 +86,20 @@ export const DEX_ROUTER_WHITELIST = {
|
|
|
79
86
|
[CHAINS_ENUM.OP]: "0xe592427a0aece92de3edee1f18e0157c05861564",
|
|
80
87
|
[CHAINS_ENUM.ARBITRUM]: "0xe592427a0aece92de3edee1f18e0157c05861564",
|
|
81
88
|
},
|
|
89
|
+
[DEX_ENUM.KYBERSWAP]: {
|
|
90
|
+
[CHAINS_ENUM.ETH]: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
|
|
91
|
+
[CHAINS_ENUM.POLYGON]: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
|
|
92
|
+
[CHAINS_ENUM.OP]: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
|
|
93
|
+
[CHAINS_ENUM.ARBITRUM]: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
|
|
94
|
+
[CHAINS_ENUM.BSC]: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
|
|
95
|
+
[CHAINS_ENUM.AVAX]: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
|
|
96
|
+
[CHAINS_ENUM.FTM]: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
|
|
97
|
+
[CHAINS_ENUM.CRO]: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
|
|
98
|
+
[CHAINS_ENUM.AURORA]: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
|
|
99
|
+
[CHAINS_ENUM.BTT]: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
|
|
100
|
+
[CHAINS_ENUM.ROSE]: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
|
|
101
|
+
[CHAINS_ENUM.LINEA]: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
|
|
102
|
+
},
|
|
82
103
|
};
|
|
83
104
|
export const DEX_SPENDER_WHITELIST = {
|
|
84
105
|
[DEX_ENUM.ONEINCH]: {
|
|
@@ -134,4 +155,18 @@ export const DEX_SPENDER_WHITELIST = {
|
|
|
134
155
|
[CHAINS_ENUM.OP]: "0xe592427a0aece92de3edee1f18e0157c05861564",
|
|
135
156
|
[CHAINS_ENUM.ARBITRUM]: "0xe592427a0aece92de3edee1f18e0157c05861564",
|
|
136
157
|
},
|
|
158
|
+
[DEX_ENUM.KYBERSWAP]: {
|
|
159
|
+
[CHAINS_ENUM.ETH]: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
|
|
160
|
+
[CHAINS_ENUM.POLYGON]: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
|
|
161
|
+
[CHAINS_ENUM.OP]: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
|
|
162
|
+
[CHAINS_ENUM.ARBITRUM]: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
|
|
163
|
+
[CHAINS_ENUM.BSC]: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
|
|
164
|
+
[CHAINS_ENUM.AVAX]: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
|
|
165
|
+
[CHAINS_ENUM.FTM]: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
|
|
166
|
+
[CHAINS_ENUM.CRO]: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
|
|
167
|
+
[CHAINS_ENUM.AURORA]: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
|
|
168
|
+
[CHAINS_ENUM.BTT]: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
|
|
169
|
+
[CHAINS_ENUM.ROSE]: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
|
|
170
|
+
[CHAINS_ENUM.LINEA]: "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5",
|
|
171
|
+
},
|
|
137
172
|
};
|
package/dist/quote.js
CHANGED
|
@@ -14,6 +14,7 @@ import { getQuote as zeroXGetQuote, decodeCalldata as zeroXDecodeCalldata, } fro
|
|
|
14
14
|
import { getQuote as paraSwapGetQuote, decodeCalldata as paraSwapDecodeCalldata, } from "./dexs/paraswap";
|
|
15
15
|
import { getQuote as openOceanGetQuote, decodeCalldata as openOceanDecodeCalldata, } from "./dexs/openocean";
|
|
16
16
|
import { getQuote as uniswapGetQuote, decodeCalldata as uniswapDecodeCalldata, } from "./dexs/uniswap";
|
|
17
|
+
import { getQuote as kyberswapGetQuote, decodeCalldata as kyberswapDecodeCalldata, } from "./dexs/kyberswap";
|
|
17
18
|
export const getQuote = (id, params, api) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
19
|
switch (id) {
|
|
19
20
|
case DEX_ENUM.WRAPTOKEN:
|
|
@@ -28,6 +29,8 @@ export const getQuote = (id, params, api) => __awaiter(void 0, void 0, void 0, f
|
|
|
28
29
|
return yield openOceanGetQuote(params, api);
|
|
29
30
|
case DEX_ENUM.UNISWAP:
|
|
30
31
|
return yield uniswapGetQuote(params, api);
|
|
32
|
+
case DEX_ENUM.KYBERSWAP:
|
|
33
|
+
return yield kyberswapGetQuote(params, api);
|
|
31
34
|
default:
|
|
32
35
|
throw new Error(`${id} is not supported!`);
|
|
33
36
|
}
|
|
@@ -44,6 +47,8 @@ export const decodeCalldata = (id, tx) => {
|
|
|
44
47
|
return openOceanDecodeCalldata(tx);
|
|
45
48
|
case DEX_ENUM.UNISWAP:
|
|
46
49
|
return uniswapDecodeCalldata(tx);
|
|
50
|
+
case DEX_ENUM.KYBERSWAP:
|
|
51
|
+
return kyberswapDecodeCalldata(tx);
|
|
47
52
|
default:
|
|
48
53
|
throw new Error(`${id} is not supported!`);
|
|
49
54
|
}
|
package/dist/utils.d.ts
CHANGED
|
@@ -5,6 +5,6 @@ import { DEX_ENUM } from "./consts";
|
|
|
5
5
|
export declare const isSameAddress: (addr1: string, addr2: string) => boolean;
|
|
6
6
|
export declare const generateGetQuote: ({ SUPPORT_CHAINS, id, dex, }: {
|
|
7
7
|
SUPPORT_CHAINS: CHAINS_ENUM[];
|
|
8
|
-
id: "uniswap3" | "matcha" | "openocean" | "1inch" | "paraswap";
|
|
8
|
+
id: "uniswap3" | "matcha" | "openocean" | "1inch" | "paraswap" | "kyberswap";
|
|
9
9
|
dex: DEX_ENUM;
|
|
10
10
|
}) => (options: QuoteParams, api: OpenApiService) => Promise<QuoteResult>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rabby-wallet/rabby-swap",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.28-alpha.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@babel/preset-env": "^7.19.1",
|
|
27
|
-
"@debank/common": "^0.3.5",
|
|
28
27
|
"@rabby-wallet/rabby-api": "^0.6.13",
|
|
29
28
|
"@types/jest": "^29.0.3",
|
|
30
29
|
"@types/node": "^18.7.18",
|
|
@@ -38,7 +37,7 @@
|
|
|
38
37
|
"typescript": "^4.8.3"
|
|
39
38
|
},
|
|
40
39
|
"peerDependencies": {
|
|
41
|
-
"@debank/common": "^0.3.
|
|
40
|
+
"@debank/common": "^0.3.21",
|
|
42
41
|
"@rabby-wallet/rabby-api": "^0.6.13"
|
|
43
42
|
},
|
|
44
43
|
"author": "vvvvvv1vvvvvv",
|
|
@@ -47,4 +46,4 @@
|
|
|
47
46
|
"url": "https://github.com/RabbyHub/rabby-swap/issues"
|
|
48
47
|
},
|
|
49
48
|
"homepage": "https://github.com/RabbyHub/rabby-swap#readme"
|
|
50
|
-
}
|
|
49
|
+
}
|