@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.
@@ -4593,6 +4593,7 @@ var Dapp;
4593
4593
  Dapp["KYBERSWAP"] = "kyberswap";
4594
4594
  Dapp["HYPERLIQUID"] = "hyperliquid";
4595
4595
  Dapp["COWSWAP"] = "cowswap";
4596
+ Dapp["ONDO"] = "ondo";
4596
4597
  })(Dapp || (Dapp = {}));
4597
4598
  /** Function-name strings used when encoding ABI calls — keep in sync with the
4598
4599
  * matching ABI files in `src/abi/`. */
@@ -4630,7 +4631,7 @@ require("dotenv").config();
4630
4631
  var factoryAddress = (_factoryAddress = {}, _factoryAddress[Network.POLYGON] = process.env.STAGING_CONTRACTS ? "0xDd87eCdB10cFF7004276AAbAbd30e7a08F69bb53" : "0xfdc7b8bFe0DD3513Cc669bB8d601Cb83e2F69cB0", _factoryAddress[Network.OPTIMISM] = "0x5e61a079A178f0E5784107a4963baAe0c5a680c6", _factoryAddress[Network.ARBITRUM] = "0xfffb5fb14606eb3a548c113026355020ddf27535", _factoryAddress[Network.BASE] = "0x49Afe3abCf66CF09Fab86cb1139D8811C8afe56F", _factoryAddress[Network.ETHEREUM] = "0x96D33bCF84DdE326014248E2896F79bbb9c13D6d", _factoryAddress[Network.PLASMA] = "0xAec4975Fc8ad911464D2948D771488b30F6eEE87", _factoryAddress[Network.HYPERLIQUID] = "0xe91505e2ab653dd128c71e9690eeefd28cc5b333", _factoryAddress);
4631
4632
  /** Router/spender address for each (network, Dapp). Target of `pool.approve`/`pool.trade`. */
4632
4633
 
