@pancakeswap/sdk 3.2.0 → 3.2.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/constants.d.ts +32 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/entities/index.d.ts +6 -0
- package/dist/entities/index.d.ts.map +1 -0
- package/dist/entities/native.d.ts +18 -0
- package/dist/entities/native.d.ts.map +1 -0
- package/dist/entities/pair.d.ts +45 -0
- package/dist/entities/pair.d.ts.map +1 -0
- package/dist/entities/route.d.ts +13 -0
- package/dist/entities/route.d.ts.map +1 -0
- package/dist/entities/token.d.ts +13 -0
- package/dist/entities/token.d.ts.map +1 -0
- package/dist/entities/trade.d.ts +104 -0
- package/dist/entities/trade.d.ts.map +1 -0
- package/dist/ether.d.ts +12 -0
- package/dist/ether.d.ts.map +1 -0
- package/dist/fetcher.d.ts +29 -0
- package/dist/fetcher.d.ts.map +1 -0
- package/dist/index.d.ts +10 -281
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +802 -0
- package/dist/index.mjs +802 -1
- package/dist/router.d.ts +61 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/trade.d.ts +5 -0
- package/dist/trade.d.ts.map +1 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -6,6 +6,9 @@ import { getAddress, getCreate2Address } from '@ethersproject/address';
|
|
|
6
6
|
import invariant4 from 'tiny-invariant';
|
|
7
7
|
import warning from 'tiny-warning';
|
|
8
8
|
import { keccak256, pack } from '@ethersproject/solidity';
|
|
9
|
+
import { Contract } from '@ethersproject/contracts';
|
|
10
|
+
import { getNetwork } from '@ethersproject/networks';
|
|
11
|
+
import { getDefaultProvider } from '@ethersproject/providers';
|
|
9
12
|
|
|
10
13
|
// src/index.ts
|
|
11
14
|
function validateAndParseAddress(address) {
|
|
@@ -67,6 +70,22 @@ var WETH9 = {
|
|
|
67
70
|
"WETH",
|
|
68
71
|
"Wrapped Ether",
|
|
69
72
|
"https://weth.io"
|
|
73
|
+
),
|
|
74
|
+
[56 /* BSC */]: new ERC20Token(
|
|
75
|
+
56 /* BSC */,
|
|
76
|
+
"0x2170Ed0880ac9A755fd29B2688956BD959F933F8",
|
|
77
|
+
18,
|
|
78
|
+
"ETH",
|
|
79
|
+
"Binance-Peg Ethereum Token",
|
|
80
|
+
"https://ethereum.org"
|
|
81
|
+
),
|
|
82
|
+
[97 /* BSC_TESTNET */]: new ERC20Token(
|
|
83
|
+
56 /* BSC */,
|
|
84
|
+
"0xE7bCB9e341D546b66a46298f4893f5650a56e99E",
|
|
85
|
+
18,
|
|
86
|
+
"ETH",
|
|
87
|
+
"ETH",
|
|
88
|
+
"https://ethereum.org"
|
|
70
89
|
)
|
|
71
90
|
};
|
|
72
91
|
var WBNB = {
|
|
@@ -715,4 +734,786 @@ var _Ether = class extends NativeCurrency {
|
|
|
715
734
|
var Ether = _Ether;
|
|
716
735
|
Ether._etherCache = {};
|
|
717
736
|
|
|
718
|
-
|
|
737
|
+
// src/abis/ERC20.json
|
|
738
|
+
var ERC20_default = [
|
|
739
|
+
{
|
|
740
|
+
constant: true,
|
|
741
|
+
inputs: [],
|
|
742
|
+
name: "decimals",
|
|
743
|
+
outputs: [{ name: "", type: "uint8" }],
|
|
744
|
+
payable: false,
|
|
745
|
+
stateMutability: "view",
|
|
746
|
+
type: "function"
|
|
747
|
+
},
|
|
748
|
+
{
|
|
749
|
+
constant: true,
|
|
750
|
+
inputs: [{ name: "", type: "address" }],
|
|
751
|
+
name: "balanceOf",
|
|
752
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
753
|
+
payable: false,
|
|
754
|
+
stateMutability: "view",
|
|
755
|
+
type: "function"
|
|
756
|
+
}
|
|
757
|
+
];
|
|
758
|
+
|
|
759
|
+
// src/abis/IPancakePair.json
|
|
760
|
+
var IPancakePair_default = [
|
|
761
|
+
{
|
|
762
|
+
anonymous: false,
|
|
763
|
+
inputs: [
|
|
764
|
+
{
|
|
765
|
+
indexed: true,
|
|
766
|
+
internalType: "address",
|
|
767
|
+
name: "owner",
|
|
768
|
+
type: "address"
|
|
769
|
+
},
|
|
770
|
+
{
|
|
771
|
+
indexed: true,
|
|
772
|
+
internalType: "address",
|
|
773
|
+
name: "spender",
|
|
774
|
+
type: "address"
|
|
775
|
+
},
|
|
776
|
+
{
|
|
777
|
+
indexed: false,
|
|
778
|
+
internalType: "uint256",
|
|
779
|
+
name: "value",
|
|
780
|
+
type: "uint256"
|
|
781
|
+
}
|
|
782
|
+
],
|
|
783
|
+
name: "Approval",
|
|
784
|
+
type: "event"
|
|
785
|
+
},
|
|
786
|
+
{
|
|
787
|
+
anonymous: false,
|
|
788
|
+
inputs: [
|
|
789
|
+
{
|
|
790
|
+
indexed: true,
|
|
791
|
+
internalType: "address",
|
|
792
|
+
name: "sender",
|
|
793
|
+
type: "address"
|
|
794
|
+
},
|
|
795
|
+
{
|
|
796
|
+
indexed: false,
|
|
797
|
+
internalType: "uint256",
|
|
798
|
+
name: "amount0",
|
|
799
|
+
type: "uint256"
|
|
800
|
+
},
|
|
801
|
+
{
|
|
802
|
+
indexed: false,
|
|
803
|
+
internalType: "uint256",
|
|
804
|
+
name: "amount1",
|
|
805
|
+
type: "uint256"
|
|
806
|
+
},
|
|
807
|
+
{
|
|
808
|
+
indexed: true,
|
|
809
|
+
internalType: "address",
|
|
810
|
+
name: "to",
|
|
811
|
+
type: "address"
|
|
812
|
+
}
|
|
813
|
+
],
|
|
814
|
+
name: "Burn",
|
|
815
|
+
type: "event"
|
|
816
|
+
},
|
|
817
|
+
{
|
|
818
|
+
anonymous: false,
|
|
819
|
+
inputs: [
|
|
820
|
+
{
|
|
821
|
+
indexed: true,
|
|
822
|
+
internalType: "address",
|
|
823
|
+
name: "sender",
|
|
824
|
+
type: "address"
|
|
825
|
+
},
|
|
826
|
+
{
|
|
827
|
+
indexed: false,
|
|
828
|
+
internalType: "uint256",
|
|
829
|
+
name: "amount0",
|
|
830
|
+
type: "uint256"
|
|
831
|
+
},
|
|
832
|
+
{
|
|
833
|
+
indexed: false,
|
|
834
|
+
internalType: "uint256",
|
|
835
|
+
name: "amount1",
|
|
836
|
+
type: "uint256"
|
|
837
|
+
}
|
|
838
|
+
],
|
|
839
|
+
name: "Mint",
|
|
840
|
+
type: "event"
|
|
841
|
+
},
|
|
842
|
+
{
|
|
843
|
+
anonymous: false,
|
|
844
|
+
inputs: [
|
|
845
|
+
{
|
|
846
|
+
indexed: true,
|
|
847
|
+
internalType: "address",
|
|
848
|
+
name: "sender",
|
|
849
|
+
type: "address"
|
|
850
|
+
},
|
|
851
|
+
{
|
|
852
|
+
indexed: false,
|
|
853
|
+
internalType: "uint256",
|
|
854
|
+
name: "amount0In",
|
|
855
|
+
type: "uint256"
|
|
856
|
+
},
|
|
857
|
+
{
|
|
858
|
+
indexed: false,
|
|
859
|
+
internalType: "uint256",
|
|
860
|
+
name: "amount1In",
|
|
861
|
+
type: "uint256"
|
|
862
|
+
},
|
|
863
|
+
{
|
|
864
|
+
indexed: false,
|
|
865
|
+
internalType: "uint256",
|
|
866
|
+
name: "amount0Out",
|
|
867
|
+
type: "uint256"
|
|
868
|
+
},
|
|
869
|
+
{
|
|
870
|
+
indexed: false,
|
|
871
|
+
internalType: "uint256",
|
|
872
|
+
name: "amount1Out",
|
|
873
|
+
type: "uint256"
|
|
874
|
+
},
|
|
875
|
+
{
|
|
876
|
+
indexed: true,
|
|
877
|
+
internalType: "address",
|
|
878
|
+
name: "to",
|
|
879
|
+
type: "address"
|
|
880
|
+
}
|
|
881
|
+
],
|
|
882
|
+
name: "Swap",
|
|
883
|
+
type: "event"
|
|
884
|
+
},
|
|
885
|
+
{
|
|
886
|
+
anonymous: false,
|
|
887
|
+
inputs: [
|
|
888
|
+
{
|
|
889
|
+
indexed: false,
|
|
890
|
+
internalType: "uint112",
|
|
891
|
+
name: "reserve0",
|
|
892
|
+
type: "uint112"
|
|
893
|
+
},
|
|
894
|
+
{
|
|
895
|
+
indexed: false,
|
|
896
|
+
internalType: "uint112",
|
|
897
|
+
name: "reserve1",
|
|
898
|
+
type: "uint112"
|
|
899
|
+
}
|
|
900
|
+
],
|
|
901
|
+
name: "Sync",
|
|
902
|
+
type: "event"
|
|
903
|
+
},
|
|
904
|
+
{
|
|
905
|
+
anonymous: false,
|
|
906
|
+
inputs: [
|
|
907
|
+
{
|
|
908
|
+
indexed: true,
|
|
909
|
+
internalType: "address",
|
|
910
|
+
name: "from",
|
|
911
|
+
type: "address"
|
|
912
|
+
},
|
|
913
|
+
{
|
|
914
|
+
indexed: true,
|
|
915
|
+
internalType: "address",
|
|
916
|
+
name: "to",
|
|
917
|
+
type: "address"
|
|
918
|
+
},
|
|
919
|
+
{
|
|
920
|
+
indexed: false,
|
|
921
|
+
internalType: "uint256",
|
|
922
|
+
name: "value",
|
|
923
|
+
type: "uint256"
|
|
924
|
+
}
|
|
925
|
+
],
|
|
926
|
+
name: "Transfer",
|
|
927
|
+
type: "event"
|
|
928
|
+
},
|
|
929
|
+
{
|
|
930
|
+
constant: true,
|
|
931
|
+
inputs: [],
|
|
932
|
+
name: "DOMAIN_SEPARATOR",
|
|
933
|
+
outputs: [
|
|
934
|
+
{
|
|
935
|
+
internalType: "bytes32",
|
|
936
|
+
name: "",
|
|
937
|
+
type: "bytes32"
|
|
938
|
+
}
|
|
939
|
+
],
|
|
940
|
+
payable: false,
|
|
941
|
+
stateMutability: "view",
|
|
942
|
+
type: "function"
|
|
943
|
+
},
|
|
944
|
+
{
|
|
945
|
+
constant: true,
|
|
946
|
+
inputs: [],
|
|
947
|
+
name: "MINIMUM_LIQUIDITY",
|
|
948
|
+
outputs: [
|
|
949
|
+
{
|
|
950
|
+
internalType: "uint256",
|
|
951
|
+
name: "",
|
|
952
|
+
type: "uint256"
|
|
953
|
+
}
|
|
954
|
+
],
|
|
955
|
+
payable: false,
|
|
956
|
+
stateMutability: "pure",
|
|
957
|
+
type: "function"
|
|
958
|
+
},
|
|
959
|
+
{
|
|
960
|
+
constant: true,
|
|
961
|
+
inputs: [],
|
|
962
|
+
name: "PERMIT_TYPEHASH",
|
|
963
|
+
outputs: [
|
|
964
|
+
{
|
|
965
|
+
internalType: "bytes32",
|
|
966
|
+
name: "",
|
|
967
|
+
type: "bytes32"
|
|
968
|
+
}
|
|
969
|
+
],
|
|
970
|
+
payable: false,
|
|
971
|
+
stateMutability: "pure",
|
|
972
|
+
type: "function"
|
|
973
|
+
},
|
|
974
|
+
{
|
|
975
|
+
constant: true,
|
|
976
|
+
inputs: [
|
|
977
|
+
{
|
|
978
|
+
internalType: "address",
|
|
979
|
+
name: "owner",
|
|
980
|
+
type: "address"
|
|
981
|
+
},
|
|
982
|
+
{
|
|
983
|
+
internalType: "address",
|
|
984
|
+
name: "spender",
|
|
985
|
+
type: "address"
|
|
986
|
+
}
|
|
987
|
+
],
|
|
988
|
+
name: "allowance",
|
|
989
|
+
outputs: [
|
|
990
|
+
{
|
|
991
|
+
internalType: "uint256",
|
|
992
|
+
name: "",
|
|
993
|
+
type: "uint256"
|
|
994
|
+
}
|
|
995
|
+
],
|
|
996
|
+
payable: false,
|
|
997
|
+
stateMutability: "view",
|
|
998
|
+
type: "function"
|
|
999
|
+
},
|
|
1000
|
+
{
|
|
1001
|
+
constant: false,
|
|
1002
|
+
inputs: [
|
|
1003
|
+
{
|
|
1004
|
+
internalType: "address",
|
|
1005
|
+
name: "spender",
|
|
1006
|
+
type: "address"
|
|
1007
|
+
},
|
|
1008
|
+
{
|
|
1009
|
+
internalType: "uint256",
|
|
1010
|
+
name: "value",
|
|
1011
|
+
type: "uint256"
|
|
1012
|
+
}
|
|
1013
|
+
],
|
|
1014
|
+
name: "approve",
|
|
1015
|
+
outputs: [
|
|
1016
|
+
{
|
|
1017
|
+
internalType: "bool",
|
|
1018
|
+
name: "",
|
|
1019
|
+
type: "bool"
|
|
1020
|
+
}
|
|
1021
|
+
],
|
|
1022
|
+
payable: false,
|
|
1023
|
+
stateMutability: "nonpayable",
|
|
1024
|
+
type: "function"
|
|
1025
|
+
},
|
|
1026
|
+
{
|
|
1027
|
+
constant: true,
|
|
1028
|
+
inputs: [
|
|
1029
|
+
{
|
|
1030
|
+
internalType: "address",
|
|
1031
|
+
name: "owner",
|
|
1032
|
+
type: "address"
|
|
1033
|
+
}
|
|
1034
|
+
],
|
|
1035
|
+
name: "balanceOf",
|
|
1036
|
+
outputs: [
|
|
1037
|
+
{
|
|
1038
|
+
internalType: "uint256",
|
|
1039
|
+
name: "",
|
|
1040
|
+
type: "uint256"
|
|
1041
|
+
}
|
|
1042
|
+
],
|
|
1043
|
+
payable: false,
|
|
1044
|
+
stateMutability: "view",
|
|
1045
|
+
type: "function"
|
|
1046
|
+
},
|
|
1047
|
+
{
|
|
1048
|
+
constant: false,
|
|
1049
|
+
inputs: [
|
|
1050
|
+
{
|
|
1051
|
+
internalType: "address",
|
|
1052
|
+
name: "to",
|
|
1053
|
+
type: "address"
|
|
1054
|
+
}
|
|
1055
|
+
],
|
|
1056
|
+
name: "burn",
|
|
1057
|
+
outputs: [
|
|
1058
|
+
{
|
|
1059
|
+
internalType: "uint256",
|
|
1060
|
+
name: "amount0",
|
|
1061
|
+
type: "uint256"
|
|
1062
|
+
},
|
|
1063
|
+
{
|
|
1064
|
+
internalType: "uint256",
|
|
1065
|
+
name: "amount1",
|
|
1066
|
+
type: "uint256"
|
|
1067
|
+
}
|
|
1068
|
+
],
|
|
1069
|
+
payable: false,
|
|
1070
|
+
stateMutability: "nonpayable",
|
|
1071
|
+
type: "function"
|
|
1072
|
+
},
|
|
1073
|
+
{
|
|
1074
|
+
constant: true,
|
|
1075
|
+
inputs: [],
|
|
1076
|
+
name: "decimals",
|
|
1077
|
+
outputs: [
|
|
1078
|
+
{
|
|
1079
|
+
internalType: "uint8",
|
|
1080
|
+
name: "",
|
|
1081
|
+
type: "uint8"
|
|
1082
|
+
}
|
|
1083
|
+
],
|
|
1084
|
+
payable: false,
|
|
1085
|
+
stateMutability: "pure",
|
|
1086
|
+
type: "function"
|
|
1087
|
+
},
|
|
1088
|
+
{
|
|
1089
|
+
constant: true,
|
|
1090
|
+
inputs: [],
|
|
1091
|
+
name: "factory",
|
|
1092
|
+
outputs: [
|
|
1093
|
+
{
|
|
1094
|
+
internalType: "address",
|
|
1095
|
+
name: "",
|
|
1096
|
+
type: "address"
|
|
1097
|
+
}
|
|
1098
|
+
],
|
|
1099
|
+
payable: false,
|
|
1100
|
+
stateMutability: "view",
|
|
1101
|
+
type: "function"
|
|
1102
|
+
},
|
|
1103
|
+
{
|
|
1104
|
+
constant: true,
|
|
1105
|
+
inputs: [],
|
|
1106
|
+
name: "getReserves",
|
|
1107
|
+
outputs: [
|
|
1108
|
+
{
|
|
1109
|
+
internalType: "uint112",
|
|
1110
|
+
name: "reserve0",
|
|
1111
|
+
type: "uint112"
|
|
1112
|
+
},
|
|
1113
|
+
{
|
|
1114
|
+
internalType: "uint112",
|
|
1115
|
+
name: "reserve1",
|
|
1116
|
+
type: "uint112"
|
|
1117
|
+
},
|
|
1118
|
+
{
|
|
1119
|
+
internalType: "uint32",
|
|
1120
|
+
name: "blockTimestampLast",
|
|
1121
|
+
type: "uint32"
|
|
1122
|
+
}
|
|
1123
|
+
],
|
|
1124
|
+
payable: false,
|
|
1125
|
+
stateMutability: "view",
|
|
1126
|
+
type: "function"
|
|
1127
|
+
},
|
|
1128
|
+
{
|
|
1129
|
+
constant: false,
|
|
1130
|
+
inputs: [
|
|
1131
|
+
{
|
|
1132
|
+
internalType: "address",
|
|
1133
|
+
name: "",
|
|
1134
|
+
type: "address"
|
|
1135
|
+
},
|
|
1136
|
+
{
|
|
1137
|
+
internalType: "address",
|
|
1138
|
+
name: "",
|
|
1139
|
+
type: "address"
|
|
1140
|
+
}
|
|
1141
|
+
],
|
|
1142
|
+
name: "initialize",
|
|
1143
|
+
outputs: [],
|
|
1144
|
+
payable: false,
|
|
1145
|
+
stateMutability: "nonpayable",
|
|
1146
|
+
type: "function"
|
|
1147
|
+
},
|
|
1148
|
+
{
|
|
1149
|
+
constant: true,
|
|
1150
|
+
inputs: [],
|
|
1151
|
+
name: "kLast",
|
|
1152
|
+
outputs: [
|
|
1153
|
+
{
|
|
1154
|
+
internalType: "uint256",
|
|
1155
|
+
name: "",
|
|
1156
|
+
type: "uint256"
|
|
1157
|
+
}
|
|
1158
|
+
],
|
|
1159
|
+
payable: false,
|
|
1160
|
+
stateMutability: "view",
|
|
1161
|
+
type: "function"
|
|
1162
|
+
},
|
|
1163
|
+
{
|
|
1164
|
+
constant: false,
|
|
1165
|
+
inputs: [
|
|
1166
|
+
{
|
|
1167
|
+
internalType: "address",
|
|
1168
|
+
name: "to",
|
|
1169
|
+
type: "address"
|
|
1170
|
+
}
|
|
1171
|
+
],
|
|
1172
|
+
name: "mint",
|
|
1173
|
+
outputs: [
|
|
1174
|
+
{
|
|
1175
|
+
internalType: "uint256",
|
|
1176
|
+
name: "liquidity",
|
|
1177
|
+
type: "uint256"
|
|
1178
|
+
}
|
|
1179
|
+
],
|
|
1180
|
+
payable: false,
|
|
1181
|
+
stateMutability: "nonpayable",
|
|
1182
|
+
type: "function"
|
|
1183
|
+
},
|
|
1184
|
+
{
|
|
1185
|
+
constant: true,
|
|
1186
|
+
inputs: [],
|
|
1187
|
+
name: "name",
|
|
1188
|
+
outputs: [
|
|
1189
|
+
{
|
|
1190
|
+
internalType: "string",
|
|
1191
|
+
name: "",
|
|
1192
|
+
type: "string"
|
|
1193
|
+
}
|
|
1194
|
+
],
|
|
1195
|
+
payable: false,
|
|
1196
|
+
stateMutability: "pure",
|
|
1197
|
+
type: "function"
|
|
1198
|
+
},
|
|
1199
|
+
{
|
|
1200
|
+
constant: true,
|
|
1201
|
+
inputs: [
|
|
1202
|
+
{
|
|
1203
|
+
internalType: "address",
|
|
1204
|
+
name: "owner",
|
|
1205
|
+
type: "address"
|
|
1206
|
+
}
|
|
1207
|
+
],
|
|
1208
|
+
name: "nonces",
|
|
1209
|
+
outputs: [
|
|
1210
|
+
{
|
|
1211
|
+
internalType: "uint256",
|
|
1212
|
+
name: "",
|
|
1213
|
+
type: "uint256"
|
|
1214
|
+
}
|
|
1215
|
+
],
|
|
1216
|
+
payable: false,
|
|
1217
|
+
stateMutability: "view",
|
|
1218
|
+
type: "function"
|
|
1219
|
+
},
|
|
1220
|
+
{
|
|
1221
|
+
constant: false,
|
|
1222
|
+
inputs: [
|
|
1223
|
+
{
|
|
1224
|
+
internalType: "address",
|
|
1225
|
+
name: "owner",
|
|
1226
|
+
type: "address"
|
|
1227
|
+
},
|
|
1228
|
+
{
|
|
1229
|
+
internalType: "address",
|
|
1230
|
+
name: "spender",
|
|
1231
|
+
type: "address"
|
|
1232
|
+
},
|
|
1233
|
+
{
|
|
1234
|
+
internalType: "uint256",
|
|
1235
|
+
name: "value",
|
|
1236
|
+
type: "uint256"
|
|
1237
|
+
},
|
|
1238
|
+
{
|
|
1239
|
+
internalType: "uint256",
|
|
1240
|
+
name: "deadline",
|
|
1241
|
+
type: "uint256"
|
|
1242
|
+
},
|
|
1243
|
+
{
|
|
1244
|
+
internalType: "uint8",
|
|
1245
|
+
name: "v",
|
|
1246
|
+
type: "uint8"
|
|
1247
|
+
},
|
|
1248
|
+
{
|
|
1249
|
+
internalType: "bytes32",
|
|
1250
|
+
name: "r",
|
|
1251
|
+
type: "bytes32"
|
|
1252
|
+
},
|
|
1253
|
+
{
|
|
1254
|
+
internalType: "bytes32",
|
|
1255
|
+
name: "s",
|
|
1256
|
+
type: "bytes32"
|
|
1257
|
+
}
|
|
1258
|
+
],
|
|
1259
|
+
name: "permit",
|
|
1260
|
+
outputs: [],
|
|
1261
|
+
payable: false,
|
|
1262
|
+
stateMutability: "nonpayable",
|
|
1263
|
+
type: "function"
|
|
1264
|
+
},
|
|
1265
|
+
{
|
|
1266
|
+
constant: true,
|
|
1267
|
+
inputs: [],
|
|
1268
|
+
name: "price0CumulativeLast",
|
|
1269
|
+
outputs: [
|
|
1270
|
+
{
|
|
1271
|
+
internalType: "uint256",
|
|
1272
|
+
name: "",
|
|
1273
|
+
type: "uint256"
|
|
1274
|
+
}
|
|
1275
|
+
],
|
|
1276
|
+
payable: false,
|
|
1277
|
+
stateMutability: "view",
|
|
1278
|
+
type: "function"
|
|
1279
|
+
},
|
|
1280
|
+
{
|
|
1281
|
+
constant: true,
|
|
1282
|
+
inputs: [],
|
|
1283
|
+
name: "price1CumulativeLast",
|
|
1284
|
+
outputs: [
|
|
1285
|
+
{
|
|
1286
|
+
internalType: "uint256",
|
|
1287
|
+
name: "",
|
|
1288
|
+
type: "uint256"
|
|
1289
|
+
}
|
|
1290
|
+
],
|
|
1291
|
+
payable: false,
|
|
1292
|
+
stateMutability: "view",
|
|
1293
|
+
type: "function"
|
|
1294
|
+
},
|
|
1295
|
+
{
|
|
1296
|
+
constant: false,
|
|
1297
|
+
inputs: [
|
|
1298
|
+
{
|
|
1299
|
+
internalType: "address",
|
|
1300
|
+
name: "to",
|
|
1301
|
+
type: "address"
|
|
1302
|
+
}
|
|
1303
|
+
],
|
|
1304
|
+
name: "skim",
|
|
1305
|
+
outputs: [],
|
|
1306
|
+
payable: false,
|
|
1307
|
+
stateMutability: "nonpayable",
|
|
1308
|
+
type: "function"
|
|
1309
|
+
},
|
|
1310
|
+
{
|
|
1311
|
+
constant: false,
|
|
1312
|
+
inputs: [
|
|
1313
|
+
{
|
|
1314
|
+
internalType: "uint256",
|
|
1315
|
+
name: "amount0Out",
|
|
1316
|
+
type: "uint256"
|
|
1317
|
+
},
|
|
1318
|
+
{
|
|
1319
|
+
internalType: "uint256",
|
|
1320
|
+
name: "amount1Out",
|
|
1321
|
+
type: "uint256"
|
|
1322
|
+
},
|
|
1323
|
+
{
|
|
1324
|
+
internalType: "address",
|
|
1325
|
+
name: "to",
|
|
1326
|
+
type: "address"
|
|
1327
|
+
},
|
|
1328
|
+
{
|
|
1329
|
+
internalType: "bytes",
|
|
1330
|
+
name: "data",
|
|
1331
|
+
type: "bytes"
|
|
1332
|
+
}
|
|
1333
|
+
],
|
|
1334
|
+
name: "swap",
|
|
1335
|
+
outputs: [],
|
|
1336
|
+
payable: false,
|
|
1337
|
+
stateMutability: "nonpayable",
|
|
1338
|
+
type: "function"
|
|
1339
|
+
},
|
|
1340
|
+
{
|
|
1341
|
+
constant: true,
|
|
1342
|
+
inputs: [],
|
|
1343
|
+
name: "symbol",
|
|
1344
|
+
outputs: [
|
|
1345
|
+
{
|
|
1346
|
+
internalType: "string",
|
|
1347
|
+
name: "",
|
|
1348
|
+
type: "string"
|
|
1349
|
+
}
|
|
1350
|
+
],
|
|
1351
|
+
payable: false,
|
|
1352
|
+
stateMutability: "pure",
|
|
1353
|
+
type: "function"
|
|
1354
|
+
},
|
|
1355
|
+
{
|
|
1356
|
+
constant: false,
|
|
1357
|
+
inputs: [],
|
|
1358
|
+
name: "sync",
|
|
1359
|
+
outputs: [],
|
|
1360
|
+
payable: false,
|
|
1361
|
+
stateMutability: "nonpayable",
|
|
1362
|
+
type: "function"
|
|
1363
|
+
},
|
|
1364
|
+
{
|
|
1365
|
+
constant: true,
|
|
1366
|
+
inputs: [],
|
|
1367
|
+
name: "token0",
|
|
1368
|
+
outputs: [
|
|
1369
|
+
{
|
|
1370
|
+
internalType: "address",
|
|
1371
|
+
name: "",
|
|
1372
|
+
type: "address"
|
|
1373
|
+
}
|
|
1374
|
+
],
|
|
1375
|
+
payable: false,
|
|
1376
|
+
stateMutability: "view",
|
|
1377
|
+
type: "function"
|
|
1378
|
+
},
|
|
1379
|
+
{
|
|
1380
|
+
constant: true,
|
|
1381
|
+
inputs: [],
|
|
1382
|
+
name: "token1",
|
|
1383
|
+
outputs: [
|
|
1384
|
+
{
|
|
1385
|
+
internalType: "address",
|
|
1386
|
+
name: "",
|
|
1387
|
+
type: "address"
|
|
1388
|
+
}
|
|
1389
|
+
],
|
|
1390
|
+
payable: false,
|
|
1391
|
+
stateMutability: "view",
|
|
1392
|
+
type: "function"
|
|
1393
|
+
},
|
|
1394
|
+
{
|
|
1395
|
+
constant: true,
|
|
1396
|
+
inputs: [],
|
|
1397
|
+
name: "totalSupply",
|
|
1398
|
+
outputs: [
|
|
1399
|
+
{
|
|
1400
|
+
internalType: "uint256",
|
|
1401
|
+
name: "",
|
|
1402
|
+
type: "uint256"
|
|
1403
|
+
}
|
|
1404
|
+
],
|
|
1405
|
+
payable: false,
|
|
1406
|
+
stateMutability: "view",
|
|
1407
|
+
type: "function"
|
|
1408
|
+
},
|
|
1409
|
+
{
|
|
1410
|
+
constant: false,
|
|
1411
|
+
inputs: [
|
|
1412
|
+
{
|
|
1413
|
+
internalType: "address",
|
|
1414
|
+
name: "to",
|
|
1415
|
+
type: "address"
|
|
1416
|
+
},
|
|
1417
|
+
{
|
|
1418
|
+
internalType: "uint256",
|
|
1419
|
+
name: "value",
|
|
1420
|
+
type: "uint256"
|
|
1421
|
+
}
|
|
1422
|
+
],
|
|
1423
|
+
name: "transfer",
|
|
1424
|
+
outputs: [
|
|
1425
|
+
{
|
|
1426
|
+
internalType: "bool",
|
|
1427
|
+
name: "",
|
|
1428
|
+
type: "bool"
|
|
1429
|
+
}
|
|
1430
|
+
],
|
|
1431
|
+
payable: false,
|
|
1432
|
+
stateMutability: "nonpayable",
|
|
1433
|
+
type: "function"
|
|
1434
|
+
},
|
|
1435
|
+
{
|
|
1436
|
+
constant: false,
|
|
1437
|
+
inputs: [
|
|
1438
|
+
{
|
|
1439
|
+
internalType: "address",
|
|
1440
|
+
name: "from",
|
|
1441
|
+
type: "address"
|
|
1442
|
+
},
|
|
1443
|
+
{
|
|
1444
|
+
internalType: "address",
|
|
1445
|
+
name: "to",
|
|
1446
|
+
type: "address"
|
|
1447
|
+
},
|
|
1448
|
+
{
|
|
1449
|
+
internalType: "uint256",
|
|
1450
|
+
name: "value",
|
|
1451
|
+
type: "uint256"
|
|
1452
|
+
}
|
|
1453
|
+
],
|
|
1454
|
+
name: "transferFrom",
|
|
1455
|
+
outputs: [
|
|
1456
|
+
{
|
|
1457
|
+
internalType: "bool",
|
|
1458
|
+
name: "",
|
|
1459
|
+
type: "bool"
|
|
1460
|
+
}
|
|
1461
|
+
],
|
|
1462
|
+
payable: false,
|
|
1463
|
+
stateMutability: "nonpayable",
|
|
1464
|
+
type: "function"
|
|
1465
|
+
}
|
|
1466
|
+
];
|
|
1467
|
+
|
|
1468
|
+
// src/fetcher.ts
|
|
1469
|
+
var TOKEN_DECIMALS_CACHE = {
|
|
1470
|
+
[56 /* BSC */]: {}
|
|
1471
|
+
};
|
|
1472
|
+
var Fetcher = class {
|
|
1473
|
+
/**
|
|
1474
|
+
* Cannot be constructed.
|
|
1475
|
+
*/
|
|
1476
|
+
// eslint-disable-next-line no-useless-constructor,@typescript-eslint/no-empty-function
|
|
1477
|
+
constructor() {
|
|
1478
|
+
}
|
|
1479
|
+
/**
|
|
1480
|
+
* Fetch information for a given token on the given chain, using the given ethers provider.
|
|
1481
|
+
* @param chainId chain of the token
|
|
1482
|
+
* @param address address of the token on the chain
|
|
1483
|
+
* @param provider provider used to fetch the token
|
|
1484
|
+
* @param symbol symbol of the token
|
|
1485
|
+
* @param name optional name of the token
|
|
1486
|
+
*/
|
|
1487
|
+
static async fetchTokenData(chainId, address, provider = getDefaultProvider(getNetwork(chainId)), symbol, name) {
|
|
1488
|
+
var _a;
|
|
1489
|
+
const parsedDecimals = typeof ((_a = TOKEN_DECIMALS_CACHE == null ? void 0 : TOKEN_DECIMALS_CACHE[chainId]) == null ? void 0 : _a[address]) === "number" ? TOKEN_DECIMALS_CACHE[chainId][address] : await new Contract(address, ERC20_default, provider).decimals().then((decimals) => {
|
|
1490
|
+
TOKEN_DECIMALS_CACHE = {
|
|
1491
|
+
...TOKEN_DECIMALS_CACHE,
|
|
1492
|
+
[chainId]: {
|
|
1493
|
+
...TOKEN_DECIMALS_CACHE == null ? void 0 : TOKEN_DECIMALS_CACHE[chainId],
|
|
1494
|
+
[address]: decimals
|
|
1495
|
+
}
|
|
1496
|
+
};
|
|
1497
|
+
return decimals;
|
|
1498
|
+
});
|
|
1499
|
+
return new Token(chainId, address, parsedDecimals, symbol, name);
|
|
1500
|
+
}
|
|
1501
|
+
/**
|
|
1502
|
+
* Fetches information about a pair and constructs a pair from the given two tokens.
|
|
1503
|
+
* @param tokenA first token
|
|
1504
|
+
* @param tokenB second token
|
|
1505
|
+
* @param provider the provider to use to fetch the data
|
|
1506
|
+
*/
|
|
1507
|
+
static async fetchPairData(tokenA, tokenB, provider = getDefaultProvider(getNetwork(tokenA.chainId))) {
|
|
1508
|
+
invariant4(tokenA.chainId === tokenB.chainId, "CHAIN_ID");
|
|
1509
|
+
const address = Pair.getAddress(tokenA, tokenB);
|
|
1510
|
+
const [reserves0, reserves1] = await new Contract(address, IPancakePair_default, provider).getReserves();
|
|
1511
|
+
const balances = tokenA.sortsBefore(tokenB) ? [reserves0, reserves1] : [reserves1, reserves0];
|
|
1512
|
+
return new Pair(
|
|
1513
|
+
CurrencyAmount.fromRawAmount(tokenA, balances[0]),
|
|
1514
|
+
CurrencyAmount.fromRawAmount(tokenB, balances[1])
|
|
1515
|
+
);
|
|
1516
|
+
}
|
|
1517
|
+
};
|
|
1518
|
+
|
|
1519
|
+
export { ChainId, ERC20Token, Ether, FACTORY_ADDRESS, FACTORY_ADDRESS_MAP, Fetcher, INIT_CODE_HASH, INIT_CODE_HASH_MAP, NATIVE, Native, ONE_HUNDRED_PERCENT, Pair, Route, Router, Trade, WBNB, WETH9, WNATIVE, ZERO_PERCENT, computePairAddress, inputOutputComparator, isTradeBetter, tradeComparator, validateAndParseAddress };
|