@@ -23,31 +23,31 @@ import { ADDRESS_ZERO } from '@setprotocol/set-protocol-v2/dist/utils/constants'
23
23
import { TransactionOverrides } from '@setprotocol/set-protocol-v2/dist/typechain' ;
24
24
import { BigNumber } from 'ethers/lib/ethers' ;
25
25
26
- import DebtIssuanceModuleV2Wrapper from '../wrappers/set-protocol-v2/DebtIssuanceModuleV2Wrapper ' ;
26
+ import SlippageIssuanceModuleWrapper from '../wrappers/set-protocol-v2/SlippageIssuanceModuleWrapper ' ;
27
27
import Assertions from '../assertions' ;
28
28
29
29
/**
30
- * @title DebtIssuanceV2API
30
+ * @title SlippageIssuanceAPI
31
31
* @author Set Protocol
32
32
*
33
- * The DebtIssuanceModuleV2API exposes issue and redeem functionality for Sets that contain poitions that accrue
33
+ * The SlippageIssuanceModuleAPI exposes issue and redeem functionality for Sets that contain poitions that accrue
34
34
* interest per block. The getter function syncs the position balance to the current block, so subsequent blocks
35
35
* will cause the position value to be slightly out of sync (a buffer is needed). This API is primarily used for Sets
36
36
* that rely on the ALM contracts to manage debt. The manager can define arbitrary issuance logic
37
37
* in the manager hook, as well as specify issue and redeem fees.
38
38
*
39
39
*/
40
- export default class DebtIssuanceV2API {
41
- private debtIssuanceModuleV2Wrapper : DebtIssuanceModuleV2Wrapper ;
40
+ export default class SlippageIssuanceAPI {
41
+ private slippageIssuanceModuleWrapper : SlippageIssuanceModuleWrapper ;
42
42
private assert : Assertions ;
43
43
44
- public constructor ( provider : Provider , debtIssuanceModuleV2Address : Address , assertions ?: Assertions ) {
45
- this . debtIssuanceModuleV2Wrapper = new DebtIssuanceModuleV2Wrapper ( provider , debtIssuanceModuleV2Address ) ;
44
+ public constructor ( provider : Provider , slippageIssuanceModuleAddress : Address , assertions ?: Assertions ) {
45
+ this . slippageIssuanceModuleWrapper = new SlippageIssuanceModuleWrapper ( provider , slippageIssuanceModuleAddress ) ;
46
46
this . assert = assertions || new Assertions ( ) ;
47
47
}
48
48
49
49
/**
50
- * Initializes the DebtIssuanceModuleV2 to the SetToken. Only callable by the SetToken's manager.
50
+ * Initializes the SlippageIssuanceModule to the SetToken. Only callable by the SetToken's manager.
51
51
*
52
52
* @param setTokenAddress Address of the SetToken to initialize
53
53
* @param maxManagerFee Maximum fee that can be charged on issue and redeem
@@ -73,7 +73,7 @@ export default class DebtIssuanceV2API {
73
73
this . assert . schema . isValidAddress ( 'feeRecipient' , feeRecipient ) ;
74
74
this . assert . schema . isValidAddress ( 'managerIssuanceHook' , managerIssuanceHook ) ;
75
75
76
- return await this . debtIssuanceModuleV2Wrapper . initialize (
76
+ return await this . slippageIssuanceModuleWrapper . initialize (
77
77
setTokenAddress ,
78
78
maxManagerFee ,
79
79
managerIssueFee ,
@@ -90,23 +90,34 @@ export default class DebtIssuanceV2API {
90
90
*
91
91
* @param setTokenAddress Address of the SetToken contract to issue
92
92
* @param quantity Quantity to issue
93
+ * @param checkedComponents Array of components to be checked to verify required collateral doesn't
94
+ * exceed defined max. Each entry must be unique.
95
+ * @param maxTokenAmountsIn Max amount of component willing to transfer in to collateralize quantity
96
+ * amount of setToken.
93
97
* @param setTokenRecipientAddress Address of the recipient of the issued SetToken
94
98
* @param callerAddress Address of caller (optional)
95
99
* @return Transaction hash of the issuance transaction
96
100
*/
97
- public async issueAsync (
101
+ public async issueWithSlippageAsync (
98
102
setTokenAddress : Address ,
99
103
quantity : BigNumber ,
104
+ checkedComponents : Address [ ] ,
105
+ maxTokenAmountsIn : BigNumber [ ] ,
100
106
setTokenRecipientAddress : Address ,
101
107
callerAddress : Address = undefined ,
102
108
txOpts : TransactionOverrides = { }
103
109
) : Promise < ContractTransaction > {
104
110
this . assert . schema . isValidAddress ( 'setAddress' , setTokenAddress ) ;
105
111
this . assert . schema . isValidAddress ( 'setTokenRecipientAddress' , setTokenRecipientAddress ) ;
112
+ this . assert . common . isUniqueList ( checkedComponents , 'checkedComponents List needs to be unique' ) ;
113
+ this . assert . common . isEqualLength ( checkedComponents , maxTokenAmountsIn ,
114
+ 'checkedComponents and maxTokenAmountsIn need to be equal length' ) ;
106
115
107
- return await this . debtIssuanceModuleV2Wrapper . issue (
116
+ return await this . slippageIssuanceModuleWrapper . issueWithSlippage (
108
117
setTokenAddress ,
109
118
quantity ,
119
+ checkedComponents ,
120
+ maxTokenAmountsIn ,
110
121
setTokenRecipientAddress ,
111
122
callerAddress ,
112
123
txOpts
@@ -118,23 +129,34 @@ export default class DebtIssuanceV2API {
118
129
*
119
130
* @param setTokenAddress Address of the SetToken contract
120
131
* @param quantity Quantity to redeem
132
+ * @param checkedComponents Array of components to be checked to verify required collateral doesn't
133
+ * exceed defined max. Each entry must be unique.
134
+ * @param minTokenAmountsOut Min amount of component willing to receive to redeem quantity
135
+ * amount of setToken.
121
136
* @param setTokenRecipientAddress Address of recipient of component tokens from redemption
122
137
* @param callerAddress Address of caller (optional)
123
138
* @return Transaction hash of the redemption transaction
124
139
*/
125
- public async redeemAsync (
140
+ public async redeemWithSlippageAsync (
126
141
setTokenAddress : Address ,
127
142
quantity : BigNumber ,
143
+ checkedComponents : Address [ ] ,
144
+ minTokenAmountsOut : BigNumber [ ] ,
128
145
setTokenRecipientAddress : Address ,
129
146
callerAddress : Address = undefined ,
130
147
txOpts : TransactionOverrides = { }
131
148
) : Promise < ContractTransaction > {
132
149
this . assert . schema . isValidAddress ( 'setAddress' , setTokenAddress ) ;
133
150
this . assert . schema . isValidAddress ( 'setTokenRecipientAddress' , setTokenRecipientAddress ) ;
151
+ this . assert . common . isUniqueList ( checkedComponents , 'checkedComponents List needs to be unique' ) ;
152
+ this . assert . common . isEqualLength ( checkedComponents , minTokenAmountsOut ,
153
+ 'checkedComponents and minTokenAmountsOut need to be equal length' ) ;
134
154
135
- return await this . debtIssuanceModuleV2Wrapper . redeem (
155
+ return await this . slippageIssuanceModuleWrapper . redeemWithSlippage (
136
156
setTokenAddress ,
137
157
quantity ,
158
+ checkedComponents ,
159
+ minTokenAmountsOut ,
138
160
setTokenRecipientAddress ,
139
161
callerAddress ,
140
162
txOpts
@@ -163,7 +185,7 @@ export default class DebtIssuanceV2API {
163
185
) : Promise < ( Address | BigNumber ) [ ] [ ] > {
164
186
this . assert . schema . isValidAddress ( 'setAddress' , setTokenAddress ) ;
165
187
166
- return await this . debtIssuanceModuleV2Wrapper . getRequiredComponentIssuanceUnits (
188
+ return await this . slippageIssuanceModuleWrapper . getRequiredComponentIssuanceUnits (
167
189
setTokenAddress ,
168
190
quantity ,
169
191
callerAddress ,
@@ -191,7 +213,7 @@ export default class DebtIssuanceV2API {
191
213
) : Promise < ( Address | BigNumber ) [ ] [ ] > {
192
214
this . assert . schema . isValidAddress ( 'setAddress' , setTokenAddress ) ;
193
215
194
- return await this . debtIssuanceModuleV2Wrapper . getRequiredComponentRedemptionUnits (
216
+ return await this . slippageIssuanceModuleWrapper . getRequiredComponentRedemptionUnits (
195
217
setTokenAddress ,
196
218
quantity ,
197
219
callerAddress ,
@@ -228,7 +250,7 @@ export default class DebtIssuanceV2API {
228
250
this . assert . schema . isValidAddress ( 'setAddress' , setTokenAddress ) ;
229
251
this . assert . common . isNotUndefined ( isIssue , 'isIssue arg must be a boolean.' ) ;
230
252
231
- return await this . debtIssuanceModuleV2Wrapper . calculateTotalFees (
253
+ return await this . slippageIssuanceModuleWrapper . calculateTotalFees (
232
254
setTokenAddress ,
233
255
quantity ,
234
256
isIssue ,
0 commit comments