@dhedge/v2-sdk 2.2.0 → 2.2.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/README.md CHANGED
@@ -124,21 +124,24 @@ await vault.trade(Dapp.KYBERSWAP, "USDC_ADDRESS", "WETH_ADDRESS", "1000000", 0.5
124
124
 
125
125
  ---
126
126
 
127
- If you want to use aggregators such as 1Inch or Odos, copy `.env.example` to `.env` and configure the API keys you need.
127
+ If you want to use aggregators such as 1Inch or Odos, or Ondo GM token swaps, copy `.env.example` to `.env` and configure the API keys you need.
128
128
 
129
129
  ```
130
130
  ONEINCH_API_KEY=YOUR_API_KEY_FROM_1INCH
131
131
  ODOS_API_KEY=YOUR_ODOS_API_KEY
132
+ ONDO_API_KEY=YOUR_ONDO_API_KEY
132
133
  ```
133
134
 
134
135
  - `ONEINCH_API_KEY` is required for `Dapp.ONEINCH`
135
136
  - `ODOS_API_KEY` is required for `Dapp.ODOS`
136
137
  - `ODOS_API_KEY` can also be required by `completeTorosWithdrawal(...)` when a Toros withdrawal needs Odos-backed swap data
138
+ - `ONDO_API_KEY` is required for Ondo GM token swaps (`Dapp.ONDO`)
137
139
 
138
140
  To get started:
139
141
 
140
142
  - get a 1inch API key from the [1inch Developer Portal](https://docs.1inch.io/docs/aggregation-protocol/introduction)
141
143
  - get an Odos API key via the [Odos developer docs](https://docs.odos.xyz/build/api-docs), and make sure it is valid for the Odos endpoint configured by this SDK
144
+ - get an Ondo API key by contacting [onboarding@ondo.finance](mailto:onboarding@ondo.finance)
142
145
  - place the keys in a `.env` file at the project root before calling aggregator-backed methods
143
146
  - if a required key is missing, the SDK will fail before transaction submission
144
147
 
@@ -0,0 +1,5 @@
1
+ import { Pool } from "../..";
2
+ export declare function getOndoSwapTxData(pool: Pool, tokenIn: string, tokenOut: string, amountIn: string, slippage: number): Promise<{
3
+ swapTxData: string;
4
+ minAmountOut: string;
5
+ }>;
package/dist/types.d.ts CHANGED
@@ -35,7 +35,8 @@ export declare enum Dapp {
35
35
  PENDLE = "pendle",
36
36
  KYBERSWAP = "kyberswap",
37
37
  HYPERLIQUID = "hyperliquid",
38
- COWSWAP = "cowswap"
38
+ COWSWAP = "cowswap",
39
+ ONDO = "ondo"
39
40
  }
40
41
  /** Function-name strings used when encoding ABI calls — keep in sync with the
41
42
  * matching ABI files in `src/abi/`. */
@@ -4594,6 +4594,7 @@ var ManagerLogic = {
4594
4594
  Dapp["KYBERSWAP"] = "kyberswap";
4595
4595
  Dapp["HYPERLIQUID"] = "hyperliquid";
4596
4596
  Dapp["COWSWAP"] = "cowswap";
4597
+ Dapp["ONDO"] = "ondo";
4597
4598
  })(exports.Dapp || (exports.Dapp = {}));
4598
4599
 
4599
4600
  (function (Transaction) {
@@ -4626,7 +4627,7 @@ require("dotenv").config();
4626
4627
  var factoryAddress = (_factoryAddress = {}, _factoryAddress[exports.Network.POLYGON] = process.env.STAGING_CONTRACTS ? "0xDd87eCdB10cFF7004276AAbAbd30e7a08F69bb53" : "0xfdc7b8bFe0DD3513Cc669bB8d601Cb83e2F69cB0", _factoryAddress[exports.Network.OPTIMISM] = "0x5e61a079A178f0E5784107a4963baAe0c5a680c6", _factoryAddress[exports.Network.ARBITRUM] = "0xfffb5fb14606eb3a548c113026355020ddf27535", _factoryAddress[exports.Network.BASE] = "0x49Afe3abCf66CF09Fab86cb1139D8811C8afe56F", _factoryAddress[exports.Network.ETHEREUM] = "0x96D33bCF84DdE326014248E2896F79bbb9c13D6d", _factoryAddress[exports.Network.PLASMA] = "0xAec4975Fc8ad911464D2948D771488b30F6eEE87", _factoryAddress[exports.Network.HYPERLIQUID] = "0xe91505e2ab653dd128c71e9690eeefd28cc5b333", _factoryAddress);
4627
4628
  /** Router/spender address for each (network, Dapp). Target of `pool.approve`/`pool.trade`. */
4628
4629
 
4629
- var routerAddress = (_routerAddress = {}, _routerAddress[exports.Network.POLYGON] = (_Network$POLYGON = {}, _Network$POLYGON[exports.Dapp.SUSHISWAP] = "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506", _Network$POLYGON[exports.Dapp.AAVE] = "0x8dFf5E27EA6b7AC08EbFdf9eB090F32ee9a30fcf", _Network$POLYGON[exports.Dapp.AAVEV3] = "0x794a61358D6845594F94dc1DB02A252b5b4814aD", _Network$POLYGON[exports.Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$POLYGON[exports.Dapp.QUICKSWAP] = "0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff", _Network$POLYGON[exports.Dapp.BALANCER] = "0xBA12222222228d8Ba445958a75a0704d566BF2C8", _Network$POLYGON[exports.Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$POLYGON[exports.Dapp.ARRAKIS] = "0xc73fb100a995b33f9fa181d420f4c8d74506df66", _Network$POLYGON[exports.Dapp.TOROS] = "0x45b90480D6F643dE2f128db091A357C3c90399f2", _Network$POLYGON[exports.Dapp.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$POLYGON[exports.Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$POLYGON[exports.Dapp.COWSWAP] = "0x893223Be4e941fAA8A8DB93D0C097fCac37801ce", _Network$POLYGON), _routerAddress[exports.Network.OPTIMISM] = (_Network$OPTIMISM = {}, _Network$OPTIMISM[exports.Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$OPTIMISM[exports.Dapp.AAVEV3] = "0x794a61358D6845594F94dc1DB02A252b5b4814aD", _Network$OPTIMISM[exports.Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$OPTIMISM[exports.Dapp.TOROS] = "0x2Ed1bd7f66e47113672f3870308b5E867C5bb743", _Network$OPTIMISM[exports.Dapp.VELODROME] = "0x9c12939390052919aF3155f41Bf4160Fd3666A6f", _Network$OPTIMISM[exports.Dapp.VELODROMEV2] = "0xa062ae8a9c5e11aaa026fc2670b0d65ccc8b2858", _Network$OPTIMISM[exports.Dapp.LYRA] = "0xCCE7819d65f348c64B7Beb205BA367b3fE33763B", _Network$OPTIMISM[exports.Dapp.ARRAKIS] = "0x9ce88a56d120300061593eF7AD074A1B710094d5", _Network$OPTIMISM[exports.Dapp.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$OPTIMISM[exports.Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$OPTIMISM[exports.Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$OPTIMISM), _routerAddress[exports.Network.ARBITRUM] = (_Network$ARBITRUM = {}, _Network$ARBITRUM[exports.Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$ARBITRUM[exports.Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$ARBITRUM[exports.Dapp.AAVEV3] = "0x794a61358D6845594F94dc1DB02A252b5b4814aD", _Network$ARBITRUM[exports.Dapp.BALANCER] = "0xBA12222222228d8Ba445958a75a0704d566BF2C8", _Network$ARBITRUM[exports.Dapp.TOROS] = "0xA5679C4272A056Bb83f039961fae7D99C48529F5", _Network$ARBITRUM[exports.Dapp.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$ARBITRUM[exports.Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$ARBITRUM[exports.Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$ARBITRUM), _routerAddress[exports.Network.BASE] = (_Network$BASE = {}, _Network$BASE[exports.Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$BASE[exports.Dapp.AERODROME] = "0xcF77a3Ba9A5CA399B7c97c74d54e5b1Beb874E43", _Network$BASE[exports.Dapp.AAVEV3] = "0xA238Dd80C259a72e81d7e4664a9801593F98d1c5", _Network$BASE[exports.Dapp.TOROS] = "0xf067575Eb60c7587C11e867907AA7284833704d1", _Network$BASE[exports.Dapp.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$BASE[exports.Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$BASE[exports.Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$BASE), _routerAddress[exports.Network.ETHEREUM] = (_Network$ETHEREUM = {}, _Network$ETHEREUM[exports.Dapp.AAVEV3] = "0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2", _Network$ETHEREUM[exports.Dapp.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$ETHEREUM[exports.Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$ETHEREUM[exports.Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$ETHEREUM[exports.Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$ETHEREUM), _routerAddress[exports.Network.PLASMA] = (_Network$PLASMA = {}, _Network$PLASMA[exports.Dapp.AAVEV3] = "0x925a2A7214Ed92428B5b1B090F80b25700095e12", _Network$PLASMA[exports.Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$PLASMA[exports.Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$PLASMA), _routerAddress[exports.Network.HYPERLIQUID] = (_Network$HYPERLIQUID = {}, _Network$HYPERLIQUID[exports.Dapp.HYPERLIQUID] = "0x6b9e773128f453f5c2c60935ee2de2cbc5390a24", _Network$HYPERLIQUID), _routerAddress);
4630
+ var routerAddress = (_routerAddress = {}, _routerAddress[exports.Network.POLYGON] = (_Network$POLYGON = {}, _Network$POLYGON[exports.Dapp.SUSHISWAP] = "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506", _Network$POLYGON[exports.Dapp.AAVE] = "0x8dFf5E27EA6b7AC08EbFdf9eB090F32ee9a30fcf", _Network$POLYGON[exports.Dapp.AAVEV3] = "0x794a61358D6845594F94dc1DB02A252b5b4814aD", _Network$POLYGON[exports.Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$POLYGON[exports.Dapp.QUICKSWAP] = "0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff", _Network$POLYGON[exports.Dapp.BALANCER] = "0xBA12222222228d8Ba445958a75a0704d566BF2C8", _Network$POLYGON[exports.Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$POLYGON[exports.Dapp.ARRAKIS] = "0xc73fb100a995b33f9fa181d420f4c8d74506df66", _Network$POLYGON[exports.Dapp.TOROS] = "0x45b90480D6F643dE2f128db091A357C3c90399f2", _Network$POLYGON[exports.Dapp.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$POLYGON[exports.Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$POLYGON[exports.Dapp.COWSWAP] = "0x893223Be4e941fAA8A8DB93D0C097fCac37801ce", _Network$POLYGON), _routerAddress[exports.Network.OPTIMISM] = (_Network$OPTIMISM = {}, _Network$OPTIMISM[exports.Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$OPTIMISM[exports.Dapp.AAVEV3] = "0x794a61358D6845594F94dc1DB02A252b5b4814aD", _Network$OPTIMISM[exports.Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$OPTIMISM[exports.Dapp.TOROS] = "0x2Ed1bd7f66e47113672f3870308b5E867C5bb743", _Network$OPTIMISM[exports.Dapp.VELODROME] = "0x9c12939390052919aF3155f41Bf4160Fd3666A6f", _Network$OPTIMISM[exports.Dapp.VELODROMEV2] = "0xa062ae8a9c5e11aaa026fc2670b0d65ccc8b2858", _Network$OPTIMISM[exports.Dapp.LYRA] = "0xCCE7819d65f348c64B7Beb205BA367b3fE33763B", _Network$OPTIMISM[exports.Dapp.ARRAKIS] = "0x9ce88a56d120300061593eF7AD074A1B710094d5", _Network$OPTIMISM[exports.Dapp.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$OPTIMISM[exports.Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$OPTIMISM[exports.Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$OPTIMISM), _routerAddress[exports.Network.ARBITRUM] = (_Network$ARBITRUM = {}, _Network$ARBITRUM[exports.Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$ARBITRUM[exports.Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$ARBITRUM[exports.Dapp.AAVEV3] = "0x794a61358D6845594F94dc1DB02A252b5b4814aD", _Network$ARBITRUM[exports.Dapp.BALANCER] = "0xBA12222222228d8Ba445958a75a0704d566BF2C8", _Network$ARBITRUM[exports.Dapp.TOROS] = "0xA5679C4272A056Bb83f039961fae7D99C48529F5", _Network$ARBITRUM[exports.Dapp.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$ARBITRUM[exports.Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$ARBITRUM[exports.Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$ARBITRUM), _routerAddress[exports.Network.BASE] = (_Network$BASE = {}, _Network$BASE[exports.Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$BASE[exports.Dapp.AERODROME] = "0xcF77a3Ba9A5CA399B7c97c74d54e5b1Beb874E43", _Network$BASE[exports.Dapp.AAVEV3] = "0xA238Dd80C259a72e81d7e4664a9801593F98d1c5", _Network$BASE[exports.Dapp.TOROS] = "0xf067575Eb60c7587C11e867907AA7284833704d1", _Network$BASE[exports.Dapp.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$BASE[exports.Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$BASE[exports.Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$BASE), _routerAddress[exports.Network.ETHEREUM] = (_Network$ETHEREUM = {}, _Network$ETHEREUM[exports.Dapp.AAVEV3] = "0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2", _Network$ETHEREUM[exports.Dapp.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$ETHEREUM[exports.Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$ETHEREUM[exports.Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$ETHEREUM[exports.Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$ETHEREUM[exports.Dapp.ONDO] = "0xde41399145F23936b03dD1474eC16c1519c0DC2a", _Network$ETHEREUM), _routerAddress[exports.Network.PLASMA] = (_Network$PLASMA = {}, _Network$PLASMA[exports.Dapp.AAVEV3] = "0x925a2A7214Ed92428B5b1B090F80b25700095e12", _Network$PLASMA[exports.Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$PLASMA[exports.Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$PLASMA), _routerAddress[exports.Network.HYPERLIQUID] = (_Network$HYPERLIQUID = {}, _Network$HYPERLIQUID[exports.Dapp.HYPERLIQUID] = "0x6b9e773128f453f5c2c60935ee2de2cbc5390a24", _Network$HYPERLIQUID), _routerAddress);
4630
4631
  /** CoW Protocol GPv2Settlement address per network (where pre-signed orders are submitted). */
4631
4632
 
4632
4633
  var gpv2SettlementAddress = (_gpv2SettlementAddres = {}, _gpv2SettlementAddres[exports.Network.POLYGON] = "0x9008D19f58AAbD9eD0D60971565AA8510560ab41", _gpv2SettlementAddres);
@@ -28536,6 +28537,233 @@ function _getCowSwapTxData() {
28536
28537
  return _getCowSwapTxData.apply(this, arguments);
28537
28538
  }
28538
28539
 
28540
+ var IOndoGMSwap = [
28541
+ {
28542
+ inputs: [
28543
+ {
28544
+ name: "tokenIn",
28545
+ type: "address"
28546
+ },
28547
+ {
28548
+ name: "amountIn",
28549
+ type: "uint256"
28550
+ },
28551
+ {
28552
+ name: "tokenOut",
28553
+ type: "address"
28554
+ },
28555
+ {
28556
+ name: "amountOutMinimum",
28557
+ type: "uint256"
28558
+ },
28559
+ {
28560
+ name: "attestationSignature",
28561
+ type: "bytes"
28562
+ },
28563
+ {
28564
+ components: [
28565
+ {
28566
+ name: "chainId",
28567
+ type: "uint256"
28568
+ },
28569
+ {
28570
+ name: "attestationId",
28571
+ type: "uint256"
28572
+ },
28573
+ {
28574
+ name: "userId",
28575
+ type: "bytes32"
28576
+ },
28577
+ {
28578
+ name: "asset",
28579
+ type: "address"
28580
+ },
28581
+ {
28582
+ name: "price",
28583
+ type: "uint256"
28584
+ },
28585
+ {
28586
+ name: "quantity",
28587
+ type: "uint256"
28588
+ },
28589
+ {
28590
+ name: "expiration",
28591
+ type: "uint256"
28592
+ },
28593
+ {
28594
+ name: "side",
28595
+ type: "uint8"
28596
+ },
28597
+ {
28598
+ name: "additionalData",
28599
+ type: "bytes32"
28600
+ }
28601
+ ],
28602
+ name: "quote",
28603
+ type: "tuple"
28604
+ }
28605
+ ],
28606
+ name: "swapExactInWithAttestation",
28607
+ outputs: [
28608
+ ],
28609
+ stateMutability: "nonpayable",
28610
+ type: "function"
28611
+ }
28612
+ ];
28613
+
28614
+ var ONDO_API_URL = "https://api.gm.ondo.finance/v1/attestations"; // Ethereum mainnet USDC — Ondo is Ethereum-only
28615
+
28616
+ var USDC_ETHEREUM = "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48";
28617
+ var iface$1 = /*#__PURE__*/new ethers.ethers.utils.Interface(IOndoGMSwap); // Ondo returns userId as a left-aligned 32-byte hex (significant bytes first,
28618
+ // e.g. 0x474d...0000), so right-pad to preserve byte order and fix it to 32 bytes.
28619
+
28620
+ function toBytes32(s) {
28621
+ var hex = s.startsWith("0x") ? s.slice(2) : s;
28622
+ return "0x" + hex.padEnd(64, "0").slice(0, 64);
28623
+ }
28624
+
28625
+ function postOndoAttestation(_x, _x2, _x3, _x4) {
28626
+ return _postOndoAttestation.apply(this, arguments);
28627
+ }
28628
+
28629
+ function _postOndoAttestation() {
28630
+ _postOndoAttestation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(symbol, side, amount, apiKey) {
28631
+ var _yield$axios$post, data, _error$response$data, _ref, code, message;
28632
+
28633
+ return runtime_1.wrap(function _callee$(_context) {
28634
+ while (1) {
28635
+ switch (_context.prev = _context.next) {
28636
+ case 0:
28637
+ _context.prev = 0;
28638
+ _context.next = 3;
28639
+ return axios.post(ONDO_API_URL, _extends({
28640
+ chainId: "ethereum-1",
28641
+ symbol: symbol,
28642
+ side: side
28643
+ }, amount, {
28644
+ duration: "short"
28645
+ }), {
28646
+ headers: {
28647
+ "x-api-key": apiKey
28648
+ }
28649
+ });
28650
+
28651
+ case 3:
28652
+ _yield$axios$post = _context.sent;
28653
+ data = _yield$axios$post.data;
28654
+ return _context.abrupt("return", data);
28655
+
28656
+ case 8:
28657
+ _context.prev = 8;
28658
+ _context.t0 = _context["catch"](0);
28659
+
28660
+ if (!(axios.isAxiosError(_context.t0) && _context.t0.response)) {
28661
+ _context.next = 13;
28662
+ break;
28663
+ }
28664
+
28665
+ _ref = (_error$response$data = _context.t0.response.data) != null ? _error$response$data : {}, code = _ref.code, message = _ref.message;
28666
+ throw new ApiError(("Ondo attestation request failed (" + _context.t0.response.status + "): " + (code != null ? code : "") + " " + (message != null ? message : JSON.stringify(_context.t0.response.data))).trim());
28667
+
28668
+ case 13:
28669
+ throw new ApiError("Ondo attestation request failed: " + (_context.t0 instanceof Error ? _context.t0.message : String(_context.t0)));
28670
+
28671
+ case 14:
28672
+ case "end":
28673
+ return _context.stop();
28674
+ }
28675
+ }
28676
+ }, _callee, null, [[0, 8]]);
28677
+ }));
28678
+ return _postOndoAttestation.apply(this, arguments);
28679
+ }
28680
+
28681
+ function getOndoSwapTxData(_x5, _x6, _x7, _x8, _x9) {
28682
+ return _getOndoSwapTxData.apply(this, arguments);
28683
+ }
28684
+
28685
+ function _getOndoSwapTxData() {
28686
+ _getOndoSwapTxData = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(pool, tokenIn, tokenOut, amountIn, slippage) {
28687
+ var apiKey, amount, isMint, gmToken, slippageBps, tokenContract, symbol, attestationAmount, attestation, signature, additionalData, quantity, priceD18, minAmountOut, usdcOut, quote, swapTxData;
28688
+ return runtime_1.wrap(function _callee2$(_context2) {
28689
+ while (1) {
28690
+ switch (_context2.prev = _context2.next) {
28691
+ case 0:
28692
+ apiKey = process.env.ONDO_API_KEY;
28693
+
28694
+ if (apiKey) {
28695
+ _context2.next = 3;
28696
+ break;
28697
+ }
28698
+
28699
+ throw new Error("ONDO_API_KEY environment variable is not set");
28700
+
28701
+ case 3:
28702
+ amount = new BigNumber__default(amountIn);
28703
+ isMint = tokenIn.toLowerCase() === USDC_ETHEREUM.toLowerCase();
28704
+ gmToken = isMint ? tokenOut : tokenIn;
28705
+ slippageBps = Math.round(slippage * 100);
28706
+ tokenContract = new ethers.ethers.Contract(gmToken, ["function symbol() view returns (string)"], pool.signer);
28707
+ _context2.next = 10;
28708
+ return tokenContract.symbol();
28709
+
28710
+ case 10:
28711
+ symbol = _context2.sent;
28712
+ // For mint: notionalValue is the USD amount to subscribe. USDonManager values
28713
+ // USDC at par (1 USDC = 1 USDon), so pass the USDC amount as-is (6dp -> decimal).
28714
+ // Discounting by a USDC market price would strand the gap as USDon in the swapper
28715
+ // (and revert via ExcessiveAmountIn once it exceeds the 1 USDC tolerance).
28716
+ // For redeem: pass the GM token amount directly as tokenAmount.
28717
+ attestationAmount = isMint ? {
28718
+ notionalValue: amount.div(1e6).toFixed(18)
28719
+ } : {
28720
+ tokenAmount: amount.div(1e18).toFixed(18)
28721
+ };
28722
+ _context2.next = 14;
28723
+ return postOndoAttestation(symbol, isMint ? "buy" : "sell", attestationAmount, apiKey);
28724
+
28725
+ case 14:
28726
+ attestation = _context2.sent;
28727
+ signature = "0x" + Buffer.from(attestation.signature, "base64").toString("hex");
28728
+ additionalData = ethers.ethers.utils.hexZeroPad("0x" + Buffer.from(attestation.additionalData, "base64").toString("hex"), 32);
28729
+ quantity = new BigNumber__default(attestation.tokenAmount);
28730
+ priceD18 = new BigNumber__default(attestation.price);
28731
+
28732
+ if (isMint) {
28733
+ minAmountOut = quantity.times(10000 - slippageBps).div(10000);
28734
+ } else {
28735
+ // USDC out (6 dec) = quantity_D18 * price_D18 / 1e30
28736
+ usdcOut = quantity.times(priceD18).div(1e30);
28737
+ minAmountOut = usdcOut.times(10000 - slippageBps).div(10000);
28738
+ }
28739
+
28740
+ quote = {
28741
+ chainId: 1,
28742
+ attestationId: attestation.attestationId,
28743
+ userId: toBytes32(attestation.userId),
28744
+ asset: attestation.assetAddress,
28745
+ price: priceD18.toFixed(0),
28746
+ quantity: quantity.toFixed(0),
28747
+ expiration: attestation.expiration,
28748
+ side: Number(attestation.side),
28749
+ additionalData: additionalData
28750
+ };
28751
+ swapTxData = iface$1.encodeFunctionData("swapExactInWithAttestation", [tokenIn, amount.toFixed(0), tokenOut, minAmountOut.toFixed(0), signature, quote]);
28752
+ return _context2.abrupt("return", {
28753
+ swapTxData: swapTxData,
28754
+ minAmountOut: minAmountOut.toFixed(0)
28755
+ });
28756
+
28757
+ case 23:
28758
+ case "end":
28759
+ return _context2.stop();
28760
+ }
28761
+ }
28762
+ }, _callee2);
28763
+ }));
28764
+ return _getOndoSwapTxData.apply(this, arguments);
28765
+ }
28766
+
28539
28767
  var ICoreDepositWalletAbi = [
28540
28768
  {
28541
28769
  inputs: [
@@ -29660,7 +29888,7 @@ var Pool = /*#__PURE__*/function () {
29660
29888
  /*#__PURE__*/
29661
29889
  function () {
29662
29890
  var _trade = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(dapp, assetFrom, assetTo, amountIn, slippage, options, sdkOptions) {
29663
- var swapTxData, minAmountOut, _yield$getOneInchSwap, _yield$getOdosSwapTxD, _yield$getPendleSwapT, _yield$getKyberSwapTx, cowSwapEstimateGas, _yield$getCowSwapTxDa, encodedTypedData, preSignTxData, cowMinOut, validatorContract, submitTx, submitReceipt, iUniswapV2Router, calculatedMinAmountOut, tx;
29891
+ var swapTxData, minAmountOut, _yield$getOneInchSwap, _yield$getOdosSwapTxD, _yield$getPendleSwapT, _yield$getKyberSwapTx, _yield$getOndoSwapTxD, cowSwapEstimateGas, _yield$getCowSwapTxDa, encodedTypedData, preSignTxData, cowMinOut, validatorContract, submitTx, submitReceipt, iUniswapV2Router, calculatedMinAmountOut, tx;
29664
29892
 
29665
29893
  return runtime_1.wrap(function _callee10$(_context10) {
29666
29894
  while (1) {
@@ -29682,7 +29910,7 @@ var Pool = /*#__PURE__*/function () {
29682
29910
 
29683
29911
  minAmountOut = null;
29684
29912
  _context10.t0 = dapp;
29685
- _context10.next = _context10.t0 === exports.Dapp.ONEINCH ? 7 : _context10.t0 === exports.Dapp.BALANCER ? 13 : _context10.t0 === exports.Dapp.TOROS ? 17 : _context10.t0 === exports.Dapp.ODOS ? 21 : _context10.t0 === exports.Dapp.PENDLE ? 27 : _context10.t0 === exports.Dapp.KYBERSWAP ? 33 : _context10.t0 === exports.Dapp.COWSWAP ? 39 : 58;
29913
+ _context10.next = _context10.t0 === exports.Dapp.ONEINCH ? 7 : _context10.t0 === exports.Dapp.BALANCER ? 13 : _context10.t0 === exports.Dapp.TOROS ? 17 : _context10.t0 === exports.Dapp.ODOS ? 21 : _context10.t0 === exports.Dapp.PENDLE ? 27 : _context10.t0 === exports.Dapp.KYBERSWAP ? 33 : _context10.t0 === exports.Dapp.ONDO ? 39 : _context10.t0 === exports.Dapp.COWSWAP ? 45 : 64;
29686
29914
  break;
29687
29915
 
29688
29916
  case 7:
@@ -29693,7 +29921,7 @@ var Pool = /*#__PURE__*/function () {
29693
29921
  _yield$getOneInchSwap = _context10.sent;
29694
29922
  swapTxData = _yield$getOneInchSwap.swapTxData;
29695
29923
  minAmountOut = _yield$getOneInchSwap.dstAmount;
29696
- return _context10.abrupt("break", 73);
29924
+ return _context10.abrupt("break", 79);
29697
29925
 
29698
29926
  case 13:
29699
29927
  _context10.next = 15;
@@ -29701,7 +29929,7 @@ var Pool = /*#__PURE__*/function () {
29701
29929
 
29702
29930
  case 15:
29703
29931
  swapTxData = _context10.sent;
29704
- return _context10.abrupt("break", 73);
29932
+ return _context10.abrupt("break", 79);
29705
29933
 
29706
29934
  case 17:
29707
29935
  _context10.next = 19;
@@ -29709,7 +29937,7 @@ var Pool = /*#__PURE__*/function () {
29709
29937
 
29710
29938
  case 19:
29711
29939
  swapTxData = _context10.sent;
29712
- return _context10.abrupt("break", 73);
29940
+ return _context10.abrupt("break", 79);
29713
29941
 
29714
29942
  case 21:
29715
29943
  _context10.next = 23;
@@ -29719,7 +29947,7 @@ var Pool = /*#__PURE__*/function () {
29719
29947
  _yield$getOdosSwapTxD = _context10.sent;
29720
29948
  swapTxData = _yield$getOdosSwapTxD.swapTxData;
29721
29949
  minAmountOut = _yield$getOdosSwapTxD.minAmountOut;
29722
- return _context10.abrupt("break", 73);
29950
+ return _context10.abrupt("break", 79);
29723
29951
 
29724
29952
  case 27:
29725
29953
  _context10.next = 29;
@@ -29729,7 +29957,7 @@ var Pool = /*#__PURE__*/function () {
29729
29957
  _yield$getPendleSwapT = _context10.sent;
29730
29958
  swapTxData = _yield$getPendleSwapT.swapTxData;
29731
29959
  minAmountOut = _yield$getPendleSwapT.minAmountOut;
29732
- return _context10.abrupt("break", 73);
29960
+ return _context10.abrupt("break", 79);
29733
29961
 
29734
29962
  case 33:
29735
29963
  _context10.next = 35;
@@ -29739,58 +29967,68 @@ var Pool = /*#__PURE__*/function () {
29739
29967
  _yield$getKyberSwapTx = _context10.sent;
29740
29968
  swapTxData = _yield$getKyberSwapTx.swapTxData;
29741
29969
  minAmountOut = _yield$getKyberSwapTx.minAmountOut;
29742
- return _context10.abrupt("break", 73);
29970
+ return _context10.abrupt("break", 79);
29743
29971
 
29744
29972
  case 39:
29973
+ _context10.next = 41;
29974
+ return getOndoSwapTxData(this, assetFrom, assetTo, amountIn.toString(), slippage);
29975
+
29976
+ case 41:
29977
+ _yield$getOndoSwapTxD = _context10.sent;
29978
+ swapTxData = _yield$getOndoSwapTxD.swapTxData;
29979
+ minAmountOut = _yield$getOndoSwapTxD.minAmountOut;
29980
+ return _context10.abrupt("break", 79);
29981
+
29982
+ case 45:
29745
29983
  cowSwapEstimateGas = isSdkOptionsBoolean(sdkOptions) ? sdkOptions : sdkOptions.estimateGas;
29746
29984
 
29747
29985
  if (!(cowSwapEstimateGas || !isSdkOptionsBoolean(sdkOptions) && sdkOptions.onlyGetTxData)) {
29748
- _context10.next = 42;
29986
+ _context10.next = 48;
29749
29987
  break;
29750
29988
  }
29751
29989
 
29752
29990
  throw new Error("CowSwap requires two sequential transactions (submit + preSign) and does not support estimateGas or onlyGetTxData");
29753
29991
 
29754
- case 42:
29755
- _context10.next = 44;
29992
+ case 48:
29993
+ _context10.next = 50;
29756
29994
  return getCowSwapTxData(this, assetFrom, assetTo, amountIn, slippage);
29757
29995
 
29758
- case 44:
29996
+ case 50:
29759
29997
  _yield$getCowSwapTxDa = _context10.sent;
29760
29998
  encodedTypedData = _yield$getCowSwapTxDa.encodedTypedData;
29761
29999
  preSignTxData = _yield$getCowSwapTxDa.preSignTxData;
29762
30000
  cowMinOut = _yield$getCowSwapTxDa.minAmountOut;
29763
30001
  // Tx 1: manager calls submit() directly on TypedStructuredDataValidator (not via pool.execTransaction)
29764
30002
  validatorContract = new ethers.Contract(routerAddress[this.network][dapp], ["function submit(address _poolLogic, uint8 _dataType, bytes memory _structuredData) external"], this.signer);
29765
- _context10.next = 51;
30003
+ _context10.next = 57;
29766
30004
  return validatorContract.submit.apply(validatorContract, [this.address, 1
29767
30005
  /* COWSWAP_ORDER */
29768
30006
  , encodedTypedData].concat(options ? [options] : []));
29769
30007
 
29770
- case 51:
30008
+ case 57:
29771
30009
  submitTx = _context10.sent;
29772
- _context10.next = 54;
30010
+ _context10.next = 60;
29773
30011
  return submitTx.wait(3);
29774
30012
 
29775
- case 54:
30013
+ case 60:
29776
30014
  submitReceipt = _context10.sent;
29777
30015
 
29778
30016
  if (!(submitReceipt.status === 0)) {
29779
- _context10.next = 57;
30017
+ _context10.next = 63;
29780
30018
  break;
29781
30019
  }
29782
30020
 
29783
30021
  return _context10.abrupt("return", submitReceipt);
29784
30022
 
29785
- case 57:
30023
+ case 63:
29786
30024
  return _context10.abrupt("return", getPoolTxOrGasEstimate(this, [gpv2SettlementAddress[this.network], preSignTxData, options, cowMinOut], sdkOptions));
29787
30025
 
29788
- case 58:
30026
+ case 64:
29789
30027
  iUniswapV2Router = new ethers.ethers.utils.Interface(IUniswapV2Router.abi);
29790
- _context10.next = 61;
30028
+ _context10.next = 67;
29791
30029
  return this.utils.getMinAmountOut(dapp, assetFrom, assetTo, amountIn, slippage);
29792
30030
 
29793
- case 61:
30031
+ case 67:
29794
30032
  calculatedMinAmountOut = _context10.sent;
29795
30033
  _context10.t1 = iUniswapV2Router;
29796
30034
  _context10.t2 = exports.Transaction.SWAP;
@@ -29798,23 +30036,23 @@ var Pool = /*#__PURE__*/function () {
29798
30036
  _context10.t4 = calculatedMinAmountOut;
29799
30037
  _context10.t5 = [assetFrom, assetTo];
29800
30038
  _context10.t6 = this.address;
29801
- _context10.next = 70;
30039
+ _context10.next = 76;
29802
30040
  return getDeadline(this);
29803
30041
 
29804
- case 70:
30042
+ case 76:
29805
30043
  _context10.t7 = _context10.sent;
29806
30044
  _context10.t8 = [_context10.t3, _context10.t4, _context10.t5, _context10.t6, _context10.t7];
29807
30045
  swapTxData = _context10.t1.encodeFunctionData.call(_context10.t1, _context10.t2, _context10.t8);
29808
30046
 
29809
- case 73:
29810
- _context10.next = 75;
30047
+ case 79:
30048
+ _context10.next = 81;
29811
30049
  return getPoolTxOrGasEstimate(this, [routerAddress[this.network][dapp], swapTxData, options, minAmountOut], sdkOptions);
29812
30050
 
29813
- case 75:
30051
+ case 81:
29814
30052
  tx = _context10.sent;
29815
30053
  return _context10.abrupt("return", tx);
29816
30054
 
29817
- case 77:
30055
+ case 83:
29818
30056
  case "end":
29819
30057
  return _context10.stop();
29820
30058
  }