SPB Git

spb/os-vault Public

Self-custody, multi-chain crypto wallet for macOS. One recovery phrase, six chain families, zero API keys — nothing leaves your Mac.

Swift 96% Shell 3.4% Makefile 0.6%
3.1 KB · 75 lines swift
Raw Blame History
1import Foundation23public struct TokenSwapInfo: BufferLayout, Equatable, Hashable, Encodable {4    public static var BUFFER_LENGTH: UInt64 = 32456    public let version: UInt87    public let isInitialized: Bool8    public let nonce: UInt89    public let tokenProgramId: PublicKey10    public var tokenAccountA: PublicKey11    public var tokenAccountB: PublicKey12    public let tokenPool: PublicKey13    public var mintA: PublicKey14    public var mintB: PublicKey15    public let feeAccount: PublicKey16    public let tradeFeeNumerator: UInt6417    public let tradeFeeDenominator: UInt6418    public let ownerTradeFeeNumerator: UInt6419    public let ownerTradeFeeDenominator: UInt6420    public let ownerWithdrawFeeNumerator: UInt6421    public let ownerWithdrawFeeDenominator: UInt6422    public let hostFeeNumerator: UInt6423    public let hostFeeDenominator: UInt6424    public let curveType: UInt825    public let payer: PublicKey26}2728extension TokenSwapInfo: BorshCodable {29    public func serialize(to writer: inout Data) throws {30        try version.serialize(to: &writer)31        if isInitialized { try UInt8(1).serialize(to: &writer) } else { try UInt8(0).serialize(to: &writer) }32        try nonce.serialize(to: &writer)33        try tokenProgramId.serialize(to: &writer)34        try tokenAccountA.serialize(to: &writer)35        try tokenAccountB.serialize(to: &writer)36        try tokenPool.serialize(to: &writer)37        try mintA.serialize(to: &writer)38        try mintB.serialize(to: &writer)39        try feeAccount.serialize(to: &writer)40        try tradeFeeNumerator.serialize(to: &writer)41        try tradeFeeDenominator.serialize(to: &writer)42        try ownerTradeFeeNumerator.serialize(to: &writer)43        try ownerTradeFeeDenominator.serialize(to: &writer)44        try ownerWithdrawFeeNumerator.serialize(to: &writer)45        try ownerWithdrawFeeDenominator.serialize(to: &writer)46        try hostFeeNumerator.serialize(to: &writer)47        try hostFeeDenominator.serialize(to: &writer)48        try curveType.serialize(to: &writer)49        try payer.serialize(to: &writer)50    }5152    public init(from reader: inout BinaryReader) throws {53        version = try .init(from: &reader)54        isInitialized = try UInt8(from: &reader) == 155        nonce = try .init(from: &reader)56        tokenProgramId = try PublicKey(from: &reader)57        tokenAccountA = try PublicKey(from: &reader)58        tokenAccountB = try PublicKey(from: &reader)59        tokenPool = try PublicKey(from: &reader)60        mintA = try PublicKey(from: &reader)61        mintB = try PublicKey(from: &reader)62        feeAccount = try PublicKey(from: &reader)63        tradeFeeNumerator = try .init(from: &reader)64        tradeFeeDenominator = try .init(from: &reader)65        ownerTradeFeeNumerator = try .init(from: &reader)66        ownerTradeFeeDenominator = try .init(from: &reader)67        ownerWithdrawFeeNumerator = try .init(from: &reader)68        ownerWithdrawFeeDenominator = try .init(from: &reader)69        hostFeeNumerator = try .init(from: &reader)70        hostFeeDenominator = try .init(from: &reader)71        curveType = try .init(from: &reader)72        payer = try PublicKey(from: &reader)73    }74}75