@renegade-fi/renegade-sdk 0.1.4 → 0.1.5
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/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { bytesToHex, concatBytes, hexToBytes, numberToBytes } from "viem/utils";
|
|
1
|
+
import { bytesToHex, concatBytes, hexToBytes, numberToBytes, numberToHex } from "viem/utils";
|
|
2
2
|
import { FixedPoint } from "./fixedPoint";
|
|
3
3
|
import {
|
|
4
4
|
type ApiExternalAssetTransfer,
|
|
@@ -12,6 +12,8 @@ import {
|
|
|
12
12
|
const BASE_AMOUNT_OFFSET = 4;
|
|
13
13
|
/** The length of the base amount in the calldata */
|
|
14
14
|
const BASE_AMOUNT_LENGTH = 32;
|
|
15
|
+
/** The address used to represent the native asset */
|
|
16
|
+
const NATIVE_ASSET_ADDR = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
* The response type for requesting a malleable quote on an external order
|
|
@@ -84,11 +86,15 @@ export class MalleableExternalMatchResponse {
|
|
|
84
86
|
|
|
85
87
|
const newCalldataBytes = concatBytes([prefix, baseAmountBytes, suffix]);
|
|
86
88
|
const newCalladata = bytesToHex(newCalldataBytes);
|
|
89
|
+
const value = this.isNativeEthSell() ? baseAmount : 0n;
|
|
90
|
+
const valueHex = numberToHex(value);
|
|
91
|
+
|
|
87
92
|
const newMatchBundle = {
|
|
88
93
|
...this.match_bundle,
|
|
89
94
|
settlement_tx: {
|
|
90
95
|
...this.match_bundle.settlement_tx,
|
|
91
96
|
data: newCalladata,
|
|
97
|
+
value: valueHex,
|
|
92
98
|
},
|
|
93
99
|
};
|
|
94
100
|
|
|
@@ -135,6 +141,17 @@ export class MalleableExternalMatchResponse {
|
|
|
135
141
|
return this.computeSendAmount(baseAmount);
|
|
136
142
|
}
|
|
137
143
|
|
|
144
|
+
/**
|
|
145
|
+
* Return whether the trade is a native ETH sell
|
|
146
|
+
*/
|
|
147
|
+
public isNativeEthSell(): boolean {
|
|
148
|
+
const matchRes = this.match_bundle.match_result;
|
|
149
|
+
const isSell = matchRes.direction === OrderSide.SELL;
|
|
150
|
+
const isBaseEth = matchRes.base_mint.toLowerCase() === NATIVE_ASSET_ADDR.toLowerCase();
|
|
151
|
+
|
|
152
|
+
return isBaseEth && isSell;
|
|
153
|
+
}
|
|
154
|
+
|
|
138
155
|
/**
|
|
139
156
|
* Check a base amount is in the valid range
|
|
140
157
|
*/
|
package/src/version.ts
CHANGED