@pendle/core-v2 0.5.1-beta-5 → 0.6.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.
Files changed (54) hide show
  1. package/contracts/SuperComposableYield/ISuperComposableYield.sol +2 -0
  2. package/contracts/SuperComposableYield/implementations/RewardManager.sol +35 -20
  3. package/contracts/SuperComposableYield/implementations/SCYBase.sol +39 -19
  4. package/contracts/SuperComposableYield/implementations/SCYBaseWithRewards.sol +26 -14
  5. package/contracts/core/PendleBaseToken.sol +2 -2
  6. package/contracts/core/PendleMarket.sol +145 -61
  7. package/contracts/core/PendleMarketFactory.sol +30 -19
  8. package/contracts/core/{PendleOwnershipToken.sol → PendlePrincipalToken.sol} +14 -2
  9. package/contracts/core/PendleRouter.sol +23 -9
  10. package/contracts/core/PendleSCYImpl/AaveV3/PendleAaveV3SCY.sol +21 -20
  11. package/contracts/core/PendleSCYImpl/PendleBenQiErc20SCY.sol +22 -16
  12. package/contracts/core/PendleSCYImpl/PendleBtrflySCY.sol +13 -13
  13. package/contracts/core/PendleSCYImpl/PendleStETHSCY.sol +107 -0
  14. package/contracts/core/PendleSCYImpl/PendleYearnVaultSCY.sol +14 -15
  15. package/contracts/core/PendleYieldContractFactory.sol +29 -14
  16. package/contracts/core/PendleYieldToken.sol +130 -76
  17. package/contracts/core/RouterStatic.sol +51 -51
  18. package/contracts/core/actions/ActionCallback.sol +36 -18
  19. package/contracts/core/actions/ActionCore.sol +41 -88
  20. package/contracts/core/actions/ActionRedeem.sol +36 -0
  21. package/contracts/core/actions/ActionYT.sol +41 -59
  22. package/contracts/core/actions/base/{ActionSCYAndOTBase.sol → ActionSCYAndPTBase.sol} +59 -45
  23. package/contracts/core/actions/base/{ActionSCYAndYOBase.sol → ActionSCYAndPYBase.sol} +57 -19
  24. package/contracts/core/actions/base/ActionSCYAndYTBase.sol +31 -21
  25. package/contracts/interfaces/IPActionCore.sol +21 -28
  26. package/contracts/interfaces/IPActionRedeem.sol +17 -0
  27. package/contracts/interfaces/IPActionYT.sol +5 -12
  28. package/contracts/interfaces/IPAllAction.sol +2 -2
  29. package/contracts/interfaces/IPMarket.sol +33 -10
  30. package/contracts/interfaces/IPMarketAddRemoveCallback.sol +2 -2
  31. package/contracts/interfaces/IPMarketFactory.sol +3 -1
  32. package/contracts/interfaces/IPMarketSwapCallback.sol +1 -1
  33. package/contracts/interfaces/{IPOwnershipToken.sol → IPPrincipalToken.sol} +1 -1
  34. package/contracts/interfaces/IPRouterStatic.sol +19 -19
  35. package/contracts/interfaces/IPYieldContractFactory.sol +10 -2
  36. package/contracts/interfaces/IPYieldToken.sol +14 -5
  37. package/contracts/interfaces/IWstETH.sol +10 -0
  38. package/contracts/libraries/JoeLibrary.sol +1 -1
  39. package/contracts/libraries/math/LogExpMath.sol +1 -1
  40. package/contracts/libraries/math/MarketApproxLib.sol +128 -88
  41. package/contracts/libraries/math/MarketMathAux.sol +13 -13
  42. package/contracts/libraries/math/MarketMathCore.sol +62 -93
  43. package/contracts/libraries/math/Math.sol +14 -2
  44. package/contracts/periphery/PendleGovernanceManager.sol +5 -3
  45. package/package.json +3 -2
  46. package/typechain-types/IPRouterStatic.ts +480 -0
  47. package/typechain-types/RouterStatic.ts +484 -4
  48. package/typechain-types/factories/IPRouterStatic__factory.ts +616 -0
  49. package/typechain-types/factories/PendleRouter__factory.ts +1 -1
  50. package/typechain-types/factories/RouterStatic__factory.ts +619 -3
  51. package/typechain-types/ActionSCYAndYOBase.ts +0 -223
  52. package/typechain-types/PendleRouterRedeemUpg.ts +0 -125
  53. package/typechain-types/factories/ActionSCYAndYOBase__factory.ts +0 -200
  54. package/typechain-types/factories/PendleRouterRedeemUpg__factory.ts +0 -112
