@juicedollar/jusd 1.0.3 → 1.0.4

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.
@@ -47,6 +47,12 @@ contract MintingHub is IMintingHub, ERC165 {
47
47
  */
48
48
  mapping(address collateral => mapping(address owner => uint256 amount)) public pendingReturns;
49
49
 
50
+ /**
51
+ * @notice Tracks whether the first position has been created.
52
+ * @dev The first position (genesis) can skip the 3-day init period requirement.
53
+ */
54
+ bool private _genesisPositionCreated;
55
+
50
56
  struct Challenge {
51
57
  address challenger; // the address from which the challenge was initiated
52
58
  uint40 start; // the start of the challenge
@@ -85,7 +91,7 @@ contract MintingHub is IMintingHub, ERC165 {
85
91
  _;
86
92
  }
87
93
 
88
- constructor(address _jusd, address _leadrate, address _roller, address _factory, address _wcbtc) {
94
+ constructor(address _jusd, address _leadrate, address payable _roller, address _factory, address _wcbtc) {
89
95
  JUSD = IJuiceDollar(_jusd);
90
96
  RATE = ILeadrate(_leadrate);
91
97
  POSITION_FACTORY = IPositionFactory(_factory);
@@ -129,7 +135,12 @@ contract MintingHub is IMintingHub, ERC165 {
129
135
  if (CHALLENGER_REWARD > _reservePPM || _reservePPM > 1_000_000) revert InvalidReservePPM();
130
136
  if (IERC20Metadata(_collateralAddress).decimals() > 24) revert InvalidCollateralDecimals(); // leaves 12 digits for price
131
137
  if (_challengeSeconds < 1 days) revert ChallengeTimeTooShort();
132
- if (_initPeriodSeconds < 3 days) revert InitPeriodTooShort();
138
+ // First position (genesis) can skip init period, all others require 3 days minimum
139
+ if (_genesisPositionCreated) {
140
+ if (_initPeriodSeconds < 3 days) revert InitPeriodTooShort();
141
+ } else {
142
+ _genesisPositionCreated = true;
143
+ }
133
144
  uint256 invalidAmount = IERC20(_collateralAddress).totalSupply() + 1;
134
145
  // TODO: Improve for older tokens that revert with assert,
135
146
  // which consumes all gas and makes the entire tx fail (uncatchable)
@@ -8,6 +8,7 @@ import {IMintingHubGateway} from "../gateway/interface/IMintingHubGateway.sol";
8
8
  import {IMintingHub} from "./interface/IMintingHub.sol";
9
9
  import {IPosition} from "./interface/IPosition.sol";
10
10
  import {IReserve} from "../interface/IReserve.sol";
11
+ import {IWrappedNative} from "../interface/IWrappedNative.sol";
11
12
  import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
12
13
 
13
14
  /**
@@ -15,13 +16,19 @@ import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
15
16
  *
16
17
  * Helper to roll over a debt from an old position to a new one.
17
18
  * Both positions should have the same collateral. Otherwise, it does not make much sense.
19
+ *
20
+ * For standard ERC20 positions, use roll/rollFully/rollFullyWithExpiration.
21
+ * Collateral flows through the user's wallet and requires approval.
22
+ *
23
+ * For native coin positions (e.g., WCBTC), use rollNative/rollFullyNative/rollFullyNativeWithExpiration.
24
+ * Collateral flows through the roller, no approval needed, and excess is returned as native coin.
18
25
  */
19
26
  contract PositionRoller {
20
27
  IJuiceDollar private jusd;
21
28
 
22
29
  error NotOwner(address pos);
23
30
  error NotPosition(address pos);
24
- error Log(uint256, uint256, uint256);
31
+ error NativeTransferFailed();
25
32
 
26
33
  event Roll(address source, uint256 collWithdraw, uint256 repay, address target, uint256 collDeposit, uint256 mint);
27
34
 
@@ -32,8 +39,8 @@ contract PositionRoller {
32
39
  /**
33
40
  * Convenience method to roll an old position into a new one.
34
41
  *
35
- * Pre-condition: an allowance for the roller to spend the collateral asset on behalf of the caller,
36
- * i.e., one should set collateral.approve(roller, collateral.balanceOf(sourcePosition)).
42
+ * Pre-condition: an allowance for the roller to spend the collateral asset
43
+ * on behalf of the caller, i.e., collateral.approve(roller, collateral.balanceOf(sourcePosition)).
37
44
  *
38
45
  * The following is assumed:
39
46
  * - If the limit of the target position permits, the user wants to roll everything.
@@ -49,21 +56,12 @@ contract PositionRoller {
49
56
  */
50
57
  function rollFullyWithExpiration(IPosition source, IPosition target, uint40 expiration) public {
51
58
  require(source.collateral() == target.collateral());
52
- uint256 principal = source.principal();
53
- uint256 interest = source.getInterest();
54
- uint256 usableMint = source.getUsableMint(principal) + interest; // Roll interest into principal
55
- uint256 mintAmount = target.getMintAmount(usableMint);
56
- uint256 collateralToWithdraw = IERC20(source.collateral()).balanceOf(address(source));
57
- uint256 targetPrice = target.price();
58
- uint256 depositAmount = (mintAmount * 10 ** 18 + targetPrice - 1) / targetPrice; // round up
59
- if (depositAmount > collateralToWithdraw) {
60
- // If we need more collateral than available from the old position, we opt for taking
61
- // the missing funds from the caller instead of requiring additional collateral.
62
- depositAmount = collateralToWithdraw;
63
- mintAmount = (depositAmount * target.price()) / 10 ** 18; // round down, rest will be taken from caller
64
- }
65
-
66
- roll(source, principal + interest, collateralToWithdraw, target, mintAmount, depositAmount, expiration);
59
+ (uint256 repay, uint256 collWithdraw, uint256 mint, uint256 collDeposit) = _calculateRollParams(
60
+ source,
61
+ target,
62
+ 0
63
+ );
64
+ roll(source, repay, collWithdraw, target, mint, collDeposit, expiration);
67
65
  }
68
66
 
69
67
  /**
@@ -72,12 +70,12 @@ contract PositionRoller {
72
70
  * It is the responsibility of the caller to ensure that both positions are valid contracts.
73
71
  *
74
72
  * @param source The source position, must be owned by the msg.sender.
75
- * @param repay The amount of principal to repay from the source position using a flash loan, freeing up some or all collateral .
76
- * @param collWithdraw Collateral to move from the source position to the msg.sender.
73
+ * @param repay The amount of principal to repay from the source position using a flash loan.
74
+ * @param collWithdraw Collateral to withdraw from the source position.
77
75
  * @param target The target position. If not owned by msg.sender or if it does not have the desired expiration,
78
76
  * it is cloned to create a position owned by the msg.sender.
79
- * @param mint The amount to be minted from the target position using collateral from msg.sender.
80
- * @param collDeposit The amount of collateral to be sent from msg.sender to the target position.
77
+ * @param mint The amount to be minted from the target position.
78
+ * @param collDeposit The amount of collateral to deposit into the target position.
81
79
  * @param expiration The desired expiration date for the target position.
82
80
  */
83
81
  function roll(
@@ -94,9 +92,10 @@ contract PositionRoller {
94
92
  source.withdrawCollateral(msg.sender, collWithdraw);
95
93
  if (mint > 0) {
96
94
  IERC20 targetCollateral = IERC20(target.collateral());
97
- if (Ownable(address(target)).owner() != msg.sender || expiration != target.expiration()) {
98
- targetCollateral.transferFrom(msg.sender, address(this), collDeposit); // get the new collateral
99
- targetCollateral.approve(target.hub(), collDeposit); // approve the new collateral and clone:
95
+ bool needsClone = Ownable(address(target)).owner() != msg.sender || expiration != target.expiration();
96
+ if (needsClone) {
97
+ targetCollateral.transferFrom(msg.sender, address(this), collDeposit);
98
+ targetCollateral.approve(target.hub(), collDeposit);
100
99
  target = _cloneTargetPosition(target, source, collDeposit, mint, expiration);
101
100
  } else {
102
101
  // We can roll into the provided existing position.
@@ -116,10 +115,125 @@ contract PositionRoller {
116
115
  emit Roll(address(source), collWithdraw, repay, address(target), collDeposit, mint);
117
116
  }
118
117
 
118
+ /**
119
+ * Convenience method to roll a native coin position into a new one.
120
+ *
121
+ * No collateral approval is needed - collateral flows through the roller
122
+ * and excess is returned as native coin.
123
+ *
124
+ * Additional collateral can be provided via msg.value.
125
+ */
126
+ function rollFullyNative(IPosition source, IPosition target) external payable {
127
+ rollFullyNativeWithExpiration(source, target, target.expiration());
128
+ }
129
+
130
+ /**
131
+ * Like rollFullyNative, but with a custom expiration date for the new position.
132
+ */
133
+ function rollFullyNativeWithExpiration(IPosition source, IPosition target, uint40 expiration) public payable {
134
+ require(source.collateral() == target.collateral());
135
+ (uint256 repay, uint256 collWithdraw, uint256 mint, uint256 collDeposit) = _calculateRollParams(
136
+ source,
137
+ target,
138
+ msg.value
139
+ );
140
+ rollNative(source, repay, collWithdraw, target, mint, collDeposit, expiration);
141
+ }
142
+
143
+ /**
144
+ * Rolls a native coin position into the target position using a flash loan.
145
+ * Collateral is routed through the roller and returned as native coin,
146
+ * eliminating the need for users to interact with wrapped native tokens directly.
147
+ *
148
+ * If additional collateral is needed (collDeposit > collWithdraw), it can be provided
149
+ * as native coin via msg.value.
150
+ *
151
+ * @param source The source position, must be owned by the msg.sender.
152
+ * @param repay The amount of principal to repay from the source position using a flash loan.
153
+ * @param collWithdraw Collateral to withdraw from the source position.
154
+ * @param target The target position. If not owned by msg.sender or if it does not have the desired expiration,
155
+ * it is cloned to create a position owned by the msg.sender.
156
+ * @param mint The amount to be minted from the target position.
157
+ * @param collDeposit The amount of collateral to deposit into the target position.
158
+ * @param expiration The desired expiration date for the target position.
159
+ */
160
+ function rollNative(
161
+ IPosition source,
162
+ uint256 repay,
163
+ uint256 collWithdraw,
164
+ IPosition target,
165
+ uint256 mint,
166
+ uint256 collDeposit,
167
+ uint40 expiration
168
+ ) public payable valid(source) valid(target) own(source) {
169
+ address collateral = address(source.collateral());
170
+
171
+ jusd.mint(address(this), repay); // take a flash loan
172
+ uint256 used = source.repay(repay);
173
+ source.withdrawCollateral(address(this), collWithdraw);
174
+ if (msg.value > 0) {
175
+ IWrappedNative(collateral).deposit{value: msg.value}();
176
+ }
177
+
178
+ if (mint > 0) {
179
+ IERC20 targetCollateral = IERC20(collateral);
180
+ bool needsClone = Ownable(address(target)).owner() != msg.sender || expiration != target.expiration();
181
+ if (needsClone) {
182
+ targetCollateral.approve(target.hub(), collDeposit);
183
+ target = _cloneTargetPosition(target, source, collDeposit, mint, expiration);
184
+ } else {
185
+ targetCollateral.transfer(address(target), collDeposit);
186
+ target.mint(msg.sender, mint);
187
+ }
188
+ }
189
+
190
+ // Transfer remaining flash loan to caller for repayment
191
+ if (repay > used) {
192
+ jusd.transfer(msg.sender, repay - used);
193
+ }
194
+ jusd.burnFrom(msg.sender, repay); // repay the flash loan
195
+
196
+ // Return excess as native coin
197
+ uint256 remaining = IERC20(collateral).balanceOf(address(this));
198
+ if (remaining > 0) {
199
+ IWrappedNative(collateral).withdraw(remaining);
200
+ (bool success, ) = msg.sender.call{value: remaining}("");
201
+ if (!success) revert NativeTransferFailed();
202
+ }
203
+
204
+ emit Roll(address(source), collWithdraw, repay, address(target), collDeposit, mint);
205
+ }
206
+
207
+ /**
208
+ * Calculates the parameters for a roll operation.
209
+ * @param extraCollateral Additional collateral provided via msg.value (for native rolls).
210
+ */
211
+ function _calculateRollParams(
212
+ IPosition source,
213
+ IPosition target,
214
+ uint256 extraCollateral
215
+ ) internal view returns (uint256 repay, uint256 collWithdraw, uint256 mint, uint256 collDeposit) {
216
+ uint256 principal = source.principal();
217
+ uint256 interest = source.getInterest();
218
+ uint256 usableMint = source.getUsableMint(principal) + interest;
219
+ uint256 mintAmount = target.getMintAmount(usableMint);
220
+ uint256 collateralAvailable = IERC20(source.collateral()).balanceOf(address(source));
221
+ uint256 totalAvailable = collateralAvailable + extraCollateral;
222
+ uint256 targetPrice = target.price();
223
+ uint256 depositAmount = (mintAmount * 10 ** 18 + targetPrice - 1) / targetPrice;
224
+
225
+ if (depositAmount > totalAvailable) {
226
+ depositAmount = totalAvailable;
227
+ mintAmount = (depositAmount * target.price()) / 10 ** 18;
228
+ }
229
+
230
+ return (principal + interest, collateralAvailable, mintAmount, depositAmount);
231
+ }
232
+
119
233
  /**
120
234
  * Clones the target position and mints the specified amount using the given collateral.
121
235
  */
122
- function _cloneTargetPosition (
236
+ function _cloneTargetPosition(
123
237
  IPosition target,
124
238
  IPosition source,
125
239
  uint256 collDeposit,
@@ -127,24 +241,24 @@ contract PositionRoller {
127
241
  uint40 expiration
128
242
  ) internal returns (IPosition) {
129
243
  if (IERC165(target.hub()).supportsInterface(type(IMintingHubGateway).interfaceId)) {
130
- bytes32 frontendCode = IMintingHubGateway(target.hub()).GATEWAY().getPositionFrontendCode(
131
- address(source)
132
- );
133
- return IPosition(
134
- IMintingHubGateway(target.hub()).clone(
135
- msg.sender,
136
- address(target),
137
- collDeposit,
138
- mint,
139
- expiration,
140
- 0, // inherit price from parent
141
- frontendCode // use the same frontend code
142
- )
143
- );
244
+ bytes32 frontendCode = IMintingHubGateway(target.hub()).GATEWAY().getPositionFrontendCode(address(source));
245
+ return
246
+ IPosition(
247
+ IMintingHubGateway(target.hub()).clone(
248
+ msg.sender,
249
+ address(target),
250
+ collDeposit,
251
+ mint,
252
+ expiration,
253
+ 0, // inherit price from parent
254
+ frontendCode // use the same frontend code
255
+ )
256
+ );
144
257
  } else {
145
- return IPosition(
146
- IMintingHub(target.hub()).clone(msg.sender, address(target), collDeposit, mint, expiration, 0)
147
- );
258
+ return
259
+ IPosition(
260
+ IMintingHub(target.hub()).clone(msg.sender, address(target), collDeposit, mint, expiration, 0)
261
+ );
148
262
  }
149
263
  }
150
264
 
@@ -157,4 +271,7 @@ contract PositionRoller {
157
271
  if (jusd.getPositionParent(address(pos)) == address(0x0)) revert NotPosition(address(pos));
158
272
  _;
159
273
  }
274
+
275
+ /// @notice Required to receive native coin when unwrapping
276
+ receive() external payable {}
160
277
  }
@@ -10,6 +10,8 @@ interface IMintingHub {
10
10
 
11
11
  function ROLLER() external view returns (PositionRoller);
12
12
 
13
+ function WCBTC() external view returns (address);
14
+
13
15
  function challenge(
14
16
  address _positionAddr,
15
17
  uint256 _collateralAmount,
@@ -11,7 +11,7 @@ contract MintingHubGateway is MintingHub, IMintingHubGateway {
11
11
  constructor(
12
12
  address _jusd,
13
13
  address _leadrate,
14
- address _roller,
14
+ address payable _roller,
15
15
  address _factory,
16
16
  address _gateway,
17
17
  address _wcbtc
package/dist/index.d.mts CHANGED
@@ -2765,7 +2765,7 @@ declare const MintingHubGatewayABI: readonly [{
2765
2765
  readonly name: "_leadrate";
2766
2766
  readonly type: "address";
2767
2767
  }, {
2768
- readonly internalType: "address";
2768
+ readonly internalType: "address payable";
2769
2769
  readonly name: "_roller";
2770
2770
  readonly type: "address";
2771
2771
  }, {
@@ -4609,20 +4609,8 @@ declare const PositionRollerABI: readonly [{
4609
4609
  readonly stateMutability: "nonpayable";
4610
4610
  readonly type: "constructor";
4611
4611
  }, {
4612
- readonly inputs: readonly [{
4613
- readonly internalType: "uint256";
4614
- readonly name: "";
4615
- readonly type: "uint256";
4616
- }, {
4617
- readonly internalType: "uint256";
4618
- readonly name: "";
4619
- readonly type: "uint256";
4620
- }, {
4621
- readonly internalType: "uint256";
4622
- readonly name: "";
4623
- readonly type: "uint256";
4624
- }];
4625
- readonly name: "Log";
4612
+ readonly inputs: readonly [];
4613
+ readonly name: "NativeTransferFailed";
4626
4614
  readonly type: "error";
4627
4615
  }, {
4628
4616
  readonly inputs: readonly [{
@@ -4723,6 +4711,38 @@ declare const PositionRollerABI: readonly [{
4723
4711
  readonly outputs: readonly [];
4724
4712
  readonly stateMutability: "nonpayable";
4725
4713
  readonly type: "function";
4714
+ }, {
4715
+ readonly inputs: readonly [{
4716
+ readonly internalType: "contract IPosition";
4717
+ readonly name: "source";
4718
+ readonly type: "address";
4719
+ }, {
4720
+ readonly internalType: "contract IPosition";
4721
+ readonly name: "target";
4722
+ readonly type: "address";
4723
+ }];
4724
+ readonly name: "rollFullyNative";
4725
+ readonly outputs: readonly [];
4726
+ readonly stateMutability: "payable";
4727
+ readonly type: "function";
4728
+ }, {
4729
+ readonly inputs: readonly [{
4730
+ readonly internalType: "contract IPosition";
4731
+ readonly name: "source";
4732
+ readonly type: "address";
4733
+ }, {
4734
+ readonly internalType: "contract IPosition";
4735
+ readonly name: "target";
4736
+ readonly type: "address";
4737
+ }, {
4738
+ readonly internalType: "uint40";
4739
+ readonly name: "expiration";
4740
+ readonly type: "uint40";
4741
+ }];
4742
+ readonly name: "rollFullyNativeWithExpiration";
4743
+ readonly outputs: readonly [];
4744
+ readonly stateMutability: "payable";
4745
+ readonly type: "function";
4726
4746
  }, {
4727
4747
  readonly inputs: readonly [{
4728
4748
  readonly internalType: "contract IPosition";
@@ -4741,6 +4761,43 @@ declare const PositionRollerABI: readonly [{
4741
4761
  readonly outputs: readonly [];
4742
4762
  readonly stateMutability: "nonpayable";
4743
4763
  readonly type: "function";
4764
+ }, {
4765
+ readonly inputs: readonly [{
4766
+ readonly internalType: "contract IPosition";
4767
+ readonly name: "source";
4768
+ readonly type: "address";
4769
+ }, {
4770
+ readonly internalType: "uint256";
4771
+ readonly name: "repay";
4772
+ readonly type: "uint256";
4773
+ }, {
4774
+ readonly internalType: "uint256";
4775
+ readonly name: "collWithdraw";
4776
+ readonly type: "uint256";
4777
+ }, {
4778
+ readonly internalType: "contract IPosition";
4779
+ readonly name: "target";
4780
+ readonly type: "address";
4781
+ }, {
4782
+ readonly internalType: "uint256";
4783
+ readonly name: "mint";
4784
+ readonly type: "uint256";
4785
+ }, {
4786
+ readonly internalType: "uint256";
4787
+ readonly name: "collDeposit";
4788
+ readonly type: "uint256";
4789
+ }, {
4790
+ readonly internalType: "uint40";
4791
+ readonly name: "expiration";
4792
+ readonly type: "uint40";
4793
+ }];
4794
+ readonly name: "rollNative";
4795
+ readonly outputs: readonly [];
4796
+ readonly stateMutability: "payable";
4797
+ readonly type: "function";
4798
+ }, {
4799
+ readonly stateMutability: "payable";
4800
+ readonly type: "receive";
4744
4801
  }];
4745
4802
 
4746
4803
  declare const PositionV2ABI: readonly [{
@@ -7619,7 +7676,7 @@ declare const MintingHubV2ABI: readonly [{
7619
7676
  readonly name: "_leadrate";
7620
7677
  readonly type: "address";
7621
7678
  }, {
7622
- readonly internalType: "address";
7679
+ readonly internalType: "address payable";
7623
7680
  readonly name: "_roller";
7624
7681
  readonly type: "address";
7625
7682
  }, {
package/dist/index.d.ts CHANGED
@@ -2765,7 +2765,7 @@ declare const MintingHubGatewayABI: readonly [{
2765
2765
  readonly name: "_leadrate";
2766
2766
  readonly type: "address";
2767
2767
  }, {
2768
- readonly internalType: "address";
2768
+ readonly internalType: "address payable";
2769
2769
  readonly name: "_roller";
2770
2770
  readonly type: "address";
2771
2771
  }, {
@@ -4609,20 +4609,8 @@ declare const PositionRollerABI: readonly [{
4609
4609
  readonly stateMutability: "nonpayable";
4610
4610
  readonly type: "constructor";
4611
4611
  }, {
4612
- readonly inputs: readonly [{
4613
- readonly internalType: "uint256";
4614
- readonly name: "";
4615
- readonly type: "uint256";
4616
- }, {
4617
- readonly internalType: "uint256";
4618
- readonly name: "";
4619
- readonly type: "uint256";
4620
- }, {
4621
- readonly internalType: "uint256";
4622
- readonly name: "";
4623
- readonly type: "uint256";
4624
- }];
4625
- readonly name: "Log";
4612
+ readonly inputs: readonly [];
4613
+ readonly name: "NativeTransferFailed";
4626
4614
  readonly type: "error";
4627
4615
  }, {
4628
4616
  readonly inputs: readonly [{
@@ -4723,6 +4711,38 @@ declare const PositionRollerABI: readonly [{
4723
4711
  readonly outputs: readonly [];
4724
4712
  readonly stateMutability: "nonpayable";
4725
4713
  readonly type: "function";
4714
+ }, {
4715
+ readonly inputs: readonly [{
4716
+ readonly internalType: "contract IPosition";
4717
+ readonly name: "source";
4718
+ readonly type: "address";
4719
+ }, {
4720
+ readonly internalType: "contract IPosition";
4721
+ readonly name: "target";
4722
+ readonly type: "address";
4723
+ }];
4724
+ readonly name: "rollFullyNative";
4725
+ readonly outputs: readonly [];
4726
+ readonly stateMutability: "payable";
4727
+ readonly type: "function";
4728
+ }, {
4729
+ readonly inputs: readonly [{
4730
+ readonly internalType: "contract IPosition";
4731
+ readonly name: "source";
4732
+ readonly type: "address";
4733
+ }, {
4734
+ readonly internalType: "contract IPosition";
4735
+ readonly name: "target";
4736
+ readonly type: "address";
4737
+ }, {
4738
+ readonly internalType: "uint40";
4739
+ readonly name: "expiration";
4740
+ readonly type: "uint40";
4741
+ }];
4742
+ readonly name: "rollFullyNativeWithExpiration";
4743
+ readonly outputs: readonly [];
4744
+ readonly stateMutability: "payable";
4745
+ readonly type: "function";
4726
4746
  }, {
4727
4747
  readonly inputs: readonly [{
4728
4748
  readonly internalType: "contract IPosition";
@@ -4741,6 +4761,43 @@ declare const PositionRollerABI: readonly [{
4741
4761
  readonly outputs: readonly [];
4742
4762
  readonly stateMutability: "nonpayable";
4743
4763
  readonly type: "function";
4764
+ }, {
4765
+ readonly inputs: readonly [{
4766
+ readonly internalType: "contract IPosition";
4767
+ readonly name: "source";
4768
+ readonly type: "address";
4769
+ }, {
4770
+ readonly internalType: "uint256";
4771
+ readonly name: "repay";
4772
+ readonly type: "uint256";
4773
+ }, {
4774
+ readonly internalType: "uint256";
4775
+ readonly name: "collWithdraw";
4776
+ readonly type: "uint256";
4777
+ }, {
4778
+ readonly internalType: "contract IPosition";
4779
+ readonly name: "target";
4780
+ readonly type: "address";
4781
+ }, {
4782
+ readonly internalType: "uint256";
4783
+ readonly name: "mint";
4784
+ readonly type: "uint256";
4785
+ }, {
4786
+ readonly internalType: "uint256";
4787
+ readonly name: "collDeposit";
4788
+ readonly type: "uint256";
4789
+ }, {
4790
+ readonly internalType: "uint40";
4791
+ readonly name: "expiration";
4792
+ readonly type: "uint40";
4793
+ }];
4794
+ readonly name: "rollNative";
4795
+ readonly outputs: readonly [];
4796
+ readonly stateMutability: "payable";
4797
+ readonly type: "function";
4798
+ }, {
4799
+ readonly stateMutability: "payable";
4800
+ readonly type: "receive";
4744
4801
  }];
4745
4802
 
4746
4803
  declare const PositionV2ABI: readonly [{
@@ -7619,7 +7676,7 @@ declare const MintingHubV2ABI: readonly [{
7619
7676
  readonly name: "_leadrate";
7620
7677
  readonly type: "address";
7621
7678
  }, {
7622
- readonly internalType: "address";
7679
+ readonly internalType: "address payable";
7623
7680
  readonly name: "_roller";
7624
7681
  readonly type: "address";
7625
7682
  }, {
package/dist/index.js CHANGED
@@ -59,16 +59,16 @@ var ADDRESS = {
59
59
  positionFactoryV2: import_viem.zeroAddress
60
60
  },
61
61
  5115: {
62
- juiceDollar: "0x0D511a9C1662924dd8f9c12D2Bd72B0264E48583",
63
- equity: "0x8FF9be291A44CA3E7b45361bf6bbE1aCd0135c06",
64
- frontendGateway: "0x6721aC661e52C6BA092debb6cc33Ee58F1a4D10A",
65
- savingsGateway: "0xC638D446072416Aa1760A73748D291Af9f3925cB",
66
- savingsVaultJUSD: "0x4bD31350f611b469bA7fCC2c5945aAEBefD7A191",
67
- mintingHubGateway: "0x44B0727688F1839c2BF7b74686F04Cba0CfE89D6",
68
- bridgeStartUSD: "0x8d149f42C8F73F9fC90e2CbED8eE0644e8837623",
69
- startUSD: "0xf65BF14763699C08F9ff11e9Dc6706DdEB69b5b9",
70
- roller: "0xD09CeBBac7cA43430A505CA7A78123D83d53Af39",
71
- positionFactoryV2: "0xD6673d8Fc25094579Ae23802957e9084860F5d1a"
62
+ juiceDollar: "0x2742bb39221434bbfcac81959C8367fDE5d83ce9",
63
+ equity: "0xD6B9d4600C45eC4388e45A474C1C153828B7C018",
64
+ frontendGateway: "0x52C2d93DAC83Da412D93D035b017486DecCE782A",
65
+ savingsGateway: "0x2e1697e7BaA6CE62B0c36B015B7a5BEC6157B99e",
66
+ savingsVaultJUSD: "0x45DA5a722b591bBce0b87B192d846AB85EFA88d3",
67
+ mintingHubGateway: "0x57c4aB0f9480AC52a58C820a58ad802B0D4c23EB",
68
+ bridgeStartUSD: "0x8c5e5594c05205454BC09487ad53db4e4DB6564D",
69
+ startUSD: "0xa37f823Bd1bae4379265A4fF9cD5a68f402dE2f5",
70
+ roller: "0xB9B5f670A19E345fFb82D91e699a3f917E237f55",
71
+ positionFactoryV2: "0x70dDC84C79B724b247C10BB9a11Bd98c08Ee3C1a"
72
72
  }
73
73
  };
74
74
 
@@ -3651,7 +3651,7 @@ var MintingHubGatewayABI = [
3651
3651
  type: "address"
3652
3652
  },
3653
3653
  {
3654
- internalType: "address",
3654
+ internalType: "address payable",
3655
3655
  name: "_roller",
3656
3656
  type: "address"
3657
3657
  },
@@ -6057,24 +6057,8 @@ var PositionRollerABI = [
6057
6057
  type: "constructor"
6058
6058
  },
6059
6059
  {
6060
- inputs: [
6061
- {
6062
- internalType: "uint256",
6063
- name: "",
6064
- type: "uint256"
6065
- },
6066
- {
6067
- internalType: "uint256",
6068
- name: "",
6069
- type: "uint256"
6070
- },
6071
- {
6072
- internalType: "uint256",
6073
- name: "",
6074
- type: "uint256"
6075
- }
6076
- ],
6077
- name: "Log",
6060
+ inputs: [],
6061
+ name: "NativeTransferFailed",
6078
6062
  type: "error"
6079
6063
  },
6080
6064
  {
@@ -6203,6 +6187,47 @@ var PositionRollerABI = [
6203
6187
  stateMutability: "nonpayable",
6204
6188
  type: "function"
6205
6189
  },
6190
+ {
6191
+ inputs: [
6192
+ {
6193
+ internalType: "contract IPosition",
6194
+ name: "source",
6195
+ type: "address"
6196
+ },
6197
+ {
6198
+ internalType: "contract IPosition",
6199
+ name: "target",
6200
+ type: "address"
6201
+ }
6202
+ ],
6203
+ name: "rollFullyNative",
6204
+ outputs: [],
6205
+ stateMutability: "payable",
6206
+ type: "function"
6207
+ },
6208
+ {
6209
+ inputs: [
6210
+ {
6211
+ internalType: "contract IPosition",
6212
+ name: "source",
6213
+ type: "address"
6214
+ },
6215
+ {
6216
+ internalType: "contract IPosition",
6217
+ name: "target",
6218
+ type: "address"
6219
+ },
6220
+ {
6221
+ internalType: "uint40",
6222
+ name: "expiration",
6223
+ type: "uint40"
6224
+ }
6225
+ ],
6226
+ name: "rollFullyNativeWithExpiration",
6227
+ outputs: [],
6228
+ stateMutability: "payable",
6229
+ type: "function"
6230
+ },
6206
6231
  {
6207
6232
  inputs: [
6208
6233
  {
@@ -6225,6 +6250,53 @@ var PositionRollerABI = [
6225
6250
  outputs: [],
6226
6251
  stateMutability: "nonpayable",
6227
6252
  type: "function"
6253
+ },
6254
+ {
6255
+ inputs: [
6256
+ {
6257
+ internalType: "contract IPosition",
6258
+ name: "source",
6259
+ type: "address"
6260
+ },
6261
+ {
6262
+ internalType: "uint256",
6263
+ name: "repay",
6264
+ type: "uint256"
6265
+ },
6266
+ {
6267
+ internalType: "uint256",
6268
+ name: "collWithdraw",
6269
+ type: "uint256"
6270
+ },
6271
+ {
6272
+ internalType: "contract IPosition",
6273
+ name: "target",
6274
+ type: "address"
6275
+ },
6276
+ {
6277
+ internalType: "uint256",
6278
+ name: "mint",
6279
+ type: "uint256"
6280
+ },
6281
+ {
6282
+ internalType: "uint256",
6283
+ name: "collDeposit",
6284
+ type: "uint256"
6285
+ },
6286
+ {
6287
+ internalType: "uint40",
6288
+ name: "expiration",
6289
+ type: "uint40"
6290
+ }
6291
+ ],
6292
+ name: "rollNative",
6293
+ outputs: [],
6294
+ stateMutability: "payable",
6295
+ type: "function"
6296
+ },
6297
+ {
6298
+ stateMutability: "payable",
6299
+ type: "receive"
6228
6300
  }
6229
6301
  ];
6230
6302
 
@@ -9618,7 +9690,7 @@ var MintingHubV2ABI = [
9618
9690
  type: "address"
9619
9691
  },
9620
9692
  {
9621
- internalType: "address",
9693
+ internalType: "address payable",
9622
9694
  name: "_roller",
9623
9695
  type: "address"
9624
9696
  },
package/dist/index.mjs CHANGED
@@ -15,16 +15,16 @@ var ADDRESS = {
15
15
  positionFactoryV2: zeroAddress
16
16
  },
17
17
  5115: {
18
- juiceDollar: "0x0D511a9C1662924dd8f9c12D2Bd72B0264E48583",
19
- equity: "0x8FF9be291A44CA3E7b45361bf6bbE1aCd0135c06",
20
- frontendGateway: "0x6721aC661e52C6BA092debb6cc33Ee58F1a4D10A",
21
- savingsGateway: "0xC638D446072416Aa1760A73748D291Af9f3925cB",
22
- savingsVaultJUSD: "0x4bD31350f611b469bA7fCC2c5945aAEBefD7A191",
23
- mintingHubGateway: "0x44B0727688F1839c2BF7b74686F04Cba0CfE89D6",
24
- bridgeStartUSD: "0x8d149f42C8F73F9fC90e2CbED8eE0644e8837623",
25
- startUSD: "0xf65BF14763699C08F9ff11e9Dc6706DdEB69b5b9",
26
- roller: "0xD09CeBBac7cA43430A505CA7A78123D83d53Af39",
27
- positionFactoryV2: "0xD6673d8Fc25094579Ae23802957e9084860F5d1a"
18
+ juiceDollar: "0x2742bb39221434bbfcac81959C8367fDE5d83ce9",
19
+ equity: "0xD6B9d4600C45eC4388e45A474C1C153828B7C018",
20
+ frontendGateway: "0x52C2d93DAC83Da412D93D035b017486DecCE782A",
21
+ savingsGateway: "0x2e1697e7BaA6CE62B0c36B015B7a5BEC6157B99e",
22
+ savingsVaultJUSD: "0x45DA5a722b591bBce0b87B192d846AB85EFA88d3",
23
+ mintingHubGateway: "0x57c4aB0f9480AC52a58C820a58ad802B0D4c23EB",
24
+ bridgeStartUSD: "0x8c5e5594c05205454BC09487ad53db4e4DB6564D",
25
+ startUSD: "0xa37f823Bd1bae4379265A4fF9cD5a68f402dE2f5",
26
+ roller: "0xB9B5f670A19E345fFb82D91e699a3f917E237f55",
27
+ positionFactoryV2: "0x70dDC84C79B724b247C10BB9a11Bd98c08Ee3C1a"
28
28
  }
29
29
  };
30
30
 
@@ -3607,7 +3607,7 @@ var MintingHubGatewayABI = [
3607
3607
  type: "address"
3608
3608
  },
3609
3609
  {
3610
- internalType: "address",
3610
+ internalType: "address payable",
3611
3611
  name: "_roller",
3612
3612
  type: "address"
3613
3613
  },
@@ -6013,24 +6013,8 @@ var PositionRollerABI = [
6013
6013
  type: "constructor"
6014
6014
  },
6015
6015
  {
6016
- inputs: [
6017
- {
6018
- internalType: "uint256",
6019
- name: "",
6020
- type: "uint256"
6021
- },
6022
- {
6023
- internalType: "uint256",
6024
- name: "",
6025
- type: "uint256"
6026
- },
6027
- {
6028
- internalType: "uint256",
6029
- name: "",
6030
- type: "uint256"
6031
- }
6032
- ],
6033
- name: "Log",
6016
+ inputs: [],
6017
+ name: "NativeTransferFailed",
6034
6018
  type: "error"
6035
6019
  },
6036
6020
  {
@@ -6159,6 +6143,47 @@ var PositionRollerABI = [
6159
6143
  stateMutability: "nonpayable",
6160
6144
  type: "function"
6161
6145
  },
6146
+ {
6147
+ inputs: [
6148
+ {
6149
+ internalType: "contract IPosition",
6150
+ name: "source",
6151
+ type: "address"
6152
+ },
6153
+ {
6154
+ internalType: "contract IPosition",
6155
+ name: "target",
6156
+ type: "address"
6157
+ }
6158
+ ],
6159
+ name: "rollFullyNative",
6160
+ outputs: [],
6161
+ stateMutability: "payable",
6162
+ type: "function"
6163
+ },
6164
+ {
6165
+ inputs: [
6166
+ {
6167
+ internalType: "contract IPosition",
6168
+ name: "source",
6169
+ type: "address"
6170
+ },
6171
+ {
6172
+ internalType: "contract IPosition",
6173
+ name: "target",
6174
+ type: "address"
6175
+ },
6176
+ {
6177
+ internalType: "uint40",
6178
+ name: "expiration",
6179
+ type: "uint40"
6180
+ }
6181
+ ],
6182
+ name: "rollFullyNativeWithExpiration",
6183
+ outputs: [],
6184
+ stateMutability: "payable",
6185
+ type: "function"
6186
+ },
6162
6187
  {
6163
6188
  inputs: [
6164
6189
  {
@@ -6181,6 +6206,53 @@ var PositionRollerABI = [
6181
6206
  outputs: [],
6182
6207
  stateMutability: "nonpayable",
6183
6208
  type: "function"
6209
+ },
6210
+ {
6211
+ inputs: [
6212
+ {
6213
+ internalType: "contract IPosition",
6214
+ name: "source",
6215
+ type: "address"
6216
+ },
6217
+ {
6218
+ internalType: "uint256",
6219
+ name: "repay",
6220
+ type: "uint256"
6221
+ },
6222
+ {
6223
+ internalType: "uint256",
6224
+ name: "collWithdraw",
6225
+ type: "uint256"
6226
+ },
6227
+ {
6228
+ internalType: "contract IPosition",
6229
+ name: "target",
6230
+ type: "address"
6231
+ },
6232
+ {
6233
+ internalType: "uint256",
6234
+ name: "mint",
6235
+ type: "uint256"
6236
+ },
6237
+ {
6238
+ internalType: "uint256",
6239
+ name: "collDeposit",
6240
+ type: "uint256"
6241
+ },
6242
+ {
6243
+ internalType: "uint40",
6244
+ name: "expiration",
6245
+ type: "uint40"
6246
+ }
6247
+ ],
6248
+ name: "rollNative",
6249
+ outputs: [],
6250
+ stateMutability: "payable",
6251
+ type: "function"
6252
+ },
6253
+ {
6254
+ stateMutability: "payable",
6255
+ type: "receive"
6184
6256
  }
6185
6257
  ];
6186
6258
 
@@ -9574,7 +9646,7 @@ var MintingHubV2ABI = [
9574
9646
  type: "address"
9575
9647
  },
9576
9648
  {
9577
- internalType: "address",
9649
+ internalType: "address payable",
9578
9650
  name: "_roller",
9579
9651
  type: "address"
9580
9652
  },
@@ -11,24 +11,8 @@ export const PositionRollerABI = [
11
11
  type: 'constructor',
12
12
  },
13
13
  {
14
- inputs: [
15
- {
16
- internalType: 'uint256',
17
- name: '',
18
- type: 'uint256',
19
- },
20
- {
21
- internalType: 'uint256',
22
- name: '',
23
- type: 'uint256',
24
- },
25
- {
26
- internalType: 'uint256',
27
- name: '',
28
- type: 'uint256',
29
- },
30
- ],
31
- name: 'Log',
14
+ inputs: [],
15
+ name: 'NativeTransferFailed',
32
16
  type: 'error',
33
17
  },
34
18
  {
@@ -157,6 +141,47 @@ export const PositionRollerABI = [
157
141
  stateMutability: 'nonpayable',
158
142
  type: 'function',
159
143
  },
144
+ {
145
+ inputs: [
146
+ {
147
+ internalType: 'contract IPosition',
148
+ name: 'source',
149
+ type: 'address',
150
+ },
151
+ {
152
+ internalType: 'contract IPosition',
153
+ name: 'target',
154
+ type: 'address',
155
+ },
156
+ ],
157
+ name: 'rollFullyNative',
158
+ outputs: [],
159
+ stateMutability: 'payable',
160
+ type: 'function',
161
+ },
162
+ {
163
+ inputs: [
164
+ {
165
+ internalType: 'contract IPosition',
166
+ name: 'source',
167
+ type: 'address',
168
+ },
169
+ {
170
+ internalType: 'contract IPosition',
171
+ name: 'target',
172
+ type: 'address',
173
+ },
174
+ {
175
+ internalType: 'uint40',
176
+ name: 'expiration',
177
+ type: 'uint40',
178
+ },
179
+ ],
180
+ name: 'rollFullyNativeWithExpiration',
181
+ outputs: [],
182
+ stateMutability: 'payable',
183
+ type: 'function',
184
+ },
160
185
  {
161
186
  inputs: [
162
187
  {
@@ -180,4 +205,51 @@ export const PositionRollerABI = [
180
205
  stateMutability: 'nonpayable',
181
206
  type: 'function',
182
207
  },
208
+ {
209
+ inputs: [
210
+ {
211
+ internalType: 'contract IPosition',
212
+ name: 'source',
213
+ type: 'address',
214
+ },
215
+ {
216
+ internalType: 'uint256',
217
+ name: 'repay',
218
+ type: 'uint256',
219
+ },
220
+ {
221
+ internalType: 'uint256',
222
+ name: 'collWithdraw',
223
+ type: 'uint256',
224
+ },
225
+ {
226
+ internalType: 'contract IPosition',
227
+ name: 'target',
228
+ type: 'address',
229
+ },
230
+ {
231
+ internalType: 'uint256',
232
+ name: 'mint',
233
+ type: 'uint256',
234
+ },
235
+ {
236
+ internalType: 'uint256',
237
+ name: 'collDeposit',
238
+ type: 'uint256',
239
+ },
240
+ {
241
+ internalType: 'uint40',
242
+ name: 'expiration',
243
+ type: 'uint40',
244
+ },
245
+ ],
246
+ name: 'rollNative',
247
+ outputs: [],
248
+ stateMutability: 'payable',
249
+ type: 'function',
250
+ },
251
+ {
252
+ stateMutability: 'payable',
253
+ type: 'receive',
254
+ },
183
255
  ] as const;
@@ -12,7 +12,7 @@ export const MintingHubGatewayABI = [
12
12
  type: 'address',
13
13
  },
14
14
  {
15
- internalType: 'address',
15
+ internalType: 'address payable',
16
16
  name: '_roller',
17
17
  type: 'address',
18
18
  },
@@ -12,7 +12,7 @@ export const MintingHubV2ABI = [
12
12
  type: 'address',
13
13
  },
14
14
  {
15
- internalType: 'address',
15
+ internalType: 'address payable',
16
16
  name: '_roller',
17
17
  type: 'address',
18
18
  },
@@ -30,15 +30,15 @@ export const ADDRESS: Record<number, ChainAddress> = {
30
30
  positionFactoryV2: zeroAddress,
31
31
  },
32
32
  5115: {
33
- juiceDollar: "0x0D511a9C1662924dd8f9c12D2Bd72B0264E48583",
34
- equity: "0x8FF9be291A44CA3E7b45361bf6bbE1aCd0135c06",
35
- frontendGateway: "0x6721aC661e52C6BA092debb6cc33Ee58F1a4D10A",
36
- savingsGateway: "0xC638D446072416Aa1760A73748D291Af9f3925cB",
37
- savingsVaultJUSD: "0x4bD31350f611b469bA7fCC2c5945aAEBefD7A191",
38
- mintingHubGateway: "0x44B0727688F1839c2BF7b74686F04Cba0CfE89D6",
39
- bridgeStartUSD: "0x8d149f42C8F73F9fC90e2CbED8eE0644e8837623",
40
- startUSD: "0xf65BF14763699C08F9ff11e9Dc6706DdEB69b5b9",
41
- roller: "0xD09CeBBac7cA43430A505CA7A78123D83d53Af39",
42
- positionFactoryV2: "0xD6673d8Fc25094579Ae23802957e9084860F5d1a",
33
+ juiceDollar: "0x2742bb39221434bbfcac81959C8367fDE5d83ce9",
34
+ equity: "0xD6B9d4600C45eC4388e45A474C1C153828B7C018",
35
+ frontendGateway: "0x52C2d93DAC83Da412D93D035b017486DecCE782A",
36
+ savingsGateway: "0x2e1697e7BaA6CE62B0c36B015B7a5BEC6157B99e",
37
+ savingsVaultJUSD: "0x45DA5a722b591bBce0b87B192d846AB85EFA88d3",
38
+ mintingHubGateway: "0x57c4aB0f9480AC52a58C820a58ad802B0D4c23EB",
39
+ bridgeStartUSD: "0x8c5e5594c05205454BC09487ad53db4e4DB6564D",
40
+ startUSD: "0xa37f823Bd1bae4379265A4fF9cD5a68f402dE2f5",
41
+ roller: "0xB9B5f670A19E345fFb82D91e699a3f917E237f55",
42
+ positionFactoryV2: "0x70dDC84C79B724b247C10BB9a11Bd98c08Ee3C1a",
43
43
  },
44
44
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juicedollar/jusd",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "JuiceDollar (JUSD) - Oracle-free, Bitcoin-collateralized stablecoin on Citrea. Decentralized minting with democratic governance.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",