UNPKG

@dolomite-exchange/dolomite-margin

Version:

Ethereum Smart Contracts and TypeScript library used for the DolomiteMargin trading protocol

749 lines 122 kB
{ "contractName": "IGenericTraderProxyV1", "abi": [ { "constant": false, "inputs": [ { "internalType": "uint256", "name": "_tradeAccountNumber", "type": "uint256" }, { "internalType": "uint256[]", "name": "_marketIdsPath", "type": "uint256[]" }, { "internalType": "uint256", "name": "_inputAmountWei", "type": "uint256" }, { "internalType": "uint256", "name": "_minOutputAmountWei", "type": "uint256" }, { "components": [ { "internalType": "enum IGenericTraderProxyBase.TraderType", "name": "traderType", "type": "uint8" }, { "internalType": "uint256", "name": "makerAccountIndex", "type": "uint256" }, { "internalType": "address", "name": "trader", "type": "address" }, { "internalType": "bytes", "name": "tradeData", "type": "bytes" } ], "internalType": "struct IGenericTraderProxyBase.TraderParam[]", "name": "_tradersPath", "type": "tuple[]" }, { "components": [ { "internalType": "address", "name": "owner", "type": "address" }, { "internalType": "uint256", "name": "number", "type": "uint256" } ], "internalType": "struct Account.Info[]", "name": "_makerAccounts", "type": "tuple[]" }, { "components": [ { "internalType": "uint256", "name": "deadline", "type": "uint256" }, { "internalType": "enum AccountBalanceLib.BalanceCheckFlag", "name": "balanceCheckFlag", "type": "uint8" }, { "internalType": "enum IGenericTraderProxyV1.EventEmissionType", "name": "eventType", "type": "uint8" } ], "internalType": "struct IGenericTraderProxyV1.UserConfig", "name": "_userConfig", "type": "tuple" } ], "name": "swapExactInputForOutput", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [ { "internalType": "uint256", "name": "_tradeAccountNumber", "type": "uint256" }, { "internalType": "uint256[]", "name": "_marketIdsPath", "type": "uint256[]" }, { "internalType": "uint256", "name": "_inputAmountWei", "type": "uint256" }, { "internalType": "uint256", "name": "_minOutputAmountWei", "type": "uint256" }, { "components": [ { "internalType": "enum IGenericTraderProxyBase.TraderType", "name": "traderType", "type": "uint8" }, { "internalType": "uint256", "name": "makerAccountIndex", "type": "uint256" }, { "internalType": "address", "name": "trader", "type": "address" }, { "internalType": "bytes", "name": "tradeData", "type": "bytes" } ], "internalType": "struct IGenericTraderProxyBase.TraderParam[]", "name": "_tradersPath", "type": "tuple[]" }, { "components": [ { "internalType": "address", "name": "owner", "type": "address" }, { "internalType": "uint256", "name": "number", "type": "uint256" } ], "internalType": "struct Account.Info[]", "name": "_makerAccounts", "type": "tuple[]" }, { "components": [ { "internalType": "uint256", "name": "fromAccountNumber", "type": "uint256" }, { "internalType": "uint256", "name": "toAccountNumber", "type": "uint256" }, { "components": [ { "internalType": "uint256", "name": "marketId", "type": "uint256" }, { "internalType": "uint256", "name": "amountWei", "type": "uint256" } ], "internalType": "struct IGenericTraderProxyV1.TransferAmount[]", "name": "transferAmounts", "type": "tuple[]" } ], "internalType": "struct IGenericTraderProxyV1.TransferCollateralParam", "name": "_transferCollateralParams", "type": "tuple" }, { "components": [ { "internalType": "uint256", "name": "marketId", "type": "uint256" }, { "internalType": "uint32", "name": "expiryTimeDelta", "type": "uint32" } ], "internalType": "struct IGenericTraderProxyV1.ExpiryParam", "name": "_expiryParams", "type": "tuple" }, { "components": [ { "internalType": "uint256", "name": "deadline", "type": "uint256" }, { "internalType": "enum AccountBalanceLib.BalanceCheckFlag", "name": "balanceCheckFlag", "type": "uint8" }, { "internalType": "enum IGenericTraderProxyV1.EventEmissionType", "name": "eventType", "type": "uint8" } ], "internalType": "struct IGenericTraderProxyV1.UserConfig", "name": "_userConfig", "type": "tuple" } ], "name": "swapExactInputForOutputAndModifyPosition", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" } ], "metadata": "{\"compiler\":{\"version\":\"0.5.16+commit.9c3226ce\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_tradeAccountNumber\",\"type\":\"uint256\"},{\"internalType\":\"uint256[]\",\"name\":\"_marketIdsPath\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256\",\"name\":\"_inputAmountWei\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_minOutputAmountWei\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"enum IGenericTraderProxyBase.TraderType\",\"name\":\"traderType\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"makerAccountIndex\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"trader\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"tradeData\",\"type\":\"bytes\"}],\"internalType\":\"struct IGenericTraderProxyBase.TraderParam[]\",\"name\":\"_tradersPath\",\"type\":\"tuple[]\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"number\",\"type\":\"uint256\"}],\"internalType\":\"struct Account.Info[]\",\"name\":\"_makerAccounts\",\"type\":\"tuple[]\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"enum AccountBalanceLib.BalanceCheckFlag\",\"name\":\"balanceCheckFlag\",\"type\":\"uint8\"},{\"internalType\":\"enum IGenericTraderProxyV1.EventEmissionType\",\"name\":\"eventType\",\"type\":\"uint8\"}],\"internalType\":\"struct IGenericTraderProxyV1.UserConfig\",\"name\":\"_userConfig\",\"type\":\"tuple\"}],\"name\":\"swapExactInputForOutput\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_tradeAccountNumber\",\"type\":\"uint256\"},{\"internalType\":\"uint256[]\",\"name\":\"_marketIdsPath\",\"type\":\"uint256[]\"},{\"internalType\":\"uint256\",\"name\":\"_inputAmountWei\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_minOutputAmountWei\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"enum IGenericTraderProxyBase.TraderType\",\"name\":\"traderType\",\"type\":\"uint8\"},{\"internalType\":\"uint256\",\"name\":\"makerAccountIndex\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"trader\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"tradeData\",\"type\":\"bytes\"}],\"internalType\":\"struct IGenericTraderProxyBase.TraderParam[]\",\"name\":\"_tradersPath\",\"type\":\"tuple[]\"},{\"components\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"number\",\"type\":\"uint256\"}],\"internalType\":\"struct Account.Info[]\",\"name\":\"_makerAccounts\",\"type\":\"tuple[]\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"fromAccountNumber\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"toAccountNumber\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amountWei\",\"type\":\"uint256\"}],\"internalType\":\"struct IGenericTraderProxyV1.TransferAmount[]\",\"name\":\"transferAmounts\",\"type\":\"tuple[]\"}],\"internalType\":\"struct IGenericTraderProxyV1.TransferCollateralParam\",\"name\":\"_transferCollateralParams\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"marketId\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"expiryTimeDelta\",\"type\":\"uint32\"}],\"internalType\":\"struct IGenericTraderProxyV1.ExpiryParam\",\"name\":\"_expiryParams\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"enum AccountBalanceLib.BalanceCheckFlag\",\"name\":\"balanceCheckFlag\",\"type\":\"uint8\"},{\"internalType\":\"enum IGenericTraderProxyV1.EventEmissionType\",\"name\":\"eventType\",\"type\":\"uint8\"}],\"internalType\":\"struct IGenericTraderProxyV1.UserConfig\",\"name\":\"_userConfig\",\"type\":\"tuple\"}],\"name\":\"swapExactInputForOutputAndModifyPosition\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"author\":\"Dolomite * Trader proxy interface for trading assets using any trader from msg.sender\",\"methods\":{\"swapExactInputForOutput(uint256,uint256[],uint256,uint256,(uint8,uint256,address,bytes)[],(address,uint256)[],(uint256,uint8,uint8))\":{\"details\":\"Swaps an exact amount of input (specified in the `_amountWeisPath[0]` parameter) for at least `_amountWeisPath[_amountWeisPath.length - 1]` of output.\",\"params\":{\"_inputAmountWei\":\"The input amount (in wei) to use for the initial trade action. Setting this value to `uint(-1)` will use the user's full balance.\",\"_makerAccounts\":\"The accounts that will be used for the maker side of the trades involving `TraderType.InternalLiquidity`.\",\"_marketIdsPath\":\"The path of market IDs to use for each trade action. Length should be equal to `_tradersPath.length + 1`.\",\"_minOutputAmountWei\":\"The minimum output amount expected to be received by the user.\",\"_tradeAccountNumber\":\"The account number to use for msg.sender's trade\",\"_tradersPath\":\"The path of traders to use for each trade action. Length should be equal to `_marketIdsPath.length - 1` and `_amountWeisPath.length - 1`.\",\"_userConfig\":\"The user configuration for the trade. Setting the `balanceCheckFlag` to `BalanceCheckFlag.From` will check that the user's `_tradeAccountNumber` is non-negative after the trade. Setting the `balanceCheckFlag` to `BalanceCheckFlag.To` has no effect.\"}},\"swapExactInputForOutputAndModifyPosition(uint256,uint256[],uint256,uint256,(uint8,uint256,address,bytes)[],(address,uint256)[],(uint256,uint256,(uint256,uint256)[]),(uint256,uint32),(uint256,uint8,uint8))\":{\"details\":\"The same function as `swapExactInputForOutput`, but allows the caller transfer collateral and modify their position's expiration in the same transaction.\",\"params\":{\"_expiryParams\":\"The parameters for modifying the expiration of the debt in the position.\",\"_inputAmountWei\":\"The input amount (in wei) to use for the initial trade action. Setting this value to `uint(-1)` will use the user's full balance.\",\"_makerAccounts\":\"The accounts that will be used for the maker side of the trades involving `TraderType.InternalLiquidity`.\",\"_marketIdsPath\":\"The path of market IDs to use for each trade action. Length should be equal to `_tradersPath.length + 1`.\",\"_minOutputAmountWei\":\"The minimum output amount expected to be received by the user.\",\"_tradeAccountNumber\":\"The account number to use for msg.sender's trade\",\"_tradersPath\":\"The path of traders to use for each trade action. Length should be equal to `_marketIdsPath.length - 1` and `_amountWeisPath.length - 1`.\",\"_transferCollateralParams\":\"The parameters for transferring collateral in/out of the `_tradeAccountNumber` once the trades settle. One of `_params.fromAccountNumber` or `_params.toAccountNumber` must be equal to `_tradeAccountNumber`.\",\"_userConfig\":\"The user configuration for the trade. Setting the `balanceCheckFlag` to `BalanceCheckFlag.From` will check that the user's balance for inputMarket for `_tradeAccountNumber` is non-negative after the trade. Setting the `balanceCheckFlag` to `BalanceCheckFlag.To` will check that the user's balance for each `transferMarket` for `transferAccountNumber` is non-negative after.\"}}},\"title\":\"IGenericTraderProxyV1\"},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/external/interfaces/IGenericTraderProxyV1.sol\":\"IGenericTraderProxyV1\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/external/interfaces/IEventEmitterRegistry.sol\":{\"keccak256\":\"0x51ae058dafa3850ba14ea352c637af48e213c4b4e69e4d398b84ec6fed91d309\",\"urls\":[\"bzz-raw://974dda23508e2d7428433db7fb280c1bc82e197fd68f9d425c57f7bf57fdf82f\",\"dweb:/ipfs/QmeTteQN1tMXChaQ4nzBvLpndVfghaoznsQDM8kAqgDeF9\"]},\"/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/external/interfaces/IGenericTraderProxyBase.sol\":{\"keccak256\":\"0x2ac2830618b13f412f53c803cb8c5e79f1ea1a7da0767fb0c6430a3435153f6f\",\"urls\":[\"bzz-raw://5e128520cdac823bc7dbe5331708c650d9a4ad6a18ec3bb7d9e8739f8360cfc0\",\"dweb:/ipfs/QmcDcrnMcXUGm7NT3q6Z4idFzqcNZukrwHn5GjX44u5Win\"]},\"/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/external/interfaces/IGenericTraderProxyV1.sol\":{\"keccak256\":\"0x8341482eb0ed7eb1f81ff64556f8e2f60b4d4cd38e24aa025ec42658d1bb15c0\",\"urls\":[\"bzz-raw://75762d5b991aee081933f13fa4faf534cdcd97a68772c7c648e25132966c2847\",\"dweb:/ipfs/QmbCBqS2cmBCfyJWXDBtcnjJ7RsbUwXvuRrbSE1ny7DakH\"]},\"/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/external/lib/AccountBalanceLib.sol\":{\"keccak256\":\"0x76fd16d615fe7cfceaf775b4e6524fd0462606c802b082498c768a7a4ca01a20\",\"urls\":[\"bzz-raw://56068145e300cde1c77c22e38cb753378abf2f0d4613dcb203e33ff101f169e2\",\"dweb:/ipfs/QmXvMzr9n7vzMHdUPgnc58KX4mrbQAqkq4kDETaj5Y55ZY\"]},\"/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/interfaces/IAccountRiskOverrideSetter.sol\":{\"keccak256\":\"0x5b9fde139ddfdaae7b650b3c3f6699e0e44605f0d9d3daadc1622eb06ad4c3f8\",\"urls\":[\"bzz-raw://2dfd5af24b6de63f94519c99fd8777a264d7cd11266fa2d525c7d72d96a9c7cf\",\"dweb:/ipfs/QmPg9fjhbnmBayZMh6yTG79xsK1PWSoAHA5pfwSXfnKKjF\"]},\"/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/interfaces/IDolomiteMargin.sol\":{\"keccak256\":\"0x7e86ed1ed04dc205245db9f4e7cf7cca60c3bfc46c57ade8129a463780647967\",\"urls\":[\"bzz-raw://f8fbd85afd334c12bdccbb6523ebea9172b27b7b4b132c4a48b4b4dd03ceeb2b\",\"dweb:/ipfs/QmU1srfSqBTz3kw7oz1KEzfTUJvphZiE4K8MRZcy9uJjv1\"]},\"/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/interfaces/IERC20Detailed.sol\":{\"keccak256\":\"0x22a62e2a8155e70300773721902f4b9118e17aa0bb5d9d1b046050a014cfb223\",\"urls\":[\"bzz-raw://03af737a33c552fbe58f6f1fbd5496854fdc28dd57be4365d56663725c083a18\",\"dweb:/ipfs/QmbgLqGAQEd6tXsZB8QaPNCAMiU6nNzP75wNbKdS65BuUF\"]},\"/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/interfaces/IInterestSetter.sol\":{\"keccak256\":\"0x546825f65490a30e29d0f6446acec49c1e895ce6b33d48ca5c05092725a63a57\",\"urls\":[\"bzz-raw://6ad3013aed985bdf6e6234ae0f7f37e6bba76c3470c33bfa24678cf19b3b412c\",\"dweb:/ipfs/QmfYaSBzxGpgiHoR7ontMJY66S5L26XwkLYoEuzsEjpbQH\"]},\"/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/interfaces/IOracleSentinel.sol\":{\"keccak256\":\"0xa94499fda55ef112640daed2cb1d06062e72c51c7b925c323b4e0ffa9b456ce5\",\"urls\":[\"bzz-raw://18b4a16acac577590a57f34f7ec6583e3cb35f575c948abb928b308d29cac1ab\",\"dweb:/ipfs/QmR1jLkzj6w7SjrdZ7GVW4V2vofSdMJwzjTqKpeUKABvxu\"]},\"/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/interfaces/IPriceOracle.sol\":{\"keccak256\":\"0x3f7c3d1397390ea44c6d5e5730d49476431c3df3b28334fe38218de5edc31138\",\"urls\":[\"bzz-raw://63ebf926fca9ce33aaabaf93805686acc25daded1648d6dab59c8c4d05116918\",\"dweb:/ipfs/QmeGkDp7ycYstpfqCYBiqoCYwy876gabx8r42o5koj3H5A\"]},\"/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/lib/Account.sol\":{\"keccak256\":\"0x2059276ea5e478bd5ac7f2712e7b1b6c85d291c647a54b264909044844828e67\",\"urls\":[\"bzz-raw://f153777051d12131b13a57e5c3af10a2670927cfc7d22c9519ab20c9b4b9bc89\",\"dweb:/ipfs/QmQMP3qS5xDAVGYKDfNkbkSqBKozQGQsGqX4e8VyjRtxPS\"]},\"/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/lib/Actions.sol\":{\"keccak256\":\"0x7b2fcf441c034952dd042b6c8b20b148359db771e7c9ac07d06369560a9f0301\",\"urls\":[\"bzz-raw://84665ee4a780360fe6160d197ba98f0bf0ab0d7c6ad87bfed6226bf2f88d8d30\",\"dweb:/ipfs/QmRDfRdAd8hSXeu4SAeeYKkKoXBhStu7n4uReYBce2JD5Z\"]},\"/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/lib/Bits.sol\":{\"keccak256\":\"0x6d9a641163b2dd25e648c65f5d9e4949a57938e29ddc4c9dddefd74a9964aeef\",\"urls\":[\"bzz-raw://67e5a04ed4055faafbc100d6ccca9c54448ed378a1a8c71171562edda7bcbf7c\",\"dweb:/ipfs/QmYRikK3Xbgiq3UBJkgoo2zNUSSrShVabpRHmQj6iQHhrc\"]},\"/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/lib/Cache.sol\":{\"keccak256\":\"0xe57c80a7621a77fcb2acb9f883fb5248e71a6dce03bc2db56df0db3fee332950\",\"urls\":[\"bzz-raw://28e221c04629674490b9a0041d4f9a5f15e669dc0cc192a5df6e2c701c36369f\",\"dweb:/ipfs/QmaL3oh8c7v9cx91pB175pyCEuzxnhNTab4UxmBMsDYfUx\"]},\"/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/lib/Decimal.sol\":{\"keccak256\":\"0xd9a348c2b1eec076609ba12bbec6b9c2e4ea135790a7ef4f5411feb050af2144\",\"urls\":[\"bzz-raw://d5bcff29e47d5cd02d7a9966e9f44c46ccbb4f0e4adfc4b0b86646880677db39\",\"dweb:/ipfs/QmRKfJD4FFM1AvTynSFNx1NcDg94o9SAcjz7dvMaJCfecp\"]},\"/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/lib/DolomiteMarginMath.sol\":{\"keccak256\":\"0x53f205f6a779d579be29faa9412c806a892b3e605fff092dfd9d14d936fa019f\",\"urls\":[\"bzz-raw://0ff936f89602a63b8e6a4eb4ce8f87673c0f45b7ce29694920905a3f0b5a6a69\",\"dweb:/ipfs/QmbYME9BeEvPC1ndV8EaUDX5fDMghLc3rocNUxFtgHmg8m\"]},\"/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/lib/EnumerableSet.sol\":{\"keccak256\":\"0x41a3460e34b7b8635d936e35e6568ceb5354b638f53b884530e0d4875fa0f151\",\"urls\":[\"bzz-raw://d1a5ba866ee95d455afe5075dadd91fc71c2806371f2c1b358a1f67c632bb0df\",\"dweb:/ipfs/QmW4qCjmsG8J3UJv97GwDLDM7wt1K4yLDKAwzWMY7TFYi5\"]},\"/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/lib/Events.sol\":{\"keccak256\":\"0x2345dcc1ebf53a3d5449dab083b1fb90b5362dae692f8ff3ad00078862894e9b\",\"urls\":[\"bzz-raw://ebd34c557c06caf0696774844f0ca9746412ecc452bdd978b3bca0fd71aefbde\",\"dweb:/ipfs/QmcwXXKgv77DqfhxABRg85WR6RBPTLmge5vJGp99o9kFf8\"]},\"/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/lib/Interest.sol\":{\"keccak256\":\"0x141a0ecb4a746f0e5767df4b99dbe33c6362df507ae9d5c02da1c1c17bc26df3\",\"urls\":[\"bzz-raw://9ff03e64a8ce5231acde07788624bf8c7a8ff55d90b157fa32f62fa887a0eff0\",\"dweb:/ipfs/QmUVxxWeE954RDXbmHJAYnHsXcit6rSXGqZUigu8t9oH2z\"]},\"/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/lib/Monetary.sol\":{\"keccak256\":\"0x5257274f2d4d3605f3e97ec45fb902111fe9a22506f0b4cf308ea933bc81bfe2\",\"urls\":[\"bzz-raw://85b8023b78805063a2ec8d376f1f5983994eabd96efd8ceadb0224dbb71c5678\",\"dweb:/ipfs/QmaDhzCzRqsuHuJfhToEC4pATQHwhh7yWWsjwfuRzFT1kG\"]},\"/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/lib/Require.sol\":{\"keccak256\":\"0x05a2a90b41b6a5f42f0a72da63d015fb0b406a9ba2172823352e522e8bf3a606\",\"urls\":[\"bzz-raw://19883f0c6d33266f756ec5c3d17539524aa24b993c46c33f8400801d09373a6c\",\"dweb:/ipfs/QmYX2fwK3vQQDSZLMrc5wMfeb8RWrcC9CGX8XECLty8QDk\"]},\"/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/lib/Storage.sol\":{\"keccak256\":\"0x9c27f3cd52af28c9b6bca18097b1793f114d08284d78417467d0d05f67e9e2a9\",\"urls\":[\"bzz-raw://d1ed0e7a7f76d59f30572996d4e164ab8fb5b2ec4bfca127983f9e936b904813\",\"dweb:/ipfs/QmePVYbgrY8Yw3Vf76pmEvE9pX916Jaa9we4kjM8tGM4J1\"]},\"/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/lib/Time.sol\":{\"keccak256\":\"0x87ee8d3c1d6e315a116426d8c8fc6f083e220fd14dda27fad4e8d7cab3dc7305\",\"urls\":[\"bzz-raw://7c20f2c52da682c3b5917fb6a19e81f43699b1d13c62b569ed723f34da72e766\",\"dweb:/ipfs/QmbXWYXi67nHBVNDKYUpo2E9ZaEVcHLvmXQkpYLMm1d5Vm\"]},\"/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/lib/Token.sol\":{\"keccak256\":\"0x095b5f8eb3665f6e246200311efc8a654fa3e90f9a1a522e27a4d089e8ab3917\",\"urls\":[\"bzz-raw://5db812b752a03d601d424e6e21be38153477082af0acf51b5c98eefa5553ed18\",\"dweb:/ipfs/QmbE549QUXYTurpx8hSMLBJvuBpfYqyNE6FBCgHJDY8PLf\"]},\"/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/lib/Types.sol\":{\"keccak256\":\"0xe1bab8c8799d83e86c7a49aaf815d8e3bc8d09562d46d44d921500db5e98de0e\",\"urls\":[\"bzz-raw://8ea3d0cc4fdab6dd9bba545a792170f939b342d8d1a7051c1c6365009af72658\",\"dweb:/ipfs/QmaLJgbavu88eEit6JPqfWnw6NmGBDZfveMXxumgWywBFG\"]},\"@openzeppelin/contracts/math/SafeMath.sol\":{\"keccak256\":\"0x640b6dee7a4b830bdfd52b5031a07fc2b12209f5b2e29e5d364a7d37f69d8076\",\"urls\":[\"bzz-raw://31113152e1ddb78fe7a4197f247591ca894e93f916867beb708d8e747b6cc74f\",\"dweb:/ipfs/QmbZaJyXdpsYGykVhHH9qpVGQg9DGCxE2QufbCUy3daTgq\"]},\"@openzeppelin/contracts/token/ERC20/IERC20.sol\":{\"keccak256\":\"0xe5bb0f57cff3e299f360052ba50f1ea0fff046df2be070b6943e0e3c3fdad8a9\",\"urls\":[\"bzz-raw://59fd025151435da35faa8093a5c7a17de02de9d08ad27275c5cdf05050820d91\",\"dweb:/ipfs/QmQMvwEcPhoRXzbXyrdoeRtvLoifUW9Qh7Luho7bmUPRkc\"]}},\"version\":1}", "bytecode": "0x", "deployedBytecode": "0x", "sourceMap": "", "deployedSourceMap": "", "source": "/*\n\n Copyright 2023 Dolomite.\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n\n*/\n\npragma solidity ^0.5.7;\npragma experimental ABIEncoderV2;\n\nimport { IDolomiteMargin } from \"../../protocol/interfaces/IDolomiteMargin.sol\";\n\nimport { Account } from \"../../protocol/lib/Account.sol\";\nimport { Types } from \"../../protocol/lib/Types.sol\";\n\nimport { AccountBalanceLib } from \"../lib/AccountBalanceLib.sol\";\n\nimport { IGenericTraderProxyBase } from \"./IGenericTraderProxyBase.sol\";\n\n\n/**\n * @title IGenericTraderProxyV1\n * @author Dolomite\n *\n * Trader proxy interface for trading assets using any trader from msg.sender\n */\ncontract IGenericTraderProxyV1 is IGenericTraderProxyBase {\n\n // ============ Enums ============\n\n enum EventEmissionType {\n None,\n BorrowPosition,\n MarginPosition\n }\n\n // ============ Structs ============\n\n struct TransferAmount {\n /// @dev The market ID to transfer\n uint256 marketId;\n /// @dev Note, setting to uint(-1) will transfer all of the user's balance. Setting to `uint(-2)` will transfer\n /// the output result of the swap (reverts if `marketId` is not `marketIdsPath[last]` and\n /// `transfer.fromAccountNumber` is not the `TRADE_ACCOUNT`).\n uint256 amountWei;\n }\n\n struct TransferCollateralParam {\n /// @dev The account number from which collateral will be transferred.\n uint256 fromAccountNumber;\n /// @dev The account number to which collateral will be transferred.\n uint256 toAccountNumber;\n /// @dev The transfers to execute after all of the trades.\n TransferAmount[] transferAmounts;\n }\n\n struct ExpiryParam {\n /// @dev The market ID whose expiry will be updated.\n uint256 marketId;\n /// @dev The new expiry time delta for the market. Setting this to `0` will reset the expiration.\n uint32 expiryTimeDelta;\n }\n\n struct UserConfig {\n uint256 deadline;\n AccountBalanceLib.BalanceCheckFlag balanceCheckFlag;\n EventEmissionType eventType;\n }\n\n // ============ Functions ============\n\n /**\n * @dev Swaps an exact amount of input (specified in the `_amountWeisPath[0]` parameter) for at least\n * `_amountWeisPath[_amountWeisPath.length - 1]` of output.\n *\n * @param _tradeAccountNumber The account number to use for msg.sender's trade\n * @param _marketIdsPath The path of market IDs to use for each trade action. Length should be equal\n * to `_tradersPath.length + 1`.\n * @param _inputAmountWei The input amount (in wei) to use for the initial trade action. Setting this\n * value to `uint(-1)` will use the user's full balance.\n * @param _minOutputAmountWei The minimum output amount expected to be received by the user.\n * @param _tradersPath The path of traders to use for each trade action. Length should be equal to\n * `_marketIdsPath.length - 1` and `_amountWeisPath.length - 1`.\n * @param _makerAccounts The accounts that will be used for the maker side of the trades involving\n * `TraderType.InternalLiquidity`.\n * @param _userConfig The user configuration for the trade. Setting the `balanceCheckFlag` to\n * `BalanceCheckFlag.From` will check that the user's `_tradeAccountNumber`\n * is non-negative after the trade. Setting the `balanceCheckFlag` to\n * `BalanceCheckFlag.To` has no effect.\n */\n function swapExactInputForOutput(\n uint256 _tradeAccountNumber,\n uint256[] calldata _marketIdsPath,\n uint256 _inputAmountWei,\n uint256 _minOutputAmountWei,\n TraderParam[] calldata _tradersPath,\n Account.Info[] calldata _makerAccounts,\n UserConfig calldata _userConfig\n )\n external;\n\n /**\n * @dev The same function as `swapExactInputForOutput`, but allows the caller transfer collateral and modify\n * their position's expiration in the same transaction.\n *\n * @param _tradeAccountNumber The account number to use for msg.sender's trade\n * @param _marketIdsPath The path of market IDs to use for each trade action. Length should be equal\n * to `_tradersPath.length + 1`.\n * @param _inputAmountWei The input amount (in wei) to use for the initial trade action. Setting this\n * value to `uint(-1)` will use the user's full balance.\n * @param _minOutputAmountWei The minimum output amount expected to be received by the user.\n * @param _tradersPath The path of traders to use for each trade action. Length should be equal to\n * `_marketIdsPath.length - 1` and `_amountWeisPath.length - 1`.\n * @param _makerAccounts The accounts that will be used for the maker side of the trades involving\n `TraderType.InternalLiquidity`.\n * @param _transferCollateralParams The parameters for transferring collateral in/out of the\n * `_tradeAccountNumber` once the trades settle. One of\n * `_params.fromAccountNumber` or `_params.toAccountNumber` must be equal to\n * `_tradeAccountNumber`.\n * @param _expiryParams The parameters for modifying the expiration of the debt in the position.\n * @param _userConfig The user configuration for the trade. Setting the `balanceCheckFlag` to\n * `BalanceCheckFlag.From` will check that the user's balance for inputMarket\n * for `_tradeAccountNumber` is non-negative after the trade. Setting the\n * `balanceCheckFlag` to `BalanceCheckFlag.To` will check that the user's\n * balance for each `transferMarket` for `transferAccountNumber` is\n * non-negative after.\n */\n function swapExactInputForOutputAndModifyPosition(\n uint256 _tradeAccountNumber,\n uint256[] calldata _marketIdsPath,\n uint256 _inputAmountWei,\n uint256 _minOutputAmountWei,\n IGenericTraderProxyBase.TraderParam[] calldata _tradersPath,\n Account.Info[] calldata _makerAccounts,\n TransferCollateralParam calldata _transferCollateralParams,\n ExpiryParam calldata _expiryParams,\n UserConfig calldata _userConfig\n )\n external;\n}\n", "sourcePath": "/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/external/interfaces/IGenericTraderProxyV1.sol", "ast": { "absolutePath": "/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/external/interfaces/IGenericTraderProxyV1.sol", "exportedSymbols": { "IGenericTraderProxyV1": [ 4697 ] }, "id": 4698, "nodeType": "SourceUnit", "nodes": [ { "id": 4610, "literals": [ "solidity", "^", "0.5", ".7" ], "nodeType": "PragmaDirective", "src": "595:23:26" }, { "id": 4611, "literals": [ "experimental", "ABIEncoderV2" ], "nodeType": "PragmaDirective", "src": "619:33:26" }, { "absolutePath": "/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/interfaces/IDolomiteMargin.sol", "file": "../../protocol/interfaces/IDolomiteMargin.sol", "id": 4613, "nodeType": "ImportDirective", "scope": 4698, "sourceUnit": 24694, "src": "654:80:26", "symbolAliases": [ { "foreign": 4612, "local": null } ], "unitAlias": "" }, { "absolutePath": "/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/lib/Account.sol", "file": "../../protocol/lib/Account.sol", "id": 4615, "nodeType": "ImportDirective", "scope": 4698, "sourceUnit": 24886, "src": "736:57:26", "symbolAliases": [ { "foreign": 4614, "local": null } ], "unitAlias": "" }, { "absolutePath": "/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/protocol/lib/Types.sol", "file": "../../protocol/lib/Types.sol", "id": 4617, "nodeType": "ImportDirective", "scope": 4698, "sourceUnit": 31362, "src": "794:53:26", "symbolAliases": [ { "foreign": 4616, "local": null } ], "unitAlias": "" }, { "absolutePath": "/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/external/lib/AccountBalanceLib.sol", "file": "../lib/AccountBalanceLib.sol", "id": 4619, "nodeType": "ImportDirective", "scope": 4698, "sourceUnit": 5892, "src": "849:65:26", "symbolAliases": [ { "foreign": 4618, "local": null } ], "unitAlias": "" }, { "absolutePath": "/home/cdc218/projects/dolomite/dolomite-protocol-v2/contracts/external/interfaces/IGenericTraderProxyBase.sol", "file": "./IGenericTraderProxyBase.sol", "id": 4621, "nodeType": "ImportDirective", "scope": 4698, "sourceUnit": 4609, "src": "916:72:26", "symbolAliases": [ { "foreign": 4620, "local": null } ], "unitAlias": "" }, { "baseContracts": [ { "arguments": null, "baseName": { "contractScope": null, "id": 4622, "name": "IGenericTraderProxyBase", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 4608, "src": "1166:23:26", "typeDescriptions": { "typeIdentifier": "t_contract$_IGenericTraderProxyBase_$4608", "typeString": "contract IGenericTraderProxyBase" } }, "id": 4623, "nodeType": "InheritanceSpecifier", "src": "1166:23:26" } ], "contractDependencies": [ 4608 ], "contractKind": "contract", "documentation": "@title IGenericTraderProxyV1\n@author Dolomite\n * Trader proxy interface for trading assets using any trader from msg.sender", "fullyImplemented": false, "id": 4697, "linearizedBaseContracts": [ 4697, 4608 ], "name": "IGenericTraderProxyV1", "nodeType": "ContractDefinition", "nodes": [ { "canonicalName": "IGenericTraderProxyV1.EventEmissionType", "id": 4627, "members": [ { "id": 4624, "name": "None", "nodeType": "EnumValue", "src": "1270:4:26" }, { "id": 4625, "name": "BorrowPosition", "nodeType": "EnumValue", "src": "1284:14:26" }, { "id": 4626, "name": "MarginPosition", "nodeType": "EnumValue", "src": "1308:14:26" } ], "name": "EventEmissionType", "nodeType": "EnumDefinition", "src": "1237:91:26" }, { "canonicalName": "IGenericTraderProxyV1.TransferAmount", "id": 4632, "members": [ { "constant": false, "id": 4629, "name": "marketId", "nodeType": "VariableDeclaration", "scope": 4632, "src": "1451:16:26", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 4628, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1451:7:26", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 4631, "name": "amountWei", "nodeType": "VariableDeclaration", "scope": 4632, "src": "1775:17:26", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 4630, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1775:7:26", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" } ], "name": "TransferAmount", "nodeType": "StructDefinition", "scope": 4697, "src": "1376:423:26", "visibility": "public" }, { "canonicalName": "IGenericTraderProxyV1.TransferCollateralParam", "id": 4640, "members": [ { "constant": false, "id": 4634, "name": "fromAccountNumber", "nodeType": "VariableDeclaration", "scope": 4640, "src": "1925:25:26", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 4633, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "1925:7:26", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 4636, "name": "toAccountNumber", "nodeType": "VariableDeclaration", "scope": 4640, "src": "2037:23:26", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 4635, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "2037:7:26", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 4639, "name": "transferAmounts", "nodeType": "VariableDeclaration", "scope": 4640, "src": "2137:32:26", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_array$_t_struct$_TransferAmount_$4632_storage_$dyn_storage_ptr", "typeString": "struct IGenericTraderProxyV1.TransferAmount[]" }, "typeName": { "baseType": { "contractScope": null, "id": 4637, "name": "TransferAmount", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 4632, "src": "2137:14:26", "typeDescriptions": { "typeIdentifier": "t_struct$_TransferAmount_$4632_storage_ptr", "typeString": "struct IGenericTraderProxyV1.TransferAmount" } }, "id": 4638, "length": null, "nodeType": "ArrayTypeName", "src": "2137:16:26", "typeDescriptions": { "typeIdentifier": "t_array$_t_struct$_TransferAmount_$4632_storage_$dyn_storage_ptr", "typeString": "struct IGenericTraderProxyV1.TransferAmount[]" } }, "value": null, "visibility": "internal" } ], "name": "TransferCollateralParam", "nodeType": "StructDefinition", "scope": 4697, "src": "1805:371:26", "visibility": "public" }, { "canonicalName": "IGenericTraderProxyV1.ExpiryParam", "id": 4645, "members": [ { "constant": false, "id": 4642, "name": "marketId", "nodeType": "VariableDeclaration", "scope": 4645, "src": "2272:16:26", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 4641, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "2272:7:26", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 4644, "name": "expiryTimeDelta", "nodeType": "VariableDeclaration", "scope": 4645, "src": "2404:22:26", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint32", "typeString": "uint32" }, "typeName": { "id": 4643, "name": "uint32", "nodeType": "ElementaryTypeName", "src": "2404:6:26", "typeDescriptions": { "typeIdentifier": "t_uint32", "typeString": "uint32" } }, "value": null, "visibility": "internal" } ], "name": "ExpiryParam", "nodeType": "StructDefinition", "scope": 4697, "src": "2182:251:26", "visibility": "public" }, { "canonicalName": "IGenericTraderProxyV1.UserConfig", "id": 4652, "members": [ { "constant": false, "id": 4647, "name": "deadline", "nodeType": "VariableDeclaration", "scope": 4652, "src": "2467:16:26", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" }, "typeName": { "id": 4646, "name": "uint256", "nodeType": "ElementaryTypeName", "src": "2467:7:26", "typeDescriptions": { "typeIdentifier": "t_uint256", "typeString": "uint256" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 4649, "name": "balanceCheckFlag", "nodeType": "VariableDeclaration", "scope": 4652, "src": "2493:51:26", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_enum$_BalanceCheckFlag_$5841", "typeString": "enum AccountBalanceLib.BalanceCheckFlag" }, "typeName": { "contractScope": null, "id": 4648, "name": "AccountBalanceLib.BalanceCheckFlag", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 5841, "src": "2493:34:26", "typeDescriptions": { "typeIdentifier": "t_enum$_BalanceCheckFlag_$5841", "typeString": "enum AccountBalanceLib.BalanceCheckFlag" } }, "value": null, "visibility": "internal" }, { "constant": false, "id": 4651, "name": "eventType", "nodeType": "VariableDeclaration", "scope": 4652, "src": "2554:27:26", "stateVariable": false, "storageLocation": "default", "typeDescriptions": { "typeIdentifier": "t_enum$_EventEmissionType_$4627", "typeString": "enum IGenericTraderProxyV1.EventEmissionType" }, "typeName": { "contractScope": null, "id": 4650, "name": "EventEmissionType", "nodeType": "UserDefinedTypeName", "referencedDeclaration": 4627, "src": "2554:17:26", "typeDescriptions": { "typeIdentifier": "t_enum$_EventEmissionType_$4627", "typeString": "enum IGenericTraderProxyV1.EventEmissionType" } }, "value": null, "visibility": "internal" } ], "name": "UserConfig", "nodeType": "StructDefinition", "scope": 4697, "src": "2439:149:26", "visibility": "public" }, { "body": null, "documentation": "@dev Swaps an exact amount of input (specified in the `_amountWeisPath[0]` parameter) for at least\n `_amountWeisPath[_amountWeisPath.length - 1]` of output.\n * @param _tradeAccountNumber The account number to use for msg.sender's trade\n@param _marketIdsPath The path of market IDs to use for each trade action. Length should be equal\n to `_tradersPath.length + 1`.\n@param _inputAmountWei The input amount (in wei) to use for the initial trade action. Setting this\n value to `uint(-1)` will use the user's full balance.\n@param _minOutputAmountWei The minimum output amount expected to be received by the user.\n@param _tradersPath The path of traders to us