@dhedge/v2-sdk 1.11.1 → 2.0.1
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/dist/entities/pool.d.ts +91 -91
- package/dist/services/flatmoney/stableLp.d.ts +4 -4
- package/dist/services/odos/index.d.ts +5 -1
- package/dist/services/pendle/index.d.ts +4 -1
- package/dist/services/toros/completeWithdrawal.d.ts +7 -0
- package/dist/services/toros/easySwapper.d.ts +2 -2
- package/dist/services/toros/initWithdrawal.d.ts +3 -0
- package/dist/services/toros/retry.d.ts +5 -0
- package/dist/services/toros/swapData.d.ts +11 -0
- package/dist/types.d.ts +5 -0
- package/dist/utils/contract.d.ts +3 -2
- package/dist/v2-sdk.cjs.development.js +5716 -2693
- package/dist/v2-sdk.cjs.development.js.map +1 -1
- package/dist/v2-sdk.cjs.production.min.js +1 -1
- package/dist/v2-sdk.cjs.production.min.js.map +1 -1
- package/dist/v2-sdk.esm.js +5716 -2693
- package/dist/v2-sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/abi/IAaveLendingPoolAssetGuard.json +645 -0
- package/src/abi/IEasySwapperV2.json +1507 -0
- package/src/abi/pendle/PT.json +15 -0
- package/src/abi/pendle/SY.json +1 -0
- package/src/entities/pool.ts +240 -149
- package/src/services/flatmoney/stableLp.ts +27 -21
- package/src/services/odos/index.ts +6 -3
- package/src/services/pendle/index.ts +43 -8
- package/src/services/toros/completeWithdrawal.ts +209 -0
- package/src/services/toros/easySwapper.ts +16 -84
- package/src/services/toros/initWithdrawal.ts +166 -0
- package/src/services/toros/retry.ts +28 -0
- package/src/services/toros/swapData.ts +70 -0
- package/src/test/constants.ts +1 -1
- package/src/test/odos.test.ts +8 -7
- package/src/test/oneInch.test.ts +20 -22
- package/src/test/pendle.test.ts +63 -37
- package/src/test/toros.test.ts +10 -8
- package/src/types.ts +8 -0
- package/src/utils/contract.ts +70 -16
package/src/utils/contract.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import set from "lodash/set";
|
|
4
4
|
import { Interface } from "@ethersproject/abi";
|
|
5
5
|
import { multiCallAddress } from "../config";
|
|
6
|
-
import { ethers, Network, Pool } from "..";
|
|
6
|
+
import { ethers, Network, Pool, SDKOptions } from "..";
|
|
7
7
|
|
|
8
8
|
export async function call(
|
|
9
9
|
provider: ethers.Signer,
|
|
@@ -94,30 +94,84 @@ export class Multicaller {
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
const getGasEstimateData = async (
|
|
98
|
+
estimateFunc: ethers.ContractFunction<ethers.BigNumber>,
|
|
99
|
+
txInfoData: { to: string; txData: string; minAmountOut: any },
|
|
100
|
+
txOptions: any = {}
|
|
101
|
+
) => {
|
|
102
|
+
let gas = null;
|
|
103
|
+
let gasEstimationError = null;
|
|
104
|
+
try {
|
|
105
|
+
gas = await estimateFunc(txInfoData.to, txInfoData.txData, txOptions);
|
|
106
|
+
} catch (e) {
|
|
107
|
+
gasEstimationError = e;
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
gas,
|
|
111
|
+
gasEstimationError,
|
|
112
|
+
...txInfoData
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export const isSdkOptionsBoolean = (
|
|
117
|
+
sdkOptions: SDKOptions
|
|
118
|
+
): sdkOptions is boolean => {
|
|
119
|
+
return typeof sdkOptions === "boolean";
|
|
120
|
+
};
|
|
121
|
+
|
|
97
122
|
export const getPoolTxOrGasEstimate = async (
|
|
98
123
|
pool: Pool,
|
|
99
124
|
args: any[],
|
|
100
|
-
|
|
125
|
+
sdkOptions: SDKOptions
|
|
101
126
|
): Promise<any> => {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
127
|
+
const txInfoData = {
|
|
128
|
+
txData: args[1],
|
|
129
|
+
to: args[0],
|
|
130
|
+
minAmountOut: args[3] || null
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
if (!isSdkOptionsBoolean(sdkOptions) && sdkOptions.onlyGetTxData) {
|
|
134
|
+
return txInfoData;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const txOptions = args[2];
|
|
138
|
+
|
|
139
|
+
if (
|
|
140
|
+
!pool.isDhedge ||
|
|
141
|
+
(!isSdkOptionsBoolean(sdkOptions) && sdkOptions.useTraderAddressAsFrom)
|
|
142
|
+
) {
|
|
143
|
+
if (
|
|
144
|
+
sdkOptions === true ||
|
|
145
|
+
(!isSdkOptionsBoolean(sdkOptions) && sdkOptions.estimateGas)
|
|
146
|
+
) {
|
|
147
|
+
return await getGasEstimateData(
|
|
148
|
+
pool.signer.estimateGas,
|
|
149
|
+
txInfoData,
|
|
150
|
+
txOptions
|
|
108
151
|
);
|
|
109
152
|
} else {
|
|
110
|
-
return await pool.
|
|
153
|
+
return await pool.signer.sendTransaction({
|
|
154
|
+
to: txInfoData.to,
|
|
155
|
+
data: txInfoData.txData,
|
|
156
|
+
...txOptions
|
|
157
|
+
});
|
|
111
158
|
}
|
|
112
159
|
} else {
|
|
113
|
-
if (
|
|
114
|
-
|
|
160
|
+
if (
|
|
161
|
+
sdkOptions === true ||
|
|
162
|
+
(!isSdkOptionsBoolean(sdkOptions) && sdkOptions.estimateGas)
|
|
163
|
+
) {
|
|
164
|
+
return await getGasEstimateData(
|
|
165
|
+
pool.poolLogic.estimateGas.execTransaction,
|
|
166
|
+
txInfoData,
|
|
167
|
+
txOptions
|
|
168
|
+
);
|
|
115
169
|
} else {
|
|
116
|
-
return await pool.
|
|
117
|
-
to
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
170
|
+
return await pool.poolLogic.execTransaction(
|
|
171
|
+
txInfoData.to,
|
|
172
|
+
txInfoData.txData,
|
|
173
|
+
txOptions
|
|
174
|
+
);
|
|
121
175
|
}
|
|
122
176
|
}
|
|
123
177
|
};
|