@dolomite-exchange/dolomite-margin 0.2.6 → 0.2.7
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/build/contracts/Account.json +11 -11
- package/build/contracts/Actions.json +11 -11
- package/build/contracts/Address.json +1 -1
- package/build/contracts/Admin.json +23 -23
- package/build/contracts/AdminImpl.json +35 -307
- package/build/contracts/AdvancedMath.json +7 -7
- package/build/contracts/AmmRebalancerProxy.json +577 -621
- package/build/contracts/AmmRebalancerProxyV1.json +78 -32
- package/build/contracts/Babylonian.json +1 -1
- package/build/contracts/Bits.json +9 -9
- package/build/contracts/Cache.json +13 -13
- package/build/contracts/ChainlinkPriceOracleV1.json +16 -16
- package/build/contracts/Context.json +1 -1
- package/build/contracts/CustomTestToken.json +9 -9
- package/build/contracts/Decimal.json +9 -9
- package/build/contracts/DelayedMultiSig.json +9 -9
- package/build/contracts/DolomiteAmmERC20.json +11 -11
- package/build/contracts/DolomiteAmmFactory.json +14 -52
- package/build/contracts/DolomiteAmmLibrary.json +24 -24
- package/build/contracts/DolomiteAmmPair.json +27 -27
- package/build/contracts/DolomiteAmmRouterProxy.json +30 -363
- package/build/contracts/DolomiteMargin.json +21 -67
- package/build/contracts/DoubleExponentInterestSetter.json +15 -21
- package/build/contracts/EnumerableSet.json +7 -7
- package/build/contracts/ErroringOmiseToken.json +9 -9
- package/build/contracts/ErroringToken.json +10 -10
- package/build/contracts/Events.json +17 -17
- package/build/contracts/ExcessivelySafeCall.json +35 -35
- package/build/contracts/Exchange.json +15 -15
- package/build/contracts/Expiry.json +36 -36
- package/build/contracts/Getters.json +33 -33
- package/build/contracts/IAutoTrader.json +9 -9
- package/build/contracts/ICallee.json +7 -7
- package/build/contracts/IChainlinkAggregator.json +5 -5
- package/build/contracts/IDolomiteAmmERC20.json +5 -5
- package/build/contracts/IDolomiteAmmFactory.json +9 -9
- package/build/contracts/IDolomiteAmmPair.json +9 -9
- package/build/contracts/IDolomiteMargin.json +23 -23
- package/build/contracts/IERC20.json +1 -1
- package/build/contracts/IERC20Detailed.json +5 -5
- package/build/contracts/IExchangeWrapper.json +5 -5
- package/build/contracts/IExpiry.json +9 -9
- package/build/contracts/IInterestSetter.json +7 -7
- package/build/contracts/ILiquidationCallback.json +7 -7
- package/build/contracts/IMakerOracle.json +5 -5
- package/build/contracts/IOasisDex.json +5 -5
- package/build/contracts/IPriceOracle.json +7 -7
- package/build/contracts/IRecyclable.json +9 -9
- package/build/contracts/ITransferProxy.json +5 -5
- package/build/contracts/IUniswapV2Callee.json +5 -5
- package/build/contracts/IUniswapV2Factory.json +5 -5
- package/build/contracts/IUniswapV2Pair.json +5 -5
- package/build/contracts/IUniswapV2Router.json +5 -5
- package/build/contracts/IWETH.json +5 -5
- package/build/contracts/Interest.json +15 -15
- package/build/contracts/LiquidateOrVaporizeImpl.json +32 -83
- package/build/contracts/LiquidatorProxyHelper.json +23 -23
- package/build/contracts/LiquidatorProxyV1.json +30 -36
- package/build/contracts/LiquidatorProxyV1WithAmm.json +49 -105
- package/build/contracts/Math.json +1 -1
- package/build/contracts/Migrations.json +8 -14
- package/build/contracts/Monetary.json +7 -7
- package/build/contracts/MultiCall.json +8 -14
- package/build/contracts/MultiSig.json +7 -7
- package/build/contracts/OmiseToken.json +8 -8
- package/build/contracts/OnlyDolomiteMargin.json +11 -11
- package/build/contracts/Operation.json +15 -15
- package/build/contracts/OperationImpl.json +39 -47
- package/build/contracts/Ownable.json +1 -1
- package/build/contracts/PartiallyDelayedMultiSig.json +9 -9
- package/build/contracts/PayableProxy.json +17 -23
- package/build/contracts/Permission.json +11 -11
- package/build/contracts/PolynomialInterestSetter.json +13 -13
- package/build/contracts/RecyclableTokenProxy.json +25 -25
- package/build/contracts/ReentrancyGuard.json +1 -1
- package/build/contracts/Require.json +7 -7
- package/build/contracts/SafeERC20.json +1 -1
- package/build/contracts/SafeETH.json +7 -7
- package/build/contracts/SafeLiquidationCallback.json +17 -17
- package/build/contracts/SafeMath.json +1 -1
- package/build/contracts/SignedOperationProxy.json +21 -104
- package/build/contracts/SimpleFeeOwner.json +18 -63
- package/build/contracts/State.json +9 -9
- package/build/contracts/Storage.json +37 -37
- package/build/contracts/TestAmmRebalancerProxy.json +32 -58
- package/build/contracts/TestAutoTrader.json +22 -22
- package/build/contracts/TestBtcUsdChainlinkAggregator.json +10 -10
- package/build/contracts/TestCallee.json +19 -19
- package/build/contracts/TestChainlinkPriceOracleV1.json +10 -94
- package/build/contracts/TestCounter.json +7 -7
- package/build/contracts/TestDaiUsdChainlinkAggregator.json +11 -11
- package/build/contracts/TestDolomiteMargin.json +22 -22
- package/build/contracts/TestDoubleExponentInterestSetter.json +10 -10
- package/build/contracts/TestEthUsdChainlinkAggregator.json +11 -11
- package/build/contracts/TestExchangeWrapper.json +28 -28
- package/build/contracts/TestInterestSetter.json +13 -13
- package/build/contracts/TestLib.json +22 -22
- package/build/contracts/TestLinkUsdChainlinkAggregator.json +11 -11
- package/build/contracts/TestLiquidateCallback.json +719 -719
- package/build/contracts/TestLiquidationCallback.json +13 -13
- package/build/contracts/TestLrcEthChainlinkAggregator.json +11 -11
- package/build/contracts/TestMakerOracle.json +10 -10
- package/build/contracts/TestMaticUsdChainlinkAggregator.json +10 -10
- package/build/contracts/TestOasisDex.json +12 -12
- package/build/contracts/TestOperationImpl.json +14 -14
- package/build/contracts/TestPolynomialInterestSetter.json +10 -10
- package/build/contracts/TestPriceAggregator.json +9 -9
- package/build/contracts/TestPriceOracle.json +13 -13
- package/build/contracts/TestRecyclableToken.json +9 -9
- package/build/contracts/TestSimpleCallee.json +15 -15
- package/build/contracts/TestToken.json +9 -9
- package/build/contracts/TestTrader.json +17 -17
- package/build/contracts/TestUniswapAmmRebalancerProxy.json +16 -16
- package/build/contracts/TestUsdcUsdChainlinkAggregator.json +11 -11
- package/build/contracts/TestWETH.json +9 -9
- package/build/contracts/Time.json +9 -9
- package/build/contracts/Token.json +9 -9
- package/build/contracts/TokenA.json +10 -10
- package/build/contracts/TokenB.json +10 -10
- package/build/contracts/TokenC.json +10 -10
- package/build/contracts/TokenD.json +10 -10
- package/build/contracts/TokenE.json +10 -10
- package/build/contracts/TokenF.json +10 -10
- package/build/contracts/TransferProxy.json +22 -28
- package/build/contracts/TypedSignature.json +9 -9
- package/build/contracts/Types.json +9 -9
- package/build/contracts/UQ112x112.json +7 -7
- package/build/contracts/UniswapV2ERC20.json +7 -7
- package/build/contracts/UniswapV2Factory.json +12 -12
- package/build/contracts/UniswapV2Library.json +20 -20
- package/build/contracts/UniswapV2Pair.json +17 -17
- package/build/contracts/UniswapV2Router02.json +16 -16
- package/build/contracts/WETH9.json +1 -1
- package/contracts/external/amm/DolomiteAmmERC20.sol +135 -0
- package/contracts/external/amm/DolomiteAmmFactory.sol +122 -0
- package/contracts/external/amm/DolomiteAmmPair.sol +573 -0
- package/contracts/external/amm/SimpleFeeOwner.sol +107 -0
- package/contracts/external/helpers/LiquidatorProxyHelper.sol +252 -0
- package/contracts/external/helpers/OnlyDolomiteMargin.sol +63 -0
- package/contracts/external/interestsetters/DoubleExponentInterestSetter.sol +212 -0
- package/contracts/external/interestsetters/PolynomialInterestSetter.sol +205 -0
- package/contracts/external/interfaces/IChainlinkAggregator.sol +33 -0
- package/contracts/external/interfaces/IDolomiteAmmERC20.sol +52 -0
- package/contracts/external/interfaces/IDolomiteAmmFactory.sol +42 -0
- package/contracts/external/interfaces/IDolomiteAmmPair.sol +116 -0
- package/contracts/external/interfaces/IExpiry.sol +70 -0
- package/contracts/external/interfaces/IMakerOracle.sol +52 -0
- package/contracts/external/interfaces/IOasisDex.sol +326 -0
- package/contracts/external/interfaces/ITransferProxy.sol +53 -0
- package/contracts/external/interfaces/IUniswapV2Router.sol +134 -0
- package/contracts/external/lib/AdvancedMath.sol +23 -0
- package/contracts/external/lib/DolomiteAmmLibrary.sol +323 -0
- package/contracts/external/lib/TypedSignature.sol +120 -0
- package/contracts/external/lib/UQ112x112.sol +22 -0
- package/contracts/external/multisig/DelayedMultiSig.sol +206 -0
- package/contracts/external/multisig/MultiSig.sol +571 -0
- package/contracts/external/multisig/PartiallyDelayedMultiSig.sol +174 -0
- package/contracts/external/oracles/ChainlinkPriceOracleV1.sol +197 -0
- package/contracts/external/oracles/TestChainlinkPriceOracleV1.sol +98 -0
- package/contracts/external/proxies/AmmRebalancerProxyV1.sol +465 -0
- package/contracts/external/proxies/DolomiteAmmRouterProxy.sol +877 -0
- package/contracts/external/proxies/LiquidatorProxyV1.sol +507 -0
- package/contracts/external/proxies/LiquidatorProxyV1WithAmm.sol +574 -0
- package/contracts/external/proxies/PayableProxy.sol +146 -0
- package/contracts/external/proxies/RecyclableTokenProxy.sol +463 -0
- package/contracts/external/proxies/SignedOperationProxy.sol +553 -0
- package/contracts/external/proxies/TransferProxy.sol +207 -0
- package/contracts/external/traders/Expiry.sol +532 -0
- package/contracts/external/uniswap-v2/UniswapV2ERC20.sol +118 -0
- package/contracts/external/uniswap-v2/UniswapV2Factory.sol +67 -0
- package/contracts/external/uniswap-v2/UniswapV2Pair.sol +283 -0
- package/contracts/external/uniswap-v2/UniswapV2Router02.sol +566 -0
- package/contracts/external/uniswap-v2/interfaces/IUniswapV2Callee.sol +13 -0
- package/contracts/external/uniswap-v2/interfaces/IUniswapV2Factory.sol +18 -0
- package/contracts/external/uniswap-v2/interfaces/IUniswapV2Pair.sol +67 -0
- package/contracts/external/uniswap-v2/interfaces/IWETH.sol +7 -0
- package/contracts/external/uniswap-v2/libraries/SafeETH.sol +29 -0
- package/contracts/external/uniswap-v2/libraries/UniswapV2Library.sol +117 -0
- package/contracts/external/utils/MultiCall.sol +95 -0
- package/contracts/protocol/impl/artifacts/OperationImpl.json +80 -0
- package/contracts/protocol/impl/artifacts/OperationImpl_metadata.json +193 -0
- package/dist/build/published_contracts/AdminImpl.json +2 -2
- package/dist/build/published_contracts/AmmRebalancerProxyV1.json +5 -0
- package/dist/build/published_contracts/ChainlinkPriceOracleV1.json +1 -1
- package/dist/build/published_contracts/DolomiteAmmFactory.json +1 -1
- package/dist/build/published_contracts/DolomiteAmmRouterProxy.json +1 -1
- package/dist/build/published_contracts/DoubleExponentInterestSetter.json +2 -2
- package/dist/build/published_contracts/Expiry.json +1 -1
- package/dist/build/published_contracts/LiquidatorProxyV1.json +1 -1
- package/dist/build/published_contracts/LiquidatorProxyV1WithAmm.json +1 -1
- package/dist/build/published_contracts/MultiCall.json +1 -1
- package/dist/build/published_contracts/PayableProxy.json +2 -2
- package/dist/build/published_contracts/SignedOperationProxy.json +2 -2
- package/dist/build/published_contracts/SimpleFeeOwner.json +1 -1
- package/dist/build/published_contracts/TestUniswapAmmRebalancerProxy.json +140 -0
- package/dist/build/published_contracts/TransferProxy.json +1 -1
- package/dist/src/lib/Contracts.d.ts +3 -1
- package/dist/src/lib/Contracts.js +7 -3
- package/dist/src/lib/Contracts.js.map +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|
|
3
|
+
Copyright 2019 dYdX Trading Inc.
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
|
16
|
+
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
pragma solidity ^0.5.7;
|
|
20
|
+
pragma experimental ABIEncoderV2;
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @title IOasisDex
|
|
25
|
+
* @author dYdX
|
|
26
|
+
*
|
|
27
|
+
* Interface for the OasisDex contract
|
|
28
|
+
*/
|
|
29
|
+
interface IOasisDex {
|
|
30
|
+
|
|
31
|
+
// ============ Structs ================
|
|
32
|
+
|
|
33
|
+
struct OfferInfo {
|
|
34
|
+
uint256 pay_amt;
|
|
35
|
+
address pay_gem;
|
|
36
|
+
uint256 buy_amt;
|
|
37
|
+
address buy_gem;
|
|
38
|
+
address owner;
|
|
39
|
+
uint64 timestamp;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
struct SortInfo {
|
|
43
|
+
uint256 next; //points to id of next higher offer
|
|
44
|
+
uint256 prev; //points to id of previous lower offer
|
|
45
|
+
uint256 delb; //the blocknumber where this entry was marked for delete
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// ============ Storage Getters ================
|
|
49
|
+
|
|
50
|
+
function last_offer_id()
|
|
51
|
+
external
|
|
52
|
+
view
|
|
53
|
+
returns (uint256);
|
|
54
|
+
|
|
55
|
+
function offers(
|
|
56
|
+
uint256 id
|
|
57
|
+
)
|
|
58
|
+
external
|
|
59
|
+
view
|
|
60
|
+
returns (OfferInfo memory);
|
|
61
|
+
|
|
62
|
+
function close_time()
|
|
63
|
+
external
|
|
64
|
+
view
|
|
65
|
+
returns (uint64);
|
|
66
|
+
|
|
67
|
+
function stopped()
|
|
68
|
+
external
|
|
69
|
+
view
|
|
70
|
+
returns (bool);
|
|
71
|
+
|
|
72
|
+
function buyEnabled()
|
|
73
|
+
external
|
|
74
|
+
view
|
|
75
|
+
returns (bool);
|
|
76
|
+
|
|
77
|
+
function matchingEnabled()
|
|
78
|
+
external
|
|
79
|
+
view
|
|
80
|
+
returns (bool);
|
|
81
|
+
|
|
82
|
+
function _rank(
|
|
83
|
+
uint256 id
|
|
84
|
+
)
|
|
85
|
+
external
|
|
86
|
+
view
|
|
87
|
+
returns (SortInfo memory);
|
|
88
|
+
|
|
89
|
+
function _best(
|
|
90
|
+
address sell_gem,
|
|
91
|
+
address buy_gem
|
|
92
|
+
)
|
|
93
|
+
external
|
|
94
|
+
view
|
|
95
|
+
returns (uint256);
|
|
96
|
+
|
|
97
|
+
function _span(
|
|
98
|
+
address sell_gem,
|
|
99
|
+
address buy_gem
|
|
100
|
+
)
|
|
101
|
+
external
|
|
102
|
+
view
|
|
103
|
+
returns (uint256);
|
|
104
|
+
|
|
105
|
+
function _dust(
|
|
106
|
+
address gem
|
|
107
|
+
)
|
|
108
|
+
external
|
|
109
|
+
view
|
|
110
|
+
returns (uint256);
|
|
111
|
+
|
|
112
|
+
function _near(
|
|
113
|
+
uint256 id
|
|
114
|
+
)
|
|
115
|
+
external
|
|
116
|
+
view
|
|
117
|
+
returns (uint256);
|
|
118
|
+
|
|
119
|
+
// ============ Constant Functions ================
|
|
120
|
+
|
|
121
|
+
function isActive(
|
|
122
|
+
uint256 id
|
|
123
|
+
)
|
|
124
|
+
external
|
|
125
|
+
view
|
|
126
|
+
returns (bool);
|
|
127
|
+
|
|
128
|
+
function getOwner(
|
|
129
|
+
uint256 id
|
|
130
|
+
)
|
|
131
|
+
external
|
|
132
|
+
view
|
|
133
|
+
returns (address);
|
|
134
|
+
|
|
135
|
+
function getOffer(
|
|
136
|
+
uint256 id
|
|
137
|
+
)
|
|
138
|
+
external
|
|
139
|
+
view
|
|
140
|
+
returns (uint256, address, uint256, address);
|
|
141
|
+
|
|
142
|
+
function getMinSell(
|
|
143
|
+
address pay_gem
|
|
144
|
+
)
|
|
145
|
+
external
|
|
146
|
+
view
|
|
147
|
+
returns (uint256);
|
|
148
|
+
|
|
149
|
+
function getBestOffer(
|
|
150
|
+
address sell_gem,
|
|
151
|
+
address buy_gem
|
|
152
|
+
)
|
|
153
|
+
external
|
|
154
|
+
view
|
|
155
|
+
returns (uint256);
|
|
156
|
+
|
|
157
|
+
function getWorseOffer(
|
|
158
|
+
uint256 id
|
|
159
|
+
)
|
|
160
|
+
external
|
|
161
|
+
view
|
|
162
|
+
returns (uint256);
|
|
163
|
+
|
|
164
|
+
function getBetterOffer(
|
|
165
|
+
uint256 id
|
|
166
|
+
)
|
|
167
|
+
external
|
|
168
|
+
view
|
|
169
|
+
returns (uint256);
|
|
170
|
+
|
|
171
|
+
function getOfferCount(
|
|
172
|
+
address sell_gem,
|
|
173
|
+
address buy_gem
|
|
174
|
+
)
|
|
175
|
+
external
|
|
176
|
+
view
|
|
177
|
+
returns (uint256);
|
|
178
|
+
|
|
179
|
+
function getFirstUnsortedOffer()
|
|
180
|
+
external
|
|
181
|
+
view
|
|
182
|
+
returns (uint256);
|
|
183
|
+
|
|
184
|
+
function getNextUnsortedOffer(
|
|
185
|
+
uint256 id
|
|
186
|
+
)
|
|
187
|
+
external
|
|
188
|
+
view
|
|
189
|
+
returns (uint256);
|
|
190
|
+
|
|
191
|
+
function isOfferSorted(
|
|
192
|
+
uint256 id
|
|
193
|
+
)
|
|
194
|
+
external
|
|
195
|
+
view
|
|
196
|
+
returns (bool);
|
|
197
|
+
|
|
198
|
+
function getBuyAmount(
|
|
199
|
+
address buy_gem,
|
|
200
|
+
address pay_gem,
|
|
201
|
+
uint256 pay_amt
|
|
202
|
+
)
|
|
203
|
+
external
|
|
204
|
+
view
|
|
205
|
+
returns (uint256);
|
|
206
|
+
|
|
207
|
+
function getPayAmount(
|
|
208
|
+
address pay_gem,
|
|
209
|
+
address buy_gem,
|
|
210
|
+
uint256 buy_amt
|
|
211
|
+
)
|
|
212
|
+
external
|
|
213
|
+
view
|
|
214
|
+
returns (uint256);
|
|
215
|
+
|
|
216
|
+
function isClosed()
|
|
217
|
+
external
|
|
218
|
+
view
|
|
219
|
+
returns (bool);
|
|
220
|
+
|
|
221
|
+
function getTime()
|
|
222
|
+
external
|
|
223
|
+
view
|
|
224
|
+
returns (uint64);
|
|
225
|
+
|
|
226
|
+
// ============ Non-Constant Functions ================
|
|
227
|
+
|
|
228
|
+
function bump(
|
|
229
|
+
bytes32 id_
|
|
230
|
+
)
|
|
231
|
+
external;
|
|
232
|
+
|
|
233
|
+
function buy(
|
|
234
|
+
uint256 id,
|
|
235
|
+
uint256 quantity
|
|
236
|
+
)
|
|
237
|
+
external
|
|
238
|
+
returns (bool);
|
|
239
|
+
|
|
240
|
+
function cancel(
|
|
241
|
+
uint256 id
|
|
242
|
+
)
|
|
243
|
+
external
|
|
244
|
+
returns (bool);
|
|
245
|
+
|
|
246
|
+
function kill(
|
|
247
|
+
bytes32 id
|
|
248
|
+
)
|
|
249
|
+
external;
|
|
250
|
+
|
|
251
|
+
function make(
|
|
252
|
+
address pay_gem,
|
|
253
|
+
address buy_gem,
|
|
254
|
+
uint128 pay_amt,
|
|
255
|
+
uint128 buy_amt
|
|
256
|
+
)
|
|
257
|
+
external
|
|
258
|
+
returns (bytes32);
|
|
259
|
+
|
|
260
|
+
function take(
|
|
261
|
+
bytes32 id,
|
|
262
|
+
uint128 maxTakeAmount
|
|
263
|
+
)
|
|
264
|
+
external;
|
|
265
|
+
|
|
266
|
+
function offer(
|
|
267
|
+
uint256 pay_amt,
|
|
268
|
+
address pay_gem,
|
|
269
|
+
uint256 buy_amt,
|
|
270
|
+
address buy_gem
|
|
271
|
+
)
|
|
272
|
+
external
|
|
273
|
+
returns (uint256);
|
|
274
|
+
|
|
275
|
+
function offer(
|
|
276
|
+
uint256 pay_amt,
|
|
277
|
+
address pay_gem,
|
|
278
|
+
uint256 buy_amt,
|
|
279
|
+
address buy_gem,
|
|
280
|
+
uint256 pos
|
|
281
|
+
)
|
|
282
|
+
external
|
|
283
|
+
returns (uint256);
|
|
284
|
+
|
|
285
|
+
function offer(
|
|
286
|
+
uint256 pay_amt,
|
|
287
|
+
address pay_gem,
|
|
288
|
+
uint256 buy_amt,
|
|
289
|
+
address buy_gem,
|
|
290
|
+
uint256 pos,
|
|
291
|
+
bool rounding
|
|
292
|
+
)
|
|
293
|
+
external
|
|
294
|
+
returns (uint256);
|
|
295
|
+
|
|
296
|
+
function insert(
|
|
297
|
+
uint256 id,
|
|
298
|
+
uint256 pos
|
|
299
|
+
)
|
|
300
|
+
external
|
|
301
|
+
returns (bool);
|
|
302
|
+
|
|
303
|
+
function del_rank(
|
|
304
|
+
uint256 id
|
|
305
|
+
)
|
|
306
|
+
external
|
|
307
|
+
returns (bool);
|
|
308
|
+
|
|
309
|
+
function sellAllAmount(
|
|
310
|
+
address pay_gem,
|
|
311
|
+
uint256 pay_amt,
|
|
312
|
+
address buy_gem,
|
|
313
|
+
uint256 min_fill_amount
|
|
314
|
+
)
|
|
315
|
+
external
|
|
316
|
+
returns (uint256);
|
|
317
|
+
|
|
318
|
+
function buyAllAmount(
|
|
319
|
+
address buy_gem,
|
|
320
|
+
uint256 buy_amt,
|
|
321
|
+
address pay_gem,
|
|
322
|
+
uint256 max_fill_amount
|
|
323
|
+
)
|
|
324
|
+
external
|
|
325
|
+
returns (uint256);
|
|
326
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|
|
3
|
+
Copyright 2019 dYdX Trading Inc.
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
|
16
|
+
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
pragma solidity ^0.5.7;
|
|
20
|
+
|
|
21
|
+
interface ITransferProxy {
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @dev Allows or disallows the caller from invoking the different transfer functions in this contract
|
|
25
|
+
*/
|
|
26
|
+
function setIsCallerTrusted(address caller, bool isTrusted) external;
|
|
27
|
+
|
|
28
|
+
function isCallerTrusted(address caller) external view returns (bool);
|
|
29
|
+
|
|
30
|
+
function transfer(
|
|
31
|
+
uint fromAccountIndex,
|
|
32
|
+
address to,
|
|
33
|
+
uint toAccountIndex,
|
|
34
|
+
address token,
|
|
35
|
+
uint amount
|
|
36
|
+
) external;
|
|
37
|
+
|
|
38
|
+
function transferMultiple(
|
|
39
|
+
uint fromAccountIndex,
|
|
40
|
+
address to,
|
|
41
|
+
uint toAccountIndex,
|
|
42
|
+
address[] calldata tokens,
|
|
43
|
+
uint[] calldata amounts
|
|
44
|
+
) external;
|
|
45
|
+
|
|
46
|
+
function transferMultipleWithMarkets(
|
|
47
|
+
uint fromAccountIndex,
|
|
48
|
+
address to,
|
|
49
|
+
uint toAccountIndex,
|
|
50
|
+
uint[] calldata markets,
|
|
51
|
+
uint[] calldata amounts
|
|
52
|
+
) external;
|
|
53
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
pragma solidity ^0.5.7;
|
|
2
|
+
|
|
3
|
+
interface IUniswapV2Router {
|
|
4
|
+
|
|
5
|
+
function factory() external pure returns (address);
|
|
6
|
+
|
|
7
|
+
function WETH() external pure returns (address);
|
|
8
|
+
|
|
9
|
+
function addLiquidity(
|
|
10
|
+
address tokenA,
|
|
11
|
+
address tokenB,
|
|
12
|
+
uint amountADesired,
|
|
13
|
+
uint amountBDesired,
|
|
14
|
+
uint amountAMin,
|
|
15
|
+
uint amountBMin,
|
|
16
|
+
address to,
|
|
17
|
+
uint deadline
|
|
18
|
+
) external returns (uint amountA, uint amountB, uint liquidity);
|
|
19
|
+
|
|
20
|
+
function addLiquidityETH(
|
|
21
|
+
address token,
|
|
22
|
+
uint amountTokenDesired,
|
|
23
|
+
uint amountTokenMin,
|
|
24
|
+
uint amountETHMin,
|
|
25
|
+
address to,
|
|
26
|
+
uint deadline
|
|
27
|
+
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
|
|
28
|
+
|
|
29
|
+
function removeLiquidity(
|
|
30
|
+
address tokenA,
|
|
31
|
+
address tokenB,
|
|
32
|
+
uint liquidity,
|
|
33
|
+
uint amountAMin,
|
|
34
|
+
uint amountBMin,
|
|
35
|
+
address to,
|
|
36
|
+
uint deadline
|
|
37
|
+
) external returns (uint amountA, uint amountB);
|
|
38
|
+
|
|
39
|
+
function removeLiquidityETH(
|
|
40
|
+
address token,
|
|
41
|
+
uint liquidity,
|
|
42
|
+
uint amountTokenMin,
|
|
43
|
+
uint amountETHMin,
|
|
44
|
+
address to,
|
|
45
|
+
uint deadline
|
|
46
|
+
) external returns (uint amountToken, uint amountETH);
|
|
47
|
+
|
|
48
|
+
function removeLiquidityWithPermit(
|
|
49
|
+
address tokenA,
|
|
50
|
+
address tokenB,
|
|
51
|
+
uint liquidity,
|
|
52
|
+
uint amountAMin,
|
|
53
|
+
uint amountBMin,
|
|
54
|
+
address to,
|
|
55
|
+
uint deadline,
|
|
56
|
+
bool approveMax, uint8 v, bytes32 r, bytes32 s
|
|
57
|
+
) external returns (uint amountA, uint amountB);
|
|
58
|
+
|
|
59
|
+
function removeLiquidityETHWithPermit(
|
|
60
|
+
address token,
|
|
61
|
+
uint liquidity,
|
|
62
|
+
uint amountTokenMin,
|
|
63
|
+
uint amountETHMin,
|
|
64
|
+
address to,
|
|
65
|
+
uint deadline,
|
|
66
|
+
bool approveMax, uint8 v, bytes32 r, bytes32 s
|
|
67
|
+
) external returns (uint amountToken, uint amountETH);
|
|
68
|
+
|
|
69
|
+
function swapExactTokensForTokens(
|
|
70
|
+
uint amountIn,
|
|
71
|
+
uint amountOutMin,
|
|
72
|
+
address[] calldata path,
|
|
73
|
+
address to,
|
|
74
|
+
uint deadline
|
|
75
|
+
) external returns (uint[] memory amounts);
|
|
76
|
+
|
|
77
|
+
function swapTokensForExactTokens(
|
|
78
|
+
uint amountOut,
|
|
79
|
+
uint amountInMax,
|
|
80
|
+
address[] calldata path,
|
|
81
|
+
address to,
|
|
82
|
+
uint deadline
|
|
83
|
+
) external returns (uint[] memory amounts);
|
|
84
|
+
|
|
85
|
+
function swapExactETHForTokens(
|
|
86
|
+
uint amountOutMin,
|
|
87
|
+
address[] calldata path,
|
|
88
|
+
address to,
|
|
89
|
+
uint deadline
|
|
90
|
+
)
|
|
91
|
+
external
|
|
92
|
+
payable
|
|
93
|
+
returns (uint[] memory amounts);
|
|
94
|
+
|
|
95
|
+
function swapTokensForExactETH(
|
|
96
|
+
uint amountOut,
|
|
97
|
+
uint amountInMax,
|
|
98
|
+
address[] calldata path,
|
|
99
|
+
address to,
|
|
100
|
+
uint deadline
|
|
101
|
+
)
|
|
102
|
+
external
|
|
103
|
+
returns (uint[] memory amounts);
|
|
104
|
+
|
|
105
|
+
function swapExactTokensForETH(
|
|
106
|
+
uint amountIn,
|
|
107
|
+
uint amountOutMin,
|
|
108
|
+
address[] calldata path,
|
|
109
|
+
address to,
|
|
110
|
+
uint deadline
|
|
111
|
+
)
|
|
112
|
+
external
|
|
113
|
+
returns (uint[] memory amounts);
|
|
114
|
+
|
|
115
|
+
function swapETHForExactTokens(
|
|
116
|
+
uint amountOut,
|
|
117
|
+
address[] calldata path,
|
|
118
|
+
address to,
|
|
119
|
+
uint deadline
|
|
120
|
+
)
|
|
121
|
+
external
|
|
122
|
+
payable
|
|
123
|
+
returns (uint[] memory amounts);
|
|
124
|
+
|
|
125
|
+
function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
|
|
126
|
+
|
|
127
|
+
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
|
|
128
|
+
|
|
129
|
+
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
|
|
130
|
+
|
|
131
|
+
function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
|
|
132
|
+
|
|
133
|
+
function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
|
|
134
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
pragma solidity ^0.5.16;
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
/// A library for performing various math operations
|
|
5
|
+
library AdvancedMath {
|
|
6
|
+
function min(uint x, uint y) internal pure returns (uint z) {
|
|
7
|
+
z = x < y ? x : y;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method)
|
|
11
|
+
function sqrt(uint y) internal pure returns (uint z) {
|
|
12
|
+
if (y > 3) {
|
|
13
|
+
z = y;
|
|
14
|
+
uint x = y / 2 + 1;
|
|
15
|
+
while (x < z) {
|
|
16
|
+
z = x;
|
|
17
|
+
x = (y / x + x) / 2;
|
|
18
|
+
}
|
|
19
|
+
} else if (y != 0) {
|
|
20
|
+
z = 1;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|