-
Notifications
You must be signed in to change notification settings - Fork 44
/
synthetix.d.ts
169 lines (163 loc) · 4.04 KB
/
synthetix.d.ts
1
2
3
4
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
declare module 'synthetix' {
import { NetworkName, NetworkId } from '.';
import ethers from 'ethers';
type SourceData = {
bytecode: string;
abi: ethers.ContractInterface;
};
type SourceRecord = Record<string, SourceData>;
type Target = {
name: string;
source: string;
address: string;
link: string;
timestamp: string;
txn: string;
network: NetworkName;
};
export type TargetsRecord = Record<string, Target>;
type Feed = {
asset: string;
category: string;
description?: string;
exchange?: string;
feed?: string;
sign: string;
};
export type FeedRecord = Record<string, Feed>;
export type Token = {
address: string;
asset?: string;
decimals: number;
feed?: string;
index?: Array<{
asset: string;
category: string;
description: string;
sign: string;
units: number;
weight: number;
}>;
inverted?: {
entryPoint: number;
lowerLimit: number;
upperLimit: number;
};
name: string;
symbol: string;
};
export type User = {
name: string;
address: string;
};
type ContractInfo = {
address: string;
replaced_in: string;
status: string;
};
export type Version = {
commit: string;
contracts: { [name: string]: ContractInfo };
date: string;
fulltag: string;
network: string;
release: string;
tag: string;
};
type VersionRecord = Record<string, Version>;
type StakingReward = {
name: string;
rewardsToken: string;
stakingToken: string;
};
export function getNetworkFromId(arg: { id: NetworkId | number }): {
useOvm?: boolean;
network: NetworkName;
};
export function getSource<
T extends { network: NetworkName; useOvm?: boolean; contract?: string }
>(
arg: T
): T extends { network: NetworkName; useOvm?: boolean; contract: string } // If contract is provided we return Source data. If not we return the contracts map
? SourceData
: SourceRecord;
export function getTarget<
T extends { network: NetworkName; useOvm?: boolean; contract?: string }
>(
arg: T
): T extends { network: NetworkName; useOvm?: boolean; contract: string } // If contract is provided we return Source data. If not we return the contracts map
? Target
: TargetsRecord;
export const chainIdMapping = {
1: {
useOvm: false,
fork: false,
network: 'mainnet',
},
5: {
useOvm: false,
fork: false,
network: 'goerli',
},
10: {
useOvm: true,
fork: false,
network: 'mainnet',
},
42: {
useOvm: false,
fork: false,
network: 'kovan',
},
69: {
useOvm: true,
fork: false,
network: 'kovan',
},
31337: {
useOvm: false,
fork: true,
network: 'mainnet',
},
'-1': {
useOvm: true,
fork: false,
network: 'goerli',
},
} as const;
export const networkToChainId = {
mainnet: 1,
goerli: 5,
'mainnet-ovm': 10,
kovan: 42,
'kovan-ovm': 69,
'mainnet-fork': 31337,
'goerli-ovm': '-1',
} as const;
// eslint-disable-next-line
export function getSynths(arg: { network: NetworkName; useOvm?: boolean }): any; // Note contract interface will generate enums for this and return the correct type to consumers
export function getFeeds(arg: { network: NetworkName; useOvm?: boolean }): FeedRecord;
export function getTokens(arg: { network: NetworkName; useOvm?: boolean }): Token[];
export function getUsers(arg: { network: NetworkName; useOvm?: boolean }): User[];
export function getVersions(arg: { network: NetworkName; useOvm?: boolean }): VersionRecord;
export function toBytes32(key: string): string;
export function getSuspensionReasons(): { [code: number]: string };
export function getStakingRewards(arg: {
network: NetworkName;
useOvm?: boolean;
}): StakingReward[];
export const network: {
id: NetworkId;
name: NetworkName;
useOvm: boolean;
};
export const networks: NetworkName[];
export const networkToChainId: Record<NetworkName, NetworkId>;
export const decode: (config: { network: NetworkName; data: string; target: Target }) => {
// eslint-disable-next-line
method: { name: string; params: Array<any> };
contract: string;
};
// eslint-disable-next-line
export const defaults: { [key: string]: any };
}