4633
- var routerAddress = (_routerAddress = {}, _routerAddress[Network.POLYGON] = (_Network$POLYGON = {}, _Network$POLYGON[Dapp.SUSHISWAP] = "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506", _Network$POLYGON[Dapp.AAVE] = "0x8dFf5E27EA6b7AC08EbFdf9eB090F32ee9a30fcf", _Network$POLYGON[Dapp.AAVEV3] = "0x794a61358D6845594F94dc1DB02A252b5b4814aD", _Network$POLYGON[Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$POLYGON[Dapp.QUICKSWAP] = "0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff", _Network$POLYGON[Dapp.BALANCER] = "0xBA12222222228d8Ba445958a75a0704d566BF2C8", _Network$POLYGON[Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$POLYGON[Dapp.ARRAKIS] = "0xc73fb100a995b33f9fa181d420f4c8d74506df66", _Network$POLYGON[Dapp.TOROS] = "0x45b90480D6F643dE2f128db091A357C3c90399f2", _Network$POLYGON[Dapp.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$POLYGON[Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$POLYGON[Dapp.COWSWAP] = "0x893223Be4e941fAA8A8DB93D0C097fCac37801ce", _Network$POLYGON), _routerAddress[Network.OPTIMISM] = (_Network$OPTIMISM = {}, _Network$OPTIMISM[Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$OPTIMISM[Dapp.AAVEV3] = "0x794a61358D6845594F94dc1DB02A252b5b4814aD", _Network$OPTIMISM[Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$OPTIMISM[Dapp.TOROS] = "0x2Ed1bd7f66e47113672f3870308b5E867C5bb743", _Network$OPTIMISM[Dapp.VELODROME] = "0x9c12939390052919aF3155f41Bf4160Fd3666A6f", _Network$OPTIMISM[Dapp.VELODROMEV2] = "0xa062ae8a9c5e11aaa026fc2670b0d65ccc8b2858", _Network$OPTIMISM[Dapp.LYRA] = "0xCCE7819d65f348c64B7Beb205BA367b3fE33763B", _Network$OPTIMISM[Dapp.ARRAKIS] = "0x9ce88a56d120300061593eF7AD074A1B710094d5", _Network$OPTIMISM[Dapp.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$OPTIMISM[Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$OPTIMISM[Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$OPTIMISM), _routerAddress[Network.ARBITRUM] = (_Network$ARBITRUM = {}, _Network$ARBITRUM[Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$ARBITRUM[Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$ARBITRUM[Dapp.AAVEV3] = "0x794a61358D6845594F94dc1DB02A252b5b4814aD", _Network$ARBITRUM[Dapp.BALANCER] = "0xBA12222222228d8Ba445958a75a0704d566BF2C8", _Network$ARBITRUM[Dapp.TOROS] = "0xA5679C4272A056Bb83f039961fae7D99C48529F5", _Network$ARBITRUM[Dapp.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$ARBITRUM[Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$ARBITRUM[Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$ARBITRUM), _routerAddress[Network.BASE] = (_Network$BASE = {}, _Network$BASE[Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$BASE[Dapp.AERODROME] = "0xcF77a3Ba9A5CA399B7c97c74d54e5b1Beb874E43", _Network$BASE[Dapp.AAVEV3] = "0xA238Dd80C259a72e81d7e4664a9801593F98d1c5", _Network$BASE[Dapp.TOROS] = "0xf067575Eb60c7587C11e867907AA7284833704d1", _Network$BASE[Dapp.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$BASE[Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$BASE[Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$BASE), _routerAddress[Network.ETHEREUM] = (_Network$ETHEREUM = {}, _Network$ETHEREUM[Dapp.AAVEV3] = "0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2", _Network$ETHEREUM[Dapp.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$ETHEREUM[Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$ETHEREUM[Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$ETHEREUM[Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$ETHEREUM), _routerAddress[Network.PLASMA] = (_Network$PLASMA = {}, _Network$PLASMA[Dapp.AAVEV3] = "0x925a2A7214Ed92428B5b1B090F80b25700095e12", _Network$PLASMA[Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$PLASMA[Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$PLASMA), _routerAddress[Network.HYPERLIQUID] = (_Network$HYPERLIQUID = {}, _Network$HYPERLIQUID[Dapp.HYPERLIQUID] = "0x6b9e773128f453f5c2c60935ee2de2cbc5390a24", _Network$HYPERLIQUID), _routerAddress);
4634
+ var routerAddress = (_routerAddress = {}, _routerAddress[Network.POLYGON] = (_Network$POLYGON = {}, _Network$POLYGON[Dapp.SUSHISWAP] = "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506", _Network$POLYGON[Dapp.AAVE] = "0x8dFf5E27EA6b7AC08EbFdf9eB090F32ee9a30fcf", _Network$POLYGON[Dapp.AAVEV3] = "0x794a61358D6845594F94dc1DB02A252b5b4814aD", _Network$POLYGON[Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$POLYGON[Dapp.QUICKSWAP] = "0xa5E0829CaCEd8fFDD4De3c43696c57F7D7A678ff", _Network$POLYGON[Dapp.BALANCER] = "0xBA12222222228d8Ba445958a75a0704d566BF2C8", _Network$POLYGON[Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$POLYGON[Dapp.ARRAKIS] = "0xc73fb100a995b33f9fa181d420f4c8d74506df66", _Network$POLYGON[Dapp.TOROS] = "0x45b90480D6F643dE2f128db091A357C3c90399f2", _Network$POLYGON[Dapp.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$POLYGON[Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$POLYGON[Dapp.COWSWAP] = "0x893223Be4e941fAA8A8DB93D0C097fCac37801ce", _Network$POLYGON), _routerAddress[Network.OPTIMISM] = (_Network$OPTIMISM = {}, _Network$OPTIMISM[Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$OPTIMISM[Dapp.AAVEV3] = "0x794a61358D6845594F94dc1DB02A252b5b4814aD", _Network$OPTIMISM[Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$OPTIMISM[Dapp.TOROS] = "0x2Ed1bd7f66e47113672f3870308b5E867C5bb743", _Network$OPTIMISM[Dapp.VELODROME] = "0x9c12939390052919aF3155f41Bf4160Fd3666A6f", _Network$OPTIMISM[Dapp.VELODROMEV2] = "0xa062ae8a9c5e11aaa026fc2670b0d65ccc8b2858", _Network$OPTIMISM[Dapp.LYRA] = "0xCCE7819d65f348c64B7Beb205BA367b3fE33763B", _Network$OPTIMISM[Dapp.ARRAKIS] = "0x9ce88a56d120300061593eF7AD074A1B710094d5", _Network$OPTIMISM[Dapp.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$OPTIMISM[Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$OPTIMISM[Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$OPTIMISM), _routerAddress[Network.ARBITRUM] = (_Network$ARBITRUM = {}, _Network$ARBITRUM[Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$ARBITRUM[Dapp.UNISWAPV3] = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", _Network$ARBITRUM[Dapp.AAVEV3] = "0x794a61358D6845594F94dc1DB02A252b5b4814aD", _Network$ARBITRUM[Dapp.BALANCER] = "0xBA12222222228d8Ba445958a75a0704d566BF2C8", _Network$ARBITRUM[Dapp.TOROS] = "0xA5679C4272A056Bb83f039961fae7D99C48529F5", _Network$ARBITRUM[Dapp.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$ARBITRUM[Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$ARBITRUM[Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$ARBITRUM), _routerAddress[Network.BASE] = (_Network$BASE = {}, _Network$BASE[Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$BASE[Dapp.AERODROME] = "0xcF77a3Ba9A5CA399B7c97c74d54e5b1Beb874E43", _Network$BASE[Dapp.AAVEV3] = "0xA238Dd80C259a72e81d7e4664a9801593F98d1c5", _Network$BASE[Dapp.TOROS] = "0xf067575Eb60c7587C11e867907AA7284833704d1", _Network$BASE[Dapp.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$BASE[Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$BASE[Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$BASE), _routerAddress[Network.ETHEREUM] = (_Network$ETHEREUM = {}, _Network$ETHEREUM[Dapp.AAVEV3] = "0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2", _Network$ETHEREUM[Dapp.ODOS] = "0x0D05a7D3448512B78fa8A9e46c4872C88C4a0D05", _Network$ETHEREUM[Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$ETHEREUM[Dapp.ONEINCH] = "0x111111125421ca6dc452d289314280a0f8842a65", _Network$ETHEREUM[Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$ETHEREUM[Dapp.ONDO] = "0xde41399145F23936b03dD1474eC16c1519c0DC2a", _Network$ETHEREUM), _routerAddress[Network.PLASMA] = (_Network$PLASMA = {}, _Network$PLASMA[Dapp.AAVEV3] = "0x925a2A7214Ed92428B5b1B090F80b25700095e12", _Network$PLASMA[Dapp.PENDLE] = "0x888888888889758F76e7103c6CbF23ABbF58F946", _Network$PLASMA[Dapp.KYBERSWAP] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5", _Network$PLASMA), _routerAddress[Network.HYPERLIQUID] = (_Network$HYPERLIQUID = {}, _Network$HYPERLIQUID[Dapp.HYPERLIQUID] = "0x6b9e773128f453f5c2c60935ee2de2cbc5390a24", _Network$HYPERLIQUID), _routerAddress);
4634
4635
  /** CoW Protocol GPv2Settlement address per network (where pre-signed orders are submitted). */
4635
4636
 
4636
4637
  var gpv2SettlementAddress = (_gpv2SettlementAddres = {}, _gpv2SettlementAddres[Network.POLYGON] = "0x9008D19f58AAbD9eD0D60971565AA8510560ab41", _gpv2SettlementAddres);
@@ -28540,6 +28541,233 @@ function _getCowSwapTxData() {
28540
28541
  return _getCowSwapTxData.apply(this, arguments);
28541
28542
  }
28542
28543
 
28544
+ var IOndoGMSwap = [
28545
+ {
28546
+ inputs: [
28547
+ {
28548
+ name: "tokenIn",
28549
+ type: "address"
28550
+ },
28551
+ {
28552
+ name: "amountIn",
28553
+ type: "uint256"
28554
+ },
28555
+ {
28556
+ name: "tokenOut",
28557
+ type: "address"
28558
+ },
28559
+ {
28560
+ name: "amountOutMinimum",
28561
+ type: "uint256"
28562
+ },
28563
+ {
28564
+ name: "attestationSignature",
28565
+ type: "bytes"
28566
+ },
28567
+ {
28568
+ components: [
28569
+ {
28570
+ name: "chainId",
28571
+ type: "uint256"
28572
+ },
28573
+ {
28574
+ name: "attestationId",
28575
+ type: "uint256"
28576
+ },
28577
+ {
28578
+ name: "userId",
28579
+ type: "bytes32"
28580
+ },
28581
+ {
28582
+ name: "asset",
28583
+ type: "address"
28584
+ },
28585
+ {
28586
+ name: "price",
28587
+ type: "uint256"
28588
+ },
28589
+ {
28590
+ name: "quantity",
28591
+ type: "uint256"
28592
+ },
28593
+ {
28594
+ name: "expiration",
28595
+ type: "uint256"
28596
+ },
28597
+ {
28598
+ name: "side",
28599
+ type: "uint8"
28600
+ },
28601
+ {
28602
+ name: "additionalData",
28603
+ type: "bytes32"
28604
+ }
28605
+ ],
28606
+ name: "quote",
28607
+ type: "tuple"
28608
+ }
28609
+ ],
28610
+ name: "swapExactInWithAttestation",
28611
+ outputs: [
28612
+ ],
28613
+ stateMutability: "nonpayable",
28614
+ type: "function"
28615
+ }
28616
+ ];
28617
+
28618
+ var ONDO_API_URL = "https://api.gm.ondo.finance/v1/attestations"; // Ethereum mainnet USDC — Ondo is Ethereum-only
28619
+
28620
+ var USDC_ETHEREUM = "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48";
28621
+ var iface$1 = /*#__PURE__*/new ethers.utils.Interface(IOndoGMSwap); // Ondo returns userId as a left-aligned 32-byte hex (significant bytes first,
28622
+ // e.g. 0x474d...0000), so right-pad to preserve byte order and fix it to 32 bytes.
28623
+
28624
+ function toBytes32(s) {
28625
+ var hex = s.startsWith("0x") ? s.slice(2) : s;
28626
+ return "0x" + hex.padEnd(64, "0").slice(0, 64);
28627
+ }
28628
+
28629
+ function postOndoAttestation(_x, _x2, _x3, _x4) {
28630
+ return _postOndoAttestation.apply(this, arguments);
28631
+ }
28632
+
28633
+ function _postOndoAttestation() {
28634
+ _postOndoAttestation = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(symbol, side, amount, apiKey) {
28635
+ var _yield$axios$post, data, _error$response$data, _ref, code, message;
28636
+
28637
+ return runtime_1.wrap(function _callee$(_context) {
28638
+ while (1) {
28639
+ switch (_context.prev = _context.next) {
28640
+ case 0:
28641
+ _context.prev = 0;
28642
+ _context.next = 3;
28643
+ return axios.post(ONDO_API_URL, _extends({
28644
+ chainId: "ethereum-1",
28645
+ symbol: symbol,
28646
+ side: side
28647
+ }, amount, {
28648
+ duration: "short"
28649
+ }), {
28650
+ headers: {
28651
+ "x-api-key": apiKey
28652
+ }
28653
+ });
28654
+
28655
+ case 3:
28656
+ _yield$axios$post = _context.sent;
28657
+ data = _yield$axios$post.data;
28658
+ return _context.abrupt("return", data);
28659
+
28660
+ case 8:
28661
+ _context.prev = 8;
28662
+ _context.t0 = _context["catch"](0);
28663
+
28664
+ if (!(axios.isAxiosError(_context.t0) && _context.t0.response)) {
28665
+ _context.next = 13;
28666
+ break;
28667
+ }
28668
+
28669
+ _ref = (_error$response$data = _context.t0.response.data) != null ? _error$response$data : {}, code = _ref.code, message = _ref.message;
28670
+ throw new ApiError(("Ondo attestation request failed (" + _context.t0.response.status + "): " + (code != null ? code : "") + " " + (message != null ? message : JSON.stringify(_context.t0.response.data))).trim());
28671
+
28672
+ case 13:
28673
+ throw new ApiError("Ondo attestation request failed: " + (_context.t0 instanceof Error ? _context.t0.message : String(_context.t0)));
28674
+
28675
+ case 14:
28676
+ case "end":
28677
+ return _context.stop();
28678
+ }
28679
+ }
28680
+ }, _callee, null, [[0, 8]]);
28681
+ }));
28682
+ return _postOndoAttestation.apply(this, arguments);
28683
+ }
28684
+
28685
+ function getOndoSwapTxData(_x5, _x6, _x7, _x8, _x9) {
28686
+ return _getOndoSwapTxData.apply(this, arguments);
28687
+ }
28688
+
28689
+ function _getOndoSwapTxData() {
28690
+ _getOndoSwapTxData = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(pool, tokenIn, tokenOut, amountIn, slippage) {
28691
+ var apiKey, amount, isMint, gmToken, slippageBps, tokenContract, symbol, attestationAmount, attestation, signature, additionalData, quantity, priceD18, minAmountOut, usdcOut, quote, swapTxData;
28692
+ return runtime_1.wrap(function _callee2$(_context2) {
28693
+ while (1) {
28694
+ switch (_context2.prev = _context2.next) {
28695
+ case 0:
28696
+ apiKey = process.env.ONDO_API_KEY;
28697
+
28698
+ if (apiKey) {
28699
+ _context2.next = 3;
28700
+ break;
28701
+ }
28702
+
28703
+ throw new Error("ONDO_API_KEY environment variable is not set");
28704
+
28705
+ case 3:
28706
+ amount = new BigNumber(amountIn);
28707
+ isMint = tokenIn.toLowerCase() === USDC_ETHEREUM.toLowerCase();
28708
+ gmToken = isMint ? tokenOut : tokenIn;
28709
+ slippageBps = Math.round(slippage * 100);
28710
+ tokenContract = new ethers.Contract(gmToken, ["function symbol() view returns (string)"], pool.signer);
28711
+ _context2.next = 10;
28712
+ return tokenContract.symbol();
28713
+
28714
+ case 10:
28715
+ symbol = _context2.sent;
28716
+ // For mint: notionalValue is the USD amount to subscribe. USDonManager values
28717
+ // USDC at par (1 USDC = 1 USDon), so pass the USDC amount as-is (6dp -> decimal).
28718
+ // Discounting by a USDC market price would strand the gap as USDon in the swapper
28719
+ // (and revert via ExcessiveAmountIn once it exceeds the 1 USDC tolerance).
28720
+ // For redeem: pass the GM token amount directly as tokenAmount.
28721
+ attestationAmount = isMint ? {
28722
+ notionalValue: amount.div(1e6).toFixed(18)
28723
+ } : {
28724
+ tokenAmount: amount.div(1e18).toFixed(18)
28725
+ };
28726
+ _context2.next = 14;
28727
+ return postOndoAttestation(symbol, isMint ? "buy" : "sell", attestationAmount, apiKey);
28728
+
28729
+ case 14:
28730
+ attestation = _context2.sent;
28731
+ signature = "0x" + Buffer.from(attestation.signature, "base64").toString("hex");
28732
+ additionalData = ethers.utils.hexZeroPad("0x" + Buffer.from(attestation.additionalData, "base64").toString("hex"), 32);
28733
+ quantity = new BigNumber(attestation.tokenAmount);
28734
+ priceD18 = new BigNumber(attestation.price);
28735
+
28736
+ if (isMint) {
28737
+ minAmountOut = quantity.times(10000 - slippageBps).div(10000);
28738
+ } else {
28739
+ // USDC out (6 dec) = quantity_D18 * price_D18 / 1e30
28740
+ usdcOut = quantity.times(priceD18).div(1e30);
28741
+ minAmountOut = usdcOut.times(10000 - slippageBps).div(10000);
28742
+ }
28743
+
28744
+ quote = {
28745
+ chainId: 1,
28746
+ attestationId: attestation.attestationId,
28747
+ userId: toBytes32(attestation.userId),
28748
+ asset: attestation.assetAddress,
28749
+ price: priceD18.toFixed(0),
28750
+ quantity: quantity.toFixed(0),
28751
+ expiration: attestation.expiration,
28752
+ side: Number(attestation.side),
28753
+ additionalData: additionalData
28754
+ };
28755
+ swapTxData = iface$1.encodeFunctionData("swapExactInWithAttestation", [tokenIn, amount.toFixed(0), tokenOut, minAmountOut.toFixed(0), signature, quote]);
28756
+ return _context2.abrupt("return", {
28757
+ swapTxData: swapTxData,
28758
+ minAmountOut: minAmountOut.toFixed(0)
28759
+ });
28760
+
28761
+ case 23:
28762
+ case "end":
28763
+ return _context2.stop();
28764
+ }
28765
+ }
28766
+ }, _callee2);
28767
+ }));
28768
+ return _getOndoSwapTxData.apply(this, arguments);
28769
+ }
28770
+
28543
28771
  var ICoreDepositWalletAbi = [
28544
28772
  {
28545
28773
  inputs: [
@@ -29664,7 +29892,7 @@ var Pool = /*#__PURE__*/function () {
29664
29892
  /*#__PURE__*/
29665
29893
  function () {
29666
29894
  var _trade = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(dapp, assetFrom, assetTo, amountIn, slippage, options, sdkOptions) {
29667
- var swapTxData, minAmountOut, _yield$getOneInchSwap, _yield$getOdosSwapTxD, _yield$getPendleSwapT, _yield$getKyberSwapTx, cowSwapEstimateGas, _yield$getCowSwapTxDa, encodedTypedData, preSignTxData, cowMinOut, validatorContract, submitTx, submitReceipt, iUniswapV2Router, calculatedMinAmountOut, tx;
29895
+ 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;
29668
29896
 
29669
29897
  return runtime_1.wrap(function _callee10$(_context10) {
29670
29898
  while (1) {
@@ -29686,7 +29914,7 @@ var Pool = /*#__PURE__*/function () {
29686
29914
 
29687
29915
  minAmountOut = null;
29688
29916
  _context10.t0 = dapp;
29689
- _context10.next = _context10.t0 === Dapp.ONEINCH ? 7 : _context10.t0 === Dapp.BALANCER ? 13 : _context10.t0 === Dapp.TOROS ? 17 : _context10.t0 === Dapp.ODOS ? 21 : _context10.t0 === Dapp.PENDLE ? 27 : _context10.t0 === Dapp.KYBERSWAP ? 33 : _context10.t0 === Dapp.COWSWAP ? 39 : 58;
29917
+ _context10.next = _context10.t0 === Dapp.ONEINCH ? 7 : _context10.t0 === Dapp.BALANCER ? 13 : _context10.t0 === Dapp.TOROS ? 17 : _context10.t0 === Dapp.ODOS ? 21 : _context10.t0 === Dapp.PENDLE ? 27 : _context10.t0 === Dapp.KYBERSWAP ? 33 : _context10.t0 === Dapp.ONDO ? 39 : _context10.t0 === Dapp.COWSWAP ? 45 : 64;
29690
29918
  break;
29691
29919
 
29692
29920
  case 7:
@@ -29697,7 +29925,7 @@ var Pool = /*#__PURE__*/function () {
29697
29925
  _yield$getOneInchSwap = _context10.sent;
29698
29926
  swapTxData = _yield$getOneInchSwap.swapTxData;
29699
29927
  minAmountOut = _yield$getOneInchSwap.dstAmount;
29700
- return _context10.abrupt("break", 73);
29928
+ return _context10.abrupt("break", 79);
29701
29929
 
29702
29930
  case 13:
29703
29931
  _context10.next = 15;
@@ -29705,7 +29933,7 @@ var Pool = /*#__PURE__*/function () {
29705
29933
 
29706
29934
  case 15:
29707
29935
  swapTxData = _context10.sent;
29708
- return _context10.abrupt("break", 73);
29936
+ return _context10.abrupt("break", 79);
29709
29937
 
29710
29938
  case 17:
29711
29939
  _context10.next = 19;
@@ -29713,7 +29941,7 @@ var Pool = /*#__PURE__*/function () {
29713
29941
 
29714
29942
  case 19:
29715
29943
  swapTxData = _context10.sent;
29716
- return _context10.abrupt("break", 73);
29944
+ return _context10.abrupt("break", 79);
29717
29945
 
29718
29946
  case 21:
29719
29947
  _context10.next = 23;
@@ -29723,7 +29951,7 @@ var Pool = /*#__PURE__*/function () {
29723
29951
  _yield$getOdosSwapTxD = _context10.sent;
29724
29952
  swapTxData = _yield$getOdosSwapTxD.swapTxData;
29725
29953
  minAmountOut = _yield$getOdosSwapTxD.minAmountOut;
29726
- return _context10.abrupt("break", 73);
29954
+ return _context10.abrupt("break", 79);
29727
29955
 
29728
29956
  case 27:
29729
29957
  _context10.next = 29;
@@ -29733,7 +29961,7 @@ var Pool = /*#__PURE__*/function () {
29733
29961
  _yield$getPendleSwapT = _context10.sent;
29734
29962
  swapTxData = _yield$getPendleSwapT.swapTxData;
29735
29963
  minAmountOut = _yield$getPendleSwapT.minAmountOut;
29736
- return _context10.abrupt("break", 73);
29964
+ return _context10.abrupt("break", 79);
29737
29965
 
29738
29966
  case 33:
29739
29967
  _context10.next = 35;
@@ -29743,58 +29971,68 @@ var Pool = /*#__PURE__*/function () {
29743
29971
  _yield$getKyberSwapTx = _context10.sent;
29744
29972
  swapTxData = _yield$getKyberSwapTx.swapTxData;
29745
29973
  minAmountOut = _yield$getKyberSwapTx.minAmountOut;
29746
- return _context10.abrupt("break", 73);
29974
+ return _context10.abrupt("break", 79);
29747
29975
 
29748
29976
  case 39:
29977
+ _context10.next = 41;
29978
+ return getOndoSwapTxData(this, assetFrom, assetTo, amountIn.toString(), slippage);
29979
+
29980
+ case 41:
29981
+ _yield$getOndoSwapTxD = _context10.sent;
29982
+ swapTxData = _yield$getOndoSwapTxD.swapTxData;
29983
+ minAmountOut = _yield$getOndoSwapTxD.minAmountOut;
29984
+ return _context10.abrupt("break", 79);
29985
+
29986
+ case 45:
29749
29987
  cowSwapEstimateGas = isSdkOptionsBoolean(sdkOptions) ? sdkOptions : sdkOptions.estimateGas;
29750
29988
 
29751
29989
  if (!(cowSwapEstimateGas || !isSdkOptionsBoolean(sdkOptions) && sdkOptions.onlyGetTxData)) {
29752
- _context10.next = 42;
29990
+ _context10.next = 48;
29753
29991
  break;
29754
29992
  }
29755
29993
 
29756
29994
  throw new Error("CowSwap requires two sequential transactions (submit + preSign) and does not support estimateGas or onlyGetTxData");
29757
29995
 
29758
- case 42:
29759
- _context10.next = 44;
29996
+ case 48:
29997
+ _context10.next = 50;
29760
29998
  return getCowSwapTxData(this, assetFrom, assetTo, amountIn, slippage);
29761
29999
 
29762
- case 44:
30000
+ case 50:
29763
30001
  _yield$getCowSwapTxDa = _context10.sent;
29764
30002
  encodedTypedData = _yield$getCowSwapTxDa.encodedTypedData;
29765
30003
  preSignTxData = _yield$getCowSwapTxDa.preSignTxData;
29766
30004
  cowMinOut = _yield$getCowSwapTxDa.minAmountOut;
29767
30005
  // Tx 1: manager calls submit() directly on TypedStructuredDataValidator (not via pool.execTransaction)
29768
30006
  validatorContract = new Contract(routerAddress[this.network][dapp], ["function submit(address _poolLogic, uint8 _dataType, bytes memory _structuredData) external"], this.signer);
29769
- _context10.next = 51;
30007
+ _context10.next = 57;
29770
30008
  return validatorContract.submit.apply(validatorContract, [this.address, 1
29771
30009
  /* COWSWAP_ORDER */
29772
30010
  , encodedTypedData].concat(options ? [options] : []));
29773
30011
 
29774
- case 51:
30012
+ case 57:
29775
30013
  submitTx = _context10.sent;
29776
- _context10.next = 54;
30014
+ _context10.next = 60;
29777
30015
  return submitTx.wait(3);
29778
30016
 
29779
- case 54:
30017
+ case 60:
29780
30018
  submitReceipt = _context10.sent;
29781
30019
 
29782
30020
  if (!(submitReceipt.status === 0)) {
29783
- _context10.next = 57;
30021
+ _context10.next = 63;
29784
30022
  break;
29785
30023
  }
29786
30024
 
29787
30025
  return _context10.abrupt("return", submitReceipt);
29788
30026
 
29789
- case 57:
30027
+ case 63:
29790
30028
  return _context10.abrupt("return", getPoolTxOrGasEstimate(this, [gpv2SettlementAddress[this.network], preSignTxData, options, cowMinOut], sdkOptions));
29791
30029
 
29792
- case 58:
30030
+ case 64:
29793
30031
  iUniswapV2Router = new ethers.utils.Interface(IUniswapV2Router.abi);
29794
- _context10.next = 61;
30032
+ _context10.next = 67;
29795
30033
  return this.utils.getMinAmountOut(dapp, assetFrom, assetTo, amountIn, slippage);
29796
30034
 
29797
- case 61:
30035
+ case 67:
29798
30036
  calculatedMinAmountOut = _context10.sent;
29799
30037
  _context10.t1 = iUniswapV2Router;
29800
30038
  _context10.t2 = Transaction.SWAP;
@@ -29802,23 +30040,23 @@ var Pool = /*#__PURE__*/function () {
29802
30040
  _context10.t4 = calculatedMinAmountOut;
29803
30041
  _context10.t5 = [assetFrom, assetTo];
29804
30042
  _context10.t6 = this.address;
29805
- _context10.next = 70;
30043
+ _context10.next = 76;
29806
30044
  return getDeadline(this);
29807
30045
 
29808
- case 70:
30046
+ case 76:
29809
30047
  _context10.t7 = _context10.sent;
29810
30048
  _context10.t8 = [_context10.t3, _context10.t4, _context10.t5, _context10.t6, _context10.t7];
29811
30049
  swapTxData = _context10.t1.encodeFunctionData.call(_context10.t1, _context10.t2, _context10.t8);
29812
30050
 
29813
- case 73:
29814
- _context10.next = 75;
30051
+ case 79:
30052
+ _context10.next = 81;
29815
30053
  return getPoolTxOrGasEstimate(this, [routerAddress[this.network][dapp], swapTxData, options, minAmountOut], sdkOptions);
29816
30054
 
29817
- case 75:
30055
+ case 81:
29818
30056
  tx = _context10.sent;
29819
30057
  return _context10.abrupt("return", tx);
29820
30058
 
29821
- case 77:
30059
+ case 83:
29822
30060
  case "end":
29823
30061
  return _context10.stop();
29824
30062
  }