@@ -8,8 +8,24 @@ import "./MarketMathCore.sol";
8
8
  struct ApproxParams {
9
9
  uint256 guessMin;
10
10
  uint256 guessMax;
11
- uint256 maxIteration;
12
- uint256 eps;
11
+ uint256 guessOffchain; // pass 0 in to skip this variable
12
+ uint256 maxIteration; // every iteration, the diff between guessMin and guessMax will be divided by 2
13
+ uint256 eps; // the max eps between the returned result & the correct result, base 1e18. Normally this number will be set
14
+ // to 1e15 (1e18/1000 = 0.1%)
15
+
16
+ /// Further explanation of the eps. Take swapExactScyForPt for example. To calc the corresponding amount of Pt to swap out,
17
+ /// it's necessary to run an approximation algorithm, because by default there only exists the Pt to Scy formula
18
+ /// To approx, the 5 values above will have to be provided, and the approx process will run as follows:
19
+ /// mid = (guessMin + guessMax) / 2 // mid here is the current guess of the amount of Pt out
20
+ /// netScyNeed = calcSwapScyForExactPt(mid)
21
+ /// if (netScyNeed > exactScyIn) guessMax = mid - 1 // since the maximum Scy in can't exceed the exactScyIn
22
+ /// else guessMin = mid (1)
23
+ /// For the (1), since netScyNeed <= exactScyIn, the result might be usable. If the netScyNeed is within eps of
24
+ /// exactScyIn (ex eps=0.1% => we have used 99.9% the amount of Scy specified), mid will be chosen as the final guess result
25
+
26
+ /// for guessOffchain, this is to provide a shortcut to guessing. The offchain SDK can precalculate the exact result
27
+ /// before the tx is sent. When the tx reaches the contract, the guessOffchain will be checked first, and if it satisfies the
28
+ /// approximation, it will be used (and save all the guessing).
13
29
  }
14
30
 
15
31
  // solhint-disable reason-string, ordering
