From 2b8834c5c940b8e35e0674e84e7ce80e7adde51f Mon Sep 17 00:00:00 2001 From: Jared Vu Date: Wed, 29 May 2024 12:40:40 -0700 Subject: [PATCH] v1.7.38: Handle channel_batch_data for v4_parent_subaccount (#370) Co-authored-by: mike-dydx Co-authored-by: Rui <102453770+ruixhuang@users.noreply.github.com> Co-authored-by: mobile-build-bot-git Co-authored-by: mike-dydx <149746839+mike-dydx@users.noreply.github.com> --- build.gradle.kts | 2 +- .../iOS/Pods/Pods.xcodeproj/project.pbxproj | 106 ++++++++---------- ...os-frameworks-Debug-input-files.xcfilelist | 3 +- ...s-frameworks-Debug-output-files.xcfilelist | 3 +- ...-frameworks-Release-input-files.xcfilelist | 3 +- ...frameworks-Release-output-files.xcfilelist | 3 +- .../Pods-abacus.ios-frameworks.sh | 2 - .../Pods-abacus.ios.debug.xcconfig | 4 +- .../Pods-abacus.ios.release.xcconfig | 4 +- .../Pods-abacus.iosTests.debug.xcconfig | 4 +- .../Pods-abacus.iosTests.release.xcconfig | 4 +- .../abacus/abacus.debug.xcconfig | 1 - .../abacus/abacus.release.xcconfig | 1 - .../calculator/TradeInputCalculator.kt | 36 +++--- .../exchange.dydx.abacus/output/Account.kt | 14 ++- .../wallet/account/AccountProcessor.kt | 5 +- .../wallet/account/OrderProcessor.kt | 7 ++ .../wallet/account/OrdersProcessor.kt | 13 ++- .../account/PerpetualPositionProcessor.kt | 11 +- .../account/PerpetualPositionsProcessor.kt | 16 ++- .../app/manager/v2/V4TransactionTests.kt | 22 +++- .../payload/v4/V4ParentSubaccountTests.kt | 20 +++- v4_abacus.podspec | 2 +- 23 files changed, 175 insertions(+), 111 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 4dfcd6439..994eaf390 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -51,7 +51,7 @@ allprojects { } group = "exchange.dydx.abacus" -version = "1.7.38" +version = "1.7.39" repositories { google() diff --git a/integration/iOS/Pods/Pods.xcodeproj/project.pbxproj b/integration/iOS/Pods/Pods.xcodeproj/project.pbxproj index 56d884654..38cf39861 100644 --- a/integration/iOS/Pods/Pods.xcodeproj/project.pbxproj +++ b/integration/iOS/Pods/Pods.xcodeproj/project.pbxproj @@ -142,26 +142,26 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ - 8437FCB39ECA4A44D93FCDCBF6066E92 /* PBXContainerItemProxy */ = { + 3E4D9EBB8F897D7BD1BB900F1CB03EFD /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = BFDFE7DC352907FC980B868725387E98 /* Project object */; proxyType = 1; - remoteGlobalIDString = 99313990C1D76A6D1D017868B6975CC8; - remoteInfo = CryptoSwift; + remoteGlobalIDString = 469F25E790D19440507BF938A40578A7; + remoteInfo = "Pods-abacus.ios"; }; - F8007D80E43B99904B0E4DD383211363 /* PBXContainerItemProxy */ = { + A9316E3AFEDA79C6BE2E70454904E23B /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = BFDFE7DC352907FC980B868725387E98 /* Project object */; proxyType = 1; remoteGlobalIDString = 4084846DAF1774840D25DF1BF2460325; remoteInfo = abacus; }; - F99C8B5A9E9146040BECE7ABFD8E196E /* PBXContainerItemProxy */ = { + D943F129042E36333E484FD2DF373D43 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = BFDFE7DC352907FC980B868725387E98 /* Project object */; proxyType = 1; - remoteGlobalIDString = 469F25E790D19440507BF938A40578A7; - remoteInfo = "Pods-abacus.ios"; + remoteGlobalIDString = 99313990C1D76A6D1D017868B6975CC8; + remoteInfo = CryptoSwift; }; /* End PBXContainerItemProxy section */ @@ -170,6 +170,7 @@ 0105D9F1362588440BA8D3158A228340 /* BlockMode.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = BlockMode.swift; path = Sources/CryptoSwift/BlockMode/BlockMode.swift; sourceTree = ""; }; 01C66D92921215B5058ADA6FA1523E18 /* SHA2.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SHA2.swift; path = Sources/CryptoSwift/SHA2.swift; sourceTree = ""; }; 0449BE88D4D44409CCF0A74B34343D27 /* StreamDecryptor.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = StreamDecryptor.swift; path = Sources/CryptoSwift/StreamDecryptor.swift; sourceTree = ""; }; + 059E5579F867BEB3F7E6DF13DEB1712B /* abacus.podspec */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; indentWidth = 2; lastKnownFileType = text; path = abacus.podspec; sourceTree = ""; tabWidth = 2; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; 05F962230C27EB8320B3F9DACAB26666 /* Random.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Random.swift; path = Sources/CryptoSwift/CS_BigInt/Random.swift; sourceTree = ""; }; 068F760AEB5D19F06497CBD5A01D4B17 /* PBKDF1.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = PBKDF1.swift; path = Sources/CryptoSwift/PKCS/PBKDF1.swift; sourceTree = ""; }; 0744F3E2DBB3A6893AC7B625FCBA2151 /* Generics.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Generics.swift; path = Sources/CryptoSwift/Generics.swift; sourceTree = ""; }; @@ -190,11 +191,11 @@ 1E34A6EC8D702D85DFC8AB0BCA04D225 /* Pods-abacus.iosTests-acknowledgements.markdown */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = "Pods-abacus.iosTests-acknowledgements.markdown"; sourceTree = ""; }; 233CC871C3B5E5D1C643AA3F5362558A /* DigestType.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = DigestType.swift; path = Sources/CryptoSwift/DigestType.swift; sourceTree = ""; }; 236DF73D92D4D71C82089CF882764244 /* NoPadding.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = NoPadding.swift; path = Sources/CryptoSwift/NoPadding.swift; sourceTree = ""; }; - 2377C417BE96C2BABD3E1DBC9B1A9D8D /* abacus.podspec */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; indentWidth = 2; lastKnownFileType = text; path = abacus.podspec; sourceTree = ""; tabWidth = 2; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; 2653766C82503F31D9367F8E622F8258 /* PBKDF2.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = PBKDF2.swift; path = Sources/CryptoSwift/PKCS/PBKDF2.swift; sourceTree = ""; }; 289CF4084C8BCFCA379CCF7847F8D1F8 /* Blowfish.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Blowfish.swift; path = Sources/CryptoSwift/Blowfish.swift; sourceTree = ""; }; 295A5EFDE6FBDDF94AEC568618EF25FE /* Hashable.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Hashable.swift; path = Sources/CryptoSwift/CS_BigInt/Hashable.swift; sourceTree = ""; }; 2A89356D96E998228A503AA1A6E9C626 /* Int+Extension.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "Int+Extension.swift"; path = "Sources/CryptoSwift/Int+Extension.swift"; sourceTree = ""; }; + 2B743EE4A0C2A395311B213324EB2342 /* abacus.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = abacus.release.xcconfig; sourceTree = ""; }; 311456A9BE6AD331F084E1FCE9FD2109 /* BigUInt.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = BigUInt.swift; path = Sources/CryptoSwift/CS_BigInt/BigUInt.swift; sourceTree = ""; }; 322DD78557BFE4B398A18CBAA3C8A353 /* BlockEncryptor.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = BlockEncryptor.swift; path = Sources/CryptoSwift/BlockEncryptor.swift; sourceTree = ""; }; 33400747830CD0D31E461E6DE1F4500B /* String Conversion.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "String Conversion.swift"; path = "Sources/CryptoSwift/CS_BigInt/String Conversion.swift"; sourceTree = ""; }; @@ -259,7 +260,6 @@ A7F75F1F8D19379B77CB9B5F20147724 /* Floating Point Conversion.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "Floating Point Conversion.swift"; path = "Sources/CryptoSwift/CS_BigInt/Floating Point Conversion.swift"; sourceTree = ""; }; AD93A59528068EF859CFB769EA8A6B21 /* StreamEncryptor.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = StreamEncryptor.swift; path = Sources/CryptoSwift/StreamEncryptor.swift; sourceTree = ""; }; AE9EA384CA84DA00859213076C156601 /* Rabbit+Foundation.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "Rabbit+Foundation.swift"; path = "Sources/CryptoSwift/Foundation/Rabbit+Foundation.swift"; sourceTree = ""; }; - AF3276B68F8BA3E3862B4F55A9AB6170 /* abacus.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = abacus.release.xcconfig; sourceTree = ""; }; B008B6FE49BB00A27F5C3A8793251FA6 /* Comparable.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Comparable.swift; path = Sources/CryptoSwift/CS_BigInt/Comparable.swift; sourceTree = ""; }; B08BBA0B72E8D4BE9811F9B7F68AA02C /* Blowfish+Foundation.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "Blowfish+Foundation.swift"; path = "Sources/CryptoSwift/Foundation/Blowfish+Foundation.swift"; sourceTree = ""; }; B26CFCBE4B1911C8EC2A1C029CEB4E75 /* String+Extension.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = "String+Extension.swift"; path = "Sources/CryptoSwift/String+Extension.swift"; sourceTree = ""; }; @@ -278,6 +278,7 @@ C74C33FAEC44BEBA526C5472D5CAFD19 /* GCD.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = GCD.swift; path = Sources/CryptoSwift/CS_BigInt/GCD.swift; sourceTree = ""; }; CAF7CB4BE35649AA1E76DE2396A37E0E /* Pods-abacus.ios-acknowledgements.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-abacus.ios-acknowledgements.plist"; sourceTree = ""; }; CE3722C155F5908792FD682A1D84EC9C /* CryptoSwift-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "CryptoSwift-Info.plist"; sourceTree = ""; }; + CF5938B823263BBF080C9B21A3470789 /* abacus.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = abacus.debug.xcconfig; sourceTree = ""; }; CF791D3ED0FED5736405B0F135A4B7DA /* Signature.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = Signature.swift; path = Sources/CryptoSwift/Signature.swift; sourceTree = ""; }; D0DF4F835FF3BD92DE8F28EF66D11155 /* Pods-abacus.ios-frameworks.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-abacus.ios-frameworks.sh"; sourceTree = ""; }; D16CC219F5813A4740742BFCB5F17BB3 /* PKCS1v15.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = PKCS1v15.swift; path = Sources/CryptoSwift/PKCS/PKCS1v15.swift; sourceTree = ""; }; @@ -305,10 +306,8 @@ F270EDBD5E4E8490F69012237AFEC6CC /* BatchedCollection.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = BatchedCollection.swift; path = Sources/CryptoSwift/BatchedCollection.swift; sourceTree = ""; }; F37859F4A09B4D8326D98D57FE5A1EE9 /* SecureBytes.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SecureBytes.swift; path = Sources/CryptoSwift/SecureBytes.swift; sourceTree = ""; }; F3BBCD0680550B4404763E23B515A31F /* OCB.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = OCB.swift; path = Sources/CryptoSwift/BlockMode/OCB.swift; sourceTree = ""; }; - F4B1F23DF610F8A9AD9305359993709D /* Abacus.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Abacus.framework; path = build/cocoapods/framework/Abacus.framework; sourceTree = ""; }; F702C9EC7CE0BC75E37AA56B71F7E614 /* AES.Cryptors.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = AES.Cryptors.swift; path = Sources/CryptoSwift/AES.Cryptors.swift; sourceTree = ""; }; F81274EDB681F11E7CB05F7DCA2BB33C /* CryptoSwift */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; name = CryptoSwift; path = CryptoSwift.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - F999223EA515513F8C78AB8A4893AAAD /* abacus.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = abacus.debug.xcconfig; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -339,11 +338,27 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 32C262F4B88173CFDD2E507FF6B0EBF1 /* Support Files */ = { + 2D0B0EF6EDF07ED1C20291E5736D2CD7 /* Development Pods */ = { isa = PBXGroup; children = ( - F999223EA515513F8C78AB8A4893AAAD /* abacus.debug.xcconfig */, - AF3276B68F8BA3E3862B4F55A9AB6170 /* abacus.release.xcconfig */, + 62AAA19B1072508BA39B574A06434036 /* abacus */, + ); + name = "Development Pods"; + sourceTree = ""; + }; + 34798EDB6F1011D15814A373E88BB56F /* Pod */ = { + isa = PBXGroup; + children = ( + 059E5579F867BEB3F7E6DF13DEB1712B /* abacus.podspec */, + ); + name = Pod; + sourceTree = ""; + }; + 471C85CB948067129D79803FD50B3454 /* Support Files */ = { + isa = PBXGroup; + children = ( + CF5938B823263BBF080C9B21A3470789 /* abacus.debug.xcconfig */, + 2B743EE4A0C2A395311B213324EB2342 /* abacus.release.xcconfig */, ); name = "Support Files"; path = "integration/iOS/Pods/Target Support Files/abacus"; @@ -357,12 +372,11 @@ name = iOS; sourceTree = ""; }; - 6CE1150C1C9A0A71A18F30B35568DD8E /* abacus */ = { + 62AAA19B1072508BA39B574A06434036 /* abacus */ = { isa = PBXGroup; children = ( - C3735E810316ABDD783461EE462A964C /* Frameworks */, - 8750F5C2E47D320BFE4309AE82291B48 /* Pod */, - 32C262F4B88173CFDD2E507FF6B0EBF1 /* Support Files */, + 34798EDB6F1011D15814A373E88BB56F /* Pod */, + 471C85CB948067129D79803FD50B3454 /* Support Files */, ); name = abacus; path = ../../..; @@ -394,14 +408,6 @@ name = Products; sourceTree = ""; }; - 8750F5C2E47D320BFE4309AE82291B48 /* Pod */ = { - isa = PBXGroup; - children = ( - 2377C417BE96C2BABD3E1DBC9B1A9D8D /* abacus.podspec */, - ); - name = Pod; - sourceTree = ""; - }; 915C28C583640C124E56AE6BB9F0DAB2 /* CryptoSwift */ = { isa = PBXGroup; children = ( @@ -521,14 +527,6 @@ path = CryptoSwift; sourceTree = ""; }; - A5DC2D324221A781AC0E7A1B4908E26D /* Development Pods */ = { - isa = PBXGroup; - children = ( - 6CE1150C1C9A0A71A18F30B35568DD8E /* abacus */, - ); - name = "Development Pods"; - sourceTree = ""; - }; B284BBC13E1216FA4484D74F45F3F36F /* Pods-abacus.ios */ = { isa = PBXGroup; children = ( @@ -555,19 +553,11 @@ name = "Targets Support Files"; sourceTree = ""; }; - C3735E810316ABDD783461EE462A964C /* Frameworks */ = { - isa = PBXGroup; - children = ( - F4B1F23DF610F8A9AD9305359993709D /* Abacus.framework */, - ); - name = Frameworks; - sourceTree = ""; - }; CF1408CF629C7361332E53B88F7BD30C = { isa = PBXGroup; children = ( 9D940727FF8FB9C785EB98E56350EF41 /* Podfile */, - A5DC2D324221A781AC0E7A1B4908E26D /* Development Pods */, + 2D0B0EF6EDF07ED1C20291E5736D2CD7 /* Development Pods */, D210D550F4EA176C3123ED886F8F87F5 /* Frameworks */, DA389CCA0C382AECE0DD24ED555B7245 /* Pods */, 7D94CDF401128D689D2B11EDCC7ECD3A /* Products */, @@ -648,8 +638,8 @@ buildRules = ( ); dependencies = ( - E8ABF0505B4018EE55DC64051C0E3170 /* PBXTargetDependency */, - CF848ADCA9D462971E67CA041BBB55DD /* PBXTargetDependency */, + 5A2D5CC658950E4A7AEC9150E168E04C /* PBXTargetDependency */, + CB00F4B79F2C6FE352C8E0E376CC0EE4 /* PBXTargetDependency */, ); name = "Pods-abacus.ios"; productName = Pods_abacus_ios; @@ -668,7 +658,7 @@ buildRules = ( ); dependencies = ( - AC2EBD83354400DAA47E7F9069901F4A /* PBXTargetDependency */, + A5DD726974B98C309F8CC82EA812FDEF /* PBXTargetDependency */, ); name = "Pods-abacus.iosTests"; productName = Pods_abacus_iosTests; @@ -898,23 +888,23 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ - AC2EBD83354400DAA47E7F9069901F4A /* PBXTargetDependency */ = { + 5A2D5CC658950E4A7AEC9150E168E04C /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = CryptoSwift; + target = 99313990C1D76A6D1D017868B6975CC8 /* CryptoSwift */; + targetProxy = D943F129042E36333E484FD2DF373D43 /* PBXContainerItemProxy */; + }; + A5DD726974B98C309F8CC82EA812FDEF /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = "Pods-abacus.ios"; target = 469F25E790D19440507BF938A40578A7 /* Pods-abacus.ios */; - targetProxy = F99C8B5A9E9146040BECE7ABFD8E196E /* PBXContainerItemProxy */; + targetProxy = 3E4D9EBB8F897D7BD1BB900F1CB03EFD /* PBXContainerItemProxy */; }; - CF848ADCA9D462971E67CA041BBB55DD /* PBXTargetDependency */ = { + CB00F4B79F2C6FE352C8E0E376CC0EE4 /* PBXTargetDependency */ = { isa = PBXTargetDependency; name = abacus; target = 4084846DAF1774840D25DF1BF2460325 /* abacus */; - targetProxy = F8007D80E43B99904B0E4DD383211363 /* PBXContainerItemProxy */; - }; - E8ABF0505B4018EE55DC64051C0E3170 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - name = CryptoSwift; - target = 99313990C1D76A6D1D017868B6975CC8 /* CryptoSwift */; - targetProxy = 8437FCB39ECA4A44D93FCDCBF6066E92 /* PBXContainerItemProxy */; + targetProxy = A9316E3AFEDA79C6BE2E70454904E23B /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ @@ -958,7 +948,7 @@ }; 22B0388248EDA44270493DDECC58CF78 /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = AF3276B68F8BA3E3862B4F55A9AB6170 /* abacus.release.xcconfig */; + baseConfigurationReference = 2B743EE4A0C2A395311B213324EB2342 /* abacus.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; @@ -1048,7 +1038,7 @@ }; 5B331F72A7F4402311EBC4A06282E60D /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = F999223EA515513F8C78AB8A4893AAAD /* abacus.debug.xcconfig */; + baseConfigurationReference = CF5938B823263BBF080C9B21A3470789 /* abacus.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; diff --git a/integration/iOS/Pods/Target Support Files/Pods-abacus.ios/Pods-abacus.ios-frameworks-Debug-input-files.xcfilelist b/integration/iOS/Pods/Target Support Files/Pods-abacus.ios/Pods-abacus.ios-frameworks-Debug-input-files.xcfilelist index fde154c0b..5a72e622a 100644 --- a/integration/iOS/Pods/Target Support Files/Pods-abacus.ios/Pods-abacus.ios-frameworks-Debug-input-files.xcfilelist +++ b/integration/iOS/Pods/Target Support Files/Pods-abacus.ios/Pods-abacus.ios-frameworks-Debug-input-files.xcfilelist @@ -1,3 +1,2 @@ ${PODS_ROOT}/Target Support Files/Pods-abacus.ios/Pods-abacus.ios-frameworks.sh -${BUILT_PRODUCTS_DIR}/CryptoSwift/CryptoSwift.framework -${PODS_ROOT}/../../../build/cocoapods/framework/Abacus.framework \ No newline at end of file +${BUILT_PRODUCTS_DIR}/CryptoSwift/CryptoSwift.framework \ No newline at end of file diff --git a/integration/iOS/Pods/Target Support Files/Pods-abacus.ios/Pods-abacus.ios-frameworks-Debug-output-files.xcfilelist b/integration/iOS/Pods/Target Support Files/Pods-abacus.ios/Pods-abacus.ios-frameworks-Debug-output-files.xcfilelist index d4b327f7e..60ae66013 100644 --- a/integration/iOS/Pods/Target Support Files/Pods-abacus.ios/Pods-abacus.ios-frameworks-Debug-output-files.xcfilelist +++ b/integration/iOS/Pods/Target Support Files/Pods-abacus.ios/Pods-abacus.ios-frameworks-Debug-output-files.xcfilelist @@ -1,2 +1 @@ -${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CryptoSwift.framework -${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Abacus.framework \ No newline at end of file +${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CryptoSwift.framework \ No newline at end of file diff --git a/integration/iOS/Pods/Target Support Files/Pods-abacus.ios/Pods-abacus.ios-frameworks-Release-input-files.xcfilelist b/integration/iOS/Pods/Target Support Files/Pods-abacus.ios/Pods-abacus.ios-frameworks-Release-input-files.xcfilelist index fde154c0b..5a72e622a 100644 --- a/integration/iOS/Pods/Target Support Files/Pods-abacus.ios/Pods-abacus.ios-frameworks-Release-input-files.xcfilelist +++ b/integration/iOS/Pods/Target Support Files/Pods-abacus.ios/Pods-abacus.ios-frameworks-Release-input-files.xcfilelist @@ -1,3 +1,2 @@ ${PODS_ROOT}/Target Support Files/Pods-abacus.ios/Pods-abacus.ios-frameworks.sh -${BUILT_PRODUCTS_DIR}/CryptoSwift/CryptoSwift.framework -${PODS_ROOT}/../../../build/cocoapods/framework/Abacus.framework \ No newline at end of file +${BUILT_PRODUCTS_DIR}/CryptoSwift/CryptoSwift.framework \ No newline at end of file diff --git a/integration/iOS/Pods/Target Support Files/Pods-abacus.ios/Pods-abacus.ios-frameworks-Release-output-files.xcfilelist b/integration/iOS/Pods/Target Support Files/Pods-abacus.ios/Pods-abacus.ios-frameworks-Release-output-files.xcfilelist index d4b327f7e..60ae66013 100644 --- a/integration/iOS/Pods/Target Support Files/Pods-abacus.ios/Pods-abacus.ios-frameworks-Release-output-files.xcfilelist +++ b/integration/iOS/Pods/Target Support Files/Pods-abacus.ios/Pods-abacus.ios-frameworks-Release-output-files.xcfilelist @@ -1,2 +1 @@ -${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CryptoSwift.framework -${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Abacus.framework \ No newline at end of file +${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CryptoSwift.framework \ No newline at end of file diff --git a/integration/iOS/Pods/Target Support Files/Pods-abacus.ios/Pods-abacus.ios-frameworks.sh b/integration/iOS/Pods/Target Support Files/Pods-abacus.ios/Pods-abacus.ios-frameworks.sh index 91b03c4c7..87d4632ad 100755 --- a/integration/iOS/Pods/Target Support Files/Pods-abacus.ios/Pods-abacus.ios-frameworks.sh +++ b/integration/iOS/Pods/Target Support Files/Pods-abacus.ios/Pods-abacus.ios-frameworks.sh @@ -177,11 +177,9 @@ code_sign_if_enabled() { if [[ "$CONFIGURATION" == "Debug" ]]; then install_framework "${BUILT_PRODUCTS_DIR}/CryptoSwift/CryptoSwift.framework" - install_framework "${PODS_ROOT}/../../../build/cocoapods/framework/Abacus.framework" fi if [[ "$CONFIGURATION" == "Release" ]]; then install_framework "${BUILT_PRODUCTS_DIR}/CryptoSwift/CryptoSwift.framework" - install_framework "${PODS_ROOT}/../../../build/cocoapods/framework/Abacus.framework" fi if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then wait diff --git a/integration/iOS/Pods/Target Support Files/Pods-abacus.ios/Pods-abacus.ios.debug.xcconfig b/integration/iOS/Pods/Target Support Files/Pods-abacus.ios/Pods-abacus.ios.debug.xcconfig index bb1b3d88e..465909b2f 100644 --- a/integration/iOS/Pods/Target Support Files/Pods-abacus.ios/Pods-abacus.ios.debug.xcconfig +++ b/integration/iOS/Pods/Target Support Files/Pods-abacus.ios/Pods-abacus.ios.debug.xcconfig @@ -1,11 +1,11 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO -FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/CryptoSwift" "${PODS_ROOT}/../../../build/cocoapods/framework" +FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/CryptoSwift" GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/CryptoSwift/CryptoSwift.framework/Headers" LD_RUNPATH_SEARCH_PATHS = $(inherited) /usr/lib/swift '@executable_path/Frameworks' '@loader_path/Frameworks' LIBRARY_SEARCH_PATHS = $(inherited) "${TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" /usr/lib/swift -OTHER_LDFLAGS = $(inherited) -l"c++" -framework "Abacus" -framework "CryptoSwift" +OTHER_LDFLAGS = $(inherited) -l"c++" -framework "CryptoSwift" OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS PODS_BUILD_DIR = ${BUILD_DIR} PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) diff --git a/integration/iOS/Pods/Target Support Files/Pods-abacus.ios/Pods-abacus.ios.release.xcconfig b/integration/iOS/Pods/Target Support Files/Pods-abacus.ios/Pods-abacus.ios.release.xcconfig index bb1b3d88e..465909b2f 100644 --- a/integration/iOS/Pods/Target Support Files/Pods-abacus.ios/Pods-abacus.ios.release.xcconfig +++ b/integration/iOS/Pods/Target Support Files/Pods-abacus.ios/Pods-abacus.ios.release.xcconfig @@ -1,11 +1,11 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO -FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/CryptoSwift" "${PODS_ROOT}/../../../build/cocoapods/framework" +FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/CryptoSwift" GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/CryptoSwift/CryptoSwift.framework/Headers" LD_RUNPATH_SEARCH_PATHS = $(inherited) /usr/lib/swift '@executable_path/Frameworks' '@loader_path/Frameworks' LIBRARY_SEARCH_PATHS = $(inherited) "${TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" /usr/lib/swift -OTHER_LDFLAGS = $(inherited) -l"c++" -framework "Abacus" -framework "CryptoSwift" +OTHER_LDFLAGS = $(inherited) -l"c++" -framework "CryptoSwift" OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS PODS_BUILD_DIR = ${BUILD_DIR} PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) diff --git a/integration/iOS/Pods/Target Support Files/Pods-abacus.iosTests/Pods-abacus.iosTests.debug.xcconfig b/integration/iOS/Pods/Target Support Files/Pods-abacus.iosTests/Pods-abacus.iosTests.debug.xcconfig index fca5da53c..48b7be218 100644 --- a/integration/iOS/Pods/Target Support Files/Pods-abacus.iosTests/Pods-abacus.iosTests.debug.xcconfig +++ b/integration/iOS/Pods/Target Support Files/Pods-abacus.iosTests/Pods-abacus.iosTests.debug.xcconfig @@ -1,8 +1,8 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO -FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/CryptoSwift" "${PODS_ROOT}/../../../build/cocoapods/framework" +FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/CryptoSwift" GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/CryptoSwift/CryptoSwift.framework/Headers" -OTHER_LDFLAGS = $(inherited) -l"c++" -framework "Abacus" -framework "CryptoSwift" +OTHER_LDFLAGS = $(inherited) -l"c++" -framework "CryptoSwift" PODS_BUILD_DIR = ${BUILD_DIR} PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) PODS_PODFILE_DIR_PATH = ${SRCROOT}/. diff --git a/integration/iOS/Pods/Target Support Files/Pods-abacus.iosTests/Pods-abacus.iosTests.release.xcconfig b/integration/iOS/Pods/Target Support Files/Pods-abacus.iosTests/Pods-abacus.iosTests.release.xcconfig index fca5da53c..48b7be218 100644 --- a/integration/iOS/Pods/Target Support Files/Pods-abacus.iosTests/Pods-abacus.iosTests.release.xcconfig +++ b/integration/iOS/Pods/Target Support Files/Pods-abacus.iosTests/Pods-abacus.iosTests.release.xcconfig @@ -1,8 +1,8 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO -FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/CryptoSwift" "${PODS_ROOT}/../../../build/cocoapods/framework" +FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/CryptoSwift" GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/CryptoSwift/CryptoSwift.framework/Headers" -OTHER_LDFLAGS = $(inherited) -l"c++" -framework "Abacus" -framework "CryptoSwift" +OTHER_LDFLAGS = $(inherited) -l"c++" -framework "CryptoSwift" PODS_BUILD_DIR = ${BUILD_DIR} PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) PODS_PODFILE_DIR_PATH = ${SRCROOT}/. diff --git a/integration/iOS/Pods/Target Support Files/abacus/abacus.debug.xcconfig b/integration/iOS/Pods/Target Support Files/abacus/abacus.debug.xcconfig index b7f6dcfae..954328169 100644 --- a/integration/iOS/Pods/Target Support Files/abacus/abacus.debug.xcconfig +++ b/integration/iOS/Pods/Target Support Files/abacus/abacus.debug.xcconfig @@ -1,6 +1,5 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/abacus -FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/../../../build/cocoapods/framework" GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 KOTLIN_PROJECT_PATH = OTHER_LDFLAGS = $(inherited) -l"c++" diff --git a/integration/iOS/Pods/Target Support Files/abacus/abacus.release.xcconfig b/integration/iOS/Pods/Target Support Files/abacus/abacus.release.xcconfig index b7f6dcfae..954328169 100644 --- a/integration/iOS/Pods/Target Support Files/abacus/abacus.release.xcconfig +++ b/integration/iOS/Pods/Target Support Files/abacus/abacus.release.xcconfig @@ -1,6 +1,5 @@ CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/abacus -FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/../../../build/cocoapods/framework" GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 KOTLIN_PROJECT_PATH = OTHER_LDFLAGS = $(inherited) -l"c++" diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/calculator/TradeInputCalculator.kt b/src/commonMain/kotlin/exchange.dydx.abacus/calculator/TradeInputCalculator.kt index 0ae7ef493..6abd6b864 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/calculator/TradeInputCalculator.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/calculator/TradeInputCalculator.kt @@ -8,6 +8,7 @@ import exchange.dydx.abacus.calculator.SlippageConstants.STOP_MARKET_ORDER_SLIPP import exchange.dydx.abacus.calculator.SlippageConstants.STOP_MARKET_ORDER_SLIPPAGE_BUFFER_MAJOR_MARKET import exchange.dydx.abacus.calculator.SlippageConstants.TAKE_PROFIT_MARKET_ORDER_SLIPPAGE_BUFFER import exchange.dydx.abacus.calculator.SlippageConstants.TAKE_PROFIT_MARKET_ORDER_SLIPPAGE_BUFFER_MAJOR_MARKET +import exchange.dydx.abacus.output.input.MarginMode import exchange.dydx.abacus.protocols.ParserProtocol import exchange.dydx.abacus.state.manager.EnvironmentFeatureFlags import exchange.dydx.abacus.utils.Numeric @@ -363,12 +364,9 @@ internal class TradeInputCalculator( when (marginMode) { "ISOLATED" -> { // TODO: When the collateral of child subaccounts is implemented, return from here. The below code is the CROSS implementation. - val currentNotionalTotal = - parser.asDouble(parser.value(position, "notionalTotal.current")) - val postOrderNotionalTotal = - parser.asDouble(parser.value(position, "notionalTotal.postOrder")) - val mmf = - parser.asDouble(parser.value(market, "configs.maintenanceMarginFraction")) + val currentNotionalTotal = parser.asDouble(parser.value(position, "notionalTotal.current")) + val postOrderNotionalTotal = parser.asDouble(parser.value(position, "notionalTotal.postOrder")) + val mmf = parser.asDouble(parser.value(market, "configs.maintenanceMarginFraction")) if (currentNotionalTotal != null && mmf != null) { if (postOrderNotionalTotal != null) { return postOrderNotionalTotal.times(mmf) @@ -874,14 +872,24 @@ internal class TradeInputCalculator( ): List? { val type = parser.asString(trade["type"]) return when (type) { - "MARKET" -> - listOf( - sizeField(), - leverageField(), - bracketsField(), - marginModeField(market, account, subaccount), - reduceOnlyField(), - ).filterNotNull() + "MARKET" -> { + val marginMode = parser.asString(trade["marginMode"]) + return when (MarginMode.invoke(marginMode)) { + MarginMode.isolated -> listOf( + sizeField(), + bracketsField(), + marginModeField(market, account, subaccount), + reduceOnlyField(), + ).filterNotNull() + else -> listOf( + sizeField(), + leverageField(), + bracketsField(), + marginModeField(market, account, subaccount), + reduceOnlyField(), + ).filterNotNull() + } + } "LIMIT" -> { val timeInForce = parser.asString(trade["timeInForce"]) diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/output/Account.kt b/src/commonMain/kotlin/exchange.dydx.abacus/output/Account.kt index 15015187f..4e626fbc9 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/output/Account.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/output/Account.kt @@ -1,5 +1,6 @@ package exchange.dydx.abacus.output +import exchange.dydx.abacus.output.input.MarginMode import exchange.dydx.abacus.output.input.OrderSide import exchange.dydx.abacus.output.input.OrderStatus import exchange.dydx.abacus.output.input.OrderTimeInForce @@ -255,6 +256,7 @@ data class SubaccountPosition( val marginUsage: TradeStatesWithDoubleValues, val quoteBalance: TradeStatesWithDoubleValues, // available for isolated market position val equity: TradeStatesWithDoubleValues, // available for isolated market position + val marginMode: MarginMode? ) { companion object { internal fun create( @@ -383,6 +385,7 @@ data class SubaccountPosition( parser, parser.asMap(data["equity"]), ) + val marginMode = parser.asString(data["marginMode"])?.let { MarginMode.invoke(it) } return if (existing?.id != id || existing.assetId != assetId || @@ -410,7 +413,8 @@ data class SubaccountPosition( existing.freeCollateral !== freeCollateral || existing.marginUsage !== marginUsage || existing.quoteBalance !== quoteBalance || - existing.equity !== equity + existing.equity !== equity || + existing.marginMode != marginMode ) { val side = positionSide(size) SubaccountPosition( @@ -442,6 +446,7 @@ data class SubaccountPosition( marginUsage, quoteBalance, equity, + marginMode, ) } else { existing @@ -662,6 +667,7 @@ data class SubaccountOrder( val reduceOnly: Boolean, val cancelReason: String?, val resources: SubaccountOrderResources, + val marginMode: MarginMode? ) { companion object { internal fun create( @@ -695,6 +701,7 @@ data class SubaccountOrder( val resources = parser.asMap(data["resources"])?.let { SubaccountOrderResources.create(existing?.resources, parser, it, localizer) } + val marginMode = parser.asString(data["marginMode"])?.let { MarginMode.invoke(it) } if (id != null && marketId != null && type != null && side != null && status != null && price != null && size != null && resources != null ) { @@ -744,7 +751,9 @@ data class SubaccountOrder( existing.postOnly != postOnly || existing.reduceOnly != reduceOnly || existing.cancelReason != cancelReason || - existing.resources !== resources + existing.resources !== resources || + existing.subaccountNumber != subaccountNumber || + existing.marginMode != marginMode ) { SubaccountOrder( subaccountNumber, @@ -774,6 +783,7 @@ data class SubaccountOrder( reduceOnly, cancelReason, resources, + marginMode, ) } else { existing diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/processor/wallet/account/AccountProcessor.kt b/src/commonMain/kotlin/exchange.dydx.abacus/processor/wallet/account/AccountProcessor.kt index 81c7af5c6..14f0fc56a 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/processor/wallet/account/AccountProcessor.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/processor/wallet/account/AccountProcessor.kt @@ -299,13 +299,14 @@ internal open class SubaccountProcessor(parser: ParserProtocol) : BaseProcessor( modified = transform(modified, payload, "current", currentAccountKeyMap) if (firstTime) { + val subaccountNumber = parser.asInt(modified["subaccountNumber"]) val openPerpetualPositionsData = ( parser.asNativeMap(payload["openPositions"]) ?: parser.asNativeMap(payload["openPerpetualPositions"]) ) - val positions = perpetualPositionsProcessor.received(openPerpetualPositionsData) + val positions = perpetualPositionsProcessor.received(openPerpetualPositionsData, subaccountNumber) modified.safeSet( "positions", positions, @@ -371,12 +372,14 @@ internal open class SubaccountProcessor(parser: ParserProtocol) : BaseProcessor( payload: List?, height: BlockAndTime?, ): Map { + val subaccountNumber = parser.asInt(subaccount["subaccountNumber"]) return if (payload != null) { val modified = subaccount.mutable() val transformed = ordersProcessor.received( parser.asNativeMap(subaccount["orders"]), payload, height, + subaccountNumber, ) modified.safeSet("orders", transformed) modified diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/processor/wallet/account/OrderProcessor.kt b/src/commonMain/kotlin/exchange.dydx.abacus/processor/wallet/account/OrderProcessor.kt index 413dbd7d7..8d2113507 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/processor/wallet/account/OrderProcessor.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/processor/wallet/account/OrderProcessor.kt @@ -1,9 +1,11 @@ package exchange.dydx.abacus.processor.wallet.account +import exchange.dydx.abacus.output.input.MarginMode import exchange.dydx.abacus.processor.base.BaseProcessor import exchange.dydx.abacus.processor.utils.OrderTypeProcessor import exchange.dydx.abacus.protocols.ParserProtocol import exchange.dydx.abacus.state.manager.BlockAndTime +import exchange.dydx.abacus.utils.NUM_PARENT_SUBACCOUNTS import exchange.dydx.abacus.utils.Numeric import exchange.dydx.abacus.utils.mutable import exchange.dydx.abacus.utils.safeSet @@ -202,6 +204,11 @@ internal class OrderProcessor(parser: ParserProtocol) : BaseProcessor(parser) { if (modified["id"] == null) { modified.safeSet("id", payload["clientId"]) } + parser.asInt(modified["subaccountNumber"])?.run { + modified.safeSet("subaccountNumber", this) + // the v4_parent_subaccount message has subaccountNumber available but v4_orders does not + modified.safeSet("marginMode", if (this >= NUM_PARENT_SUBACCOUNTS) MarginMode.isolated.rawValue else MarginMode.cross.rawValue) + } val size = parser.asDouble(payload["size"]) if (size != null) { var totalFilled = parser.asDouble(payload["totalFilled"]) diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/processor/wallet/account/OrdersProcessor.kt b/src/commonMain/kotlin/exchange.dydx.abacus/processor/wallet/account/OrdersProcessor.kt index 236507209..d8fbafcdd 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/processor/wallet/account/OrdersProcessor.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/processor/wallet/account/OrdersProcessor.kt @@ -4,6 +4,7 @@ import exchange.dydx.abacus.processor.base.BaseProcessor import exchange.dydx.abacus.protocols.ParserProtocol import exchange.dydx.abacus.state.manager.BlockAndTime import exchange.dydx.abacus.utils.mutable +import exchange.dydx.abacus.utils.safeSet import exchange.dydx.abacus.utils.typedSafeSet internal class OrdersProcessor(parser: ParserProtocol) : BaseProcessor(parser) { @@ -12,16 +13,24 @@ internal class OrdersProcessor(parser: ParserProtocol) : BaseProcessor(parser) { internal fun received( existing: Map?, payload: List?, - height: BlockAndTime? + height: BlockAndTime?, + subaccountNumber: Int?, ): Map? { return if (payload != null) { val orders = existing?.mutable() ?: mutableMapOf() for (data in payload) { parser.asNativeMap(data)?.let { data -> val orderId = parser.asString(data["id"] ?: data["clientId"]) + val modified = data.toMutableMap() + val orderSubaccountNumber = parser.asInt(data["subaccountNumber"]) + + if (orderSubaccountNumber == null) { + modified.safeSet("subaccountNumber", subaccountNumber) + } + if (orderId != null) { val existing = parser.asNativeMap(orders[orderId]) - val order = itemProcessor.received(existing, data, height) + val order = itemProcessor.received(existing, modified, height) orders.typedSafeSet(orderId, order) } } diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/processor/wallet/account/PerpetualPositionProcessor.kt b/src/commonMain/kotlin/exchange.dydx.abacus/processor/wallet/account/PerpetualPositionProcessor.kt index e2ff1e9e8..62b2e619b 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/processor/wallet/account/PerpetualPositionProcessor.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/processor/wallet/account/PerpetualPositionProcessor.kt @@ -1,8 +1,10 @@ package exchange.dydx.abacus.processor.wallet.account import abs +import exchange.dydx.abacus.output.input.MarginMode import exchange.dydx.abacus.processor.base.BaseProcessor import exchange.dydx.abacus.protocols.ParserProtocol +import exchange.dydx.abacus.utils.NUM_PARENT_SUBACCOUNTS import exchange.dydx.abacus.utils.Numeric import exchange.dydx.abacus.utils.ParsingHelper import exchange.dydx.abacus.utils.safeSet @@ -106,7 +108,7 @@ internal class PerpetualPositionProcessor(parser: ParserProtocol) : BaseProcesso override fun received( existing: Map?, - payload: Map + payload: Map, ): Map { var modified = transform(existing, payload, positionKeyMap) modified = transform(modified, payload, "current", currentPositionKeyMap) @@ -115,6 +117,13 @@ internal class PerpetualPositionProcessor(parser: ParserProtocol) : BaseProcesso val sizeMap = size(parser.asNativeMap(payload["size"]), size, parser.asString(payload["side"])) modified.safeSet("size", sizeMap) + parser.asInt(payload["subaccountNumber"])?.run { + modified.safeSet("subaccountNumber", this) + + // the v4_parent_subaccount message has subaccountNumber available but v4_orders does not + modified.safeSet("marginMode", if (this >= NUM_PARENT_SUBACCOUNTS) MarginMode.isolated.rawValue else MarginMode.cross.rawValue) + } + ParsingHelper.asset(parser.asString(modified["id"]))?.let { modified["assetId"] = it } diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/processor/wallet/account/PerpetualPositionsProcessor.kt b/src/commonMain/kotlin/exchange.dydx.abacus/processor/wallet/account/PerpetualPositionsProcessor.kt index e97dcb8ec..b4a04c4de 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/processor/wallet/account/PerpetualPositionsProcessor.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/processor/wallet/account/PerpetualPositionsProcessor.kt @@ -2,18 +2,28 @@ package exchange.dydx.abacus.processor.wallet.account import exchange.dydx.abacus.processor.base.BaseProcessor import exchange.dydx.abacus.protocols.ParserProtocol +import exchange.dydx.abacus.utils.modify import exchange.dydx.abacus.utils.mutable import exchange.dydx.abacus.utils.safeSet internal class PerpetualPositionsProcessor(parser: ParserProtocol) : BaseProcessor(parser) { private val itemProcessor = PerpetualPositionProcessor(parser = parser) - internal fun received(payload: Map?): Map? { + internal fun received( + payload: Map?, + subaccountNumber: Int?, + ): Map? { if (payload != null) { val result = mutableMapOf() for ((key, value) in payload) { - parser.asNativeMap(value)?.let { value -> - val item = itemProcessor.received(null, value) + parser.asNativeMap(value)?.let { data -> + + var modifiedData = data.toMutableMap() + subaccountNumber?.run { + modifiedData.modify("subaccountNumber", subaccountNumber) + } + + val item = itemProcessor.received(null, modifiedData) result.safeSet(key, item) } } diff --git a/src/commonTest/kotlin/exchange.dydx.abacus/app/manager/v2/V4TransactionTests.kt b/src/commonTest/kotlin/exchange.dydx.abacus/app/manager/v2/V4TransactionTests.kt index 6810cc8c6..824f10fbe 100644 --- a/src/commonTest/kotlin/exchange.dydx.abacus/app/manager/v2/V4TransactionTests.kt +++ b/src/commonTest/kotlin/exchange.dydx.abacus/app/manager/v2/V4TransactionTests.kt @@ -350,14 +350,15 @@ class V4TransactionTests : NetworkTests() { testWebSocket?.simulateConnected(true) testWebSocket?.simulateReceived(mock.connectionMock.connectedMessage) testWebSocket?.simulateReceived(mock.marketsChannel.v4_subscribed_r1) - + stateManager.market = "ETH-USD" + testWebSocket?.simulateReceived(mock.orderbookChannel.load_test_2_subscribed) stateManager.setAddresses(null, "dydx155va0m7wz5n8zcqscn9afswwt04n4usj46wvp5") + if (withPositions) { testWebSocket?.simulateReceived(mock.v4ParentSubaccountsMock.subscribed_with_positions) } else { testWebSocket?.simulateReceived(mock.v4ParentSubaccountsMock.subscribed) } - stateManager.market = "BTC-USD" } private fun prepareIsolatedMarginClosePosition() { @@ -372,7 +373,7 @@ class V4TransactionTests : NetworkTests() { stateManager.trade("2", TradeInputField.targetLeverage) if (isShortTerm) { - stateManager.trade("MARKET", TradeInputField.timeInForceType) + stateManager.trade("MARKET", TradeInputField.type) } else { stateManager.trade("LIMIT", TradeInputField.type) stateManager.trade("GTT", TradeInputField.timeInForceType) @@ -403,6 +404,21 @@ class V4TransactionTests : NetworkTests() { assertEquals(256, transferPayload.destinationSubaccountNumber, "Should have 2 transactions") } + @Test + fun testIsolatedMarginPlaceShortTermOrderTransactions() { + setStateMachineForIsolatedMarginTests(stateManager) + prepareIsolatedMarginTrade(true) + + val orderPayload = subaccountSupervisor?.placeOrderPayload(0) + assertNotNull(orderPayload, "Order payload should not be null") + assertEquals(256, orderPayload.subaccountNumber, "Should be 256 since 0 and 128 are unavailable") + + val transferPayload = subaccountSupervisor?.getTransferPayloadForIsolatedMarginTrade(orderPayload) + assertNotNull(transferPayload, "Transfer payload should not be null") + assertEquals(0, transferPayload.subaccountNumber, "The parent subaccount 0 should be the origin") + assertEquals(256, transferPayload.destinationSubaccountNumber, "Should have 2 transactions") + } + @Test fun testCancelOrderForChildSubaccount() { setStateMachineForIsolatedMarginTests(stateManager) diff --git a/src/commonTest/kotlin/exchange.dydx.abacus/payload/v4/V4ParentSubaccountTests.kt b/src/commonTest/kotlin/exchange.dydx.abacus/payload/v4/V4ParentSubaccountTests.kt index 62f65bb03..05ae61fe7 100644 --- a/src/commonTest/kotlin/exchange.dydx.abacus/payload/v4/V4ParentSubaccountTests.kt +++ b/src/commonTest/kotlin/exchange.dydx.abacus/payload/v4/V4ParentSubaccountTests.kt @@ -82,7 +82,9 @@ class V4ParentSubaccountTests : V4BaseTests(true) { }, "leverage": { "current": -0.12 - } + }, + "subaccountNumber": 0, + "marginMode": "CROSS" } } }, @@ -128,7 +130,9 @@ class V4ParentSubaccountTests : V4BaseTests(true) { }, "buyingPower": { "current": 7962.44 - } + }, + "subaccountNumber": 128, + "marginMode": "ISOLATED" } }, "orders": { @@ -144,7 +148,9 @@ class V4ParentSubaccountTests : V4BaseTests(true) { "timeInForce": "GTT", "postOnly": false, "reduceOnly": false, - "goodTilBlock": "5837" + "goodTilBlock": "5837", + "subaccountNumber": 128, + "marginMode": "ISOLATED" } } } @@ -186,7 +192,9 @@ class V4ParentSubaccountTests : V4BaseTests(true) { }, "leverage": { "current": -0.12 - } + }, + "subaccountNumber": 0, + "marginMode": "CROSS" }, "RUNE-USD": { "id": "RUNE-USD", @@ -229,7 +237,9 @@ class V4ParentSubaccountTests : V4BaseTests(true) { }, "marginUsage": { "current": 0.0397 - } + }, + "subaccountNumber": 128, + "marginMode": "ISOLATED" } }, "pendingPositions": [ diff --git a/v4_abacus.podspec b/v4_abacus.podspec index cfdd72ba9..4bb221e77 100644 --- a/v4_abacus.podspec +++ b/v4_abacus.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = 'v4_abacus' - spec.version = '1.7.35' + spec.version = '1.7.38' spec.homepage = 'https://github.com/dydxprotocol/v4-abacus' spec.source = { :http=> ''} spec.authors = ''