diff --git a/build.gradle.kts b/build.gradle.kts index b9c1df508..77b9302c4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -51,7 +51,7 @@ allprojects { } group = "exchange.dydx.abacus" -version = "1.7.36" +version = "1.7.40" repositories { google() diff --git a/detekt.yml b/detekt.yml index 33960f594..e5142244b 100644 --- a/detekt.yml +++ b/detekt.yml @@ -20,7 +20,7 @@ complexity: LargeClass: threshold: 1000 # up from 600 LongMethod: - threshold: 100 # up from 60 + active: false TooManyFunctions: active: false NestedBlockDepth: 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/output/input/Input.kt b/src/commonMain/kotlin/exchange.dydx.abacus/output/input/Input.kt index c3695b813..c66e75095 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/output/input/Input.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/output/input/Input.kt @@ -1,6 +1,7 @@ package exchange.dydx.abacus.output.input import exchange.dydx.abacus.protocols.ParserProtocol +import exchange.dydx.abacus.state.internalstate.InternalState import exchange.dydx.abacus.state.manager.V4Environment import exchange.dydx.abacus.utils.IList import exchange.dydx.abacus.utils.Logger @@ -39,7 +40,8 @@ data class Input( existing: Input?, parser: ParserProtocol, data: Map<*, *>?, - environment: V4Environment? + environment: V4Environment?, + internalState: InternalState? ): Input? { Logger.d { "creating Input\n" } @@ -50,7 +52,7 @@ data class Input( val closePosition = ClosePositionInput.create(existing?.closePosition, parser, parser.asMap(data["closePosition"])) val transfer = - TransferInput.create(existing?.transfer, parser, parser.asMap(data["transfer"]), environment) + TransferInput.create(existing?.transfer, parser, parser.asMap(data["transfer"]), environment, internalState?.transfer) val triggerOrders = TriggerOrdersInput.create(existing?.triggerOrders, parser, parser.asMap(data["triggerOrders"])) val adjustIsolatedMargin = diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/output/input/TransferInput.kt b/src/commonMain/kotlin/exchange.dydx.abacus/output/input/TransferInput.kt index 8e14b5cba..e094ef997 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/output/input/TransferInput.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/output/input/TransferInput.kt @@ -1,6 +1,7 @@ package exchange.dydx.abacus.output.input import exchange.dydx.abacus.protocols.ParserProtocol +import exchange.dydx.abacus.state.internalstate.InternalTransferInputState import exchange.dydx.abacus.state.manager.CctpConfig.cctpChainIds import exchange.dydx.abacus.state.manager.ExchangeConfig.exchangeList import exchange.dydx.abacus.state.manager.V4Environment @@ -30,7 +31,8 @@ data class DepositInputOptions( internal fun create( existing: DepositInputOptions?, parser: ParserProtocol, - data: Map<*, *>? + data: Map<*, *>?, + internalState: InternalTransferInputState? ): DepositInputOptions? { Logger.d { "creating Deposit Input Options\n" } @@ -39,35 +41,9 @@ data class DepositInputOptions( val needsAddress = parser.asBool(data["needsAddress"]) val needsFastSpeed = parser.asBool(data["needsFastSpeed"]) - var chains: IMutableList? = null - parser.asList(data["chains"])?.let { data -> - chains = iMutableListOf() - for (i in data.indices) { - val item = data[i] - SelectionOption.create( - existing?.chains?.getOrNull(i), - parser, - parser.asMap(item), - )?.let { - chains?.add(it) - } - } - } + val chains: IList? = internalState?.chains?.toIList() ?: iListOf() - var assets: IMutableList? = null - parser.asList(data["assets"])?.let { data -> - assets = iMutableListOf() - for (i in data.indices) { - val item = data[i] - SelectionOption.create( - existing?.assets?.getOrNull(i), - parser, - parser.asMap(item), - )?.let { - assets?.add(it) - } - } - } + val assets: IList? = internalState?.tokens?.toIList() ?: iListOf() var exchanges: IMutableList? = null exchangeList?.let { data -> @@ -118,7 +94,8 @@ data class WithdrawalInputOptions( internal fun create( existing: WithdrawalInputOptions?, parser: ParserProtocol, - data: Map<*, *>? + data: Map<*, *>?, + internalState: InternalTransferInputState?, ): WithdrawalInputOptions? { Logger.d { "creating Withdrawal Input Options\n" } @@ -127,34 +104,9 @@ data class WithdrawalInputOptions( val needsAddress = parser.asBool(data["needsAddress"]) val needsFastSpeed = parser.asBool(data["needsFastSpeed"]) - var chains: IMutableList? = null - parser.asList(data["chains"])?.let { data -> - chains = iMutableListOf() - for (i in data.indices) { - val item = data[i] - SelectionOption.create( - existing?.chains?.getOrNull(i), - parser, - parser.asMap(item), - )?.let { - chains?.add(it) - } - } - } - var assets: IMutableList? = null - parser.asList(data["assets"])?.let { data -> - assets = iMutableListOf() - for (i in data.indices) { - val item = data[i] - SelectionOption.create( - existing?.assets?.getOrNull(i), - parser, - parser.asMap(item), - )?.let { - assets?.add(it) - } - } - } + val chains: IList? = internalState?.chains?.toIList() ?: iListOf() + + val assets: IList? = internalState?.tokens?.toIList() ?: iListOf() var exchanges: IMutableList? = null exchangeList?.let { data -> @@ -260,44 +212,7 @@ data class TransferInputChainResource( val networkName: String?, val chainId: Int?, val iconUrl: String? -) { - companion object { - internal fun create( - existing: TransferInputChainResource?, - parser: ParserProtocol, - data: Map<*, *>? - ): TransferInputChainResource? { - Logger.d { "creating Transfer Input Chain Resource\n" } - - data?.let { - val chainName = parser.asString(data["chainName"]) - val rpc = parser.asString(data["rpc"]) - val networkName = parser.asString(data["networkName"]) - val chainId = parser.asInt(data["chainId"]) - val iconUrl = parser.asString(data["iconUrl"]) - - return if (existing?.chainName != chainName || - existing?.rpc != rpc || - existing?.networkName != networkName || - existing?.chainId != chainId || - existing?.iconUrl != iconUrl - ) { - TransferInputChainResource( - chainName, - rpc, - networkName, - chainId, - iconUrl, - ) - } else { - existing - } - } - Logger.d { "Transfer Input Chain Resource not valid" } - return null - } - } -} +) @JsExport @Serializable @@ -307,44 +222,7 @@ data class TransferInputTokenResource( var symbol: String?, var decimals: Int?, var iconUrl: String? -) { - companion object { - internal fun create( - existing: TransferInputTokenResource?, - parser: ParserProtocol, - data: Map<*, *>? - ): TransferInputTokenResource? { - Logger.d { "creating Transfer Input Token Resource\n" } - - data?.let { - val name = parser.asString(data["name"]) - val address = parser.asString(data["address"]) - val symbol = parser.asString(data["symbol"]) - val decimals = parser.asInt(data["decimals"]) - val iconUrl = parser.asString(data["iconUrl"]) - - return if (existing?.name != name || - existing?.address != address || - existing?.symbol != symbol || - existing?.decimals != decimals || - existing?.iconUrl != iconUrl - ) { - TransferInputTokenResource( - name, - address, - symbol, - decimals, - iconUrl, - ) - } else { - existing - } - } - Logger.d { "Transfer Input Token Resource not valid" } - return null - } - } -} +) @JsExport @Serializable @@ -355,32 +233,13 @@ data class TransferInputResources( companion object { internal fun create( existing: TransferInputResources?, - parser: ParserProtocol, - data: Map<*, *>? + internalState: InternalTransferInputState?, ): TransferInputResources? { Logger.d { "creating Transfer Input Resources\n" } - data?.let { - val chainResourcesMap = parser.asMap(data["chainResources"]) - val chainResources: IMap = - chainResourcesMap?.mapValues { entry -> - TransferInputChainResource.create( - null, - parser, - parser.asMap(entry.value), - ) ?: TransferInputChainResource(null, null, null, null, null) - }?.toIMap() ?: iMapOf() - - val tokenResourcesMap = parser.asMap(data["tokenResources"]) - val tokenResources: IMap = - tokenResourcesMap?.mapValues { - TransferInputTokenResource.create( - null, - parser, - parser.asMap(it.value), - ) ?: TransferInputTokenResource(null, null, null, null, null) - }?.toIMap() ?: iMapOf() - + internalState?.let { + val chainResources: IMap = internalState.chainResources?.toIMap() ?: iMapOf() + val tokenResources: IMap = internalState.tokenResources?.toIMap() ?: iMapOf() return if ( existing?.chainResources != chainResources || existing.tokenResources != tokenResources @@ -632,7 +491,8 @@ data class TransferInput( existing: TransferInput?, parser: ParserProtocol, data: Map<*, *>?, - environment: V4Environment? + environment: V4Environment?, + internalState: InternalTransferInputState? ): TransferInput? { Logger.d { "creating Transfer Input\n" } @@ -656,6 +516,7 @@ data class TransferInput( existing?.depositOptions, parser, parser.asMap(data["depositOptions"]), + internalState, ) } @@ -665,6 +526,7 @@ data class TransferInput( existing?.withdrawalOptions, parser, parser.asMap(data["withdrawalOptions"]), + internalState, ) } @@ -686,8 +548,7 @@ data class TransferInput( val resources = TransferInputResources.create( existing?.resources, - parser, - parser.asMap(data["resources"]), + internalState, ) val route = parser.asMap(data["route"]) diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/processor/router/IRouterProcessor.kt b/src/commonMain/kotlin/exchange.dydx.abacus/processor/router/IRouterProcessor.kt new file mode 100644 index 000000000..a9c7b44b5 --- /dev/null +++ b/src/commonMain/kotlin/exchange.dydx.abacus/processor/router/IRouterProcessor.kt @@ -0,0 +1,51 @@ +package exchange.dydx.abacus.processor.router + +interface IRouterProcessor { + var tokens: List? + var chains: List? + var exchangeDestinationChainId: String? + fun receivedChains( + existing: Map?, + payload: Map + ): Map? + + fun receivedTokens( + existing: Map?, + payload: Map + ): Map? + + fun receivedV2SdkInfo( + existing: Map?, + payload: Map + ): Map? + + fun receivedRoute( + existing: Map?, + payload: Map, + requestId: String?, + ): Map? + + fun receivedRouteV2( + existing: Map?, + payload: Map, + requestId: String? + ): Map? + + fun usdcAmount(data: Map): Double? + fun receivedStatus( + existing: Map?, + payload: Map, + transactionId: String?, + ): Map? + + fun updateTokensDefaults(modified: MutableMap, selectedChainId: String?) + fun defaultChainId(): String? + fun selectedTokenSymbol(tokenAddress: String?): String? + fun selectedTokenDecimals(tokenAddress: String?): String? + fun filteredTokens(chainId: String?): List? + fun defaultTokenAddress(chainId: String?): String? + fun chainResources(chainId: String?): Map? + fun tokenResources(chainId: String?): Map? + fun chainOptions(): List + fun tokenOptions(chainId: String?): List +} diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/processor/squid/SquidChainProcessor.kt b/src/commonMain/kotlin/exchange.dydx.abacus/processor/squid/SquidChainProcessor.kt index 684b9b6a8..a886b0d33 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/processor/squid/SquidChainProcessor.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/processor/squid/SquidChainProcessor.kt @@ -1,22 +1,19 @@ package exchange.dydx.abacus.processor.squid -import exchange.dydx.abacus.processor.base.BaseProcessor +import exchange.dydx.abacus.output.input.SelectionOption import exchange.dydx.abacus.protocols.ParserProtocol -internal class SquidChainProcessor(parser: ParserProtocol) : BaseProcessor(parser) { - private val keyMap = mapOf( - "string" to mapOf( - "chainName" to "stringKey", - "networkIdentifier" to "stringKey", - "chainId" to "type", - "chainIconURI" to "iconUrl", - ), - ) - - override fun received( - existing: Map?, +internal class SquidChainProcessor( + private val parser: ParserProtocol +) { + fun received( payload: Map - ): Map { - return transform(existing, payload, keyMap) + ): SelectionOption { + return SelectionOption( + stringKey = parser.asString(payload["networkIdentifier"]) ?: parser.asString(payload["chainName"]), + string = parser.asString(payload["networkIdentifier"]) ?: parser.asString(payload["chainName"]), + type = parser.asString(payload["chainId"]) ?: "", + iconUrl = parser.asString(payload["chainIconURI"]), + ) } } diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/processor/squid/SquidChainResourceProcessor.kt b/src/commonMain/kotlin/exchange.dydx.abacus/processor/squid/SquidChainResourceProcessor.kt index b090e0593..97c371ad8 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/processor/squid/SquidChainResourceProcessor.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/processor/squid/SquidChainResourceProcessor.kt @@ -1,23 +1,20 @@ package exchange.dydx.abacus.processor.squid -import exchange.dydx.abacus.processor.base.BaseProcessor +import exchange.dydx.abacus.output.input.TransferInputChainResource import exchange.dydx.abacus.protocols.ParserProtocol -internal class SquidChainResourceProcessor(parser: ParserProtocol) : BaseProcessor(parser) { - private val keyMap = mapOf( - "string" to mapOf( - "chainName" to "chainName", - "rpc" to "rpc", - "networkName" to "networkName", - "chainId" to "chainId", - "chainIconURI" to "iconUrl", - ), - ) - - override fun received( - existing: Map?, +internal class SquidChainResourceProcessor( + private val parser: ParserProtocol +) { + fun received( payload: Map - ): Map { - return transform(existing, payload, keyMap) + ): TransferInputChainResource { + return TransferInputChainResource( + chainName = parser.asString(payload["chainName"]), + rpc = parser.asString(payload["rpc"]), + networkName = parser.asString(payload["networkName"]), + chainId = parser.asInt(payload["chainId"]), + iconUrl = parser.asString(payload["chainIconURI"]), + ) } } diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/processor/squid/SquidProcessor.kt b/src/commonMain/kotlin/exchange.dydx.abacus/processor/squid/SquidProcessor.kt index 327d6dafe..be3e69031 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/processor/squid/SquidProcessor.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/processor/squid/SquidProcessor.kt @@ -1,12 +1,19 @@ package exchange.dydx.abacus.processor.squid +import exchange.dydx.abacus.output.input.SelectionOption +import exchange.dydx.abacus.output.input.TransferInputChainResource +import exchange.dydx.abacus.output.input.TransferInputTokenResource import exchange.dydx.abacus.processor.base.BaseProcessor import exchange.dydx.abacus.protocols.ParserProtocol +import exchange.dydx.abacus.state.internalstate.InternalTransferInputState import exchange.dydx.abacus.state.manager.CctpConfig.cctpChainIds import exchange.dydx.abacus.utils.mutable import exchange.dydx.abacus.utils.safeSet -internal class SquidProcessor(parser: ParserProtocol) : BaseProcessor(parser) { +internal class SquidProcessor( + parser: ParserProtocol, + private val internalState: InternalTransferInputState, +) : BaseProcessor(parser) { private var chains: List? = null private var tokens: List? = null var exchangeDestinationChainId: String? = null @@ -26,12 +33,12 @@ internal class SquidProcessor(parser: ParserProtocol) : BaseProcessor(parser) { } val chainOptions = chainOptions() - modified.safeSet("transfer.depositOptions.chains", chainOptions) - modified.safeSet("transfer.withdrawalOptions.chains", chainOptions) + internalState.chains = chainOptions + val selectedChainId = defaultChainId() modified.safeSet("transfer.chain", selectedChainId) selectedChainId?.let { - modified.safeSet("transfer.resources.chainResources", chainResources(selectedChainId)) + internalState.chainResources = chainResources(selectedChainId) } updateTokensDefaults(modified, selectedChainId) @@ -75,12 +82,12 @@ internal class SquidProcessor(parser: ParserProtocol) : BaseProcessor(parser) { } val chainOptions = chainOptions() - modified.safeSet("transfer.depositOptions.chains", chainOptions) - modified.safeSet("transfer.withdrawalOptions.chains", chainOptions) + internalState.chains = chainOptions + val selectedChainId = defaultChainId() modified.safeSet("transfer.chain", selectedChainId) selectedChainId?.let { - modified.safeSet("transfer.resources.chainResources", chainResources(selectedChainId)) + internalState.chainResources = chainResources(selectedChainId) } updateTokensDefaults(modified, selectedChainId) @@ -164,10 +171,9 @@ internal class SquidProcessor(parser: ParserProtocol) : BaseProcessor(parser) { private fun updateTokensDefaults(modified: MutableMap, selectedChainId: String?) { val tokenOptions = tokenOptions(selectedChainId) - modified.safeSet("transfer.depositOptions.assets", tokenOptions) - modified.safeSet("transfer.withdrawalOptions.assets", tokenOptions) + internalState.tokens = tokenOptions modified.safeSet("transfer.token", defaultTokenAddress(selectedChainId)) - modified.safeSet("transfer.resources.tokenResources", tokenResources(selectedChainId)) + internalState.tokenResources = tokenResources(selectedChainId) } internal fun defaultChainId(): String? { @@ -226,43 +232,43 @@ internal class SquidProcessor(parser: ParserProtocol) : BaseProcessor(parser) { } } - internal fun chainResources(chainId: String?): Map? { - val chainResources = mutableMapOf() + internal fun chainResources(chainId: String?): Map? { + val chainResources = mutableMapOf() chainId?.let { this.chains?.find { parser.asString(parser.asNativeMap(it)?.get("chainId")) == chainId }?.let { val processor = SquidChainResourceProcessor(parser) parser.asNativeMap(it)?.let { payload -> - chainResources[chainId] = processor.received(null, payload) + chainResources[chainId] = processor.received(payload) } } } return chainResources } - internal fun tokenResources(chainId: String?): Map? { - val tokenResources = mutableMapOf() + internal fun tokenResources(chainId: String?): Map? { + val tokenResources = mutableMapOf() filteredTokens(chainId)?.forEach { parser.asString(parser.asNativeMap(it)?.get("address"))?.let { key -> val processor = SquidTokenResourceProcessor(parser) parser.asNativeMap(it)?.let { payload -> - tokenResources[key] = processor.received(null, payload) + tokenResources[key] = processor.received(payload) } } } return tokenResources } - private fun chainOptions(): List { + private fun chainOptions(): List { val chainProcessor = SquidChainProcessor(parser) - val options = mutableListOf() + val options = mutableListOf() - this.chains?.let { it -> + this.chains?.let { for (chain in it) { parser.asNativeMap(chain)?.let { chain -> - if (parser.asString(chain.get("chainType")) != "cosmos") { - options.add(chainProcessor.received(null, chain)) + if (parser.asString(chain["chainType"]) != "cosmos") { + options.add(chainProcessor.received(chain)) } } } @@ -272,9 +278,9 @@ internal class SquidProcessor(parser: ParserProtocol) : BaseProcessor(parser) { return options } - internal fun tokenOptions(chainId: String?): List { + internal fun tokenOptions(chainId: String?): List { val processor = SquidTokenProcessor(parser) - val options = mutableListOf() + val options = mutableListOf() val selectedChainId = chainId ?: defaultChainId() selectedChainId?.let { @@ -282,15 +288,15 @@ internal class SquidProcessor(parser: ParserProtocol) : BaseProcessor(parser) { this.tokens?.let { for (token in it) { parser.asNativeMap(token)?.let { token -> - if (parser.asString(token.get("chainId")) == selectedChainId) { - options.add(processor.received(null, token)) + if (parser.asString(token["chainId"]) == selectedChainId) { + options.add(processor.received(token)) } } } } } - options.sortBy { parser.asString(parser.asNativeMap(it)?.get("stringKey")) } + options.sortBy { it.stringKey } return options } } diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/processor/squid/SquidTokenProcessor.kt b/src/commonMain/kotlin/exchange.dydx.abacus/processor/squid/SquidTokenProcessor.kt index 217e769c0..6cf7eb668 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/processor/squid/SquidTokenProcessor.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/processor/squid/SquidTokenProcessor.kt @@ -1,21 +1,19 @@ package exchange.dydx.abacus.processor.squid -import exchange.dydx.abacus.processor.base.BaseProcessor +import exchange.dydx.abacus.output.input.SelectionOption import exchange.dydx.abacus.protocols.ParserProtocol -internal class SquidTokenProcessor(parser: ParserProtocol) : BaseProcessor(parser) { - private val keyMap = mapOf( - "string" to mapOf( - "name" to "stringKey", - "address" to "type", - "logoURI" to "iconUrl", - ), - ) - - override fun received( - existing: Map?, +internal class SquidTokenProcessor( + private val parser: ParserProtocol, +) { + fun received( payload: Map - ): Map { - return transform(existing, payload, keyMap) + ): SelectionOption { + return SelectionOption( + stringKey = parser.asString(payload["name"]), + string = parser.asString(payload["name"]), + type = parser.asString(payload["address"]) ?: "", + iconUrl = parser.asString(payload["logoURI"]), + ) } } diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/processor/squid/SquidTokenResourceProcessor.kt b/src/commonMain/kotlin/exchange.dydx.abacus/processor/squid/SquidTokenResourceProcessor.kt index 26f389a1c..5e3783f1d 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/processor/squid/SquidTokenResourceProcessor.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/processor/squid/SquidTokenResourceProcessor.kt @@ -1,23 +1,20 @@ package exchange.dydx.abacus.processor.squid -import exchange.dydx.abacus.processor.base.BaseProcessor +import exchange.dydx.abacus.output.input.TransferInputTokenResource import exchange.dydx.abacus.protocols.ParserProtocol -internal class SquidTokenResourceProcessor(parser: ParserProtocol) : BaseProcessor(parser) { - private val keyMap = mapOf( - "string" to mapOf( - "name" to "name", - "address" to "address", - "symbol" to "symbol", - "decimals" to "decimals", - "logoURI" to "iconUrl", - ), - ) - - override fun received( - existing: Map?, +internal class SquidTokenResourceProcessor( + private val parser: ParserProtocol +) { + fun received( payload: Map - ): Map { - return transform(existing, payload, keyMap) + ): TransferInputTokenResource { + return TransferInputTokenResource( + name = parser.asString(payload["name"]), + address = parser.asString(payload["address"]), + symbol = parser.asString(payload["symbol"]), + decimals = parser.asInt(payload["decimals"]), + iconUrl = parser.asString(payload["logoURI"]), + ) } } 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/commonMain/kotlin/exchange.dydx.abacus/state/internalstate/InternalState.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/internalstate/InternalState.kt new file mode 100644 index 000000000..34214d499 --- /dev/null +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/internalstate/InternalState.kt @@ -0,0 +1,5 @@ +package exchange.dydx.abacus.state.internalstate + +internal data class InternalState( + val transfer: InternalTransferInputState = InternalTransferInputState(), +) diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/internalstate/InternalTransferInputState.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/internalstate/InternalTransferInputState.kt new file mode 100644 index 000000000..7dc5e6687 --- /dev/null +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/internalstate/InternalTransferInputState.kt @@ -0,0 +1,12 @@ +package exchange.dydx.abacus.state.internalstate + +import exchange.dydx.abacus.output.input.SelectionOption +import exchange.dydx.abacus.output.input.TransferInputChainResource +import exchange.dydx.abacus.output.input.TransferInputTokenResource + +internal data class InternalTransferInputState( + var chains: List? = null, + var tokens: List? = null, + var chainResources: Map? = null, + var tokenResources: Map? = null, +) diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/V4StateManagerAdaptor+Transfer.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/V4StateManagerAdaptor+Transfer.kt index 3be6e2222..ab54bed1b 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/V4StateManagerAdaptor+Transfer.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/V4StateManagerAdaptor+Transfer.kt @@ -73,7 +73,7 @@ internal fun V4StateManagerAdaptor.retrieveDepositExchanges() { internal fun V4StateManagerAdaptor.retrieveDepositRoute(state: PerpetualState?) { val isCctp = state?.input?.transfer?.isCctp ?: false when (appConfigs.squidVersion) { - AppConfigs.SquidVersion.V1, AppConfigs.SquidVersion.V2WithdrawalOnly -> retrieveDepositRouteV1( + AppConfigs.SquidVersion.V2WithdrawalOnly -> retrieveDepositRouteV1( state, ) @@ -273,7 +273,7 @@ internal fun V4StateManagerAdaptor.retrieveWithdrawalRoute( val isCctp = cctpChainIds?.any { it.isCctpEnabled(state?.input?.transfer) } ?: false val isExchange = state?.input?.transfer?.exchange != null when (appConfigs.squidVersion) { - AppConfigs.SquidVersion.V1, AppConfigs.SquidVersion.V2DepositOnly -> retrieveWithdrawalRouteV1( + AppConfigs.SquidVersion.V2DepositOnly -> retrieveWithdrawalRouteV1( state, decimals, gas, diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/V4StateManagerAdaptor.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/V4StateManagerAdaptor.kt index 7142136f0..0920ceaeb 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/V4StateManagerAdaptor.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/V4StateManagerAdaptor.kt @@ -27,8 +27,6 @@ import exchange.dydx.abacus.state.model.onChainRewardTokenPrice import exchange.dydx.abacus.state.model.onChainRewardsParams import exchange.dydx.abacus.state.model.onChainUserFeeTier import exchange.dydx.abacus.state.model.onChainUserStats -import exchange.dydx.abacus.state.model.squidChains -import exchange.dydx.abacus.state.model.squidTokens import exchange.dydx.abacus.state.model.squidV2SdkInfo import exchange.dydx.abacus.state.model.updateHeight import exchange.dydx.abacus.utils.CoroutineTimer @@ -294,20 +292,8 @@ class V4StateManagerAdaptor( override fun didSetReadyToConnect(readyToConnect: Boolean) { super.didSetReadyToConnect(readyToConnect) if (readyToConnect) { - when (appConfigs.squidVersion) { - AppConfigs.SquidVersion.V1 -> { - retrieveTransferChains() - retrieveTransferTokens() - } - - AppConfigs.SquidVersion.V2, - AppConfigs.SquidVersion.V2DepositOnly, - AppConfigs.SquidVersion.V2WithdrawalOnly -> { - retrieveTransferAssets() - retrieveCctpChainIds() - } - } - + retrieveTransferAssets() + retrieveCctpChainIds() retrieveDepositExchanges() bestEffortConnectChain() retrieveLaunchIncentiveSeasons() @@ -737,20 +723,6 @@ class V4StateManagerAdaptor( } } - private fun retrieveTransferChains() { - val oldState = stateMachine.state - val url = configs.squidChains() - val squidIntegratorId = environment.squidIntegratorId - if (url != null && squidIntegratorId != null) { - val header = iMapOf("x-integrator-id" to squidIntegratorId) - get(url, null, header) { _, response, httpCode, _ -> - if (success(httpCode) && response != null) { - update(stateMachine.squidChains(response), oldState) - } - } - } - } - private fun retrieveTransferAssets() { val oldState = stateMachine.state val url = configs.squidV2Assets() @@ -765,20 +737,6 @@ class V4StateManagerAdaptor( } } - private fun retrieveTransferTokens() { - val oldState = stateMachine.state - val url = configs.squidToken() - val squidIntegratorId = environment.squidIntegratorId - if (url != null && squidIntegratorId != null) { - val header = iMapOf("x-integrator-id" to squidIntegratorId) - get(url, null, header) { _, response, httpCode, _ -> - if (success(httpCode) && response != null) { - update(stateMachine.squidTokens(response), oldState) - } - } - } - } - private fun parseHeight(response: String) { val json = parser.decodeJsonObject(response) if (json != null && json["error"] != null) { diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/utils/Settings.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/utils/Settings.kt index 1744f02c9..8eed0e3ba 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/utils/Settings.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/manager/utils/Settings.kt @@ -10,12 +10,11 @@ class AppConfigs( var enableLogger: Boolean = false, ) { enum class SquidVersion { - V1, V2, V2DepositOnly, V2WithdrawalOnly, } - var squidVersion: SquidVersion = SquidVersion.V1 + var squidVersion: SquidVersion = SquidVersion.V2 companion object { val forApp = AppConfigs(subscribeToCandles = true, loadRemote = true) diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/model/TradingStateMachine.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/model/TradingStateMachine.kt index c97b0b406..1dc48e07a 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/model/TradingStateMachine.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/model/TradingStateMachine.kt @@ -45,6 +45,7 @@ import exchange.dydx.abacus.state.app.adaptors.AbUrl import exchange.dydx.abacus.state.app.helper.Formatter import exchange.dydx.abacus.state.changes.Changes import exchange.dydx.abacus.state.changes.StateChanges +import exchange.dydx.abacus.state.internalstate.InternalState import exchange.dydx.abacus.state.manager.BlockAndTime import exchange.dydx.abacus.state.manager.EnvironmentFeatureFlags import exchange.dydx.abacus.state.manager.TokenInfo @@ -81,6 +82,8 @@ open class TradingStateMachine( private val maxSubaccountNumber: Int, private val useParentSubaccount: Boolean, ) { + private val internalState: InternalState = InternalState() + internal val parser: ParserProtocol = Parser() internal val marketsProcessor = MarketsSummaryProcessor(parser) internal val assetsProcessor = run { @@ -90,7 +93,7 @@ open class TradingStateMachine( } internal val walletProcessor = WalletProcessor(parser) internal val configsProcessor = ConfigsProcessor(parser) - internal val squidProcessor = SquidProcessor(parser) + internal val squidProcessor = SquidProcessor(parser, internalState.transfer) internal val rewardsProcessor = RewardsProcessor(parser) internal val launchIncentiveProcessor = LaunchIncentiveProcessor(parser) @@ -1273,7 +1276,7 @@ open class TradingStateMachine( this.environment, ) this.input?.let { - input = Input.create(input, parser, it, environment) + input = Input.create(input, parser, it, environment, internalState) } } } diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/Configs.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/Configs.kt index e1317f371..7fdabee38 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/Configs.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/Configs.kt @@ -164,13 +164,12 @@ data class OnboardingConfigs( val retrieveSquidRoutes: Boolean, ) { enum class SquidVersion { - V1, V2, V2DepositOnly, V2WithdrawalOnly, } - var squidVersion: SquidVersion = SquidVersion.V1 + var squidVersion: SquidVersion = SquidVersion.V2 companion object { val forApp = OnboardingConfigs( diff --git a/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/OnboardingSupervisor.kt b/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/OnboardingSupervisor.kt index 1ba83abd1..8fc8caf1b 100644 --- a/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/OnboardingSupervisor.kt +++ b/src/commonMain/kotlin/exchange.dydx.abacus/state/v2/supervisor/OnboardingSupervisor.kt @@ -24,11 +24,9 @@ import exchange.dydx.abacus.state.manager.HumanReadableWithdrawPayload import exchange.dydx.abacus.state.manager.pendingCctpWithdraw import exchange.dydx.abacus.state.model.TradingStateMachine import exchange.dydx.abacus.state.model.TransferInputField -import exchange.dydx.abacus.state.model.squidChains import exchange.dydx.abacus.state.model.squidRoute import exchange.dydx.abacus.state.model.squidRouteV2 import exchange.dydx.abacus.state.model.squidStatus -import exchange.dydx.abacus.state.model.squidTokens import exchange.dydx.abacus.state.model.squidV2SdkInfo import exchange.dydx.abacus.state.model.transfer import exchange.dydx.abacus.utils.AnalyticsUtils @@ -67,33 +65,8 @@ internal class OnboardingSupervisor( } private fun retrieveSquidRoutes() { - when (configs.squidVersion) { - OnboardingConfigs.SquidVersion.V1 -> { - retrieveTransferChains() - retrieveTransferTokens() - } - - OnboardingConfigs.SquidVersion.V2, - OnboardingConfigs.SquidVersion.V2DepositOnly, - OnboardingConfigs.SquidVersion.V2WithdrawalOnly -> { - retrieveTransferAssets() - retrieveCctpChainIds() - } - } - } - - private fun retrieveTransferChains() { - val oldState = stateMachine.state - val url = helper.configs.squidChains() - val squidIntegratorId = helper.environment.squidIntegratorId - if (url != null && squidIntegratorId != null) { - val header = iMapOf("x-integrator-id" to squidIntegratorId) - helper.get(url, null, header) { _, response, httpCode, _ -> - if (helper.success(httpCode) && response != null) { - update(stateMachine.squidChains(response), oldState) - } - } - } + retrieveTransferAssets() + retrieveCctpChainIds() } private fun retrieveTransferAssets() { @@ -110,20 +83,6 @@ internal class OnboardingSupervisor( } } - private fun retrieveTransferTokens() { - val oldState = stateMachine.state - val url = helper.configs.squidToken() - val squidIntegratorId = helper.environment.squidIntegratorId - if (url != null && squidIntegratorId != null) { - val header = iMapOf("x-integrator-id" to squidIntegratorId) - helper.get(url, null, header) { _, response, httpCode, _ -> - if (helper.success(httpCode) && response != null) { - update(stateMachine.squidTokens(response), oldState) - } - } - } - } - private fun retrieveCctpChainIds() { val url = "${helper.deploymentUri}/configs/cctp.json" helper.get(url) { _, response, _, _ -> @@ -176,7 +135,7 @@ internal class OnboardingSupervisor( ) { val isCctp = state?.input?.transfer?.isCctp ?: false when (configs.squidVersion) { - OnboardingConfigs.SquidVersion.V1, OnboardingConfigs.SquidVersion.V2WithdrawalOnly -> retrieveDepositRouteV1( + OnboardingConfigs.SquidVersion.V2WithdrawalOnly -> retrieveDepositRouteV1( state, accountAddress, sourceAddress, @@ -530,7 +489,7 @@ internal class OnboardingSupervisor( CctpConfig.cctpChainIds?.any { it.isCctpEnabled(state?.input?.transfer) } ?: false val isExchange = state?.input?.transfer?.exchange != null when (configs.squidVersion) { - OnboardingConfigs.SquidVersion.V1, OnboardingConfigs.SquidVersion.V2DepositOnly -> retrieveWithdrawalRouteV1( + OnboardingConfigs.SquidVersion.V2DepositOnly -> retrieveWithdrawalRouteV1( state, decimals, gas, diff --git a/src/commonTest/kotlin/exchange.dydx.abacus/app/manager/V4ForegroundCycleTests.kt b/src/commonTest/kotlin/exchange.dydx.abacus/app/manager/V4ForegroundCycleTests.kt index 329cfa37a..c01fa1639 100644 --- a/src/commonTest/kotlin/exchange.dydx.abacus/app/manager/V4ForegroundCycleTests.kt +++ b/src/commonTest/kotlin/exchange.dydx.abacus/app/manager/V4ForegroundCycleTests.kt @@ -86,8 +86,8 @@ class V4ForegroundCycleTests : NetworkTests() { "https://indexer.v4staging.dydx.exchange/v4/time", "https://api.examples.com/configs/markets.json", "https://api.dydx.exchange/v4/geo", - "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/chains", - "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/tokens", + "https://testnet.v2.api.squidrouter.com/v2/sdk-info", + "https://api.examples.com/configs/cctp.json", "https://api.examples.com/configs/exchanges.json", "https://indexer.v4staging.dydx.exchange/v4/height", "https://dydx.exchange/v4-launch-incentive/query/ccar-perpetuals" @@ -169,8 +169,8 @@ class V4ForegroundCycleTests : NetworkTests() { "https://indexer.v4staging.dydx.exchange/v4/time", "https://api.examples.com/configs/markets.json", "https://api.dydx.exchange/v4/geo", - "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/chains", - "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/tokens", + "https://testnet.v2.api.squidrouter.com/v2/sdk-info", + "https://api.examples.com/configs/cctp.json", "https://api.examples.com/configs/exchanges.json", "https://indexer.v4staging.dydx.exchange/v4/height", "https://dydx.exchange/v4-launch-incentive/query/ccar-perpetuals", @@ -221,8 +221,8 @@ class V4ForegroundCycleTests : NetworkTests() { "https://indexer.v4staging.dydx.exchange/v4/time", "https://api.examples.com/configs/markets.json", "https://api.dydx.exchange/v4/geo", - "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/chains", - "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/tokens", + "https://testnet.v2.api.squidrouter.com/v2/sdk-info", + "https://api.examples.com/configs/cctp.json", "https://api.examples.com/configs/exchanges.json", "https://indexer.v4staging.dydx.exchange/v4/height", "https://dydx.exchange/v4-launch-incentive/query/ccar-perpetuals", @@ -261,8 +261,8 @@ class V4ForegroundCycleTests : NetworkTests() { "https://indexer.v4staging.dydx.exchange/v4/time", "https://api.examples.com/configs/markets.json", "https://api.dydx.exchange/v4/geo", - "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/chains", - "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/tokens", + "https://testnet.v2.api.squidrouter.com/v2/sdk-info", + "https://api.examples.com/configs/cctp.json", "https://api.examples.com/configs/exchanges.json", "https://indexer.v4staging.dydx.exchange/v4/height", "https://dydx.exchange/v4-launch-incentive/query/ccar-perpetuals", @@ -325,8 +325,8 @@ class V4ForegroundCycleTests : NetworkTests() { "https://indexer.v4staging.dydx.exchange/v4/time", "https://api.examples.com/configs/markets.json", "https://api.dydx.exchange/v4/geo", - "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/chains", - "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/tokens", + "https://testnet.v2.api.squidrouter.com/v2/sdk-info", + "https://api.examples.com/configs/cctp.json", "https://api.examples.com/configs/exchanges.json", "https://indexer.v4staging.dydx.exchange/v4/height", "https://dydx.exchange/v4-launch-incentive/query/ccar-perpetuals", @@ -378,8 +378,8 @@ class V4ForegroundCycleTests : NetworkTests() { "https://indexer.v4staging.dydx.exchange/v4/time", "https://api.examples.com/configs/markets.json", "https://api.dydx.exchange/v4/geo", - "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/chains", - "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/tokens", + "https://testnet.v2.api.squidrouter.com/v2/sdk-info", + "https://api.examples.com/configs/cctp.json", "https://api.examples.com/configs/exchanges.json", "https://indexer.v4staging.dydx.exchange/v4/height", "https://dydx.exchange/v4-launch-incentive/query/ccar-perpetuals", @@ -461,8 +461,8 @@ class V4ForegroundCycleTests : NetworkTests() { "https://indexer.v4staging.dydx.exchange/v4/time", "https://api.examples.com/configs/markets.json", "https://api.dydx.exchange/v4/geo", - "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/chains", - "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/tokens", + "https://testnet.v2.api.squidrouter.com/v2/sdk-info", + "https://api.examples.com/configs/cctp.json", "https://api.examples.com/configs/exchanges.json", "https://indexer.v4staging.dydx.exchange/v4/height", "https://dydx.exchange/v4-launch-incentive/query/ccar-perpetuals", @@ -509,8 +509,8 @@ class V4ForegroundCycleTests : NetworkTests() { "https://indexer.v4staging.dydx.exchange/v4/time", "https://api.examples.com/configs/markets.json", "https://api.dydx.exchange/v4/geo", - "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/chains", - "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/tokens", + "https://testnet.v2.api.squidrouter.com/v2/sdk-info", + "https://api.examples.com/configs/cctp.json", "https://api.examples.com/configs/exchanges.json", "https://indexer.v4staging.dydx.exchange/v4/height", "https://dydx.exchange/v4-launch-incentive/query/ccar-perpetuals", @@ -590,8 +590,8 @@ class V4ForegroundCycleTests : NetworkTests() { "https://indexer.v4staging.dydx.exchange/v4/time", "https://api.examples.com/configs/markets.json", "https://api.dydx.exchange/v4/geo", - "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/chains", - "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/tokens", + "https://testnet.v2.api.squidrouter.com/v2/sdk-info", + "https://api.examples.com/configs/cctp.json", "https://api.examples.com/configs/exchanges.json", "https://indexer.v4staging.dydx.exchange/v4/height", "https://dydx.exchange/v4-launch-incentive/query/ccar-perpetuals", diff --git a/src/commonTest/kotlin/exchange.dydx.abacus/app/manager/v2/V4ForegroundCycleTests.kt b/src/commonTest/kotlin/exchange.dydx.abacus/app/manager/v2/V4ForegroundCycleTests.kt index ea722cc71..19ca16e76 100644 --- a/src/commonTest/kotlin/exchange.dydx.abacus/app/manager/v2/V4ForegroundCycleTests.kt +++ b/src/commonTest/kotlin/exchange.dydx.abacus/app/manager/v2/V4ForegroundCycleTests.kt @@ -103,8 +103,8 @@ class V4ForegroundCycleTests : NetworkTests() { // "https://api.examples.com/configs/documentation.json", // "https://indexer.v4staging.dydx.exchange/v4/time", // "https://api.examples.com/configs/markets.json", -// "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/chains", -// "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/tokens", +// "https://testnet.v2.api.squidrouter.com/v2/sdk-info", +// "https://api.examples.com/configs/cctp.json", // "https://api.examples.com/configs/exchanges.json", // "https://indexer.v4staging.dydx.exchange/v4/height", // "https://dydx.exchange/v4-launch-incentive/query/ccar-perpetuals" @@ -117,8 +117,8 @@ class V4ForegroundCycleTests : NetworkTests() { "https://indexer.v4staging.dydx.exchange/v4/height", "https://api.examples.com/configs/markets.json", "https://dydx.exchange/v4-launch-incentive/query/ccar-perpetuals", - "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/chains", - "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/tokens", + "https://testnet.v2.api.squidrouter.com/v2/sdk-info", + "https://api.examples.com/configs/cctp.json", "https://api.examples.com/configs/exchanges.json", "https://api.dydx.exchange/v4/geo" ] @@ -193,21 +193,6 @@ class V4ForegroundCycleTests : NetworkTests() { ) compareExpectedRequests( -// """ -// [ -// "https://api.examples.com/configs/documentation.json", -// "https://indexer.v4staging.dydx.exchange/v4/time", -// "https://api.examples.com/configs/markets.json", -// "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/chains", -// "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/tokens", -// "https://api.examples.com/configs/exchanges.json", -// "https://indexer.v4staging.dydx.exchange/v4/height", -// "https://dydx.exchange/v4-launch-incentive/query/ccar-perpetuals", -// "https://indexer.v4staging.dydx.exchange/v4/sparklines?timePeriod=ONE_DAY", -// "https://indexer.v4staging.dydx.exchange/v4/historicalFunding/ETH-USD", -// "https://indexer.v4staging.dydx.exchange/v4/candles/perpetualMarkets/ETH-USD?resolution=1DAY" -// ] -// """.trimIndent(), """ [ "https://api.examples.com/configs/documentation.json", @@ -215,8 +200,8 @@ class V4ForegroundCycleTests : NetworkTests() { "https://indexer.v4staging.dydx.exchange/v4/height", "https://api.examples.com/configs/markets.json", "https://dydx.exchange/v4-launch-incentive/query/ccar-perpetuals", - "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/chains", - "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/tokens", + "https://testnet.v2.api.squidrouter.com/v2/sdk-info", + "https://api.examples.com/configs/cctp.json", "https://api.examples.com/configs/exchanges.json", "https://api.dydx.exchange/v4/geo", "https://indexer.v4staging.dydx.exchange/v4/sparklines?timePeriod=ONE_DAY", @@ -265,8 +250,8 @@ class V4ForegroundCycleTests : NetworkTests() { // "https://api.examples.com/configs/documentation.json", // "https://indexer.v4staging.dydx.exchange/v4/time", // "https://api.examples.com/configs/markets.json", -// "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/chains", -// "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/tokens", +// "https://testnet.v2.api.squidrouter.com/v2/sdk-info", +// "https://api.examples.com/configs/cctp.json", // "https://api.examples.com/configs/exchanges.json", // "https://indexer.v4staging.dydx.exchange/v4/height", // "https://dydx.exchange/v4-launch-incentive/query/ccar-perpetuals", @@ -285,8 +270,8 @@ class V4ForegroundCycleTests : NetworkTests() { "https://indexer.v4staging.dydx.exchange/v4/height", "https://api.examples.com/configs/markets.json", "https://dydx.exchange/v4-launch-incentive/query/ccar-perpetuals", - "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/chains", - "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/tokens", + "https://testnet.v2.api.squidrouter.com/v2/sdk-info", + "https://api.examples.com/configs/cctp.json", "https://api.examples.com/configs/exchanges.json", "https://api.dydx.exchange/v4/geo", "https://indexer.v4staging.dydx.exchange/v4/sparklines?timePeriod=ONE_DAY", @@ -323,8 +308,8 @@ class V4ForegroundCycleTests : NetworkTests() { // "https://api.examples.com/configs/documentation.json", // "https://indexer.v4staging.dydx.exchange/v4/time", // "https://api.examples.com/configs/markets.json", -// "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/chains", -// "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/tokens", +// "https://testnet.v2.api.squidrouter.com/v2/sdk-info", +// "https://api.examples.com/configs/cctp.json", // "https://api.examples.com/configs/exchanges.json", // "https://indexer.v4staging.dydx.exchange/v4/height", // "https://dydx.exchange/v4-launch-incentive/query/ccar-perpetuals", @@ -340,8 +325,8 @@ class V4ForegroundCycleTests : NetworkTests() { "https://indexer.v4staging.dydx.exchange/v4/height", "https://api.examples.com/configs/markets.json", "https://dydx.exchange/v4-launch-incentive/query/ccar-perpetuals", - "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/chains", - "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/tokens", + "https://testnet.v2.api.squidrouter.com/v2/sdk-info", + "https://api.examples.com/configs/cctp.json", "https://api.examples.com/configs/exchanges.json", "https://api.dydx.exchange/v4/geo", "https://indexer.v4staging.dydx.exchange/v4/sparklines?timePeriod=ONE_DAY", @@ -404,8 +389,8 @@ class V4ForegroundCycleTests : NetworkTests() { "https://indexer.v4staging.dydx.exchange/v4/height", "https://api.examples.com/configs/markets.json", "https://dydx.exchange/v4-launch-incentive/query/ccar-perpetuals", - "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/chains", - "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/tokens", + "https://testnet.v2.api.squidrouter.com/v2/sdk-info", + "https://api.examples.com/configs/cctp.json", "https://api.examples.com/configs/exchanges.json", "https://api.dydx.exchange/v4/geo", "https://indexer.v4staging.dydx.exchange/v4/screen?address=0xsecondaryFakeAddress", @@ -457,8 +442,8 @@ class V4ForegroundCycleTests : NetworkTests() { "https://indexer.v4staging.dydx.exchange/v4/height", "https://api.examples.com/configs/markets.json", "https://dydx.exchange/v4-launch-incentive/query/ccar-perpetuals", - "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/chains", - "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/tokens", + "https://testnet.v2.api.squidrouter.com/v2/sdk-info", + "https://api.examples.com/configs/cctp.json", "https://api.examples.com/configs/exchanges.json", "https://api.dydx.exchange/v4/geo", "https://indexer.v4staging.dydx.exchange/v4/screen?address=cosmos1fq8q55896ljfjj7v3x0qd0z3sr78wmes940uhm", @@ -566,8 +551,8 @@ class V4ForegroundCycleTests : NetworkTests() { "https://indexer.v4staging.dydx.exchange/v4/height", "https://api.examples.com/configs/markets.json", "https://dydx.exchange/v4-launch-incentive/query/ccar-perpetuals", - "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/chains", - "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/tokens", + "https://testnet.v2.api.squidrouter.com/v2/sdk-info", + "https://api.examples.com/configs/cctp.json", "https://api.examples.com/configs/exchanges.json", "https://api.dydx.exchange/v4/geo", "https://indexer.v4staging.dydx.exchange/v4/screen?address=cosmos1fq8q55896ljfjj7v3x0qd0z3sr78wmes940uhm", @@ -614,8 +599,8 @@ class V4ForegroundCycleTests : NetworkTests() { "https://indexer.v4staging.dydx.exchange/v4/height", "https://api.examples.com/configs/markets.json", "https://dydx.exchange/v4-launch-incentive/query/ccar-perpetuals", - "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/chains", - "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/tokens", + "https://testnet.v2.api.squidrouter.com/v2/sdk-info", + "https://api.examples.com/configs/cctp.json", "https://api.examples.com/configs/exchanges.json", "https://api.dydx.exchange/v4/geo", "https://indexer.v4staging.dydx.exchange/v4/screen?address=cosmos1fq8q55896ljfjj7v3x0qd0z3sr78wmes940uhm", @@ -695,8 +680,8 @@ class V4ForegroundCycleTests : NetworkTests() { "https://indexer.v4staging.dydx.exchange/v4/height", "https://api.examples.com/configs/markets.json", "https://dydx.exchange/v4-launch-incentive/query/ccar-perpetuals", - "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/chains", - "https://squid-api-git-main-cosmos-testnet-0xsquid.vercel.app/v1/tokens", + "https://testnet.v2.api.squidrouter.com/v2/sdk-info", + "https://api.examples.com/configs/cctp.json", "https://api.examples.com/configs/exchanges.json", "https://api.dydx.exchange/v4/geo", "https://indexer.v4staging.dydx.exchange/v4/screen?address=cosmos1fq8q55896ljfjj7v3x0qd0z3sr78wmes940uhm", 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/src/commonTest/kotlin/exchange.dydx.abacus/payload/v4/V4SquidTests.kt b/src/commonTest/kotlin/exchange.dydx.abacus/payload/v4/V4SquidTests.kt index a17f7c6f4..00c93356f 100644 --- a/src/commonTest/kotlin/exchange.dydx.abacus/payload/v4/V4SquidTests.kt +++ b/src/commonTest/kotlin/exchange.dydx.abacus/payload/v4/V4SquidTests.kt @@ -235,11 +235,10 @@ class V4SquidTests : V4BaseTests() { val stateChange = perp.squidChains(mock.squidChainsMock.payload) assertNotNull(stateChange) - val result = parser.asMap(perp.squidProcessor.chainResources("1"))!! - val resource = parser.asMap(result["1"])!! - assertTrue(resource.keys.size == 5) - assertTrue(resource["chainId"] == "1") // Ethereum - assertTrue(resource["chainName"] == "Ethereum") // Ethereum + val result = perp.squidProcessor.chainResources("1") + val resource = result?.get("1") + assertTrue(resource?.chainId == 1) // Ethereum + assertTrue(resource?.chainName == "Ethereum") // Ethereum } @Test 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 = ''