@@ -20,7 +36,13 @@ library MarketApproxLib {
20
36
  using SCYIndexLib for SCYIndex;
21
37
  using MarketMathCore for MarketState;
22
38
 
23
- function approxSwapOtForExactScy(
39
+ struct SlotSwapPtForExactScy {
40
+ uint256 ptInGuess;
41
+ int256 _assetToAccount;
42
+ uint256 netAssetOut;
43
+ }
44
+
45
+ function approxSwapPtForExactScy(
24
46
  MarketState memory market,
25
47
  SCYIndex index,
26
48
  uint256 minScyOut,
@@ -30,7 +52,7 @@ library MarketApproxLib {
30
52
  internal
31
53
  pure
32
54
  returns (
33
- uint256, /*netOtIn*/
55
+ uint256, /*netPtIn*/
34
56
  uint256 /*netScyOut*/
35
57
  )
36
58
  {
@@ -50,55 +72,59 @@ library MarketApproxLib {
50
72
  MarketPreCompute memory comp = market.getMarketPreCompute(index, blockTime);
51
73
 
52
74
  if (approx.guessMax == type(uint256).max) {
53
- approx.guessMax = calcMaxOtIn(market.totalOt, comp.totalAsset);
75
+ approx.guessMax = calcMaxPtIn(market.totalPt, comp.totalAsset);
54
76
  }
55
77
 
56
78
  /// ------------------------------------------------------------
57
79
  /// BINARY SEARCH
58
80
  /// ------------------------------------------------------------
59
81
 
60
- while (approx.maxIteration != 0) {
61
- unchecked {
62
- approx.maxIteration--;
63
- }
64
- uint256 otInGuess = (approx.guessMin + approx.guessMax) / 2;
82
+ for (uint256 iter = 0; iter < approx.maxIteration; ) {
83
+ // ++iter at end of loop
84
+
85
+ SlotSwapPtForExactScy memory slot;
86
+ slot.ptInGuess = getCurrentGuess(iter, approx);
65
87
 
66
88
  /// ------------------------------------------------------------
67
89
  /// CHECK SLOPE
68
90
  /// ------------------------------------------------------------
69
91
  (isSlopeNonNeg, largestGoodSlope) = updateSlope(
70
- market.totalOt,
71
- otInGuess,
92
+ market.totalPt,
93
+ slot.ptInGuess,
72
94
  comp,
73
95
  largestGoodSlope
74
96
  );
75
97
  if (!isSlopeNonNeg) {
76
- approx.guessMax = otInGuess;
98
+ approx.guessMax = slot.ptInGuess;
77
99
  continue;
78
100
  }
79
101
 
80
102
  /// ------------------------------------------------------------
81
103
  /// CHECK ASSET
82
104
  /// ------------------------------------------------------------
83
- (int256 _assetToAccount, ) = market.calcTrade(comp, otInGuess.neg());
84
- uint256 netAssetOut = _assetToAccount.Uint();
105
+ (slot._assetToAccount, ) = market.calcTrade(comp, slot.ptInGuess.neg());
106
+ slot.netAssetOut = slot._assetToAccount.Uint();
85
107
 
86
- if (netAssetOut >= minAssetOut) {
87
- approx.guessMax = otInGuess;
108
+ if (slot.netAssetOut >= minAssetOut) {
109
+ approx.guessMax = slot.ptInGuess;
88
110
  /// ------------------------------------------------------------
89
111
  /// CHECK IF ANSWER FOUND
90
112
  /// ------------------------------------------------------------
91
- if (Math.isAGreaterApproxB(netAssetOut, minAssetOut, approx.eps)) {
92
- return (otInGuess, index.assetToScy(netAssetOut));
113
+ if (Math.isAGreaterApproxB(slot.netAssetOut, minAssetOut, approx.eps)) {
114
+ return (slot.ptInGuess, index.assetToScy(slot.netAssetOut));
93
115
  }
94
116
  } else {
95
- approx.guessMin = otInGuess + 1;
117
+ approx.guessMin = slot.ptInGuess + 1;
118
+ }
119
+
120
+ unchecked {
121
+ ++iter;
96
122
  }
97
123
  }
98
124
  revert("approx fail");
99
125
  }
100
126
 
101
- function approxSwapExactScyForOt(
127
+ function approxSwapExactScyForPt(
102
128
  MarketState memory market,
103
129
  SCYIndex index,
104
130
  uint256 maxScyIn,
@@ -108,7 +134,7 @@ library MarketApproxLib {
108
134
  internal
109
135
  pure
110
136
  returns (
111
- uint256, /*netOtOut*/
137
+ uint256, /*netPtOut*/
112
138
  uint256 /*netScyIn*/
113
139
  )
114
140
  {
@@ -126,42 +152,43 @@ library MarketApproxLib {
126
152
  MarketPreCompute memory comp = market.getMarketPreCompute(index, blockTime);
127
153
 
128
154
  if (approx.guessMax == type(uint256).max) {
129
- approx.guessMax = calcMaxOtOut(market.totalOt, comp);
155
+ approx.guessMax = calcMaxPtOut(market.totalPt, comp);
130
156
  }
131
157
 
132
158
  /// ------------------------------------------------------------
133
159
  /// BINARY SEARCH
134
160
  /// ------------------------------------------------------------
135
161
 
136
- while (approx.maxIteration != 0) {
137
- unchecked {
138
- approx.maxIteration--;
139
- }
140
- uint256 otOutGuess = (approx.guessMin + approx.guessMax + 1) / 2;
162
+ for (uint256 iter = 0; iter < approx.maxIteration; ) {
163
+ uint256 ptOutGuess = getCurrentGuess(iter, approx);
141
164
 
142
165
  /// ------------------------------------------------------------
143
166
  /// CHECK ASSET
144
167
  /// ------------------------------------------------------------
145
- (int256 _assetToAccount, ) = market.calcTrade(comp, otOutGuess.Int());
168
+ (int256 _assetToAccount, ) = market.calcTrade(comp, ptOutGuess.Int());
146
169
  uint256 netAssetIn = _assetToAccount.neg().Uint();
147
170
 
148
171
  if (netAssetIn <= maxAssetIn) {
149
- approx.guessMin = otOutGuess;
172
+ approx.guessMin = ptOutGuess;
150
173
  /// ------------------------------------------------------------
151
174
  /// CHECK IF ANSWER FOUND
152
175
  /// ------------------------------------------------------------
153
176
  if (Math.isASmallerApproxB(netAssetIn, maxAssetIn, approx.eps)) {
154
- return (otOutGuess, index.assetToScy(netAssetIn));
177
+ return (ptOutGuess, index.assetToScy(netAssetIn));
155
178
  }
156
179
  } else {
157
- approx.guessMax = otOutGuess - 1;
180
+ approx.guessMax = ptOutGuess - 1;
181
+ }
182
+
183
+ unchecked {
184
+ ++iter;
158
185
  }
159
186
  }
160
187
  revert("approx fail");
161
188
  }
162
189
 
163
190
  struct SlotSwapExactScyForYt {
164
- uint256 otInGuess;
191
+ uint256 ptInGuess;
165
192
  int256 _assetToAccount;
166
193
  uint256 netAssetOut;
167
194
  uint256 amountAssetNeedMore;
@@ -197,53 +224,56 @@ library MarketApproxLib {
197
224
  MarketPreCompute memory comp = market.getMarketPreCompute(index, blockTime);
198
225
 
199
226
  if (approx.guessMax == type(uint256).max) {
200
- approx.guessMax = calcMaxOtIn(market.totalOt, comp.totalAsset);
227
+ approx.guessMax = calcMaxPtIn(market.totalPt, comp.totalAsset);
201
228
  }
202
229
 
203
230
  /// ------------------------------------------------------------
204
231
  /// BINARY SEARCH
205
232
  /// ------------------------------------------------------------
206
233
 
207
- while (approx.maxIteration != 0) {
208
- unchecked {
209
- approx.maxIteration--;
210
- }
234
+ for (uint256 iter = 0; iter < approx.maxIteration; ) {
235
+ // iter++ at end of loop
211
236
 
212
237
  SlotSwapExactScyForYt memory slot;
213
- // ytOutGuess = otInGuess
214
- slot.otInGuess = (approx.guessMin + approx.guessMax + 1) / 2;
238
+ // ytOutGuess = ptInGuess
239
+
240
+ slot.ptInGuess = getCurrentGuess(iter, approx);
215
241
 
216
242
  /// ------------------------------------------------------------
217
243
  /// CHECK SLOPE
218
244
  /// ------------------------------------------------------------
219
245
  (isSlopeNonNeg, largestGoodSlope) = updateSlope(
220
- market.totalOt,
221
- slot.otInGuess,
246
+ market.totalPt,
247
+ slot.ptInGuess,
222
248
  comp,
223
249
  largestGoodSlope
224
250
  );
225
251
  if (!isSlopeNonNeg) {
226
- approx.guessMax = slot.otInGuess - 1;
252
+ approx.guessMax = slot.ptInGuess - 1;
227
253
  continue;
228
254
  }
229
255
 
230
256
  /// ------------------------------------------------------------
231
257
  /// CHECK ASSET
232
258
  /// ------------------------------------------------------------
233
- (slot._assetToAccount, ) = market.calcTrade(comp, slot.otInGuess.neg());
259
+ (slot._assetToAccount, ) = market.calcTrade(comp, slot.ptInGuess.neg());
234
260
  slot.netAssetOut = slot._assetToAccount.Uint();
235
- slot.amountAssetNeedMore = slot.otInGuess - slot.netAssetOut;
261
+ slot.amountAssetNeedMore = slot.ptInGuess - slot.netAssetOut;
236
262
 
237
263
  if (slot.amountAssetNeedMore <= maxAssetIn) {
238
- approx.guessMin = slot.otInGuess;
264
+ approx.guessMin = slot.ptInGuess;
239
265
  /// ------------------------------------------------------------
240
266
  /// CHECK IF ANSWER FOUND
241
267
  /// ------------------------------------------------------------
242
268
  if (Math.isASmallerApproxB(slot.amountAssetNeedMore, maxAssetIn, approx.eps)) {
243
- return (slot.otInGuess, index.assetToScy(slot.amountAssetNeedMore));
269
+ return (slot.ptInGuess, index.assetToScy(slot.amountAssetNeedMore));
244
270
  }
245
271
  } else {
246
- approx.guessMax = slot.otInGuess - 1;
272
+ approx.guessMax = slot.ptInGuess - 1;
273
+ }
274
+
275
+ unchecked {
276
+ ++iter;
247
277
  }
248
278
  }
249
279
  revert("approx fail");
@@ -277,106 +307,116 @@ library MarketApproxLib {
277
307
  MarketPreCompute memory comp = market.getMarketPreCompute(index, blockTime);
278
308
 
279
309
  if (approx.guessMax == type(uint256).max) {
280
- approx.guessMax = calcMaxOtOut(market.totalOt, comp);
310
+ approx.guessMax = calcMaxPtOut(market.totalPt, comp);
281
311
  }
282
312
 
283
313
  /// ------------------------------------------------------------
284
314
  /// BINARY SEARCH
285
315
  /// ------------------------------------------------------------
286
316
 
287
- while (approx.maxIteration != 0) {
288
- unchecked {
289
- approx.maxIteration--;
290
- }
291
- // ytInGuess = otOutGuess
292
- uint256 otOutGuess = (approx.guessMin + approx.guessMax) / 2;
317
+ for (uint256 iter = 0; iter < approx.maxIteration; ) {
318
+ // iter++ at end of loop
319
+
320
+ // ytInGuess = ptOutGuess
321
+ uint256 ptOutGuess = getCurrentGuess(iter, approx);
293
322
 
294
323
  /// ------------------------------------------------------------
295
324
  /// CHECK ASSET
296
325
  /// ------------------------------------------------------------
297
- (int256 _assetToAccount, ) = market.calcTrade(comp, otOutGuess.Int());
326
+ (int256 _assetToAccount, ) = market.calcTrade(comp, ptOutGuess.Int());
298
327
  uint256 netAssetOwed = _assetToAccount.neg().Uint();
299
328
 
300
- // since otOutGuess is between guessMin & guessMax, it's guaranteed that
301
- // there are enough Yt to pair with otOut
329
+ // since ptOutGuess is between guessMin & guessMax, it's guaranteed that
330
+ // there are enough Yt to pair with ptOut
302
331
 
303
- uint256 netAssetOut = otOutGuess - netAssetOwed;
332
+ uint256 netAssetOut = ptOutGuess - netAssetOwed;
304
333
 
305
334
  if (netAssetOut >= minAssetOut) {
306
- approx.guessMax = otOutGuess;
335
+ approx.guessMax = ptOutGuess;
307
336
  /// ------------------------------------------------------------
308
337
  /// CHECK IF ANSWER FOUND
309
338
  /// ------------------------------------------------------------
310
339
  if (Math.isAGreaterApproxB(netAssetOut, minAssetOut, approx.eps)) {
311
- return (otOutGuess, index.assetToScy(netAssetOut));
340
+ return (ptOutGuess, index.assetToScy(netAssetOut));
312
341
  }
313
342
  } else {
314
- approx.guessMin = otOutGuess + 1;
343
+ approx.guessMin = ptOutGuess + 1;
344
+ }
345
+
346
+ unchecked {
347
+ ++iter;
315
348
  }
316
349
  }
317
350
  revert("approx fail");
318
351
  }
319
352
 
320
353
  function updateSlope(
321
- int256 totalOt,
322
- uint256 otInGuess,
354
+ int256 totalPt,
355
+ uint256 ptInGuess,
323
356
  MarketPreCompute memory comp,
324
357
  uint256 largestGoodSlope
325
358
  ) internal pure returns (bool isSlopeNonNeg, uint256 newLargestGoodSlop) {
326
- if (otInGuess <= largestGoodSlope) {
359
+ if (ptInGuess <= largestGoodSlope) {
327
360
  return (true, largestGoodSlope);
328
361
  }
329
362
  // it's not guaranteed that the current slop is good
330
363
  // we therefore have to recalculate the slope
331
- int256 slope = slopeFactor(totalOt, otInGuess.neg(), comp);
332
- if (slope >= 0) return (true, otInGuess);
364
+ int256 slope = slopeFactor(totalPt, ptInGuess.neg(), comp);
365
+ if (slope >= 0) return (true, ptInGuess);
333
366
  else return (false, largestGoodSlope);
334
367
  }
335
368
 
336
- // otToMarket < totalAsset && totalOt
369
+ // ptToMarket < totalAsset && totalPt
337
370
  function slopeFactor(
338
- int256 totalOt,
339
- int256 otToAccount,
371
+ int256 totalPt,
372
+ int256 ptToAccount,
340
373
  MarketPreCompute memory comp
341
374
  ) internal pure returns (int256) {
342
- int256 otToMarket = -otToAccount;
343
- int256 diffAssetOtToMarket = comp.totalAsset - otToMarket;
344
- int256 sumOt = otToMarket + totalOt;
375
+ int256 ptToMarket = -ptToAccount;
376
+ int256 diffAssetPtToMarket = comp.totalAsset - ptToMarket;
377
+ int256 sumPt = ptToMarket + totalPt;
345
378
 
346
- require(diffAssetOtToMarket > 0 && sumOt > 0, "invalid otToMarket");
379
+ require(diffAssetPtToMarket > 0 && sumPt > 0, "invalid ptToMarket");
347
380
 
348
- int256 part1 = (otToMarket * (totalOt + comp.totalAsset)).divDown(
349
- sumOt * diffAssetOtToMarket
381
+ int256 part1 = (ptToMarket * (totalPt + comp.totalAsset)).divDown(
382
+ sumPt * diffAssetPtToMarket
350
383
  );
351
384
 
352
- int256 part2 = sumOt.divDown(diffAssetOtToMarket).ln();
385
+ int256 part2 = sumPt.divDown(diffAssetPtToMarket).ln();
353
386
  int256 part3 = Math.IONE.divDown(comp.rateScalar);
354
387
 
355
388
  return comp.rateAnchor - (part1 - part2).mulDown(part3);
356
389
  }
357
390
 
358
- function calcMaxOtOut(int256 totalOt, MarketPreCompute memory comp)
391
+ function calcMaxPtOut(int256 totalPt, MarketPreCompute memory comp)
359
392
  internal
360
393
  pure
361
394
  returns (uint256)
362
395
  {
363
- int256 logitP = (Math.IONE.mulDown(comp.feeRate) - comp.rateAnchor)
396
+ int256 logitP = (Math.IONE.mulDown(comp.lnFeeRate) - comp.rateAnchor)
364
397
  .mulDown(comp.rateScalar)
365
398
  .exp();
366
399
  int256 proportion = logitP.divDown(logitP + Math.IONE);
367
- int256 numerator = proportion.mulDown(totalOt + comp.totalAsset);
368
- int256 maxOtOut = totalOt - numerator;
369
- // TODO: 999 & 1000 are magic numbers
370
- return (maxOtOut.Uint() * 999) / 1000;
400
+ int256 numerator = proportion.mulDown(totalPt + comp.totalAsset);
401
+ int256 maxPtOut = totalPt - numerator;
402
+ // only get 99.9% of the theoretical max to accommodate some precision issues
403
+ return (maxPtOut.Uint() * 999) / 1000;
371
404
  }
372
405
 
373
- function calcMaxOtIn(int256 totalOt, int256 totalAsset) internal pure returns (uint256) {
374
- return Math.min(totalOt, totalAsset).Uint() - 1;
406
+ function calcMaxPtIn(int256 totalPt, int256 totalAsset) internal pure returns (uint256) {
407
+ return Math.min(totalPt, totalAsset).Uint() - 1;
375
408
  }
376
409
 
377
410
  function isValidApproxParams(ApproxParams memory approx) internal pure returns (bool) {
378
- return (approx.guessMin <= approx.guessMax &&
379
- approx.maxIteration <= 256 &&
380
- approx.eps <= Math.ONE);
411
+ return (approx.guessMin <= approx.guessMax && approx.eps <= Math.ONE);
412
+ }
413
+
414
+ function getCurrentGuess(uint256 iteration, ApproxParams memory approx)
415
+ internal
416
+ pure
417
+ returns (uint256)
418
+ {
419
+ if (iteration == 0 && approx.guessOffchain != 0) return approx.guessOffchain;
420
+ else return (approx.guessMin + approx.guessMax) / 2;
381
421
  }
382
422
  }
@@ -15,7 +15,7 @@ library MarketMathAux {
15
15
  MarketState memory market,
16
16
  SCYIndex index,
17
17
  uint256 scyDesired,
18
- uint256 otDesired,
18
+ uint256 ptDesired,
19
19
  bool updateState
20
20
  )
21
21
  internal
@@ -24,7 +24,7 @@ library MarketMathAux {
24
24
  uint256 lpToReserve,
25
25
  uint256 lpToAccount,
26
26
  uint256 scyUsed,
27
- uint256 otUsed
27
+ uint256 ptUsed
28
28
  )
29
29
  {
30
30
  (
@@ -36,42 +36,42 @@ library MarketMathAux {
36
36
  market,
37
37
  index,
38
38
  scyDesired.Int(),
39
- otDesired.Int(),
39
+ ptDesired.Int(),
40
40
  updateState
41
41
  );
42
42
 
43
43
  lpToReserve = _lpToReserve.Uint();
44
44
  lpToAccount = _lpToAccount.Uint();
45
45
  scyUsed = _scyUsed.Uint();
46
- otUsed = _otUsed.Uint();
46
+ ptUsed = _otUsed.Uint();
47
47
  }
48
48
 
49
49
  function removeLiquidity(
50
50
  MarketState memory market,
51
51
  uint256 lpToRemove,
52
52
  bool updateState
53
- ) internal pure returns (uint256 scyToAccount, uint256 netOtToAccount) {
54
- (int256 _scyToAccount, int256 _otToAccount) = MarketMathCore.removeLiquidityCore(
53
+ ) internal pure returns (uint256 scyToAccount, uint256 netPtToAccount) {
54
+ (int256 _scyToAccount, int256 _ptToAccount) = MarketMathCore.removeLiquidityCore(
55
55
  market,
56
56
  lpToRemove.Int(),
57
57
  updateState
58
58
  );
59
59
 
60
60
  scyToAccount = _scyToAccount.Uint();
61
- netOtToAccount = _otToAccount.Uint();
61
+ netPtToAccount = _ptToAccount.Uint();
62
62
  }
63
63
 
64
- function swapExactOtForScy(
64
+ function swapExactPtForScy(
65
65
  MarketState memory market,
66
66
  SCYIndex index,
67
- uint256 exactOtToMarket,
67
+ uint256 exactPtToMarket,
68
68
  uint256 blockTime,
69
69
  bool updateState
70
70
  ) internal pure returns (uint256 netScyToAccount, uint256 netScyToReserve) {
71
71
  (int256 _netScyToAccount, int256 _netScyToReserve) = MarketMathCore.executeTradeCore(
72
72
  market,
73
73
  index,
74
- exactOtToMarket.neg(),
74
+ exactPtToMarket.neg(),
75
75
  blockTime,
76
76
  updateState
77
77
  );
@@ -80,17 +80,17 @@ library MarketMathAux {
80
80
  netScyToReserve = _netScyToReserve.Uint();
81
81
  }
82
82
 
83
- function swapScyForExactOt(
83
+ function swapScyForExactPt(
84
84
  MarketState memory market,
85
85
  SCYIndex index,
86
- uint256 exactOtToAccount,
86
+ uint256 exactPtToAccount,
87
87
  uint256 blockTime,
88
88
  bool updateState
89
89
  ) internal pure returns (uint256 netScyToMarket, uint256 netScyToReserve) {
90
90
  (int256 _netScyToAccount, int256 _netScyToReserve) = MarketMathCore.executeTradeCore(
91
91
  market,
92
92
  index,
93
- exactOtToAccount.Int(),
93
+ exactPtToAccount.Int(),
94
94
  blockTime,
95
95
  updateState
96
96
  );